How to determine C code is compiled for Android/NDK or iOS

孤街醉人 提交于 2019-12-05 16:54:50

问题


I am reusing a legacy C library in an iOS app and in an Android app. I want to customize some macro definitions (e.g. for logging). Are there standard defines to check for (using #ifdef) whether the code is being compiled for iOS or Android/NDK?


回答1:


__ANDROID__ or ANDROID for Android (compilation with the NDK) and __APPLE__ on Apple platforms (iOS or OSX)




回答2:


you should consider creating two separate projects for those platforms with separate output/bin directories but shared source code. Then you just set some define in project properties for android and ios so you can recognize it when compiling



来源:https://stackoverflow.com/questions/4345405/how-to-determine-c-code-is-compiled-for-android-ndk-or-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!