tags:

views:

91

answers:

2

Hello,

I am compiling under linux (GCC 4.4.2) and windows VS C++ Express Edition 2008

I am currently compiling under windows XP Pro 32bit, and have added this to my source code.

#if defined( WIN32 )
/* Do windows stuff here */
#endif

However, the code in the if statement is disabled (grayed out). However if I do the following:

#if defined( _MSC_VER )
/* Do windows stuff here */
#endif

The if statement code is enabled.

I am just wondering, what should I be using. I have seen many programmers use WIN32. However, doesn't seem to work for me. Should I be using _MSC_VER instead?

Many thanks for any advice,

+1  A: 

Use _WIN32 instead. The IntelliSense parser in VS2008 is troublesome, this might not necessarily solve your problem. It got a complete rewrite in VS2010.

Hans Passant
+1  A: 

There is no WIN32. If you've seen it being used elsewhere, it's either wrong or the code is explicitly defining that macro itself somewhere.

You want _WIN32. See http://msdn.microsoft.com/en-us/library/b0084kay(VS.80).aspx for a list of predefined macros in Microsoft's compiler.

jamesdlin