nestlog: + ex2 + expand README.md
This commit is contained in:
parent
7bfde708dd
commit
c32699ae14
4 changed files with 96 additions and 5 deletions
|
|
@ -8,6 +8,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
|
|||
#include(cmake/FindSphinx.cmake)
|
||||
|
||||
add_subdirectory(ex1)
|
||||
add_subdirectory(ex2)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# make standard directories for std:: includes explicit
|
||||
|
|
|
|||
3
example/ex2/CMakeLists.txt
Normal file
3
example/ex2/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
add_executable(ex2 ex2.cpp)
|
||||
|
||||
target_include_directories(ex2 PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
||||
27
example/ex2/ex2.cpp
Normal file
27
example/ex2/ex2.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* examples ex2/ex2.cpp */
|
||||
|
||||
#include "nestlog/scope.hpp"
|
||||
|
||||
int
|
||||
fib(int n) {
|
||||
XO_SCOPE(log);
|
||||
|
||||
int retval = 1;
|
||||
|
||||
if (n >= 2)
|
||||
retval = fib(n - 1) + fib(n - 2);
|
||||
|
||||
log("result ", ":retval ", retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char ** argv) {
|
||||
XO_SCOPE(log);
|
||||
|
||||
int n = 4;
|
||||
int fn = fib(n);
|
||||
|
||||
log(":n ", n, " :fib(n) ", fn);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue