How to use the __IPHONE_4_0 definition in a C ++ library using Xcode?

I am trying to develop a C ++ library for an iOS application. This library loads the GLES and OpenAL functions. The idea is to create a C ++ library and use the same code in iOS and Android (as as a built-in compilation). I am only with the implementation of iOS, and I made a sample application with a library, and I have this block inside the library:

#ifdef _IPHONE_4_0

    #warning "Including iPhone SDK 4.0 working here" // compiling warning is actived

    #include <OpenGLES / ES2 / gl.h>
    #include <OpenGLES / ES2 / glext.h>

    #include <OpenAL / al.h>
    #include <OpenAL / alc.h>

    ...

#elif __ANDROID_API_ // Android

    #warning "Including Android working here" // Compiling warning is not actived
        ...

#endif

So, the problem is with the sentence "#ifdef _IPHONE_4_0". If I use it, Xcode cannot find the include files, but if I comment on all the if clauses (part of android too), Xcode can find all of them.

#warning sentences show that the compiler reads part of the iphone (with comments and no lines) at compile time. Should the definition be used in a different way?

Thanks in advance!

+3
source share
1 answer

Check this box. How to reliably detect Mac OS X, iOS, Linux, Windows in the C preprocessor?

, , __IPHONE_4_0 iOS 4.0 SDK. , SDK.

- Xcode ( ) IOS_BUILD, . objective-c, ++

+1

All Articles