Does C have an equivalent to the开发者_Python百科 Obj c #pragma mark?
Objective-C is a superset of C. #pragma
directives are part of the C standard, so they also exist in Objective-C also.
There are only a handful of #pragma
directives that are actually standardised, but, any conforming compiler is supposed to ignore #pragma
directives that it doesn't understand.
The problem though, is that “legally” the same #pragma
directive can cause two conforming implementations to behave differently.
In any case, if you are writing C code using Xcode, then you can use #pragma mark
for organisation; just keep in mind that it may decrease portability.
Each compiler and IDE will support a different set of #pragma
directives. You'll have to investigate which are available with your toolset. If you are using Xcode for C, it sounds like it will still work.
I keep my C code organized by grouping related functions in different source files.
For example, string files are in "zstr.c"; big numbers are in "big.c"; ..., and I keep header files with the prototypes of the functions defined: "zstr.h", "big.h", ...
I haven't felt the need to use the #pragma mechanism (or any other beside the directory/file mechanisn of the OS) to help my organisation of code.
精彩评论