Syntax
#pragma option options #pragma option push options #pragma option pop #pragma nopushoptwarn
Description
Use #pragma option to include command-line options within your program code. #pragma option can also be used with the push or pop arguments.
#pragma option [options...]
options can be any command-line option (except those listed in the following paragraph). Any number of options can appear in one directive. For example, both of the following are valid:
#pragma option -C #pragma option -C -A
Any of the toggle options (such as -a or -K) can be turned on and off as on the command line. For these toggle options, you can also put a period following the option to return the option to its command-line, configuration file, or option-menu setting. This allows you to temporarily change an option, and then return it to its default, without having to remember (or even needing to know) what the exact default setting was.
Options that cannot appear in a pragma option include:
B |
c |
dname |
Dname=string |
efilename |
E |
Fx |
h |
Ifilename |
lexset |
M |
o |
P |
Q |
S |
T |
Uname |
V |
X |
Y |
|
Efilename |
f |
i# |
m* |
npath |
ofilename |
U |
W |
z |
*
Other options can be changed anywhere. The following options will only affect the compiler if they get changed between functions or object declarations:
1 |
h |
r |
2 |
k |
rd |
A |
N |
v |
Ff |
O |
y |
G |
p |
Z |
The following options can be changed at any time and take effect immediately:
A |
gn |
zE |
b |
jn |
zF |
C |
K |
zH |
d |
wxxx |
|
The options can appear followed by a dot (.) to reset the option to its command-line state.
#pragma option using push or pop
The #pragma option directive can also be used with the push and pop arguments to enable you to easily modify compiler directives.
Using the #pragma option push allows you to save all (or a selected subset of) options before including any files that could potentially change many compiler options and warnings, and then, with the single statement, #pragma option pop, return to the previous state. For example:
#pragma option push #include <theworld.h> #pragma option pop #include "mystuff.h"
The #pragma option push directive first pushes all compiler options and warning settings on a stack and then handles any options (if supplied). The following examples show how the #pragma option push can be used with or without options:
#pragma option push -C -A #pragma option push
The #pragma option pop directive changes compiler options and warnings by popping the last set of options and warnings from the stack. It gives a warning, "Pragma option pop with no matching option push", if the stack is empty, in which case nothing happens.
The following generates a warning about an empty stack:
#pragma option push #pragma option pop #pragma option pop /* Warning */
We do not recommend it, but you can turn off this warning with the directive: #pragma warn -nop.
If you try to specify any options after pop, you get the error, "Nothing allowed after pragma option pop." For example, the following produces an error:
#pragma option pop -C/* ERROR */
If your stack of pushed options is not the same at the start of a file as at the end of a file, you receive a warning: "Previous options and warnings not restored." To turn off this warning, use the directive, #pragma nopushoptwarn .
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|