Retired Documents Library Developer
Search

Next: , Previous: RS/6000 and PowerPC Pragmas, Up: Pragmas


5.53.4 Darwin Pragmas

The following pragmas are available for all architectures running the Darwin operating system. These are useful for compatibility with other Mac OS compilers.

mark tokens...
This pragma is accepted, but has no effect.
options align=alignment
This pragma sets the alignment of fields in structures. The values of alignment may be mac68k, to emulate m68k alignment, or power, to emulate PowerPC alignment. Uses of this pragma nest properly; to restore the previous setting, use reset for the alignment.

The power setting, when compiling for the Intel target, does not fully emulate the alignments on native PowerPC targets. When the first field within a struct is of type double, this causes the struct to be 8-byte aligned on PowerPC target, but only 4-byte aligned on Intel target. When such a struct is nested within another aggregate, differing layouts on the two targets can occur. In such a case, a dummy field char : 0; can be inserted before the double to achieve the same layout on both targets.

segment tokens...
This pragma is accepted, but has no effect.
unused (var [, var]...)
This pragma declares variables to be possibly unused. GCC will not produce warnings for the listed variables. The effect is similar to that of the unused attribute, except that this pragma may appear anywhere within the variables' scopes.
optimization_level { 0 | 1 | 2 | 3 | reset }
optimize_for_size { on | off | reset }
GCC optimization_level { 0 | 1 | 2 | 3 | reset }
GCC optimize_for_size { on | off | reset }
(These pragmas are APPLE ONLY.)

These pragmas set the current optimization level, similar but not identical to -O0 through -O3, or -Os, on the command line. These pragmas form a stack; the "reset" argument pops the stack, restoring the optimization level to what it was before the previous optimization pragma. The optimization level in effect at the beginning of each function definition is applied to that function. Currently, the pragmas will not affect optimizations whose implementation is based on whole-file analysis; this notably includes inlining and strict aliasing. Also, the feature currently doesn't apply to functions whose body is within a class definition (that is, such functions are compiled with the command line options).

The versions without "GCC" have the same syntax and similar effect as CodeWarrior pragmas (although since the optimizations performed by the compilers are not identical, the effect of the options won't be either). These may be convenient for existing code. The versions with "GCC" are recommended for new code.