gnat_rm.texi

来自「理解和实践操作系统的一本好书」· TEXI 代码 · 共 1,978 行 · 第 1/5 页

TEXI
1,978
字号
@smallexample @c adapragma Complex_Representation        ([Entity =>] LOCAL_NAME);@end smallexample@noindentThe @var{Entity} argument must be the name of a record type which hastwo fields of the same floating-point type.  The effect of this pragma isto force gcc to use the special internal complex representation form forthis record, which may be more efficient.  Note that this may result inthe code for this type not conforming to standard ABI (applicationbinary interface) requirements for the handling of record types.  Forexample, in some environments, there is a requirement for passingrecords by pointer, and the use of this pragma may result in passingthis type in floating-point registers.@node Pragma Component_Alignment@unnumberedsec Pragma Component_Alignment@cindex Alignments of components@findex Component_Alignment@noindentSyntax:@smallexample @c adapragma Component_Alignment (     [Form =>] ALIGNMENT_CHOICE  [, [Name =>] type_LOCAL_NAME]);ALIGNMENT_CHOICE ::=  Component_Size| Component_Size_4| Storage_Unit| Default@end smallexample@noindentSpecifies the alignment of components in array or record types.The meaning of the @var{Form} argument is as follows:@table @code@findex Component_Size@item Component_SizeAligns scalar components and subcomponents of the array or record typeon boundaries appropriate to their inherent size (naturallyaligned).  For example, 1-byte components are aligned on byte boundaries,2-byte integer components are aligned on 2-byte boundaries, 4-byteinteger components are aligned on 4-byte boundaries and so on.  Thesealignment rules correspond to the normal rules for C compilers on allmachines except the VAX@.@findex Component_Size_4@item Component_Size_4Naturally aligns components with a size of four or fewerbytes.  Components that are larger than 4 bytes are placed on the next4-byte boundary.@findex Storage_Unit@item Storage_UnitSpecifies that array or record components are byte aligned, i.e.@:aligned on boundaries determined by the value of the constant@code{System.Storage_Unit}.@cindex OpenVMS@item DefaultSpecifies that array or record components are aligned on defaultboundaries, appropriate to the underlying hardware or operating system orboth.  For OpenVMS VAX systems, the @code{Default} choice is the same asthe @code{Storage_Unit} choice (byte alignment).  For all other systems,the @code{Default} choice is the same as @code{Component_Size} (naturalalignment).@end table@noindentIf the @code{Name} parameter is present, @var{type_LOCAL_NAME} mustrefer to a local record or array type, and the specified alignmentchoice applies to the specified type.  The use of@code{Component_Alignment} together with a pragma @code{Pack} causes the@code{Component_Alignment} pragma to be ignored.  The use of@code{Component_Alignment} together with a record representation clauseis only effective for fields not specified by the representation clause.If the @code{Name} parameter is absent, the pragma can be used as eithera configuration pragma, in which case it applies to one or more units inaccordance with the normal rules for configuration pragmas, or it can beused within a declarative part, in which case it applies to types thatare declared within this declarative part, or within any nested scopewithin this declarative part.  In either case it specifies the alignmentto be applied to any record or array type which has otherwise standardrepresentation.If the alignment for a record or array type is not specified (usingpragma @code{Pack}, pragma @code{Component_Alignment}, or a record repclause), the GNAT uses the default alignment as described previously.@node Pragma Convention_Identifier@unnumberedsec Pragma Convention_Identifier@findex Convention_Identifier@cindex Conventions, synonyms@noindentSyntax:@smallexample @c adapragma Convention_Identifier (         [Name =>]       IDENTIFIER,         [Convention =>] convention_IDENTIFIER);@end smallexample@noindentThis pragma provides a mechanism for supplying synonyms for existingconvention identifiers. The @code{Name} identifier can subsequentlybe used as a synonym for the given convention in other pragmas (includingfor example pragma @code{Import} or another @code{Convention_Identifier}pragma). As an example of the use of this, suppose you had legacy codewhich used Fortran77 as the identifier for Fortran. Then the pragma:@smallexample @c adapragma Convention_Identifier (Fortran77, Fortran);@end smallexample@noindentwould allow the use of the convention identifier @code{Fortran77} insubsequent code, avoiding the need to modify the sources. As anotherexample, you could use this to parametrize convention requirementsaccording to systems. Suppose you needed to use @code{Stdcall} onwindows systems, and @code{C} on some other system, then you coulddefine a convention identifier @code{Library} and use a single@code{Convention_Identifier} pragma to specify which conventionwould be used system-wide.@node Pragma CPP_Class@unnumberedsec Pragma CPP_Class@findex CPP_Class@cindex Interfacing with C++@noindentSyntax:@smallexample @c adapragma CPP_Class ([Entity =>] LOCAL_NAME);@end smallexample@noindentThe argument denotes an entity in the current declarative region that isdeclared as a tagged record type. It indicates that the type correspondsto an externally declared C++ class type, and is to be laid out the sameway that C++ would lay out the type.Types for which @code{CPP_Class} is specified do not have assignment orequality operators defined (such operations can be imported or declaredas subprograms as required). Initialization is allowed only by constructorfunctions (see pragma @code{CPP_Constructor}). Such types are implicitlylimited if not explicitly declared as limited or derived from a limitedtype, and a warning is issued in that case.Pragma @code{CPP_Class} is intended primarily for automatic generationusing an automatic binding generator tool.See @ref{Interfacing to C++} for related information.Note: Pragma @code{CPP_Class} is currently obsolete. It is supportedfor backward compatibility but its functionality is availableusing pragma @code{Import} with @code{Convention} = @code{CPP}.@node Pragma CPP_Constructor@unnumberedsec Pragma CPP_Constructor@cindex Interfacing with C++@findex CPP_Constructor@noindentSyntax:@smallexample @c adapragma CPP_Constructor ([Entity =>] LOCAL_NAME  [, [External_Name =>] static_string_EXPRESSION ]  [, [Link_Name     =>] static_string_EXPRESSION ]);@end smallexample@noindentThis pragma identifies an imported function (imported in the usual waywith pragma @code{Import}) as corresponding to a C++ constructor. If@code{External_Name} and @code{Link_Name} are not specified then the@code{Entity} argument is a name that must have been previously mentionedin a pragma @code{Import} with @code{Convention} = @code{CPP}. Such namemust be of one of the following forms:@itemize @bullet@item@code{function @var{Fname} return @var{T}'Class}@item@code{function @var{Fname} (@dots{}) return @var{T}'Class}@end itemize@noindentwhere @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.The first form is the default constructor, used when an object of type@var{T} is created on the Ada side with no explicit constructor.  Otherconstructors (including the copy constructor, which is simply a specialcase of the second form in which the one and only argument is of type@var{T}), can only appear in two contexts:@itemize @bullet@itemOn the right side of an initialization of an object of type @var{T}.@itemIn an extension aggregate for an object of a type derived from @var{T}.@end itemize@noindentAlthough the constructor is described as a function that returns a valueon the Ada side, it is typically a procedure with an extra implicitargument (the object being initialized) at the implementationlevel.  GNAT issues the appropriate call, whatever it is, to get theobject properly initialized.In the case of derived objects, you may use one of two possible formsfor declaring and creating an object:@itemize @bullet@item @code{New_Object : Derived_T}@item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}@end itemize@noindentIn the first case the default constructor is called and extension fieldsif any are initialized according to the default initializationexpressions in the Ada declaration.  In the second case, the givenconstructor is called and the extension aggregate indicates the explicitvalues of the extension fields.If no constructors are imported, it is impossible to create any objectson the Ada side.  If no default constructor is imported, only theinitialization forms using an explicit call to a constructor arepermitted.Pragma @code{CPP_Constructor} is intended primarily for automatic generationusing an automatic binding generator tool.See @ref{Interfacing to C++} for more related information.@node Pragma CPP_Virtual@unnumberedsec Pragma CPP_Virtual@cindex Interfacing to C++@findex CPP_Virtual@noindentThis pragma is now obsolete has has no effect because GNAT generatesthe same object layout than the G++ compiler.See @ref{Interfacing to C++} for related information.@node Pragma CPP_Vtable@unnumberedsec Pragma CPP_Vtable@cindex Interfacing with C++@findex CPP_Vtable@noindentThis pragma is now obsolete has has no effect because GNAT generatesthe same object layout than the G++ compiler.See @ref{Interfacing to C++} for related information.@node Pragma Debug@unnumberedsec Pragma Debug@findex Debug@noindentSyntax:@smallexample @c adapragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);PROCEDURE_CALL_WITHOUT_SEMICOLON ::=  PROCEDURE_NAME| PROCEDURE_PREFIX ACTUAL_PARAMETER_PART@end smallexample@noindentThe procedure call argument has the syntactic form of an expression, meetingthe syntactic requirements for pragmas.If debug pragmas are not enabled or if the condition is present and evaluatesto False, this pragma has no effect. If debug pragmas are enabled, thesemantics of the pragma is exactly equivalent to the procedure call statementcorresponding to the argument with a terminating semicolon. Pragmas arepermitted in sequences of declarations, so you can use pragma @code{Debug} tointersperse calls to debug procedures in the middle of declarations. Debugpragmas can be enabled either by use of the command line switch @code{-gnata}or by use of the configuration pragma @code{Debug_Policy}.@node Pragma Debug_Policy@unnumberedsec Pragma Debug_Policy@findex Debug_Policy@noindentSyntax:@smallexample @c adapragma Debug_Policy (CHECK | IGNORE);@end smallexample@noindentIf the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.This pragma overrides the effect of the @code{-gnata} switch on thecommand line.@node Pragma Detect_Blocking@unnumberedsec Pragma Detect_Blocking@findex Detect_Blocking@noindentSyntax:@smallexample @c adapragma Detect_Blocking;@end smallexample@noindentThis is a configuration pragma that forces the detection of potentiallyblocking operations within a protected operation, and to raise Program_Errorif that happens.@node Pragma Elaboration_Checks@unnumberedsec Pragma Elaboration_Checks@cindex Elaboration control@findex Elaboration_Checks@noindentSyntax:@smallexample @c adapragma Elaboration_Checks (Dynamic | Static);@end smallexample@noindentThis is a configuration pragma that provides control over theelaboration model used by the compilation affected by thepragma.  If the parameter is @code{Dynamic},then the dynamic elaborationmodel described in the Ada Reference Manual is used, as thoughthe @code{-gnatE} switch had been specified on the commandline.  If the parameter is @code{Static}, then the default GNAT staticmodel is used.  This configuration pragma overrides the settingof the command line.  For full details on the elaboration modelsused by the GNAT compiler, see section ``Elaboration OrderHandling in GNAT'' in the @cite{GNAT User's Guide}.@node Pragma Eliminate@unnumberedsec Pragma Eliminate@cindex Elimination of unused subprograms@findex Eliminate@noindentSyntax:@smallexample @c adapragma Eliminate (    [Unit_Name =>] IDENTIFIER |                   SELECTED_COMPONENT);pragma Eliminate (    [Unit_Name       =>]  IDENTIFIER |                          SELECTED_COMPONENT,    [Entity          =>]  IDENTIFIER |                          SELECTED_COMPONENT |                          STRING_LITERAL    [,OVERLOADING_RESOLUTION]);OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |                           SOURCE_LOCATIONPARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |                                      FUNCTION_PROFILEPROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPESFUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]                      Result_Type => result_SUBTYPE_NAME]PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})SUBTYPE_NAME    ::= STRING_VALUESOURCE_LOCATION ::= Source_Location => SOURCE_TRACESOURCE_TRACE    ::= STRING_VALUESTRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}@end smallexample@noindentThis pragma indicates that the given entity is not used outside thecompilation unit it is defined in. The entity must be an explicitly declaredsubprogram; this includes  generic subprogram instances andsubprograms declared in generic package instances.If the entity to be eliminated is a library level subprogram, thenthe first form of pragma @code{Eliminate} is used with only a single argument.In this form, the @code{Unit_Name} argument specifies the name of thelibrary  level unit to be eliminated.In all other cases, both @code{Unit_Name} and @code{Entity} argumentsare required. If item is an entity of a library package, then the firstargument specifies the unit name, and the second argument specifiesthe particular entity.  If the second argument is in string form, it mustcorrespond to the internal manner in which GNAT stores entity names (see

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?