c++ - How do I turn off functions that are used to print debug data in the program -
so there several functions in c++ program "dump" data. has immensly helped me troubleshoot developed application. data dumped dozen ascii files.
now want these functions not dump data can see how fast program can run , also, have "final version" of program.
do functions:
#define do_debug #ifdef do_debug void dump_dataa(...) { // lot of code } #else void dump_dataa(...) { return; } #endif
i thinking along these lines since cannot go , remove lines dump data onto std::out , ascii files. not seem idea. since if have upgrade program later, lines me. best way "turn off" functions dumping debug data?
your way possible, arguments evaluated, , implementation should visible (in header). may use preprocessor follow:
#define do_debug #ifdef do_debug void dump_dataa_impl(/*args*/); // implement in cpp file or in header # define dump_dataa(...) dump_dataa_impl(__va_args__) #else # define dump_dataa(...) /* empty */ #endif
Comments
Post a Comment