English 中文(简体)
如何在带有 Xcode 的 C++ 库中使用 `Iphone_ 4_ 0 定义?
原标题:How to use __IPHONE_4_0 definition in a C++ library with 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 develop a library in C++ and use the same code in iOS and Android (both as native compilation). I am only with the iOS implementation, and I have done a sample application with the 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

因此,问题在于句子“#ifdef_Iphone_4_0” 。 如果我使用它, Xcode 找不到包含的文件, 但是如果我对所有的 if lalusule (和机器人部分) 进行评论, Xcode 可以找到所有的文件 。

#warning sentences shows that the compiler is reading the iphone part (with and without lines commented) in compilation time. Do I need to use the definition in other way?

提前感谢!

最佳回答

检查此文章 < a href=" "https://stackoverflow.com/ questions/5919996/ how-to- detect- reliable-mac-os-x-ios-ios-linux- windows-in- c- preceror" > 如何检测可靠的Mac OS X、iOS、Linux、C预处理器中的窗口?

此外,据我所知, iOs 4. 0 SDK 中只定义了 iphone_ 4_ 0 宏。 因此, 如果您使用另一个版本的 SDK, 代码不应该有效 。

另一种方法是在 Xcode 项目构建设置( 预处理器宏字段) 中定义您自己的宏, 并命名为 IOS_ BUILD, 例如。 它将以 - 目标- c 和 c++ 代码同时提供 。

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签