nestlog: + ex2 + expand README.md

This commit is contained in:
Roland Conybeare 2023-09-11 16:24:46 -04:00
commit c32699ae14
4 changed files with 96 additions and 5 deletions

View file

@ -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

View 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
View 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);
}