📄 pragma.gml
字号:
.el .do begin
#pragma library (mylib "&pathnam.&libdir16.&pc.dos&pc.graph.lib");
#pragma library (mylib "&pathnam.&libdir32.&pc.dos&pc.graph.lib");
.do end
.millust end
.do end
.if '&lang' eq 'FORTRAN 77' .do begin
.millust begin
.if '&target' eq 'QNX' .do begin
*$pragma library mylib &pathnam.&libdir.&pc.graph.lib
.do end
.el .do begin
*$pragma library mylib &pathnam.&libdir16.&pc.dos&pc.graph.lib
*$pragma library mylib &pathnam.&libdir32.&pc.dos&pc.graph.lib
.do end
.millust end
.if '&cmpclass' ne 'load-n-go' .do begin
.np
If no libraries are specified as in the following example,
.millust begin
*$pragma library
.millust end
.pc
the run-time libraries corresponding to the memory and floating-point models
used to compile the file will be generated.
.do end
.do end
.*
.if '&lang' eq 'C' or '&lang' eq 'C/C++' .do begin
.*
.section The ALLOC_TEXT Pragma (C Only)
.*
.np
.ix 'pragmas' 'alloc_text'
.ix 'alloc_text pragma'
The "alloc_text" pragma can be used to specify the name of the text
segment into which the generated code for a function, or a list of
functions, is to be placed.
The following describes the form of the "alloc_text" pragma.
.mbox begin
:prgbeg. alloc_text ( :id.seg_name:eid., :id.fn:eid. :rp., :id.fn:eid.:erp. ) :prgend.
.mbox end
.synote
.note seg_name
is the name of the text segment.
.note fn
is the name of a function.
.endnote
.np
Consider the following example.
.millust begin
extern int fn1(int);
extern int fn2(void);
#pragma alloc_text ( my_text, fn1, fn2 );
.millust end
.pc
The code for the functions
.id fn1
and
.id fn2
will be placed in the segment
.id my_text.
Note: function prototypes for the named functions must exist prior
to the "alloc_text" pragma.
.*
.section The CODE_SEG Pragma
.*
.np
.ix 'pragmas' 'code_seg'
.ix 'code_seg pragma'
The "code_seg" pragma can be used to specify the name of the text
segment into which the generated code for functions is to be placed.
The following describes the form of the "code_seg" pragma.
.mbox begin
:prgbeg. code_seg ( :id.seg_name:eid. :op., :id.class_name:eid.:eop. ) :prgend.
.mbox end
.synote
.note seg_name
is the name of the text segment optionally enclosed in quotes.
Also,
.mono seg_name
may be a macro as in:
.millust begin
#define seg_name "MY_CODE_SEG"
#pragma code_seg ( seg_name );
.millust end
.note class_name
is the optional class name of the text segment and may be enclosed in quotes.
Also,
.mono class_name
may be a macro as in:
.millust begin
#define class_name "MY_CLASS"
#pragma code_seg ( "MY_CODE_SEG", class_name );
.millust end
.endnote
.np
Consider the following example.
.millust begin
#pragma code_seg ( my_text );
int incr( int i )
{
return( i + 1 );
}
int decr( int i )
{
return( i - 1 );
}
.millust end
.pc
The code for the functions
.id incr
and
.id decr
will be placed in the segment
.id my_text.
.np
To return to the default segment, do not specify any string between
the opening and closing parenthesis.
.millust begin
#pragma code_seg ();
.millust end
.*
.section The COMMENT Pragma
.*
.np
.ix 'pragmas' 'comment'
.ix 'comment pragma'
The "comment" pragma can be used to place a comment record in an
object file or executable file.
The following describes the form of the "comment" pragma.
.mbox begin
:prgbeg. comment ( :id.comment_type:eid. :op., :id."comment_string":eid.:eop. ) :prgend.
.mbox end
.synote
.note comment_type
specifies the type of comment record.
The allowable comment types are:
.begnote
.note lib
Default libraries are specified in special object module records.
Library names are extracted from these special records by the
&lnkname..
When unresolved references remain after processing all object modules
specified in linker "FILE" directives, these default libraries are
searched after all libraries specified in linker "LIBRARY" directives
have been searched.
.np
The "lib" form of this pragma offers the same features as the
"library" pragma.
See the section entitled :HDREF refid='&praglib'. for more information.
.endnote
.note "comment_string"
is an optional string literal that provides additional information
for some comment types.
.endnote
.np
Consider the following example.
.millust begin
#pragma comment ( lib, "mylib" );
.millust end
.*
.section The DATA_SEG Pragma
.*
.np
.ix 'pragmas' 'data_seg'
.ix 'data_seg pragma'
The "data_seg" pragma can be used to specify the name of the
segment into which data is to be placed.
The following describes the form of the "data_seg" pragma.
.mbox begin
:prgbeg. data_seg ( :id.seg_name:eid. :op., :id.class_name:eid.:eop. ) :prgend.
.mbox end
.synote
.note seg_name
is the name of the data segment and may be enclosed in quotes.
Also,
.mono seg_name
may be a macro as in:
.millust begin
#define seg_name "MY_DATA_SEG"
#pragma data_seg ( seg_name );
.millust end
.note class_name
is the optional class name of the data segment and may be enclosed in quotes.
Also,
.mono class_name
may be a macro as in:
.millust begin
#define class_name "MY_CLASS"
#pragma data_seg ( "MY_DATA_SEG", class_name );
.millust end
.endnote
.np
Consider the following example.
.millust begin
#pragma data_seg ( my_data );
static int i;
static int j;
.millust end
.pc
The data for
.id i
and
.id j
will be placed in the segment
.id my_data.
.np
To return to the default segment, do not specify any string between
the opening and closing parenthesis.
.millust begin
#pragma data_seg ();
.millust end
.*
.section *refid=&pragdsbl. The DISABLE_MESSAGE Pragma (C Only)
.*
.np
.ix 'pragmas' 'disable_message'
.ix 'disable_message pragma'
The "disable_message" pragma disables the issuance of specified
diagnostic messages.
The form of the "disable_message" pragma is as follows.
.mbox begin
:prgbeg. disable_message ( :id.msg_num:eid. :rp., :id.msg_num:eid.:erp. ) :prgend.
.mbox end
.synote
.note msg_num
is the number of the diagnostic message.
.if &e'&dohelp eq 0 .do begin
This number corresponds to the number issued by the compiler and can
be found in the appendix entitled :HDREF refid='cmsgs'..
.do end
.el .do begin
This number corresponds to the number issued by the compiler.
.do end
Make sure to strip all leading zeroes from the message number (to
avoid interpretation as an octal constant).
.esynote
.np
See also the description of :HDREF refid='&pragenbl.'..
.*
.section The DUMP_OBJECT_MODEL Pragma (C++ Only)
.*
.np
.ix 'object model'
.ix 'pragmas' 'dump_object_model'
.ix 'dump_object_model pragma'
.ix 'class information'
The "dump_object_model" pragma causes the C++ compiler to print
information about the object model for an indicated
.if &version ge 107 .do begin
class or an enumeration name to the diagnostics file.
.ix 'enumeration' 'information'
.ix 'enumeration' 'values'
.do end
.el .do begin
class.
.do end
For class names, this information includes the offsets and sizes of
fields within the class and within base classes.
.if &version ge 107 .do begin
For enumeration names, this information consists of a list of all the
enumeration constants with their values.
.do end
.np
The general form of the "dump_object_model" pragma is as follows.
.mbox begin
:prgbeg. dump_object_model :id.class:eid. :prgend.
.if &version ge 107 .do begin
:prgbeg. dump_object_model :id.enumeration:eid. :prgend.
.do end
:id.class ::= a defined C++ class free of errors:eid.
.if &version ge 107 .do begin
:id.enumeration ::= a defined C++ enumeration name:eid.
.do end
.mbox end
.np
This pragma is designed to be used for information purposes only.
.*
.section *refid=&pragenbl. The ENABLE_MESSAGE Pragma (C Only)
.*
.np
.ix 'pragmas' 'enable_message'
.ix 'enable_message pragma'
The "enable_message" pragma re-enables the issuance of specified
diagnostic messages that have been previously disabled.
The form of the "enable_message" pragma is as follows.
.mbox begin
:prgbeg. enable_message ( :id.msg_num:eid. :rp., :id.msg_num:eid.:erp. ) :prgend.
.mbox end
.synote
.note msg_num
is the number of the diagnostic message.
.if &e'&dohelp eq 0 .do begin
This number corresponds to the number issued by the compiler and can
be found in the appendix entitled :HDREF refid='cmsgs'..
.do end
.el .do begin
This number corresponds to the number issued by the compiler.
.do end
Make sure to strip all leading zeroes from the message number (to
avoid interpretation as an octal constant).
.esynote
.np
See also the description of :HDREF refid='&pragdsbl.'..
.*
.if &version ge 107 .do begin
.*
.section The ENUM Pragma
.*
.np
.ix 'pragmas' 'enum'
.ix 'enum pragma'
The "enum" pragma affects the underlying storage-definition for
subsequent
.us enum
declarations.
The forms of the "enum" pragma are as follows.
.mbox begin
:prgbeg. enum int :prgend.
:prgbeg. enum minimum :prgend.
:prgbeg. enum original :prgend.
:prgbeg. enum pop :prgend.
.mbox end
.synote
.note int
Make
.us int
the underlying storage definition (same as the "ei" compiler option).
.note minimum
Minimize the underlying storage definition (same as not specifying
the "ei" compiler option).
.note original
Reset back to the original compiler option setting (i.e., what was or
was not specified on the command line).
.note pop
Restore the previous setting.
.esynote
.np
The first three forms all push the previous setting before
establishing the new setting.
.*
.do end
.*
.section The ERROR Pragma
.*
.np
.ix 'pragmas' 'error'
.ix 'error pragma'
The "error" pragma can be used to issue an error message with the
specified text.
The following describes the form of the "error" pragma.
.mbox begin
:prgbeg. error :id."error text":eid. :prgend.
.mbox end
.synote
.note "error text"
is the text of the message that you wish to display.
.endnote
.np
You should use the ISO
.kw #error
directive rather than this pragma.
This pragma is provided for compatibility with legacy code.
The following is an example.
.millust begin
#if defined(__386__)
...
#elseif defined(__86__)
...
#else
#pragma error ( "neither __386__ or __86__ defined" );
#endif
.millust end
.*
.if &version ge 107 .do begin
.*
.section The EXTREF Pragma
.*
.np
.ix 'pragmas' 'extref'
.ix 'extref pragma'
.ix 'external references'
The "extref" pragma is used to generate a reference to an external
function or data item.
The form of the "extref" pragma is as follows.
.mbox begin
:prgbeg. extref :id.name:eid. :prgend.
.mbox end
.synote
.note name
is the name of an external function or data item.
It must be declared to be an external function or data item before
the pragma is encountered.
In C++, when
.sy name
is a function, it must not be overloaded.
.esynote
.np
This pragma causes an external reference for the function or data item
to be emitted into the object file even if that function or data item
is not referenced in the module.
The external reference will cause the linker to include the module
containing that name in the linked program or DLL.
.np
This is useful for debugging since you can cause debugging routines
(callable from within debugger) to be included into a program or DLL
to be debugged.
.np
In C++, you can also force constructors and/or destructors to be
called for a data item without necessarily referencing the data item
anywhere in your code.
.*
.do end
.*
.section The FUNCTION Pragma
.*
.np
.ix 'pragmas' 'function'
.ix 'function pragma'
Certain functions, such as those listed in the description of the "oi"
and "om" options, have intrinsic forms.
These functions are special functions that are recognized by the
compiler and processed in a special way.
For example, the compiler may choose to generate in-line code for the
function.
The intrinsic attribute for these special functions is set by
specifying the "oi" or "om" option or using an "intrinsic" pragma.
The "function" pragma can be used to remove the intrinsic attribute
for a specified list of functions.
.np
The following describes the form of the "function" pragma.
.mbox begin
:prgbeg. function ( :id.fn:eid. :rp., :id.fn:eid.:erp. ) :prgend.
.mbox end
.synote
.note fn
is the name of a function.
.endnote
.np
Suppose the following source code was compiled using the "om" option
so that when one of the special math functions is referenced, the
intrinsic form will be used.
In our example, we have referenced the function
.id sin
which does have an intrinsic form.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -