ios – #pragma objective-c:你能不只是’标记’?

我熟悉#pragma mark objective-c / xcode / ios开发,它对于查找代码段很有用.

但是,我想知道除了’mark’之外是否还有其他关键字.比如,你能做#pragma somethingelse吗?提前致谢!

解决方法

首先,一些例子:

>您可以控制诊断:

http://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas
>并从同一个链接

  • clang supports the Microsoft “#pragma pack” feature for controlling record layout. GCC also contains support for this feature,however where MSVC and GCC are incompatible clang follows the MSVC deFinition.

  • clang supports the Microsoft #pragma comment(lib,"foo.lib") feature for automatically linking against the specified library. Currently this feature only works with the Visual C++ linker.

  • clang supports the Microsoft #pragma comment(linker,"/flag:foo") feature for adding linker flags to COFF object files. The user is responsible for ensuring that the linker understands the flags.

但是,该列表中的第二个和第三个不适用于您的iOS代码.
>维基百科[link]说clang也支持#pragma一次.

最后,这是一个链接clang API documentation的pragma处理代码.您可以从那里浏览以查看其他所有内容.特别是,TokenKinds.def描述了所有被接受的令牌,因此可能是完整的:

#pragma unused
#pragma GCC visibility [push/pop]
#pragma pack [value/show/push/pop/etc/etc/etc]
#pragma clang __debug parser_crash
#pragma clang __debug captured
#pragma ms_struct [on/off]
#pragma align [native/natural/mac68k/power/reset]
#pragma weak [identifier]
#pragma weak [identifier = identifier] // alias
#pragma redefine_extname [identifier identifier]
#pragma STDC FP_CONTRACT
#pragma OPENCL EXTENSION
#pragma omp [...]
#pragma detect_mismatch
#pragma comment

解析代码(见于ParsePragma.cpp)似乎表明并非所有这些代码都已实现,即使前端接受它们也是如此.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...