Sign in to follow this  
Uphoreum

Finding What OS I'm Compiling On

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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Uphoreum
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?


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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this