Possible Duplicate:
the role of #ifdef and #ifndef
Does
#ifndef _WIN32
instruct the cpp to omit the code for 32 bit windows platform ?
Possible Duplicate:
the role of #ifdef and #ifndef
Does
#ifndef _WIN32
instruct the cpp to omit the code for 32 bit windows platform ?
#ifndef _WIN32
tells the pre-processor to include the code below it till a corresponding #endif
, if _WIN32 is not defined.
#ifndef _WIN32
#define STR1 "Some String"
#endif
The macro STR1 will get included if _WIN32 is not defined and will not get included if _WIN32 is defined. Please note that _WIN32 is a system defined macro. Generally, the code which is not meant for Windows platform or which is generic and cannot be compiled in Windows is placed under such #ifndef _WIN32 macros.
The MSDN page says _WIN32 will be defined by default for all 32 bit and 64 bit builds.
This directive means "don't include this code when _WIN32 macro defined". If you define macro _WIN32 only when compile for the Win32 then this code "instruct the cpp to omit the code for 32 bit windows platform".
Well it is a preprocessor directive. It is called compilation constants.
Compiler will consider the piece of code under those #ifndef if the compilation constant(such as, _WIN32) is not defined.
I believe above explanation will help you resolving your query.
To be more specific,
#ifndef _WIN32
...
...
...
some code
...
...
...
#endif
here if you have not defined _WIN32 (such as #define _WIN32) then the code within that #if...#endif will be compiled.
hope it helps.