some_id
some_id

Reputation: 29886

C equivalent to #pragma in Obj-C

Does C have an equivalent to the Obj c #pragma mark?

Upvotes: 0

Views: 464

Answers (3)

dreamlax
dreamlax

Reputation: 95355

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.

Upvotes: 2

pmg
pmg

Reputation: 108978

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.

Upvotes: -1

Ned Batchelder
Ned Batchelder

Reputation: 375734

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.

Upvotes: 2

Related Questions