With #pragma, Borland C++ can define the directives it wants without interfering with other compilers that support #pragma. If the compiler doesn't recognize directive-name, it ignores the #pragma directive without any error or warning message.
Borland C++ supports the following #pragma directives:
The codeseg directive lets you name the segment, class, or group where functions are allocated. If the pragma is used without any of its options arguments, the default code segment is used for function allocation.
The comment directive lets you write a comment record into an output file. The comment type can be one of the following values:
Value Explanation
exestr The linker writes string into an .OBJ file. Your specified string is placed in the executable file. Such a string is never loaded into memory but can be found in the executable file by use of a suitable file search utility.
lib Writes a comment record into an .OBJ file. The comment record is used by the linker as a library-search directory. A library module that is not specified in the linker's response-file can be specified by the comment LIB directive. The linker includes the library module name specified in string as the last library. Multiple modules can be named and linked in the order in which they are named.
user The compiler writes string into the .OBJ file. The specified string is ignored by the linker.
These two pragmas allow the program to specify function(s) that should be called either upon program startup (before the main function is called), or program exit (just before the program terminates through _exit).
The specified function-name must be a previously declared function taking no arguments and returning void; in other words, it should be declared as:
void func(void);
The optional priority parameter should be an integer in the range 64 to 255. The highest priority is 0. Functions with higher priorities are called first at startup and last at exit. If you don't specify a priority, it defaults to 100.
Note: Priorities from 0 to 63 are used by the C libraries, and should not be used by the user.
This directive sets the name of the file in which to store precompiled headers.
If you aren't using precompiled headers, this directive has no effect. You can use the command-line compiler option -H=filename or Use Precompiled Headers to change the name of the file used to store precompiled headers.
This directive terminates the list of header files eligible for precompilation. You can use it to reduce the amount of disk space used by precompiled headers.
Use #pragma message to specify a user-defined message within your program code.
The first form requires that the text consist of one or more string constants, and the message must be enclosed in parentheses. (This form is compatible with MSC.) The second form uses the text following the #pragma for the text of the warning message. With both forms of the #pragma, any macro references are expanded before the message is displayed.
Display of user-defined messages is on by default and can be turned on or off with the User-Defined Warnings (Options|Project|Messages|General) in the IDE. This option corresponds to the 16/32 bit compiler's -wmsg switch.
Use #pragma option to include command-line options within your program code.
options can be any command-line option (except those listed in the following paragraph). Any number of options can appear in one directive. 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, 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:
Before the use of any macro name that begins with two underscores (and is therefore a possible built-in macro) in an #if, #ifdef, #ifndef or #elif directive.
Before the occurrence of the first real token (the first C or C++ declaration).
Certain command-line options can appear only in a #pragma option command before these events. These options are:
-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.
The saveregs pragma guarantees that a huge function will not change the value of any of the registers when it is entered. This directive is sometimes needed for interfacing with assembly language code. The directive should be placed immediately before the function definition. It applies to that function alone.
The saveregs pragma guarantees that a huge function will not change the value of any of the registers when it is entered. This directive is sometimes needed for interfacing with assembly language code. The directive should be placed immediately before the function definition. It applies to that function alone.
These two pragmas allow the program to specify function(s) that should be called either upon program startup (before the main function is called), or program exit (just before the program terminates through _exit).
The specified function-name must be a previously declared function taking no arguments and returning void; in other words, it should be declared as:
void func(void);
The optional priority parameter should be an integer in the range 64 to 255. The highest priority is 0. Functions with higher priorities are called first at startup and last at exit. If you don't specify a priority, it defaults to 100.
Note: Priorities from 0 to 63 are used by the C libraries, and should not be used by the user.
PRAGMAs are directions to the compiler. They are compiler dependent. They are used to select optimisation levels (optimise code generation for speed/ size of the excecutable), and many others.
: Any one who knows more abt the PRAGMA Preprocessor directive pls give me full details abt that.
: PRAGMAs are directions to the compiler. They are compiler dependent. They are used to select optimisation levels (optimise code generation for speed/ size of the excecutable), and many others.
:
:
: : Any one who knows more abt the PRAGMA Preprocessor directive pls give me full details abt that.
: With #pragma, Borland C++ can define the directives it wants without interfering with other compilers that support #pragma. If the compiler doesn't recognize directive-name, it ignores the #pragma directive without any error or warning message.
: Borland C++ supports the following #pragma directives:
: The codeseg directive lets you name the segment, class, or group where functions are allocated. If the pragma is used without any of its options arguments, the default code segment is used for function allocation.
: The comment directive lets you write a comment record into an output file. The comment type can be one of the following values:
:
: Value Explanation
:
: exestr The linker writes string into an .OBJ file. Your specified string is placed in the executable file. Such a string is never loaded into memory but can be found in the executable file by use of a suitable file search utility.
: lib Writes a comment record into an .OBJ file. The comment record is used by the linker as a library-search directory. A library module that is not specified in the linker's response-file can be specified by the comment LIB directive. The linker includes the library module name specified in string as the last library. Multiple modules can be named and linked in the order in which they are named.
:
: user The compiler writes string into the .OBJ file. The specified string is ignored by the linker.
: These two pragmas allow the program to specify function(s) that should be called either upon program startup (before the main function is called), or program exit (just before the program terminates through _exit).
: The specified function-name must be a previously declared function taking no arguments and returning void; in other words, it should be declared as:
:
: void func(void);
:
: The optional priority parameter should be an integer in the range 64 to 255. The highest priority is 0. Functions with higher priorities are called first at startup and last at exit. If you don't specify a priority, it defaults to 100.
:
: Note: Priorities from 0 to 63 are used by the C libraries, and should not be used by the user.
: This directive sets the name of the file in which to store precompiled headers.
: If you aren't using precompiled headers, this directive has no effect. You can use the command-line compiler option -H=filename or Use Precompiled Headers to change the name of the file used to store precompiled headers.
: This directive terminates the list of header files eligible for precompilation. You can use it to reduce the amount of disk space used by precompiled headers.
: Use #pragma message to specify a user-defined message within your program code.
: The first form requires that the text consist of one or more string constants, and the message must be enclosed in parentheses. (This form is compatible with MSC.) The second form uses the text following the #pragma for the text of the warning message. With both forms of the #pragma, any macro references are expanded before the message is displayed.
: Display of user-defined messages is on by default and can be turned on or off with the User-Defined Warnings (Options|Project|Messages|General) in the IDE. This option corresponds to the 16/32 bit compiler's -wmsg switch.
: Use #pragma option to include command-line options within your program code.
: options can be any command-line option (except those listed in the following paragraph). Any number of options can appear in one directive. 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, 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:
: Before the use of any macro name that begins with two underscores (and is therefore a possible built-in macro) in an #if, #ifdef, #ifndef or #elif directive.
: Before the occurrence of the first real token (the first C or C++ declaration).
:
: Certain command-line options can appear only in a #pragma option command before these events. These options are:
:
: -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.
: The saveregs pragma guarantees that a huge function will not change the value of any of the registers when it is entered. This directive is sometimes needed for interfacing with assembly language code. The directive should be placed immediately before the function definition. It applies to that function alone.
: The saveregs pragma guarantees that a huge function will not change the value of any of the registers when it is entered. This directive is sometimes needed for interfacing with assembly language code. The directive should be placed immediately before the function definition. It applies to that function alone.
: These two pragmas allow the program to specify function(s) that should be called either upon program startup (before the main function is called), or program exit (just before the program terminates through _exit).
: The specified function-name must be a previously declared function taking no arguments and returning void; in other words, it should be declared as:
:
: void func(void);
:
: The optional priority parameter should be an integer in the range 64 to 255. The highest priority is 0. Functions with higher priorities are called first at startup and last at exit. If you don't specify a priority, it defaults to 100.
:
: Note: Priorities from 0 to 63 are used by the C libraries, and should not be used by the user.
Comments
#pragma anon_struct on
#pragma anon_struct off
Description
The anon_struct directive allows you to compile anonymous structures embedded in classes.
#pragma anon_struct on
struct S {
int i;
struct { // Embedded anonymous struct
int j ;
float x ;
};
class { // Embedded anonymous class
public:
long double ld;
};
S() { i = 1; j = 2; x = 3.3; ld = 12345.5;}
};
#pragma anon_struct off
void main() {
S mystruct;
mystruct.x = 1.2; // Assign to embedded data.
}
Syntax
#pragma directive-name
Description
With #pragma, Borland C++ can define the directives it wants without interfering with other compilers that support #pragma. If the compiler doesn't recognize directive-name, it ignores the #pragma directive without any error or warning message.
Borland C++ supports the following #pragma directives:
#pragma argsused
#pragma anon_struct
#pragma codeseg
#pragma comment
#pragma exit
#pragma hdrfile
#pragma hdrstop
#pragma inline
#pragma intrinsic
#pragma message
#pragma option
#pragma saveregs
#pragma startup
#pragma warn
Syntax
#pragma argused
Description
The argsused pragma is allowed only between function definitions, and it affects only the next function. It disables the warning message:
"Parameter name is never used in function func-name"
Syntax
#pragma codeseg <"seg_class">
Description
The codeseg directive lets you name the segment, class, or group where functions are allocated. If the pragma is used without any of its options arguments, the default code segment is used for function allocation.
Syntax
#pragma comment (comment type, "string")
Description
The comment directive lets you write a comment record into an output file. The comment type can be one of the following values:
Value Explanation
exestr The linker writes string into an .OBJ file. Your specified string is placed in the executable file. Such a string is never loaded into memory but can be found in the executable file by use of a suitable file search utility.
lib Writes a comment record into an .OBJ file. The comment record is used by the linker as a library-search directory. A library module that is not specified in the linker's response-file can be specified by the comment LIB directive. The linker includes the library module name specified in string as the last library. Multiple modules can be named and linked in the order in which they are named.
user The compiler writes string into the .OBJ file. The specified string is ignored by the linker.
Syntax
#pragma startup function-name
#pragma exit function-name
Description
These two pragmas allow the program to specify function(s) that should be called either upon program startup (before the main function is called), or program exit (just before the program terminates through _exit).
The specified function-name must be a previously declared function taking no arguments and returning void; in other words, it should be declared as:
void func(void);
The optional priority parameter should be an integer in the range 64 to 255. The highest priority is 0. Functions with higher priorities are called first at startup and last at exit. If you don't specify a priority, it defaults to 100.
Note: Priorities from 0 to 63 are used by the C libraries, and should not be used by the user.
Syntax
#pragma hdrfile "filename.CSM"
Description
This directive sets the name of the file in which to store precompiled headers.
If you aren't using precompiled headers, this directive has no effect. You can use the command-line compiler option -H=filename or Use Precompiled Headers to change the name of the file used to store precompiled headers.
Syntax
#pragma hdrstop
Description
This directive terminates the list of header files eligible for precompilation. You can use it to reduce the amount of disk space used by precompiled headers.
Syntax
#pragma inline
Description
This directive is equivalent to the -B command-line compiler option or the IDE inline option.
This is best placed at the top of the file, because the compiler restarts itself with the -B option when it encounters #pragma inline.
Syntax
#pragma intrinsic [-]function-name
Description
Use #pragma intrinsic to override command-line switches or IDE options to control the inlining of functions.
When inlining an intrinsic function, always include a prototype for that function before using it.
Syntax
#pragma message ("text" ["text"["text" ...]])
#pragma message text
Description
Use #pragma message to specify a user-defined message within your program code.
The first form requires that the text consist of one or more string constants, and the message must be enclosed in parentheses. (This form is compatible with MSC.) The second form uses the text following the #pragma for the text of the warning message. With both forms of the #pragma, any macro references are expanded before the message is displayed.
Display of user-defined messages is on by default and can be turned on or off with the User-Defined Warnings (Options|Project|Messages|General) in the IDE. This option corresponds to the 16/32 bit compiler's -wmsg switch.
Syntax
#pragma option [options...]
Description
Use #pragma option to include command-line options within your program code.
options can be any command-line option (except those listed in the following paragraph). Any number of options can appear in one directive. 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, 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 -lfilename
-lexset -M -o
-P -Q -S
-T -Uname -V
-X -Y
You can use #pragmas, #includes, #define, and some #ifs in the following cases:
Before the use of any macro name that begins with two underscores (and is therefore a possible built-in macro) in an #if, #ifdef, #ifndef or #elif directive.
Before the occurrence of the first real token (the first C or C++ declaration).
Certain command-line options can appear only in a #pragma option command before these events. These options are:
-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.
Syntax
#pragma saveregs
Description
The saveregs pragma guarantees that a huge function will not change the value of any of the registers when it is entered. This directive is sometimes needed for interfacing with assembly language code. The directive should be placed immediately before the function definition. It applies to that function alone.
Borland C++ 5.0 Programmer's GuideSyntax
#pragma saveregs
Description
The saveregs pragma guarantees that a huge function will not change the value of any of the registers when it is entered. This directive is sometimes needed for interfacing with assembly language code. The directive should be placed immediately before the function definition. It applies to that function alone.
Syntax
#pragma startup function-name
#pragma exit function-name
Description
These two pragmas allow the program to specify function(s) that should be called either upon program startup (before the main function is called), or program exit (just before the program terminates through _exit).
The specified function-name must be a previously declared function taking no arguments and returning void; in other words, it should be declared as:
void func(void);
The optional priority parameter should be an integer in the range 64 to 255. The highest priority is 0. Functions with higher priorities are called first at startup and last at exit. If you don't specify a priority, it defaults to 100.
Note: Priorities from 0 to 63 are used by the C libraries, and should not be used by the user.
Syntax
#pragma warn [+|-|.]www
Description
The warn pragma lets you override specific -wxxx command-line options or check Display Warningsl in the Messages options.
Finally, done =P
: Any one who knows more abt the PRAGMA Preprocessor directive pls give me full details abt that.
:
:
:
: : Any one who knows more abt the PRAGMA Preprocessor directive pls give me full details abt that.
: :
:
:
:
Thanks for ur reply.
: This is directly copy/pasted from the Borland C++ Reference:
:
: #pragma anon_struct on
: #pragma anon_struct off
:
: Description
:
: The anon_struct directive allows you to compile anonymous structures embedded in classes.
:
: #pragma anon_struct on
:
: struct S {
: int i;
: struct { // Embedded anonymous struct
: int j ;
: float x ;
: };
: class { // Embedded anonymous class
: public:
: long double ld;
: };
: S() { i = 1; j = 2; x = 3.3; ld = 12345.5;}
: };
: #pragma anon_struct off
:
: void main() {
: S mystruct;
: mystruct.x = 1.2; // Assign to embedded data.
:
: }
:
: Syntax
:
: #pragma directive-name
:
: Description
:
: With #pragma, Borland C++ can define the directives it wants without interfering with other compilers that support #pragma. If the compiler doesn't recognize directive-name, it ignores the #pragma directive without any error or warning message.
: Borland C++ supports the following #pragma directives:
:
: #pragma argsused
: #pragma anon_struct
: #pragma codeseg
: #pragma comment
: #pragma exit
: #pragma hdrfile
: #pragma hdrstop
: #pragma inline
: #pragma intrinsic
: #pragma message
: #pragma option
: #pragma saveregs
: #pragma startup
: #pragma warn
:
: Syntax
:
: #pragma argused
:
: Description
:
: The argsused pragma is allowed only between function definitions, and it affects only the next function. It disables the warning message:
:
: "Parameter name is never used in function func-name"
:
: Syntax
:
: #pragma codeseg <"seg_class">
:
: Description
:
: The codeseg directive lets you name the segment, class, or group where functions are allocated. If the pragma is used without any of its options arguments, the default code segment is used for function allocation.
:
: Syntax
:
: #pragma comment (comment type, "string")
:
: Description
:
: The comment directive lets you write a comment record into an output file. The comment type can be one of the following values:
:
: Value Explanation
:
: exestr The linker writes string into an .OBJ file. Your specified string is placed in the executable file. Such a string is never loaded into memory but can be found in the executable file by use of a suitable file search utility.
: lib Writes a comment record into an .OBJ file. The comment record is used by the linker as a library-search directory. A library module that is not specified in the linker's response-file can be specified by the comment LIB directive. The linker includes the library module name specified in string as the last library. Multiple modules can be named and linked in the order in which they are named.
:
: user The compiler writes string into the .OBJ file. The specified string is ignored by the linker.
:
:
:
: Syntax
:
: #pragma startup function-name
: #pragma exit function-name
:
: Description
:
: These two pragmas allow the program to specify function(s) that should be called either upon program startup (before the main function is called), or program exit (just before the program terminates through _exit).
: The specified function-name must be a previously declared function taking no arguments and returning void; in other words, it should be declared as:
:
: void func(void);
:
: The optional priority parameter should be an integer in the range 64 to 255. The highest priority is 0. Functions with higher priorities are called first at startup and last at exit. If you don't specify a priority, it defaults to 100.
:
: Note: Priorities from 0 to 63 are used by the C libraries, and should not be used by the user.
:
:
: Syntax
:
: #pragma hdrfile "filename.CSM"
:
: Description
:
: This directive sets the name of the file in which to store precompiled headers.
: If you aren't using precompiled headers, this directive has no effect. You can use the command-line compiler option -H=filename or Use Precompiled Headers to change the name of the file used to store precompiled headers.
:
:
: Syntax
:
: #pragma hdrstop
:
: Description
:
: This directive terminates the list of header files eligible for precompilation. You can use it to reduce the amount of disk space used by precompiled headers.
:
:
: Syntax
:
: #pragma inline
:
: Description
:
: This directive is equivalent to the -B command-line compiler option or the IDE inline option.
: This is best placed at the top of the file, because the compiler restarts itself with the -B option when it encounters #pragma inline.
:
:
: Syntax
:
: #pragma intrinsic [-]function-name
:
: Description
:
: Use #pragma intrinsic to override command-line switches or IDE options to control the inlining of functions.
: When inlining an intrinsic function, always include a prototype for that function before using it.
:
:
: Syntax
:
: #pragma message ("text" ["text"["text" ...]])
: #pragma message text
:
: Description
:
: Use #pragma message to specify a user-defined message within your program code.
: The first form requires that the text consist of one or more string constants, and the message must be enclosed in parentheses. (This form is compatible with MSC.) The second form uses the text following the #pragma for the text of the warning message. With both forms of the #pragma, any macro references are expanded before the message is displayed.
: Display of user-defined messages is on by default and can be turned on or off with the User-Defined Warnings (Options|Project|Messages|General) in the IDE. This option corresponds to the 16/32 bit compiler's -wmsg switch.
:
:
: Syntax
:
: #pragma option [options...]
:
: Description
:
: Use #pragma option to include command-line options within your program code.
: options can be any command-line option (except those listed in the following paragraph). Any number of options can appear in one directive. 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, 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 -lfilename
: -lexset -M -o
: -P -Q -S
: -T -Uname -V
: -X -Y
:
: You can use #pragmas, #includes, #define, and some #ifs in the following cases:
: Before the use of any macro name that begins with two underscores (and is therefore a possible built-in macro) in an #if, #ifdef, #ifndef or #elif directive.
: Before the occurrence of the first real token (the first C or C++ declaration).
:
: Certain command-line options can appear only in a #pragma option command before these events. These options are:
:
: -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.
:
:
: Syntax
:
: #pragma saveregs
:
: Description
:
: The saveregs pragma guarantees that a huge function will not change the value of any of the registers when it is entered. This directive is sometimes needed for interfacing with assembly language code. The directive should be placed immediately before the function definition. It applies to that function alone.
:
: Borland C++ 5.0 Programmer's GuideSyntax
:
: #pragma saveregs
:
: Description
:
: The saveregs pragma guarantees that a huge function will not change the value of any of the registers when it is entered. This directive is sometimes needed for interfacing with assembly language code. The directive should be placed immediately before the function definition. It applies to that function alone.
:
:
:
: Syntax
:
: #pragma startup function-name
: #pragma exit function-name
:
: Description
:
: These two pragmas allow the program to specify function(s) that should be called either upon program startup (before the main function is called), or program exit (just before the program terminates through _exit).
: The specified function-name must be a previously declared function taking no arguments and returning void; in other words, it should be declared as:
:
: void func(void);
:
: The optional priority parameter should be an integer in the range 64 to 255. The highest priority is 0. Functions with higher priorities are called first at startup and last at exit. If you don't specify a priority, it defaults to 100.
:
: Note: Priorities from 0 to 63 are used by the C libraries, and should not be used by the user.
:
:
:
: Syntax
:
: #pragma warn [+|-|.]www
:
: Description
:
: The warn pragma lets you override specific -wxxx command-line options or check Display Warningsl in the Messages options.
:
:
:
: Finally, done =P
:
: