문제

I have the source code for a video decoder which is written in C. The code was successfully compiled and executed on MAC terminal (which uses GCC compiler). Now I'm trying to create an application on Xcode with the same source code. Only the GUI for the application is written in Objective-C.

When I tried to execute on Xcode (which uses LLVM compiler), I'm getting a lot of errors in the C code. The only other compiler option that Xcode provides is LLVM GCC 4.2. I compiled using that and found that it is not able to recognize the code written in Objective-C.

Is there any compiler that can be used for both Objective-C and C? Can GCC 4.2 compiler be used for compiling Objective-C code?

How to tell Xcode to compile using GCC 4.2 compiler?

Kindly help. Thanks in advance!

도움이 되었습니까?

해결책

Both LLVM and GCC can be used to compile C, C++ and Objective-C code.

My guess is that some compiler flags are set incorrectly.

다른 팁

Objective-C is a strict superset of ANSI C, so any compiler that can compile Objective-C code can also compile (ANSI) C code. If your library does not use standard C, then you might run into problems.

The same is true for Objective-C++, which is a strict superset of C++.

If, like in your case, you have a conflicting typedef in your header file, you can use conditional compilation to hide the typedef when compiling Objective-C code:

#ifndef __OBJC__
typedef unsigned char BOOL;
#endif
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top