Does Objective-C compile to native code or byte-code?

前端 未结 4 1055
孤独总比滥情好
孤独总比滥情好 2021-02-14 09:58

On OS X, does Objective-C compile to native code or byte-code?

Can Objective-C programs be compiled on Linux?

4条回答
  •  终归单人心
    2021-02-14 10:39

    Objective-C is compiled to native code by either GCC or LLVM[*]. You can compile ObjC programs on Linux (the generic GCC will happily support ObjC, though it uses a different runtime library than either of the Apple ones). For a cross-platform API similar to Cocoa (i.e. derived from Cocoa) which will happily work on Linux and let you port some code between OS X and Linux, check out GNUstep: http://www.gnustep.org

    [*]In fact, LLVM internally compiles the Objective-C to an internal bitcode representation, then to code for the target machine, so perhaps the answer is "both"…

提交回复
热议问题