項目中添加C語言文件后編譯出現(xiàn)大量錯誤,因為工程中有pch文件,作為預編譯頭文件,Objective-C和C都會引用到它,而里面都是Objective-C代碼,C編譯器是編譯不了的,所以就出現(xiàn)了大量錯誤。
the pch is included as a prefix into both C and ObjC files. So my C files were getting Foundation.h which of course would never work :)
所以要在pch文件中加上:
#ifdef __OBJC__
#import ...
#endif
屏蔽C對它的引用。
參考鏈接