Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#ifdef _DEBUG in main function

Does #ifdef _DEBUG in the main function has any sense if I am working on visual studio 2013 ?

If yes, what it is for ?

int _tmain(int argc, _TCHAR* argv[])
{
#ifdef _DEBUG

//creating some objects, using  functions etc;

#endif
}
like image 335
davoid Avatar asked Mar 25 '15 15:03

davoid


1 Answers

#ifdef DEBUG or #ifdef _DEBUG are used to handle some code that you use for debugging purposes. If you add #undef _DEBUG or similar to this at the very beginning of your code, the compiler will skip the code contained in #ifdef DEBUG /* bla bla */ #endif.

If you're

//creating some objects, using functions etc;

inside this block and thinking this will work, I assure you, it won't until you include -D_DEBUG in compiler's options during invocation.

like image 82
ForceBru Avatar answered Oct 03 '22 00:10

ForceBru