How would I combine C and Objective-C in the same file? - objective-c

I'm trying to make a Lua compiler for Mac OSX with an interface written in Objective-C and the Lua source code written in C.

You already are combining C and Objective C. No extra effort is needed.

Objective-C is a proper superset of C. Any C you write in an Objective-C file is perfectly valid.

Related

How to call D functions from Objective C?

How could it be possible to call D functions from Objective C? Is such a bridge even possible?
D has limited Objective-C support already: https://dlang.org/spec/objc_interface.html
This thread explains how to do the same from C++: Calling a D function directly from C++
I guess it should not be difficult to do the same from Objective-C code.
Since Objective-C still has all the C stuff, they could call each others functions through the extern(C) interface too, reducing the problem to the solved issue of calling D functions from C.

Mixing C and Objective-C and effects

I am new to Objective-C and I am wondering if it is possible to mix C and pure Objective-C freely. If so, does it have any effects on my program?
Objective-C is a strict superset of C thus C code is a subset of Objective-C code so all C code is also Objective-C code.
Thus you can include any C code in Objective-C.

Can clang or gcc convert Objective C code into plain C?

I'd like to convert Objective C code into plain C. I can do this by hand rather easily. For example this Objective C code:
[object method];
could be converted to something like:
SEL method = sel_registerName("method");
objc_msgSend(object, method);
However this is kind of tedious, especially for larger files. It seems clang should be able to generate this C code pretty easily. Is there a way I can convince it to do so?
Short answer: No.
Longer answer: clang supports -rewrite-objc, but you are almost certainly not going to like the results.

Does every Objective C program get converted to C code?

Since Objective-C is basically an extension of C, Does the code get converted to pure C code before it is compiled to native code ?
If so, does the conversion happens on RAM or a temporary file containing C code on disk is created by the compiler which is further compiled by C compiler to native code ?
That Objective-C syntax is an extension of C syntax does not mean that it could not have its own compiler. C++ is the same way - its syntax is compatible with C (for the most part, anyway) but it has its own set of tools. Compilers for C, C++, and Objective-C can reuse parts of each other for preprocessing, syntactic analysis and code generation, but there is not need to run them sequentially (e.g. Objective-C ==> C ==> Target code). Compilers no longer go through human-readable assembly language, either (this has been the case for a very long time, too).
No, Objective-C gets compiled to assembler directly (assuming GCC).

How could be diff(X) converted to OpenCV or Objective C?

How could be differentiation implemented within XCode Objective C or OpenCV ? (diff(BWImage) in matlab that is http://www.mathworks.com/help/techdoc/ref/diff.html)
You don't need to implement it, it is already done, that's what cv::Sobel does. http://opencv.willowgarage.com/documentation/cpp/imgproc_image_filtering.html#cv-sobel