从.m(Objective-C)文件生成.c源 [英] Generate .c source from a .m (Objective-C) file
本文介绍了从.m(Objective-C)文件生成.c源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用GCC或Clang(或其他工具)从Objective-C源文件(.m)生成C源文件(.c)?
Is it possible to generate a C source file (.c) from an Objective-C source file (.m), using, maybe, GCC or Clang (or another tool)?
推荐答案
不,但你可能对C ++重写器感兴趣。给定一个目标C文件,让我们说:
No, but you may be interested in the C++ rewriter. Given an objective-C file, let's say:
#import <stdio.h>
int main() {
void (^blk)(void) = ^{
printf("hi");
};
blk();
return 0;
}
您可以使用
clang -rewrite-objc main.c
这是很好看的如何实现objective-C。大多数文件将只是C.
which is great to see how objective-C is implemented. Most of the file will be just C.
一些结果表达式是密集的。您需要耐心,C知识和 Objective-C运行时参考。 http://cdecl.org/ 有助于小件。
Some of the resulting expressions are dense. You'll need patience, C knowledge, and the Objective-C Runtime Reference. http://cdecl.org/ helps with small pieces.
这篇关于从.m(Objective-C)文件生成.c源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文