I am familiar with #pragma mark objective-c / xcode / ios development and that it is useful for finding sections of code.
However, I am wondering if there are other keywords other than 'mark'. Like, can you do #pragma somethingelse? Thanks in advance!
First, some examples:
You can control diagnostics:
http://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas
And from the same link:
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.
The second and third from that list won't apply to your iOS code, though.
Wikipedia [link] says that clang supports #pragma once
, too.
And finally, here's a link to the clang API documentation for the pragma
handling code. You can browse from there to see everything else. In particular, TokenKinds.def describes all the accepted tokens, so presumably it's complete:
#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
The parsing code, found in ParsePragma.cpp
, seems to indicate that not all of them are implemented, even if the front-end accepts them, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With