gnat_rm.texi

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

TEXI
1,978
字号
* Pragma Volatile::* Pragma Warnings::* Pragma Weak_External::* Pragma Wide_Character_Encoding::@end menu@node Pragma Abort_Defer@unnumberedsec Pragma Abort_Defer@findex Abort_Defer@cindex Deferring aborts@noindentSyntax:@smallexamplepragma Abort_Defer;@end smallexample@noindentThis pragma must appear at the start of the statement sequence of ahandled sequence of statements (right after the @code{begin}).  It hasthe effect of deferring aborts for the sequence of statements (but notfor the declarations or handlers, if any, associated with this statementsequence).@node Pragma Ada_83@unnumberedsec Pragma Ada_83@findex Ada_83@noindentSyntax:@smallexample @c adapragma Ada_83;@end smallexample@noindentA configuration pragma that establishes Ada 83 mode for the unit towhich it applies, regardless of the mode set by the command lineswitches.  In Ada 83 mode, GNAT attempts to be as compatible withthe syntax and semantics of Ada 83, as defined in the original Ada83 Reference Manual as possible.  In particular, the keywords added by Ada 95and Ada 2005 are not recognized, optional package bodies are allowed,and generics may name types with unknown discriminants without usingthe @code{(<>)} notation.  In addition, some but not all of the additionalrestrictions of Ada 83 are enforced.Ada 83 mode is intended for two purposes.  Firstly, it allows existingAda 83 code to be compiled and adapted to GNAT with less effort.Secondly, it aids in keeping code backwards compatible with Ada 83.However, there is no guarantee that code that is processed correctlyby GNAT in Ada 83 mode will in fact compile and execute with an Ada83 compiler, since GNAT does not enforce all the additional checksrequired by Ada 83.@node Pragma Ada_95@unnumberedsec Pragma Ada_95@findex Ada_95@noindentSyntax:@smallexample @c adapragma Ada_95;@end smallexample@noindentA configuration pragma that establishes Ada 95 mode for the unit to whichit applies, regardless of the mode set by the command line switches.This mode is set automatically for the @code{Ada} and @code{System}packages and their children, so you need not specify it in thesecontexts.  This pragma is useful when writing a reusable component thatitself uses Ada 95 features, but which is intended to be usable fromeither Ada 83 or Ada 95 programs.@node Pragma Ada_05@unnumberedsec Pragma Ada_05@findex Ada_05@noindentSyntax:@smallexample @c adapragma Ada_05;@end smallexample@noindentA configuration pragma that establishes Ada 2005 mode for the unit to whichit applies, regardless of the mode set by the command line switches.This mode is set automatically for the @code{Ada} and @code{System}packages and their children, so you need not specify it in thesecontexts.  This pragma is useful when writing a reusable component thatitself uses Ada 2005 features, but which is intended to be usable fromeither Ada 83 or Ada 95 programs.@node Pragma Ada_2005@unnumberedsec Pragma Ada_2005@findex Ada_2005@noindentSyntax:@smallexample @c adapragma Ada_2005;@end smallexample@noindentThis configuration pragma is a synonym for pragma Ada_05 and has thesame syntax and effect.@node Pragma Annotate@unnumberedsec Pragma Annotate@findex Annotate@noindentSyntax:@smallexample @c adapragma Annotate (IDENTIFIER @{, ARG@});ARG ::= NAME | EXPRESSION@end smallexample@noindentThis pragma is used to annotate programs.  @var{identifier} identifiesthe type of annotation.  GNAT verifies that it is an identifier, but doesnot otherwise analyze it.  The @var{arg} argumentcan be either a string literal or anexpression.  String literals are assumed to be of type@code{Standard.String}.  Names of entities are simply analyzed as entitynames.  All other expressions are analyzed as expressions, and must beunambiguous.The analyzed pragma is retained in the tree, but not otherwise processedby any part of the GNAT compiler.  This pragma is intended for use byexternal tools, including ASIS@.@node Pragma Assert@unnumberedsec Pragma Assert@findex Assert@noindentSyntax:@smallexample @c adapragma Assert (  boolean_EXPRESSION  [, static_string_EXPRESSION]);@end smallexample@noindentThe effect of this pragma depends on whether the corresponding commandline switch is set to activate assertions.  The pragma expands into codeequivalent to the following:@smallexample @c adaif assertions-enabled then   if not boolean_EXPRESSION then      System.Assertions.Raise_Assert_Failure        (string_EXPRESSION);   end if;end if;@end smallexample@noindentThe string argument, if given, is the message that will be associatedwith the exception occurrence if the exception is raised.  If no secondargument is given, the default message is @samp{@var{file}:@var{nnn}},where @var{file} is the name of the source file containing the assert,and @var{nnn} is the line number of the assert.  A pragma is not astatement, so if a statement sequence contains nothing but a pragmaassert, then a null statement is required in addition, as in:@smallexample @c ada@dots{}if J > 3 then   pragma Assert (K > 3, "Bad value for K");   null;end if;@end smallexample@noindentNote that, as with the @code{if} statement to which it is equivalent, thetype of the expression is either @code{Standard.Boolean}, or any type derivedfrom this standard type.If assertions are disabled (switch @code{-gnata} not used), then thereis no run-time effect (and in particular, any side effects from theexpression will not occur at run time).  (The expression is stillanalyzed at compile time, and may cause types to be frozen if they arementioned here for the first time).If assertions are enabled, then the given expression is tested, and ifit is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is calledwhich results in the raising of @code{Assert_Failure} with the given message.You should generally avoid side effects in the expression arguments ofthis pragma, because these side effects will turn on and off with thesetting of the assertions mode, resulting in assertions that have aneffect on the program.  However, the expressions are analyzed forsemantic correctness whether or not assertions are enabled, so turningassertions on and off cannot affect the legality of a program.@node Pragma Ast_Entry@unnumberedsec Pragma Ast_Entry@cindex OpenVMS@findex Ast_Entry@noindentSyntax:@smallexample @c adapragma AST_Entry (entry_IDENTIFIER);@end smallexample@noindentThis pragma is implemented only in the OpenVMS implementation of GNAT@.  Theargument is the simple name of a single entry; at most one @code{AST_Entry}pragma is allowed for any given entry.  This pragma must be used inconjunction with the @code{AST_Entry} attribute, and is only allowed afterthe entry declaration and in the same task type specification or single taskas the entry to which it applies.  This pragma specifies that the given entrymay be used to handle an OpenVMS asynchronous system trap (@code{AST})resulting from an OpenVMS system service call.  The pragma does not affectnormal use of the entry.  For further details on this pragma, see theDEC Ada Language Reference Manual, section 9.12a.@node Pragma C_Pass_By_Copy@unnumberedsec Pragma C_Pass_By_Copy@cindex Passing by copy@findex C_Pass_By_Copy@noindentSyntax:@smallexample @c adapragma C_Pass_By_Copy  ([Max_Size =>] static_integer_EXPRESSION);@end smallexample@noindentNormally the default mechanism for passing C convention records to Cconvention subprograms is to pass them by reference, as suggested by RMB.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to changethis default, by requiring that record formal parameters be passed bycopy if all of the following conditions are met:@itemize @bullet@itemThe size of the record type does not exceed the value specified for@code{Max_Size}.@itemThe record type has @code{Convention C}.@itemThe formal parameter has this record type, and the subprogram has aforeign (non-Ada) convention.@end itemize@noindentIf these conditions are met the argument is passed by copy, i.e.@: in amanner consistent with what C expects if the corresponding formal in theC prototype is a struct (rather than a pointer to a struct).You can also pass records by copy by specifying the convention@code{C_Pass_By_Copy} for the record type, or by using the extended@code{Import} and @code{Export} pragmas, which allow specification ofpassing mechanisms on a parameter by parameter basis.@node Pragma Check_Name@unnumberedsec Pragma Check_Name@cindex Defining check names@cindex Check names, defining@findex Check_Name@noindentSyntax:@smallexample @c adapragma Check_Name (check_name_IDENTIFIER);@end smallexample@noindentThis is a configuration pragma that defines a new implementationdefined check name (unless IDENTIFIER matches one of the predefinedcheck names, in which case the pragma has no effect). Check namesare global to a partition, so if two more more configuration pragmasare present in a partition mentioning the same name, only one newcheck name is introduced.An implementation defined check name introduced with this pragma maybe used in only three contexts: @code{pragma Suppress},@code{pragma Unsuppress},and as the prefix of a @code{Check_Name'Enabled} attribute reference. Forany of these three cases, the check name must be visible. A checkname is visible if it is in the configuration pragmas applying tothe current unit, or if it appears at the start of any unit thatis part of the dependency set of the current unit (e.g. units thatare mentioned in @code{with} clauses.@node Pragma Comment@unnumberedsec Pragma Comment@findex Comment@noindentSyntax:@smallexample @c adapragma Comment (static_string_EXPRESSION);@end smallexample@noindentThis is almost identical in effect to pragma @code{Ident}.  It allows theplacement of a comment into the object file and hence into theexecutable file if the operating system permits such usage.  Thedifference is that @code{Comment}, unlike @code{Ident}, hasno limitations on placement of the pragma (it can be placedanywhere in the main source unit), and if more than one pragmais used, all comments are retained.@node Pragma Common_Object@unnumberedsec Pragma Common_Object@findex Common_Object@noindentSyntax:@smallexample @c adapragma Common_Object (     [Internal =>] LOCAL_NAME  [, [External =>] EXTERNAL_SYMBOL]  [, [Size     =>] EXTERNAL_SYMBOL] );EXTERNAL_SYMBOL ::=  IDENTIFIER| static_string_EXPRESSION@end smallexample@noindentThis pragma enables the shared use of variables stored in overlaidlinker areas corresponding to the use of @code{COMMON}in Fortran.  The singleobject @var{LOCAL_NAME} is assigned to the area designated bythe @var{External} argument.You may define a record to correspond to a seriesof fields.  The @var{Size} argumentis syntax checked in GNAT, but otherwise ignored.@code{Common_Object} is not supported on all platforms.  If nosupport is available, then the code generator will issue a messageindicating that the necessary attribute for implementation of thispragma is not available.@node Pragma Compile_Time_Error@unnumberedsec Pragma Compile_Time_Error@findex Compile_Time_Error@noindentSyntax:@smallexample @c adapragma Compile_Time_Error         (boolean_EXPRESSION, static_string_EXPRESSION);@end smallexample@noindentThis pragma can be used to generate additional compile timeerror messages. Itis particularly useful in generics, where errors can be issued forspecific problematic instantiations. The first parameter is a booleanexpression. The pragma is effective only if the value of this expressionis known at compile time, and has the value True. The set of expressionswhose values are known at compile time includes all static booleanexpressions, and also other values which the compiler can determineat compile time (e.g. the size of a record type set by an explicitsize representation clause, or the value of a variable which wasinitialized to a constant and is known not to have been modified).If these conditions are met, an error message is generated usingthe value given as the second argument. This string value may containembedded ASCII.LF characters to break the message into multiple lines.@node Pragma Compile_Time_Warning@unnumberedsec Pragma Compile_Time_Warning@findex Compile_Time_Warning@noindentSyntax:@smallexample @c adapragma Compile_Time_Warning         (boolean_EXPRESSION, static_string_EXPRESSION);@end smallexample@noindentSame as pragma Compile_Time_Error, except a warning is issued insteadof an error message.@node Pragma Complete_Representation@unnumberedsec Pragma Complete_Representation@findex Complete_Representation@noindentSyntax:@smallexample @c adapragma Complete_Representation;@end smallexample@noindentThis pragma must appear immediately within a record representationclause. Typical placements are before the first component clauseor after the last component clause. The effect is to give an errormessage if any component is missing a component clause. This pragmamay be used to ensure that a record representation clause iscomplete, and that this invariant is maintained if fields areadded to the record in the future.@node Pragma Complex_Representation@unnumberedsec Pragma Complex_Representation@findex Complex_Representation@noindentSyntax:

⌨️ 快捷键说明

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