質問

I'm using on xcode a configuration to compile source as Objective-C++, but I added a Library and I want compile it as Objective-C, have a way to do it?

my config:

//:configuration = Debug
CLANG_CXX_LIBRARY = libstdc++

//:configuration = Release
CLANG_CXX_LIBRARY = libstdc++

//:completeSettings = some
GCC_C_LANGUAGE_STANDARD
CLANG_CXX_LIBRARY
GCC_CW_ASM_SYNTAX

//:configuration = Debug
CLANG_CXX_LIBRARY = libstdc++
GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp

//:configuration = Release
CLANG_CXX_LIBRARY = libstdc++
GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp

//:completeSettings = some
GCC_C_LANGUAGE_STANDARD
CLANG_CXX_LIBRARY
GCC_CW_ASM_SYNTAX
GCC_INPUT_FILETYPE
役に立ちましたか?

解決

I don't recommend what you've done here. Rather than changing the global default it is much better to name your files correctly (.m for ObjC and .mm for ObjC++, '.cpp' for C++). If for some reason this is impossible, then you can select individual files to override. Select them in your Files list, open the inspector and in the Identity and Type field select the File Type that you want for each. It should be possible to reset individual files back to ObjC this way, but I recommend leaving the default alone and overriding where absolutely required.

It is not a good practice to compile most of your code as ObjC++. It is not a well-supported language. It is intended as glue between ObjC and pure C++. ObjC++ carries a lot of overhead and incurs performance penalties at compile time and runtime (it also uses more memory at runtime than either ObjC or C++). It is the least supported by the debugger and other tools. You certainly should not make it your default language. See Wrapping C++ Final Edition for more on the subject.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top