If I create a c file and add this to the top.
#import <GLKit/GLKit.h>
I get a bunch of strange errors. This is the case if I import any objective C file. I have seen nothing about this in other questions/answers. Everyone seems to suggest that C and Objective C work seamlessly together!
gl.h
Unknown type name 'GLenum'; did you mean 'enum'?
GLKNamedEffect.h
Expected identifier or '('
If you rename your c file from
something.ctosomething.m, you should be able to use:within your file. Now, if you do that, the resulting file will be an Objective-C file and will need an Objective-C compiler to be compiled, hence the need to specify the
.mextension.In other words, Objective-C is a language built on top of C. So you “mix” their syntaxes, so to speak but only the Objective-C compiler will be able to compile the mix. The C compiler will know nothing about ObjC.
By changing the extension of your file, you are in a way choosing the compiler, and you can have a “plain C” file which imports an Objective-C header and calls into some Objective-C library.