更新时间:2023-02-16 23:41:50
您的问题是,你有.h文件被包含在C ++文件,和/或包括在其中。为了做你想要的所有你使用的类c ++需要保持所有obj相关的东西在一个#ifdef或只是不公开任何obj c头文件。
Your problem is that you have .h files that are being included by C++ files that have objective c type and/or includes in them. In order to do what you want all of your classes that are used by c++ need to either keep all obj c related stuff in an #ifdef or simply not expose anything obj c in the header file.
例如,您可以在标题中使用此ifdef:
For example, you can use this ifdef in your header:
#ifdef __OBJC__
// Objective C / C++ code here
#endif
重要的是记住.h文件是 以及头文件,因此它们实际上包括在内。如果在.cpp文件中包含目标c代码,编译器就会感到困惑和哭泣。
It's important to remember that .h files are includes as well as header files, so they are actually included. If you include objective c code in a .cpp file the compiler gets confused and cries.
编辑:最重要的事情要记住,你需要确保任何目标c头文件(或其他具有目标c代码的文件)不包括在cpp文件中。如果你能做到这一点,你会很好。
The most important thing to remember is that you need to ensure that any objective c header files (or other files with objective c code) are not included from the cpp files. If you can do that you'll be fine.