ios - #pragma objective-c : can you have more than just 'mark' ?

标签 ios objective-c pragma

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

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

最佳答案

首先,举几个例子:

  1. 您可以控制诊断:

    http://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas

  2. 来自同一个链接:

    • 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 代码。

  3. 维基百科 [ 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/

相关文章:

c++ - C++ #pragma 预处理器可以/应该驻留在函数中吗

ios - swift #pragma 替换来删除生产和开发中的代码(即 #if TEST_CODE == 1)?

javascript - 苹果浏览器 : drag on element with click handler sometimes triggers click outside of element

ios - GPUImage混合图像和视频会崩溃,从而释放了帧缓冲区

objective-c - 以编程方式调用 segue 原因 NSInvalidArgumentException,原因 : 'UILabel length' unrecognized selector

c - 私有(private)变量与减少 OMP

ios - CABasicAnimation 持续时间和保持图层位置

ios - 在 iphone 上同时进行调试和发布构建

android - 在 Woocommerce Rest API 调用中按多个属性及其属性术语过滤产品列表

objective-c - NSFetchedResultsController - 严重的应用程序错误