我熟悉 #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 once
。
最后,这是一个指向 clang API documentation 的链接pragma
处理代码。您可以从那里浏览以查看其他所有内容。特别是,TokenKinds.def 描述了所有接受的 token ,因此大概是完整的:
#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
中找到, 似乎表明并非所有这些都已实现,即使前端接受了它们也是如此。
关于ios - #pragma objective-c : can you have more than just 'mark' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17089908/