# Thread: _WINDOWS_ not getting defined

1. ## _WINDOWS_ not getting defined

Hi Guys,
I have this piece of code...but somehow even after including windows.h, _WINDOW_ is not getting defines.
The below code compiles just fine ;(

Code:
```#include <Windows.h>
#include <iostream>
using namespace std;

int main()
{
#ifdef _WINDOWS_
123
#endif
cout << "Hello world" << endl;
return 0;
}```
Any help will really be appreciated.

Thanks

2. SourceForge.net: Operating Systems - predef
Perhaps because _WINDOWS_ isn't a flag that is set by anybody.
Where did you get the idea that this symbol was declared?

The usual test is
#ifdef _WIN32

3. Also that's c++ code... in the C forum.

4. Originally Posted by Salem
SourceForge.net: Operating Systems - predef
Perhaps because _WINDOWS_ isn't a flag that is set by anybody.
Where did you get the idea that this symbol was declared?

The usual test is
#ifdef _WIN32
Well thats the first statement in windows.h file sitting under include directory. Is this the correct file then, getting included from:
C:\Program Files\Microsoft Visual Studio 8\VC\include\

5. Maybe somewhere else, there is #undef _WINDOWS_ as well.

_WIN32 is usually pre-declared as a defined symbol by your IDE, so I'd go with that.

Thread moved to platform specific issues.

6. Originally Posted by Salem
Maybe somewhere else, there is #undef _WINDOWS_ as well.

_WIN32 is usually pre-declared as a defined symbol by your IDE, so I'd go with that.

Thread moved to platform specific issues.
Actually it does gets defined....my problem was that I was including windows.h before stdafx.h on VC.
Thanks for all the responses...i guess i have many more stupid ones coming