Platform Macros not working?

I was trying to build my app in Android using Cygwin.

One of my source files contain the line #if (CC_TARGET_PLATFORM!=CC_PLATFORM_WIN32) to properly use includes as I code on Visual Studio. It was workign fine before but for some unknown reason, it always goes to the #else branch, even though it’s compiling for Android.

Here’s the full snippet of the infected part:

#if (CC_TARGET_PLATFORM!=CC_PLATFORM_WIN32)
    #include 
    #include 
    #include 
    #include 
#else
    #include "dirent_win/dirent.h"
#endif

Any thoughts on this?

Working here in 2.1.2, building Cygwin inside Win7.

This is even weirder than I thought. On Visual Studio 2012, I changed the code to something like this:

#if (CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID)
    #include 
    #include 
    #include 
    #include 
#elif (CC_TARGET_PLATFORM==CC_PLATFORM_WIN32)
    #include "dirent_win/dirent.h" 
#else
    // Nothing to do here
#endif

For some reason, it compiles the #if (CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID) branch. What gives?

I’ll try re-downloading the sources and see if it still persists.

Same happened to me right now. Not sure why yet.
Using Virtual Studio 2010 and cocos2d-x 2.1.5.
The project I’m building was created with version “2.1.4”’s project creator python script; don’t know if this has something to do or not, but I think it shouldn’t.

May be you forgot to include cocos2d.h before using this macro!

4 Likes

Thanks @owl929! That was exactly my error.

Thanks ! That resolved ! :blush:

thanks,i resolved too。

Thanks @owl929, I was searching and searching and searching and the solution is, as usual, so trivial, if one knows what’s going on :slight_smile: