重複の可能性:
#ifdefと#ifndefの役割
しますか
#ifndef _WIN32
32ビットWindowsプラットフォームのコードを省略するようにcppに指示しますか?
#ifndef _WIN32
#endif
_WIN32 が定義されていない場合、対応する までその下のコードを含めるようにプリプロセッサに指示します。
#ifndef _WIN32
#define STR1 "Some String"
#endif
_WIN32 が定義されていない場合はマクロ STR1 が含まれ、_WIN32 が定義されている場合は含まれません。_WIN32 はシステム定義のマクロであることに注意してください。一般に、Windows プラットフォーム向けではないコード、または一般的で Windows でコンパイルできないコードは、そのような #ifndef _WIN32 マクロの下に配置されます。
MSDN ページによると、_WIN32 はすべての 32 ビットおよび 64 ビット ビルドに対してデフォルトで定義されます。
このディレクティブは、「_WIN32 マクロが定義されている場合は、このコードを含めないでください」という意味です。Win32 用にコンパイルするときにのみマクロ _WIN32 を定義する場合、このコードは「cpp に 32 ビット Windows プラットフォームのコードを省略するように指示します」。
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.