# Finding What OS I'm Compiling On

This topic is 3785 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm hoping to be able to compile my framework on multiple platforms without any code change. Since it will be a DLL on Windows, I need to test whether to add "__declspec(dllexport)" based on what OS the framework is being compiled on. Is there a define in one of the standard headers that has what OS that the compiling is happening on? Or something like that? I'm hoping to do some #ifdef things to include/not include declspec.

##### Share on other sites
Oh, I see. Thanks!

##### Share on other sites
Okay, I looked in the SDL header to see what it did, and came up with this:

#if defined(__WIN32__)#define DECLSPEC __declspec(dllexport)#define DECLSPEC#endif#else

It acts as though __WIN32__ is not defined though, because the #define __declspec(dllexport) line is gray. I'm using Visual C++ 2005 Express. Is this the correct macro?

##### Share on other sites
Quote:
 Original post by UphoreumIt acts as though __WIN32__ is not defined though, because the #define __declspec(dllexport) line is gray. I'm using Visual C++ 2005 Express. Is this the correct macro?

The greyed out code feature of VS2005 doesn't work great. I found it only worked correctly about 50% of the time. Just turn it off.

Are you finding that the code isn't actually compiling correctly or are you just basing the "it's not working" off of what VS2005 is telling you with its font coloring?

-me

##### Share on other sites
If you read the page I linked to you'd find that __WIN32__ is defined by Borland, which isn't MSVC 2005. Try _WIN32.

##### Share on other sites
I think you want the "#else" between the two "#define"s:

#if defined(__WIN32__)#define DECLSPEC __declspec(dllexport)#else#define DECLSPEC#endif

##### Share on other sites
Oops, sorry, I did a little copy/paste, but somehow pasted in the wrong place. That's why it was backwards.

Yep, _WIN32 worked. Sorry about not reading the page, I had seen __WIN32__ in the SDL headers earlier and decided that must be it, but it wasn't.