-rewrite-objc和clang中的Objective-C [英] -rewrite-objc and Objective-C in clang
问题描述
最近,我有一个问题。铛可以使用-rewrite-objc将Objective-C转换为c ++。
所以我认为,第一步。 clang将Objective-C编译为C ++。然后只能使用c ++编译器进行编译。这样吗?
clang首先使用运行时将Objective-C转换为C ++,然后编译为机器代码?
Recently, I have one problem. The clang can translate Objective-C to c++ use -rewrite-objc. So I think, the first step. clang compile Objective-C to C++. And then compile only can use c++ compiler. Is it do like this? clang first translate Objective-C to C++ with runTime, and then compile to the machine code?
推荐答案
-rewrite-objc
可以将ObjC转换为C ++,因此可以在Visual Studio中对其进行编译。它仍然是Objective-C语义,您仍然需要Objective-C运行时。并不是将Objective-C神奇地转换为C ++ OO体系结构。
-rewrite-objc
exists to translate ObjC to C++ so it can be compiled in the Visual Studio. It is still Objective-C semantics and you still need the objective-c runtime. It is not magically converting Objective-C to the C++ OO architecture.
这更像是将Objective-C实现为预编译器扩展。
This is much more like when Objective-C was implemented as a pre-compiler extension.
所有这些都依赖于以下事实:Objective-C类只是具有奇特行为的C结构,而objective-c方法调用都可以转换为对 objc_msgSend的调用()
。
It all relies on the fact that Objective-C classes are just C structures with fancy behavior and objective-c method calls all can be translated to calls to objc_msgSend()
.
这篇关于-rewrite-objc和clang中的Objective-C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!