Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to obtain an intermediate C code from Objective-C?

As I understand correctly, besides the fact that Objective-C language is a strict superset of a "clean" C, added OOP paradigm is simulated by a set of functions partially described in Objective-C Runtime Reference.

Therefore, I'm expecting a possibility to somehow compile Objective-C code in an intermediate C/C++ file (maybe with some asm inserts).

Is it generally possible ?

like image 419
Martin Babacaev Avatar asked May 05 '11 16:05

Martin Babacaev


Video Answer


2 Answers

You could use the clang rewriter to convert to C++. Not aware of a way to go to C though.

The rewriter is available via the "-rewrite-objc" command line option.

like image 159
Catfish_Man Avatar answered Sep 29 '22 22:09

Catfish_Man


As far as I know, there is no software that preprocesses Objective-C code into intermediate C code.

But you could write your Objective-C program entirely in C by calling directly into the Objective-C runtime. The trouble is just that the code might vary between implementations or even different versions of the same runtime.

The question is, is it actually worth the trouble?

like image 35
onitake Avatar answered Sep 29 '22 22:09

onitake