![]() |
#ifdef APP_DEBUG
Hi All,
I have seen a lot of C++ codes have the following: #ifdef APP_DEBUG <pirntf statement> #endif Can you please explain when/how to make these printf statement inside the #ifdef executed. Where I can define APP_DEBUG to be true so the printf statement will be executed. This is C++ on Linux box Thanks, JP |
http://www.fredosaurus.com/notes-cpp...sor/ifdef.html
http://www.cprogramming.com/tutorial/cpreprocessor.html Quote:
|
Hi,
Thanks for the answer but Is there anyway that I can set the variable at command prompt for APP_DEBUG and export that variable to make APP_DEBUG become TRUE so the printf statement will be executed. If I add #define APP_DEBUG TRUE then I need to recompile the code again and I don't want to do that. Thanks JP |
Well, that pragma is surely designed for the programmer.. not the user. Programmers get used to recompiling.
Did you read the links? |
Quote:
You can also re-make the stuff by defining this at the command line like "make -DDEBUG" (or whatever the macro is called on your program). If you intend to implement debug stuff that can be accesible by the user, you should be looking at adding one parameter to your program. Then read it in main, if the given param is enabled, then printf whatever. |
Quote:
Also, that google link is how to use command line arguments with C++.. |
All times are GMT -5. The time now is 04:54 AM. |