1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c Copyright (C) 1995-2004 Free Software Foundation o
14 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
16 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
18 @setfilename gnat_rm.info
19 @settitle GNAT Reference Manual
20 @setchapternewpage odd
23 @include gcc-common.texi
25 @dircategory GNU Ada tools
27 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
31 Copyright @copyright{} 1995-2004, Free Software Foundation
33 Permission is granted to copy, distribute and/or modify this document
34 under the terms of the GNU Free Documentation License, Version 1.2
35 or any later version published by the Free Software Foundation;
36 with the Invariant Sections being ``GNU Free Documentation License'',
37 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
38 no Back-Cover Texts. A copy of the license is included in the section
39 entitled ``GNU Free Documentation License''.
44 @title GNAT Reference Manual
45 @subtitle GNAT, The GNU Ada 95 Compiler
46 @subtitle GCC version @value{version-GCC}
47 @author Ada Core Technologies, Inc.
50 @vskip 0pt plus 1filll
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
64 GNAT, The GNU Ada 95 Compiler@*
65 GCC version @value{version-GCC}@*
68 Ada Core Technologies, Inc.
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Project File Reference::
85 * GNU Free Documentation License::
88 --- The Detailed Node Listing ---
92 * What This Reference Manual Contains::
93 * Related Information::
95 Implementation Defined Pragmas
97 * Pragma Abort_Defer::
103 * Pragma C_Pass_By_Copy::
105 * Pragma Common_Object::
106 * Pragma Compile_Time_Warning::
107 * Pragma Complex_Representation::
108 * Pragma Component_Alignment::
109 * Pragma Convention_Identifier::
111 * Pragma CPP_Constructor::
112 * Pragma CPP_Virtual::
113 * Pragma CPP_Vtable::
115 * Pragma Elaboration_Checks::
117 * Pragma Export_Exception::
118 * Pragma Export_Function::
119 * Pragma Export_Object::
120 * Pragma Export_Procedure::
121 * Pragma Export_Value::
122 * Pragma Export_Valued_Procedure::
123 * Pragma Extend_System::
125 * Pragma External_Name_Casing::
126 * Pragma Finalize_Storage_Only::
127 * Pragma Float_Representation::
129 * Pragma Import_Exception::
130 * Pragma Import_Function::
131 * Pragma Import_Object::
132 * Pragma Import_Procedure::
133 * Pragma Import_Valued_Procedure::
134 * Pragma Initialize_Scalars::
135 * Pragma Inline_Always::
136 * Pragma Inline_Generic::
138 * Pragma Interface_Name::
139 * Pragma Interrupt_Handler::
140 * Pragma Interrupt_State::
141 * Pragma Keep_Names::
144 * Pragma Linker_Alias::
145 * Pragma Linker_Section::
146 * Pragma Long_Float::
147 * Pragma Machine_Attribute::
148 * Pragma Main_Storage::
150 * Pragma Normalize_Scalars::
151 * Pragma Obsolescent::
154 * Pragma Propagate_Exceptions::
155 * Pragma Psect_Object::
156 * Pragma Pure_Function::
158 * Pragma Restricted_Run_Time::
159 * Pragma Restriction_Warnings::
160 * Pragma Source_File_Name::
161 * Pragma Source_File_Name_Project::
162 * Pragma Source_Reference::
163 * Pragma Stream_Convert::
164 * Pragma Style_Checks::
166 * Pragma Suppress_All::
167 * Pragma Suppress_Exception_Locations::
168 * Pragma Suppress_Initialization::
171 * Pragma Task_Storage::
172 * Pragma Thread_Body::
173 * Pragma Time_Slice::
175 * Pragma Unchecked_Union::
176 * Pragma Unimplemented_Unit::
177 * Pragma Universal_Data::
178 * Pragma Unreferenced::
179 * Pragma Unreserve_All_Interrupts::
180 * Pragma Unsuppress::
181 * Pragma Use_VADS_Size::
182 * Pragma Validity_Checks::
185 * Pragma Weak_External::
187 Implementation Defined Attributes
197 * Default_Bit_Order::
205 * Has_Discriminants::
211 * Max_Interrupt_Priority::
213 * Maximum_Alignment::
217 * Passed_By_Reference::
228 * Unconstrained_Array::
229 * Universal_Literal_String::
230 * Unrestricted_Access::
236 The Implementation of Standard I/O
238 * Standard I/O Packages::
247 * Operations on C Streams::
248 * Interfacing to C Streams::
252 * Ada.Characters.Latin_9 (a-chlat9.ads)::
253 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
254 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
255 * Ada.Command_Line.Remove (a-colire.ads)::
256 * Ada.Command_Line.Environment (a-colien.ads)::
257 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
258 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
259 * Ada.Exceptions.Traceback (a-exctra.ads)::
260 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
261 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
262 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
263 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
264 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
265 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
266 * GNAT.Array_Split (g-arrspl.ads)::
267 * GNAT.AWK (g-awk.ads)::
268 * GNAT.Bounded_Buffers (g-boubuf.ads)::
269 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
270 * GNAT.Bubble_Sort (g-bubsor.ads)::
271 * GNAT.Bubble_Sort_A (g-busora.ads)::
272 * GNAT.Bubble_Sort_G (g-busorg.ads)::
273 * GNAT.Calendar (g-calend.ads)::
274 * GNAT.Calendar.Time_IO (g-catiio.ads)::
275 * GNAT.Case_Util (g-casuti.ads)::
276 * GNAT.CGI (g-cgi.ads)::
277 * GNAT.CGI.Cookie (g-cgicoo.ads)::
278 * GNAT.CGI.Debug (g-cgideb.ads)::
279 * GNAT.Command_Line (g-comlin.ads)::
280 * GNAT.Compiler_Version (g-comver.ads)::
281 * GNAT.Ctrl_C (g-ctrl_c.ads)::
282 * GNAT.CRC32 (g-crc32.ads)::
283 * GNAT.Current_Exception (g-curexc.ads)::
284 * GNAT.Debug_Pools (g-debpoo.ads)::
285 * GNAT.Debug_Utilities (g-debuti.ads)::
286 * GNAT.Directory_Operations (g-dirope.ads)::
287 * GNAT.Dynamic_HTables (g-dynhta.ads)::
288 * GNAT.Dynamic_Tables (g-dyntab.ads)::
289 * GNAT.Exception_Actions (g-excact.ads)::
290 * GNAT.Exception_Traces (g-exctra.ads)::
291 * GNAT.Exceptions (g-except.ads)::
292 * GNAT.Expect (g-expect.ads)::
293 * GNAT.Float_Control (g-flocon.ads)::
294 * GNAT.Heap_Sort (g-heasor.ads)::
295 * GNAT.Heap_Sort_A (g-hesora.ads)::
296 * GNAT.Heap_Sort_G (g-hesorg.ads)::
297 * GNAT.HTable (g-htable.ads)::
298 * GNAT.IO (g-io.ads)::
299 * GNAT.IO_Aux (g-io_aux.ads)::
300 * GNAT.Lock_Files (g-locfil.ads)::
301 * GNAT.MD5 (g-md5.ads)::
302 * GNAT.Memory_Dump (g-memdum.ads)::
303 * GNAT.Most_Recent_Exception (g-moreex.ads)::
304 * GNAT.OS_Lib (g-os_lib.ads)::
305 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
306 * GNAT.Regexp (g-regexp.ads)::
307 * GNAT.Registry (g-regist.ads)::
308 * GNAT.Regpat (g-regpat.ads)::
309 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
310 * GNAT.Semaphores (g-semaph.ads)::
311 * GNAT.Signals (g-signal.ads)::
312 * GNAT.Sockets (g-socket.ads)::
313 * GNAT.Source_Info (g-souinf.ads)::
314 * GNAT.Spell_Checker (g-speche.ads)::
315 * GNAT.Spitbol.Patterns (g-spipat.ads)::
316 * GNAT.Spitbol (g-spitbo.ads)::
317 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
318 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
319 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
320 * GNAT.Strings (g-string.ads)::
321 * GNAT.String_Split (g-strspl.ads)::
322 * GNAT.Table (g-table.ads)::
323 * GNAT.Task_Lock (g-tasloc.ads)::
324 * GNAT.Threads (g-thread.ads)::
325 * GNAT.Traceback (g-traceb.ads)::
326 * GNAT.Traceback.Symbolic (g-trasym.ads)::
327 * GNAT.Wide_String_Split (g-wistsp.ads)::
328 * Interfaces.C.Extensions (i-cexten.ads)::
329 * Interfaces.C.Streams (i-cstrea.ads)::
330 * Interfaces.CPP (i-cpp.ads)::
331 * Interfaces.Os2lib (i-os2lib.ads)::
332 * Interfaces.Os2lib.Errors (i-os2err.ads)::
333 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
334 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
335 * Interfaces.Packed_Decimal (i-pacdec.ads)::
336 * Interfaces.VxWorks (i-vxwork.ads)::
337 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
338 * System.Address_Image (s-addima.ads)::
339 * System.Assertions (s-assert.ads)::
340 * System.Memory (s-memory.ads)::
341 * System.Partition_Interface (s-parint.ads)::
342 * System.Restrictions (s-restri.ads)::
343 * System.Rident (s-rident.ads)::
344 * System.Task_Info (s-tasinf.ads)::
345 * System.Wch_Cnv (s-wchcnv.ads)::
346 * System.Wch_Con (s-wchcon.ads)::
350 * Text_IO Stream Pointer Positioning::
351 * Text_IO Reading and Writing Non-Regular Files::
353 * Treating Text_IO Files as Streams::
354 * Text_IO Extensions::
355 * Text_IO Facilities for Unbounded Strings::
359 * Wide_Text_IO Stream Pointer Positioning::
360 * Wide_Text_IO Reading and Writing Non-Regular Files::
362 Interfacing to Other Languages
365 * Interfacing to C++::
366 * Interfacing to COBOL::
367 * Interfacing to Fortran::
368 * Interfacing to non-GNAT Ada code::
370 Specialized Needs Annexes
372 Implementation of Specific Ada Features
373 * Machine Code Insertions::
374 * GNAT Implementation of Tasking::
375 * GNAT Implementation of Shared Passive Packages::
376 * Code Generation for Array Aggregates::
378 Project File Reference
380 GNU Free Documentation License
387 @node About This Guide
388 @unnumbered About This Guide
391 This manual contains useful information in writing programs using the
392 GNAT compiler. It includes information on implementation dependent
393 characteristics of GNAT, including all the information required by Annex
396 Ada 95 is designed to be highly portable.
397 In general, a program will have the same effect even when compiled by
398 different compilers on different platforms.
399 However, since Ada 95 is designed to be used in a
400 wide variety of applications, it also contains a number of system
401 dependent features to be used in interfacing to the external world.
402 @cindex Implementation-dependent features
405 Note: Any program that makes use of implementation-dependent features
406 may be non-portable. You should follow good programming practice and
407 isolate and clearly document any sections of your program that make use
408 of these features in a non-portable manner.
411 * What This Reference Manual Contains::
413 * Related Information::
416 @node What This Reference Manual Contains
417 @unnumberedsec What This Reference Manual Contains
420 This reference manual contains the following chapters:
424 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
425 pragmas, which can be used to extend and enhance the functionality of the
429 @ref{Implementation Defined Attributes}, lists GNAT
430 implementation-dependent attributes which can be used to extend and
431 enhance the functionality of the compiler.
434 @ref{Implementation Advice}, provides information on generally
435 desirable behavior which are not requirements that all compilers must
436 follow since it cannot be provided on all systems, or which may be
437 undesirable on some systems.
440 @ref{Implementation Defined Characteristics}, provides a guide to
441 minimizing implementation dependent features.
444 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
445 implemented by GNAT, and how they can be imported into user
446 application programs.
449 @ref{Representation Clauses and Pragmas}, describes in detail the
450 way that GNAT represents data, and in particular the exact set
451 of representation clauses and pragmas that is accepted.
454 @ref{Standard Library Routines}, provides a listing of packages and a
455 brief description of the functionality that is provided by Ada's
456 extensive set of standard library routines as implemented by GNAT@.
459 @ref{The Implementation of Standard I/O}, details how the GNAT
460 implementation of the input-output facilities.
463 @ref{The GNAT Library}, is a catalog of packages that complement
464 the Ada predefined library.
467 @ref{Interfacing to Other Languages}, describes how programs
468 written in Ada using GNAT can be interfaced to other programming
471 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
472 of the specialized needs annexes.
475 @ref{Implementation of Specific Ada Features}, discusses issues related
476 to GNAT's implementation of machine code insertions, tasking, and several
480 @ref{Project File Reference}, presents the syntax and semantics
485 @cindex Ada 95 ISO/ANSI Standard
487 This reference manual assumes that you are familiar with Ada 95
488 language, as described in the International Standard
489 ANSI/ISO/IEC-8652:1995, Jan 1995.
492 @unnumberedsec Conventions
493 @cindex Conventions, typographical
494 @cindex Typographical conventions
497 Following are examples of the typographical and graphic conventions used
502 @code{Functions}, @code{utility program names}, @code{standard names},
509 @file{File Names}, @samp{button names}, and @samp{field names}.
518 [optional information or parameters]
521 Examples are described by text
523 and then shown this way.
528 Commands that are entered by the user are preceded in this manual by the
529 characters @samp{$ } (dollar sign followed by space). If your system uses this
530 sequence as a prompt, then the commands will appear exactly as you see them
531 in the manual. If your system uses some other prompt, then the command will
532 appear with the @samp{$} replaced by whatever prompt character you are using.
534 @node Related Information
535 @unnumberedsec Related Information
537 See the following documents for further information on GNAT:
541 @cite{GNAT User's Guide}, which provides information on how to use
542 the GNAT compiler system.
545 @cite{Ada 95 Reference Manual}, which contains all reference
546 material for the Ada 95 programming language.
549 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
550 of the standard reference manual cited above. The annotations describe
551 detailed aspects of the design decision, and in particular contain useful
552 sections on Ada 83 compatibility.
555 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
556 which contains specific information on compatibility between GNAT and
560 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
561 describes in detail the pragmas and attributes provided by the DEC Ada 83
566 @node Implementation Defined Pragmas
567 @chapter Implementation Defined Pragmas
570 Ada 95 defines a set of pragmas that can be used to supply additional
571 information to the compiler. These language defined pragmas are
572 implemented in GNAT and work as described in the Ada 95 Reference
575 In addition, Ada 95 allows implementations to define additional pragmas
576 whose meaning is defined by the implementation. GNAT provides a number
577 of these implementation-dependent pragmas which can be used to extend
578 and enhance the functionality of the compiler. This section of the GNAT
579 Reference Manual describes these additional pragmas.
581 Note that any program using these pragmas may not be portable to other
582 compilers (although GNAT implements this set of pragmas on all
583 platforms). Therefore if portability to other compilers is an important
584 consideration, the use of these pragmas should be minimized.
587 * Pragma Abort_Defer::
593 * Pragma C_Pass_By_Copy::
595 * Pragma Common_Object::
596 * Pragma Compile_Time_Warning::
597 * Pragma Complex_Representation::
598 * Pragma Component_Alignment::
599 * Pragma Convention_Identifier::
601 * Pragma CPP_Constructor::
602 * Pragma CPP_Virtual::
603 * Pragma CPP_Vtable::
605 * Pragma Elaboration_Checks::
607 * Pragma Export_Exception::
608 * Pragma Export_Function::
609 * Pragma Export_Object::
610 * Pragma Export_Procedure::
611 * Pragma Export_Value::
612 * Pragma Export_Valued_Procedure::
613 * Pragma Extend_System::
615 * Pragma External_Name_Casing::
616 * Pragma Finalize_Storage_Only::
617 * Pragma Float_Representation::
619 * Pragma Import_Exception::
620 * Pragma Import_Function::
621 * Pragma Import_Object::
622 * Pragma Import_Procedure::
623 * Pragma Import_Valued_Procedure::
624 * Pragma Initialize_Scalars::
625 * Pragma Inline_Always::
626 * Pragma Inline_Generic::
628 * Pragma Interface_Name::
629 * Pragma Interrupt_Handler::
630 * Pragma Interrupt_State::
631 * Pragma Keep_Names::
634 * Pragma Linker_Alias::
635 * Pragma Linker_Section::
636 * Pragma Long_Float::
637 * Pragma Machine_Attribute::
638 * Pragma Main_Storage::
640 * Pragma Normalize_Scalars::
641 * Pragma Obsolescent::
644 * Pragma Propagate_Exceptions::
645 * Pragma Psect_Object::
646 * Pragma Pure_Function::
648 * Pragma Restricted_Run_Time::
649 * Pragma Restriction_Warnings::
650 * Pragma Source_File_Name::
651 * Pragma Source_File_Name_Project::
652 * Pragma Source_Reference::
653 * Pragma Stream_Convert::
654 * Pragma Style_Checks::
656 * Pragma Suppress_All::
657 * Pragma Suppress_Exception_Locations::
658 * Pragma Suppress_Initialization::
661 * Pragma Task_Storage::
662 * Pragma Thread_Body::
663 * Pragma Time_Slice::
665 * Pragma Unchecked_Union::
666 * Pragma Unimplemented_Unit::
667 * Pragma Universal_Data::
668 * Pragma Unreferenced::
669 * Pragma Unreserve_All_Interrupts::
670 * Pragma Unsuppress::
671 * Pragma Use_VADS_Size::
672 * Pragma Validity_Checks::
675 * Pragma Weak_External::
678 @node Pragma Abort_Defer
679 @unnumberedsec Pragma Abort_Defer
681 @cindex Deferring aborts
689 This pragma must appear at the start of the statement sequence of a
690 handled sequence of statements (right after the @code{begin}). It has
691 the effect of deferring aborts for the sequence of statements (but not
692 for the declarations or handlers, if any, associated with this statement
696 @unnumberedsec Pragma Ada_83
705 A configuration pragma that establishes Ada 83 mode for the unit to
706 which it applies, regardless of the mode set by the command line
707 switches. In Ada 83 mode, GNAT attempts to be as compatible with
708 the syntax and semantics of Ada 83, as defined in the original Ada
709 83 Reference Manual as possible. In particular, the new Ada 95
710 keywords are not recognized, optional package bodies are allowed,
711 and generics may name types with unknown discriminants without using
712 the @code{(<>)} notation. In addition, some but not all of the additional
713 restrictions of Ada 83 are enforced.
715 Ada 83 mode is intended for two purposes. Firstly, it allows existing
716 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
717 Secondly, it aids in keeping code backwards compatible with Ada 83.
718 However, there is no guarantee that code that is processed correctly
719 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
720 83 compiler, since GNAT does not enforce all the additional checks
724 @unnumberedsec Pragma Ada_95
733 A configuration pragma that establishes Ada 95 mode for the unit to which
734 it applies, regardless of the mode set by the command line switches.
735 This mode is set automatically for the @code{Ada} and @code{System}
736 packages and their children, so you need not specify it in these
737 contexts. This pragma is useful when writing a reusable component that
738 itself uses Ada 95 features, but which is intended to be usable from
739 either Ada 83 or Ada 95 programs.
741 @node Pragma Annotate
742 @unnumberedsec Pragma Annotate
747 pragma Annotate (IDENTIFIER @{, ARG@});
749 ARG ::= NAME | EXPRESSION
753 This pragma is used to annotate programs. @var{identifier} identifies
754 the type of annotation. GNAT verifies this is an identifier, but does
755 not otherwise analyze it. The @var{arg} argument
756 can be either a string literal or an
757 expression. String literals are assumed to be of type
758 @code{Standard.String}. Names of entities are simply analyzed as entity
759 names. All other expressions are analyzed as expressions, and must be
762 The analyzed pragma is retained in the tree, but not otherwise processed
763 by any part of the GNAT compiler. This pragma is intended for use by
764 external tools, including ASIS@.
767 @unnumberedsec Pragma Assert
774 [, static_string_EXPRESSION]);
778 The effect of this pragma depends on whether the corresponding command
779 line switch is set to activate assertions. The pragma expands into code
780 equivalent to the following:
783 if assertions-enabled then
784 if not boolean_EXPRESSION then
785 System.Assertions.Raise_Assert_Failure
792 The string argument, if given, is the message that will be associated
793 with the exception occurrence if the exception is raised. If no second
794 argument is given, the default message is @samp{@var{file}:@var{nnn}},
795 where @var{file} is the name of the source file containing the assert,
796 and @var{nnn} is the line number of the assert. A pragma is not a
797 statement, so if a statement sequence contains nothing but a pragma
798 assert, then a null statement is required in addition, as in:
803 pragma Assert (K > 3, "Bad value for K");
809 Note that, as with the @code{if} statement to which it is equivalent, the
810 type of the expression is either @code{Standard.Boolean}, or any type derived
811 from this standard type.
813 If assertions are disabled (switch @code{-gnata} not used), then there
814 is no effect (and in particular, any side effects from the expression
815 are suppressed). More precisely it is not quite true that the pragma
816 has no effect, since the expression is analyzed, and may cause types
817 to be frozen if they are mentioned here for the first time.
819 If assertions are enabled, then the given expression is tested, and if
820 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
821 which results in the raising of @code{Assert_Failure} with the given message.
823 If the boolean expression has side effects, these side effects will turn
824 on and off with the setting of the assertions mode, resulting in
825 assertions that have an effect on the program. You should generally
826 avoid side effects in the expression arguments of this pragma. However,
827 the expressions are analyzed for semantic correctness whether or not
828 assertions are enabled, so turning assertions on and off cannot affect
829 the legality of a program.
831 @node Pragma Ast_Entry
832 @unnumberedsec Pragma Ast_Entry
838 pragma AST_Entry (entry_IDENTIFIER);
842 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
843 argument is the simple name of a single entry; at most one @code{AST_Entry}
844 pragma is allowed for any given entry. This pragma must be used in
845 conjunction with the @code{AST_Entry} attribute, and is only allowed after
846 the entry declaration and in the same task type specification or single task
847 as the entry to which it applies. This pragma specifies that the given entry
848 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
849 resulting from an OpenVMS system service call. The pragma does not affect
850 normal use of the entry. For further details on this pragma, see the
851 DEC Ada Language Reference Manual, section 9.12a.
853 @node Pragma C_Pass_By_Copy
854 @unnumberedsec Pragma C_Pass_By_Copy
855 @cindex Passing by copy
856 @findex C_Pass_By_Copy
860 pragma C_Pass_By_Copy
861 ([Max_Size =>] static_integer_EXPRESSION);
865 Normally the default mechanism for passing C convention records to C
866 convention subprograms is to pass them by reference, as suggested by RM
867 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
868 this default, by requiring that record formal parameters be passed by
869 copy if all of the following conditions are met:
873 The size of the record type does not exceed@*@var{static_integer_expression}.
875 The record type has @code{Convention C}.
877 The formal parameter has this record type, and the subprogram has a
878 foreign (non-Ada) convention.
882 If these conditions are met the argument is passed by copy, i.e.@: in a
883 manner consistent with what C expects if the corresponding formal in the
884 C prototype is a struct (rather than a pointer to a struct).
886 You can also pass records by copy by specifying the convention
887 @code{C_Pass_By_Copy} for the record type, or by using the extended
888 @code{Import} and @code{Export} pragmas, which allow specification of
889 passing mechanisms on a parameter by parameter basis.
892 @unnumberedsec Pragma Comment
898 pragma Comment (static_string_EXPRESSION);
902 This is almost identical in effect to pragma @code{Ident}. It allows the
903 placement of a comment into the object file and hence into the
904 executable file if the operating system permits such usage. The
905 difference is that @code{Comment}, unlike @code{Ident}, has
906 no limitations on placement of the pragma (it can be placed
907 anywhere in the main source unit), and if more than one pragma
908 is used, all comments are retained.
910 @node Pragma Common_Object
911 @unnumberedsec Pragma Common_Object
912 @findex Common_Object
917 pragma Common_Object (
918 [Internal =>] LOCAL_NAME,
919 [, [External =>] EXTERNAL_SYMBOL]
920 [, [Size =>] EXTERNAL_SYMBOL] );
924 | static_string_EXPRESSION
928 This pragma enables the shared use of variables stored in overlaid
929 linker areas corresponding to the use of @code{COMMON}
930 in Fortran. The single
931 object @var{local_name} is assigned to the area designated by
932 the @var{External} argument.
933 You may define a record to correspond to a series
934 of fields. The @var{size} argument
935 is syntax checked in GNAT, but otherwise ignored.
937 @code{Common_Object} is not supported on all platforms. If no
938 support is available, then the code generator will issue a message
939 indicating that the necessary attribute for implementation of this
940 pragma is not available.
942 @node Pragma Compile_Time_Warning
943 @unnumberedsec Pragma Compile_Time_Warning
944 @findex Compile_Time_Warning
949 pragma Compile_Time_Warning
950 (boolean_EXPRESSION, static_string_EXPRESSION);
954 This pragma can be used to generate additional compile time warnings. It
955 is particularly useful in generics, where warnings can be issued for
956 specific problematic instantiations. The first parameter is a boolean
957 expression. The pragma is effective only if the value of this expression
958 is known at compile time, and has the value True. The set of expressions
959 whose values are known at compile time includes all static boolean
960 expressions, and also other values which the compiler can determine
961 at compile time (e.g. the size of a record type set by an explicit
962 size representation clause, or the value of a variable which was
963 initialized to a constant and is known not to have been modified).
964 If these conditions are met, a warning message is generated using
965 the value given as the second argument. This string value may contain
966 embedded ASCII.LF characters to break the message into multiple lines.
968 @node Pragma Complex_Representation
969 @unnumberedsec Pragma Complex_Representation
970 @findex Complex_Representation
975 pragma Complex_Representation
976 ([Entity =>] LOCAL_NAME);
980 The @var{Entity} argument must be the name of a record type which has
981 two fields of the same floating-point type. The effect of this pragma is
982 to force gcc to use the special internal complex representation form for
983 this record, which may be more efficient. Note that this may result in
984 the code for this type not conforming to standard ABI (application
985 binary interface) requirements for the handling of record types. For
986 example, in some environments, there is a requirement for passing
987 records by pointer, and the use of this pragma may result in passing
988 this type in floating-point registers.
990 @node Pragma Component_Alignment
991 @unnumberedsec Pragma Component_Alignment
992 @cindex Alignments of components
993 @findex Component_Alignment
998 pragma Component_Alignment (
999 [Form =>] ALIGNMENT_CHOICE
1000 [, [Name =>] type_LOCAL_NAME]);
1002 ALIGNMENT_CHOICE ::=
1010 Specifies the alignment of components in array or record types.
1011 The meaning of the @var{Form} argument is as follows:
1014 @findex Component_Size
1015 @item Component_Size
1016 Aligns scalar components and subcomponents of the array or record type
1017 on boundaries appropriate to their inherent size (naturally
1018 aligned). For example, 1-byte components are aligned on byte boundaries,
1019 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1020 integer components are aligned on 4-byte boundaries and so on. These
1021 alignment rules correspond to the normal rules for C compilers on all
1022 machines except the VAX@.
1024 @findex Component_Size_4
1025 @item Component_Size_4
1026 Naturally aligns components with a size of four or fewer
1027 bytes. Components that are larger than 4 bytes are placed on the next
1030 @findex Storage_Unit
1032 Specifies that array or record components are byte aligned, i.e.@:
1033 aligned on boundaries determined by the value of the constant
1034 @code{System.Storage_Unit}.
1038 Specifies that array or record components are aligned on default
1039 boundaries, appropriate to the underlying hardware or operating system or
1040 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1041 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1042 the @code{Default} choice is the same as @code{Component_Size} (natural
1047 If the @code{Name} parameter is present, @var{type_local_name} must
1048 refer to a local record or array type, and the specified alignment
1049 choice applies to the specified type. The use of
1050 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1051 @code{Component_Alignment} pragma to be ignored. The use of
1052 @code{Component_Alignment} together with a record representation clause
1053 is only effective for fields not specified by the representation clause.
1055 If the @code{Name} parameter is absent, the pragma can be used as either
1056 a configuration pragma, in which case it applies to one or more units in
1057 accordance with the normal rules for configuration pragmas, or it can be
1058 used within a declarative part, in which case it applies to types that
1059 are declared within this declarative part, or within any nested scope
1060 within this declarative part. In either case it specifies the alignment
1061 to be applied to any record or array type which has otherwise standard
1064 If the alignment for a record or array type is not specified (using
1065 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1066 clause), the GNAT uses the default alignment as described previously.
1068 @node Pragma Convention_Identifier
1069 @unnumberedsec Pragma Convention_Identifier
1070 @findex Convention_Identifier
1071 @cindex Conventions, synonyms
1075 @smallexample @c ada
1076 pragma Convention_Identifier (
1077 [Name =>] IDENTIFIER,
1078 [Convention =>] convention_IDENTIFIER);
1082 This pragma provides a mechanism for supplying synonyms for existing
1083 convention identifiers. The @code{Name} identifier can subsequently
1084 be used as a synonym for the given convention in other pragmas (including
1085 for example pragma @code{Import} or another @code{Convention_Identifier}
1086 pragma). As an example of the use of this, suppose you had legacy code
1087 which used Fortran77 as the identifier for Fortran. Then the pragma:
1089 @smallexample @c ada
1090 pragma Convention_Identifier (Fortran77, Fortran);
1094 would allow the use of the convention identifier @code{Fortran77} in
1095 subsequent code, avoiding the need to modify the sources. As another
1096 example, you could use this to parametrize convention requirements
1097 according to systems. Suppose you needed to use @code{Stdcall} on
1098 windows systems, and @code{C} on some other system, then you could
1099 define a convention identifier @code{Library} and use a single
1100 @code{Convention_Identifier} pragma to specify which convention
1101 would be used system-wide.
1103 @node Pragma CPP_Class
1104 @unnumberedsec Pragma CPP_Class
1106 @cindex Interfacing with C++
1110 @smallexample @c ada
1111 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1115 The argument denotes an entity in the current declarative region
1116 that is declared as a tagged or untagged record type. It indicates that
1117 the type corresponds to an externally declared C++ class type, and is to
1118 be laid out the same way that C++ would lay out the type.
1120 If (and only if) the type is tagged, at least one component in the
1121 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1122 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1125 Types for which @code{CPP_Class} is specified do not have assignment or
1126 equality operators defined (such operations can be imported or declared
1127 as subprograms as required). Initialization is allowed only by
1128 constructor functions (see pragma @code{CPP_Constructor}).
1130 Pragma @code{CPP_Class} is intended primarily for automatic generation
1131 using an automatic binding generator tool.
1132 See @ref{Interfacing to C++} for related information.
1134 @node Pragma CPP_Constructor
1135 @unnumberedsec Pragma CPP_Constructor
1136 @cindex Interfacing with C++
1137 @findex CPP_Constructor
1141 @smallexample @c ada
1142 pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
1146 This pragma identifies an imported function (imported in the usual way
1147 with pragma @code{Import}) as corresponding to a C++
1148 constructor. The argument is a name that must have been
1149 previously mentioned in a pragma @code{Import}
1150 with @code{Convention} = @code{CPP}, and must be of one of the following
1155 @code{function @var{Fname} return @var{T}'Class}
1158 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1162 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1164 The first form is the default constructor, used when an object of type
1165 @var{T} is created on the Ada side with no explicit constructor. Other
1166 constructors (including the copy constructor, which is simply a special
1167 case of the second form in which the one and only argument is of type
1168 @var{T}), can only appear in two contexts:
1172 On the right side of an initialization of an object of type @var{T}.
1174 In an extension aggregate for an object of a type derived from @var{T}.
1178 Although the constructor is described as a function that returns a value
1179 on the Ada side, it is typically a procedure with an extra implicit
1180 argument (the object being initialized) at the implementation
1181 level. GNAT issues the appropriate call, whatever it is, to get the
1182 object properly initialized.
1184 In the case of derived objects, you may use one of two possible forms
1185 for declaring and creating an object:
1188 @item @code{New_Object : Derived_T}
1189 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1193 In the first case the default constructor is called and extension fields
1194 if any are initialized according to the default initialization
1195 expressions in the Ada declaration. In the second case, the given
1196 constructor is called and the extension aggregate indicates the explicit
1197 values of the extension fields.
1199 If no constructors are imported, it is impossible to create any objects
1200 on the Ada side. If no default constructor is imported, only the
1201 initialization forms using an explicit call to a constructor are
1204 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1205 using an automatic binding generator tool.
1206 See @ref{Interfacing to C++} for more related information.
1208 @node Pragma CPP_Virtual
1209 @unnumberedsec Pragma CPP_Virtual
1210 @cindex Interfacing to C++
1215 @smallexample @c ada
1218 [, [Vtable_Ptr =>] vtable_ENTITY,]
1219 [, [Position =>] static_integer_EXPRESSION]);
1223 This pragma serves the same function as pragma @code{Import} in that
1224 case of a virtual function imported from C++. The @var{Entity} argument
1226 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1227 applies. The @var{Vtable_Ptr} argument specifies
1228 the Vtable_Ptr component which contains the
1229 entry for this virtual function. The @var{Position} argument
1230 is the sequential number
1231 counting virtual functions for this Vtable starting at 1.
1233 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1234 there is one Vtable_Ptr present (single inheritance case) and all
1235 virtual functions are imported. In that case the compiler can deduce both
1238 No @code{External_Name} or @code{Link_Name} arguments are required for a
1239 virtual function, since it is always accessed indirectly via the
1240 appropriate Vtable entry.
1242 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1243 using an automatic binding generator tool.
1244 See @ref{Interfacing to C++} for related information.
1246 @node Pragma CPP_Vtable
1247 @unnumberedsec Pragma CPP_Vtable
1248 @cindex Interfacing with C++
1253 @smallexample @c ada
1256 [Vtable_Ptr =>] vtable_ENTITY,
1257 [Entry_Count =>] static_integer_EXPRESSION);
1261 Given a record to which the pragma @code{CPP_Class} applies,
1262 this pragma can be specified for each component of type
1263 @code{CPP.Interfaces.Vtable_Ptr}.
1264 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1265 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1266 the number of virtual functions on the C++ side. Not all of these
1267 functions need to be imported on the Ada side.
1269 You may omit the @code{CPP_Vtable} pragma if there is only one
1270 @code{Vtable_Ptr} component in the record and all virtual functions are
1271 imported on the Ada side (the default value for the entry count in this
1272 case is simply the total number of virtual functions).
1274 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1275 using an automatic binding generator tool.
1276 See @ref{Interfacing to C++} for related information.
1279 @unnumberedsec Pragma Debug
1284 @smallexample @c ada
1285 pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON);
1287 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1289 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1293 The argument has the syntactic form of an expression, meeting the
1294 syntactic requirements for pragmas.
1296 If assertions are not enabled on the command line, this pragma has no
1297 effect. If asserts are enabled, the semantics of the pragma is exactly
1298 equivalent to the procedure call statement corresponding to the argument
1299 with a terminating semicolon. Pragmas are permitted in sequences of
1300 declarations, so you can use pragma @code{Debug} to intersperse calls to
1301 debug procedures in the middle of declarations.
1303 @node Pragma Elaboration_Checks
1304 @unnumberedsec Pragma Elaboration_Checks
1305 @cindex Elaboration control
1306 @findex Elaboration_Checks
1310 @smallexample @c ada
1311 pragma Elaboration_Checks (Dynamic | Static);
1315 This is a configuration pragma that provides control over the
1316 elaboration model used by the compilation affected by the
1317 pragma. If the parameter is @code{Dynamic},
1318 then the dynamic elaboration
1319 model described in the Ada Reference Manual is used, as though
1320 the @code{-gnatE} switch had been specified on the command
1321 line. If the parameter is @code{Static}, then the default GNAT static
1322 model is used. This configuration pragma overrides the setting
1323 of the command line. For full details on the elaboration models
1324 used by the GNAT compiler, see section ``Elaboration Order
1325 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1327 @node Pragma Eliminate
1328 @unnumberedsec Pragma Eliminate
1329 @cindex Elimination of unused subprograms
1334 @smallexample @c ada
1336 [Unit_Name =>] IDENTIFIER |
1337 SELECTED_COMPONENT);
1340 [Unit_Name =>] IDENTIFIER |
1342 [Entity =>] IDENTIFIER |
1343 SELECTED_COMPONENT |
1345 [,OVERLOADING_RESOLUTION]);
1347 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1350 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1353 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1355 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1356 Result_Type => result_SUBTYPE_NAME]
1358 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1359 SUBTYPE_NAME ::= STRING_LITERAL
1361 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1362 SOURCE_TRACE ::= STRING_LITERAL
1366 This pragma indicates that the given entity is not used outside the
1367 compilation unit it is defined in. The entity must be an explicitly declared
1368 subprogram; this includes generic subprogram instances and
1369 subprograms declared in generic package instances.
1371 If the entity to be eliminated is a library level subprogram, then
1372 the first form of pragma @code{Eliminate} is used with only a single argument.
1373 In this form, the @code{Unit_Name} argument specifies the name of the
1374 library level unit to be eliminated.
1376 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1377 are required. If item is an entity of a library package, then the first
1378 argument specifies the unit name, and the second argument specifies
1379 the particular entity. If the second argument is in string form, it must
1380 correspond to the internal manner in which GNAT stores entity names (see
1381 compilation unit Namet in the compiler sources for details).
1383 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1384 to distinguish between overloaded subprograms. If a pragma does not contain
1385 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1386 subprograms denoted by the first two parameters.
1388 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1389 to be eliminated in a manner similar to that used for the extended
1390 @code{Import} and @code{Export} pragmas, except that the subtype names are
1391 always given as string literals. At the moment, this form of distinguishing
1392 overloaded subprograms is implemented only partially, so we do not recommend
1393 using it for practical subprogram elimination.
1395 Note, that in case of a parameterless procedure its profile is represented
1396 as @code{Parameter_Types => ("")}
1398 Alternatively, the @code{Source_Location} parameter is used to specify
1399 which overloaded alternative is to be eliminated by pointing to the
1400 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1401 source text. The string literal submitted as SOURCE_TRACE should have
1402 the following format:
1404 @smallexample @c ada
1405 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1410 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1411 FILE_NAME ::= STRING_LITERAL
1412 LINE_NUMBER ::= DIGIT @{DIGIT@}
1415 SOURCE_TRACE should be the short name of the source file (with no directory
1416 information), and LINE_NUMBER is supposed to point to the line where the
1417 defining name of the subprogram is located.
1419 For the subprograms that are not a part of generic instantiations, only one
1420 SOURCE_LOCATION is used. If a subprogram is declared in a package
1421 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1422 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1423 second one denotes the declaration of the corresponding subprogram in the
1424 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1425 in case of nested instantiations.
1427 The effect of the pragma is to allow the compiler to eliminate
1428 the code or data associated with the named entity. Any reference to
1429 an eliminated entity outside the compilation unit it is defined in,
1430 causes a compile time or link time error.
1432 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1433 in a system independent manner, with unused entities eliminated, without
1434 the requirement of modifying the source text. Normally the required set
1435 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1436 tool. Elimination of unused entities local to a compilation unit is
1437 automatic, without requiring the use of pragma @code{Eliminate}.
1439 Note that the reason this pragma takes string literals where names might
1440 be expected is that a pragma @code{Eliminate} can appear in a context where the
1441 relevant names are not visible.
1443 Note that any change in the source files that includes removing, splitting of
1444 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1447 @node Pragma Export_Exception
1448 @unnumberedsec Pragma Export_Exception
1450 @findex Export_Exception
1454 @smallexample @c ada
1455 pragma Export_Exception (
1456 [Internal =>] LOCAL_NAME,
1457 [, [External =>] EXTERNAL_SYMBOL,]
1458 [, [Form =>] Ada | VMS]
1459 [, [Code =>] static_integer_EXPRESSION]);
1463 | static_string_EXPRESSION
1467 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1468 causes the specified exception to be propagated outside of the Ada program,
1469 so that it can be handled by programs written in other OpenVMS languages.
1470 This pragma establishes an external name for an Ada exception and makes the
1471 name available to the OpenVMS Linker as a global symbol. For further details
1472 on this pragma, see the
1473 DEC Ada Language Reference Manual, section 13.9a3.2.
1475 @node Pragma Export_Function
1476 @unnumberedsec Pragma Export_Function
1477 @cindex Argument passing mechanisms
1478 @findex Export_Function
1483 @smallexample @c ada
1484 pragma Export_Function (
1485 [Internal =>] LOCAL_NAME,
1486 [, [External =>] EXTERNAL_SYMBOL]
1487 [, [Parameter_Types =>] PARAMETER_TYPES]
1488 [, [Result_Type =>] result_SUBTYPE_MARK]
1489 [, [Mechanism =>] MECHANISM]
1490 [, [Result_Mechanism =>] MECHANISM_NAME]);
1494 | static_string_EXPRESSION
1499 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1503 | subtype_Name ' Access
1507 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1509 MECHANISM_ASSOCIATION ::=
1510 [formal_parameter_NAME =>] MECHANISM_NAME
1518 Use this pragma to make a function externally callable and optionally
1519 provide information on mechanisms to be used for passing parameter and
1520 result values. We recommend, for the purposes of improving portability,
1521 this pragma always be used in conjunction with a separate pragma
1522 @code{Export}, which must precede the pragma @code{Export_Function}.
1523 GNAT does not require a separate pragma @code{Export}, but if none is
1524 present, @code{Convention Ada} is assumed, which is usually
1525 not what is wanted, so it is usually appropriate to use this
1526 pragma in conjunction with a @code{Export} or @code{Convention}
1527 pragma that specifies the desired foreign convention.
1528 Pragma @code{Export_Function}
1529 (and @code{Export}, if present) must appear in the same declarative
1530 region as the function to which they apply.
1532 @var{internal_name} must uniquely designate the function to which the
1533 pragma applies. If more than one function name exists of this name in
1534 the declarative part you must use the @code{Parameter_Types} and
1535 @code{Result_Type} parameters is mandatory to achieve the required
1536 unique designation. @var{subtype_ mark}s in these parameters must
1537 exactly match the subtypes in the corresponding function specification,
1538 using positional notation to match parameters with subtype marks.
1539 The form with an @code{'Access} attribute can be used to match an
1540 anonymous access parameter.
1543 @cindex Passing by descriptor
1544 Note that passing by descriptor is not supported, even on the OpenVMS
1547 @cindex Suppressing external name
1548 Special treatment is given if the EXTERNAL is an explicit null
1549 string or a static string expressions that evaluates to the null
1550 string. In this case, no external name is generated. This form
1551 still allows the specification of parameter mechanisms.
1553 @node Pragma Export_Object
1554 @unnumberedsec Pragma Export_Object
1555 @findex Export_Object
1559 @smallexample @c ada
1560 pragma Export_Object
1561 [Internal =>] LOCAL_NAME,
1562 [, [External =>] EXTERNAL_SYMBOL]
1563 [, [Size =>] EXTERNAL_SYMBOL]
1567 | static_string_EXPRESSION
1571 This pragma designates an object as exported, and apart from the
1572 extended rules for external symbols, is identical in effect to the use of
1573 the normal @code{Export} pragma applied to an object. You may use a
1574 separate Export pragma (and you probably should from the point of view
1575 of portability), but it is not required. @var{Size} is syntax checked,
1576 but otherwise ignored by GNAT@.
1578 @node Pragma Export_Procedure
1579 @unnumberedsec Pragma Export_Procedure
1580 @findex Export_Procedure
1584 @smallexample @c ada
1585 pragma Export_Procedure (
1586 [Internal =>] LOCAL_NAME
1587 [, [External =>] EXTERNAL_SYMBOL]
1588 [, [Parameter_Types =>] PARAMETER_TYPES]
1589 [, [Mechanism =>] MECHANISM]);
1593 | static_string_EXPRESSION
1598 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1602 | subtype_Name ' Access
1606 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1608 MECHANISM_ASSOCIATION ::=
1609 [formal_parameter_NAME =>] MECHANISM_NAME
1617 This pragma is identical to @code{Export_Function} except that it
1618 applies to a procedure rather than a function and the parameters
1619 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1620 GNAT does not require a separate pragma @code{Export}, but if none is
1621 present, @code{Convention Ada} is assumed, which is usually
1622 not what is wanted, so it is usually appropriate to use this
1623 pragma in conjunction with a @code{Export} or @code{Convention}
1624 pragma that specifies the desired foreign convention.
1627 @cindex Passing by descriptor
1628 Note that passing by descriptor is not supported, even on the OpenVMS
1631 @cindex Suppressing external name
1632 Special treatment is given if the EXTERNAL is an explicit null
1633 string or a static string expressions that evaluates to the null
1634 string. In this case, no external name is generated. This form
1635 still allows the specification of parameter mechanisms.
1637 @node Pragma Export_Value
1638 @unnumberedsec Pragma Export_Value
1639 @findex Export_Value
1643 @smallexample @c ada
1644 pragma Export_Value (
1645 [Value =>] static_integer_EXPRESSION,
1646 [Link_Name =>] static_string_EXPRESSION);
1650 This pragma serves to export a static integer value for external use.
1651 The first argument specifies the value to be exported. The Link_Name
1652 argument specifies the symbolic name to be associated with the integer
1653 value. This pragma is useful for defining a named static value in Ada
1654 that can be referenced in assembly language units to be linked with
1655 the application. This pragma is currently supported only for the
1656 AAMP target and is ignored for other targets.
1658 @node Pragma Export_Valued_Procedure
1659 @unnumberedsec Pragma Export_Valued_Procedure
1660 @findex Export_Valued_Procedure
1664 @smallexample @c ada
1665 pragma Export_Valued_Procedure (
1666 [Internal =>] LOCAL_NAME
1667 [, [External =>] EXTERNAL_SYMBOL]
1668 [, [Parameter_Types =>] PARAMETER_TYPES]
1669 [, [Mechanism =>] MECHANISM]);
1673 | static_string_EXPRESSION
1678 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1682 | subtype_Name ' Access
1686 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1688 MECHANISM_ASSOCIATION ::=
1689 [formal_parameter_NAME =>] MECHANISM_NAME
1697 This pragma is identical to @code{Export_Procedure} except that the
1698 first parameter of @var{local_name}, which must be present, must be of
1699 mode @code{OUT}, and externally the subprogram is treated as a function
1700 with this parameter as the result of the function. GNAT provides for
1701 this capability to allow the use of @code{OUT} and @code{IN OUT}
1702 parameters in interfacing to external functions (which are not permitted
1704 GNAT does not require a separate pragma @code{Export}, but if none is
1705 present, @code{Convention Ada} is assumed, which is almost certainly
1706 not what is wanted since the whole point of this pragma is to interface
1707 with foreign language functions, so it is usually appropriate to use this
1708 pragma in conjunction with a @code{Export} or @code{Convention}
1709 pragma that specifies the desired foreign convention.
1712 @cindex Passing by descriptor
1713 Note that passing by descriptor is not supported, even on the OpenVMS
1716 @cindex Suppressing external name
1717 Special treatment is given if the EXTERNAL is an explicit null
1718 string or a static string expressions that evaluates to the null
1719 string. In this case, no external name is generated. This form
1720 still allows the specification of parameter mechanisms.
1722 @node Pragma Extend_System
1723 @unnumberedsec Pragma Extend_System
1724 @cindex @code{system}, extending
1726 @findex Extend_System
1730 @smallexample @c ada
1731 pragma Extend_System ([Name =>] IDENTIFIER);
1735 This pragma is used to provide backwards compatibility with other
1736 implementations that extend the facilities of package @code{System}. In
1737 GNAT, @code{System} contains only the definitions that are present in
1738 the Ada 95 RM@. However, other implementations, notably the DEC Ada 83
1739 implementation, provide many extensions to package @code{System}.
1741 For each such implementation accommodated by this pragma, GNAT provides a
1742 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1743 implementation, which provides the required additional definitions. You
1744 can use this package in two ways. You can @code{with} it in the normal
1745 way and access entities either by selection or using a @code{use}
1746 clause. In this case no special processing is required.
1748 However, if existing code contains references such as
1749 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1750 definitions provided in package @code{System}, you may use this pragma
1751 to extend visibility in @code{System} in a non-standard way that
1752 provides greater compatibility with the existing code. Pragma
1753 @code{Extend_System} is a configuration pragma whose single argument is
1754 the name of the package containing the extended definition
1755 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
1756 control of this pragma will be processed using special visibility
1757 processing that looks in package @code{System.Aux_@var{xxx}} where
1758 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1759 package @code{System}, but not found in package @code{System}.
1761 You can use this pragma either to access a predefined @code{System}
1762 extension supplied with the compiler, for example @code{Aux_DEC} or
1763 you can construct your own extension unit following the above
1764 definition. Note that such a package is a child of @code{System}
1765 and thus is considered part of the implementation. To compile
1766 it you will have to use the appropriate switch for compiling
1767 system units. See the GNAT User's Guide for details.
1769 @node Pragma External
1770 @unnumberedsec Pragma External
1775 @smallexample @c ada
1777 [ Convention =>] convention_IDENTIFIER,
1778 [ Entity =>] local_NAME
1779 [, [External_Name =>] static_string_EXPRESSION ]
1780 [, [Link_Name =>] static_string_EXPRESSION ]);
1784 This pragma is identical in syntax and semantics to pragma
1785 @code{Export} as defined in the Ada Reference Manual. It is
1786 provided for compatibility with some Ada 83 compilers that
1787 used this pragma for exactly the same purposes as pragma
1788 @code{Export} before the latter was standardized.
1790 @node Pragma External_Name_Casing
1791 @unnumberedsec Pragma External_Name_Casing
1792 @cindex Dec Ada 83 casing compatibility
1793 @cindex External Names, casing
1794 @cindex Casing of External names
1795 @findex External_Name_Casing
1799 @smallexample @c ada
1800 pragma External_Name_Casing (
1801 Uppercase | Lowercase
1802 [, Uppercase | Lowercase | As_Is]);
1806 This pragma provides control over the casing of external names associated
1807 with Import and Export pragmas. There are two cases to consider:
1810 @item Implicit external names
1811 Implicit external names are derived from identifiers. The most common case
1812 arises when a standard Ada 95 Import or Export pragma is used with only two
1815 @smallexample @c ada
1816 pragma Import (C, C_Routine);
1820 Since Ada is a case insensitive language, the spelling of the identifier in
1821 the Ada source program does not provide any information on the desired
1822 casing of the external name, and so a convention is needed. In GNAT the
1823 default treatment is that such names are converted to all lower case
1824 letters. This corresponds to the normal C style in many environments.
1825 The first argument of pragma @code{External_Name_Casing} can be used to
1826 control this treatment. If @code{Uppercase} is specified, then the name
1827 will be forced to all uppercase letters. If @code{Lowercase} is specified,
1828 then the normal default of all lower case letters will be used.
1830 This same implicit treatment is also used in the case of extended DEC Ada 83
1831 compatible Import and Export pragmas where an external name is explicitly
1832 specified using an identifier rather than a string.
1834 @item Explicit external names
1835 Explicit external names are given as string literals. The most common case
1836 arises when a standard Ada 95 Import or Export pragma is used with three
1839 @smallexample @c ada
1840 pragma Import (C, C_Routine, "C_routine");
1844 In this case, the string literal normally provides the exact casing required
1845 for the external name. The second argument of pragma
1846 @code{External_Name_Casing} may be used to modify this behavior.
1847 If @code{Uppercase} is specified, then the name
1848 will be forced to all uppercase letters. If @code{Lowercase} is specified,
1849 then the name will be forced to all lowercase letters. A specification of
1850 @code{As_Is} provides the normal default behavior in which the casing is
1851 taken from the string provided.
1855 This pragma may appear anywhere that a pragma is valid. In particular, it
1856 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1857 case it applies to all subsequent compilations, or it can be used as a program
1858 unit pragma, in which case it only applies to the current unit, or it can
1859 be used more locally to control individual Import/Export pragmas.
1861 It is primarily intended for use with OpenVMS systems, where many
1862 compilers convert all symbols to upper case by default. For interfacing to
1863 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
1866 @smallexample @c ada
1867 pragma External_Name_Casing (Uppercase, Uppercase);
1871 to enforce the upper casing of all external symbols.
1873 @node Pragma Finalize_Storage_Only
1874 @unnumberedsec Pragma Finalize_Storage_Only
1875 @findex Finalize_Storage_Only
1879 @smallexample @c ada
1880 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1884 This pragma allows the compiler not to emit a Finalize call for objects
1885 defined at the library level. This is mostly useful for types where
1886 finalization is only used to deal with storage reclamation since in most
1887 environments it is not necessary to reclaim memory just before terminating
1888 execution, hence the name.
1890 @node Pragma Float_Representation
1891 @unnumberedsec Pragma Float_Representation
1893 @findex Float_Representation
1897 @smallexample @c ada
1898 pragma Float_Representation (FLOAT_REP);
1900 FLOAT_REP ::= VAX_Float | IEEE_Float
1905 allows control over the internal representation chosen for the predefined
1906 floating point types declared in the packages @code{Standard} and
1907 @code{System}. On all systems other than OpenVMS, the argument must
1908 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
1909 argument may be @code{VAX_Float} to specify the use of the VAX float
1910 format for the floating-point types in Standard. This requires that
1911 the standard runtime libraries be recompiled. See the
1912 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1913 of the GNAT Users Guide for details on the use of this command.
1916 @unnumberedsec Pragma Ident
1921 @smallexample @c ada
1922 pragma Ident (static_string_EXPRESSION);
1926 This pragma provides a string identification in the generated object file,
1927 if the system supports the concept of this kind of identification string.
1928 This pragma is allowed only in the outermost declarative part or
1929 declarative items of a compilation unit. If more than one @code{Ident}
1930 pragma is given, only the last one processed is effective.
1932 On OpenVMS systems, the effect of the pragma is identical to the effect of
1933 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
1934 maximum allowed length is 31 characters, so if it is important to
1935 maintain compatibility with this compiler, you should obey this length
1938 @node Pragma Import_Exception
1939 @unnumberedsec Pragma Import_Exception
1941 @findex Import_Exception
1945 @smallexample @c ada
1946 pragma Import_Exception (
1947 [Internal =>] LOCAL_NAME,
1948 [, [External =>] EXTERNAL_SYMBOL,]
1949 [, [Form =>] Ada | VMS]
1950 [, [Code =>] static_integer_EXPRESSION]);
1954 | static_string_EXPRESSION
1958 This pragma is implemented only in the OpenVMS implementation of GNAT@.
1959 It allows OpenVMS conditions (for example, from OpenVMS system services or
1960 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
1961 The pragma specifies that the exception associated with an exception
1962 declaration in an Ada program be defined externally (in non-Ada code).
1963 For further details on this pragma, see the
1964 DEC Ada Language Reference Manual, section 13.9a.3.1.
1966 @node Pragma Import_Function
1967 @unnumberedsec Pragma Import_Function
1968 @findex Import_Function
1972 @smallexample @c ada
1973 pragma Import_Function (
1974 [Internal =>] LOCAL_NAME,
1975 [, [External =>] EXTERNAL_SYMBOL]
1976 [, [Parameter_Types =>] PARAMETER_TYPES]
1977 [, [Result_Type =>] SUBTYPE_MARK]
1978 [, [Mechanism =>] MECHANISM]
1979 [, [Result_Mechanism =>] MECHANISM_NAME]
1980 [, [First_Optional_Parameter =>] IDENTIFIER]);
1984 | static_string_EXPRESSION
1988 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1992 | subtype_Name ' Access
1996 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1998 MECHANISM_ASSOCIATION ::=
1999 [formal_parameter_NAME =>] MECHANISM_NAME
2004 | Descriptor [([Class =>] CLASS_NAME)]
2006 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2010 This pragma is used in conjunction with a pragma @code{Import} to
2011 specify additional information for an imported function. The pragma
2012 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2013 @code{Import_Function} pragma and both must appear in the same
2014 declarative part as the function specification.
2016 The @var{Internal} argument must uniquely designate
2017 the function to which the
2018 pragma applies. If more than one function name exists of this name in
2019 the declarative part you must use the @code{Parameter_Types} and
2020 @var{Result_Type} parameters to achieve the required unique
2021 designation. Subtype marks in these parameters must exactly match the
2022 subtypes in the corresponding function specification, using positional
2023 notation to match parameters with subtype marks.
2024 The form with an @code{'Access} attribute can be used to match an
2025 anonymous access parameter.
2027 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2028 parameters to specify passing mechanisms for the
2029 parameters and result. If you specify a single mechanism name, it
2030 applies to all parameters. Otherwise you may specify a mechanism on a
2031 parameter by parameter basis using either positional or named
2032 notation. If the mechanism is not specified, the default mechanism
2036 @cindex Passing by descriptor
2037 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2039 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2040 It specifies that the designated parameter and all following parameters
2041 are optional, meaning that they are not passed at the generated code
2042 level (this is distinct from the notion of optional parameters in Ada
2043 where the parameters are passed anyway with the designated optional
2044 parameters). All optional parameters must be of mode @code{IN} and have
2045 default parameter values that are either known at compile time
2046 expressions, or uses of the @code{'Null_Parameter} attribute.
2048 @node Pragma Import_Object
2049 @unnumberedsec Pragma Import_Object
2050 @findex Import_Object
2054 @smallexample @c ada
2055 pragma Import_Object
2056 [Internal =>] LOCAL_NAME,
2057 [, [External =>] EXTERNAL_SYMBOL],
2058 [, [Size =>] EXTERNAL_SYMBOL]);
2062 | static_string_EXPRESSION
2066 This pragma designates an object as imported, and apart from the
2067 extended rules for external symbols, is identical in effect to the use of
2068 the normal @code{Import} pragma applied to an object. Unlike the
2069 subprogram case, you need not use a separate @code{Import} pragma,
2070 although you may do so (and probably should do so from a portability
2071 point of view). @var{size} is syntax checked, but otherwise ignored by
2074 @node Pragma Import_Procedure
2075 @unnumberedsec Pragma Import_Procedure
2076 @findex Import_Procedure
2080 @smallexample @c ada
2081 pragma Import_Procedure (
2082 [Internal =>] LOCAL_NAME,
2083 [, [External =>] EXTERNAL_SYMBOL]
2084 [, [Parameter_Types =>] PARAMETER_TYPES]
2085 [, [Mechanism =>] MECHANISM]
2086 [, [First_Optional_Parameter =>] IDENTIFIER]);
2090 | static_string_EXPRESSION
2094 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2098 | subtype_Name ' Access
2102 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2104 MECHANISM_ASSOCIATION ::=
2105 [formal_parameter_NAME =>] MECHANISM_NAME
2110 | Descriptor [([Class =>] CLASS_NAME)]
2112 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2116 This pragma is identical to @code{Import_Function} except that it
2117 applies to a procedure rather than a function and the parameters
2118 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2120 @node Pragma Import_Valued_Procedure
2121 @unnumberedsec Pragma Import_Valued_Procedure
2122 @findex Import_Valued_Procedure
2126 @smallexample @c ada
2127 pragma Import_Valued_Procedure (
2128 [Internal =>] LOCAL_NAME,
2129 [, [External =>] EXTERNAL_SYMBOL]
2130 [, [Parameter_Types =>] PARAMETER_TYPES]
2131 [, [Mechanism =>] MECHANISM]
2132 [, [First_Optional_Parameter =>] IDENTIFIER]);
2136 | static_string_EXPRESSION
2140 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2144 | subtype_Name ' Access
2148 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2150 MECHANISM_ASSOCIATION ::=
2151 [formal_parameter_NAME =>] MECHANISM_NAME
2156 | Descriptor [([Class =>] CLASS_NAME)]
2158 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2162 This pragma is identical to @code{Import_Procedure} except that the
2163 first parameter of @var{local_name}, which must be present, must be of
2164 mode @code{OUT}, and externally the subprogram is treated as a function
2165 with this parameter as the result of the function. The purpose of this
2166 capability is to allow the use of @code{OUT} and @code{IN OUT}
2167 parameters in interfacing to external functions (which are not permitted
2168 in Ada functions). You may optionally use the @code{Mechanism}
2169 parameters to specify passing mechanisms for the parameters.
2170 If you specify a single mechanism name, it applies to all parameters.
2171 Otherwise you may specify a mechanism on a parameter by parameter
2172 basis using either positional or named notation. If the mechanism is not
2173 specified, the default mechanism is used.
2175 Note that it is important to use this pragma in conjunction with a separate
2176 pragma Import that specifies the desired convention, since otherwise the
2177 default convention is Ada, which is almost certainly not what is required.
2179 @node Pragma Initialize_Scalars
2180 @unnumberedsec Pragma Initialize_Scalars
2181 @findex Initialize_Scalars
2182 @cindex debugging with Initialize_Scalars
2186 @smallexample @c ada
2187 pragma Initialize_Scalars;
2191 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2192 two important differences. First, there is no requirement for the pragma
2193 to be used uniformly in all units of a partition, in particular, it is fine
2194 to use this just for some or all of the application units of a partition,
2195 without needing to recompile the run-time library.
2197 In the case where some units are compiled with the pragma, and some without,
2198 then a declaration of a variable where the type is defined in package
2199 Standard or is locally declared will always be subject to initialization,
2200 as will any declaration of a scalar variable. For composite variables,
2201 whether the variable is initialized may also depend on whether the package
2202 in which the type of the variable is declared is compiled with the pragma.
2204 The other important difference is that there is control over the value used
2205 for initializing scalar objects. At bind time, you can select whether to
2206 initialize with invalid values (like Normalize_Scalars), or with high or
2207 low values, or with a specified bit pattern. See the users guide for binder
2208 options for specifying these cases.
2210 This means that you can compile a program, and then without having to
2211 recompile the program, you can run it with different values being used
2212 for initializing otherwise uninitialized values, to test if your program
2213 behavior depends on the choice. Of course the behavior should not change,
2214 and if it does, then most likely you have an erroneous reference to an
2215 uninitialized value.
2217 Note that pragma @code{Initialize_Scalars} is particularly useful in
2218 conjunction with the enhanced validity checking that is now provided
2219 in GNAT, which checks for invalid values under more conditions.
2220 Using this feature (see description of the @code{-gnatV} flag in the
2221 users guide) in conjunction with pragma @code{Initialize_Scalars}
2222 provides a powerful new tool to assist in the detection of problems
2223 caused by uninitialized variables.
2225 @node Pragma Inline_Always
2226 @unnumberedsec Pragma Inline_Always
2227 @findex Inline_Always
2231 @smallexample @c ada
2232 pragma Inline_Always (NAME [, NAME]);
2236 Similar to pragma @code{Inline} except that inlining is not subject to
2237 the use of option @code{-gnatn} and the inlining happens regardless of
2238 whether this option is used.
2240 @node Pragma Inline_Generic
2241 @unnumberedsec Pragma Inline_Generic
2242 @findex Inline_Generic
2246 @smallexample @c ada
2247 pragma Inline_Generic (generic_package_NAME);
2251 This is implemented for compatibility with DEC Ada 83 and is recognized,
2252 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2253 by default when using GNAT@.
2255 @node Pragma Interface
2256 @unnumberedsec Pragma Interface
2261 @smallexample @c ada
2263 [Convention =>] convention_identifier,
2264 [Entity =>] local_name
2265 [, [External_Name =>] static_string_expression],
2266 [, [Link_Name =>] static_string_expression]);
2270 This pragma is identical in syntax and semantics to
2271 the standard Ada 95 pragma @code{Import}. It is provided for compatibility
2272 with Ada 83. The definition is upwards compatible both with pragma
2273 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2274 with some extended implementations of this pragma in certain Ada 83
2277 @node Pragma Interface_Name
2278 @unnumberedsec Pragma Interface_Name
2279 @findex Interface_Name
2283 @smallexample @c ada
2284 pragma Interface_Name (
2285 [Entity =>] LOCAL_NAME
2286 [, [External_Name =>] static_string_EXPRESSION]
2287 [, [Link_Name =>] static_string_EXPRESSION]);
2291 This pragma provides an alternative way of specifying the interface name
2292 for an interfaced subprogram, and is provided for compatibility with Ada
2293 83 compilers that use the pragma for this purpose. You must provide at
2294 least one of @var{External_Name} or @var{Link_Name}.
2296 @node Pragma Interrupt_Handler
2297 @unnumberedsec Pragma Interrupt_Handler
2298 @findex Interrupt_Handler
2302 @smallexample @c ada
2303 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2307 This program unit pragma is supported for parameterless protected procedures
2308 as described in Annex C of the Ada Reference Manual. On the AAMP target
2309 the pragma can also be specified for nonprotected parameterless procedures
2310 that are declared at the library level (which includes procedures
2311 declared at the top level of a library package). In the case of AAMP,
2312 when this pragma is applied to a nonprotected procedure, the instruction
2313 @code{IERET} is generated for returns from the procedure, enabling
2314 maskable interrupts, in place of the normal return instruction.
2316 @node Pragma Interrupt_State
2317 @unnumberedsec Pragma Interrupt_State
2318 @findex Interrupt_State
2322 @smallexample @c ada
2323 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2327 Normally certain interrupts are reserved to the implementation. Any attempt
2328 to attach an interrupt causes Program_Error to be raised, as described in
2329 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2330 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2331 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2332 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2333 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2334 Ada exceptions, or used to implement run-time functions such as the
2335 @code{abort} statement and stack overflow checking.
2337 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2338 such uses of interrupts. It subsumes the functionality of pragma
2339 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2340 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2341 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2342 and may be used to mark interrupts required by the board support package
2345 Interrupts can be in one of three states:
2349 The interrupt is reserved (no Ada handler can be installed), and the
2350 Ada run-time may not install a handler. As a result you are guaranteed
2351 standard system default action if this interrupt is raised.
2355 The interrupt is reserved (no Ada handler can be installed). The run time
2356 is allowed to install a handler for internal control purposes, but is
2357 not required to do so.
2361 The interrupt is unreserved. The user may install a handler to provide
2366 These states are the allowed values of the @code{State} parameter of the
2367 pragma. The @code{Name} parameter is a value of the type
2368 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2369 @code{Ada.Interrupts.Names}.
2371 This is a configuration pragma, and the binder will check that there
2372 are no inconsistencies between different units in a partition in how a
2373 given interrupt is specified. It may appear anywhere a pragma is legal.
2375 The effect is to move the interrupt to the specified state.
2377 By declaring interrupts to be SYSTEM, you guarantee the standard system
2378 action, such as a core dump.
2380 By declaring interrupts to be USER, you guarantee that you can install
2383 Note that certain signals on many operating systems cannot be caught and
2384 handled by applications. In such cases, the pragma is ignored. See the
2385 operating system documentation, or the value of the array @code{Reserved}
2386 declared in the specification of package @code{System.OS_Interface}.
2388 Overriding the default state of signals used by the Ada runtime may interfere
2389 with an application's runtime behavior in the cases of the synchronous signals,
2390 and in the case of the signal used to implement the @code{abort} statement.
2392 @node Pragma Keep_Names
2393 @unnumberedsec Pragma Keep_Names
2398 @smallexample @c ada
2399 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2403 The @var{LOCAL_NAME} argument
2404 must refer to an enumeration first subtype
2405 in the current declarative part. The effect is to retain the enumeration
2406 literal names for use by @code{Image} and @code{Value} even if a global
2407 @code{Discard_Names} pragma applies. This is useful when you want to
2408 generally suppress enumeration literal names and for example you therefore
2409 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2410 want to retain the names for specific enumeration types.
2412 @node Pragma License
2413 @unnumberedsec Pragma License
2415 @cindex License checking
2419 @smallexample @c ada
2420 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2424 This pragma is provided to allow automated checking for appropriate license
2425 conditions with respect to the standard and modified GPL@. A pragma
2426 @code{License}, which is a configuration pragma that typically appears at
2427 the start of a source file or in a separate @file{gnat.adc} file, specifies
2428 the licensing conditions of a unit as follows:
2432 This is used for a unit that can be freely used with no license restrictions.
2433 Examples of such units are public domain units, and units from the Ada
2437 This is used for a unit that is licensed under the unmodified GPL, and which
2438 therefore cannot be @code{with}'ed by a restricted unit.
2441 This is used for a unit licensed under the GNAT modified GPL that includes
2442 a special exception paragraph that specifically permits the inclusion of
2443 the unit in programs without requiring the entire program to be released
2444 under the GPL@. This is the license used for the GNAT run-time which ensures
2445 that the run-time can be used freely in any program without GPL concerns.
2448 This is used for a unit that is restricted in that it is not permitted to
2449 depend on units that are licensed under the GPL@. Typical examples are
2450 proprietary code that is to be released under more restrictive license
2451 conditions. Note that restricted units are permitted to @code{with} units
2452 which are licensed under the modified GPL (this is the whole point of the
2458 Normally a unit with no @code{License} pragma is considered to have an
2459 unknown license, and no checking is done. However, standard GNAT headers
2460 are recognized, and license information is derived from them as follows.
2464 A GNAT license header starts with a line containing 78 hyphens. The following
2465 comment text is searched for the appearance of any of the following strings.
2467 If the string ``GNU General Public License'' is found, then the unit is assumed
2468 to have GPL license, unless the string ``As a special exception'' follows, in
2469 which case the license is assumed to be modified GPL@.
2471 If one of the strings
2472 ``This specification is adapted from the Ada Semantic Interface'' or
2473 ``This specification is derived from the Ada Reference Manual'' is found
2474 then the unit is assumed to be unrestricted.
2478 These default actions means that a program with a restricted license pragma
2479 will automatically get warnings if a GPL unit is inappropriately
2480 @code{with}'ed. For example, the program:
2482 @smallexample @c ada
2485 procedure Secret_Stuff is
2491 if compiled with pragma @code{License} (@code{Restricted}) in a
2492 @file{gnat.adc} file will generate the warning:
2497 >>> license of withed unit "Sem_Ch3" is incompatible
2499 2. with GNAT.Sockets;
2500 3. procedure Secret_Stuff is
2504 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2505 compiler and is licensed under the
2506 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2507 run time, and is therefore licensed under the modified GPL@.
2509 @node Pragma Link_With
2510 @unnumberedsec Pragma Link_With
2515 @smallexample @c ada
2516 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2520 This pragma is provided for compatibility with certain Ada 83 compilers.
2521 It has exactly the same effect as pragma @code{Linker_Options} except
2522 that spaces occurring within one of the string expressions are treated
2523 as separators. For example, in the following case:
2525 @smallexample @c ada
2526 pragma Link_With ("-labc -ldef");
2530 results in passing the strings @code{-labc} and @code{-ldef} as two
2531 separate arguments to the linker. In addition pragma Link_With allows
2532 multiple arguments, with the same effect as successive pragmas.
2534 @node Pragma Linker_Alias
2535 @unnumberedsec Pragma Linker_Alias
2536 @findex Linker_Alias
2540 @smallexample @c ada
2541 pragma Linker_Alias (
2542 [Entity =>] LOCAL_NAME
2543 [Alias =>] static_string_EXPRESSION);
2547 This pragma establishes a linker alias for the given named entity. For
2548 further details on the exact effect, consult the GCC manual.
2550 @node Pragma Linker_Section
2551 @unnumberedsec Pragma Linker_Section
2552 @findex Linker_Section
2556 @smallexample @c ada
2557 pragma Linker_Section (
2558 [Entity =>] LOCAL_NAME
2559 [Section =>] static_string_EXPRESSION);
2563 This pragma specifies the name of the linker section for the given entity.
2564 For further details on the exact effect, consult the GCC manual.
2566 @node Pragma Long_Float
2567 @unnumberedsec Pragma Long_Float
2573 @smallexample @c ada
2574 pragma Long_Float (FLOAT_FORMAT);
2576 FLOAT_FORMAT ::= D_Float | G_Float
2580 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2581 It allows control over the internal representation chosen for the predefined
2582 type @code{Long_Float} and for floating point type representations with
2583 @code{digits} specified in the range 7 through 15.
2584 For further details on this pragma, see the
2585 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
2586 this pragma, the standard runtime libraries must be recompiled. See the
2587 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2588 of the GNAT User's Guide for details on the use of this command.
2590 @node Pragma Machine_Attribute
2591 @unnumberedsec Pragma Machine_Attribute
2592 @findex Machine_Attribute
2596 @smallexample @c ada
2597 pragma Machine_Attribute (
2598 [Attribute_Name =>] string_EXPRESSION,
2599 [Entity =>] LOCAL_NAME);
2603 Machine dependent attributes can be specified for types and/or
2604 declarations. Currently only subprogram entities are supported. This
2605 pragma is semantically equivalent to
2606 @code{__attribute__((@var{string_expression}))} in GNU C,
2607 where @code{@var{string_expression}} is
2608 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2609 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2610 configuration header file @file{tm.h} for each machine. See the GCC
2611 manual for further information.
2613 @node Pragma Main_Storage
2614 @unnumberedsec Pragma Main_Storage
2616 @findex Main_Storage
2620 @smallexample @c ada
2622 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2624 MAIN_STORAGE_OPTION ::=
2625 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2626 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
2631 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
2632 no effect in GNAT, other than being syntax checked. Note that the pragma
2633 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2635 @node Pragma No_Return
2636 @unnumberedsec Pragma No_Return
2641 @smallexample @c ada
2642 pragma No_Return (procedure_LOCAL_NAME);
2646 @var{procedure_local_NAME} must refer to one or more procedure
2647 declarations in the current declarative part. A procedure to which this
2648 pragma is applied may not contain any explicit @code{return} statements,
2649 and also may not contain any implicit return statements from falling off
2650 the end of a statement sequence. One use of this pragma is to identify
2651 procedures whose only purpose is to raise an exception.
2653 Another use of this pragma is to suppress incorrect warnings about
2654 missing returns in functions, where the last statement of a function
2655 statement sequence is a call to such a procedure.
2657 @node Pragma Normalize_Scalars
2658 @unnumberedsec Pragma Normalize_Scalars
2659 @findex Normalize_Scalars
2663 @smallexample @c ada
2664 pragma Normalize_Scalars;
2668 This is a language defined pragma which is fully implemented in GNAT@. The
2669 effect is to cause all scalar objects that are not otherwise initialized
2670 to be initialized. The initial values are implementation dependent and
2674 @item Standard.Character
2676 Objects whose root type is Standard.Character are initialized to
2677 Character'Last. This will be out of range of the subtype only if
2678 the subtype range excludes this value.
2680 @item Standard.Wide_Character
2682 Objects whose root type is Standard.Wide_Character are initialized to
2683 Wide_Character'Last. This will be out of range of the subtype only if
2684 the subtype range excludes this value.
2688 Objects of an integer type are initialized to base_type'First, where
2689 base_type is the base type of the object type. This will be out of range
2690 of the subtype only if the subtype range excludes this value. For example,
2691 if you declare the subtype:
2693 @smallexample @c ada
2694 subtype Ityp is integer range 1 .. 10;
2698 then objects of type x will be initialized to Integer'First, a negative
2699 number that is certainly outside the range of subtype @code{Ityp}.
2702 Objects of all real types (fixed and floating) are initialized to
2703 base_type'First, where base_Type is the base type of the object type.
2704 This will be out of range of the subtype only if the subtype range
2705 excludes this value.
2708 Objects of a modular type are initialized to typ'Last. This will be out
2709 of range of the subtype only if the subtype excludes this value.
2711 @item Enumeration types
2712 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2713 the value @code{2 ** typ'Size - 1}. This will be out of range of the
2714 enumeration subtype in all cases except where the subtype contains
2715 exactly 2**8, 2**16, or 2**32 elements.
2719 @node Pragma Obsolescent
2720 @unnumberedsec Pragma Obsolescent
2725 @smallexample @c ada
2726 pragma Obsolescent [(static_string_EXPRESSION)];
2730 This pragma must occur immediately following a subprogram
2731 declaration. It indicates that the associated function or procedure
2732 is considered obsolescent and should not be used. Typically this is
2733 used when an API must be modified by eventually removing or modifying
2734 existing subprograms. The pragma can be used at an intermediate stage
2735 when the subprogram is still present, but will be removed later.
2737 The effect of this pragma is to output a warning message that the
2738 subprogram is obsolescent if the appropriate warning option in the
2739 compiler is activated. If a parameter is present, then a second
2740 warning message is given containing this text.
2742 @node Pragma Passive
2743 @unnumberedsec Pragma Passive
2748 @smallexample @c ada
2749 pragma Passive ([Semaphore | No]);
2753 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
2754 compatibility with DEC Ada 83 implementations, where it is used within a
2755 task definition to request that a task be made passive. If the argument
2756 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
2757 treats the pragma as an assertion that the containing task is passive
2758 and that optimization of context switch with this task is permitted and
2759 desired. If the argument @code{No} is present, the task must not be
2760 optimized. GNAT does not attempt to optimize any tasks in this manner
2761 (since protected objects are available in place of passive tasks).
2763 @node Pragma Polling
2764 @unnumberedsec Pragma Polling
2769 @smallexample @c ada
2770 pragma Polling (ON | OFF);
2774 This pragma controls the generation of polling code. This is normally off.
2775 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2776 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
2777 runtime library, and can be found in file @file{a-excpol.adb}.
2779 Pragma @code{Polling} can appear as a configuration pragma (for example it
2780 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
2781 can be used in the statement or declaration sequence to control polling
2784 A call to the polling routine is generated at the start of every loop and
2785 at the start of every subprogram call. This guarantees that the @code{Poll}
2786 routine is called frequently, and places an upper bound (determined by
2787 the complexity of the code) on the period between two @code{Poll} calls.
2789 The primary purpose of the polling interface is to enable asynchronous
2790 aborts on targets that cannot otherwise support it (for example Windows
2791 NT), but it may be used for any other purpose requiring periodic polling.
2792 The standard version is null, and can be replaced by a user program. This
2793 will require re-compilation of the @code{Ada.Exceptions} package that can
2794 be found in files @file{a-except.ads} and @file{a-except.adb}.
2796 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2797 distribution) is used to enable the asynchronous abort capability on
2798 targets that do not normally support the capability. The version of
2799 @code{Poll} in this file makes a call to the appropriate runtime routine
2800 to test for an abort condition.
2802 Note that polling can also be enabled by use of the @code{-gnatP} switch. See
2803 the @cite{GNAT User's Guide} for details.
2805 @node Pragma Propagate_Exceptions
2806 @unnumberedsec Pragma Propagate_Exceptions
2807 @findex Propagate_Exceptions
2808 @cindex Zero Cost Exceptions
2812 @smallexample @c ada
2813 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
2817 This pragma indicates that the given entity, which is the name of an
2818 imported foreign-language subprogram may receive an Ada exception,
2819 and that the exception should be propagated. It is relevant only if
2820 zero cost exception handling is in use, and is thus never needed if
2821 the alternative @code{longjmp} / @code{setjmp} implementation of
2822 exceptions is used (although it is harmless to use it in such cases).
2824 The implementation of fast exceptions always properly propagates
2825 exceptions through Ada code, as described in the Ada Reference Manual.
2826 However, this manual is silent about the propagation of exceptions
2827 through foreign code. For example, consider the
2828 situation where @code{P1} calls
2829 @code{P2}, and @code{P2} calls @code{P3}, where
2830 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
2831 @code{P3} raises an Ada exception. The question is whether or not
2832 it will be propagated through @code{P2} and can be handled in
2835 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
2836 the answer is always yes. For some targets on which zero cost exception
2837 handling is implemented, the answer is also always yes. However, there
2838 are some targets, notably in the current version all x86 architecture
2839 targets, in which the answer is that such propagation does not
2840 happen automatically. If such propagation is required on these
2841 targets, it is mandatory to use @code{Propagate_Exceptions} to
2842 name all foreign language routines through which Ada exceptions
2845 @node Pragma Psect_Object
2846 @unnumberedsec Pragma Psect_Object
2847 @findex Psect_Object
2851 @smallexample @c ada
2852 pragma Psect_Object (
2853 [Internal =>] LOCAL_NAME,
2854 [, [External =>] EXTERNAL_SYMBOL]
2855 [, [Size =>] EXTERNAL_SYMBOL]);
2859 | static_string_EXPRESSION
2863 This pragma is identical in effect to pragma @code{Common_Object}.
2865 @node Pragma Pure_Function
2866 @unnumberedsec Pragma Pure_Function
2867 @findex Pure_Function
2871 @smallexample @c ada
2872 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
2876 This pragma appears in the same declarative part as a function
2877 declaration (or a set of function declarations if more than one
2878 overloaded declaration exists, in which case the pragma applies
2879 to all entities). It specifies that the function @code{Entity} is
2880 to be considered pure for the purposes of code generation. This means
2881 that the compiler can assume that there are no side effects, and
2882 in particular that two calls with identical arguments produce the
2883 same result. It also means that the function can be used in an
2886 Note that, quite deliberately, there are no static checks to try
2887 to ensure that this promise is met, so @code{Pure_Function} can be used
2888 with functions that are conceptually pure, even if they do modify
2889 global variables. For example, a square root function that is
2890 instrumented to count the number of times it is called is still
2891 conceptually pure, and can still be optimized, even though it
2892 modifies a global variable (the count). Memo functions are another
2893 example (where a table of previous calls is kept and consulted to
2894 avoid re-computation).
2897 Note: Most functions in a @code{Pure} package are automatically pure, and
2898 there is no need to use pragma @code{Pure_Function} for such functions. One
2899 exception is any function that has at least one formal of type
2900 @code{System.Address} or a type derived from it. Such functions are not
2901 considered pure by default, since the compiler assumes that the
2902 @code{Address} parameter may be functioning as a pointer and that the
2903 referenced data may change even if the address value does not.
2904 Similarly, imported functions are not considered to be pure by default,
2905 since there is no way of checking that they are in fact pure. The use
2906 of pragma @code{Pure_Function} for such a function will override these default
2907 assumption, and cause the compiler to treat a designated subprogram as pure
2910 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
2911 applies to the underlying renamed function. This can be used to
2912 disambiguate cases of overloading where some but not all functions
2913 in a set of overloaded functions are to be designated as pure.
2915 @node Pragma Ravenscar
2916 @unnumberedsec Pragma Ravenscar
2921 @smallexample @c ada
2926 A configuration pragma that establishes the following set of restrictions:
2929 @item No_Abort_Statements
2930 [RM D.7] There are no abort_statements, and there are
2931 no calls to Task_Identification.Abort_Task.
2933 @item No_Select_Statements
2934 There are no select_statements.
2936 @item No_Task_Hierarchy
2937 [RM D.7] All (non-environment) tasks depend
2938 directly on the environment task of the partition.
2940 @item No_Task_Allocators
2941 [RM D.7] There are no allocators for task types
2942 or types containing task subcomponents.
2944 @item No_Dynamic_Priorities
2945 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2947 @item No_Terminate_Alternatives
2948 [RM D.7] There are no selective_accepts with terminate_alternatives
2950 @item No_Dynamic_Interrupts
2951 There are no semantic dependencies on Ada.Interrupts.
2953 @item No_Implicit_Heap_Allocations
2954 [RM D.7] No constructs are allowed to cause implicit heap allocation
2956 @item No_Protected_Type_Allocators
2957 There are no allocators for protected types or
2958 types containing protected subcomponents.
2960 @item No_Local_Protected_Objects
2961 Protected objects and access types that designate
2962 such objects shall be declared only at library level.
2964 @item No_Requeue_Statements
2965 Requeue statements are not allowed.
2968 There are no semantic dependencies on the package Ada.Calendar.
2970 @item No_Relative_Delay
2971 There are no delay_relative_statements.
2973 @item No_Task_Attributes
2974 There are no semantic dependencies on the Ada.Task_Attributes package and
2975 there are no references to the attributes Callable and Terminated [RM 9.9].
2977 @item Boolean_Entry_Barriers
2978 Entry barrier condition expressions shall be boolean
2979 objects which are declared in the protected type
2980 which contains the entry.
2982 @item Max_Asynchronous_Select_Nesting = 0
2983 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous_selects.
2984 A value of zero prevents the use of any asynchronous_select.
2986 @item Max_Task_Entries = 0
2987 [RM D.7] Specifies the maximum number of entries
2988 per task. The bounds of every entry family
2989 of a task unit shall be static, or shall be
2990 defined by a discriminant of a subtype whose
2991 corresponding bound is static. A value of zero
2992 indicates that no rendezvous are possible. For
2993 the Ravenscar pragma, the value of Max_Task_Entries is always
2996 @item Max_Protected_Entries = 1
2997 [RM D.7] Specifies the maximum number of entries per
2998 protected type. The bounds of every entry family of
2999 a protected unit shall be static, or shall be defined
3000 by a discriminant of a subtype whose corresponding
3001 bound is static. For the Ravenscar pragma the value of
3002 Max_Protected_Entries is always 1.
3004 @item Max_Select_Alternatives = 0
3005 [RM D.7] Specifies the maximum number of alternatives in a selective_accept.
3006 For the Ravenscar pragma the value is always 0.
3008 @item No_Task_Termination
3009 Tasks which terminate are erroneous.
3011 @item No_Entry_Queue
3012 No task can be queued on a protected entry. Note that this restrictions is
3013 checked at run time. The violation of this restriction generates a
3014 Program_Error exception.
3018 This set of restrictions corresponds to the definition of the ``Ravenscar
3019 Profile'' for limited tasking, devised and published by the
3020 @cite{International Real-Time Ada Workshop}, 1997,
3021 and whose most recent description is available at
3022 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
3024 The above set is a superset of the restrictions provided by pragma
3025 @code{Restricted_Run_Time}, it includes five additional restrictions
3026 (@code{Boolean_Entry_Barriers}, @code{No_Select_Statements},
3028 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
3029 that pragma @code{Ravenscar}, like the pragma @code{Restricted_Run_Time},
3030 automatically causes the use of a simplified, more efficient version
3031 of the tasking run-time system.
3033 @node Pragma Restricted_Run_Time
3034 @unnumberedsec Pragma Restricted_Run_Time
3035 @findex Restricted_Run_Time
3039 @smallexample @c ada
3040 pragma Restricted_Run_Time;
3044 A configuration pragma that establishes the following set of restrictions:
3047 @item No_Abort_Statements
3048 @item No_Entry_Queue
3049 @item No_Task_Hierarchy
3050 @item No_Task_Allocators
3051 @item No_Dynamic_Priorities
3052 @item No_Terminate_Alternatives
3053 @item No_Dynamic_Interrupts
3054 @item No_Protected_Type_Allocators
3055 @item No_Local_Protected_Objects
3056 @item No_Requeue_Statements
3057 @item No_Task_Attributes
3058 @item Max_Asynchronous_Select_Nesting = 0
3059 @item Max_Task_Entries = 0
3060 @item Max_Protected_Entries = 1
3061 @item Max_Select_Alternatives = 0
3065 This set of restrictions causes the automatic selection of a simplified
3066 version of the run time that provides improved performance for the
3067 limited set of tasking functionality permitted by this set of restrictions.
3069 @node Pragma Restriction_Warnings
3070 @unnumberedsec Pragma Restriction_Warnings
3071 @findex Restriction_Warnings
3075 @smallexample @c ada
3076 pragma Restriction_Warnings
3077 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3081 This pragma allows a series of restriction identifiers to be
3082 specified (the list of allowed identifiers is the same as for
3083 pragma @code{Restrictions}). For each of these identifiers
3084 the compiler checks for violations of the restriction, but
3085 generates a warning message rather than an error message
3086 if the restriction is violated.
3088 @node Pragma Source_File_Name
3089 @unnumberedsec Pragma Source_File_Name
3090 @findex Source_File_Name
3094 @smallexample @c ada
3095 pragma Source_File_Name (
3096 [Unit_Name =>] unit_NAME,
3097 Spec_File_Name => STRING_LITERAL);
3099 pragma Source_File_Name (
3100 [Unit_Name =>] unit_NAME,
3101 Body_File_Name => STRING_LITERAL);
3105 Use this to override the normal naming convention. It is a configuration
3106 pragma, and so has the usual applicability of configuration pragmas
3107 (i.e.@: it applies to either an entire partition, or to all units in a
3108 compilation, or to a single unit, depending on how it is used.
3109 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
3110 the second argument is required, and indicates whether this is the file
3111 name for the spec or for the body.
3113 Another form of the @code{Source_File_Name} pragma allows
3114 the specification of patterns defining alternative file naming schemes
3115 to apply to all files.
3117 @smallexample @c ada
3118 pragma Source_File_Name
3119 (Spec_File_Name => STRING_LITERAL
3120 [,Casing => CASING_SPEC]
3121 [,Dot_Replacement => STRING_LITERAL]);
3123 pragma Source_File_Name
3124 (Body_File_Name => STRING_LITERAL
3125 [,Casing => CASING_SPEC]
3126 [,Dot_Replacement => STRING_LITERAL]);
3128 pragma Source_File_Name
3129 (Subunit_File_Name => STRING_LITERAL
3130 [,Casing => CASING_SPEC]
3131 [,Dot_Replacement => STRING_LITERAL]);
3133 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3137 The first argument is a pattern that contains a single asterisk indicating
3138 the point at which the unit name is to be inserted in the pattern string
3139 to form the file name. The second argument is optional. If present it
3140 specifies the casing of the unit name in the resulting file name string.
3141 The default is lower case. Finally the third argument allows for systematic
3142 replacement of any dots in the unit name by the specified string literal.
3144 A pragma Source_File_Name cannot appear after a
3145 @ref{Pragma Source_File_Name_Project}.
3147 For more details on the use of the @code{Source_File_Name} pragma,
3148 see the sections ``Using Other File Names'' and
3149 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3151 @node Pragma Source_File_Name_Project
3152 @unnumberedsec Pragma Source_File_Name_Project
3153 @findex Source_File_Name_Project
3156 This pragma has the same syntax and semantics as pragma Source_File_Name.
3157 It is only allowed as a stand alone configuration pragma.
3158 It cannot appear after a @ref{Pragma Source_File_Name}, and
3159 most importantly, once pragma Source_File_Name_Project appears,
3160 no further Source_File_Name pragmas are allowed.
3162 The intention is that Source_File_Name_Project pragmas are always
3163 generated by the Project Manager in a manner consistent with the naming
3164 specified in a project file, and when naming is controlled in this manner,
3165 it is not permissible to attempt to modify this naming scheme using
3166 Source_File_Name pragmas (which would not be known to the project manager).
3168 @node Pragma Source_Reference
3169 @unnumberedsec Pragma Source_Reference
3170 @findex Source_Reference
3174 @smallexample @c ada
3175 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3179 This pragma must appear as the first line of a source file.
3180 @var{integer_literal} is the logical line number of the line following
3181 the pragma line (for use in error messages and debugging
3182 information). @var{string_literal} is a static string constant that
3183 specifies the file name to be used in error messages and debugging
3184 information. This is most notably used for the output of @code{gnatchop}
3185 with the @code{-r} switch, to make sure that the original unchopped
3186 source file is the one referred to.
3188 The second argument must be a string literal, it cannot be a static
3189 string expression other than a string literal. This is because its value
3190 is needed for error messages issued by all phases of the compiler.
3192 @node Pragma Stream_Convert
3193 @unnumberedsec Pragma Stream_Convert
3194 @findex Stream_Convert
3198 @smallexample @c ada
3199 pragma Stream_Convert (
3200 [Entity =>] type_LOCAL_NAME,
3201 [Read =>] function_NAME,
3202 [Write =>] function_NAME);
3206 This pragma provides an efficient way of providing stream functions for
3207 types defined in packages. Not only is it simpler to use than declaring
3208 the necessary functions with attribute representation clauses, but more
3209 significantly, it allows the declaration to made in such a way that the
3210 stream packages are not loaded unless they are needed. The use of
3211 the Stream_Convert pragma adds no overhead at all, unless the stream
3212 attributes are actually used on the designated type.
3214 The first argument specifies the type for which stream functions are
3215 provided. The second parameter provides a function used to read values
3216 of this type. It must name a function whose argument type may be any
3217 subtype, and whose returned type must be the type given as the first
3218 argument to the pragma.
3220 The meaning of the @var{Read}
3221 parameter is that if a stream attribute directly
3222 or indirectly specifies reading of the type given as the first parameter,
3223 then a value of the type given as the argument to the Read function is
3224 read from the stream, and then the Read function is used to convert this
3225 to the required target type.
3227 Similarly the @var{Write} parameter specifies how to treat write attributes
3228 that directly or indirectly apply to the type given as the first parameter.
3229 It must have an input parameter of the type specified by the first parameter,
3230 and the return type must be the same as the input type of the Read function.
3231 The effect is to first call the Write function to convert to the given stream
3232 type, and then write the result type to the stream.
3234 The Read and Write functions must not be overloaded subprograms. If necessary
3235 renamings can be supplied to meet this requirement.
3236 The usage of this attribute is best illustrated by a simple example, taken
3237 from the GNAT implementation of package Ada.Strings.Unbounded:
3239 @smallexample @c ada
3240 function To_Unbounded (S : String)
3241 return Unbounded_String
3242 renames To_Unbounded_String;
3244 pragma Stream_Convert
3245 (Unbounded_String, To_Unbounded, To_String);
3249 The specifications of the referenced functions, as given in the Ada 95
3250 Reference Manual are:
3252 @smallexample @c ada
3253 function To_Unbounded_String (Source : String)
3254 return Unbounded_String;
3256 function To_String (Source : Unbounded_String)
3261 The effect is that if the value of an unbounded string is written to a
3262 stream, then the representation of the item in the stream is in the same
3263 format used for @code{Standard.String}, and this same representation is
3264 expected when a value of this type is read from the stream.
3266 @node Pragma Style_Checks
3267 @unnumberedsec Pragma Style_Checks
3268 @findex Style_Checks
3272 @smallexample @c ada
3273 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3274 On | Off [, LOCAL_NAME]);
3278 This pragma is used in conjunction with compiler switches to control the
3279 built in style checking provided by GNAT@. The compiler switches, if set,
3280 provide an initial setting for the switches, and this pragma may be used
3281 to modify these settings, or the settings may be provided entirely by
3282 the use of the pragma. This pragma can be used anywhere that a pragma
3283 is legal, including use as a configuration pragma (including use in
3284 the @file{gnat.adc} file).
3286 The form with a string literal specifies which style options are to be
3287 activated. These are additive, so they apply in addition to any previously
3288 set style check options. The codes for the options are the same as those
3289 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3290 For example the following two methods can be used to enable
3295 @smallexample @c ada
3296 pragma Style_Checks ("l");
3301 gcc -c -gnatyl @dots{}
3306 The form ALL_CHECKS activates all standard checks (its use is equivalent
3307 to the use of the @code{gnaty} switch with no options. See GNAT User's
3310 The forms with @code{Off} and @code{On}
3311 can be used to temporarily disable style checks
3312 as shown in the following example:
3314 @smallexample @c ada
3318 pragma Style_Checks ("k"); -- requires keywords in lower case
3319 pragma Style_Checks (Off); -- turn off style checks
3320 NULL; -- this will not generate an error message
3321 pragma Style_Checks (On); -- turn style checks back on
3322 NULL; -- this will generate an error message
3326 Finally the two argument form is allowed only if the first argument is
3327 @code{On} or @code{Off}. The effect is to turn of semantic style checks
3328 for the specified entity, as shown in the following example:
3330 @smallexample @c ada
3334 pragma Style_Checks ("r"); -- require consistency of identifier casing
3336 Rf1 : Integer := ARG; -- incorrect, wrong case
3337 pragma Style_Checks (Off, Arg);
3338 Rf2 : Integer := ARG; -- OK, no error
3341 @node Pragma Subtitle
3342 @unnumberedsec Pragma Subtitle
3347 @smallexample @c ada
3348 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3352 This pragma is recognized for compatibility with other Ada compilers
3353 but is ignored by GNAT@.
3355 @node Pragma Suppress_All
3356 @unnumberedsec Pragma Suppress_All
3357 @findex Suppress_All
3361 @smallexample @c ada
3362 pragma Suppress_All;
3366 This pragma can only appear immediately following a compilation
3367 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
3368 which it follows. This pragma is implemented for compatibility with DEC
3369 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
3370 configuration pragma is the preferred usage in GNAT@.
3372 @node Pragma Suppress_Exception_Locations
3373 @unnumberedsec Pragma Suppress_Exception_Locations
3374 @findex Suppress_Exception_Locations
3378 @smallexample @c ada
3379 pragma Suppress_Exception_Locations;
3383 In normal mode, a raise statement for an exception by default generates
3384 an exception message giving the file name and line number for the location
3385 of the raise. This is useful for debugging and logging purposes, but this
3386 entails extra space for the strings for the messages. The configuration
3387 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3388 generation of these strings, with the result that space is saved, but the
3389 exception message for such raises is null. This configuration pragma may
3390 appear in a global configuration pragma file, or in a specific unit as
3391 usual. It is not required that this pragma be used consistently within
3392 a partition, so it is fine to have some units within a partition compiled
3393 with this pragma and others compiled in normal mode without it.
3395 @node Pragma Suppress_Initialization
3396 @unnumberedsec Pragma Suppress_Initialization
3397 @findex Suppress_Initialization
3398 @cindex Suppressing initialization
3399 @cindex Initialization, suppression of
3403 @smallexample @c ada
3404 pragma Suppress_Initialization ([Entity =>] type_Name);
3408 This pragma suppresses any implicit or explicit initialization
3409 associated with the given type name for all variables of this type.
3411 @node Pragma Task_Info
3412 @unnumberedsec Pragma Task_Info
3417 @smallexample @c ada
3418 pragma Task_Info (EXPRESSION);
3422 This pragma appears within a task definition (like pragma
3423 @code{Priority}) and applies to the task in which it appears. The
3424 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3425 The @code{Task_Info} pragma provides system dependent control over
3426 aspects of tasking implementation, for example, the ability to map
3427 tasks to specific processors. For details on the facilities available
3428 for the version of GNAT that you are using, see the documentation
3429 in the specification of package System.Task_Info in the runtime
3432 @node Pragma Task_Name
3433 @unnumberedsec Pragma Task_Name
3438 @smallexample @c ada
3439 pragma Task_Name (string_EXPRESSION);
3443 This pragma appears within a task definition (like pragma
3444 @code{Priority}) and applies to the task in which it appears. The
3445 argument must be of type String, and provides a name to be used for
3446 the task instance when the task is created. Note that this expression
3447 is not required to be static, and in particular, it can contain
3448 references to task discriminants. This facility can be used to
3449 provide different names for different tasks as they are created,
3450 as illustrated in the example below.
3452 The task name is recorded internally in the run-time structures
3453 and is accessible to tools like the debugger. In addition the
3454 routine @code{Ada.Task_Identification.Image} will return this
3455 string, with a unique task address appended.
3457 @smallexample @c ada
3458 -- Example of the use of pragma Task_Name
3460 with Ada.Task_Identification;
3461 use Ada.Task_Identification;
3462 with Text_IO; use Text_IO;
3465 type Astring is access String;
3467 task type Task_Typ (Name : access String) is
3468 pragma Task_Name (Name.all);
3471 task body Task_Typ is
3472 Nam : constant String := Image (Current_Task);
3474 Put_Line ("-->" & Nam (1 .. 14) & "<--");
3477 type Ptr_Task is access Task_Typ;
3478 Task_Var : Ptr_Task;
3482 new Task_Typ (new String'("This is task 1"));
3484 new Task_Typ (new String'("This is task 2"));
3488 @node Pragma Task_Storage
3489 @unnumberedsec Pragma Task_Storage
3490 @findex Task_Storage
3493 @smallexample @c ada
3494 pragma Task_Storage (
3495 [Task_Type =>] LOCAL_NAME,
3496 [Top_Guard =>] static_integer_EXPRESSION);
3500 This pragma specifies the length of the guard area for tasks. The guard
3501 area is an additional storage area allocated to a task. A value of zero
3502 means that either no guard area is created or a minimal guard area is
3503 created, depending on the target. This pragma can appear anywhere a
3504 @code{Storage_Size} attribute definition clause is allowed for a task
3507 @node Pragma Thread_Body
3508 @unnumberedsec Pragma Thread_Body
3512 @smallexample @c ada
3513 pragma Thread_Body (
3514 [Entity =>] LOCAL_NAME,
3515 [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3519 This pragma specifies that the subprogram whose name is given as the
3520 @code{Entity} argument is a thread body, which will be activated
3521 by being called via its Address from foreign code. The purpose is
3522 to allow execution and registration of the foreign thread within the
3523 Ada run-time system.
3525 See the library unit @code{System.Threads} for details on the expansion of
3526 a thread body subprogram, including the calls made to subprograms
3527 within System.Threads to register the task. This unit also lists the
3528 targets and runtime systems for which this pragma is supported.
3530 A thread body subprogram may not be called directly from Ada code, and
3531 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3532 to such a subprogram. The only legitimate way of calling such a subprogram
3533 is to pass its Address to foreign code and then make the call from the
3536 A thread body subprogram may have any parameters, and it may be a function
3537 returning a result. The convention of the thread body subprogram may be
3538 set in the usual manner using @code{pragma Convention}.
3540 The secondary stack size parameter, if given, is used to set the size
3541 of secondary stack for the thread. The secondary stack is allocated as
3542 a local variable of the expanded thread body subprogram, and thus is
3543 allocated out of the main thread stack size. If no secondary stack
3544 size parameter is present, the default size (from the declaration in
3545 @code{System.Secondary_Stack} is used.
3547 @node Pragma Time_Slice
3548 @unnumberedsec Pragma Time_Slice
3553 @smallexample @c ada
3554 pragma Time_Slice (static_duration_EXPRESSION);
3558 For implementations of GNAT on operating systems where it is possible
3559 to supply a time slice value, this pragma may be used for this purpose.
3560 It is ignored if it is used in a system that does not allow this control,
3561 or if it appears in other than the main program unit.
3563 Note that the effect of this pragma is identical to the effect of the
3564 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3567 @unnumberedsec Pragma Title
3572 @smallexample @c ada
3573 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3576 [Title =>] STRING_LITERAL,
3577 | [Subtitle =>] STRING_LITERAL
3581 Syntax checked but otherwise ignored by GNAT@. This is a listing control
3582 pragma used in DEC Ada 83 implementations to provide a title and/or
3583 subtitle for the program listing. The program listing generated by GNAT
3584 does not have titles or subtitles.
3586 Unlike other pragmas, the full flexibility of named notation is allowed
3587 for this pragma, i.e.@: the parameters may be given in any order if named
3588 notation is used, and named and positional notation can be mixed
3589 following the normal rules for procedure calls in Ada.
3591 @node Pragma Unchecked_Union
3592 @unnumberedsec Pragma Unchecked_Union
3594 @findex Unchecked_Union
3598 @smallexample @c ada
3599 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
3603 This pragma is used to declare that the specified type should be represented
3605 equivalent to a C union type, and is intended only for use in
3606 interfacing with C code that uses union types. In Ada terms, the named
3607 type must obey the following rules:
3611 It is a non-tagged non-limited record type.
3613 It has a single discrete discriminant with a default value.
3615 The component list consists of a single variant part.
3617 Each variant has a component list with a single component.
3619 No nested variants are allowed.
3621 No component has an explicit default value.
3623 No component has a non-static constraint.
3627 In addition, given a type that meets the above requirements, the
3628 following restrictions apply to its use throughout the program:
3632 The discriminant name can be mentioned only in an aggregate.
3634 No subtypes may be created of this type.
3636 The type may not be constrained by giving a discriminant value.
3638 The type cannot be passed as the actual for a generic formal with a
3643 Equality and inequality operations on @code{unchecked_unions} are not
3644 available, since there is no discriminant to compare and the compiler
3645 does not even know how many bits to compare. It is implementation
3646 dependent whether this is detected at compile time as an illegality or
3647 whether it is undetected and considered to be an erroneous construct. In
3648 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
3649 the composite case (where two composites are compared that contain an
3650 unchecked union component), so such comparisons are simply considered
3653 The layout of the resulting type corresponds exactly to a C union, where
3654 each branch of the union corresponds to a single variant in the Ada
3655 record. The semantics of the Ada program is not changed in any way by
3656 the pragma, i.e.@: provided the above restrictions are followed, and no
3657 erroneous incorrect references to fields or erroneous comparisons occur,
3658 the semantics is exactly as described by the Ada reference manual.
3659 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
3660 type and the default convention is C.
3662 @node Pragma Unimplemented_Unit
3663 @unnumberedsec Pragma Unimplemented_Unit
3664 @findex Unimplemented_Unit
3668 @smallexample @c ada
3669 pragma Unimplemented_Unit;
3673 If this pragma occurs in a unit that is processed by the compiler, GNAT
3674 aborts with the message @samp{@var{xxx} not implemented}, where
3675 @var{xxx} is the name of the current compilation unit. This pragma is
3676 intended to allow the compiler to handle unimplemented library units in
3679 The abort only happens if code is being generated. Thus you can use
3680 specs of unimplemented packages in syntax or semantic checking mode.
3682 @node Pragma Universal_Data
3683 @unnumberedsec Pragma Universal_Data
3684 @findex Universal_Data
3688 @smallexample @c ada
3689 pragma Universal_Data [(library_unit_Name)];
3693 This pragma is supported only for the AAMP target and is ignored for
3694 other targets. The pragma specifies that all library-level objects
3695 (Counter 0 data) associated with the library unit are to be accessed
3696 and updated using universal addressing (24-bit addresses for AAMP5)
3697 rather than the default of 16-bit Data Environment (DENV) addressing.
3698 Use of this pragma will generally result in less efficient code for
3699 references to global data associated with the library unit, but
3700 allows such data to be located anywhere in memory. This pragma is
3701 a library unit pragma, but can also be used as a configuration pragma
3702 (including use in the @file{gnat.adc} file). The functionality
3703 of this pragma is also available by applying the -univ switch on the
3704 compilations of units where universal addressing of the data is desired.
3706 @node Pragma Unreferenced
3707 @unnumberedsec Pragma Unreferenced
3708 @findex Unreferenced
3709 @cindex Warnings, unreferenced
3713 @smallexample @c ada
3714 pragma Unreferenced (local_Name @{, local_Name@});
3718 This pragma signals that the entities whose names are listed are
3719 deliberately not referenced in the current source unit. This
3720 suppresses warnings about the
3721 entities being unreferenced, and in addition a warning will be
3722 generated if one of these entities is in fact referenced in the
3723 same unit as the pragma (or in the corresponding body, or one
3726 This is particularly useful for clearly signaling that a particular
3727 parameter is not referenced in some particular subprogram implementation
3728 and that this is deliberate. It can also be useful in the case of
3729 objects declared only for their initialization or finalization side
3732 If @code{local_Name} identifies more than one matching homonym in the
3733 current scope, then the entity most recently declared is the one to which
3736 The left hand side of an assignment does not count as a reference for the
3737 purpose of this pragma. Thus it is fine to assign to an entity for which
3738 pragma Unreferenced is given.
3740 @node Pragma Unreserve_All_Interrupts
3741 @unnumberedsec Pragma Unreserve_All_Interrupts
3742 @findex Unreserve_All_Interrupts
3746 @smallexample @c ada
3747 pragma Unreserve_All_Interrupts;
3751 Normally certain interrupts are reserved to the implementation. Any attempt
3752 to attach an interrupt causes Program_Error to be raised, as described in
3753 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3754 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
3755 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3756 interrupt execution.
3758 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3759 a program, then all such interrupts are unreserved. This allows the
3760 program to handle these interrupts, but disables their standard
3761 functions. For example, if this pragma is used, then pressing
3762 @kbd{Ctrl-C} will not automatically interrupt execution. However,
3763 a program can then handle the @code{SIGINT} interrupt as it chooses.
3765 For a full list of the interrupts handled in a specific implementation,
3766 see the source code for the specification of @code{Ada.Interrupts.Names} in
3767 file @file{a-intnam.ads}. This is a target dependent file that contains the
3768 list of interrupts recognized for a given target. The documentation in
3769 this file also specifies what interrupts are affected by the use of
3770 the @code{Unreserve_All_Interrupts} pragma.
3772 For a more general facility for controlling what interrupts can be
3773 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
3774 of the @code{Unreserve_All_Interrupts} pragma.
3776 @node Pragma Unsuppress
3777 @unnumberedsec Pragma Unsuppress
3782 @smallexample @c ada
3783 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3787 This pragma undoes the effect of a previous pragma @code{Suppress}. If
3788 there is no corresponding pragma @code{Suppress} in effect, it has no
3789 effect. The range of the effect is the same as for pragma
3790 @code{Suppress}. The meaning of the arguments is identical to that used
3791 in pragma @code{Suppress}.
3793 One important application is to ensure that checks are on in cases where
3794 code depends on the checks for its correct functioning, so that the code
3795 will compile correctly even if the compiler switches are set to suppress
3798 @node Pragma Use_VADS_Size
3799 @unnumberedsec Pragma Use_VADS_Size
3800 @cindex @code{Size}, VADS compatibility
3801 @findex Use_VADS_Size
3805 @smallexample @c ada
3806 pragma Use_VADS_Size;
3810 This is a configuration pragma. In a unit to which it applies, any use
3811 of the 'Size attribute is automatically interpreted as a use of the
3812 'VADS_Size attribute. Note that this may result in incorrect semantic
3813 processing of valid Ada 95 programs. This is intended to aid in the
3814 handling of legacy code which depends on the interpretation of Size
3815 as implemented in the VADS compiler. See description of the VADS_Size
3816 attribute for further details.
3818 @node Pragma Validity_Checks
3819 @unnumberedsec Pragma Validity_Checks
3820 @findex Validity_Checks
3824 @smallexample @c ada
3825 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3829 This pragma is used in conjunction with compiler switches to control the
3830 built-in validity checking provided by GNAT@. The compiler switches, if set
3831 provide an initial setting for the switches, and this pragma may be used
3832 to modify these settings, or the settings may be provided entirely by
3833 the use of the pragma. This pragma can be used anywhere that a pragma
3834 is legal, including use as a configuration pragma (including use in
3835 the @file{gnat.adc} file).
3837 The form with a string literal specifies which validity options are to be
3838 activated. The validity checks are first set to include only the default
3839 reference manual settings, and then a string of letters in the string
3840 specifies the exact set of options required. The form of this string
3841 is exactly as described for the @code{-gnatVx} compiler switch (see the
3842 GNAT users guide for details). For example the following two methods
3843 can be used to enable validity checking for mode @code{in} and
3844 @code{in out} subprogram parameters:
3848 @smallexample @c ada
3849 pragma Validity_Checks ("im");
3854 gcc -c -gnatVim @dots{}
3859 The form ALL_CHECKS activates all standard checks (its use is equivalent
3860 to the use of the @code{gnatva} switch.
3862 The forms with @code{Off} and @code{On}
3863 can be used to temporarily disable validity checks
3864 as shown in the following example:
3866 @smallexample @c ada
3870 pragma Validity_Checks ("c"); -- validity checks for copies
3871 pragma Validity_Checks (Off); -- turn off validity checks
3872 A := B; -- B will not be validity checked
3873 pragma Validity_Checks (On); -- turn validity checks back on
3874 A := C; -- C will be validity checked
3877 @node Pragma Volatile
3878 @unnumberedsec Pragma Volatile
3883 @smallexample @c ada
3884 pragma Volatile (local_NAME);
3888 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
3889 implementation is fully conformant with this definition. The reason it
3890 is mentioned in this section is that a pragma of the same name was supplied
3891 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 implementation
3892 of pragma Volatile is upwards compatible with the implementation in
3895 @node Pragma Warnings
3896 @unnumberedsec Pragma Warnings
3901 @smallexample @c ada
3902 pragma Warnings (On | Off [, LOCAL_NAME]);
3906 Normally warnings are enabled, with the output being controlled by
3907 the command line switch. Warnings (@code{Off}) turns off generation of
3908 warnings until a Warnings (@code{On}) is encountered or the end of the
3909 current unit. If generation of warnings is turned off using this
3910 pragma, then no warning messages are output, regardless of the
3911 setting of the command line switches.
3913 The form with a single argument is a configuration pragma.
3915 If the @var{local_name} parameter is present, warnings are suppressed for
3916 the specified entity. This suppression is effective from the point where
3917 it occurs till the end of the extended scope of the variable (similar to
3918 the scope of @code{Suppress}).
3920 @node Pragma Weak_External
3921 @unnumberedsec Pragma Weak_External
3922 @findex Weak_External
3926 @smallexample @c ada
3927 pragma Weak_External ([Entity =>] LOCAL_NAME);
3931 This pragma specifies that the given entity should be marked as a weak
3932 external (one that does not have to be resolved) for the linker. For
3933 further details, consult the GCC manual.
3935 @node Implementation Defined Attributes
3936 @chapter Implementation Defined Attributes
3937 Ada 95 defines (throughout the Ada 95 reference manual,
3938 summarized in annex K),
3939 a set of attributes that provide useful additional functionality in all
3940 areas of the language. These language defined attributes are implemented
3941 in GNAT and work as described in the Ada 95 Reference Manual.
3943 In addition, Ada 95 allows implementations to define additional
3944 attributes whose meaning is defined by the implementation. GNAT provides
3945 a number of these implementation-dependent attributes which can be used
3946 to extend and enhance the functionality of the compiler. This section of
3947 the GNAT reference manual describes these additional attributes.
3949 Note that any program using these attributes may not be portable to
3950 other compilers (although GNAT implements this set of attributes on all
3951 platforms). Therefore if portability to other compilers is an important
3952 consideration, you should minimize the use of these attributes.
3963 * Default_Bit_Order::
3971 * Has_Discriminants::
3977 * Max_Interrupt_Priority::
3979 * Maximum_Alignment::
3983 * Passed_By_Reference::
3994 * Unconstrained_Array::
3995 * Universal_Literal_String::
3996 * Unrestricted_Access::
4004 @unnumberedsec Abort_Signal
4005 @findex Abort_Signal
4007 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4008 prefix) provides the entity for the special exception used to signal
4009 task abort or asynchronous transfer of control. Normally this attribute
4010 should only be used in the tasking runtime (it is highly peculiar, and
4011 completely outside the normal semantics of Ada, for a user program to
4012 intercept the abort exception).
4015 @unnumberedsec Address_Size
4016 @cindex Size of @code{Address}
4017 @findex Address_Size
4019 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4020 prefix) is a static constant giving the number of bits in an
4021 @code{Address}. It is the same value as System.Address'Size,
4022 but has the advantage of being static, while a direct
4023 reference to System.Address'Size is non-static because Address
4027 @unnumberedsec Asm_Input
4030 The @code{Asm_Input} attribute denotes a function that takes two
4031 parameters. The first is a string, the second is an expression of the
4032 type designated by the prefix. The first (string) argument is required
4033 to be a static expression, and is the constraint for the parameter,
4034 (e.g.@: what kind of register is required). The second argument is the
4035 value to be used as the input argument. The possible values for the
4036 constant are the same as those used in the RTL, and are dependent on
4037 the configuration file used to built the GCC back end.
4038 @ref{Machine Code Insertions}
4041 @unnumberedsec Asm_Output
4044 The @code{Asm_Output} attribute denotes a function that takes two
4045 parameters. The first is a string, the second is the name of a variable
4046 of the type designated by the attribute prefix. The first (string)
4047 argument is required to be a static expression and designates the
4048 constraint for the parameter (e.g.@: what kind of register is
4049 required). The second argument is the variable to be updated with the
4050 result. The possible values for constraint are the same as those used in
4051 the RTL, and are dependent on the configuration file used to build the
4052 GCC back end. If there are no output operands, then this argument may
4053 either be omitted, or explicitly given as @code{No_Output_Operands}.
4054 @ref{Machine Code Insertions}
4057 @unnumberedsec AST_Entry
4061 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
4062 the name of an entry, it yields a value of the predefined type AST_Handler
4063 (declared in the predefined package System, as extended by the use of
4064 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
4065 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
4066 Language Reference Manual}, section 9.12a.
4071 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4072 offset within the storage unit (byte) that contains the first bit of
4073 storage allocated for the object. The value of this attribute is of the
4074 type @code{Universal_Integer}, and is always a non-negative number not
4075 exceeding the value of @code{System.Storage_Unit}.
4077 For an object that is a variable or a constant allocated in a register,
4078 the value is zero. (The use of this attribute does not force the
4079 allocation of a variable to memory).
4081 For an object that is a formal parameter, this attribute applies
4082 to either the matching actual parameter or to a copy of the
4083 matching actual parameter.
4085 For an access object the value is zero. Note that
4086 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4087 designated object. Similarly for a record component
4088 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4089 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4090 are subject to index checks.
4092 This attribute is designed to be compatible with the DEC Ada 83 definition
4093 and implementation of the @code{Bit} attribute.
4096 @unnumberedsec Bit_Position
4097 @findex Bit_Position
4099 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4100 of the fields of the record type, yields the bit
4101 offset within the record contains the first bit of
4102 storage allocated for the object. The value of this attribute is of the
4103 type @code{Universal_Integer}. The value depends only on the field
4104 @var{C} and is independent of the alignment of
4105 the containing record @var{R}.
4108 @unnumberedsec Code_Address
4109 @findex Code_Address
4110 @cindex Subprogram address
4111 @cindex Address of subprogram code
4114 attribute may be applied to subprograms in Ada 95, but the
4115 intended effect from the Ada 95 reference manual seems to be to provide
4116 an address value which can be used to call the subprogram by means of
4117 an address clause as in the following example:
4119 @smallexample @c ada
4120 procedure K is @dots{}
4123 for L'Address use K'Address;
4124 pragma Import (Ada, L);
4128 A call to @code{L} is then expected to result in a call to @code{K}@.
4129 In Ada 83, where there were no access-to-subprogram values, this was
4130 a common work around for getting the effect of an indirect call.
4131 GNAT implements the above use of @code{Address} and the technique
4132 illustrated by the example code works correctly.
4134 However, for some purposes, it is useful to have the address of the start
4135 of the generated code for the subprogram. On some architectures, this is
4136 not necessarily the same as the @code{Address} value described above.
4137 For example, the @code{Address} value may reference a subprogram
4138 descriptor rather than the subprogram itself.
4140 The @code{'Code_Address} attribute, which can only be applied to
4141 subprogram entities, always returns the address of the start of the
4142 generated code of the specified subprogram, which may or may not be
4143 the same value as is returned by the corresponding @code{'Address}
4146 @node Default_Bit_Order
4147 @unnumberedsec Default_Bit_Order
4149 @cindex Little endian
4150 @findex Default_Bit_Order
4152 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4153 permissible prefix), provides the value @code{System.Default_Bit_Order}
4154 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4155 @code{Low_Order_First}). This is used to construct the definition of
4156 @code{Default_Bit_Order} in package @code{System}.
4159 @unnumberedsec Elaborated
4162 The prefix of the @code{'Elaborated} attribute must be a unit name. The
4163 value is a Boolean which indicates whether or not the given unit has been
4164 elaborated. This attribute is primarily intended for internal use by the
4165 generated code for dynamic elaboration checking, but it can also be used
4166 in user programs. The value will always be True once elaboration of all
4167 units has been completed. An exception is for units which need no
4168 elaboration, the value is always False for such units.
4171 @unnumberedsec Elab_Body
4174 This attribute can only be applied to a program unit name. It returns
4175 the entity for the corresponding elaboration procedure for elaborating
4176 the body of the referenced unit. This is used in the main generated
4177 elaboration procedure by the binder and is not normally used in any
4178 other context. However, there may be specialized situations in which it
4179 is useful to be able to call this elaboration procedure from Ada code,
4180 e.g.@: if it is necessary to do selective re-elaboration to fix some
4184 @unnumberedsec Elab_Spec
4187 This attribute can only be applied to a program unit name. It returns
4188 the entity for the corresponding elaboration procedure for elaborating
4189 the specification of the referenced unit. This is used in the main
4190 generated elaboration procedure by the binder and is not normally used
4191 in any other context. However, there may be specialized situations in
4192 which it is useful to be able to call this elaboration procedure from
4193 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4198 @cindex Ada 83 attributes
4201 The @code{Emax} attribute is provided for compatibility with Ada 83. See
4202 the Ada 83 reference manual for an exact description of the semantics of
4206 @unnumberedsec Enum_Rep
4207 @cindex Representation of enums
4210 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4211 function with the following spec:
4213 @smallexample @c ada
4214 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4215 return @i{Universal_Integer};
4219 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4220 enumeration type or to a non-overloaded enumeration
4221 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
4222 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4223 enumeration literal or object.
4225 The function returns the representation value for the given enumeration
4226 value. This will be equal to value of the @code{Pos} attribute in the
4227 absence of an enumeration representation clause. This is a static
4228 attribute (i.e.@: the result is static if the argument is static).
4230 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4231 in which case it simply returns the integer value. The reason for this
4232 is to allow it to be used for @code{(<>)} discrete formal arguments in
4233 a generic unit that can be instantiated with either enumeration types
4234 or integer types. Note that if @code{Enum_Rep} is used on a modular
4235 type whose upper bound exceeds the upper bound of the largest signed
4236 integer type, and the argument is a variable, so that the universal
4237 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4238 may raise @code{Constraint_Error}.
4241 @unnumberedsec Epsilon
4242 @cindex Ada 83 attributes
4245 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
4246 the Ada 83 reference manual for an exact description of the semantics of
4250 @unnumberedsec Fixed_Value
4253 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4254 function with the following specification:
4256 @smallexample @c ada
4257 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4262 The value returned is the fixed-point value @var{V} such that
4264 @smallexample @c ada
4265 @var{V} = Arg * @var{S}'Small
4269 The effect is thus similar to first converting the argument to the
4270 integer type used to represent @var{S}, and then doing an unchecked
4271 conversion to the fixed-point type. The difference is
4272 that there are full range checks, to ensure that the result is in range.
4273 This attribute is primarily intended for use in implementation of the
4274 input-output functions for fixed-point values.
4276 @node Has_Discriminants
4277 @unnumberedsec Has_Discriminants
4278 @cindex Discriminants, testing for
4279 @findex Has_Discriminants
4281 The prefix of the @code{Has_Discriminants} attribute is a type. The result
4282 is a Boolean value which is True if the type has discriminants, and False
4283 otherwise. The intended use of this attribute is in conjunction with generic
4284 definitions. If the attribute is applied to a generic private type, it
4285 indicates whether or not the corresponding actual type has discriminants.
4291 The @code{Img} attribute differs from @code{Image} in that it may be
4292 applied to objects as well as types, in which case it gives the
4293 @code{Image} for the subtype of the object. This is convenient for
4296 @smallexample @c ada
4297 Put_Line ("X = " & X'Img);
4301 has the same meaning as the more verbose:
4303 @smallexample @c ada
4304 Put_Line ("X = " & @var{T}'Image (X));
4308 where @var{T} is the (sub)type of the object @code{X}.
4311 @unnumberedsec Integer_Value
4312 @findex Integer_Value
4314 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4315 function with the following spec:
4317 @smallexample @c ada
4318 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4323 The value returned is the integer value @var{V}, such that
4325 @smallexample @c ada
4326 Arg = @var{V} * @var{T}'Small
4330 where @var{T} is the type of @code{Arg}.
4331 The effect is thus similar to first doing an unchecked conversion from
4332 the fixed-point type to its corresponding implementation type, and then
4333 converting the result to the target integer type. The difference is
4334 that there are full range checks, to ensure that the result is in range.
4335 This attribute is primarily intended for use in implementation of the
4336 standard input-output functions for fixed-point values.
4339 @unnumberedsec Large
4340 @cindex Ada 83 attributes
4343 The @code{Large} attribute is provided for compatibility with Ada 83. See
4344 the Ada 83 reference manual for an exact description of the semantics of
4348 @unnumberedsec Machine_Size
4349 @findex Machine_Size
4351 This attribute is identical to the @code{Object_Size} attribute. It is
4352 provided for compatibility with the DEC Ada 83 attribute of this name.
4355 @unnumberedsec Mantissa
4356 @cindex Ada 83 attributes
4359 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
4360 the Ada 83 reference manual for an exact description of the semantics of
4363 @node Max_Interrupt_Priority
4364 @unnumberedsec Max_Interrupt_Priority
4365 @cindex Interrupt priority, maximum
4366 @findex Max_Interrupt_Priority
4368 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4369 permissible prefix), provides the same value as
4370 @code{System.Max_Interrupt_Priority}.
4373 @unnumberedsec Max_Priority
4374 @cindex Priority, maximum
4375 @findex Max_Priority
4377 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4378 prefix) provides the same value as @code{System.Max_Priority}.
4380 @node Maximum_Alignment
4381 @unnumberedsec Maximum_Alignment
4382 @cindex Alignment, maximum
4383 @findex Maximum_Alignment
4385 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4386 permissible prefix) provides the maximum useful alignment value for the
4387 target. This is a static value that can be used to specify the alignment
4388 for an object, guaranteeing that it is properly aligned in all
4391 @node Mechanism_Code
4392 @unnumberedsec Mechanism_Code
4393 @cindex Return values, passing mechanism
4394 @cindex Parameters, passing mechanism
4395 @findex Mechanism_Code
4397 @code{@var{function}'Mechanism_Code} yields an integer code for the
4398 mechanism used for the result of function, and
4399 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4400 used for formal parameter number @var{n} (a static integer value with 1
4401 meaning the first parameter) of @var{subprogram}. The code returned is:
4409 by descriptor (default descriptor class)
4411 by descriptor (UBS: unaligned bit string)
4413 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4415 by descriptor (UBA: unaligned bit array)
4417 by descriptor (S: string, also scalar access type parameter)
4419 by descriptor (SB: string with arbitrary bounds)
4421 by descriptor (A: contiguous array)
4423 by descriptor (NCA: non-contiguous array)
4427 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4430 @node Null_Parameter
4431 @unnumberedsec Null_Parameter
4432 @cindex Zero address, passing
4433 @findex Null_Parameter
4435 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4436 type or subtype @var{T} allocated at machine address zero. The attribute
4437 is allowed only as the default expression of a formal parameter, or as
4438 an actual expression of a subprogram call. In either case, the
4439 subprogram must be imported.
4441 The identity of the object is represented by the address zero in the
4442 argument list, independent of the passing mechanism (explicit or
4445 This capability is needed to specify that a zero address should be
4446 passed for a record or other composite object passed by reference.
4447 There is no way of indicating this without the @code{Null_Parameter}
4451 @unnumberedsec Object_Size
4452 @cindex Size, used for objects
4455 The size of an object is not necessarily the same as the size of the type
4456 of an object. This is because by default object sizes are increased to be
4457 a multiple of the alignment of the object. For example,
4458 @code{Natural'Size} is
4459 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4460 Similarly, a record containing an integer and a character:
4462 @smallexample @c ada
4470 will have a size of 40 (that is @code{Rec'Size} will be 40. The
4471 alignment will be 4, because of the
4472 integer field, and so the default size of record objects for this type
4473 will be 64 (8 bytes).
4475 The @code{@var{type}'Object_Size} attribute
4476 has been added to GNAT to allow the
4477 default object size of a type to be easily determined. For example,
4478 @code{Natural'Object_Size} is 32, and
4479 @code{Rec'Object_Size} (for the record type in the above example) will be
4480 64. Note also that, unlike the situation with the
4481 @code{Size} attribute as defined in the Ada RM, the
4482 @code{Object_Size} attribute can be specified individually
4483 for different subtypes. For example:
4485 @smallexample @c ada
4486 type R is new Integer;
4487 subtype R1 is R range 1 .. 10;
4488 subtype R2 is R range 1 .. 10;
4489 for R2'Object_Size use 8;
4493 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4494 32 since the default object size for a subtype is the same as the object size
4495 for the parent subtype. This means that objects of type @code{R}
4497 by default be 32 bits (four bytes). But objects of type
4498 @code{R2} will be only
4499 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4501 @node Passed_By_Reference
4502 @unnumberedsec Passed_By_Reference
4503 @cindex Parameters, when passed by reference
4504 @findex Passed_By_Reference
4506 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4507 a value of type @code{Boolean} value that is @code{True} if the type is
4508 normally passed by reference and @code{False} if the type is normally
4509 passed by copy in calls. For scalar types, the result is always @code{False}
4510 and is static. For non-scalar types, the result is non-static.
4513 @unnumberedsec Range_Length
4514 @findex Range_Length
4516 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
4517 the number of values represented by the subtype (zero for a null
4518 range). The result is static for static subtypes. @code{Range_Length}
4519 applied to the index subtype of a one dimensional array always gives the
4520 same result as @code{Range} applied to the array itself.
4523 @unnumberedsec Safe_Emax
4524 @cindex Ada 83 attributes
4527 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
4528 the Ada 83 reference manual for an exact description of the semantics of
4532 @unnumberedsec Safe_Large
4533 @cindex Ada 83 attributes
4536 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
4537 the Ada 83 reference manual for an exact description of the semantics of
4541 @unnumberedsec Small
4542 @cindex Ada 83 attributes
4545 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
4546 GNAT also allows this attribute to be applied to floating-point types
4547 for compatibility with Ada 83. See
4548 the Ada 83 reference manual for an exact description of the semantics of
4549 this attribute when applied to floating-point types.
4552 @unnumberedsec Storage_Unit
4553 @findex Storage_Unit
4555 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
4556 prefix) provides the same value as @code{System.Storage_Unit}.
4559 @unnumberedsec Target_Name
4562 @code{Standard'Target_Name} (@code{Standard} is the only permissible
4563 prefix) provides a static string value that identifies the target
4564 for the current compilation. For GCC implementations, this is the
4565 standard gcc target name without the terminating slash (for
4566 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
4572 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
4573 provides the same value as @code{System.Tick},
4576 @unnumberedsec To_Address
4579 The @code{System'To_Address}
4580 (@code{System} is the only permissible prefix)
4581 denotes a function identical to
4582 @code{System.Storage_Elements.To_Address} except that
4583 it is a static attribute. This means that if its argument is
4584 a static expression, then the result of the attribute is a
4585 static expression. The result is that such an expression can be
4586 used in contexts (e.g.@: preelaborable packages) which require a
4587 static expression and where the function call could not be used
4588 (since the function call is always non-static, even if its
4589 argument is static).
4592 @unnumberedsec Type_Class
4595 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
4596 the value of the type class for the full type of @var{type}. If
4597 @var{type} is a generic formal type, the value is the value for the
4598 corresponding actual subtype. The value of this attribute is of type
4599 @code{System.Aux_DEC.Type_Class}, which has the following definition:
4601 @smallexample @c ada
4603 (Type_Class_Enumeration,
4605 Type_Class_Fixed_Point,
4606 Type_Class_Floating_Point,
4611 Type_Class_Address);
4615 Protected types yield the value @code{Type_Class_Task}, which thus
4616 applies to all concurrent types. This attribute is designed to
4617 be compatible with the DEC Ada 83 attribute of the same name.
4620 @unnumberedsec UET_Address
4623 The @code{UET_Address} attribute can only be used for a prefix which
4624 denotes a library package. It yields the address of the unit exception
4625 table when zero cost exception handling is used. This attribute is
4626 intended only for use within the GNAT implementation. See the unit
4627 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
4628 for details on how this attribute is used in the implementation.
4630 @node Unconstrained_Array
4631 @unnumberedsec Unconstrained_Array
4632 @findex Unconstrained_Array
4634 The @code{Unconstrained_Array} attribute can be used with a prefix that
4635 denotes any type or subtype. It is a static attribute that yields
4636 @code{True} if the prefix designates an unconstrained array,
4637 and @code{False} otherwise. In a generic instance, the result is
4638 still static, and yields the result of applying this test to the
4641 @node Universal_Literal_String
4642 @unnumberedsec Universal_Literal_String
4643 @cindex Named numbers, representation of
4644 @findex Universal_Literal_String
4646 The prefix of @code{Universal_Literal_String} must be a named
4647 number. The static result is the string consisting of the characters of
4648 the number as defined in the original source. This allows the user
4649 program to access the actual text of named numbers without intermediate
4650 conversions and without the need to enclose the strings in quotes (which
4651 would preclude their use as numbers). This is used internally for the
4652 construction of values of the floating-point attributes from the file
4653 @file{ttypef.ads}, but may also be used by user programs.
4655 @node Unrestricted_Access
4656 @unnumberedsec Unrestricted_Access
4657 @cindex @code{Access}, unrestricted
4658 @findex Unrestricted_Access
4660 The @code{Unrestricted_Access} attribute is similar to @code{Access}
4661 except that all accessibility and aliased view checks are omitted. This
4662 is a user-beware attribute. It is similar to
4663 @code{Address}, for which it is a desirable replacement where the value
4664 desired is an access type. In other words, its effect is identical to
4665 first applying the @code{Address} attribute and then doing an unchecked
4666 conversion to a desired access type. In GNAT, but not necessarily in
4667 other implementations, the use of static chains for inner level
4668 subprograms means that @code{Unrestricted_Access} applied to a
4669 subprogram yields a value that can be called as long as the subprogram
4670 is in scope (normal Ada 95 accessibility rules restrict this usage).
4672 It is possible to use @code{Unrestricted_Access} for any type, but care
4673 must be excercised if it is used to create pointers to unconstrained
4674 objects. In this case, the resulting pointer has the same scope as the
4675 context of the attribute, and may not be returned to some enclosing
4676 scope. For instance, a function cannot use @code{Unrestricted_Access}
4677 to create a unconstrained pointer and then return that value to the
4681 @unnumberedsec VADS_Size
4682 @cindex @code{Size}, VADS compatibility
4685 The @code{'VADS_Size} attribute is intended to make it easier to port
4686 legacy code which relies on the semantics of @code{'Size} as implemented
4687 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
4688 same semantic interpretation. In particular, @code{'VADS_Size} applied
4689 to a predefined or other primitive type with no Size clause yields the
4690 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
4691 typical machines). In addition @code{'VADS_Size} applied to an object
4692 gives the result that would be obtained by applying the attribute to
4693 the corresponding type.
4696 @unnumberedsec Value_Size
4697 @cindex @code{Size}, setting for not-first subtype
4699 @code{@var{type}'Value_Size} is the number of bits required to represent
4700 a value of the given subtype. It is the same as @code{@var{type}'Size},
4701 but, unlike @code{Size}, may be set for non-first subtypes.
4704 @unnumberedsec Wchar_T_Size
4705 @findex Wchar_T_Size
4706 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
4707 prefix) provides the size in bits of the C @code{wchar_t} type
4708 primarily for constructing the definition of this type in
4709 package @code{Interfaces.C}.
4712 @unnumberedsec Word_Size
4714 @code{Standard'Word_Size} (@code{Standard} is the only permissible
4715 prefix) provides the value @code{System.Word_Size}.
4717 @c ------------------------
4718 @node Implementation Advice
4719 @chapter Implementation Advice
4721 The main text of the Ada 95 Reference Manual describes the required
4722 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
4725 In addition, there are sections throughout the Ada 95
4726 reference manual headed
4727 by the phrase ``implementation advice''. These sections are not normative,
4728 i.e.@: they do not specify requirements that all compilers must
4729 follow. Rather they provide advice on generally desirable behavior. You
4730 may wonder why they are not requirements. The most typical answer is
4731 that they describe behavior that seems generally desirable, but cannot
4732 be provided on all systems, or which may be undesirable on some systems.
4734 As far as practical, GNAT follows the implementation advice sections in
4735 the Ada 95 Reference Manual. This chapter contains a table giving the
4736 reference manual section number, paragraph number and several keywords
4737 for each advice. Each entry consists of the text of the advice followed
4738 by the GNAT interpretation of this advice. Most often, this simply says
4739 ``followed'', which means that GNAT follows the advice. However, in a
4740 number of cases, GNAT deliberately deviates from this advice, in which
4741 case the text describes what GNAT does and why.
4743 @cindex Error detection
4744 @unnumberedsec 1.1.3(20): Error Detection
4747 If an implementation detects the use of an unsupported Specialized Needs
4748 Annex feature at run time, it should raise @code{Program_Error} if
4751 Not relevant. All specialized needs annex features are either supported,
4752 or diagnosed at compile time.
4755 @unnumberedsec 1.1.3(31): Child Units
4758 If an implementation wishes to provide implementation-defined
4759 extensions to the functionality of a language-defined library unit, it
4760 should normally do so by adding children to the library unit.
4764 @cindex Bounded errors
4765 @unnumberedsec 1.1.5(12): Bounded Errors
4768 If an implementation detects a bounded error or erroneous
4769 execution, it should raise @code{Program_Error}.
4771 Followed in all cases in which the implementation detects a bounded
4772 error or erroneous execution. Not all such situations are detected at
4776 @unnumberedsec 2.8(16): Pragmas
4779 Normally, implementation-defined pragmas should have no semantic effect
4780 for error-free programs; that is, if the implementation-defined pragmas
4781 are removed from a working program, the program should still be legal,
4782 and should still have the same semantics.
4784 The following implementation defined pragmas are exceptions to this
4796 @item CPP_Constructor
4804 @item Interface_Name
4806 @item Machine_Attribute
4808 @item Unimplemented_Unit
4810 @item Unchecked_Union
4815 In each of the above cases, it is essential to the purpose of the pragma
4816 that this advice not be followed. For details see the separate section
4817 on implementation defined pragmas.
4819 @unnumberedsec 2.8(17-19): Pragmas
4822 Normally, an implementation should not define pragmas that can
4823 make an illegal program legal, except as follows:
4827 A pragma used to complete a declaration, such as a pragma @code{Import};
4831 A pragma used to configure the environment by adding, removing, or
4832 replacing @code{library_items}.
4834 See response to paragraph 16 of this same section.
4836 @cindex Character Sets
4837 @cindex Alternative Character Sets
4838 @unnumberedsec 3.5.2(5): Alternative Character Sets
4841 If an implementation supports a mode with alternative interpretations
4842 for @code{Character} and @code{Wide_Character}, the set of graphic
4843 characters of @code{Character} should nevertheless remain a proper
4844 subset of the set of graphic characters of @code{Wide_Character}. Any
4845 character set ``localizations'' should be reflected in the results of
4846 the subprograms defined in the language-defined package
4847 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
4848 an alternative interpretation of @code{Character}, the implementation should
4849 also support a corresponding change in what is a legal
4850 @code{identifier_letter}.
4852 Not all wide character modes follow this advice, in particular the JIS
4853 and IEC modes reflect standard usage in Japan, and in these encoding,
4854 the upper half of the Latin-1 set is not part of the wide-character
4855 subset, since the most significant bit is used for wide character
4856 encoding. However, this only applies to the external forms. Internally
4857 there is no such restriction.
4859 @cindex Integer types
4860 @unnumberedsec 3.5.4(28): Integer Types
4864 An implementation should support @code{Long_Integer} in addition to
4865 @code{Integer} if the target machine supports 32-bit (or longer)
4866 arithmetic. No other named integer subtypes are recommended for package
4867 @code{Standard}. Instead, appropriate named integer subtypes should be
4868 provided in the library package @code{Interfaces} (see B.2).
4870 @code{Long_Integer} is supported. Other standard integer types are supported
4871 so this advice is not fully followed. These types
4872 are supported for convenient interface to C, and so that all hardware
4873 types of the machine are easily available.
4874 @unnumberedsec 3.5.4(29): Integer Types
4878 An implementation for a two's complement machine should support
4879 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
4880 implementation should support a non-binary modules up to @code{Integer'Last}.
4884 @cindex Enumeration values
4885 @unnumberedsec 3.5.5(8): Enumeration Values
4888 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
4889 subtype, if the value of the operand does not correspond to the internal
4890 code for any enumeration literal of its type (perhaps due to an
4891 un-initialized variable), then the implementation should raise
4892 @code{Program_Error}. This is particularly important for enumeration
4893 types with noncontiguous internal codes specified by an
4894 enumeration_representation_clause.
4899 @unnumberedsec 3.5.7(17): Float Types
4902 An implementation should support @code{Long_Float} in addition to
4903 @code{Float} if the target machine supports 11 or more digits of
4904 precision. No other named floating point subtypes are recommended for
4905 package @code{Standard}. Instead, appropriate named floating point subtypes
4906 should be provided in the library package @code{Interfaces} (see B.2).
4908 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
4909 former provides improved compatibility with other implementations
4910 supporting this type. The latter corresponds to the highest precision
4911 floating-point type supported by the hardware. On most machines, this
4912 will be the same as @code{Long_Float}, but on some machines, it will
4913 correspond to the IEEE extended form. The notable case is all ia32
4914 (x86) implementations, where @code{Long_Long_Float} corresponds to
4915 the 80-bit extended precision format supported in hardware on this
4916 processor. Note that the 128-bit format on SPARC is not supported,
4917 since this is a software rather than a hardware format.
4919 @cindex Multidimensional arrays
4920 @cindex Arrays, multidimensional
4921 @unnumberedsec 3.6.2(11): Multidimensional Arrays
4924 An implementation should normally represent multidimensional arrays in
4925 row-major order, consistent with the notation used for multidimensional
4926 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
4927 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
4928 column-major order should be used instead (see B.5, ``Interfacing with
4933 @findex Duration'Small
4934 @unnumberedsec 9.6(30-31): Duration'Small
4937 Whenever possible in an implementation, the value of @code{Duration'Small}
4938 should be no greater than 100 microseconds.
4940 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
4944 The time base for @code{delay_relative_statements} should be monotonic;
4945 it need not be the same time base as used for @code{Calendar.Clock}.
4949 @unnumberedsec 10.2.1(12): Consistent Representation
4952 In an implementation, a type declared in a pre-elaborated package should
4953 have the same representation in every elaboration of a given version of
4954 the package, whether the elaborations occur in distinct executions of
4955 the same program, or in executions of distinct programs or partitions
4956 that include the given version.
4958 Followed, except in the case of tagged types. Tagged types involve
4959 implicit pointers to a local copy of a dispatch table, and these pointers
4960 have representations which thus depend on a particular elaboration of the
4961 package. It is not easy to see how it would be possible to follow this
4962 advice without severely impacting efficiency of execution.
4964 @cindex Exception information
4965 @unnumberedsec 11.4.1(19): Exception Information
4968 @code{Exception_Message} by default and @code{Exception_Information}
4969 should produce information useful for
4970 debugging. @code{Exception_Message} should be short, about one
4971 line. @code{Exception_Information} can be long. @code{Exception_Message}
4972 should not include the
4973 @code{Exception_Name}. @code{Exception_Information} should include both
4974 the @code{Exception_Name} and the @code{Exception_Message}.
4976 Followed. For each exception that doesn't have a specified
4977 @code{Exception_Message}, the compiler generates one containing the location
4978 of the raise statement. This location has the form ``file:line'', where
4979 file is the short file name (without path information) and line is the line
4980 number in the file. Note that in the case of the Zero Cost Exception
4981 mechanism, these messages become redundant with the Exception_Information that
4982 contains a full backtrace of the calling sequence, so they are disabled.
4983 To disable explicitly the generation of the source location message, use the
4984 Pragma @code{Discard_Names}.
4986 @cindex Suppression of checks
4987 @cindex Checks, suppression of
4988 @unnumberedsec 11.5(28): Suppression of Checks
4991 The implementation should minimize the code executed for checks that
4992 have been suppressed.
4996 @cindex Representation clauses
4997 @unnumberedsec 13.1 (21-24): Representation Clauses
5000 The recommended level of support for all representation items is
5001 qualified as follows:
5005 An implementation need not support representation items containing
5006 non-static expressions, except that an implementation should support a
5007 representation item for a given entity if each non-static expression in
5008 the representation item is a name that statically denotes a constant
5009 declared before the entity.
5011 Followed. GNAT does not support non-static expressions in representation
5012 clauses unless they are constants declared before the entity. For
5015 @smallexample @c ada
5017 for X'Address use To_address (16#2000#);
5021 will be rejected, since the To_Address expression is non-static. Instead
5024 @smallexample @c ada
5025 X_Address : constant Address : = To_Address (16#2000#);
5027 for X'Address use X_Address;
5032 An implementation need not support a specification for the @code{Size}
5033 for a given composite subtype, nor the size or storage place for an
5034 object (including a component) of a given composite subtype, unless the
5035 constraints on the subtype and its composite subcomponents (if any) are
5036 all static constraints.
5038 Followed. Size Clauses are not permitted on non-static components, as
5043 An aliased component, or a component whose type is by-reference, should
5044 always be allocated at an addressable location.
5048 @cindex Packed types
5049 @unnumberedsec 13.2(6-8): Packed Types
5052 If a type is packed, then the implementation should try to minimize
5053 storage allocated to objects of the type, possibly at the expense of
5054 speed of accessing components, subject to reasonable complexity in
5055 addressing calculations.
5059 The recommended level of support pragma @code{Pack} is:
5061 For a packed record type, the components should be packed as tightly as
5062 possible subject to the Sizes of the component subtypes, and subject to
5063 any @code{record_representation_clause} that applies to the type; the
5064 implementation may, but need not, reorder components or cross aligned
5065 word boundaries to improve the packing. A component whose @code{Size} is
5066 greater than the word size may be allocated an integral number of words.
5068 Followed. Tight packing of arrays is supported for all component sizes
5069 up to 64-bits. If the array component size is 1 (that is to say, if
5070 the component is a boolean type or an enumeration type with two values)
5071 then values of the type are implicitly initialized to zero. This
5072 happens both for objects of the packed type, and for objects that have a
5073 subcomponent of the packed type.
5077 An implementation should support Address clauses for imported
5081 @cindex @code{Address} clauses
5082 @unnumberedsec 13.3(14-19): Address Clauses
5086 For an array @var{X}, @code{@var{X}'Address} should point at the first
5087 component of the array, and not at the array bounds.
5093 The recommended level of support for the @code{Address} attribute is:
5095 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5096 object that is aliased or of a by-reference type, or is an entity whose
5097 @code{Address} has been specified.
5099 Followed. A valid address will be produced even if none of those
5100 conditions have been met. If necessary, the object is forced into
5101 memory to ensure the address is valid.
5105 An implementation should support @code{Address} clauses for imported
5112 Objects (including subcomponents) that are aliased or of a by-reference
5113 type should be allocated on storage element boundaries.
5119 If the @code{Address} of an object is specified, or it is imported or exported,
5120 then the implementation should not perform optimizations based on
5121 assumptions of no aliases.
5125 @cindex @code{Alignment} clauses
5126 @unnumberedsec 13.3(29-35): Alignment Clauses
5129 The recommended level of support for the @code{Alignment} attribute for
5132 An implementation should support specified Alignments that are factors
5133 and multiples of the number of storage elements per word, subject to the
5140 An implementation need not support specified @code{Alignment}s for
5141 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5142 loaded and stored by available machine instructions.
5148 An implementation need not support specified @code{Alignment}s that are
5149 greater than the maximum @code{Alignment} the implementation ever returns by
5156 The recommended level of support for the @code{Alignment} attribute for
5159 Same as above, for subtypes, but in addition:
5165 For stand-alone library-level objects of statically constrained
5166 subtypes, the implementation should support all @code{Alignment}s
5167 supported by the target linker. For example, page alignment is likely to
5168 be supported for such objects, but not for subtypes.
5172 @cindex @code{Size} clauses
5173 @unnumberedsec 13.3(42-43): Size Clauses
5176 The recommended level of support for the @code{Size} attribute of
5179 A @code{Size} clause should be supported for an object if the specified
5180 @code{Size} is at least as large as its subtype's @code{Size}, and
5181 corresponds to a size in storage elements that is a multiple of the
5182 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5186 @unnumberedsec 13.3(50-56): Size Clauses
5189 If the @code{Size} of a subtype is specified, and allows for efficient
5190 independent addressability (see 9.10) on the target architecture, then
5191 the @code{Size} of the following objects of the subtype should equal the
5192 @code{Size} of the subtype:
5194 Aliased objects (including components).
5200 @code{Size} clause on a composite subtype should not affect the
5201 internal layout of components.
5207 The recommended level of support for the @code{Size} attribute of subtypes is:
5211 The @code{Size} (if not specified) of a static discrete or fixed point
5212 subtype should be the number of bits needed to represent each value
5213 belonging to the subtype using an unbiased representation, leaving space
5214 for a sign bit only if the subtype contains negative values. If such a
5215 subtype is a first subtype, then an implementation should support a
5216 specified @code{Size} for it that reflects this representation.
5222 For a subtype implemented with levels of indirection, the @code{Size}
5223 should include the size of the pointers, but not the size of what they
5228 @cindex @code{Component_Size} clauses
5229 @unnumberedsec 13.3(71-73): Component Size Clauses
5232 The recommended level of support for the @code{Component_Size}
5237 An implementation need not support specified @code{Component_Sizes} that are
5238 less than the @code{Size} of the component subtype.
5244 An implementation should support specified @code{Component_Size}s that
5245 are factors and multiples of the word size. For such
5246 @code{Component_Size}s, the array should contain no gaps between
5247 components. For other @code{Component_Size}s (if supported), the array
5248 should contain no gaps between components when packing is also
5249 specified; the implementation should forbid this combination in cases
5250 where it cannot support a no-gaps representation.
5254 @cindex Enumeration representation clauses
5255 @cindex Representation clauses, enumeration
5256 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5259 The recommended level of support for enumeration representation clauses
5262 An implementation need not support enumeration representation clauses
5263 for boolean types, but should at minimum support the internal codes in
5264 the range @code{System.Min_Int.System.Max_Int}.
5268 @cindex Record representation clauses
5269 @cindex Representation clauses, records
5270 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5273 The recommended level of support for
5274 @*@code{record_representation_clauses} is:
5276 An implementation should support storage places that can be extracted
5277 with a load, mask, shift sequence of machine code, and set with a load,
5278 shift, mask, store sequence, given the available machine instructions
5285 A storage place should be supported if its size is equal to the
5286 @code{Size} of the component subtype, and it starts and ends on a
5287 boundary that obeys the @code{Alignment} of the component subtype.
5293 If the default bit ordering applies to the declaration of a given type,
5294 then for a component whose subtype's @code{Size} is less than the word
5295 size, any storage place that does not cross an aligned word boundary
5296 should be supported.
5302 An implementation may reserve a storage place for the tag field of a
5303 tagged type, and disallow other components from overlapping that place.
5305 Followed. The storage place for the tag field is the beginning of the tagged
5306 record, and its size is Address'Size. GNAT will reject an explicit component
5307 clause for the tag field.
5311 An implementation need not support a @code{component_clause} for a
5312 component of an extension part if the storage place is not after the
5313 storage places of all components of the parent type, whether or not
5314 those storage places had been specified.
5316 Followed. The above advice on record representation clauses is followed,
5317 and all mentioned features are implemented.
5319 @cindex Storage place attributes
5320 @unnumberedsec 13.5.2(5): Storage Place Attributes
5323 If a component is represented using some form of pointer (such as an
5324 offset) to the actual data of the component, and this data is contiguous
5325 with the rest of the object, then the storage place attributes should
5326 reflect the place of the actual data, not the pointer. If a component is
5327 allocated discontinuously from the rest of the object, then a warning
5328 should be generated upon reference to one of its storage place
5331 Followed. There are no such components in GNAT@.
5333 @cindex Bit ordering
5334 @unnumberedsec 13.5.3(7-8): Bit Ordering
5337 The recommended level of support for the non-default bit ordering is:
5341 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5342 should support the non-default bit ordering in addition to the default
5345 Followed. Word size does not equal storage size in this implementation.
5346 Thus non-default bit ordering is not supported.
5348 @cindex @code{Address}, as private type
5349 @unnumberedsec 13.7(37): Address as Private
5352 @code{Address} should be of a private type.
5356 @cindex Operations, on @code{Address}
5357 @cindex @code{Address}, operations of
5358 @unnumberedsec 13.7.1(16): Address Operations
5361 Operations in @code{System} and its children should reflect the target
5362 environment semantics as closely as is reasonable. For example, on most
5363 machines, it makes sense for address arithmetic to ``wrap around''.
5364 Operations that do not make sense should raise @code{Program_Error}.
5366 Followed. Address arithmetic is modular arithmetic that wraps around. No
5367 operation raises @code{Program_Error}, since all operations make sense.
5369 @cindex Unchecked conversion
5370 @unnumberedsec 13.9(14-17): Unchecked Conversion
5373 The @code{Size} of an array object should not include its bounds; hence,
5374 the bounds should not be part of the converted data.
5380 The implementation should not generate unnecessary run-time checks to
5381 ensure that the representation of @var{S} is a representation of the
5382 target type. It should take advantage of the permission to return by
5383 reference when possible. Restrictions on unchecked conversions should be
5384 avoided unless required by the target environment.
5386 Followed. There are no restrictions on unchecked conversion. A warning is
5387 generated if the source and target types do not have the same size since
5388 the semantics in this case may be target dependent.
5392 The recommended level of support for unchecked conversions is:
5396 Unchecked conversions should be supported and should be reversible in
5397 the cases where this clause defines the result. To enable meaningful use
5398 of unchecked conversion, a contiguous representation should be used for
5399 elementary subtypes, for statically constrained array subtypes whose
5400 component subtype is one of the subtypes described in this paragraph,
5401 and for record subtypes without discriminants whose component subtypes
5402 are described in this paragraph.
5406 @cindex Heap usage, implicit
5407 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5410 An implementation should document any cases in which it dynamically
5411 allocates heap storage for a purpose other than the evaluation of an
5414 Followed, the only other points at which heap storage is dynamically
5415 allocated are as follows:
5419 At initial elaboration time, to allocate dynamically sized global
5423 To allocate space for a task when a task is created.
5426 To extend the secondary stack dynamically when needed. The secondary
5427 stack is used for returning variable length results.
5432 A default (implementation-provided) storage pool for an
5433 access-to-constant type should not have overhead to support deallocation of
5440 A storage pool for an anonymous access type should be created at the
5441 point of an allocator for the type, and be reclaimed when the designated
5442 object becomes inaccessible.
5446 @cindex Unchecked deallocation
5447 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5450 For a standard storage pool, @code{Free} should actually reclaim the
5455 @cindex Stream oriented attributes
5456 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5459 If a stream element is the same size as a storage element, then the
5460 normal in-memory representation should be used by @code{Read} and
5461 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
5462 should use the smallest number of stream elements needed to represent
5463 all values in the base range of the scalar type.
5466 Followed. By default, GNAT uses the interpretation suggested by AI-195,
5467 which specifies using the size of the first subtype.
5468 However, such an implementation is based on direct binary
5469 representations and is therefore target- and endianness-dependent.
5470 To address this issue, GNAT also supplies an alternate implementation
5471 of the stream attributes @code{Read} and @code{Write},
5472 which uses the target-independent XDR standard representation
5474 @cindex XDR representation
5475 @cindex @code{Read} attribute
5476 @cindex @code{Write} attribute
5477 @cindex Stream oriented attributes
5478 The XDR implementation is provided as an alternative body of the
5479 @code{System.Stream_Attributes} package, in the file
5480 @file{s-strxdr.adb} in the GNAT library.
5481 There is no @file{s-strxdr.ads} file.
5482 In order to install the XDR implementation, do the following:
5484 @item Replace the default implementation of the
5485 @code{System.Stream_Attributes} package with the XDR implementation.
5486 For example on a Unix platform issue the commands:
5488 $ mv s-stratt.adb s-strold.adb
5489 $ mv s-strxdr.adb s-stratt.adb
5493 Rebuild the GNAT run-time library as documented in the
5494 @cite{GNAT User's Guide}
5497 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5500 If an implementation provides additional named predefined integer types,
5501 then the names should end with @samp{Integer} as in
5502 @samp{Long_Integer}. If an implementation provides additional named
5503 predefined floating point types, then the names should end with
5504 @samp{Float} as in @samp{Long_Float}.
5508 @findex Ada.Characters.Handling
5509 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
5512 If an implementation provides a localized definition of @code{Character}
5513 or @code{Wide_Character}, then the effects of the subprograms in
5514 @code{Characters.Handling} should reflect the localizations. See also
5517 Followed. GNAT provides no such localized definitions.
5519 @cindex Bounded-length strings
5520 @unnumberedsec A.4.4(106): Bounded-Length String Handling
5523 Bounded string objects should not be implemented by implicit pointers
5524 and dynamic allocation.
5526 Followed. No implicit pointers or dynamic allocation are used.
5528 @cindex Random number generation
5529 @unnumberedsec A.5.2(46-47): Random Number Generation
5532 Any storage associated with an object of type @code{Generator} should be
5533 reclaimed on exit from the scope of the object.
5539 If the generator period is sufficiently long in relation to the number
5540 of distinct initiator values, then each possible value of
5541 @code{Initiator} passed to @code{Reset} should initiate a sequence of
5542 random numbers that does not, in a practical sense, overlap the sequence
5543 initiated by any other value. If this is not possible, then the mapping
5544 between initiator values and generator states should be a rapidly
5545 varying function of the initiator value.
5547 Followed. The generator period is sufficiently long for the first
5548 condition here to hold true.
5550 @findex Get_Immediate
5551 @unnumberedsec A.10.7(23): @code{Get_Immediate}
5554 The @code{Get_Immediate} procedures should be implemented with
5555 unbuffered input. For a device such as a keyboard, input should be
5556 @dfn{available} if a key has already been typed, whereas for a disk
5557 file, input should always be available except at end of file. For a file
5558 associated with a keyboard-like device, any line-editing features of the
5559 underlying operating system should be disabled during the execution of
5560 @code{Get_Immediate}.
5562 Followed on all targets except VxWorks. For VxWorks, there is no way to
5563 provide this functionality that does not result in the input buffer being
5564 flushed before the @code{Get_Immediate} call. A special unit
5565 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
5569 @unnumberedsec B.1(39-41): Pragma @code{Export}
5572 If an implementation supports pragma @code{Export} to a given language,
5573 then it should also allow the main subprogram to be written in that
5574 language. It should support some mechanism for invoking the elaboration
5575 of the Ada library units included in the system, and for invoking the
5576 finalization of the environment task. On typical systems, the
5577 recommended mechanism is to provide two subprograms whose link names are
5578 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
5579 elaboration code for library units. @code{adafinal} should contain the
5580 finalization code. These subprograms should have no effect the second
5581 and subsequent time they are called.
5587 Automatic elaboration of pre-elaborated packages should be
5588 provided when pragma @code{Export} is supported.
5590 Followed when the main program is in Ada. If the main program is in a
5591 foreign language, then
5592 @code{adainit} must be called to elaborate pre-elaborated
5597 For each supported convention @var{L} other than @code{Intrinsic}, an
5598 implementation should support @code{Import} and @code{Export} pragmas
5599 for objects of @var{L}-compatible types and for subprograms, and pragma
5600 @code{Convention} for @var{L}-eligible types and for subprograms,
5601 presuming the other language has corresponding features. Pragma
5602 @code{Convention} need not be supported for scalar types.
5606 @cindex Package @code{Interfaces}
5608 @unnumberedsec B.2(12-13): Package @code{Interfaces}
5611 For each implementation-defined convention identifier, there should be a
5612 child package of package Interfaces with the corresponding name. This
5613 package should contain any declarations that would be useful for
5614 interfacing to the language (implementation) represented by the
5615 convention. Any declarations useful for interfacing to any language on
5616 the given hardware architecture should be provided directly in
5619 Followed. An additional package not defined
5620 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
5621 for interfacing to C++.
5625 An implementation supporting an interface to C, COBOL, or Fortran should
5626 provide the corresponding package or packages described in the following
5629 Followed. GNAT provides all the packages described in this section.
5631 @cindex C, interfacing with
5632 @unnumberedsec B.3(63-71): Interfacing with C
5635 An implementation should support the following interface correspondences
5642 An Ada procedure corresponds to a void-returning C function.
5648 An Ada function corresponds to a non-void C function.
5654 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
5661 An Ada @code{in} parameter of an access-to-object type with designated
5662 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
5663 where @var{t} is the C type corresponding to the Ada type @var{T}.
5669 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
5670 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
5671 argument to a C function, where @var{t} is the C type corresponding to
5672 the Ada type @var{T}. In the case of an elementary @code{out} or
5673 @code{in out} parameter, a pointer to a temporary copy is used to
5674 preserve by-copy semantics.
5680 An Ada parameter of a record type @var{T}, of any mode, is passed as a
5681 @code{@var{t}*} argument to a C function, where @var{t} is the C
5682 structure corresponding to the Ada type @var{T}.
5684 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
5685 pragma, or Convention, or by explicitly specifying the mechanism for a given
5686 call using an extended import or export pragma.
5690 An Ada parameter of an array type with component type @var{T}, of any
5691 mode, is passed as a @code{@var{t}*} argument to a C function, where
5692 @var{t} is the C type corresponding to the Ada type @var{T}.
5698 An Ada parameter of an access-to-subprogram type is passed as a pointer
5699 to a C function whose prototype corresponds to the designated
5700 subprogram's specification.
5704 @cindex COBOL, interfacing with
5705 @unnumberedsec B.4(95-98): Interfacing with COBOL
5708 An Ada implementation should support the following interface
5709 correspondences between Ada and COBOL@.
5715 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
5716 the COBOL type corresponding to @var{T}.
5722 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
5723 the corresponding COBOL type.
5729 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
5730 COBOL type corresponding to the Ada parameter type; for scalars, a local
5731 copy is used if necessary to ensure by-copy semantics.
5735 @cindex Fortran, interfacing with
5736 @unnumberedsec B.5(22-26): Interfacing with Fortran
5739 An Ada implementation should support the following interface
5740 correspondences between Ada and Fortran:
5746 An Ada procedure corresponds to a Fortran subroutine.
5752 An Ada function corresponds to a Fortran function.
5758 An Ada parameter of an elementary, array, or record type @var{T} is
5759 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
5760 the Fortran type corresponding to the Ada type @var{T}, and where the
5761 INTENT attribute of the corresponding dummy argument matches the Ada
5762 formal parameter mode; the Fortran implementation's parameter passing
5763 conventions are used. For elementary types, a local copy is used if
5764 necessary to ensure by-copy semantics.
5770 An Ada parameter of an access-to-subprogram type is passed as a
5771 reference to a Fortran procedure whose interface corresponds to the
5772 designated subprogram's specification.
5776 @cindex Machine operations
5777 @unnumberedsec C.1(3-5): Access to Machine Operations
5780 The machine code or intrinsic support should allow access to all
5781 operations normally available to assembly language programmers for the
5782 target environment, including privileged instructions, if any.
5788 The interfacing pragmas (see Annex B) should support interface to
5789 assembler; the default assembler should be associated with the
5790 convention identifier @code{Assembler}.
5796 If an entity is exported to assembly language, then the implementation
5797 should allocate it at an addressable location, and should ensure that it
5798 is retained by the linking process, even if not otherwise referenced
5799 from the Ada code. The implementation should assume that any call to a
5800 machine code or assembler subprogram is allowed to read or update every
5801 object that is specified as exported.
5805 @unnumberedsec C.1(10-16): Access to Machine Operations
5808 The implementation should ensure that little or no overhead is
5809 associated with calling intrinsic and machine-code subprograms.
5811 Followed for both intrinsics and machine-code subprograms.
5815 It is recommended that intrinsic subprograms be provided for convenient
5816 access to any machine operations that provide special capabilities or
5817 efficiency and that are not otherwise available through the language
5820 Followed. A full set of machine operation intrinsic subprograms is provided.
5824 Atomic read-modify-write operations---e.g.@:, test and set, compare and
5825 swap, decrement and test, enqueue/dequeue.
5827 Followed on any target supporting such operations.
5831 Standard numeric functions---e.g.@:, sin, log.
5833 Followed on any target supporting such operations.
5837 String manipulation operations---e.g.@:, translate and test.
5839 Followed on any target supporting such operations.
5843 Vector operations---e.g.@:, compare vector against thresholds.
5845 Followed on any target supporting such operations.
5849 Direct operations on I/O ports.
5851 Followed on any target supporting such operations.
5853 @cindex Interrupt support
5854 @unnumberedsec C.3(28): Interrupt Support
5857 If the @code{Ceiling_Locking} policy is not in effect, the
5858 implementation should provide means for the application to specify which
5859 interrupts are to be blocked during protected actions, if the underlying
5860 system allows for a finer-grain control of interrupt blocking.
5862 Followed. The underlying system does not allow for finer-grain control
5863 of interrupt blocking.
5865 @cindex Protected procedure handlers
5866 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
5869 Whenever possible, the implementation should allow interrupt handlers to
5870 be called directly by the hardware.
5874 This is never possible under IRIX, so this is followed by default.
5876 Followed on any target where the underlying operating system permits
5881 Whenever practical, violations of any
5882 implementation-defined restrictions should be detected before run time.
5884 Followed. Compile time warnings are given when possible.
5886 @cindex Package @code{Interrupts}
5888 @unnumberedsec C.3.2(25): Package @code{Interrupts}
5892 If implementation-defined forms of interrupt handler procedures are
5893 supported, such as protected procedures with parameters, then for each
5894 such form of a handler, a type analogous to @code{Parameterless_Handler}
5895 should be specified in a child package of @code{Interrupts}, with the
5896 same operations as in the predefined package Interrupts.
5900 @cindex Pre-elaboration requirements
5901 @unnumberedsec C.4(14): Pre-elaboration Requirements
5904 It is recommended that pre-elaborated packages be implemented in such a
5905 way that there should be little or no code executed at run time for the
5906 elaboration of entities not already covered by the Implementation
5909 Followed. Executable code is generated in some cases, e.g.@: loops
5910 to initialize large arrays.
5912 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
5916 If the pragma applies to an entity, then the implementation should
5917 reduce the amount of storage used for storing names associated with that
5922 @cindex Package @code{Task_Attributes}
5923 @findex Task_Attributes
5924 @unnumberedsec C.7.2(30): The Package Task_Attributes
5927 Some implementations are targeted to domains in which memory use at run
5928 time must be completely deterministic. For such implementations, it is
5929 recommended that the storage for task attributes will be pre-allocated
5930 statically and not from the heap. This can be accomplished by either
5931 placing restrictions on the number and the size of the task's
5932 attributes, or by using the pre-allocated storage for the first @var{N}
5933 attribute objects, and the heap for the others. In the latter case,
5934 @var{N} should be documented.
5936 Not followed. This implementation is not targeted to such a domain.
5938 @cindex Locking Policies
5939 @unnumberedsec D.3(17): Locking Policies
5943 The implementation should use names that end with @samp{_Locking} for
5944 locking policies defined by the implementation.
5946 Followed. A single implementation-defined locking policy is defined,
5947 whose name (@code{Inheritance_Locking}) follows this suggestion.
5949 @cindex Entry queuing policies
5950 @unnumberedsec D.4(16): Entry Queuing Policies
5953 Names that end with @samp{_Queuing} should be used
5954 for all implementation-defined queuing policies.
5956 Followed. No such implementation-defined queuing policies exist.
5958 @cindex Preemptive abort
5959 @unnumberedsec D.6(9-10): Preemptive Abort
5962 Even though the @code{abort_statement} is included in the list of
5963 potentially blocking operations (see 9.5.1), it is recommended that this
5964 statement be implemented in a way that never requires the task executing
5965 the @code{abort_statement} to block.
5971 On a multi-processor, the delay associated with aborting a task on
5972 another processor should be bounded; the implementation should use
5973 periodic polling, if necessary, to achieve this.
5977 @cindex Tasking restrictions
5978 @unnumberedsec D.7(21): Tasking Restrictions
5981 When feasible, the implementation should take advantage of the specified
5982 restrictions to produce a more efficient implementation.
5984 GNAT currently takes advantage of these restrictions by providing an optimized
5985 run time when the Ravenscar profile and the GNAT restricted run time set
5986 of restrictions are specified. See pragma @code{Ravenscar} and pragma
5987 @code{Restricted_Run_Time} for more details.
5989 @cindex Time, monotonic
5990 @unnumberedsec D.8(47-49): Monotonic Time
5993 When appropriate, implementations should provide configuration
5994 mechanisms to change the value of @code{Tick}.
5996 Such configuration mechanisms are not appropriate to this implementation
5997 and are thus not supported.
6001 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6002 be implemented as transformations of the same time base.
6008 It is recommended that the @dfn{best} time base which exists in
6009 the underlying system be available to the application through
6010 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
6014 @cindex Partition communication subsystem
6016 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6019 Whenever possible, the PCS on the called partition should allow for
6020 multiple tasks to call the RPC-receiver with different messages and
6021 should allow them to block until the corresponding subprogram body
6024 Followed by GLADE, a separately supplied PCS that can be used with
6029 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6030 should raise @code{Storage_Error} if it runs out of space trying to
6031 write the @code{Item} into the stream.
6033 Followed by GLADE, a separately supplied PCS that can be used with
6036 @cindex COBOL support
6037 @unnumberedsec F(7): COBOL Support
6040 If COBOL (respectively, C) is widely supported in the target
6041 environment, implementations supporting the Information Systems Annex
6042 should provide the child package @code{Interfaces.COBOL} (respectively,
6043 @code{Interfaces.C}) specified in Annex B and should support a
6044 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6045 pragmas (see Annex B), thus allowing Ada programs to interface with
6046 programs written in that language.
6050 @cindex Decimal radix support
6051 @unnumberedsec F.1(2): Decimal Radix Support
6054 Packed decimal should be used as the internal representation for objects
6055 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6057 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
6061 @unnumberedsec G: Numerics
6064 If Fortran (respectively, C) is widely supported in the target
6065 environment, implementations supporting the Numerics Annex
6066 should provide the child package @code{Interfaces.Fortran} (respectively,
6067 @code{Interfaces.C}) specified in Annex B and should support a
6068 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6069 pragmas (see Annex B), thus allowing Ada programs to interface with
6070 programs written in that language.
6074 @cindex Complex types
6075 @unnumberedsec G.1.1(56-58): Complex Types
6078 Because the usual mathematical meaning of multiplication of a complex
6079 operand and a real operand is that of the scaling of both components of
6080 the former by the latter, an implementation should not perform this
6081 operation by first promoting the real operand to complex type and then
6082 performing a full complex multiplication. In systems that, in the
6083 future, support an Ada binding to IEC 559:1989, the latter technique
6084 will not generate the required result when one of the components of the
6085 complex operand is infinite. (Explicit multiplication of the infinite
6086 component by the zero component obtained during promotion yields a NaN
6087 that propagates into the final result.) Analogous advice applies in the
6088 case of multiplication of a complex operand and a pure-imaginary
6089 operand, and in the case of division of a complex operand by a real or
6090 pure-imaginary operand.
6096 Similarly, because the usual mathematical meaning of addition of a
6097 complex operand and a real operand is that the imaginary operand remains
6098 unchanged, an implementation should not perform this operation by first
6099 promoting the real operand to complex type and then performing a full
6100 complex addition. In implementations in which the @code{Signed_Zeros}
6101 attribute of the component type is @code{True} (and which therefore
6102 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6103 predefined arithmetic operations), the latter technique will not
6104 generate the required result when the imaginary component of the complex
6105 operand is a negatively signed zero. (Explicit addition of the negative
6106 zero to the zero obtained during promotion yields a positive zero.)
6107 Analogous advice applies in the case of addition of a complex operand
6108 and a pure-imaginary operand, and in the case of subtraction of a
6109 complex operand and a real or pure-imaginary operand.
6115 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6116 attempt to provide a rational treatment of the signs of zero results and
6117 result components. As one example, the result of the @code{Argument}
6118 function should have the sign of the imaginary component of the
6119 parameter @code{X} when the point represented by that parameter lies on
6120 the positive real axis; as another, the sign of the imaginary component
6121 of the @code{Compose_From_Polar} function should be the same as
6122 (respectively, the opposite of) that of the @code{Argument} parameter when that
6123 parameter has a value of zero and the @code{Modulus} parameter has a
6124 nonnegative (respectively, negative) value.
6128 @cindex Complex elementary functions
6129 @unnumberedsec G.1.2(49): Complex Elementary Functions
6132 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6133 @code{True} should attempt to provide a rational treatment of the signs
6134 of zero results and result components. For example, many of the complex
6135 elementary functions have components that are odd functions of one of
6136 the parameter components; in these cases, the result component should
6137 have the sign of the parameter component at the origin. Other complex
6138 elementary functions have zero components whose sign is opposite that of
6139 a parameter component at the origin, or is always positive or always
6144 @cindex Accuracy requirements
6145 @unnumberedsec G.2.4(19): Accuracy Requirements
6148 The versions of the forward trigonometric functions without a
6149 @code{Cycle} parameter should not be implemented by calling the
6150 corresponding version with a @code{Cycle} parameter of
6151 @code{2.0*Numerics.Pi}, since this will not provide the required
6152 accuracy in some portions of the domain. For the same reason, the
6153 version of @code{Log} without a @code{Base} parameter should not be
6154 implemented by calling the corresponding version with a @code{Base}
6155 parameter of @code{Numerics.e}.
6159 @cindex Complex arithmetic accuracy
6160 @cindex Accuracy, complex arithmetic
6161 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6165 The version of the @code{Compose_From_Polar} function without a
6166 @code{Cycle} parameter should not be implemented by calling the
6167 corresponding version with a @code{Cycle} parameter of
6168 @code{2.0*Numerics.Pi}, since this will not provide the required
6169 accuracy in some portions of the domain.
6173 @c -----------------------------------------
6174 @node Implementation Defined Characteristics
6175 @chapter Implementation Defined Characteristics
6178 In addition to the implementation dependent pragmas and attributes, and
6179 the implementation advice, there are a number of other features of Ada
6180 95 that are potentially implementation dependent. These are mentioned
6181 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6183 A requirement for conforming Ada compilers is that they provide
6184 documentation describing how the implementation deals with each of these
6185 issues. In this chapter, you will find each point in annex M listed
6186 followed by a description in italic font of how GNAT
6190 implementation on IRIX 5.3 operating system or greater
6192 handles the implementation dependence.
6194 You can use this chapter as a guide to minimizing implementation
6195 dependent features in your programs if portability to other compilers
6196 and other operating systems is an important consideration. The numbers
6197 in each section below correspond to the paragraph number in the Ada 95
6203 @strong{2}. Whether or not each recommendation given in Implementation
6204 Advice is followed. See 1.1.2(37).
6207 @xref{Implementation Advice}.
6212 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
6215 The complexity of programs that can be processed is limited only by the
6216 total amount of available virtual memory, and disk space for the
6217 generated object files.
6222 @strong{4}. Variations from the standard that are impractical to avoid
6223 given the implementation's execution environment. See 1.1.3(6).
6226 There are no variations from the standard.
6231 @strong{5}. Which @code{code_statement}s cause external
6232 interactions. See 1.1.3(10).
6235 Any @code{code_statement} can potentially cause external interactions.
6240 @strong{6}. The coded representation for the text of an Ada
6241 program. See 2.1(4).
6244 See separate section on source representation.
6249 @strong{7}. The control functions allowed in comments. See 2.1(14).
6252 See separate section on source representation.
6257 @strong{8}. The representation for an end of line. See 2.2(2).
6260 See separate section on source representation.
6265 @strong{9}. Maximum supported line length and lexical element
6266 length. See 2.2(15).
6269 The maximum line length is 255 characters an the maximum length of a
6270 lexical element is also 255 characters.
6275 @strong{10}. Implementation defined pragmas. See 2.8(14).
6279 @xref{Implementation Defined Pragmas}.
6284 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
6287 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6288 parameter, checks that the optimization flag is set, and aborts if it is
6294 @strong{12}. The sequence of characters of the value returned by
6295 @code{@var{S}'Image} when some of the graphic characters of
6296 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
6300 The sequence of characters is as defined by the wide character encoding
6301 method used for the source. See section on source representation for
6307 @strong{13}. The predefined integer types declared in
6308 @code{Standard}. See 3.5.4(25).
6312 @item Short_Short_Integer
6315 (Short) 16 bit signed
6319 64 bit signed (Alpha OpenVMS only)
6320 32 bit signed (all other targets)
6321 @item Long_Long_Integer
6328 @strong{14}. Any nonstandard integer types and the operators defined
6329 for them. See 3.5.4(26).
6332 There are no nonstandard integer types.
6337 @strong{15}. Any nonstandard real types and the operators defined for
6341 There are no nonstandard real types.
6346 @strong{16}. What combinations of requested decimal precision and range
6347 are supported for floating point types. See 3.5.7(7).
6350 The precision and range is as defined by the IEEE standard.
6355 @strong{17}. The predefined floating point types declared in
6356 @code{Standard}. See 3.5.7(16).
6363 (Short) 32 bit IEEE short
6366 @item Long_Long_Float
6367 64 bit IEEE long (80 bit IEEE long on x86 processors)
6373 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
6376 @code{Fine_Delta} is 2**(@minus{}63)
6381 @strong{19}. What combinations of small, range, and digits are
6382 supported for fixed point types. See 3.5.9(10).
6385 Any combinations are permitted that do not result in a small less than
6386 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6387 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6388 is 64 bits (true of all architectures except ia32), then the output from
6389 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
6390 is because floating-point conversions are used to convert fixed point.
6395 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
6396 within an unnamed @code{block_statement}. See 3.9(10).
6399 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6400 decimal integer are allocated.
6405 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
6408 @xref{Implementation Defined Attributes}.
6413 @strong{22}. Any implementation-defined time types. See 9.6(6).
6416 There are no implementation-defined time types.
6421 @strong{23}. The time base associated with relative delays.
6424 See 9.6(20). The time base used is that provided by the C library
6425 function @code{gettimeofday}.
6430 @strong{24}. The time base of the type @code{Calendar.Time}. See
6434 The time base used is that provided by the C library function
6435 @code{gettimeofday}.
6440 @strong{25}. The time zone used for package @code{Calendar}
6441 operations. See 9.6(24).
6444 The time zone used by package @code{Calendar} is the current system time zone
6445 setting for local time, as accessed by the C library function
6451 @strong{26}. Any limit on @code{delay_until_statements} of
6452 @code{select_statements}. See 9.6(29).
6455 There are no such limits.
6460 @strong{27}. Whether or not two non overlapping parts of a composite
6461 object are independently addressable, in the case where packing, record
6462 layout, or @code{Component_Size} is specified for the object. See
6466 Separate components are independently addressable if they do not share
6467 overlapping storage units.
6472 @strong{28}. The representation for a compilation. See 10.1(2).
6475 A compilation is represented by a sequence of files presented to the
6476 compiler in a single invocation of the @code{gcc} command.
6481 @strong{29}. Any restrictions on compilations that contain multiple
6482 compilation_units. See 10.1(4).
6485 No single file can contain more than one compilation unit, but any
6486 sequence of files can be presented to the compiler as a single
6492 @strong{30}. The mechanisms for creating an environment and for adding
6493 and replacing compilation units. See 10.1.4(3).
6496 See separate section on compilation model.
6501 @strong{31}. The manner of explicitly assigning library units to a
6502 partition. See 10.2(2).
6505 If a unit contains an Ada main program, then the Ada units for the partition
6506 are determined by recursive application of the rules in the Ada Reference
6507 Manual section 10.2(2-6). In other words, the Ada units will be those that
6508 are needed by the main program, and then this definition of need is applied
6509 recursively to those units, and the partition contains the transitive
6510 closure determined by this relationship. In short, all the necessary units
6511 are included, with no need to explicitly specify the list. If additional
6512 units are required, e.g.@: by foreign language units, then all units must be
6513 mentioned in the context clause of one of the needed Ada units.
6515 If the partition contains no main program, or if the main program is in
6516 a language other than Ada, then GNAT
6517 provides the binder options @code{-z} and @code{-n} respectively, and in
6518 this case a list of units can be explicitly supplied to the binder for
6519 inclusion in the partition (all units needed by these units will also
6520 be included automatically). For full details on the use of these
6521 options, refer to the @cite{GNAT User's Guide} sections on Binding
6527 @strong{32}. The implementation-defined means, if any, of specifying
6528 which compilation units are needed by a given compilation unit. See
6532 The units needed by a given compilation unit are as defined in
6533 the Ada Reference Manual section 10.2(2-6). There are no
6534 implementation-defined pragmas or other implementation-defined
6535 means for specifying needed units.
6540 @strong{33}. The manner of designating the main subprogram of a
6541 partition. See 10.2(7).
6544 The main program is designated by providing the name of the
6545 corresponding @file{ALI} file as the input parameter to the binder.
6550 @strong{34}. The order of elaboration of @code{library_items}. See
6554 The first constraint on ordering is that it meets the requirements of
6555 chapter 10 of the Ada 95 Reference Manual. This still leaves some
6556 implementation dependent choices, which are resolved by first
6557 elaborating bodies as early as possible (i.e.@: in preference to specs
6558 where there is a choice), and second by evaluating the immediate with
6559 clauses of a unit to determine the probably best choice, and
6560 third by elaborating in alphabetical order of unit names
6561 where a choice still remains.
6566 @strong{35}. Parameter passing and function return for the main
6567 subprogram. See 10.2(21).
6570 The main program has no parameters. It may be a procedure, or a function
6571 returning an integer type. In the latter case, the returned integer
6572 value is the return code of the program (overriding any value that
6573 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
6578 @strong{36}. The mechanisms for building and running partitions. See
6582 GNAT itself supports programs with only a single partition. The GNATDIST
6583 tool provided with the GLADE package (which also includes an implementation
6584 of the PCS) provides a completely flexible method for building and running
6585 programs consisting of multiple partitions. See the separate GLADE manual
6591 @strong{37}. The details of program execution, including program
6592 termination. See 10.2(25).
6595 See separate section on compilation model.
6600 @strong{38}. The semantics of any non-active partitions supported by the
6601 implementation. See 10.2(28).
6604 Passive partitions are supported on targets where shared memory is
6605 provided by the operating system. See the GLADE reference manual for
6611 @strong{39}. The information returned by @code{Exception_Message}. See
6615 Exception message returns the null string unless a specific message has
6616 been passed by the program.
6621 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
6622 declared within an unnamed @code{block_statement}. See 11.4.1(12).
6625 Blocks have implementation defined names of the form @code{B@var{nnn}}
6626 where @var{nnn} is an integer.
6631 @strong{41}. The information returned by
6632 @code{Exception_Information}. See 11.4.1(13).
6635 @code{Exception_Information} returns a string in the following format:
6638 @emph{Exception_Name:} nnnnn
6639 @emph{Message:} mmmmm
6641 @emph{Call stack traceback locations:}
6642 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
6650 @code{nnnn} is the fully qualified name of the exception in all upper
6651 case letters. This line is always present.
6654 @code{mmmm} is the message (this line present only if message is non-null)
6657 @code{ppp} is the Process Id value as a decimal integer (this line is
6658 present only if the Process Id is non-zero). Currently we are
6659 not making use of this field.
6662 The Call stack traceback locations line and the following values
6663 are present only if at least one traceback location was recorded.
6664 The values are given in C style format, with lower case letters
6665 for a-f, and only as many digits present as are necessary.
6669 The line terminator sequence at the end of each line, including
6670 the last line is a single @code{LF} character (@code{16#0A#}).
6675 @strong{42}. Implementation-defined check names. See 11.5(27).
6678 No implementation-defined check names are supported.
6683 @strong{43}. The interpretation of each aspect of representation. See
6687 See separate section on data representations.
6692 @strong{44}. Any restrictions placed upon representation items. See
6696 See separate section on data representations.
6701 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
6705 Size for an indefinite subtype is the maximum possible size, except that
6706 for the case of a subprogram parameter, the size of the parameter object
6712 @strong{46}. The default external representation for a type tag. See
6716 The default external representation for a type tag is the fully expanded
6717 name of the type in upper case letters.
6722 @strong{47}. What determines whether a compilation unit is the same in
6723 two different partitions. See 13.3(76).
6726 A compilation unit is the same in two different partitions if and only
6727 if it derives from the same source file.
6732 @strong{48}. Implementation-defined components. See 13.5.1(15).
6735 The only implementation defined component is the tag for a tagged type,
6736 which contains a pointer to the dispatching table.
6741 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
6742 ordering. See 13.5.3(5).
6745 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
6746 implementation, so no non-default bit ordering is supported. The default
6747 bit ordering corresponds to the natural endianness of the target architecture.
6752 @strong{50}. The contents of the visible part of package @code{System}
6753 and its language-defined children. See 13.7(2).
6756 See the definition of these packages in files @file{system.ads} and
6757 @file{s-stoele.ads}.
6762 @strong{51}. The contents of the visible part of package
6763 @code{System.Machine_Code}, and the meaning of
6764 @code{code_statements}. See 13.8(7).
6767 See the definition and documentation in file @file{s-maccod.ads}.
6772 @strong{52}. The effect of unchecked conversion. See 13.9(11).
6775 Unchecked conversion between types of the same size
6776 and results in an uninterpreted transmission of the bits from one type
6777 to the other. If the types are of unequal sizes, then in the case of
6778 discrete types, a shorter source is first zero or sign extended as
6779 necessary, and a shorter target is simply truncated on the left.
6780 For all non-discrete types, the source is first copied if necessary
6781 to ensure that the alignment requirements of the target are met, then
6782 a pointer is constructed to the source value, and the result is obtained
6783 by dereferencing this pointer after converting it to be a pointer to the
6789 @strong{53}. The manner of choosing a storage pool for an access type
6790 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
6793 There are 3 different standard pools used by the compiler when
6794 @code{Storage_Pool} is not specified depending whether the type is local
6795 to a subprogram or defined at the library level and whether
6796 @code{Storage_Size}is specified or not. See documentation in the runtime
6797 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
6798 @code{System.Pool_Local} in files @file{s-poosiz.ads},
6799 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
6805 @strong{54}. Whether or not the implementation provides user-accessible
6806 names for the standard pool type(s). See 13.11(17).
6810 See documentation in the sources of the run time mentioned in paragraph
6811 @strong{53} . All these pools are accessible by means of @code{with}'ing
6817 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
6820 @code{Storage_Size} is measured in storage units, and refers to the
6821 total space available for an access type collection, or to the primary
6822 stack space for a task.
6827 @strong{56}. Implementation-defined aspects of storage pools. See
6831 See documentation in the sources of the run time mentioned in paragraph
6832 @strong{53} for details on GNAT-defined aspects of storage pools.
6837 @strong{57}. The set of restrictions allowed in a pragma
6838 @code{Restrictions}. See 13.12(7).
6841 All RM defined Restriction identifiers are implemented. The following
6842 additional restriction identifiers are provided. There are two separate
6843 lists of implementation dependent restriction identifiers. The first
6844 set requires consistency throughout a partition (in other words, if the
6845 restriction identifier is used for any compilation unit in the partition,
6846 then all compilation units in the partition must obey the restriction.
6850 @item Boolean_Entry_Barriers
6851 @findex Boolean_Entry_Barriers
6852 This restriction ensures at compile time that barriers in entry declarations
6853 for protected types are restricted to references to simple boolean variables
6854 defined in the private part of the protected type. No other form of entry
6855 barriers is permitted. This is one of the restrictions of the Ravenscar
6856 profile for limited tasking (see also pragma @code{Ravenscar}).
6858 @item Max_Entry_Queue_Depth => Expr
6859 @findex Max_Entry_Queue_Depth
6860 This restriction is a declaration that any protected entry compiled in
6861 the scope of the restriction has at most the specified number of
6862 tasks waiting on the entry
6863 at any one time, and so no queue is required. This restriction is not
6864 checked at compile time. A program execution is erroneous if an attempt
6865 is made to queue more than the specified number of tasks on such an entry.
6869 This restriction ensures at compile time that there is no implicit or
6870 explicit dependence on the package @code{Ada.Calendar}.
6872 @item No_Direct_Boolean_Operators
6873 @findex No_Direct_Boolean_Operators
6874 This restriction ensures that no logical (and/or/xor) or comparison
6875 operators are used on operands of type Boolean (or any type derived
6876 from Boolean). This is intended for use in safety critical programs
6877 where the certification protocol requires the use of short-circuit
6878 (and then, or else) forms for all composite boolean operations.
6880 @item No_Dynamic_Interrupts
6881 @findex No_Dynamic_Interrupts
6882 This restriction ensures at compile time that there is no attempt to
6883 dynamically associate interrupts. Only static association is allowed.
6885 @item No_Enumeration_Maps
6886 @findex No_Enumeration_Maps
6887 This restriction ensures at compile time that no operations requiring
6888 enumeration maps are used (that is Image and Value attributes applied
6889 to enumeration types).
6891 @item No_Entry_Calls_In_Elaboration_Code
6892 @findex No_Entry_Calls_In_Elaboration_Code
6893 This restriction ensures at compile time that no task or protected entry
6894 calls are made during elaboration code. As a result of the use of this
6895 restriction, the compiler can assume that no code past an accept statement
6896 in a task can be executed at elaboration time.
6898 @item No_Exception_Handlers
6899 @findex No_Exception_Handlers
6900 This restriction ensures at compile time that there are no explicit
6901 exception handlers. It also indicates that no exception propagation will
6902 be provided. In this mode, exceptions may be raised but will result in
6903 an immediate call to the last chance handler, a routine that the user
6904 must define with the following profile:
6906 procedure Last_Chance_Handler
6907 (Source_Location : System.Address; Line : Integer);
6908 pragma Export (C, Last_Chance_Handler,
6909 "__gnat_last_chance_handler");
6911 The parameter is a C null-terminated string representing a message to be
6912 associated with the exception (typically the source location of the raise
6913 statement generated by the compiler). The Line parameter when non-zero
6914 represents the line number in the source program where the raise occurs.
6916 @item No_Exception_Streams
6917 @findex No_Exception_Streams
6918 This restriction ensures at compile time that no stream operations for
6919 types Exception_Id or Exception_Occurrence are used. This also makes it
6920 impossible to pass exceptions to or from a partition with this restriction
6921 in a distributed environment. If this exception is active, then the generated
6922 code is simplified by omitting the otherwise-required global registration
6923 of exceptions when they are declared.
6925 @item No_Implicit_Conditionals
6926 @findex No_Implicit_Conditionals
6927 This restriction ensures that the generated code does not contain any
6928 implicit conditionals, either by modifying the generated code where possible,
6929 or by rejecting any construct that would otherwise generate an implicit
6932 @item No_Implicit_Dynamic_Code
6933 @findex No_Implicit_Dynamic_Code
6934 This restriction prevents the compiler from building ``trampolines''.
6935 This is a structure that is built on the stack and contains dynamic
6936 code to be executed at run time. A trampoline is needed to indirectly
6937 address a nested subprogram (that is a subprogram that is not at the
6938 library level). The restriction prevents the use of any of the
6939 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
6940 being applied to a subprogram that is not at the library level.
6942 @item No_Implicit_Loops
6943 @findex No_Implicit_Loops
6944 This restriction ensures that the generated code does not contain any
6945 implicit @code{for} loops, either by modifying
6946 the generated code where possible,
6947 or by rejecting any construct that would otherwise generate an implicit
6950 @item No_Initialize_Scalars
6951 @findex No_Initialize_Scalars
6952 This restriction ensures that no unit in the partition is compiled with
6953 pragma Initialize_Scalars. This allows the generation of more efficient
6954 code, and in particular eliminates dummy null initialization routines that
6955 are otherwise generated for some record and array types.
6957 @item No_Local_Protected_Objects
6958 @findex No_Local_Protected_Objects
6959 This restriction ensures at compile time that protected objects are
6960 only declared at the library level.
6962 @item No_Protected_Type_Allocators
6963 @findex No_Protected_Type_Allocators
6964 This restriction ensures at compile time that there are no allocator
6965 expressions that attempt to allocate protected objects.
6967 @item No_Secondary_Stack
6968 @findex No_Secondary_Stack
6969 This restriction ensures at compile time that the generated code does not
6970 contain any reference to the secondary stack. The secondary stack is used
6971 to implement functions returning unconstrained objects (arrays or records)
6974 @item No_Select_Statements
6975 @findex No_Select_Statements
6976 This restriction ensures at compile time no select statements of any kind
6977 are permitted, that is the keyword @code{select} may not appear.
6978 This is one of the restrictions of the Ravenscar
6979 profile for limited tasking (see also pragma @code{Ravenscar}).
6981 @item No_Standard_Storage_Pools
6982 @findex No_Standard_Storage_Pools
6983 This restriction ensures at compile time that no access types
6984 use the standard default storage pool. Any access type declared must
6985 have an explicit Storage_Pool attribute defined specifying a
6986 user-defined storage pool.
6990 This restriction ensures at compile time that there are no implicit or
6991 explicit dependencies on the package @code{Ada.Streams}.
6993 @item No_Task_Attributes
6994 @findex No_Task_Attributes
6995 This restriction ensures at compile time that there are no implicit or
6996 explicit dependencies on the package @code{Ada.Task_Attributes}.
6998 @item No_Task_Termination
6999 @findex No_Task_Termination
7000 This restriction ensures at compile time that no terminate alternatives
7001 appear in any task body.
7005 This restriction prevents the declaration of tasks or task types throughout
7006 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
7007 except that violations are caught at compile time and cause an error message
7008 to be output either by the compiler or binder.
7010 @item No_Wide_Characters
7011 @findex No_Wide_Characters
7012 This restriction ensures at compile time that no uses of the types
7013 @code{Wide_Character} or @code{Wide_String}
7014 appear, and that no wide character literals
7015 appear in the program (that is literals representing characters not in
7016 type @code{Character}.
7018 @item Static_Priorities
7019 @findex Static_Priorities
7020 This restriction ensures at compile time that all priority expressions
7021 are static, and that there are no dependencies on the package
7022 @code{Ada.Dynamic_Priorities}.
7024 @item Static_Storage_Size
7025 @findex Static_Storage_Size
7026 This restriction ensures at compile time that any expression appearing
7027 in a Storage_Size pragma or attribute definition clause is static.
7032 The second set of implementation dependent restriction identifiers
7033 does not require partition-wide consistency.
7034 The restriction may be enforced for a single
7035 compilation unit without any effect on any of the
7036 other compilation units in the partition.
7040 @item No_Elaboration_Code
7041 @findex No_Elaboration_Code
7042 This restriction ensures at compile time that no elaboration code is
7043 generated. Note that this is not the same condition as is enforced
7044 by pragma @code{Preelaborate}. There are cases in which pragma
7045 @code{Preelaborate} still permits code to be generated (e.g.@: code
7046 to initialize a large array to all zeroes), and there are cases of units
7047 which do not meet the requirements for pragma @code{Preelaborate},
7048 but for which no elaboration code is generated. Generally, it is
7049 the case that preelaborable units will meet the restrictions, with
7050 the exception of large aggregates initialized with an others_clause,
7051 and exception declarations (which generate calls to a run-time
7052 registry procedure). Note that this restriction is enforced on
7053 a unit by unit basis, it need not be obeyed consistently
7054 throughout a partition.
7056 @item No_Entry_Queue
7057 @findex No_Entry_Queue
7058 This restriction is a declaration that any protected entry compiled in
7059 the scope of the restriction has at most one task waiting on the entry
7060 at any one time, and so no queue is required. This restriction is not
7061 checked at compile time. A program execution is erroneous if an attempt
7062 is made to queue a second task on such an entry.
7064 @item No_Implementation_Attributes
7065 @findex No_Implementation_Attributes
7066 This restriction checks at compile time that no GNAT-defined attributes
7067 are present. With this restriction, the only attributes that can be used
7068 are those defined in the Ada 95 Reference Manual.
7070 @item No_Implementation_Pragmas
7071 @findex No_Implementation_Pragmas
7072 This restriction checks at compile time that no GNAT-defined pragmas
7073 are present. With this restriction, the only pragmas that can be used
7074 are those defined in the Ada 95 Reference Manual.
7076 @item No_Implementation_Restrictions
7077 @findex No_Implementation_Restrictions
7078 This restriction checks at compile time that no GNAT-defined restriction
7079 identifiers (other than @code{No_Implementation_Restrictions} itself)
7080 are present. With this restriction, the only other restriction identifiers
7081 that can be used are those defined in the Ada 95 Reference Manual.
7088 @strong{58}. The consequences of violating limitations on
7089 @code{Restrictions} pragmas. See 13.12(9).
7092 Restrictions that can be checked at compile time result in illegalities
7093 if violated. Currently there are no other consequences of violating
7099 @strong{59}. The representation used by the @code{Read} and
7100 @code{Write} attributes of elementary types in terms of stream
7101 elements. See 13.13.2(9).
7104 The representation is the in-memory representation of the base type of
7105 the type, using the number of bits corresponding to the
7106 @code{@var{type}'Size} value, and the natural ordering of the machine.
7111 @strong{60}. The names and characteristics of the numeric subtypes
7112 declared in the visible part of package @code{Standard}. See A.1(3).
7115 See items describing the integer and floating-point types supported.
7120 @strong{61}. The accuracy actually achieved by the elementary
7121 functions. See A.5.1(1).
7124 The elementary functions correspond to the functions available in the C
7125 library. Only fast math mode is implemented.
7130 @strong{62}. The sign of a zero result from some of the operators or
7131 functions in @code{Numerics.Generic_Elementary_Functions}, when
7132 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
7135 The sign of zeroes follows the requirements of the IEEE 754 standard on
7141 @strong{63}. The value of
7142 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
7145 Maximum image width is 649, see library file @file{a-numran.ads}.
7150 @strong{64}. The value of
7151 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
7154 Maximum image width is 80, see library file @file{a-nudira.ads}.
7159 @strong{65}. The algorithms for random number generation. See
7163 The algorithm is documented in the source files @file{a-numran.ads} and
7164 @file{a-numran.adb}.
7169 @strong{66}. The string representation of a random number generator's
7170 state. See A.5.2(38).
7173 See the documentation contained in the file @file{a-numran.adb}.
7178 @strong{67}. The minimum time interval between calls to the
7179 time-dependent Reset procedure that are guaranteed to initiate different
7180 random number sequences. See A.5.2(45).
7183 The minimum period between reset calls to guarantee distinct series of
7184 random numbers is one microsecond.
7189 @strong{68}. The values of the @code{Model_Mantissa},
7190 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7191 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7192 Annex is not supported. See A.5.3(72).
7195 See the source file @file{ttypef.ads} for the values of all numeric
7201 @strong{69}. Any implementation-defined characteristics of the
7202 input-output packages. See A.7(14).
7205 There are no special implementation defined characteristics for these
7211 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
7215 All type representations are contiguous, and the @code{Buffer_Size} is
7216 the value of @code{@var{type}'Size} rounded up to the next storage unit
7222 @strong{71}. External files for standard input, standard output, and
7223 standard error See A.10(5).
7226 These files are mapped onto the files provided by the C streams
7227 libraries. See source file @file{i-cstrea.ads} for further details.
7232 @strong{72}. The accuracy of the value produced by @code{Put}. See
7236 If more digits are requested in the output than are represented by the
7237 precision of the value, zeroes are output in the corresponding least
7238 significant digit positions.
7243 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
7244 @code{Command_Name}. See A.15(1).
7247 These are mapped onto the @code{argv} and @code{argc} parameters of the
7248 main program in the natural manner.
7253 @strong{74}. Implementation-defined convention names. See B.1(11).
7256 The following convention names are supported
7264 Synonym for Assembler
7266 Synonym for Assembler
7269 @item C_Pass_By_Copy
7270 Allowed only for record types, like C, but also notes that record
7271 is to be passed by copy rather than reference.
7277 Treated the same as C
7279 Treated the same as C
7283 For support of pragma @code{Import} with convention Intrinsic, see
7284 separate section on Intrinsic Subprograms.
7286 Stdcall (used for Windows implementations only). This convention correspond
7287 to the WINAPI (previously called Pascal convention) C/C++ convention under
7288 Windows. A function with this convention cleans the stack before exit.
7294 Stubbed is a special convention used to indicate that the body of the
7295 subprogram will be entirely ignored. Any call to the subprogram
7296 is converted into a raise of the @code{Program_Error} exception. If a
7297 pragma @code{Import} specifies convention @code{stubbed} then no body need
7298 be present at all. This convention is useful during development for the
7299 inclusion of subprograms whose body has not yet been written.
7303 In addition, all otherwise unrecognized convention names are also
7304 treated as being synonymous with convention C@. In all implementations
7305 except for VMS, use of such other names results in a warning. In VMS
7306 implementations, these names are accepted silently.
7311 @strong{75}. The meaning of link names. See B.1(36).
7314 Link names are the actual names used by the linker.
7319 @strong{76}. The manner of choosing link names when neither the link
7320 name nor the address of an imported or exported entity is specified. See
7324 The default linker name is that which would be assigned by the relevant
7325 external language, interpreting the Ada name as being in all lower case
7331 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
7334 The string passed to @code{Linker_Options} is presented uninterpreted as
7335 an argument to the link command, unless it contains Ascii.NUL characters.
7336 NUL characters if they appear act as argument separators, so for example
7338 @smallexample @c ada
7339 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7343 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7344 linker. The order of linker options is preserved for a given unit. The final
7345 list of options passed to the linker is in reverse order of the elaboration
7346 order. For example, linker options fo a body always appear before the options
7347 from the corresponding package spec.
7352 @strong{78}. The contents of the visible part of package
7353 @code{Interfaces} and its language-defined descendants. See B.2(1).
7356 See files with prefix @file{i-} in the distributed library.
7361 @strong{79}. Implementation-defined children of package
7362 @code{Interfaces}. The contents of the visible part of package
7363 @code{Interfaces}. See B.2(11).
7366 See files with prefix @file{i-} in the distributed library.
7371 @strong{80}. The types @code{Floating}, @code{Long_Floating},
7372 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7373 @code{COBOL_Character}; and the initialization of the variables
7374 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7375 @code{Interfaces.COBOL}. See B.4(50).
7382 (Floating) Long_Float
7387 @item Decimal_Element
7389 @item COBOL_Character
7394 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7399 @strong{81}. Support for access to machine instructions. See C.1(1).
7402 See documentation in file @file{s-maccod.ads} in the distributed library.
7407 @strong{82}. Implementation-defined aspects of access to machine
7408 operations. See C.1(9).
7411 See documentation in file @file{s-maccod.ads} in the distributed library.
7416 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
7419 Interrupts are mapped to signals or conditions as appropriate. See
7421 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7422 on the interrupts supported on a particular target.
7427 @strong{84}. Implementation-defined aspects of pre-elaboration. See
7431 GNAT does not permit a partition to be restarted without reloading,
7432 except under control of the debugger.
7437 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
7440 Pragma @code{Discard_Names} causes names of enumeration literals to
7441 be suppressed. In the presence of this pragma, the Image attribute
7442 provides the image of the Pos of the literal, and Value accepts
7448 @strong{86}. The result of the @code{Task_Identification.Image}
7449 attribute. See C.7.1(7).
7452 The result of this attribute is an 8-digit hexadecimal string
7453 representing the virtual address of the task control block.
7458 @strong{87}. The value of @code{Current_Task} when in a protected entry
7459 or interrupt handler. See C.7.1(17).
7462 Protected entries or interrupt handlers can be executed by any
7463 convenient thread, so the value of @code{Current_Task} is undefined.
7468 @strong{88}. The effect of calling @code{Current_Task} from an entry
7469 body or interrupt handler. See C.7.1(19).
7472 The effect of calling @code{Current_Task} from an entry body or
7473 interrupt handler is to return the identification of the task currently
7479 @strong{89}. Implementation-defined aspects of
7480 @code{Task_Attributes}. See C.7.2(19).
7483 There are no implementation-defined aspects of @code{Task_Attributes}.
7488 @strong{90}. Values of all @code{Metrics}. See D(2).
7491 The metrics information for GNAT depends on the performance of the
7492 underlying operating system. The sources of the run-time for tasking
7493 implementation, together with the output from @code{-gnatG} can be
7494 used to determine the exact sequence of operating systems calls made
7495 to implement various tasking constructs. Together with appropriate
7496 information on the performance of the underlying operating system,
7497 on the exact target in use, this information can be used to determine
7498 the required metrics.
7503 @strong{91}. The declarations of @code{Any_Priority} and
7504 @code{Priority}. See D.1(11).
7507 See declarations in file @file{system.ads}.
7512 @strong{92}. Implementation-defined execution resources. See D.1(15).
7515 There are no implementation-defined execution resources.
7520 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
7521 access to a protected object keeps its processor busy. See D.2.1(3).
7524 On a multi-processor, a task that is waiting for access to a protected
7525 object does not keep its processor busy.
7530 @strong{94}. The affect of implementation defined execution resources
7531 on task dispatching. See D.2.1(9).
7536 Tasks map to IRIX threads, and the dispatching policy is as defined by
7537 the IRIX implementation of threads.
7539 Tasks map to threads in the threads package used by GNAT@. Where possible
7540 and appropriate, these threads correspond to native threads of the
7541 underlying operating system.
7546 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
7547 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
7550 There are no implementation-defined policy-identifiers allowed in this
7556 @strong{96}. Implementation-defined aspects of priority inversion. See
7560 Execution of a task cannot be preempted by the implementation processing
7561 of delay expirations for lower priority tasks.
7566 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
7571 Tasks map to IRIX threads, and the dispatching policy is as defied by
7572 the IRIX implementation of threads.
7574 The policy is the same as that of the underlying threads implementation.
7579 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
7580 in a pragma @code{Locking_Policy}. See D.3(4).
7583 The only implementation defined policy permitted in GNAT is
7584 @code{Inheritance_Locking}. On targets that support this policy, locking
7585 is implemented by inheritance, i.e.@: the task owning the lock operates
7586 at a priority equal to the highest priority of any task currently
7587 requesting the lock.
7592 @strong{99}. Default ceiling priorities. See D.3(10).
7595 The ceiling priority of protected objects of the type
7596 @code{System.Interrupt_Priority'Last} as described in the Ada 95
7597 Reference Manual D.3(10),
7602 @strong{100}. The ceiling of any protected object used internally by
7603 the implementation. See D.3(16).
7606 The ceiling priority of internal protected objects is
7607 @code{System.Priority'Last}.
7612 @strong{101}. Implementation-defined queuing policies. See D.4(1).
7615 There are no implementation-defined queueing policies.
7620 @strong{102}. On a multiprocessor, any conditions that cause the
7621 completion of an aborted construct to be delayed later than what is
7622 specified for a single processor. See D.6(3).
7625 The semantics for abort on a multi-processor is the same as on a single
7626 processor, there are no further delays.
7631 @strong{103}. Any operations that implicitly require heap storage
7632 allocation. See D.7(8).
7635 The only operation that implicitly requires heap storage allocation is
7641 @strong{104}. Implementation-defined aspects of pragma
7642 @code{Restrictions}. See D.7(20).
7645 There are no such implementation-defined aspects.
7650 @strong{105}. Implementation-defined aspects of package
7651 @code{Real_Time}. See D.8(17).
7654 There are no implementation defined aspects of package @code{Real_Time}.
7659 @strong{106}. Implementation-defined aspects of
7660 @code{delay_statements}. See D.9(8).
7663 Any difference greater than one microsecond will cause the task to be
7664 delayed (see D.9(7)).
7669 @strong{107}. The upper bound on the duration of interrupt blocking
7670 caused by the implementation. See D.12(5).
7673 The upper bound is determined by the underlying operating system. In
7674 no cases is it more than 10 milliseconds.
7679 @strong{108}. The means for creating and executing distributed
7683 The GLADE package provides a utility GNATDIST for creating and executing
7684 distributed programs. See the GLADE reference manual for further details.
7689 @strong{109}. Any events that can result in a partition becoming
7690 inaccessible. See E.1(7).
7693 See the GLADE reference manual for full details on such events.
7698 @strong{110}. The scheduling policies, treatment of priorities, and
7699 management of shared resources between partitions in certain cases. See
7703 See the GLADE reference manual for full details on these aspects of
7704 multi-partition execution.
7709 @strong{111}. Events that cause the version of a compilation unit to
7713 Editing the source file of a compilation unit, or the source files of
7714 any units on which it is dependent in a significant way cause the version
7715 to change. No other actions cause the version number to change. All changes
7716 are significant except those which affect only layout, capitalization or
7722 @strong{112}. Whether the execution of the remote subprogram is
7723 immediately aborted as a result of cancellation. See E.4(13).
7726 See the GLADE reference manual for details on the effect of abort in
7727 a distributed application.
7732 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
7735 See the GLADE reference manual for a full description of all implementation
7736 defined aspects of the PCS@.
7741 @strong{114}. Implementation-defined interfaces in the PCS@. See
7745 See the GLADE reference manual for a full description of all
7746 implementation defined interfaces.
7751 @strong{115}. The values of named numbers in the package
7752 @code{Decimal}. See F.2(7).
7764 @item Max_Decimal_Digits
7771 @strong{116}. The value of @code{Max_Picture_Length} in the package
7772 @code{Text_IO.Editing}. See F.3.3(16).
7780 @strong{117}. The value of @code{Max_Picture_Length} in the package
7781 @code{Wide_Text_IO.Editing}. See F.3.4(5).
7789 @strong{118}. The accuracy actually achieved by the complex elementary
7790 functions and by other complex arithmetic operations. See G.1(1).
7793 Standard library functions are used for the complex arithmetic
7794 operations. Only fast math mode is currently supported.
7799 @strong{119}. The sign of a zero result (or a component thereof) from
7800 any operator or function in @code{Numerics.Generic_Complex_Types}, when
7801 @code{Real'Signed_Zeros} is True. See G.1.1(53).
7804 The signs of zero values are as recommended by the relevant
7805 implementation advice.
7810 @strong{120}. The sign of a zero result (or a component thereof) from
7811 any operator or function in
7812 @code{Numerics.Generic_Complex_Elementary_Functions}, when
7813 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
7816 The signs of zero values are as recommended by the relevant
7817 implementation advice.
7822 @strong{121}. Whether the strict mode or the relaxed mode is the
7823 default. See G.2(2).
7826 The strict mode is the default. There is no separate relaxed mode. GNAT
7827 provides a highly efficient implementation of strict mode.
7832 @strong{122}. The result interval in certain cases of fixed-to-float
7833 conversion. See G.2.1(10).
7836 For cases where the result interval is implementation dependent, the
7837 accuracy is that provided by performing all operations in 64-bit IEEE
7838 floating-point format.
7843 @strong{123}. The result of a floating point arithmetic operation in
7844 overflow situations, when the @code{Machine_Overflows} attribute of the
7845 result type is @code{False}. See G.2.1(13).
7848 Infinite and Nan values are produced as dictated by the IEEE
7849 floating-point standard.
7854 @strong{124}. The result interval for division (or exponentiation by a
7855 negative exponent), when the floating point hardware implements division
7856 as multiplication by a reciprocal. See G.2.1(16).
7859 Not relevant, division is IEEE exact.
7864 @strong{125}. The definition of close result set, which determines the
7865 accuracy of certain fixed point multiplications and divisions. See
7869 Operations in the close result set are performed using IEEE long format
7870 floating-point arithmetic. The input operands are converted to
7871 floating-point, the operation is done in floating-point, and the result
7872 is converted to the target type.
7877 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
7878 point multiplication or division for which the result shall be in the
7879 perfect result set. See G.2.3(22).
7882 The result is only defined to be in the perfect result set if the result
7883 can be computed by a single scaling operation involving a scale factor
7884 representable in 64-bits.
7889 @strong{127}. The result of a fixed point arithmetic operation in
7890 overflow situations, when the @code{Machine_Overflows} attribute of the
7891 result type is @code{False}. See G.2.3(27).
7894 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
7900 @strong{128}. The result of an elementary function reference in
7901 overflow situations, when the @code{Machine_Overflows} attribute of the
7902 result type is @code{False}. See G.2.4(4).
7905 IEEE infinite and Nan values are produced as appropriate.
7910 @strong{129}. The value of the angle threshold, within which certain
7911 elementary functions, complex arithmetic operations, and complex
7912 elementary functions yield results conforming to a maximum relative
7913 error bound. See G.2.4(10).
7916 Information on this subject is not yet available.
7921 @strong{130}. The accuracy of certain elementary functions for
7922 parameters beyond the angle threshold. See G.2.4(10).
7925 Information on this subject is not yet available.
7930 @strong{131}. The result of a complex arithmetic operation or complex
7931 elementary function reference in overflow situations, when the
7932 @code{Machine_Overflows} attribute of the corresponding real type is
7933 @code{False}. See G.2.6(5).
7936 IEEE infinite and Nan values are produced as appropriate.
7941 @strong{132}. The accuracy of certain complex arithmetic operations and
7942 certain complex elementary functions for parameters (or components
7943 thereof) beyond the angle threshold. See G.2.6(8).
7946 Information on those subjects is not yet available.
7951 @strong{133}. Information regarding bounded errors and erroneous
7952 execution. See H.2(1).
7955 Information on this subject is not yet available.
7960 @strong{134}. Implementation-defined aspects of pragma
7961 @code{Inspection_Point}. See H.3.2(8).
7964 Pragma @code{Inspection_Point} ensures that the variable is live and can
7965 be examined by the debugger at the inspection point.
7970 @strong{135}. Implementation-defined aspects of pragma
7971 @code{Restrictions}. See H.4(25).
7974 There are no implementation-defined aspects of pragma @code{Restrictions}. The
7975 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
7976 generated code. Checks must suppressed by use of pragma @code{Suppress}.
7981 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
7985 There are no restrictions on pragma @code{Restrictions}.
7987 @node Intrinsic Subprograms
7988 @chapter Intrinsic Subprograms
7989 @cindex Intrinsic Subprograms
7992 * Intrinsic Operators::
7993 * Enclosing_Entity::
7994 * Exception_Information::
7995 * Exception_Message::
8003 * Shift_Right_Arithmetic::
8008 GNAT allows a user application program to write the declaration:
8010 @smallexample @c ada
8011 pragma Import (Intrinsic, name);
8015 providing that the name corresponds to one of the implemented intrinsic
8016 subprograms in GNAT, and that the parameter profile of the referenced
8017 subprogram meets the requirements. This chapter describes the set of
8018 implemented intrinsic subprograms, and the requirements on parameter profiles.
8019 Note that no body is supplied; as with other uses of pragma Import, the
8020 body is supplied elsewhere (in this case by the compiler itself). Note
8021 that any use of this feature is potentially non-portable, since the
8022 Ada standard does not require Ada compilers to implement this feature.
8024 @node Intrinsic Operators
8025 @section Intrinsic Operators
8026 @cindex Intrinsic operator
8029 All the predefined numeric operators in package Standard
8030 in @code{pragma Import (Intrinsic,..)}
8031 declarations. In the binary operator case, the operands must have the same
8032 size. The operand or operands must also be appropriate for
8033 the operator. For example, for addition, the operands must
8034 both be floating-point or both be fixed-point, and the
8035 right operand for @code{"**"} must have a root type of
8036 @code{Standard.Integer'Base}.
8037 You can use an intrinsic operator declaration as in the following example:
8039 @smallexample @c ada
8040 type Int1 is new Integer;
8041 type Int2 is new Integer;
8043 function "+" (X1 : Int1; X2 : Int2) return Int1;
8044 function "+" (X1 : Int1; X2 : Int2) return Int2;
8045 pragma Import (Intrinsic, "+");
8049 This declaration would permit ``mixed mode'' arithmetic on items
8050 of the differing types @code{Int1} and @code{Int2}.
8051 It is also possible to specify such operators for private types, if the
8052 full views are appropriate arithmetic types.
8054 @node Enclosing_Entity
8055 @section Enclosing_Entity
8056 @cindex Enclosing_Entity
8058 This intrinsic subprogram is used in the implementation of the
8059 library routine @code{GNAT.Source_Info}. The only useful use of the
8060 intrinsic import in this case is the one in this unit, so an
8061 application program should simply call the function
8062 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8063 the current subprogram, package, task, entry, or protected subprogram.
8065 @node Exception_Information
8066 @section Exception_Information
8067 @cindex Exception_Information'
8069 This intrinsic subprogram is used in the implementation of the
8070 library routine @code{GNAT.Current_Exception}. The only useful
8071 use of the intrinsic import in this case is the one in this unit,
8072 so an application program should simply call the function
8073 @code{GNAT.Current_Exception.Exception_Information} to obtain
8074 the exception information associated with the current exception.
8076 @node Exception_Message
8077 @section Exception_Message
8078 @cindex Exception_Message
8080 This intrinsic subprogram is used in the implementation of the
8081 library routine @code{GNAT.Current_Exception}. The only useful
8082 use of the intrinsic import in this case is the one in this unit,
8083 so an application program should simply call the function
8084 @code{GNAT.Current_Exception.Exception_Message} to obtain
8085 the message associated with the current exception.
8087 @node Exception_Name
8088 @section Exception_Name
8089 @cindex Exception_Name
8091 This intrinsic subprogram is used in the implementation of the
8092 library routine @code{GNAT.Current_Exception}. The only useful
8093 use of the intrinsic import in this case is the one in this unit,
8094 so an application program should simply call the function
8095 @code{GNAT.Current_Exception.Exception_Name} to obtain
8096 the name of the current exception.
8102 This intrinsic subprogram is used in the implementation of the
8103 library routine @code{GNAT.Source_Info}. The only useful use of the
8104 intrinsic import in this case is the one in this unit, so an
8105 application program should simply call the function
8106 @code{GNAT.Source_Info.File} to obtain the name of the current
8113 This intrinsic subprogram is used in the implementation of the
8114 library routine @code{GNAT.Source_Info}. The only useful use of the
8115 intrinsic import in this case is the one in this unit, so an
8116 application program should simply call the function
8117 @code{GNAT.Source_Info.Line} to obtain the number of the current
8121 @section Rotate_Left
8124 In standard Ada 95, the @code{Rotate_Left} function is available only
8125 for the predefined modular types in package @code{Interfaces}. However, in
8126 GNAT it is possible to define a Rotate_Left function for a user
8127 defined modular type or any signed integer type as in this example:
8129 @smallexample @c ada
8131 (Value : My_Modular_Type;
8133 return My_Modular_Type;
8137 The requirements are that the profile be exactly as in the example
8138 above. The only modifications allowed are in the formal parameter
8139 names, and in the type of @code{Value} and the return type, which
8140 must be the same, and must be either a signed integer type, or
8141 a modular integer type with a binary modulus, and the size must
8142 be 8. 16, 32 or 64 bits.
8145 @section Rotate_Right
8146 @cindex Rotate_Right
8148 A @code{Rotate_Right} function can be defined for any user defined
8149 binary modular integer type, or signed integer type, as described
8150 above for @code{Rotate_Left}.
8156 A @code{Shift_Left} function can be defined for any user defined
8157 binary modular integer type, or signed integer type, as described
8158 above for @code{Rotate_Left}.
8161 @section Shift_Right
8164 A @code{Shift_Right} function can be defined for any user defined
8165 binary modular integer type, or signed integer type, as described
8166 above for @code{Rotate_Left}.
8168 @node Shift_Right_Arithmetic
8169 @section Shift_Right_Arithmetic
8170 @cindex Shift_Right_Arithmetic
8172 A @code{Shift_Right_Arithmetic} function can be defined for any user
8173 defined binary modular integer type, or signed integer type, as described
8174 above for @code{Rotate_Left}.
8176 @node Source_Location
8177 @section Source_Location
8178 @cindex Source_Location
8180 This intrinsic subprogram is used in the implementation of the
8181 library routine @code{GNAT.Source_Info}. The only useful use of the
8182 intrinsic import in this case is the one in this unit, so an
8183 application program should simply call the function
8184 @code{GNAT.Source_Info.Source_Location} to obtain the current
8185 source file location.
8187 @node Representation Clauses and Pragmas
8188 @chapter Representation Clauses and Pragmas
8189 @cindex Representation Clauses
8192 * Alignment Clauses::
8194 * Storage_Size Clauses::
8195 * Size of Variant Record Objects::
8196 * Biased Representation ::
8197 * Value_Size and Object_Size Clauses::
8198 * Component_Size Clauses::
8199 * Bit_Order Clauses::
8200 * Effect of Bit_Order on Byte Ordering::
8201 * Pragma Pack for Arrays::
8202 * Pragma Pack for Records::
8203 * Record Representation Clauses::
8204 * Enumeration Clauses::
8206 * Effect of Convention on Representation::
8207 * Determining the Representations chosen by GNAT::
8211 @cindex Representation Clause
8212 @cindex Representation Pragma
8213 @cindex Pragma, representation
8214 This section describes the representation clauses accepted by GNAT, and
8215 their effect on the representation of corresponding data objects.
8217 GNAT fully implements Annex C (Systems Programming). This means that all
8218 the implementation advice sections in chapter 13 are fully implemented.
8219 However, these sections only require a minimal level of support for
8220 representation clauses. GNAT provides much more extensive capabilities,
8221 and this section describes the additional capabilities provided.
8223 @node Alignment Clauses
8224 @section Alignment Clauses
8225 @cindex Alignment Clause
8228 GNAT requires that all alignment clauses specify a power of 2, and all
8229 default alignments are always a power of 2. The default alignment
8230 values are as follows:
8233 @item @emph{Primitive Types}.
8234 For primitive types, the alignment is the minimum of the actual size of
8235 objects of the type divided by @code{Storage_Unit},
8236 and the maximum alignment supported by the target.
8237 (This maximum alignment is given by the GNAT-specific attribute
8238 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8239 @cindex @code{Maximum_Alignment} attribute
8240 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8241 default alignment will be 8 on any target that supports alignments
8242 this large, but on some targets, the maximum alignment may be smaller
8243 than 8, in which case objects of type @code{Long_Float} will be maximally
8246 @item @emph{Arrays}.
8247 For arrays, the alignment is equal to the alignment of the component type
8248 for the normal case where no packing or component size is given. If the
8249 array is packed, and the packing is effective (see separate section on
8250 packed arrays), then the alignment will be one for long packed arrays,
8251 or arrays whose length is not known at compile time. For short packed
8252 arrays, which are handled internally as modular types, the alignment
8253 will be as described for primitive types, e.g.@: a packed array of length
8254 31 bits will have an object size of four bytes, and an alignment of 4.
8256 @item @emph{Records}.
8257 For the normal non-packed case, the alignment of a record is equal to
8258 the maximum alignment of any of its components. For tagged records, this
8259 includes the implicit access type used for the tag. If a pragma @code{Pack} is
8260 used and all fields are packable (see separate section on pragma @code{Pack}),
8261 then the resulting alignment is 1.
8263 A special case is when:
8266 the size of the record is given explicitly, or a
8267 full record representation clause is given, and
8269 the size of the record is 2, 4, or 8 bytes.
8272 In this case, an alignment is chosen to match the
8273 size of the record. For example, if we have:
8275 @smallexample @c ada
8276 type Small is record
8279 for Small'Size use 16;
8283 then the default alignment of the record type @code{Small} is 2, not 1. This
8284 leads to more efficient code when the record is treated as a unit, and also
8285 allows the type to specified as @code{Atomic} on architectures requiring
8291 An alignment clause may
8292 always specify a larger alignment than the default value, up to some
8293 maximum value dependent on the target (obtainable by using the
8294 attribute reference @code{Standard'Maximum_Alignment}).
8296 it is permissible to specify a smaller alignment than the default value
8297 is for a record with a record representation clause.
8298 In this case, packable fields for which a component clause is
8299 given still result in a default alignment corresponding to the original
8300 type, but this may be overridden, since these components in fact only
8301 require an alignment of one byte. For example, given
8303 @smallexample @c ada
8309 A at 0 range 0 .. 31;
8312 for V'alignment use 1;
8316 @cindex Alignment, default
8317 The default alignment for the type @code{V} is 4, as a result of the
8318 Integer field in the record, but since this field is placed with a
8319 component clause, it is permissible, as shown, to override the default
8320 alignment of the record with a smaller value.
8323 @section Size Clauses
8327 The default size for a type @code{T} is obtainable through the
8328 language-defined attribute @code{T'Size} and also through the
8329 equivalent GNAT-defined attribute @code{T'Value_Size}.
8330 For objects of type @code{T}, GNAT will generally increase the type size
8331 so that the object size (obtainable through the GNAT-defined attribute
8332 @code{T'Object_Size})
8333 is a multiple of @code{T'Alignment * Storage_Unit}.
8336 @smallexample @c ada
8337 type Smallint is range 1 .. 6;
8346 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8347 as specified by the RM rules,
8348 but objects of this type will have a size of 8
8349 (@code{Smallint'Object_Size} = 8),
8350 since objects by default occupy an integral number
8351 of storage units. On some targets, notably older
8352 versions of the Digital Alpha, the size of stand
8353 alone objects of this type may be 32, reflecting
8354 the inability of the hardware to do byte load/stores.
8356 Similarly, the size of type @code{Rec} is 40 bits
8357 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8358 the alignment is 4, so objects of this type will have
8359 their size increased to 64 bits so that it is a multiple
8360 of the alignment (in bits). The reason for this decision, which is
8361 in accordance with the specific Implementation Advice in RM 13.3(43):
8364 A @code{Size} clause should be supported for an object if the specified
8365 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8366 to a size in storage elements that is a multiple of the object's
8367 @code{Alignment} (if the @code{Alignment} is nonzero).
8371 An explicit size clause may be used to override the default size by
8372 increasing it. For example, if we have:
8374 @smallexample @c ada
8375 type My_Boolean is new Boolean;
8376 for My_Boolean'Size use 32;
8380 then values of this type will always be 32 bits long. In the case of
8381 discrete types, the size can be increased up to 64 bits, with the effect
8382 that the entire specified field is used to hold the value, sign- or
8383 zero-extended as appropriate. If more than 64 bits is specified, then
8384 padding space is allocated after the value, and a warning is issued that
8385 there are unused bits.
8387 Similarly the size of records and arrays may be increased, and the effect
8388 is to add padding bits after the value. This also causes a warning message
8391 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
8392 Size in bits, this corresponds to an object of size 256 megabytes (minus
8393 one). This limitation is true on all targets. The reason for this
8394 limitation is that it improves the quality of the code in many cases
8395 if it is known that a Size value can be accommodated in an object of
8398 @node Storage_Size Clauses
8399 @section Storage_Size Clauses
8400 @cindex Storage_Size Clause
8403 For tasks, the @code{Storage_Size} clause specifies the amount of space
8404 to be allocated for the task stack. This cannot be extended, and if the
8405 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8406 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
8407 or a @code{Storage_Size} pragma in the task definition to set the
8408 appropriate required size. A useful technique is to include in every
8409 task definition a pragma of the form:
8411 @smallexample @c ada
8412 pragma Storage_Size (Default_Stack_Size);
8416 Then @code{Default_Stack_Size} can be defined in a global package, and
8417 modified as required. Any tasks requiring stack sizes different from the
8418 default can have an appropriate alternative reference in the pragma.
8420 For access types, the @code{Storage_Size} clause specifies the maximum
8421 space available for allocation of objects of the type. If this space is
8422 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8423 In the case where the access type is declared local to a subprogram, the
8424 use of a @code{Storage_Size} clause triggers automatic use of a special
8425 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8426 space for the pool is automatically reclaimed on exit from the scope in
8427 which the type is declared.
8429 A special case recognized by the compiler is the specification of a
8430 @code{Storage_Size} of zero for an access type. This means that no
8431 items can be allocated from the pool, and this is recognized at compile
8432 time, and all the overhead normally associated with maintaining a fixed
8433 size storage pool is eliminated. Consider the following example:
8435 @smallexample @c ada
8437 type R is array (Natural) of Character;
8438 type P is access all R;
8439 for P'Storage_Size use 0;
8440 -- Above access type intended only for interfacing purposes
8444 procedure g (m : P);
8445 pragma Import (C, g);
8456 As indicated in this example, these dummy storage pools are often useful in
8457 connection with interfacing where no object will ever be allocated. If you
8458 compile the above example, you get the warning:
8461 p.adb:16:09: warning: allocation from empty storage pool
8462 p.adb:16:09: warning: Storage_Error will be raised at run time
8466 Of course in practice, there will not be any explicit allocators in the
8467 case of such an access declaration.
8469 @node Size of Variant Record Objects
8470 @section Size of Variant Record Objects
8471 @cindex Size, variant record objects
8472 @cindex Variant record objects, size
8475 In the case of variant record objects, there is a question whether Size gives
8476 information about a particular variant, or the maximum size required
8477 for any variant. Consider the following program
8479 @smallexample @c ada
8480 with Text_IO; use Text_IO;
8482 type R1 (A : Boolean := False) is record
8484 when True => X : Character;
8493 Put_Line (Integer'Image (V1'Size));
8494 Put_Line (Integer'Image (V2'Size));
8499 Here we are dealing with a variant record, where the True variant
8500 requires 16 bits, and the False variant requires 8 bits.
8501 In the above example, both V1 and V2 contain the False variant,
8502 which is only 8 bits long. However, the result of running the
8511 The reason for the difference here is that the discriminant value of
8512 V1 is fixed, and will always be False. It is not possible to assign
8513 a True variant value to V1, therefore 8 bits is sufficient. On the
8514 other hand, in the case of V2, the initial discriminant value is
8515 False (from the default), but it is possible to assign a True
8516 variant value to V2, therefore 16 bits must be allocated for V2
8517 in the general case, even fewer bits may be needed at any particular
8518 point during the program execution.
8520 As can be seen from the output of this program, the @code{'Size}
8521 attribute applied to such an object in GNAT gives the actual allocated
8522 size of the variable, which is the largest size of any of the variants.
8523 The Ada Reference Manual is not completely clear on what choice should
8524 be made here, but the GNAT behavior seems most consistent with the
8525 language in the RM@.
8527 In some cases, it may be desirable to obtain the size of the current
8528 variant, rather than the size of the largest variant. This can be
8529 achieved in GNAT by making use of the fact that in the case of a
8530 subprogram parameter, GNAT does indeed return the size of the current
8531 variant (because a subprogram has no way of knowing how much space
8532 is actually allocated for the actual).
8534 Consider the following modified version of the above program:
8536 @smallexample @c ada
8537 with Text_IO; use Text_IO;
8539 type R1 (A : Boolean := False) is record
8541 when True => X : Character;
8548 function Size (V : R1) return Integer is
8554 Put_Line (Integer'Image (V2'Size));
8555 Put_Line (Integer'IMage (Size (V2)));
8557 Put_Line (Integer'Image (V2'Size));
8558 Put_Line (Integer'IMage (Size (V2)));
8563 The output from this program is
8573 Here we see that while the @code{'Size} attribute always returns
8574 the maximum size, regardless of the current variant value, the
8575 @code{Size} function does indeed return the size of the current
8578 @node Biased Representation
8579 @section Biased Representation
8580 @cindex Size for biased representation
8581 @cindex Biased representation
8584 In the case of scalars with a range starting at other than zero, it is
8585 possible in some cases to specify a size smaller than the default minimum
8586 value, and in such cases, GNAT uses an unsigned biased representation,
8587 in which zero is used to represent the lower bound, and successive values
8588 represent successive values of the type.
8590 For example, suppose we have the declaration:
8592 @smallexample @c ada
8593 type Small is range -7 .. -4;
8594 for Small'Size use 2;
8598 Although the default size of type @code{Small} is 4, the @code{Size}
8599 clause is accepted by GNAT and results in the following representation
8603 -7 is represented as 2#00#
8604 -6 is represented as 2#01#
8605 -5 is represented as 2#10#
8606 -4 is represented as 2#11#
8610 Biased representation is only used if the specified @code{Size} clause
8611 cannot be accepted in any other manner. These reduced sizes that force
8612 biased representation can be used for all discrete types except for
8613 enumeration types for which a representation clause is given.
8615 @node Value_Size and Object_Size Clauses
8616 @section Value_Size and Object_Size Clauses
8619 @cindex Size, of objects
8622 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
8623 required to hold values of type @code{T}. Although this interpretation was
8624 allowed in Ada 83, it was not required, and this requirement in practice
8625 can cause some significant difficulties. For example, in most Ada 83
8626 compilers, @code{Natural'Size} was 32. However, in Ada 95,
8627 @code{Natural'Size} is
8628 typically 31. This means that code may change in behavior when moving
8629 from Ada 83 to Ada 95. For example, consider:
8631 @smallexample @c ada
8638 at 0 range 0 .. Natural'Size - 1;
8639 at 0 range Natural'Size .. 2 * Natural'Size - 1;
8644 In the above code, since the typical size of @code{Natural} objects
8645 is 32 bits and @code{Natural'Size} is 31, the above code can cause
8646 unexpected inefficient packing in Ada 95, and in general there are
8647 cases where the fact that the object size can exceed the
8648 size of the type causes surprises.
8650 To help get around this problem GNAT provides two implementation
8651 defined attributes, @code{Value_Size} and @code{Object_Size}. When
8652 applied to a type, these attributes yield the size of the type
8653 (corresponding to the RM defined size attribute), and the size of
8654 objects of the type respectively.
8656 The @code{Object_Size} is used for determining the default size of
8657 objects and components. This size value can be referred to using the
8658 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
8659 the basis of the determination of the size. The backend is free to
8660 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
8661 character might be stored in 32 bits on a machine with no efficient
8662 byte access instructions such as the Alpha.
8664 The default rules for the value of @code{Object_Size} for
8665 discrete types are as follows:
8669 The @code{Object_Size} for base subtypes reflect the natural hardware
8670 size in bits (run the compiler with @option{-gnatS} to find those values
8671 for numeric types). Enumeration types and fixed-point base subtypes have
8672 8, 16, 32 or 64 bits for this size, depending on the range of values
8676 The @code{Object_Size} of a subtype is the same as the
8677 @code{Object_Size} of
8678 the type from which it is obtained.
8681 The @code{Object_Size} of a derived base type is copied from the parent
8682 base type, and the @code{Object_Size} of a derived first subtype is copied
8683 from the parent first subtype.
8687 The @code{Value_Size} attribute
8688 is the (minimum) number of bits required to store a value
8690 This value is used to determine how tightly to pack
8691 records or arrays with components of this type, and also affects
8692 the semantics of unchecked conversion (unchecked conversions where
8693 the @code{Value_Size} values differ generate a warning, and are potentially
8696 The default rules for the value of @code{Value_Size} are as follows:
8700 The @code{Value_Size} for a base subtype is the minimum number of bits
8701 required to store all values of the type (including the sign bit
8702 only if negative values are possible).
8705 If a subtype statically matches the first subtype of a given type, then it has
8706 by default the same @code{Value_Size} as the first subtype. This is a
8707 consequence of RM 13.1(14) (``if two subtypes statically match,
8708 then their subtype-specific aspects are the same''.)
8711 All other subtypes have a @code{Value_Size} corresponding to the minimum
8712 number of bits required to store all values of the subtype. For
8713 dynamic bounds, it is assumed that the value can range down or up
8714 to the corresponding bound of the ancestor
8718 The RM defined attribute @code{Size} corresponds to the
8719 @code{Value_Size} attribute.
8721 The @code{Size} attribute may be defined for a first-named subtype. This sets
8722 the @code{Value_Size} of
8723 the first-named subtype to the given value, and the
8724 @code{Object_Size} of this first-named subtype to the given value padded up
8725 to an appropriate boundary. It is a consequence of the default rules
8726 above that this @code{Object_Size} will apply to all further subtypes. On the
8727 other hand, @code{Value_Size} is affected only for the first subtype, any
8728 dynamic subtypes obtained from it directly, and any statically matching
8729 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
8731 @code{Value_Size} and
8732 @code{Object_Size} may be explicitly set for any subtype using
8733 an attribute definition clause. Note that the use of these attributes
8734 can cause the RM 13.1(14) rule to be violated. If two access types
8735 reference aliased objects whose subtypes have differing @code{Object_Size}
8736 values as a result of explicit attribute definition clauses, then it
8737 is erroneous to convert from one access subtype to the other.
8739 At the implementation level, Esize stores the Object_Size and the
8740 RM_Size field stores the @code{Value_Size} (and hence the value of the
8741 @code{Size} attribute,
8742 which, as noted above, is equivalent to @code{Value_Size}).
8744 To get a feel for the difference, consider the following examples (note
8745 that in each case the base is @code{Short_Short_Integer} with a size of 8):
8748 Object_Size Value_Size
8750 type x1 is range 0 .. 5; 8 3
8752 type x2 is range 0 .. 5;
8753 for x2'size use 12; 16 12
8755 subtype x3 is x2 range 0 .. 3; 16 2
8757 subtype x4 is x2'base range 0 .. 10; 8 4
8759 subtype x5 is x2 range 0 .. dynamic; 16 3*
8761 subtype x6 is x2'base range 0 .. dynamic; 8 3*
8766 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
8767 but it seems in the spirit of the RM rules to allocate the minimum number
8768 of bits (here 3, given the range for @code{x2})
8769 known to be large enough to hold the given range of values.
8771 So far, so good, but GNAT has to obey the RM rules, so the question is
8772 under what conditions must the RM @code{Size} be used.
8773 The following is a list
8774 of the occasions on which the RM @code{Size} must be used:
8778 Component size for packed arrays or records
8781 Value of the attribute @code{Size} for a type
8784 Warning about sizes not matching for unchecked conversion
8788 For record types, the @code{Object_Size} is always a multiple of the
8789 alignment of the type (this is true for all types). In some cases the
8790 @code{Value_Size} can be smaller. Consider:
8800 On a typical 32-bit architecture, the X component will be four bytes, and
8801 require four-byte alignment, and the Y component will be one byte. In this
8802 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
8803 required to store a value of this type, and for example, it is permissible
8804 to have a component of type R in an outer record whose component size is
8805 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
8806 since it must be rounded up so that this value is a multiple of the
8807 alignment (4 bytes = 32 bits).
8810 For all other types, the @code{Object_Size}
8811 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
8812 Only @code{Size} may be specified for such types.
8814 @node Component_Size Clauses
8815 @section Component_Size Clauses
8816 @cindex Component_Size Clause
8819 Normally, the value specified in a component clause must be consistent
8820 with the subtype of the array component with regard to size and alignment.
8821 In other words, the value specified must be at least equal to the size
8822 of this subtype, and must be a multiple of the alignment value.
8824 In addition, component size clauses are allowed which cause the array
8825 to be packed, by specifying a smaller value. The cases in which this
8826 is allowed are for component size values in the range 1 through 63. The value
8827 specified must not be smaller than the Size of the subtype. GNAT will
8828 accurately honor all packing requests in this range. For example, if
8831 @smallexample @c ada
8832 type r is array (1 .. 8) of Natural;
8833 for r'Component_Size use 31;
8837 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
8838 Of course access to the components of such an array is considerably
8839 less efficient than if the natural component size of 32 is used.
8841 @node Bit_Order Clauses
8842 @section Bit_Order Clauses
8843 @cindex Bit_Order Clause
8844 @cindex bit ordering
8845 @cindex ordering, of bits
8848 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
8849 attribute. The specification may either correspond to the default bit
8850 order for the target, in which case the specification has no effect and
8851 places no additional restrictions, or it may be for the non-standard
8852 setting (that is the opposite of the default).
8854 In the case where the non-standard value is specified, the effect is
8855 to renumber bits within each byte, but the ordering of bytes is not
8856 affected. There are certain
8857 restrictions placed on component clauses as follows:
8861 @item Components fitting within a single storage unit.
8863 These are unrestricted, and the effect is merely to renumber bits. For
8864 example if we are on a little-endian machine with @code{Low_Order_First}
8865 being the default, then the following two declarations have exactly
8868 @smallexample @c ada
8871 B : Integer range 1 .. 120;
8875 A at 0 range 0 .. 0;
8876 B at 0 range 1 .. 7;
8881 B : Integer range 1 .. 120;
8884 for R2'Bit_Order use High_Order_First;
8887 A at 0 range 7 .. 7;
8888 B at 0 range 0 .. 6;
8893 The useful application here is to write the second declaration with the
8894 @code{Bit_Order} attribute definition clause, and know that it will be treated
8895 the same, regardless of whether the target is little-endian or big-endian.
8897 @item Components occupying an integral number of bytes.
8899 These are components that exactly fit in two or more bytes. Such component
8900 declarations are allowed, but have no effect, since it is important to realize
8901 that the @code{Bit_Order} specification does not affect the ordering of bytes.
8902 In particular, the following attempt at getting an endian-independent integer
8905 @smallexample @c ada
8910 for R2'Bit_Order use High_Order_First;
8913 A at 0 range 0 .. 31;
8918 This declaration will result in a little-endian integer on a
8919 little-endian machine, and a big-endian integer on a big-endian machine.
8920 If byte flipping is required for interoperability between big- and
8921 little-endian machines, this must be explicitly programmed. This capability
8922 is not provided by @code{Bit_Order}.
8924 @item Components that are positioned across byte boundaries
8926 but do not occupy an integral number of bytes. Given that bytes are not
8927 reordered, such fields would occupy a non-contiguous sequence of bits
8928 in memory, requiring non-trivial code to reassemble. They are for this
8929 reason not permitted, and any component clause specifying such a layout
8930 will be flagged as illegal by GNAT@.
8935 Since the misconception that Bit_Order automatically deals with all
8936 endian-related incompatibilities is a common one, the specification of
8937 a component field that is an integral number of bytes will always
8938 generate a warning. This warning may be suppressed using
8939 @code{pragma Suppress} if desired. The following section contains additional
8940 details regarding the issue of byte ordering.
8942 @node Effect of Bit_Order on Byte Ordering
8943 @section Effect of Bit_Order on Byte Ordering
8944 @cindex byte ordering
8945 @cindex ordering, of bytes
8948 In this section we will review the effect of the @code{Bit_Order} attribute
8949 definition clause on byte ordering. Briefly, it has no effect at all, but
8950 a detailed example will be helpful. Before giving this
8951 example, let us review the precise
8952 definition of the effect of defining @code{Bit_Order}. The effect of a
8953 non-standard bit order is described in section 15.5.3 of the Ada
8957 2 A bit ordering is a method of interpreting the meaning of
8958 the storage place attributes.
8962 To understand the precise definition of storage place attributes in
8963 this context, we visit section 13.5.1 of the manual:
8966 13 A record_representation_clause (without the mod_clause)
8967 specifies the layout. The storage place attributes (see 13.5.2)
8968 are taken from the values of the position, first_bit, and last_bit
8969 expressions after normalizing those values so that first_bit is
8970 less than Storage_Unit.
8974 The critical point here is that storage places are taken from
8975 the values after normalization, not before. So the @code{Bit_Order}
8976 interpretation applies to normalized values. The interpretation
8977 is described in the later part of the 15.5.3 paragraph:
8980 2 A bit ordering is a method of interpreting the meaning of
8981 the storage place attributes. High_Order_First (known in the
8982 vernacular as ``big endian'') means that the first bit of a
8983 storage element (bit 0) is the most significant bit (interpreting
8984 the sequence of bits that represent a component as an unsigned
8985 integer value). Low_Order_First (known in the vernacular as
8986 ``little endian'') means the opposite: the first bit is the
8991 Note that the numbering is with respect to the bits of a storage
8992 unit. In other words, the specification affects only the numbering
8993 of bits within a single storage unit.
8995 We can make the effect clearer by giving an example.
8997 Suppose that we have an external device which presents two bytes, the first
8998 byte presented, which is the first (low addressed byte) of the two byte
8999 record is called Master, and the second byte is called Slave.
9001 The left most (most significant bit is called Control for each byte, and
9002 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9003 (least significant) bit.
9005 On a big-endian machine, we can write the following representation clause
9007 @smallexample @c ada
9009 Master_Control : Bit;
9017 Slave_Control : Bit;
9028 Master_Control at 0 range 0 .. 0;
9029 Master_V1 at 0 range 1 .. 1;
9030 Master_V2 at 0 range 2 .. 2;
9031 Master_V3 at 0 range 3 .. 3;
9032 Master_V4 at 0 range 4 .. 4;
9033 Master_V5 at 0 range 5 .. 5;
9034 Master_V6 at 0 range 6 .. 6;
9035 Master_V7 at 0 range 7 .. 7;
9036 Slave_Control at 1 range 0 .. 0;
9037 Slave_V1 at 1 range 1 .. 1;
9038 Slave_V2 at 1 range 2 .. 2;
9039 Slave_V3 at 1 range 3 .. 3;
9040 Slave_V4 at 1 range 4 .. 4;
9041 Slave_V5 at 1 range 5 .. 5;
9042 Slave_V6 at 1 range 6 .. 6;
9043 Slave_V7 at 1 range 7 .. 7;
9048 Now if we move this to a little endian machine, then the bit ordering within
9049 the byte is backwards, so we have to rewrite the record rep clause as:
9051 @smallexample @c ada
9053 Master_Control at 0 range 7 .. 7;
9054 Master_V1 at 0 range 6 .. 6;
9055 Master_V2 at 0 range 5 .. 5;
9056 Master_V3 at 0 range 4 .. 4;
9057 Master_V4 at 0 range 3 .. 3;
9058 Master_V5 at 0 range 2 .. 2;
9059 Master_V6 at 0 range 1 .. 1;
9060 Master_V7 at 0 range 0 .. 0;
9061 Slave_Control at 1 range 7 .. 7;
9062 Slave_V1 at 1 range 6 .. 6;
9063 Slave_V2 at 1 range 5 .. 5;
9064 Slave_V3 at 1 range 4 .. 4;
9065 Slave_V4 at 1 range 3 .. 3;
9066 Slave_V5 at 1 range 2 .. 2;
9067 Slave_V6 at 1 range 1 .. 1;
9068 Slave_V7 at 1 range 0 .. 0;
9073 It is a nuisance to have to rewrite the clause, especially if
9074 the code has to be maintained on both machines. However,
9075 this is a case that we can handle with the
9076 @code{Bit_Order} attribute if it is implemented.
9077 Note that the implementation is not required on byte addressed
9078 machines, but it is indeed implemented in GNAT.
9079 This means that we can simply use the
9080 first record clause, together with the declaration
9082 @smallexample @c ada
9083 for Data'Bit_Order use High_Order_First;
9087 and the effect is what is desired, namely the layout is exactly the same,
9088 independent of whether the code is compiled on a big-endian or little-endian
9091 The important point to understand is that byte ordering is not affected.
9092 A @code{Bit_Order} attribute definition never affects which byte a field
9093 ends up in, only where it ends up in that byte.
9094 To make this clear, let us rewrite the record rep clause of the previous
9097 @smallexample @c ada
9098 for Data'Bit_Order use High_Order_First;
9100 Master_Control at 0 range 0 .. 0;
9101 Master_V1 at 0 range 1 .. 1;
9102 Master_V2 at 0 range 2 .. 2;
9103 Master_V3 at 0 range 3 .. 3;
9104 Master_V4 at 0 range 4 .. 4;
9105 Master_V5 at 0 range 5 .. 5;
9106 Master_V6 at 0 range 6 .. 6;
9107 Master_V7 at 0 range 7 .. 7;
9108 Slave_Control at 0 range 8 .. 8;
9109 Slave_V1 at 0 range 9 .. 9;
9110 Slave_V2 at 0 range 10 .. 10;
9111 Slave_V3 at 0 range 11 .. 11;
9112 Slave_V4 at 0 range 12 .. 12;
9113 Slave_V5 at 0 range 13 .. 13;
9114 Slave_V6 at 0 range 14 .. 14;
9115 Slave_V7 at 0 range 15 .. 15;
9120 This is exactly equivalent to saying (a repeat of the first example):
9122 @smallexample @c ada
9123 for Data'Bit_Order use High_Order_First;
9125 Master_Control at 0 range 0 .. 0;
9126 Master_V1 at 0 range 1 .. 1;
9127 Master_V2 at 0 range 2 .. 2;
9128 Master_V3 at 0 range 3 .. 3;
9129 Master_V4 at 0 range 4 .. 4;
9130 Master_V5 at 0 range 5 .. 5;
9131 Master_V6 at 0 range 6 .. 6;
9132 Master_V7 at 0 range 7 .. 7;
9133 Slave_Control at 1 range 0 .. 0;
9134 Slave_V1 at 1 range 1 .. 1;
9135 Slave_V2 at 1 range 2 .. 2;
9136 Slave_V3 at 1 range 3 .. 3;
9137 Slave_V4 at 1 range 4 .. 4;
9138 Slave_V5 at 1 range 5 .. 5;
9139 Slave_V6 at 1 range 6 .. 6;
9140 Slave_V7 at 1 range 7 .. 7;
9145 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9146 field. The storage place attributes are obtained by normalizing the
9147 values given so that the @code{First_Bit} value is less than 8. After
9148 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9149 we specified in the other case.
9151 Now one might expect that the @code{Bit_Order} attribute might affect
9152 bit numbering within the entire record component (two bytes in this
9153 case, thus affecting which byte fields end up in), but that is not
9154 the way this feature is defined, it only affects numbering of bits,
9155 not which byte they end up in.
9157 Consequently it never makes sense to specify a starting bit number
9158 greater than 7 (for a byte addressable field) if an attribute
9159 definition for @code{Bit_Order} has been given, and indeed it
9160 may be actively confusing to specify such a value, so the compiler
9161 generates a warning for such usage.
9163 If you do need to control byte ordering then appropriate conditional
9164 values must be used. If in our example, the slave byte came first on
9165 some machines we might write:
9167 @smallexample @c ada
9168 Master_Byte_First constant Boolean := @dots{};
9170 Master_Byte : constant Natural :=
9171 1 - Boolean'Pos (Master_Byte_First);
9172 Slave_Byte : constant Natural :=
9173 Boolean'Pos (Master_Byte_First);
9175 for Data'Bit_Order use High_Order_First;
9177 Master_Control at Master_Byte range 0 .. 0;
9178 Master_V1 at Master_Byte range 1 .. 1;
9179 Master_V2 at Master_Byte range 2 .. 2;
9180 Master_V3 at Master_Byte range 3 .. 3;
9181 Master_V4 at Master_Byte range 4 .. 4;
9182 Master_V5 at Master_Byte range 5 .. 5;
9183 Master_V6 at Master_Byte range 6 .. 6;
9184 Master_V7 at Master_Byte range 7 .. 7;
9185 Slave_Control at Slave_Byte range 0 .. 0;
9186 Slave_V1 at Slave_Byte range 1 .. 1;
9187 Slave_V2 at Slave_Byte range 2 .. 2;
9188 Slave_V3 at Slave_Byte range 3 .. 3;
9189 Slave_V4 at Slave_Byte range 4 .. 4;
9190 Slave_V5 at Slave_Byte range 5 .. 5;
9191 Slave_V6 at Slave_Byte range 6 .. 6;
9192 Slave_V7 at Slave_Byte range 7 .. 7;
9197 Now to switch between machines, all that is necessary is
9198 to set the boolean constant @code{Master_Byte_First} in
9199 an appropriate manner.
9201 @node Pragma Pack for Arrays
9202 @section Pragma Pack for Arrays
9203 @cindex Pragma Pack (for arrays)
9206 Pragma @code{Pack} applied to an array has no effect unless the component type
9207 is packable. For a component type to be packable, it must be one of the
9214 Any type whose size is specified with a size clause
9216 Any packed array type with a static size
9220 For all these cases, if the component subtype size is in the range
9221 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9222 component size were specified giving the component subtype size.
9223 For example if we have:
9225 @smallexample @c ada
9226 type r is range 0 .. 17;
9228 type ar is array (1 .. 8) of r;
9233 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9234 and the size of the array @code{ar} will be exactly 40 bits.
9236 Note that in some cases this rather fierce approach to packing can produce
9237 unexpected effects. For example, in Ada 95, type Natural typically has a
9238 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9239 close packing, which saves a few bits, but results in far less efficient
9240 access. Since many other Ada compilers will ignore such a packing request,
9241 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9242 might not be what is intended. You can easily remove this warning by
9243 using an explicit @code{Component_Size} setting instead, which never generates
9244 a warning, since the intention of the programmer is clear in this case.
9246 GNAT treats packed arrays in one of two ways. If the size of the array is
9247 known at compile time and is less than 64 bits, then internally the array
9248 is represented as a single modular type, of exactly the appropriate number
9249 of bits. If the length is greater than 63 bits, or is not known at compile
9250 time, then the packed array is represented as an array of bytes, and the
9251 length is always a multiple of 8 bits.
9253 Note that to represent a packed array as a modular type, the alignment must
9254 be suitable for the modular type involved. For example, on typical machines
9255 a 32-bit packed array will be represented by a 32-bit modular integer with
9256 an alignment of four bytes. If you explicitly override the default alignment
9257 with an alignment clause that is too small, the modular representation
9258 cannot be used. For example, consider the following set of declarations:
9260 @smallexample @c ada
9261 type R is range 1 .. 3;
9262 type S is array (1 .. 31) of R;
9263 for S'Component_Size use 2;
9265 for S'Alignment use 1;
9269 If the alignment clause were not present, then a 62-bit modular
9270 representation would be chosen (typically with an alignment of 4 or 8
9271 bytes depending on the target). But the default alignment is overridden
9272 with the explicit alignment clause. This means that the modular
9273 representation cannot be used, and instead the array of bytes
9274 representation must be used, meaning that the length must be a multiple
9275 of 8. Thus the above set of declarations will result in a diagnostic
9276 rejecting the size clause and noting that the minimum size allowed is 64.
9278 @cindex Pragma Pack (for type Natural)
9279 @cindex Pragma Pack warning
9281 One special case that is worth noting occurs when the base type of the
9282 component size is 8/16/32 and the subtype is one bit less. Notably this
9283 occurs with subtype @code{Natural}. Consider:
9285 @smallexample @c ada
9286 type Arr is array (1 .. 32) of Natural;
9291 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9292 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9293 Ada 83 compilers did not attempt 31 bit packing.
9295 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9296 does pack 31-bit subtype to 31 bits. This may result in a substantial
9297 unintended performance penalty when porting legacy Ada 83 code. To help
9298 prevent this, GNAT generates a warning in such cases. If you really want 31
9299 bit packing in a case like this, you can set the component size explicitly:
9301 @smallexample @c ada
9302 type Arr is array (1 .. 32) of Natural;
9303 for Arr'Component_Size use 31;
9307 Here 31-bit packing is achieved as required, and no warning is generated,
9308 since in this case the programmer intention is clear.
9310 @node Pragma Pack for Records
9311 @section Pragma Pack for Records
9312 @cindex Pragma Pack (for records)
9315 Pragma @code{Pack} applied to a record will pack the components to reduce
9316 wasted space from alignment gaps and by reducing the amount of space
9317 taken by components. We distinguish between @emph{packable} components and
9318 @emph{non-packable} components.
9319 Components of the following types are considered packable:
9322 All primitive types are packable.
9325 Small packed arrays, whose size does not exceed 64 bits, and where the
9326 size is statically known at compile time, are represented internally
9327 as modular integers, and so they are also packable.
9332 All packable components occupy the exact number of bits corresponding to
9333 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9334 can start on an arbitrary bit boundary.
9336 All other types are non-packable, they occupy an integral number of
9338 are placed at a boundary corresponding to their alignment requirements.
9340 For example, consider the record
9342 @smallexample @c ada
9343 type Rb1 is array (1 .. 13) of Boolean;
9346 type Rb2 is array (1 .. 65) of Boolean;
9361 The representation for the record x2 is as follows:
9363 @smallexample @c ada
9364 for x2'Size use 224;
9366 l1 at 0 range 0 .. 0;
9367 l2 at 0 range 1 .. 64;
9368 l3 at 12 range 0 .. 31;
9369 l4 at 16 range 0 .. 0;
9370 l5 at 16 range 1 .. 13;
9371 l6 at 18 range 0 .. 71;
9376 Studying this example, we see that the packable fields @code{l1}
9378 of length equal to their sizes, and placed at specific bit boundaries (and
9379 not byte boundaries) to
9380 eliminate padding. But @code{l3} is of a non-packable float type, so
9381 it is on the next appropriate alignment boundary.
9383 The next two fields are fully packable, so @code{l4} and @code{l5} are
9384 minimally packed with no gaps. However, type @code{Rb2} is a packed
9385 array that is longer than 64 bits, so it is itself non-packable. Thus
9386 the @code{l6} field is aligned to the next byte boundary, and takes an
9387 integral number of bytes, i.e.@: 72 bits.
9389 @node Record Representation Clauses
9390 @section Record Representation Clauses
9391 @cindex Record Representation Clause
9394 Record representation clauses may be given for all record types, including
9395 types obtained by record extension. Component clauses are allowed for any
9396 static component. The restrictions on component clauses depend on the type
9399 @cindex Component Clause
9400 For all components of an elementary type, the only restriction on component
9401 clauses is that the size must be at least the 'Size value of the type
9402 (actually the Value_Size). There are no restrictions due to alignment,
9403 and such components may freely cross storage boundaries.
9405 Packed arrays with a size up to and including 64 bits are represented
9406 internally using a modular type with the appropriate number of bits, and
9407 thus the same lack of restriction applies. For example, if you declare:
9409 @smallexample @c ada
9410 type R is array (1 .. 49) of Boolean;
9416 then a component clause for a component of type R may start on any
9417 specified bit boundary, and may specify a value of 49 bits or greater.
9419 The rules for other types are different for GNAT 3 and GNAT 5 versions
9420 (based on GCC 2 and GCC 3 respectively). In GNAT 5, larger components
9421 may also be placed on arbitrary boundaries, so for example, the following
9424 @smallexample @c ada
9425 type R is array (1 .. 79) of Boolean;
9435 G at 0 range 0 .. 0;
9436 H at 0 range 1 .. 1;
9437 L at 0 range 2 .. 80;
9438 R at 0 range 81 .. 159;
9443 In GNAT 3, there are more severe restrictions on larger components.
9444 For non-primitive types, including packed arrays with a size greater than
9445 64 bits, component clauses must respect the alignment requirement of the
9446 type, in particular, always starting on a byte boundary, and the length
9447 must be a multiple of the storage unit.
9449 The following rules regarding tagged types are enforced in both GNAT 3 and
9452 The tag field of a tagged type always occupies an address sized field at
9453 the start of the record. No component clause may attempt to overlay this
9456 In the case of a record extension T1, of a type T, no component clause applied
9457 to the type T1 can specify a storage location that would overlap the first
9458 T'Size bytes of the record.
9460 @node Enumeration Clauses
9461 @section Enumeration Clauses
9463 The only restriction on enumeration clauses is that the range of values
9464 must be representable. For the signed case, if one or more of the
9465 representation values are negative, all values must be in the range:
9467 @smallexample @c ada
9468 System.Min_Int .. System.Max_Int
9472 For the unsigned case, where all values are non negative, the values must
9475 @smallexample @c ada
9476 0 .. System.Max_Binary_Modulus;
9480 A @emph{confirming} representation clause is one in which the values range
9481 from 0 in sequence, i.e.@: a clause that confirms the default representation
9482 for an enumeration type.
9483 Such a confirming representation
9484 is permitted by these rules, and is specially recognized by the compiler so
9485 that no extra overhead results from the use of such a clause.
9487 If an array has an index type which is an enumeration type to which an
9488 enumeration clause has been applied, then the array is stored in a compact
9489 manner. Consider the declarations:
9491 @smallexample @c ada
9492 type r is (A, B, C);
9493 for r use (A => 1, B => 5, C => 10);
9494 type t is array (r) of Character;
9498 The array type t corresponds to a vector with exactly three elements and
9499 has a default size equal to @code{3*Character'Size}. This ensures efficient
9500 use of space, but means that accesses to elements of the array will incur
9501 the overhead of converting representation values to the corresponding
9502 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
9504 @node Address Clauses
9505 @section Address Clauses
9506 @cindex Address Clause
9508 The reference manual allows a general restriction on representation clauses,
9509 as found in RM 13.1(22):
9512 An implementation need not support representation
9513 items containing nonstatic expressions, except that
9514 an implementation should support a representation item
9515 for a given entity if each nonstatic expression in the
9516 representation item is a name that statically denotes
9517 a constant declared before the entity.
9521 In practice this is applicable only to address clauses, since this is the
9522 only case in which a non-static expression is permitted by the syntax. As
9523 the AARM notes in sections 13.1 (22.a-22.h):
9526 22.a Reason: This is to avoid the following sort of thing:
9528 22.b X : Integer := F(@dots{});
9529 Y : Address := G(@dots{});
9530 for X'Address use Y;
9532 22.c In the above, we have to evaluate the
9533 initialization expression for X before we
9534 know where to put the result. This seems
9535 like an unreasonable implementation burden.
9537 22.d The above code should instead be written
9540 22.e Y : constant Address := G(@dots{});
9541 X : Integer := F(@dots{});
9542 for X'Address use Y;
9544 22.f This allows the expression ``Y'' to be safely
9545 evaluated before X is created.
9547 22.g The constant could be a formal parameter of mode in.
9549 22.h An implementation can support other nonstatic
9550 expressions if it wants to. Expressions of type
9551 Address are hardly ever static, but their value
9552 might be known at compile time anyway in many
9557 GNAT does indeed permit many additional cases of non-static expressions. In
9558 particular, if the type involved is elementary there are no restrictions
9559 (since in this case, holding a temporary copy of the initialization value,
9560 if one is present, is inexpensive). In addition, if there is no implicit or
9561 explicit initialization, then there are no restrictions. GNAT will reject
9562 only the case where all three of these conditions hold:
9567 The type of the item is non-elementary (e.g.@: a record or array).
9570 There is explicit or implicit initialization required for the object.
9571 Note that access values are always implicitly initialized, and also
9572 in GNAT, certain bit-packed arrays (those having a dynamic length or
9573 a length greater than 64) will also be implicitly initialized to zero.
9576 The address value is non-static. Here GNAT is more permissive than the
9577 RM, and allows the address value to be the address of a previously declared
9578 stand-alone variable, as long as it does not itself have an address clause.
9580 @smallexample @c ada
9581 Anchor : Some_Initialized_Type;
9582 Overlay : Some_Initialized_Type;
9583 for Overlay'Address use Anchor'Address;
9587 However, the prefix of the address clause cannot be an array component, or
9588 a component of a discriminated record.
9593 As noted above in section 22.h, address values are typically non-static. In
9594 particular the To_Address function, even if applied to a literal value, is
9595 a non-static function call. To avoid this minor annoyance, GNAT provides
9596 the implementation defined attribute 'To_Address. The following two
9597 expressions have identical values:
9601 @smallexample @c ada
9602 To_Address (16#1234_0000#)
9603 System'To_Address (16#1234_0000#);
9607 except that the second form is considered to be a static expression, and
9608 thus when used as an address clause value is always permitted.
9611 Additionally, GNAT treats as static an address clause that is an
9612 unchecked_conversion of a static integer value. This simplifies the porting
9613 of legacy code, and provides a portable equivalent to the GNAT attribute
9616 Another issue with address clauses is the interaction with alignment
9617 requirements. When an address clause is given for an object, the address
9618 value must be consistent with the alignment of the object (which is usually
9619 the same as the alignment of the type of the object). If an address clause
9620 is given that specifies an inappropriately aligned address value, then the
9621 program execution is erroneous.
9623 Since this source of erroneous behavior can have unfortunate effects, GNAT
9624 checks (at compile time if possible, generating a warning, or at execution
9625 time with a run-time check) that the alignment is appropriate. If the
9626 run-time check fails, then @code{Program_Error} is raised. This run-time
9627 check is suppressed if range checks are suppressed, or if
9628 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
9631 An address clause cannot be given for an exported object. More
9632 understandably the real restriction is that objects with an address
9633 clause cannot be exported. This is because such variables are not
9634 defined by the Ada program, so there is no external object to export.
9637 It is permissible to give an address clause and a pragma Import for the
9638 same object. In this case, the variable is not really defined by the
9639 Ada program, so there is no external symbol to be linked. The link name
9640 and the external name are ignored in this case. The reason that we allow this
9641 combination is that it provides a useful idiom to avoid unwanted
9642 initializations on objects with address clauses.
9644 When an address clause is given for an object that has implicit or
9645 explicit initialization, then by default initialization takes place. This
9646 means that the effect of the object declaration is to overwrite the
9647 memory at the specified address. This is almost always not what the
9648 programmer wants, so GNAT will output a warning:
9658 for Ext'Address use System'To_Address (16#1234_1234#);
9660 >>> warning: implicit initialization of "Ext" may
9661 modify overlaid storage
9662 >>> warning: use pragma Import for "Ext" to suppress
9663 initialization (RM B(24))
9669 As indicated by the warning message, the solution is to use a (dummy) pragma
9670 Import to suppress this initialization. The pragma tell the compiler that the
9671 object is declared and initialized elsewhere. The following package compiles
9672 without warnings (and the initialization is suppressed):
9674 @smallexample @c ada
9682 for Ext'Address use System'To_Address (16#1234_1234#);
9683 pragma Import (Ada, Ext);
9688 A final issue with address clauses involves their use for overlaying
9689 variables, as in the following example:
9690 @cindex Overlaying of objects
9692 @smallexample @c ada
9695 for B'Address use A'Address;
9699 or alternatively, using the form recommended by the RM:
9701 @smallexample @c ada
9703 Addr : constant Address := A'Address;
9705 for B'Address use Addr;
9709 In both of these cases, @code{A}
9710 and @code{B} become aliased to one another via the
9711 address clause. This use of address clauses to overlay
9712 variables, achieving an effect similar to unchecked
9713 conversion was erroneous in Ada 83, but in Ada 95
9714 the effect is implementation defined. Furthermore, the
9715 Ada 95 RM specifically recommends that in a situation
9716 like this, @code{B} should be subject to the following
9717 implementation advice (RM 13.3(19)):
9720 19 If the Address of an object is specified, or it is imported
9721 or exported, then the implementation should not perform
9722 optimizations based on assumptions of no aliases.
9726 GNAT follows this recommendation, and goes further by also applying
9727 this recommendation to the overlaid variable (@code{A}
9728 in the above example) in this case. This means that the overlay
9729 works "as expected", in that a modification to one of the variables
9730 will affect the value of the other.
9732 @node Effect of Convention on Representation
9733 @section Effect of Convention on Representation
9734 @cindex Convention, effect on representation
9737 Normally the specification of a foreign language convention for a type or
9738 an object has no effect on the chosen representation. In particular, the
9739 representation chosen for data in GNAT generally meets the standard system
9740 conventions, and for example records are laid out in a manner that is
9741 consistent with C@. This means that specifying convention C (for example)
9744 There are three exceptions to this general rule:
9748 @item Convention Fortran and array subtypes
9749 If pragma Convention Fortran is specified for an array subtype, then in
9750 accordance with the implementation advice in section 3.6.2(11) of the
9751 Ada Reference Manual, the array will be stored in a Fortran-compatible
9752 column-major manner, instead of the normal default row-major order.
9754 @item Convention C and enumeration types
9755 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
9756 to accommodate all values of the type. For example, for the enumeration
9759 @smallexample @c ada
9760 type Color is (Red, Green, Blue);
9764 8 bits is sufficient to store all values of the type, so by default, objects
9765 of type @code{Color} will be represented using 8 bits. However, normal C
9766 convention is to use 32 bits for all enum values in C, since enum values
9767 are essentially of type int. If pragma @code{Convention C} is specified for an
9768 Ada enumeration type, then the size is modified as necessary (usually to
9769 32 bits) to be consistent with the C convention for enum values.
9771 @item Convention C/Fortran and Boolean types
9772 In C, the usual convention for boolean values, that is values used for
9773 conditions, is that zero represents false, and nonzero values represent
9774 true. In Ada, the normal convention is that two specific values, typically
9775 0/1, are used to represent false/true respectively.
9777 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
9778 value represents true).
9780 To accommodate the Fortran and C conventions, if a pragma Convention specifies
9781 C or Fortran convention for a derived Boolean, as in the following example:
9783 @smallexample @c ada
9784 type C_Switch is new Boolean;
9785 pragma Convention (C, C_Switch);
9789 then the GNAT generated code will treat any nonzero value as true. For truth
9790 values generated by GNAT, the conventional value 1 will be used for True, but
9791 when one of these values is read, any nonzero value is treated as True.
9795 @node Determining the Representations chosen by GNAT
9796 @section Determining the Representations chosen by GNAT
9797 @cindex Representation, determination of
9798 @cindex @code{-gnatR} switch
9801 Although the descriptions in this section are intended to be complete, it is
9802 often easier to simply experiment to see what GNAT accepts and what the
9803 effect is on the layout of types and objects.
9805 As required by the Ada RM, if a representation clause is not accepted, then
9806 it must be rejected as illegal by the compiler. However, when a
9807 representation clause or pragma is accepted, there can still be questions
9808 of what the compiler actually does. For example, if a partial record
9809 representation clause specifies the location of some components and not
9810 others, then where are the non-specified components placed? Or if pragma
9811 @code{Pack} is used on a record, then exactly where are the resulting
9812 fields placed? The section on pragma @code{Pack} in this chapter can be
9813 used to answer the second question, but it is often easier to just see
9814 what the compiler does.
9816 For this purpose, GNAT provides the option @code{-gnatR}. If you compile
9817 with this option, then the compiler will output information on the actual
9818 representations chosen, in a format similar to source representation
9819 clauses. For example, if we compile the package:
9821 @smallexample @c ada
9823 type r (x : boolean) is tagged record
9825 when True => S : String (1 .. 100);
9830 type r2 is new r (false) with record
9835 y2 at 16 range 0 .. 31;
9842 type x1 is array (1 .. 10) of x;
9843 for x1'component_size use 11;
9845 type ia is access integer;
9847 type Rb1 is array (1 .. 13) of Boolean;
9850 type Rb2 is array (1 .. 65) of Boolean;
9866 using the switch @code{-gnatR} we obtain the following output:
9869 Representation information for unit q
9870 -------------------------------------
9873 for r'Alignment use 4;
9875 x at 4 range 0 .. 7;
9876 _tag at 0 range 0 .. 31;
9877 s at 5 range 0 .. 799;
9880 for r2'Size use 160;
9881 for r2'Alignment use 4;
9883 x at 4 range 0 .. 7;
9884 _tag at 0 range 0 .. 31;
9885 _parent at 0 range 0 .. 63;
9886 y2 at 16 range 0 .. 31;
9890 for x'Alignment use 1;
9892 y at 0 range 0 .. 7;
9895 for x1'Size use 112;
9896 for x1'Alignment use 1;
9897 for x1'Component_Size use 11;
9899 for rb1'Size use 13;
9900 for rb1'Alignment use 2;
9901 for rb1'Component_Size use 1;
9903 for rb2'Size use 72;
9904 for rb2'Alignment use 1;
9905 for rb2'Component_Size use 1;
9907 for x2'Size use 224;
9908 for x2'Alignment use 4;
9910 l1 at 0 range 0 .. 0;
9911 l2 at 0 range 1 .. 64;
9912 l3 at 12 range 0 .. 31;
9913 l4 at 16 range 0 .. 0;
9914 l5 at 16 range 1 .. 13;
9915 l6 at 18 range 0 .. 71;
9920 The Size values are actually the Object_Size, i.e.@: the default size that
9921 will be allocated for objects of the type.
9922 The ?? size for type r indicates that we have a variant record, and the
9923 actual size of objects will depend on the discriminant value.
9925 The Alignment values show the actual alignment chosen by the compiler
9926 for each record or array type.
9928 The record representation clause for type r shows where all fields
9929 are placed, including the compiler generated tag field (whose location
9930 cannot be controlled by the programmer).
9932 The record representation clause for the type extension r2 shows all the
9933 fields present, including the parent field, which is a copy of the fields
9934 of the parent type of r2, i.e.@: r1.
9936 The component size and size clauses for types rb1 and rb2 show
9937 the exact effect of pragma @code{Pack} on these arrays, and the record
9938 representation clause for type x2 shows how pragma @code{Pack} affects
9941 In some cases, it may be useful to cut and paste the representation clauses
9942 generated by the compiler into the original source to fix and guarantee
9943 the actual representation to be used.
9945 @node Standard Library Routines
9946 @chapter Standard Library Routines
9949 The Ada 95 Reference Manual contains in Annex A a full description of an
9950 extensive set of standard library routines that can be used in any Ada
9951 program, and which must be provided by all Ada compilers. They are
9952 analogous to the standard C library used by C programs.
9954 GNAT implements all of the facilities described in annex A, and for most
9955 purposes the description in the Ada 95
9956 reference manual, or appropriate Ada
9957 text book, will be sufficient for making use of these facilities.
9959 In the case of the input-output facilities, @xref{The Implementation of
9960 Standard I/O}, gives details on exactly how GNAT interfaces to the
9961 file system. For the remaining packages, the Ada 95 reference manual
9962 should be sufficient. The following is a list of the packages included,
9963 together with a brief description of the functionality that is provided.
9965 For completeness, references are included to other predefined library
9966 routines defined in other sections of the Ada 95 reference manual (these are
9967 cross-indexed from annex A).
9971 This is a parent package for all the standard library packages. It is
9972 usually included implicitly in your program, and itself contains no
9973 useful data or routines.
9975 @item Ada.Calendar (9.6)
9976 @code{Calendar} provides time of day access, and routines for
9977 manipulating times and durations.
9979 @item Ada.Characters (A.3.1)
9980 This is a dummy parent package that contains no useful entities
9982 @item Ada.Characters.Handling (A.3.2)
9983 This package provides some basic character handling capabilities,
9984 including classification functions for classes of characters (e.g.@: test
9985 for letters, or digits).
9987 @item Ada.Characters.Latin_1 (A.3.3)
9988 This package includes a complete set of definitions of the characters
9989 that appear in type CHARACTER@. It is useful for writing programs that
9990 will run in international environments. For example, if you want an
9991 upper case E with an acute accent in a string, it is often better to use
9992 the definition of @code{UC_E_Acute} in this package. Then your program
9993 will print in an understandable manner even if your environment does not
9994 support these extended characters.
9996 @item Ada.Command_Line (A.15)
9997 This package provides access to the command line parameters and the name
9998 of the current program (analogous to the use of @code{argc} and @code{argv}
9999 in C), and also allows the exit status for the program to be set in a
10000 system-independent manner.
10002 @item Ada.Decimal (F.2)
10003 This package provides constants describing the range of decimal numbers
10004 implemented, and also a decimal divide routine (analogous to the COBOL
10005 verb DIVIDE .. GIVING .. REMAINDER ..)
10007 @item Ada.Direct_IO (A.8.4)
10008 This package provides input-output using a model of a set of records of
10009 fixed-length, containing an arbitrary definite Ada type, indexed by an
10010 integer record number.
10012 @item Ada.Dynamic_Priorities (D.5)
10013 This package allows the priorities of a task to be adjusted dynamically
10014 as the task is running.
10016 @item Ada.Exceptions (11.4.1)
10017 This package provides additional information on exceptions, and also
10018 contains facilities for treating exceptions as data objects, and raising
10019 exceptions with associated messages.
10021 @item Ada.Finalization (7.6)
10022 This package contains the declarations and subprograms to support the
10023 use of controlled types, providing for automatic initialization and
10024 finalization (analogous to the constructors and destructors of C++)
10026 @item Ada.Interrupts (C.3.2)
10027 This package provides facilities for interfacing to interrupts, which
10028 includes the set of signals or conditions that can be raised and
10029 recognized as interrupts.
10031 @item Ada.Interrupts.Names (C.3.2)
10032 This package provides the set of interrupt names (actually signal
10033 or condition names) that can be handled by GNAT@.
10035 @item Ada.IO_Exceptions (A.13)
10036 This package defines the set of exceptions that can be raised by use of
10037 the standard IO packages.
10040 This package contains some standard constants and exceptions used
10041 throughout the numerics packages. Note that the constants pi and e are
10042 defined here, and it is better to use these definitions than rolling
10045 @item Ada.Numerics.Complex_Elementary_Functions
10046 Provides the implementation of standard elementary functions (such as
10047 log and trigonometric functions) operating on complex numbers using the
10048 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10049 created by the package @code{Numerics.Complex_Types}.
10051 @item Ada.Numerics.Complex_Types
10052 This is a predefined instantiation of
10053 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10054 build the type @code{Complex} and @code{Imaginary}.
10056 @item Ada.Numerics.Discrete_Random
10057 This package provides a random number generator suitable for generating
10058 random integer values from a specified range.
10060 @item Ada.Numerics.Float_Random
10061 This package provides a random number generator suitable for generating
10062 uniformly distributed floating point values.
10064 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10065 This is a generic version of the package that provides the
10066 implementation of standard elementary functions (such as log and
10067 trigonometric functions) for an arbitrary complex type.
10069 The following predefined instantiations of this package are provided:
10073 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10075 @code{Ada.Numerics.Complex_Elementary_Functions}
10077 @code{Ada.Numerics.
10078 Long_Complex_Elementary_Functions}
10081 @item Ada.Numerics.Generic_Complex_Types
10082 This is a generic package that allows the creation of complex types,
10083 with associated complex arithmetic operations.
10085 The following predefined instantiations of this package exist
10088 @code{Ada.Numerics.Short_Complex_Complex_Types}
10090 @code{Ada.Numerics.Complex_Complex_Types}
10092 @code{Ada.Numerics.Long_Complex_Complex_Types}
10095 @item Ada.Numerics.Generic_Elementary_Functions
10096 This is a generic package that provides the implementation of standard
10097 elementary functions (such as log an trigonometric functions) for an
10098 arbitrary float type.
10100 The following predefined instantiations of this package exist
10104 @code{Ada.Numerics.Short_Elementary_Functions}
10106 @code{Ada.Numerics.Elementary_Functions}
10108 @code{Ada.Numerics.Long_Elementary_Functions}
10111 @item Ada.Real_Time (D.8)
10112 This package provides facilities similar to those of @code{Calendar}, but
10113 operating with a finer clock suitable for real time control. Note that
10114 annex D requires that there be no backward clock jumps, and GNAT generally
10115 guarantees this behavior, but of course if the external clock on which
10116 the GNAT runtime depends is deliberately reset by some external event,
10117 then such a backward jump may occur.
10119 @item Ada.Sequential_IO (A.8.1)
10120 This package provides input-output facilities for sequential files,
10121 which can contain a sequence of values of a single type, which can be
10122 any Ada type, including indefinite (unconstrained) types.
10124 @item Ada.Storage_IO (A.9)
10125 This package provides a facility for mapping arbitrary Ada types to and
10126 from a storage buffer. It is primarily intended for the creation of new
10129 @item Ada.Streams (13.13.1)
10130 This is a generic package that provides the basic support for the
10131 concept of streams as used by the stream attributes (@code{Input},
10132 @code{Output}, @code{Read} and @code{Write}).
10134 @item Ada.Streams.Stream_IO (A.12.1)
10135 This package is a specialization of the type @code{Streams} defined in
10136 package @code{Streams} together with a set of operations providing
10137 Stream_IO capability. The Stream_IO model permits both random and
10138 sequential access to a file which can contain an arbitrary set of values
10139 of one or more Ada types.
10141 @item Ada.Strings (A.4.1)
10142 This package provides some basic constants used by the string handling
10145 @item Ada.Strings.Bounded (A.4.4)
10146 This package provides facilities for handling variable length
10147 strings. The bounded model requires a maximum length. It is thus
10148 somewhat more limited than the unbounded model, but avoids the use of
10149 dynamic allocation or finalization.
10151 @item Ada.Strings.Fixed (A.4.3)
10152 This package provides facilities for handling fixed length strings.
10154 @item Ada.Strings.Maps (A.4.2)
10155 This package provides facilities for handling character mappings and
10156 arbitrarily defined subsets of characters. For instance it is useful in
10157 defining specialized translation tables.
10159 @item Ada.Strings.Maps.Constants (A.4.6)
10160 This package provides a standard set of predefined mappings and
10161 predefined character sets. For example, the standard upper to lower case
10162 conversion table is found in this package. Note that upper to lower case
10163 conversion is non-trivial if you want to take the entire set of
10164 characters, including extended characters like E with an acute accent,
10165 into account. You should use the mappings in this package (rather than
10166 adding 32 yourself) to do case mappings.
10168 @item Ada.Strings.Unbounded (A.4.5)
10169 This package provides facilities for handling variable length
10170 strings. The unbounded model allows arbitrary length strings, but
10171 requires the use of dynamic allocation and finalization.
10173 @item Ada.Strings.Wide_Bounded (A.4.7)
10174 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10175 @itemx Ada.Strings.Wide_Maps (A.4.7)
10176 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10177 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10178 These packages provide analogous capabilities to the corresponding
10179 packages without @samp{Wide_} in the name, but operate with the types
10180 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10181 and @code{Character}.
10183 @item Ada.Synchronous_Task_Control (D.10)
10184 This package provides some standard facilities for controlling task
10185 communication in a synchronous manner.
10188 This package contains definitions for manipulation of the tags of tagged
10191 @item Ada.Task_Attributes
10192 This package provides the capability of associating arbitrary
10193 task-specific data with separate tasks.
10196 This package provides basic text input-output capabilities for
10197 character, string and numeric data. The subpackages of this
10198 package are listed next.
10200 @item Ada.Text_IO.Decimal_IO
10201 Provides input-output facilities for decimal fixed-point types
10203 @item Ada.Text_IO.Enumeration_IO
10204 Provides input-output facilities for enumeration types.
10206 @item Ada.Text_IO.Fixed_IO
10207 Provides input-output facilities for ordinary fixed-point types.
10209 @item Ada.Text_IO.Float_IO
10210 Provides input-output facilities for float types. The following
10211 predefined instantiations of this generic package are available:
10215 @code{Short_Float_Text_IO}
10217 @code{Float_Text_IO}
10219 @code{Long_Float_Text_IO}
10222 @item Ada.Text_IO.Integer_IO
10223 Provides input-output facilities for integer types. The following
10224 predefined instantiations of this generic package are available:
10227 @item Short_Short_Integer
10228 @code{Ada.Short_Short_Integer_Text_IO}
10229 @item Short_Integer
10230 @code{Ada.Short_Integer_Text_IO}
10232 @code{Ada.Integer_Text_IO}
10234 @code{Ada.Long_Integer_Text_IO}
10235 @item Long_Long_Integer
10236 @code{Ada.Long_Long_Integer_Text_IO}
10239 @item Ada.Text_IO.Modular_IO
10240 Provides input-output facilities for modular (unsigned) types
10242 @item Ada.Text_IO.Complex_IO (G.1.3)
10243 This package provides basic text input-output capabilities for complex
10246 @item Ada.Text_IO.Editing (F.3.3)
10247 This package contains routines for edited output, analogous to the use
10248 of pictures in COBOL@. The picture formats used by this package are a
10249 close copy of the facility in COBOL@.
10251 @item Ada.Text_IO.Text_Streams (A.12.2)
10252 This package provides a facility that allows Text_IO files to be treated
10253 as streams, so that the stream attributes can be used for writing
10254 arbitrary data, including binary data, to Text_IO files.
10256 @item Ada.Unchecked_Conversion (13.9)
10257 This generic package allows arbitrary conversion from one type to
10258 another of the same size, providing for breaking the type safety in
10259 special circumstances.
10261 If the types have the same Size (more accurately the same Value_Size),
10262 then the effect is simply to transfer the bits from the source to the
10263 target type without any modification. This usage is well defined, and
10264 for simple types whose representation is typically the same across
10265 all implementations, gives a portable method of performing such
10268 If the types do not have the same size, then the result is implementation
10269 defined, and thus may be non-portable. The following describes how GNAT
10270 handles such unchecked conversion cases.
10272 If the types are of different sizes, and are both discrete types, then
10273 the effect is of a normal type conversion without any constraint checking.
10274 In particular if the result type has a larger size, the result will be
10275 zero or sign extended. If the result type has a smaller size, the result
10276 will be truncated by ignoring high order bits.
10278 If the types are of different sizes, and are not both discrete types,
10279 then the conversion works as though pointers were created to the source
10280 and target, and the pointer value is converted. The effect is that bits
10281 are copied from successive low order storage units and bits of the source
10282 up to the length of the target type.
10284 A warning is issued if the lengths differ, since the effect in this
10285 case is implementation dependent, and the above behavior may not match
10286 that of some other compiler.
10288 A pointer to one type may be converted to a pointer to another type using
10289 unchecked conversion. The only case in which the effect is undefined is
10290 when one or both pointers are pointers to unconstrained array types. In
10291 this case, the bounds information may get incorrectly transferred, and in
10292 particular, GNAT uses double size pointers for such types, and it is
10293 meaningless to convert between such pointer types. GNAT will issue a
10294 warning if the alignment of the target designated type is more strict
10295 than the alignment of the source designated type (since the result may
10296 be unaligned in this case).
10298 A pointer other than a pointer to an unconstrained array type may be
10299 converted to and from System.Address. Such usage is common in Ada 83
10300 programs, but note that Ada.Address_To_Access_Conversions is the
10301 preferred method of performing such conversions in Ada 95. Neither
10302 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10303 used in conjunction with pointers to unconstrained objects, since
10304 the bounds information cannot be handled correctly in this case.
10306 @item Ada.Unchecked_Deallocation (13.11.2)
10307 This generic package allows explicit freeing of storage previously
10308 allocated by use of an allocator.
10310 @item Ada.Wide_Text_IO (A.11)
10311 This package is similar to @code{Ada.Text_IO}, except that the external
10312 file supports wide character representations, and the internal types are
10313 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10314 and @code{String}. It contains generic subpackages listed next.
10316 @item Ada.Wide_Text_IO.Decimal_IO
10317 Provides input-output facilities for decimal fixed-point types
10319 @item Ada.Wide_Text_IO.Enumeration_IO
10320 Provides input-output facilities for enumeration types.
10322 @item Ada.Wide_Text_IO.Fixed_IO
10323 Provides input-output facilities for ordinary fixed-point types.
10325 @item Ada.Wide_Text_IO.Float_IO
10326 Provides input-output facilities for float types. The following
10327 predefined instantiations of this generic package are available:
10331 @code{Short_Float_Wide_Text_IO}
10333 @code{Float_Wide_Text_IO}
10335 @code{Long_Float_Wide_Text_IO}
10338 @item Ada.Wide_Text_IO.Integer_IO
10339 Provides input-output facilities for integer types. The following
10340 predefined instantiations of this generic package are available:
10343 @item Short_Short_Integer
10344 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10345 @item Short_Integer
10346 @code{Ada.Short_Integer_Wide_Text_IO}
10348 @code{Ada.Integer_Wide_Text_IO}
10350 @code{Ada.Long_Integer_Wide_Text_IO}
10351 @item Long_Long_Integer
10352 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10355 @item Ada.Wide_Text_IO.Modular_IO
10356 Provides input-output facilities for modular (unsigned) types
10358 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10359 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10360 external file supports wide character representations.
10362 @item Ada.Wide_Text_IO.Editing (F.3.4)
10363 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10364 types are @code{Wide_Character} and @code{Wide_String} instead of
10365 @code{Character} and @code{String}.
10367 @item Ada.Wide_Text_IO.Streams (A.12.3)
10368 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10369 types are @code{Wide_Character} and @code{Wide_String} instead of
10370 @code{Character} and @code{String}.
10373 @node The Implementation of Standard I/O
10374 @chapter The Implementation of Standard I/O
10377 GNAT implements all the required input-output facilities described in
10378 A.6 through A.14. These sections of the Ada 95 reference manual describe the
10379 required behavior of these packages from the Ada point of view, and if
10380 you are writing a portable Ada program that does not need to know the
10381 exact manner in which Ada maps to the outside world when it comes to
10382 reading or writing external files, then you do not need to read this
10383 chapter. As long as your files are all regular files (not pipes or
10384 devices), and as long as you write and read the files only from Ada, the
10385 description in the Ada 95 reference manual is sufficient.
10387 However, if you want to do input-output to pipes or other devices, such
10388 as the keyboard or screen, or if the files you are dealing with are
10389 either generated by some other language, or to be read by some other
10390 language, then you need to know more about the details of how the GNAT
10391 implementation of these input-output facilities behaves.
10393 In this chapter we give a detailed description of exactly how GNAT
10394 interfaces to the file system. As always, the sources of the system are
10395 available to you for answering questions at an even more detailed level,
10396 but for most purposes the information in this chapter will suffice.
10398 Another reason that you may need to know more about how input-output is
10399 implemented arises when you have a program written in mixed languages
10400 where, for example, files are shared between the C and Ada sections of
10401 the same program. GNAT provides some additional facilities, in the form
10402 of additional child library packages, that facilitate this sharing, and
10403 these additional facilities are also described in this chapter.
10406 * Standard I/O Packages::
10415 * Operations on C Streams::
10416 * Interfacing to C Streams::
10419 @node Standard I/O Packages
10420 @section Standard I/O Packages
10423 The Standard I/O packages described in Annex A for
10429 Ada.Text_IO.Complex_IO
10431 Ada.Text_IO.Text_Streams,
10435 Ada.Wide_Text_IO.Complex_IO,
10437 Ada.Wide_Text_IO.Text_Streams
10447 are implemented using the C
10448 library streams facility; where
10452 All files are opened using @code{fopen}.
10454 All input/output operations use @code{fread}/@code{fwrite}.
10458 There is no internal buffering of any kind at the Ada library level. The
10459 only buffering is that provided at the system level in the
10460 implementation of the C library routines that support streams. This
10461 facilitates shared use of these streams by mixed language programs.
10464 @section FORM Strings
10467 The format of a FORM string in GNAT is:
10470 "keyword=value,keyword=value,@dots{},keyword=value"
10474 where letters may be in upper or lower case, and there are no spaces
10475 between values. The order of the entries is not important. Currently
10476 there are two keywords defined.
10484 The use of these parameters is described later in this section.
10490 Direct_IO can only be instantiated for definite types. This is a
10491 restriction of the Ada language, which means that the records are fixed
10492 length (the length being determined by @code{@var{type}'Size}, rounded
10493 up to the next storage unit boundary if necessary).
10495 The records of a Direct_IO file are simply written to the file in index
10496 sequence, with the first record starting at offset zero, and subsequent
10497 records following. There is no control information of any kind. For
10498 example, if 32-bit integers are being written, each record takes
10499 4-bytes, so the record at index @var{K} starts at offset
10500 (@var{K}@minus{}1)*4.
10502 There is no limit on the size of Direct_IO files, they are expanded as
10503 necessary to accommodate whatever records are written to the file.
10505 @node Sequential_IO
10506 @section Sequential_IO
10509 Sequential_IO may be instantiated with either a definite (constrained)
10510 or indefinite (unconstrained) type.
10512 For the definite type case, the elements written to the file are simply
10513 the memory images of the data values with no control information of any
10514 kind. The resulting file should be read using the same type, no validity
10515 checking is performed on input.
10517 For the indefinite type case, the elements written consist of two
10518 parts. First is the size of the data item, written as the memory image
10519 of a @code{Interfaces.C.size_t} value, followed by the memory image of
10520 the data value. The resulting file can only be read using the same
10521 (unconstrained) type. Normal assignment checks are performed on these
10522 read operations, and if these checks fail, @code{Data_Error} is
10523 raised. In particular, in the array case, the lengths must match, and in
10524 the variant record case, if the variable for a particular read operation
10525 is constrained, the discriminants must match.
10527 Note that it is not possible to use Sequential_IO to write variable
10528 length array items, and then read the data back into different length
10529 arrays. For example, the following will raise @code{Data_Error}:
10531 @smallexample @c ada
10532 package IO is new Sequential_IO (String);
10537 IO.Write (F, "hello!")
10538 IO.Reset (F, Mode=>In_File);
10545 On some Ada implementations, this will print @code{hell}, but the program is
10546 clearly incorrect, since there is only one element in the file, and that
10547 element is the string @code{hello!}.
10549 In Ada 95, this kind of behavior can be legitimately achieved using
10550 Stream_IO, and this is the preferred mechanism. In particular, the above
10551 program fragment rewritten to use Stream_IO will work correctly.
10557 Text_IO files consist of a stream of characters containing the following
10558 special control characters:
10561 LF (line feed, 16#0A#) Line Mark
10562 FF (form feed, 16#0C#) Page Mark
10566 A canonical Text_IO file is defined as one in which the following
10567 conditions are met:
10571 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
10575 The character @code{FF} is used only as a page mark, i.e.@: to mark the
10576 end of a page and consequently can appear only immediately following a
10577 @code{LF} (line mark) character.
10580 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
10581 (line mark, page mark). In the former case, the page mark is implicitly
10582 assumed to be present.
10586 A file written using Text_IO will be in canonical form provided that no
10587 explicit @code{LF} or @code{FF} characters are written using @code{Put}
10588 or @code{Put_Line}. There will be no @code{FF} character at the end of
10589 the file unless an explicit @code{New_Page} operation was performed
10590 before closing the file.
10592 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
10593 pipe, can be read using any of the routines in Text_IO@. The
10594 semantics in this case will be exactly as defined in the Ada 95 reference
10595 manual and all the routines in Text_IO are fully implemented.
10597 A text file that does not meet the requirements for a canonical Text_IO
10598 file has one of the following:
10602 The file contains @code{FF} characters not immediately following a
10603 @code{LF} character.
10606 The file contains @code{LF} or @code{FF} characters written by
10607 @code{Put} or @code{Put_Line}, which are not logically considered to be
10608 line marks or page marks.
10611 The file ends in a character other than @code{LF} or @code{FF},
10612 i.e.@: there is no explicit line mark or page mark at the end of the file.
10616 Text_IO can be used to read such non-standard text files but subprograms
10617 to do with line or page numbers do not have defined meanings. In
10618 particular, a @code{FF} character that does not follow a @code{LF}
10619 character may or may not be treated as a page mark from the point of
10620 view of page and line numbering. Every @code{LF} character is considered
10621 to end a line, and there is an implied @code{LF} character at the end of
10625 * Text_IO Stream Pointer Positioning::
10626 * Text_IO Reading and Writing Non-Regular Files::
10628 * Treating Text_IO Files as Streams::
10629 * Text_IO Extensions::
10630 * Text_IO Facilities for Unbounded Strings::
10633 @node Text_IO Stream Pointer Positioning
10634 @subsection Stream Pointer Positioning
10637 @code{Ada.Text_IO} has a definition of current position for a file that
10638 is being read. No internal buffering occurs in Text_IO, and usually the
10639 physical position in the stream used to implement the file corresponds
10640 to this logical position defined by Text_IO@. There are two exceptions:
10644 After a call to @code{End_Of_Page} that returns @code{True}, the stream
10645 is positioned past the @code{LF} (line mark) that precedes the page
10646 mark. Text_IO maintains an internal flag so that subsequent read
10647 operations properly handle the logical position which is unchanged by
10648 the @code{End_Of_Page} call.
10651 After a call to @code{End_Of_File} that returns @code{True}, if the
10652 Text_IO file was positioned before the line mark at the end of file
10653 before the call, then the logical position is unchanged, but the stream
10654 is physically positioned right at the end of file (past the line mark,
10655 and past a possible page mark following the line mark. Again Text_IO
10656 maintains internal flags so that subsequent read operations properly
10657 handle the logical position.
10661 These discrepancies have no effect on the observable behavior of
10662 Text_IO, but if a single Ada stream is shared between a C program and
10663 Ada program, or shared (using @samp{shared=yes} in the form string)
10664 between two Ada files, then the difference may be observable in some
10667 @node Text_IO Reading and Writing Non-Regular Files
10668 @subsection Reading and Writing Non-Regular Files
10671 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
10672 can be used for reading and writing. Writing is not affected and the
10673 sequence of characters output is identical to the normal file case, but
10674 for reading, the behavior of Text_IO is modified to avoid undesirable
10675 look-ahead as follows:
10677 An input file that is not a regular file is considered to have no page
10678 marks. Any @code{Ascii.FF} characters (the character normally used for a
10679 page mark) appearing in the file are considered to be data
10680 characters. In particular:
10684 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
10685 following a line mark. If a page mark appears, it will be treated as a
10689 This avoids the need to wait for an extra character to be typed or
10690 entered from the pipe to complete one of these operations.
10693 @code{End_Of_Page} always returns @code{False}
10696 @code{End_Of_File} will return @code{False} if there is a page mark at
10697 the end of the file.
10701 Output to non-regular files is the same as for regular files. Page marks
10702 may be written to non-regular files using @code{New_Page}, but as noted
10703 above they will not be treated as page marks on input if the output is
10704 piped to another Ada program.
10706 Another important discrepancy when reading non-regular files is that the end
10707 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
10708 pressing the @key{EOT} key,
10710 is signaled once (i.e.@: the test @code{End_Of_File}
10711 will yield @code{True}, or a read will
10712 raise @code{End_Error}), but then reading can resume
10713 to read data past that end of
10714 file indication, until another end of file indication is entered.
10716 @node Get_Immediate
10717 @subsection Get_Immediate
10718 @cindex Get_Immediate
10721 Get_Immediate returns the next character (including control characters)
10722 from the input file. In particular, Get_Immediate will return LF or FF
10723 characters used as line marks or page marks. Such operations leave the
10724 file positioned past the control character, and it is thus not treated
10725 as having its normal function. This means that page, line and column
10726 counts after this kind of Get_Immediate call are set as though the mark
10727 did not occur. In the case where a Get_Immediate leaves the file
10728 positioned between the line mark and page mark (which is not normally
10729 possible), it is undefined whether the FF character will be treated as a
10732 @node Treating Text_IO Files as Streams
10733 @subsection Treating Text_IO Files as Streams
10734 @cindex Stream files
10737 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
10738 as a stream. Data written to a Text_IO file in this stream mode is
10739 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
10740 16#0C# (@code{FF}), the resulting file may have non-standard
10741 format. Similarly if read operations are used to read from a Text_IO
10742 file treated as a stream, then @code{LF} and @code{FF} characters may be
10743 skipped and the effect is similar to that described above for
10744 @code{Get_Immediate}.
10746 @node Text_IO Extensions
10747 @subsection Text_IO Extensions
10748 @cindex Text_IO extensions
10751 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
10752 to the standard @code{Text_IO} package:
10755 @item function File_Exists (Name : String) return Boolean;
10756 Determines if a file of the given name exists.
10758 @item function Get_Line return String;
10759 Reads a string from the standard input file. The value returned is exactly
10760 the length of the line that was read.
10762 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
10763 Similar, except that the parameter File specifies the file from which
10764 the string is to be read.
10768 @node Text_IO Facilities for Unbounded Strings
10769 @subsection Text_IO Facilities for Unbounded Strings
10770 @cindex Text_IO for unbounded strings
10771 @cindex Unbounded_String, Text_IO operations
10774 The package @code{Ada.Strings.Unbounded.Text_IO}
10775 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
10776 subprograms useful for Text_IO operations on unbounded strings:
10780 @item function Get_Line (File : File_Type) return Unbounded_String;
10781 Reads a line from the specified file
10782 and returns the result as an unbounded string.
10784 @item procedure Put (File : File_Type; U : Unbounded_String);
10785 Writes the value of the given unbounded string to the specified file
10786 Similar to the effect of
10787 @code{Put (To_String (U))} except that an extra copy is avoided.
10789 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
10790 Writes the value of the given unbounded string to the specified file,
10791 followed by a @code{New_Line}.
10792 Similar to the effect of @code{Put_Line (To_String (U))} except
10793 that an extra copy is avoided.
10797 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
10798 and is optional. If the parameter is omitted, then the standard input or
10799 output file is referenced as appropriate.
10801 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
10802 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
10803 @code{Wide_Text_IO} functionality for unbounded wide strings.
10806 @section Wide_Text_IO
10809 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
10810 both input and output files may contain special sequences that represent
10811 wide character values. The encoding scheme for a given file may be
10812 specified using a FORM parameter:
10819 as part of the FORM string (WCEM = wide character encoding method),
10820 where @var{x} is one of the following characters
10826 Upper half encoding
10838 The encoding methods match those that
10839 can be used in a source
10840 program, but there is no requirement that the encoding method used for
10841 the source program be the same as the encoding method used for files,
10842 and different files may use different encoding methods.
10844 The default encoding method for the standard files, and for opened files
10845 for which no WCEM parameter is given in the FORM string matches the
10846 wide character encoding specified for the main program (the default
10847 being brackets encoding if no coding method was specified with -gnatW).
10851 In this encoding, a wide character is represented by a five character
10859 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
10860 characters (using upper case letters) of the wide character code. For
10861 example, ESC A345 is used to represent the wide character with code
10862 16#A345#. This scheme is compatible with use of the full
10863 @code{Wide_Character} set.
10865 @item Upper Half Coding
10866 The wide character with encoding 16#abcd#, where the upper bit is on
10867 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
10868 16#cd#. The second byte may never be a format control character, but is
10869 not required to be in the upper half. This method can be also used for
10870 shift-JIS or EUC where the internal coding matches the external coding.
10872 @item Shift JIS Coding
10873 A wide character is represented by a two character sequence 16#ab# and
10874 16#cd#, with the restrictions described for upper half encoding as
10875 described above. The internal character code is the corresponding JIS
10876 character according to the standard algorithm for Shift-JIS
10877 conversion. Only characters defined in the JIS code set table can be
10878 used with this encoding method.
10881 A wide character is represented by a two character sequence 16#ab# and
10882 16#cd#, with both characters being in the upper half. The internal
10883 character code is the corresponding JIS character according to the EUC
10884 encoding algorithm. Only characters defined in the JIS code set table
10885 can be used with this encoding method.
10888 A wide character is represented using
10889 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
10890 10646-1/Am.2. Depending on the character value, the representation
10891 is a one, two, or three byte sequence:
10894 16#0000#-16#007f#: 2#0xxxxxxx#
10895 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
10896 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
10900 where the xxx bits correspond to the left-padded bits of the
10901 16-bit character value. Note that all lower half ASCII characters
10902 are represented as ASCII bytes and all upper half characters and
10903 other wide characters are represented as sequences of upper-half
10904 (The full UTF-8 scheme allows for encoding 31-bit characters as
10905 6-byte sequences, but in this implementation, all UTF-8 sequences
10906 of four or more bytes length will raise a Constraint_Error, as
10907 will all invalid UTF-8 sequences.)
10909 @item Brackets Coding
10910 In this encoding, a wide character is represented by the following eight
10911 character sequence:
10918 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
10919 characters (using uppercase letters) of the wide character code. For
10920 example, @code{["A345"]} is used to represent the wide character with code
10922 This scheme is compatible with use of the full Wide_Character set.
10923 On input, brackets coding can also be used for upper half characters,
10924 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
10925 is only used for wide characters with a code greater than @code{16#FF#}.
10930 For the coding schemes other than Hex and Brackets encoding,
10931 not all wide character
10932 values can be represented. An attempt to output a character that cannot
10933 be represented using the encoding scheme for the file causes
10934 Constraint_Error to be raised. An invalid wide character sequence on
10935 input also causes Constraint_Error to be raised.
10938 * Wide_Text_IO Stream Pointer Positioning::
10939 * Wide_Text_IO Reading and Writing Non-Regular Files::
10942 @node Wide_Text_IO Stream Pointer Positioning
10943 @subsection Stream Pointer Positioning
10946 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
10947 of stream pointer positioning (@pxref{Text_IO}). There is one additional
10950 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
10951 normal lower ASCII set (i.e.@: a character in the range:
10953 @smallexample @c ada
10954 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
10958 then although the logical position of the file pointer is unchanged by
10959 the @code{Look_Ahead} call, the stream is physically positioned past the
10960 wide character sequence. Again this is to avoid the need for buffering
10961 or backup, and all @code{Wide_Text_IO} routines check the internal
10962 indication that this situation has occurred so that this is not visible
10963 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
10964 can be observed if the wide text file shares a stream with another file.
10966 @node Wide_Text_IO Reading and Writing Non-Regular Files
10967 @subsection Reading and Writing Non-Regular Files
10970 As in the case of Text_IO, when a non-regular file is read, it is
10971 assumed that the file contains no page marks (any form characters are
10972 treated as data characters), and @code{End_Of_Page} always returns
10973 @code{False}. Similarly, the end of file indication is not sticky, so
10974 it is possible to read beyond an end of file.
10980 A stream file is a sequence of bytes, where individual elements are
10981 written to the file as described in the Ada 95 reference manual. The type
10982 @code{Stream_Element} is simply a byte. There are two ways to read or
10983 write a stream file.
10987 The operations @code{Read} and @code{Write} directly read or write a
10988 sequence of stream elements with no control information.
10991 The stream attributes applied to a stream file transfer data in the
10992 manner described for stream attributes.
10996 @section Shared Files
10999 Section A.14 of the Ada 95 Reference Manual allows implementations to
11000 provide a wide variety of behavior if an attempt is made to access the
11001 same external file with two or more internal files.
11003 To provide a full range of functionality, while at the same time
11004 minimizing the problems of portability caused by this implementation
11005 dependence, GNAT handles file sharing as follows:
11009 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11010 to open two or more files with the same full name is considered an error
11011 and is not supported. The exception @code{Use_Error} will be
11012 raised. Note that a file that is not explicitly closed by the program
11013 remains open until the program terminates.
11016 If the form parameter @samp{shared=no} appears in the form string, the
11017 file can be opened or created with its own separate stream identifier,
11018 regardless of whether other files sharing the same external file are
11019 opened. The exact effect depends on how the C stream routines handle
11020 multiple accesses to the same external files using separate streams.
11023 If the form parameter @samp{shared=yes} appears in the form string for
11024 each of two or more files opened using the same full name, the same
11025 stream is shared between these files, and the semantics are as described
11026 in Ada 95 Reference Manual, Section A.14.
11030 When a program that opens multiple files with the same name is ported
11031 from another Ada compiler to GNAT, the effect will be that
11032 @code{Use_Error} is raised.
11034 The documentation of the original compiler and the documentation of the
11035 program should then be examined to determine if file sharing was
11036 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11037 and @code{Create} calls as required.
11039 When a program is ported from GNAT to some other Ada compiler, no
11040 special attention is required unless the @samp{shared=@var{xxx}} form
11041 parameter is used in the program. In this case, you must examine the
11042 documentation of the new compiler to see if it supports the required
11043 file sharing semantics, and form strings modified appropriately. Of
11044 course it may be the case that the program cannot be ported if the
11045 target compiler does not support the required functionality. The best
11046 approach in writing portable code is to avoid file sharing (and hence
11047 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11050 One common use of file sharing in Ada 83 is the use of instantiations of
11051 Sequential_IO on the same file with different types, to achieve
11052 heterogeneous input-output. Although this approach will work in GNAT if
11053 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11054 for this purpose (using the stream attributes)
11057 @section Open Modes
11060 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11061 using the mode shown in the following table:
11064 @center @code{Open} and @code{Create} Call Modes
11066 @b{OPEN } @b{CREATE}
11067 Append_File "r+" "w+"
11069 Out_File (Direct_IO) "r+" "w"
11070 Out_File (all other cases) "w" "w"
11071 Inout_File "r+" "w+"
11075 If text file translation is required, then either @samp{b} or @samp{t}
11076 is added to the mode, depending on the setting of Text. Text file
11077 translation refers to the mapping of CR/LF sequences in an external file
11078 to LF characters internally. This mapping only occurs in DOS and
11079 DOS-like systems, and is not relevant to other systems.
11081 A special case occurs with Stream_IO@. As shown in the above table, the
11082 file is initially opened in @samp{r} or @samp{w} mode for the
11083 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
11084 subsequently requires switching from reading to writing or vice-versa,
11085 then the file is reopened in @samp{r+} mode to permit the required operation.
11087 @node Operations on C Streams
11088 @section Operations on C Streams
11089 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11090 access to the C library functions for operations on C streams:
11092 @smallexample @c adanocomment
11093 package Interfaces.C_Streams is
11094 -- Note: the reason we do not use the types that are in
11095 -- Interfaces.C is that we want to avoid dragging in the
11096 -- code in this unit if possible.
11097 subtype chars is System.Address;
11098 -- Pointer to null-terminated array of characters
11099 subtype FILEs is System.Address;
11100 -- Corresponds to the C type FILE*
11101 subtype voids is System.Address;
11102 -- Corresponds to the C type void*
11103 subtype int is Integer;
11104 subtype long is Long_Integer;
11105 -- Note: the above types are subtypes deliberately, and it
11106 -- is part of this spec that the above correspondences are
11107 -- guaranteed. This means that it is legitimate to, for
11108 -- example, use Integer instead of int. We provide these
11109 -- synonyms for clarity, but in some cases it may be
11110 -- convenient to use the underlying types (for example to
11111 -- avoid an unnecessary dependency of a spec on the spec
11113 type size_t is mod 2 ** Standard'Address_Size;
11114 NULL_Stream : constant FILEs;
11115 -- Value returned (NULL in C) to indicate an
11116 -- fdopen/fopen/tmpfile error
11117 ----------------------------------
11118 -- Constants Defined in stdio.h --
11119 ----------------------------------
11120 EOF : constant int;
11121 -- Used by a number of routines to indicate error or
11123 IOFBF : constant int;
11124 IOLBF : constant int;
11125 IONBF : constant int;
11126 -- Used to indicate buffering mode for setvbuf call
11127 SEEK_CUR : constant int;
11128 SEEK_END : constant int;
11129 SEEK_SET : constant int;
11130 -- Used to indicate origin for fseek call
11131 function stdin return FILEs;
11132 function stdout return FILEs;
11133 function stderr return FILEs;
11134 -- Streams associated with standard files
11135 --------------------------
11136 -- Standard C functions --
11137 --------------------------
11138 -- The functions selected below are ones that are
11139 -- available in DOS, OS/2, UNIX and Xenix (but not
11140 -- necessarily in ANSI C). These are very thin interfaces
11141 -- which copy exactly the C headers. For more
11142 -- documentation on these functions, see the Microsoft C
11143 -- "Run-Time Library Reference" (Microsoft Press, 1990,
11144 -- ISBN 1-55615-225-6), which includes useful information
11145 -- on system compatibility.
11146 procedure clearerr (stream : FILEs);
11147 function fclose (stream : FILEs) return int;
11148 function fdopen (handle : int; mode : chars) return FILEs;
11149 function feof (stream : FILEs) return int;
11150 function ferror (stream : FILEs) return int;
11151 function fflush (stream : FILEs) return int;
11152 function fgetc (stream : FILEs) return int;
11153 function fgets (strng : chars; n : int; stream : FILEs)
11155 function fileno (stream : FILEs) return int;
11156 function fopen (filename : chars; Mode : chars)
11158 -- Note: to maintain target independence, use
11159 -- text_translation_required, a boolean variable defined in
11160 -- a-sysdep.c to deal with the target dependent text
11161 -- translation requirement. If this variable is set,
11162 -- then b/t should be appended to the standard mode
11163 -- argument to set the text translation mode off or on
11165 function fputc (C : int; stream : FILEs) return int;
11166 function fputs (Strng : chars; Stream : FILEs) return int;
11183 function ftell (stream : FILEs) return long;
11190 function isatty (handle : int) return int;
11191 procedure mktemp (template : chars);
11192 -- The return value (which is just a pointer to template)
11194 procedure rewind (stream : FILEs);
11195 function rmtmp return int;
11203 function tmpfile return FILEs;
11204 function ungetc (c : int; stream : FILEs) return int;
11205 function unlink (filename : chars) return int;
11206 ---------------------
11207 -- Extra functions --
11208 ---------------------
11209 -- These functions supply slightly thicker bindings than
11210 -- those above. They are derived from functions in the
11211 -- C Run-Time Library, but may do a bit more work than
11212 -- just directly calling one of the Library functions.
11213 function is_regular_file (handle : int) return int;
11214 -- Tests if given handle is for a regular file (result 1)
11215 -- or for a non-regular file (pipe or device, result 0).
11216 ---------------------------------
11217 -- Control of Text/Binary Mode --
11218 ---------------------------------
11219 -- If text_translation_required is true, then the following
11220 -- functions may be used to dynamically switch a file from
11221 -- binary to text mode or vice versa. These functions have
11222 -- no effect if text_translation_required is false (i.e. in
11223 -- normal UNIX mode). Use fileno to get a stream handle.
11224 procedure set_binary_mode (handle : int);
11225 procedure set_text_mode (handle : int);
11226 ----------------------------
11227 -- Full Path Name support --
11228 ----------------------------
11229 procedure full_name (nam : chars; buffer : chars);
11230 -- Given a NUL terminated string representing a file
11231 -- name, returns in buffer a NUL terminated string
11232 -- representing the full path name for the file name.
11233 -- On systems where it is relevant the drive is also
11234 -- part of the full path name. It is the responsibility
11235 -- of the caller to pass an actual parameter for buffer
11236 -- that is big enough for any full path name. Use
11237 -- max_path_len given below as the size of buffer.
11238 max_path_len : integer;
11239 -- Maximum length of an allowable full path name on the
11240 -- system, including a terminating NUL character.
11241 end Interfaces.C_Streams;
11244 @node Interfacing to C Streams
11245 @section Interfacing to C Streams
11248 The packages in this section permit interfacing Ada files to C Stream
11251 @smallexample @c ada
11252 with Interfaces.C_Streams;
11253 package Ada.Sequential_IO.C_Streams is
11254 function C_Stream (F : File_Type)
11255 return Interfaces.C_Streams.FILEs;
11257 (File : in out File_Type;
11258 Mode : in File_Mode;
11259 C_Stream : in Interfaces.C_Streams.FILEs;
11260 Form : in String := "");
11261 end Ada.Sequential_IO.C_Streams;
11263 with Interfaces.C_Streams;
11264 package Ada.Direct_IO.C_Streams is
11265 function C_Stream (F : File_Type)
11266 return Interfaces.C_Streams.FILEs;
11268 (File : in out File_Type;
11269 Mode : in File_Mode;
11270 C_Stream : in Interfaces.C_Streams.FILEs;
11271 Form : in String := "");
11272 end Ada.Direct_IO.C_Streams;
11274 with Interfaces.C_Streams;
11275 package Ada.Text_IO.C_Streams is
11276 function C_Stream (F : File_Type)
11277 return Interfaces.C_Streams.FILEs;
11279 (File : in out File_Type;
11280 Mode : in File_Mode;
11281 C_Stream : in Interfaces.C_Streams.FILEs;
11282 Form : in String := "");
11283 end Ada.Text_IO.C_Streams;
11285 with Interfaces.C_Streams;
11286 package Ada.Wide_Text_IO.C_Streams is
11287 function C_Stream (F : File_Type)
11288 return Interfaces.C_Streams.FILEs;
11290 (File : in out File_Type;
11291 Mode : in File_Mode;
11292 C_Stream : in Interfaces.C_Streams.FILEs;
11293 Form : in String := "");
11294 end Ada.Wide_Text_IO.C_Streams;
11296 with Interfaces.C_Streams;
11297 package Ada.Stream_IO.C_Streams is
11298 function C_Stream (F : File_Type)
11299 return Interfaces.C_Streams.FILEs;
11301 (File : in out File_Type;
11302 Mode : in File_Mode;
11303 C_Stream : in Interfaces.C_Streams.FILEs;
11304 Form : in String := "");
11305 end Ada.Stream_IO.C_Streams;
11309 In each of these five packages, the @code{C_Stream} function obtains the
11310 @code{FILE} pointer from a currently opened Ada file. It is then
11311 possible to use the @code{Interfaces.C_Streams} package to operate on
11312 this stream, or the stream can be passed to a C program which can
11313 operate on it directly. Of course the program is responsible for
11314 ensuring that only appropriate sequences of operations are executed.
11316 One particular use of relevance to an Ada program is that the
11317 @code{setvbuf} function can be used to control the buffering of the
11318 stream used by an Ada file. In the absence of such a call the standard
11319 default buffering is used.
11321 The @code{Open} procedures in these packages open a file giving an
11322 existing C Stream instead of a file name. Typically this stream is
11323 imported from a C program, allowing an Ada file to operate on an
11326 @node The GNAT Library
11327 @chapter The GNAT Library
11330 The GNAT library contains a number of general and special purpose packages.
11331 It represents functionality that the GNAT developers have found useful, and
11332 which is made available to GNAT users. The packages described here are fully
11333 supported, and upwards compatibility will be maintained in future releases,
11334 so you can use these facilities with the confidence that the same functionality
11335 will be available in future releases.
11337 The chapter here simply gives a brief summary of the facilities available.
11338 The full documentation is found in the spec file for the package. The full
11339 sources of these library packages, including both spec and body, are provided
11340 with all GNAT releases. For example, to find out the full specifications of
11341 the SPITBOL pattern matching capability, including a full tutorial and
11342 extensive examples, look in the @file{g-spipat.ads} file in the library.
11344 For each entry here, the package name (as it would appear in a @code{with}
11345 clause) is given, followed by the name of the corresponding spec file in
11346 parentheses. The packages are children in four hierarchies, @code{Ada},
11347 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
11348 GNAT-specific hierarchy.
11350 Note that an application program should only use packages in one of these
11351 four hierarchies if the package is defined in the Ada Reference Manual,
11352 or is listed in this section of the GNAT Programmers Reference Manual.
11353 All other units should be considered internal implementation units and
11354 should not be directly @code{with}'ed by application code. The use of
11355 a @code{with} statement that references one of these internal implementation
11356 units makes an application potentially dependent on changes in versions
11357 of GNAT, and will generate a warning message.
11360 * Ada.Characters.Latin_9 (a-chlat9.ads)::
11361 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
11362 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
11363 * Ada.Command_Line.Remove (a-colire.ads)::
11364 * Ada.Command_Line.Environment (a-colien.ads)::
11365 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
11366 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
11367 * Ada.Exceptions.Traceback (a-exctra.ads)::
11368 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
11369 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
11370 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
11371 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
11372 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
11373 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
11374 * GNAT.Array_Split (g-arrspl.ads)::
11375 * GNAT.AWK (g-awk.ads)::
11376 * GNAT.Bounded_Buffers (g-boubuf.ads)::
11377 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
11378 * GNAT.Bubble_Sort (g-bubsor.ads)::
11379 * GNAT.Bubble_Sort_A (g-busora.ads)::
11380 * GNAT.Bubble_Sort_G (g-busorg.ads)::
11381 * GNAT.Calendar (g-calend.ads)::
11382 * GNAT.Calendar.Time_IO (g-catiio.ads)::
11383 * GNAT.CRC32 (g-crc32.ads)::
11384 * GNAT.Case_Util (g-casuti.ads)::
11385 * GNAT.CGI (g-cgi.ads)::
11386 * GNAT.CGI.Cookie (g-cgicoo.ads)::
11387 * GNAT.CGI.Debug (g-cgideb.ads)::
11388 * GNAT.Command_Line (g-comlin.ads)::
11389 * GNAT.Compiler_Version (g-comver.ads)::
11390 * GNAT.Ctrl_C (g-ctrl_c.ads)::
11391 * GNAT.Current_Exception (g-curexc.ads)::
11392 * GNAT.Debug_Pools (g-debpoo.ads)::
11393 * GNAT.Debug_Utilities (g-debuti.ads)::
11394 * GNAT.Directory_Operations (g-dirope.ads)::
11395 * GNAT.Dynamic_HTables (g-dynhta.ads)::
11396 * GNAT.Dynamic_Tables (g-dyntab.ads)::
11397 * GNAT.Exception_Actions (g-excact.ads)::
11398 * GNAT.Exception_Traces (g-exctra.ads)::
11399 * GNAT.Exceptions (g-except.ads)::
11400 * GNAT.Expect (g-expect.ads)::
11401 * GNAT.Float_Control (g-flocon.ads)::
11402 * GNAT.Heap_Sort (g-heasor.ads)::
11403 * GNAT.Heap_Sort_A (g-hesora.ads)::
11404 * GNAT.Heap_Sort_G (g-hesorg.ads)::
11405 * GNAT.HTable (g-htable.ads)::
11406 * GNAT.IO (g-io.ads)::
11407 * GNAT.IO_Aux (g-io_aux.ads)::
11408 * GNAT.Lock_Files (g-locfil.ads)::
11409 * GNAT.MD5 (g-md5.ads)::
11410 * GNAT.Memory_Dump (g-memdum.ads)::
11411 * GNAT.Most_Recent_Exception (g-moreex.ads)::
11412 * GNAT.OS_Lib (g-os_lib.ads)::
11413 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
11414 * GNAT.Regexp (g-regexp.ads)::
11415 * GNAT.Registry (g-regist.ads)::
11416 * GNAT.Regpat (g-regpat.ads)::
11417 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
11418 * GNAT.Semaphores (g-semaph.ads)::
11419 * GNAT.Signals (g-signal.ads)::
11420 * GNAT.Sockets (g-socket.ads)::
11421 * GNAT.Source_Info (g-souinf.ads)::
11422 * GNAT.Spell_Checker (g-speche.ads)::
11423 * GNAT.Spitbol.Patterns (g-spipat.ads)::
11424 * GNAT.Spitbol (g-spitbo.ads)::
11425 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
11426 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
11427 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
11428 * GNAT.Strings (g-string.ads)::
11429 * GNAT.String_Split (g-strspl.ads)::
11430 * GNAT.Table (g-table.ads)::
11431 * GNAT.Task_Lock (g-tasloc.ads)::
11432 * GNAT.Threads (g-thread.ads)::
11433 * GNAT.Traceback (g-traceb.ads)::
11434 * GNAT.Traceback.Symbolic (g-trasym.ads)::
11435 * GNAT.Wide_String_Split (g-wistsp.ads)::
11436 * Interfaces.C.Extensions (i-cexten.ads)::
11437 * Interfaces.C.Streams (i-cstrea.ads)::
11438 * Interfaces.CPP (i-cpp.ads)::
11439 * Interfaces.Os2lib (i-os2lib.ads)::
11440 * Interfaces.Os2lib.Errors (i-os2err.ads)::
11441 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
11442 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
11443 * Interfaces.Packed_Decimal (i-pacdec.ads)::
11444 * Interfaces.VxWorks (i-vxwork.ads)::
11445 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
11446 * System.Address_Image (s-addima.ads)::
11447 * System.Assertions (s-assert.ads)::
11448 * System.Memory (s-memory.ads)::
11449 * System.Partition_Interface (s-parint.ads)::
11450 * System.Restrictions (s-restri.ads)::
11451 * System.Rident (s-rident.ads)::
11452 * System.Task_Info (s-tasinf.ads)::
11453 * System.Wch_Cnv (s-wchcnv.ads)::
11454 * System.Wch_Con (s-wchcon.ads)::
11457 @node Ada.Characters.Latin_9 (a-chlat9.ads)
11458 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11459 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11460 @cindex Latin_9 constants for Character
11463 This child of @code{Ada.Characters}
11464 provides a set of definitions corresponding to those in the
11465 RM-defined package @code{Ada.Characters.Latin_1} but with the
11466 few modifications required for @code{Latin-9}
11467 The provision of such a package
11468 is specifically authorized by the Ada Reference Manual
11471 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
11472 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11473 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11474 @cindex Latin_1 constants for Wide_Character
11477 This child of @code{Ada.Characters}
11478 provides a set of definitions corresponding to those in the
11479 RM-defined package @code{Ada.Characters.Latin_1} but with the
11480 types of the constants being @code{Wide_Character}
11481 instead of @code{Character}. The provision of such a package
11482 is specifically authorized by the Ada Reference Manual
11485 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
11486 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11487 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11488 @cindex Latin_9 constants for Wide_Character
11491 This child of @code{Ada.Characters}
11492 provides a set of definitions corresponding to those in the
11493 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11494 types of the constants being @code{Wide_Character}
11495 instead of @code{Character}. The provision of such a package
11496 is specifically authorized by the Ada Reference Manual
11499 @node Ada.Command_Line.Remove (a-colire.ads)
11500 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11501 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11502 @cindex Removing command line arguments
11503 @cindex Command line, argument removal
11506 This child of @code{Ada.Command_Line}
11507 provides a mechanism for logically removing
11508 arguments from the argument list. Once removed, an argument is not visible
11509 to further calls on the subprograms in @code{Ada.Command_Line} will not
11510 see the removed argument.
11512 @node Ada.Command_Line.Environment (a-colien.ads)
11513 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11514 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11515 @cindex Environment entries
11518 This child of @code{Ada.Command_Line}
11519 provides a mechanism for obtaining environment values on systems
11520 where this concept makes sense.
11522 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
11523 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11524 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11525 @cindex C Streams, Interfacing with Direct_IO
11528 This package provides subprograms that allow interfacing between
11529 C streams and @code{Direct_IO}. The stream identifier can be
11530 extracted from a file opened on the Ada side, and an Ada file
11531 can be constructed from a stream opened on the C side.
11533 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
11534 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11535 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11536 @cindex Null_Occurrence, testing for
11539 This child subprogram provides a way of testing for the null
11540 exception occurrence (@code{Null_Occurrence}) without raising
11543 @node Ada.Exceptions.Traceback (a-exctra.ads)
11544 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11545 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11546 @cindex Traceback for Exception Occurrence
11549 This child package provides the subprogram (@code{Tracebacks}) to
11550 give a traceback array of addresses based on an exception
11553 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
11554 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11555 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11556 @cindex C Streams, Interfacing with Sequential_IO
11559 This package provides subprograms that allow interfacing between
11560 C streams and @code{Sequential_IO}. The stream identifier can be
11561 extracted from a file opened on the Ada side, and an Ada file
11562 can be constructed from a stream opened on the C side.
11564 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
11565 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11566 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11567 @cindex C Streams, Interfacing with Stream_IO
11570 This package provides subprograms that allow interfacing between
11571 C streams and @code{Stream_IO}. The stream identifier can be
11572 extracted from a file opened on the Ada side, and an Ada file
11573 can be constructed from a stream opened on the C side.
11575 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
11576 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11577 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11578 @cindex @code{Unbounded_String}, IO support
11579 @cindex @code{Text_IO}, extensions for unbounded strings
11582 This package provides subprograms for Text_IO for unbounded
11583 strings, avoiding the necessity for an intermediate operation
11584 with ordinary strings.
11586 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
11587 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11588 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11589 @cindex @code{Unbounded_Wide_String}, IO support
11590 @cindex @code{Text_IO}, extensions for unbounded wide strings
11593 This package provides subprograms for Text_IO for unbounded
11594 wide strings, avoiding the necessity for an intermediate operation
11595 with ordinary wide strings.
11597 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
11598 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11599 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11600 @cindex C Streams, Interfacing with @code{Text_IO}
11603 This package provides subprograms that allow interfacing between
11604 C streams and @code{Text_IO}. The stream identifier can be
11605 extracted from a file opened on the Ada side, and an Ada file
11606 can be constructed from a stream opened on the C side.
11608 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
11609 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11610 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11611 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
11614 This package provides subprograms that allow interfacing between
11615 C streams and @code{Wide_Text_IO}. The stream identifier can be
11616 extracted from a file opened on the Ada side, and an Ada file
11617 can be constructed from a stream opened on the C side.
11619 @node GNAT.Array_Split (g-arrspl.ads)
11620 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11621 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11622 @cindex Array splitter
11625 Useful array-manipulation routines: given a set of separators, split
11626 an array wherever the separators appear, and provide direct access
11627 to the resulting slices.
11629 @node GNAT.AWK (g-awk.ads)
11630 @section @code{GNAT.AWK} (@file{g-awk.ads})
11631 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
11636 Provides AWK-like parsing functions, with an easy interface for parsing one
11637 or more files containing formatted data. The file is viewed as a database
11638 where each record is a line and a field is a data element in this line.
11640 @node GNAT.Bounded_Buffers (g-boubuf.ads)
11641 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11642 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11644 @cindex Bounded Buffers
11647 Provides a concurrent generic bounded buffer abstraction. Instances are
11648 useful directly or as parts of the implementations of other abstractions,
11651 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
11652 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11653 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11658 Provides a thread-safe asynchronous intertask mailbox communication facility.
11660 @node GNAT.Bubble_Sort (g-bubsor.ads)
11661 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11662 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11664 @cindex Bubble sort
11667 Provides a general implementation of bubble sort usable for sorting arbitrary
11668 data items. Exchange and comparison procedures are provided by passing
11669 access-to-procedure values.
11671 @node GNAT.Bubble_Sort_A (g-busora.ads)
11672 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11673 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11675 @cindex Bubble sort
11678 Provides a general implementation of bubble sort usable for sorting arbitrary
11679 data items. Move and comparison procedures are provided by passing
11680 access-to-procedure values. This is an older version, retained for
11681 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
11683 @node GNAT.Bubble_Sort_G (g-busorg.ads)
11684 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11685 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11687 @cindex Bubble sort
11690 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
11691 are provided as generic parameters, this improves efficiency, especially
11692 if the procedures can be inlined, at the expense of duplicating code for
11693 multiple instantiations.
11695 @node GNAT.Calendar (g-calend.ads)
11696 @section @code{GNAT.Calendar} (@file{g-calend.ads})
11697 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
11698 @cindex @code{Calendar}
11701 Extends the facilities provided by @code{Ada.Calendar} to include handling
11702 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
11703 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
11704 C @code{timeval} format.
11706 @node GNAT.Calendar.Time_IO (g-catiio.ads)
11707 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11708 @cindex @code{Calendar}
11710 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11712 @node GNAT.CRC32 (g-crc32.ads)
11713 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
11714 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
11716 @cindex Cyclic Redundancy Check
11719 This package implements the CRC-32 algorithm. For a full description
11720 of this algorithm see
11721 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
11722 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
11723 Aug.@: 1988. Sarwate, D.V@.
11726 Provides an extended capability for formatted output of time values with
11727 full user control over the format. Modeled on the GNU Date specification.
11729 @node GNAT.Case_Util (g-casuti.ads)
11730 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
11731 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
11732 @cindex Casing utilities
11733 @cindex Character handling (@code{GNAT.Case_Util})
11736 A set of simple routines for handling upper and lower casing of strings
11737 without the overhead of the full casing tables
11738 in @code{Ada.Characters.Handling}.
11740 @node GNAT.CGI (g-cgi.ads)
11741 @section @code{GNAT.CGI} (@file{g-cgi.ads})
11742 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
11743 @cindex CGI (Common Gateway Interface)
11746 This is a package for interfacing a GNAT program with a Web server via the
11747 Common Gateway Interface (CGI)@. Basically this package parses the CGI
11748 parameters, which are a set of key/value pairs sent by the Web server. It
11749 builds a table whose index is the key and provides some services to deal
11752 @node GNAT.CGI.Cookie (g-cgicoo.ads)
11753 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11754 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11755 @cindex CGI (Common Gateway Interface) cookie support
11756 @cindex Cookie support in CGI
11759 This is a package to interface a GNAT program with a Web server via the
11760 Common Gateway Interface (CGI). It exports services to deal with Web
11761 cookies (piece of information kept in the Web client software).
11763 @node GNAT.CGI.Debug (g-cgideb.ads)
11764 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11765 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11766 @cindex CGI (Common Gateway Interface) debugging
11769 This is a package to help debugging CGI (Common Gateway Interface)
11770 programs written in Ada.
11772 @node GNAT.Command_Line (g-comlin.ads)
11773 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
11774 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
11775 @cindex Command line
11778 Provides a high level interface to @code{Ada.Command_Line} facilities,
11779 including the ability to scan for named switches with optional parameters
11780 and expand file names using wild card notations.
11782 @node GNAT.Compiler_Version (g-comver.ads)
11783 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11784 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11785 @cindex Compiler Version
11786 @cindex Version, of compiler
11789 Provides a routine for obtaining the version of the compiler used to
11790 compile the program. More accurately this is the version of the binder
11791 used to bind the program (this will normally be the same as the version
11792 of the compiler if a consistent tool set is used to compile all units
11795 @node GNAT.Ctrl_C (g-ctrl_c.ads)
11796 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11797 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11801 Provides a simple interface to handle Ctrl-C keyboard events.
11803 @node GNAT.Current_Exception (g-curexc.ads)
11804 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11805 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11806 @cindex Current exception
11807 @cindex Exception retrieval
11810 Provides access to information on the current exception that has been raised
11811 without the need for using the Ada-95 exception choice parameter specification
11812 syntax. This is particularly useful in simulating typical facilities for
11813 obtaining information about exceptions provided by Ada 83 compilers.
11815 @node GNAT.Debug_Pools (g-debpoo.ads)
11816 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11817 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11819 @cindex Debug pools
11820 @cindex Memory corruption debugging
11823 Provide a debugging storage pools that helps tracking memory corruption
11824 problems. See section ``Finding memory problems with GNAT Debug Pool'' in
11825 the @cite{GNAT User's Guide}.
11827 @node GNAT.Debug_Utilities (g-debuti.ads)
11828 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11829 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11833 Provides a few useful utilities for debugging purposes, including conversion
11834 to and from string images of address values. Supports both C and Ada formats
11835 for hexadecimal literals.
11837 @node GNAT.Directory_Operations (g-dirope.ads)
11838 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
11839 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
11840 @cindex Directory operations
11843 Provides a set of routines for manipulating directories, including changing
11844 the current directory, making new directories, and scanning the files in a
11847 @node GNAT.Dynamic_HTables (g-dynhta.ads)
11848 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11849 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11850 @cindex Hash tables
11853 A generic implementation of hash tables that can be used to hash arbitrary
11854 data. Provided in two forms, a simple form with built in hash functions,
11855 and a more complex form in which the hash function is supplied.
11858 This package provides a facility similar to that of @code{GNAT.HTable},
11859 except that this package declares a type that can be used to define
11860 dynamic instances of the hash table, while an instantiation of
11861 @code{GNAT.HTable} creates a single instance of the hash table.
11863 @node GNAT.Dynamic_Tables (g-dyntab.ads)
11864 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11865 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11866 @cindex Table implementation
11867 @cindex Arrays, extendable
11870 A generic package providing a single dimension array abstraction where the
11871 length of the array can be dynamically modified.
11874 This package provides a facility similar to that of @code{GNAT.Table},
11875 except that this package declares a type that can be used to define
11876 dynamic instances of the table, while an instantiation of
11877 @code{GNAT.Table} creates a single instance of the table type.
11879 @node GNAT.Exception_Actions (g-excact.ads)
11880 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11881 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11882 @cindex Exception actions
11885 Provides callbacks when an exception is raised. Callbacks can be registered
11886 for specific exceptions, or when any exception is raised. This
11887 can be used for instance to force a core dump to ease debugging.
11889 @node GNAT.Exception_Traces (g-exctra.ads)
11890 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11891 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11892 @cindex Exception traces
11896 Provides an interface allowing to control automatic output upon exception
11899 @node GNAT.Exceptions (g-except.ads)
11900 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
11901 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
11902 @cindex Exceptions, Pure
11903 @cindex Pure packages, exceptions
11906 Normally it is not possible to raise an exception with
11907 a message from a subprogram in a pure package, since the
11908 necessary types and subprograms are in @code{Ada.Exceptions}
11909 which is not a pure unit. @code{GNAT.Exceptions} provides a
11910 facility for getting around this limitation for a few
11911 predefined exceptions, and for example allow raising
11912 @code{Constraint_Error} with a message from a pure subprogram.
11914 @node GNAT.Expect (g-expect.ads)
11915 @section @code{GNAT.Expect} (@file{g-expect.ads})
11916 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
11919 Provides a set of subprograms similar to what is available
11920 with the standard Tcl Expect tool.
11921 It allows you to easily spawn and communicate with an external process.
11922 You can send commands or inputs to the process, and compare the output
11923 with some expected regular expression. Currently @code{GNAT.Expect}
11924 is implemented on all native GNAT ports except for OpenVMS@.
11925 It is not implemented for cross ports, and in particular is not
11926 implemented for VxWorks or LynxOS@.
11928 @node GNAT.Float_Control (g-flocon.ads)
11929 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
11930 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
11931 @cindex Floating-Point Processor
11934 Provides an interface for resetting the floating-point processor into the
11935 mode required for correct semantic operation in Ada. Some third party
11936 library calls may cause this mode to be modified, and the Reset procedure
11937 in this package can be used to reestablish the required mode.
11939 @node GNAT.Heap_Sort (g-heasor.ads)
11940 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11941 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11945 Provides a general implementation of heap sort usable for sorting arbitrary
11946 data items. Exchange and comparison procedures are provided by passing
11947 access-to-procedure values. The algorithm used is a modified heap sort
11948 that performs approximately N*log(N) comparisons in the worst case.
11950 @node GNAT.Heap_Sort_A (g-hesora.ads)
11951 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
11952 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
11956 Provides a general implementation of heap sort usable for sorting arbitrary
11957 data items. Move and comparison procedures are provided by passing
11958 access-to-procedure values. The algorithm used is a modified heap sort
11959 that performs approximately N*log(N) comparisons in the worst case.
11960 This differs from @code{GNAT.Heap_Sort} in having a less convenient
11961 interface, but may be slightly more efficient.
11963 @node GNAT.Heap_Sort_G (g-hesorg.ads)
11964 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
11965 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
11969 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
11970 are provided as generic parameters, this improves efficiency, especially
11971 if the procedures can be inlined, at the expense of duplicating code for
11972 multiple instantiations.
11974 @node GNAT.HTable (g-htable.ads)
11975 @section @code{GNAT.HTable} (@file{g-htable.ads})
11976 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
11977 @cindex Hash tables
11980 A generic implementation of hash tables that can be used to hash arbitrary
11981 data. Provides two approaches, one a simple static approach, and the other
11982 allowing arbitrary dynamic hash tables.
11984 @node GNAT.IO (g-io.ads)
11985 @section @code{GNAT.IO} (@file{g-io.ads})
11986 @cindex @code{GNAT.IO} (@file{g-io.ads})
11988 @cindex Input/Output facilities
11991 A simple preelaborable input-output package that provides a subset of
11992 simple Text_IO functions for reading characters and strings from
11993 Standard_Input, and writing characters, strings and integers to either
11994 Standard_Output or Standard_Error.
11996 @node GNAT.IO_Aux (g-io_aux.ads)
11997 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
11998 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12000 @cindex Input/Output facilities
12002 Provides some auxiliary functions for use with Text_IO, including a test
12003 for whether a file exists, and functions for reading a line of text.
12005 @node GNAT.Lock_Files (g-locfil.ads)
12006 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12007 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12008 @cindex File locking
12009 @cindex Locking using files
12012 Provides a general interface for using files as locks. Can be used for
12013 providing program level synchronization.
12015 @node GNAT.MD5 (g-md5.ads)
12016 @section @code{GNAT.MD5} (@file{g-md5.ads})
12017 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12018 @cindex Message Digest MD5
12021 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12023 @node GNAT.Memory_Dump (g-memdum.ads)
12024 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12025 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12026 @cindex Dump Memory
12029 Provides a convenient routine for dumping raw memory to either the
12030 standard output or standard error files. Uses GNAT.IO for actual
12033 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12034 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12035 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12036 @cindex Exception, obtaining most recent
12039 Provides access to the most recently raised exception. Can be used for
12040 various logging purposes, including duplicating functionality of some
12041 Ada 83 implementation dependent extensions.
12043 @node GNAT.OS_Lib (g-os_lib.ads)
12044 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12045 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12046 @cindex Operating System interface
12047 @cindex Spawn capability
12050 Provides a range of target independent operating system interface functions,
12051 including time/date management, file operations, subprocess management,
12052 including a portable spawn procedure, and access to environment variables
12053 and error return codes.
12055 @node GNAT.Perfect_Hash.Generators (g-pehage.ads)
12056 @section @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12057 @cindex @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12058 @cindex Hash functions
12061 Provides a generator of static minimal perfect hash functions. No
12062 collisions occur and each item can be retrieved from the table in one
12063 probe (perfect property). The hash table size corresponds to the exact
12064 size of the key set and no larger (minimal property). The key set has to
12065 be know in advance (static property). The hash functions are also order
12066 preservering. If w2 is inserted after w1 in the generator, their
12067 hashcode are in the same order. These hashing functions are very
12068 convenient for use with realtime applications.
12070 @node GNAT.Regexp (g-regexp.ads)
12071 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12072 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12073 @cindex Regular expressions
12074 @cindex Pattern matching
12077 A simple implementation of regular expressions, using a subset of regular
12078 expression syntax copied from familiar Unix style utilities. This is the
12079 simples of the three pattern matching packages provided, and is particularly
12080 suitable for ``file globbing'' applications.
12082 @node GNAT.Registry (g-regist.ads)
12083 @section @code{GNAT.Registry} (@file{g-regist.ads})
12084 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12085 @cindex Windows Registry
12088 This is a high level binding to the Windows registry. It is possible to
12089 do simple things like reading a key value, creating a new key. For full
12090 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12091 package provided with the Win32Ada binding
12093 @node GNAT.Regpat (g-regpat.ads)
12094 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12095 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
12096 @cindex Regular expressions
12097 @cindex Pattern matching
12100 A complete implementation of Unix-style regular expression matching, copied
12101 from the original V7 style regular expression library written in C by
12102 Henry Spencer (and binary compatible with this C library).
12104 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
12105 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12106 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12107 @cindex Secondary Stack Info
12110 Provide the capability to query the high water mark of the current task's
12113 @node GNAT.Semaphores (g-semaph.ads)
12114 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
12115 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
12119 Provides classic counting and binary semaphores using protected types.
12121 @node GNAT.Signals (g-signal.ads)
12122 @section @code{GNAT.Signals} (@file{g-signal.ads})
12123 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
12127 Provides the ability to manipulate the blocked status of signals on supported
12130 @node GNAT.Sockets (g-socket.ads)
12131 @section @code{GNAT.Sockets} (@file{g-socket.ads})
12132 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
12136 A high level and portable interface to develop sockets based applications.
12137 This package is based on the sockets thin binding found in
12138 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
12139 on all native GNAT ports except for OpenVMS@. It is not implemented
12140 for the LynxOS@ cross port.
12142 @node GNAT.Source_Info (g-souinf.ads)
12143 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
12144 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
12145 @cindex Source Information
12148 Provides subprograms that give access to source code information known at
12149 compile time, such as the current file name and line number.
12151 @node GNAT.Spell_Checker (g-speche.ads)
12152 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12153 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12154 @cindex Spell checking
12157 Provides a function for determining whether one string is a plausible
12158 near misspelling of another string.
12160 @node GNAT.Spitbol.Patterns (g-spipat.ads)
12161 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12162 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12163 @cindex SPITBOL pattern matching
12164 @cindex Pattern matching
12167 A complete implementation of SNOBOL4 style pattern matching. This is the
12168 most elaborate of the pattern matching packages provided. It fully duplicates
12169 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
12170 efficient algorithm developed by Robert Dewar for the SPITBOL system.
12172 @node GNAT.Spitbol (g-spitbo.ads)
12173 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12174 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12175 @cindex SPITBOL interface
12178 The top level package of the collection of SPITBOL-style functionality, this
12179 package provides basic SNOBOL4 string manipulation functions, such as
12180 Pad, Reverse, Trim, Substr capability, as well as a generic table function
12181 useful for constructing arbitrary mappings from strings in the style of
12182 the SNOBOL4 TABLE function.
12184 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
12185 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12186 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12187 @cindex Sets of strings
12188 @cindex SPITBOL Tables
12191 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12192 for type @code{Standard.Boolean}, giving an implementation of sets of
12195 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
12196 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12197 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12198 @cindex Integer maps
12200 @cindex SPITBOL Tables
12203 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12204 for type @code{Standard.Integer}, giving an implementation of maps
12205 from string to integer values.
12207 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
12208 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12209 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12210 @cindex String maps
12212 @cindex SPITBOL Tables
12215 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
12216 a variable length string type, giving an implementation of general
12217 maps from strings to strings.
12219 @node GNAT.Strings (g-string.ads)
12220 @section @code{GNAT.Strings} (@file{g-string.ads})
12221 @cindex @code{GNAT.Strings} (@file{g-string.ads})
12224 Common String access types and related subprograms. Basically it
12225 defines a string access and an array of string access types.
12227 @node GNAT.String_Split (g-strspl.ads)
12228 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
12229 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
12230 @cindex String splitter
12233 Useful string-manipulation routines: given a set of separators, split
12234 a string wherever the separators appear, and provide direct access
12235 to the resulting slices. This package is instantiated from
12236 @code{GNAT.Array_Split}.
12238 @node GNAT.Table (g-table.ads)
12239 @section @code{GNAT.Table} (@file{g-table.ads})
12240 @cindex @code{GNAT.Table} (@file{g-table.ads})
12241 @cindex Table implementation
12242 @cindex Arrays, extendable
12245 A generic package providing a single dimension array abstraction where the
12246 length of the array can be dynamically modified.
12249 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
12250 except that this package declares a single instance of the table type,
12251 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
12252 used to define dynamic instances of the table.
12254 @node GNAT.Task_Lock (g-tasloc.ads)
12255 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12256 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12257 @cindex Task synchronization
12258 @cindex Task locking
12262 A very simple facility for locking and unlocking sections of code using a
12263 single global task lock. Appropriate for use in situations where contention
12264 between tasks is very rarely expected.
12266 @node GNAT.Threads (g-thread.ads)
12267 @section @code{GNAT.Threads} (@file{g-thread.ads})
12268 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
12269 @cindex Foreign threads
12270 @cindex Threads, foreign
12273 Provides facilities for creating and destroying threads with explicit calls.
12274 These threads are known to the GNAT run-time system. These subprograms are
12275 exported C-convention procedures intended to be called from foreign code.
12276 By using these primitives rather than directly calling operating systems
12277 routines, compatibility with the Ada tasking runt-time is provided.
12279 @node GNAT.Traceback (g-traceb.ads)
12280 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
12281 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
12282 @cindex Trace back facilities
12285 Provides a facility for obtaining non-symbolic traceback information, useful
12286 in various debugging situations.
12288 @node GNAT.Traceback.Symbolic (g-trasym.ads)
12289 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12290 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12291 @cindex Trace back facilities
12294 Provides symbolic traceback information that includes the subprogram
12295 name and line number information.
12297 @node GNAT.Wide_String_Split (g-wistsp.ads)
12298 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12299 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12300 @cindex Wide_String splitter
12303 Useful wide_string-manipulation routines: given a set of separators, split
12304 a wide_string wherever the separators appear, and provide direct access
12305 to the resulting slices. This package is instantiated from
12306 @code{GNAT.Array_Split}.
12308 @node Interfaces.C.Extensions (i-cexten.ads)
12309 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12310 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12313 This package contains additional C-related definitions, intended
12314 for use with either manually or automatically generated bindings
12317 @node Interfaces.C.Streams (i-cstrea.ads)
12318 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12319 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12320 @cindex C streams, interfacing
12323 This package is a binding for the most commonly used operations
12326 @node Interfaces.CPP (i-cpp.ads)
12327 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
12328 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
12329 @cindex C++ interfacing
12330 @cindex Interfacing, to C++
12333 This package provides facilities for use in interfacing to C++. It
12334 is primarily intended to be used in connection with automated tools
12335 for the generation of C++ interfaces.
12337 @node Interfaces.Os2lib (i-os2lib.ads)
12338 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12339 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12340 @cindex Interfacing, to OS/2
12341 @cindex OS/2 interfacing
12344 This package provides interface definitions to the OS/2 library.
12345 It is a thin binding which is a direct translation of the
12346 various @file{<bse@.h>} files.
12348 @node Interfaces.Os2lib.Errors (i-os2err.ads)
12349 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12350 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12351 @cindex OS/2 Error codes
12352 @cindex Interfacing, to OS/2
12353 @cindex OS/2 interfacing
12356 This package provides definitions of the OS/2 error codes.
12358 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
12359 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12360 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12361 @cindex Interfacing, to OS/2
12362 @cindex Synchronization, OS/2
12363 @cindex OS/2 synchronization primitives
12366 This is a child package that provides definitions for interfacing
12367 to the @code{OS/2} synchronization primitives.
12369 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
12370 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12371 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12372 @cindex Interfacing, to OS/2
12373 @cindex Thread control, OS/2
12374 @cindex OS/2 thread interfacing
12377 This is a child package that provides definitions for interfacing
12378 to the @code{OS/2} thread primitives.
12380 @node Interfaces.Packed_Decimal (i-pacdec.ads)
12381 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12382 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12383 @cindex IBM Packed Format
12384 @cindex Packed Decimal
12387 This package provides a set of routines for conversions to and
12388 from a packed decimal format compatible with that used on IBM
12391 @node Interfaces.VxWorks (i-vxwork.ads)
12392 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12393 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12394 @cindex Interfacing to VxWorks
12395 @cindex VxWorks, interfacing
12398 This package provides a limited binding to the VxWorks API.
12399 In particular, it interfaces with the
12400 VxWorks hardware interrupt facilities.
12402 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
12403 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12404 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12405 @cindex Interfacing to VxWorks' I/O
12406 @cindex VxWorks, I/O interfacing
12407 @cindex VxWorks, Get_Immediate
12408 @cindex Get_Immediate, VxWorks
12411 This package provides a binding to the ioctl (IO/Control)
12412 function of VxWorks, defining a set of option values and
12413 function codes. A particular use of this package is
12414 to enable the use of Get_Immediate under VxWorks.
12416 @node System.Address_Image (s-addima.ads)
12417 @section @code{System.Address_Image} (@file{s-addima.ads})
12418 @cindex @code{System.Address_Image} (@file{s-addima.ads})
12419 @cindex Address image
12420 @cindex Image, of an address
12423 This function provides a useful debugging
12424 function that gives an (implementation dependent)
12425 string which identifies an address.
12427 @node System.Assertions (s-assert.ads)
12428 @section @code{System.Assertions} (@file{s-assert.ads})
12429 @cindex @code{System.Assertions} (@file{s-assert.ads})
12431 @cindex Assert_Failure, exception
12434 This package provides the declaration of the exception raised
12435 by an run-time assertion failure, as well as the routine that
12436 is used internally to raise this assertion.
12438 @node System.Memory (s-memory.ads)
12439 @section @code{System.Memory} (@file{s-memory.ads})
12440 @cindex @code{System.Memory} (@file{s-memory.ads})
12441 @cindex Memory allocation
12444 This package provides the interface to the low level routines used
12445 by the generated code for allocation and freeing storage for the
12446 default storage pool (analogous to the C routines malloc and free.
12447 It also provides a reallocation interface analogous to the C routine
12448 realloc. The body of this unit may be modified to provide alternative
12449 allocation mechanisms for the default pool, and in addition, direct
12450 calls to this unit may be made for low level allocation uses (for
12451 example see the body of @code{GNAT.Tables}).
12453 @node System.Partition_Interface (s-parint.ads)
12454 @section @code{System.Partition_Interface} (@file{s-parint.ads})
12455 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
12456 @cindex Partition intefacing functions
12459 This package provides facilities for partition interfacing. It
12460 is used primarily in a distribution context when using Annex E
12463 @node System.Restrictions (s-restri.ads)
12464 @section @code{System.Restrictions} (@file{s-restri.ads})
12465 @cindex @code{System.Restrictions} (@file{s-restri.ads})
12466 @cindex Run-time restrictions access
12469 This package provides facilities for accessing at run-time
12470 the status of restrictions specified at compile time for
12471 the partition. Information is available both with regard
12472 to actual restrictions specified, and with regard to
12473 compiler determined information on which restrictions
12474 are violated by one or more packages in the partition.
12476 @node System.Rident (s-rident.ads)
12477 @section @code{System.Rident} (@file{s-rident.ads})
12478 @cindex @code{System.Rident} (@file{s-rident.ads})
12479 @cindex Restrictions definitions
12482 This package provides definitions of the restrictions
12483 identifiers supported by GNAT, and also the format of
12484 the restrictions provided in package System.Restrictions.
12485 It is not normally necessary to @code{with} this generic package
12486 since the necessary instantiation is included in
12487 package System.Restrictions.
12489 @node System.Task_Info (s-tasinf.ads)
12490 @section @code{System.Task_Info} (@file{s-tasinf.ads})
12491 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
12492 @cindex Task_Info pragma
12495 This package provides target dependent functionality that is used
12496 to support the @code{Task_Info} pragma
12498 @node System.Wch_Cnv (s-wchcnv.ads)
12499 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12500 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12501 @cindex Wide Character, Representation
12502 @cindex Wide String, Conversion
12503 @cindex Representation of wide characters
12506 This package provides routines for converting between
12507 wide characters and a representation as a value of type
12508 @code{Standard.String}, using a specified wide character
12509 encoding method. It uses definitions in
12510 package @code{System.Wch_Con}.
12512 @node System.Wch_Con (s-wchcon.ads)
12513 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
12514 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
12517 This package provides definitions and descriptions of
12518 the various methods used for encoding wide characters
12519 in ordinary strings. These definitions are used by
12520 the package @code{System.Wch_Cnv}.
12522 @node Interfacing to Other Languages
12523 @chapter Interfacing to Other Languages
12525 The facilities in annex B of the Ada 95 Reference Manual are fully
12526 implemented in GNAT, and in addition, a full interface to C++ is
12530 * Interfacing to C::
12531 * Interfacing to C++::
12532 * Interfacing to COBOL::
12533 * Interfacing to Fortran::
12534 * Interfacing to non-GNAT Ada code::
12537 @node Interfacing to C
12538 @section Interfacing to C
12541 Interfacing to C with GNAT can use one of two approaches:
12545 The types in the package @code{Interfaces.C} may be used.
12547 Standard Ada types may be used directly. This may be less portable to
12548 other compilers, but will work on all GNAT compilers, which guarantee
12549 correspondence between the C and Ada types.
12553 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
12554 effect, since this is the default. The following table shows the
12555 correspondence between Ada scalar types and the corresponding C types.
12560 @item Short_Integer
12562 @item Short_Short_Integer
12566 @item Long_Long_Integer
12574 @item Long_Long_Float
12575 This is the longest floating-point type supported by the hardware.
12579 Additionally, there are the following general correspondences between Ada
12583 Ada enumeration types map to C enumeration types directly if pragma
12584 @code{Convention C} is specified, which causes them to have int
12585 length. Without pragma @code{Convention C}, Ada enumeration types map to
12586 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
12587 @code{int}, respectively) depending on the number of values passed.
12588 This is the only case in which pragma @code{Convention C} affects the
12589 representation of an Ada type.
12592 Ada access types map to C pointers, except for the case of pointers to
12593 unconstrained types in Ada, which have no direct C equivalent.
12596 Ada arrays map directly to C arrays.
12599 Ada records map directly to C structures.
12602 Packed Ada records map to C structures where all members are bit fields
12603 of the length corresponding to the @code{@var{type}'Size} value in Ada.
12606 @node Interfacing to C++
12607 @section Interfacing to C++
12610 The interface to C++ makes use of the following pragmas, which are
12611 primarily intended to be constructed automatically using a binding generator
12612 tool, although it is possible to construct them by hand. No suitable binding
12613 generator tool is supplied with GNAT though.
12615 Using these pragmas it is possible to achieve complete
12616 inter-operability between Ada tagged types and C class definitions.
12617 See @ref{Implementation Defined Pragmas}, for more details.
12620 @item pragma CPP_Class ([Entity =>] @var{local_name})
12621 The argument denotes an entity in the current declarative region that is
12622 declared as a tagged or untagged record type. It indicates that the type
12623 corresponds to an externally declared C++ class type, and is to be laid
12624 out the same way that C++ would lay out the type.
12626 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
12627 This pragma identifies an imported function (imported in the usual way
12628 with pragma @code{Import}) as corresponding to a C++ constructor.
12630 @item pragma CPP_Vtable @dots{}
12631 One @code{CPP_Vtable} pragma can be present for each component of type
12632 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
12636 @node Interfacing to COBOL
12637 @section Interfacing to COBOL
12640 Interfacing to COBOL is achieved as described in section B.4 of
12641 the Ada 95 reference manual.
12643 @node Interfacing to Fortran
12644 @section Interfacing to Fortran
12647 Interfacing to Fortran is achieved as described in section B.5 of the
12648 reference manual. The pragma @code{Convention Fortran}, applied to a
12649 multi-dimensional array causes the array to be stored in column-major
12650 order as required for convenient interface to Fortran.
12652 @node Interfacing to non-GNAT Ada code
12653 @section Interfacing to non-GNAT Ada code
12655 It is possible to specify the convention @code{Ada} in a pragma
12656 @code{Import} or pragma @code{Export}. However this refers to
12657 the calling conventions used by GNAT, which may or may not be
12658 similar enough to those used by some other Ada 83 or Ada 95
12659 compiler to allow interoperation.
12661 If arguments types are kept simple, and if the foreign compiler generally
12662 follows system calling conventions, then it may be possible to integrate
12663 files compiled by other Ada compilers, provided that the elaboration
12664 issues are adequately addressed (for example by eliminating the
12665 need for any load time elaboration).
12667 In particular, GNAT running on VMS is designed to
12668 be highly compatible with the DEC Ada 83 compiler, so this is one
12669 case in which it is possible to import foreign units of this type,
12670 provided that the data items passed are restricted to simple scalar
12671 values or simple record types without variants, or simple array
12672 types with fixed bounds.
12674 @node Specialized Needs Annexes
12675 @chapter Specialized Needs Annexes
12678 Ada 95 defines a number of specialized needs annexes, which are not
12679 required in all implementations. However, as described in this chapter,
12680 GNAT implements all of these special needs annexes:
12683 @item Systems Programming (Annex C)
12684 The Systems Programming Annex is fully implemented.
12686 @item Real-Time Systems (Annex D)
12687 The Real-Time Systems Annex is fully implemented.
12689 @item Distributed Systems (Annex E)
12690 Stub generation is fully implemented in the GNAT compiler. In addition,
12691 a complete compatible PCS is available as part of the GLADE system,
12692 a separate product. When the two
12693 products are used in conjunction, this annex is fully implemented.
12695 @item Information Systems (Annex F)
12696 The Information Systems annex is fully implemented.
12698 @item Numerics (Annex G)
12699 The Numerics Annex is fully implemented.
12701 @item Safety and Security (Annex H)
12702 The Safety and Security annex is fully implemented.
12705 @node Implementation of Specific Ada Features
12706 @chapter Implementation of Specific Ada Features
12709 This chapter describes the GNAT implementation of several Ada language
12713 * Machine Code Insertions::
12714 * GNAT Implementation of Tasking::
12715 * GNAT Implementation of Shared Passive Packages::
12716 * Code Generation for Array Aggregates::
12719 @node Machine Code Insertions
12720 @section Machine Code Insertions
12723 Package @code{Machine_Code} provides machine code support as described
12724 in the Ada 95 Reference Manual in two separate forms:
12727 Machine code statements, consisting of qualified expressions that
12728 fit the requirements of RM section 13.8.
12730 An intrinsic callable procedure, providing an alternative mechanism of
12731 including machine instructions in a subprogram.
12735 The two features are similar, and both are closely related to the mechanism
12736 provided by the asm instruction in the GNU C compiler. Full understanding
12737 and use of the facilities in this package requires understanding the asm
12738 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
12739 by Richard Stallman. The relevant section is titled ``Extensions to the C
12740 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
12742 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
12743 semantic restrictions and effects as described below. Both are provided so
12744 that the procedure call can be used as a statement, and the function call
12745 can be used to form a code_statement.
12747 The first example given in the GCC documentation is the C @code{asm}
12750 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
12754 The equivalent can be written for GNAT as:
12756 @smallexample @c ada
12757 Asm ("fsinx %1 %0",
12758 My_Float'Asm_Output ("=f", result),
12759 My_Float'Asm_Input ("f", angle));
12763 The first argument to @code{Asm} is the assembler template, and is
12764 identical to what is used in GNU C@. This string must be a static
12765 expression. The second argument is the output operand list. It is
12766 either a single @code{Asm_Output} attribute reference, or a list of such
12767 references enclosed in parentheses (technically an array aggregate of
12770 The @code{Asm_Output} attribute denotes a function that takes two
12771 parameters. The first is a string, the second is the name of a variable
12772 of the type designated by the attribute prefix. The first (string)
12773 argument is required to be a static expression and designates the
12774 constraint for the parameter (e.g.@: what kind of register is
12775 required). The second argument is the variable to be updated with the
12776 result. The possible values for constraint are the same as those used in
12777 the RTL, and are dependent on the configuration file used to build the
12778 GCC back end. If there are no output operands, then this argument may
12779 either be omitted, or explicitly given as @code{No_Output_Operands}.
12781 The second argument of @code{@var{my_float}'Asm_Output} functions as
12782 though it were an @code{out} parameter, which is a little curious, but
12783 all names have the form of expressions, so there is no syntactic
12784 irregularity, even though normally functions would not be permitted
12785 @code{out} parameters. The third argument is the list of input
12786 operands. It is either a single @code{Asm_Input} attribute reference, or
12787 a list of such references enclosed in parentheses (technically an array
12788 aggregate of such references).
12790 The @code{Asm_Input} attribute denotes a function that takes two
12791 parameters. The first is a string, the second is an expression of the
12792 type designated by the prefix. The first (string) argument is required
12793 to be a static expression, and is the constraint for the parameter,
12794 (e.g.@: what kind of register is required). The second argument is the
12795 value to be used as the input argument. The possible values for the
12796 constant are the same as those used in the RTL, and are dependent on
12797 the configuration file used to built the GCC back end.
12799 If there are no input operands, this argument may either be omitted, or
12800 explicitly given as @code{No_Input_Operands}. The fourth argument, not
12801 present in the above example, is a list of register names, called the
12802 @dfn{clobber} argument. This argument, if given, must be a static string
12803 expression, and is a space or comma separated list of names of registers
12804 that must be considered destroyed as a result of the @code{Asm} call. If
12805 this argument is the null string (the default value), then the code
12806 generator assumes that no additional registers are destroyed.
12808 The fifth argument, not present in the above example, called the
12809 @dfn{volatile} argument, is by default @code{False}. It can be set to
12810 the literal value @code{True} to indicate to the code generator that all
12811 optimizations with respect to the instruction specified should be
12812 suppressed, and that in particular, for an instruction that has outputs,
12813 the instruction will still be generated, even if none of the outputs are
12814 used. See the full description in the GCC manual for further details.
12816 The @code{Asm} subprograms may be used in two ways. First the procedure
12817 forms can be used anywhere a procedure call would be valid, and
12818 correspond to what the RM calls ``intrinsic'' routines. Such calls can
12819 be used to intersperse machine instructions with other Ada statements.
12820 Second, the function forms, which return a dummy value of the limited
12821 private type @code{Asm_Insn}, can be used in code statements, and indeed
12822 this is the only context where such calls are allowed. Code statements
12823 appear as aggregates of the form:
12825 @smallexample @c ada
12826 Asm_Insn'(Asm (@dots{}));
12827 Asm_Insn'(Asm_Volatile (@dots{}));
12831 In accordance with RM rules, such code statements are allowed only
12832 within subprograms whose entire body consists of such statements. It is
12833 not permissible to intermix such statements with other Ada statements.
12835 Typically the form using intrinsic procedure calls is more convenient
12836 and more flexible. The code statement form is provided to meet the RM
12837 suggestion that such a facility should be made available. The following
12838 is the exact syntax of the call to @code{Asm}. As usual, if named notation
12839 is used, the arguments may be given in arbitrary order, following the
12840 normal rules for use of positional and named arguments)
12844 [Template =>] static_string_EXPRESSION
12845 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
12846 [,[Inputs =>] INPUT_OPERAND_LIST ]
12847 [,[Clobber =>] static_string_EXPRESSION ]
12848 [,[Volatile =>] static_boolean_EXPRESSION] )
12850 OUTPUT_OPERAND_LIST ::=
12851 [PREFIX.]No_Output_Operands
12852 | OUTPUT_OPERAND_ATTRIBUTE
12853 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
12855 OUTPUT_OPERAND_ATTRIBUTE ::=
12856 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
12858 INPUT_OPERAND_LIST ::=
12859 [PREFIX.]No_Input_Operands
12860 | INPUT_OPERAND_ATTRIBUTE
12861 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
12863 INPUT_OPERAND_ATTRIBUTE ::=
12864 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
12868 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
12869 are declared in the package @code{Machine_Code} and must be referenced
12870 according to normal visibility rules. In particular if there is no
12871 @code{use} clause for this package, then appropriate package name
12872 qualification is required.
12874 @node GNAT Implementation of Tasking
12875 @section GNAT Implementation of Tasking
12878 This chapter outlines the basic GNAT approach to tasking (in particular,
12879 a multi-layered library for portability) and discusses issues related
12880 to compliance with the Real-Time Systems Annex.
12883 * Mapping Ada Tasks onto the Underlying Kernel Threads::
12884 * Ensuring Compliance with the Real-Time Annex::
12887 @node Mapping Ada Tasks onto the Underlying Kernel Threads
12888 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
12891 GNAT's run-time support comprises two layers:
12894 @item GNARL (GNAT Run-time Layer)
12895 @item GNULL (GNAT Low-level Library)
12899 In GNAT, Ada's tasking services rely on a platform and OS independent
12900 layer known as GNARL@. This code is responsible for implementing the
12901 correct semantics of Ada's task creation, rendezvous, protected
12904 GNARL decomposes Ada's tasking semantics into simpler lower level
12905 operations such as create a thread, set the priority of a thread,
12906 yield, create a lock, lock/unlock, etc. The spec for these low-level
12907 operations constitutes GNULLI, the GNULL Interface. This interface is
12908 directly inspired from the POSIX real-time API@.
12910 If the underlying executive or OS implements the POSIX standard
12911 faithfully, the GNULL Interface maps as is to the services offered by
12912 the underlying kernel. Otherwise, some target dependent glue code maps
12913 the services offered by the underlying kernel to the semantics expected
12916 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
12917 key point is that each Ada task is mapped on a thread in the underlying
12918 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
12920 In addition Ada task priorities map onto the underlying thread priorities.
12921 Mapping Ada tasks onto the underlying kernel threads has several advantages:
12925 The underlying scheduler is used to schedule the Ada tasks. This
12926 makes Ada tasks as efficient as kernel threads from a scheduling
12930 Interaction with code written in C containing threads is eased
12931 since at the lowest level Ada tasks and C threads map onto the same
12932 underlying kernel concept.
12935 When an Ada task is blocked during I/O the remaining Ada tasks are
12939 On multiprocessor systems Ada tasks can execute in parallel.
12943 Some threads libraries offer a mechanism to fork a new process, with the
12944 child process duplicating the threads from the parent.
12946 support this functionality when the parent contains more than one task.
12947 @cindex Forking a new process
12949 @node Ensuring Compliance with the Real-Time Annex
12950 @subsection Ensuring Compliance with the Real-Time Annex
12951 @cindex Real-Time Systems Annex compliance
12954 Although mapping Ada tasks onto
12955 the underlying threads has significant advantages, it does create some
12956 complications when it comes to respecting the scheduling semantics
12957 specified in the real-time annex (Annex D).
12959 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
12960 scheduling policy states:
12963 @emph{When the active priority of a ready task that is not running
12964 changes, or the setting of its base priority takes effect, the
12965 task is removed from the ready queue for its old active priority
12966 and is added at the tail of the ready queue for its new active
12967 priority, except in the case where the active priority is lowered
12968 due to the loss of inherited priority, in which case the task is
12969 added at the head of the ready queue for its new active priority.}
12973 While most kernels do put tasks at the end of the priority queue when
12974 a task changes its priority, (which respects the main
12975 FIFO_Within_Priorities requirement), almost none keep a thread at the
12976 beginning of its priority queue when its priority drops from the loss
12977 of inherited priority.
12979 As a result most vendors have provided incomplete Annex D implementations.
12981 The GNAT run-time, has a nice cooperative solution to this problem
12982 which ensures that accurate FIFO_Within_Priorities semantics are
12985 The principle is as follows. When an Ada task T is about to start
12986 running, it checks whether some other Ada task R with the same
12987 priority as T has been suspended due to the loss of priority
12988 inheritance. If this is the case, T yields and is placed at the end of
12989 its priority queue. When R arrives at the front of the queue it
12992 Note that this simple scheme preserves the relative order of the tasks
12993 that were ready to execute in the priority queue where R has been
12996 @node GNAT Implementation of Shared Passive Packages
12997 @section GNAT Implementation of Shared Passive Packages
12998 @cindex Shared passive packages
13001 GNAT fully implements the pragma @code{Shared_Passive} for
13002 @cindex pragma @code{Shared_Passive}
13003 the purpose of designating shared passive packages.
13004 This allows the use of passive partitions in the
13005 context described in the Ada Reference Manual; i.e. for communication
13006 between separate partitions of a distributed application using the
13007 features in Annex E.
13009 @cindex Distribution Systems Annex
13011 However, the implementation approach used by GNAT provides for more
13012 extensive usage as follows:
13015 @item Communication between separate programs
13017 This allows separate programs to access the data in passive
13018 partitions, using protected objects for synchronization where
13019 needed. The only requirement is that the two programs have a
13020 common shared file system. It is even possible for programs
13021 running on different machines with different architectures
13022 (e.g. different endianness) to communicate via the data in
13023 a passive partition.
13025 @item Persistence between program runs
13027 The data in a passive package can persist from one run of a
13028 program to another, so that a later program sees the final
13029 values stored by a previous run of the same program.
13034 The implementation approach used is to store the data in files. A
13035 separate stream file is created for each object in the package, and
13036 an access to an object causes the corresponding file to be read or
13039 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
13040 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
13041 set to the directory to be used for these files.
13042 The files in this directory
13043 have names that correspond to their fully qualified names. For
13044 example, if we have the package
13046 @smallexample @c ada
13048 pragma Shared_Passive (X);
13055 and the environment variable is set to @code{/stemp/}, then the files created
13056 will have the names:
13064 These files are created when a value is initially written to the object, and
13065 the files are retained until manually deleted. This provides the persistence
13066 semantics. If no file exists, it means that no partition has assigned a value
13067 to the variable; in this case the initial value declared in the package
13068 will be used. This model ensures that there are no issues in synchronizing
13069 the elaboration process, since elaboration of passive packages elaborates the
13070 initial values, but does not create the files.
13072 The files are written using normal @code{Stream_IO} access.
13073 If you want to be able
13074 to communicate between programs or partitions running on different
13075 architectures, then you should use the XDR versions of the stream attribute
13076 routines, since these are architecture independent.
13078 If active synchronization is required for access to the variables in the
13079 shared passive package, then as described in the Ada Reference Manual, the
13080 package may contain protected objects used for this purpose. In this case
13081 a lock file (whose name is @file{___lock} (three underscores)
13082 is created in the shared memory directory.
13083 @cindex @file{___lock} file (for shared passive packages)
13084 This is used to provide the required locking
13085 semantics for proper protected object synchronization.
13087 As of January 2003, GNAT supports shared passive packages on all platforms
13088 except for OpenVMS.
13090 @node Code Generation for Array Aggregates
13091 @section Code Generation for Array Aggregates
13094 * Static constant aggregates with static bounds::
13095 * Constant aggregates with an unconstrained nominal types::
13096 * Aggregates with static bounds::
13097 * Aggregates with non-static bounds::
13098 * Aggregates in assignment statements::
13102 Aggregate have a rich syntax and allow the user to specify the values of
13103 complex data structures by means of a single construct. As a result, the
13104 code generated for aggregates can be quite complex and involve loops, case
13105 statements and multiple assignments. In the simplest cases, however, the
13106 compiler will recognize aggregates whose components and constraints are
13107 fully static, and in those cases the compiler will generate little or no
13108 executable code. The following is an outline of the code that GNAT generates
13109 for various aggregate constructs. For further details, the user will find it
13110 useful to examine the output produced by the -gnatG flag to see the expanded
13111 source that is input to the code generator. The user will also want to examine
13112 the assembly code generated at various levels of optimization.
13114 The code generated for aggregates depends on the context, the component values,
13115 and the type. In the context of an object declaration the code generated is
13116 generally simpler than in the case of an assignment. As a general rule, static
13117 component values and static subtypes also lead to simpler code.
13119 @node Static constant aggregates with static bounds
13120 @subsection Static constant aggregates with static bounds
13123 For the declarations:
13124 @smallexample @c ada
13125 type One_Dim is array (1..10) of integer;
13126 ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
13130 GNAT generates no executable code: the constant ar0 is placed in static memory.
13131 The same is true for constant aggregates with named associations:
13133 @smallexample @c ada
13134 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
13135 Cr3 : constant One_Dim := (others => 7777);
13139 The same is true for multidimensional constant arrays such as:
13141 @smallexample @c ada
13142 type two_dim is array (1..3, 1..3) of integer;
13143 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
13147 The same is true for arrays of one-dimensional arrays: the following are
13150 @smallexample @c ada
13151 type ar1b is array (1..3) of boolean;
13152 type ar_ar is array (1..3) of ar1b;
13153 None : constant ar1b := (others => false); -- fully static
13154 None2 : constant ar_ar := (1..3 => None); -- fully static
13158 However, for multidimensional aggregates with named associations, GNAT will
13159 generate assignments and loops, even if all associations are static. The
13160 following two declarations generate a loop for the first dimension, and
13161 individual component assignments for the second dimension:
13163 @smallexample @c ada
13164 Zero1: constant two_dim := (1..3 => (1..3 => 0));
13165 Zero2: constant two_dim := (others => (others => 0));
13168 @node Constant aggregates with an unconstrained nominal types
13169 @subsection Constant aggregates with an unconstrained nominal types
13172 In such cases the aggregate itself establishes the subtype, so that
13173 associations with @code{others} cannot be used. GNAT determines the
13174 bounds for the actual subtype of the aggregate, and allocates the
13175 aggregate statically as well. No code is generated for the following:
13177 @smallexample @c ada
13178 type One_Unc is array (natural range <>) of integer;
13179 Cr_Unc : constant One_Unc := (12,24,36);
13182 @node Aggregates with static bounds
13183 @subsection Aggregates with static bounds
13186 In all previous examples the aggregate was the initial (and immutable) value
13187 of a constant. If the aggregate initializes a variable, then code is generated
13188 for it as a combination of individual assignments and loops over the target
13189 object. The declarations
13191 @smallexample @c ada
13192 Cr_Var1 : One_Dim := (2, 5, 7, 11);
13193 Cr_Var2 : One_Dim := (others > -1);
13197 generate the equivalent of
13199 @smallexample @c ada
13205 for I in Cr_Var2'range loop
13206 Cr_Var2 (I) := =-1;
13210 @node Aggregates with non-static bounds
13211 @subsection Aggregates with non-static bounds
13214 If the bounds of the aggregate are not statically compatible with the bounds
13215 of the nominal subtype of the target, then constraint checks have to be
13216 generated on the bounds. For a multidimensional array, constraint checks may
13217 have to be applied to sub-arrays individually, if they do not have statically
13218 compatible subtypes.
13220 @node Aggregates in assignment statements
13221 @subsection Aggregates in assignment statements
13224 In general, aggregate assignment requires the construction of a temporary,
13225 and a copy from the temporary to the target of the assignment. This is because
13226 it is not always possible to convert the assignment into a series of individual
13227 component assignments. For example, consider the simple case:
13229 @smallexample @c ada
13234 This cannot be converted into:
13236 @smallexample @c ada
13242 So the aggregate has to be built first in a separate location, and then
13243 copied into the target. GNAT recognizes simple cases where this intermediate
13244 step is not required, and the assignments can be performed in place, directly
13245 into the target. The following sufficient criteria are applied:
13249 The bounds of the aggregate are static, and the associations are static.
13251 The components of the aggregate are static constants, names of
13252 simple variables that are not renamings, or expressions not involving
13253 indexed components whose operands obey these rules.
13257 If any of these conditions are violated, the aggregate will be built in
13258 a temporary (created either by the front-end or the code generator) and then
13259 that temporary will be copied onto the target.
13261 @node Project File Reference
13262 @chapter Project File Reference
13265 This chapter describes the syntax and semantics of project files.
13266 Project files specify the options to be used when building a system.
13267 Project files can specify global settings for all tools,
13268 as well as tool-specific settings.
13269 See the chapter on project files in the GNAT Users guide for examples of use.
13273 * Lexical Elements::
13275 * Typed string declarations::
13279 * Project Attributes::
13280 * Attribute References::
13281 * External Values::
13282 * Case Construction::
13284 * Package Renamings::
13286 * Project Extensions::
13287 * Project File Elaboration::
13290 @node Reserved Words
13291 @section Reserved Words
13294 All Ada95 reserved words are reserved in project files, and cannot be used
13295 as variable names or project names. In addition, the following are
13296 also reserved in project files:
13299 @item @code{extends}
13301 @item @code{external}
13303 @item @code{project}
13307 @node Lexical Elements
13308 @section Lexical Elements
13311 Rules for identifiers are the same as in Ada95. Identifiers
13312 are case-insensitive. Strings are case sensitive, except where noted.
13313 Comments have the same form as in Ada95.
13323 simple_name @{. simple_name@}
13327 @section Declarations
13330 Declarations introduce new entities that denote types, variables, attributes,
13331 and packages. Some declarations can only appear immediately within a project
13332 declaration. Others can appear within a project or within a package.
13336 declarative_item ::=
13337 simple_declarative_item |
13338 typed_string_declaration |
13339 package_declaration
13341 simple_declarative_item ::=
13342 variable_declaration |
13343 typed_variable_declaration |
13344 attribute_declaration |
13348 @node Typed string declarations
13349 @section Typed string declarations
13352 Typed strings are sequences of string literals. Typed strings are the only
13353 named types in project files. They are used in case constructions, where they
13354 provide support for conditional attribute definitions.
13358 typed_string_declaration ::=
13359 @b{type} <typed_string_>_simple_name @b{is}
13360 ( string_literal @{, string_literal@} );
13364 A typed string declaration can only appear immediately within a project
13367 All the string literals in a typed string declaration must be distinct.
13373 Variables denote values, and appear as constituents of expressions.
13376 typed_variable_declaration ::=
13377 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
13379 variable_declaration ::=
13380 <variable_>simple_name := expression;
13384 The elaboration of a variable declaration introduces the variable and
13385 assigns to it the value of the expression. The name of the variable is
13386 available after the assignment symbol.
13389 A typed_variable can only be declare once.
13392 a non typed variable can be declared multiple times.
13395 Before the completion of its first declaration, the value of variable
13396 is the null string.
13399 @section Expressions
13402 An expression is a formula that defines a computation or retrieval of a value.
13403 In a project file the value of an expression is either a string or a list
13404 of strings. A string value in an expression is either a literal, the current
13405 value of a variable, an external value, an attribute reference, or a
13406 concatenation operation.
13419 attribute_reference
13425 ( <string_>expression @{ , <string_>expression @} )
13428 @subsection Concatenation
13430 The following concatenation functions are defined:
13432 @smallexample @c ada
13433 function "&" (X : String; Y : String) return String;
13434 function "&" (X : String_List; Y : String) return String_List;
13435 function "&" (X : String_List; Y : String_List) return String_List;
13439 @section Attributes
13442 An attribute declaration defines a property of a project or package. This
13443 property can later be queried by means of an attribute reference.
13444 Attribute values are strings or string lists.
13446 Some attributes are associative arrays. These attributes are mappings whose
13447 domain is a set of strings. These attributes are declared one association
13448 at a time, by specifying a point in the domain and the corresponding image
13449 of the attribute. They may also be declared as a full associative array,
13450 getting the same associations as the corresponding attribute in an imported
13451 or extended project.
13453 Attributes that are not associative arrays are called simple attributes.
13457 attribute_declaration ::=
13458 full_associative_array_declaration |
13459 @b{for} attribute_designator @b{use} expression ;
13461 full_associative_array_declaration ::=
13462 @b{for} <associative_array_attribute_>simple_name @b{use}
13463 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
13465 attribute_designator ::=
13466 <simple_attribute_>simple_name |
13467 <associative_array_attribute_>simple_name ( string_literal )
13471 Some attributes are project-specific, and can only appear immediately within
13472 a project declaration. Others are package-specific, and can only appear within
13473 the proper package.
13475 The expression in an attribute definition must be a string or a string_list.
13476 The string literal appearing in the attribute_designator of an associative
13477 array attribute is case-insensitive.
13479 @node Project Attributes
13480 @section Project Attributes
13483 The following attributes apply to a project. All of them are simple
13488 Expression must be a path name. The attribute defines the
13489 directory in which the object files created by the build are to be placed. If
13490 not specified, object files are placed in the project directory.
13493 Expression must be a path name. The attribute defines the
13494 directory in which the executables created by the build are to be placed.
13495 If not specified, executables are placed in the object directory.
13498 Expression must be a list of path names. The attribute
13499 defines the directories in which the source files for the project are to be
13500 found. If not specified, source files are found in the project directory.
13503 Expression must be a list of file names. The attribute
13504 defines the individual files, in the project directory, which are to be used
13505 as sources for the project. File names are path_names that contain no directory
13506 information. If the project has no sources the attribute must be declared
13507 explicitly with an empty list.
13509 @item Source_List_File
13510 Expression must a single path name. The attribute
13511 defines a text file that contains a list of source file names to be used
13512 as sources for the project
13515 Expression must be a path name. The attribute defines the
13516 directory in which a library is to be built. The directory must exist, must
13517 be distinct from the project's object directory, and must be writable.
13520 Expression must be a string that is a legal file name,
13521 without extension. The attribute defines a string that is used to generate
13522 the name of the library to be built by the project.
13525 Argument must be a string value that must be one of the
13526 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
13527 string is case-insensitive. If this attribute is not specified, the library is
13528 a static library. Otherwise, the library may be dynamic or relocatable. This
13529 distinction is operating-system dependent.
13531 @item Library_Version
13532 Expression must be a string value whose interpretation
13533 is platform dependent. On UNIX, it is used only for dynamic/relocatable
13534 libraries as the internal name of the library (the @code{"soname"}). If the
13535 library file name (built from the @code{Library_Name}) is different from the
13536 @code{Library_Version}, then the library file will be a symbolic link to the
13537 actual file whose name will be @code{Library_Version}.
13539 @item Library_Interface
13540 Expression must be a string list. Each element of the string list
13541 must designate a unit of the project.
13542 If this attribute is present in a Library Project File, then the project
13543 file is a Stand-alone Library_Project_File.
13545 @item Library_Auto_Init
13546 Expression must be a single string "true" or "false", case-insensitive.
13547 If this attribute is present in a Stand-alone Library Project File,
13548 it indicates if initialization is automatic when the dynamic library
13551 @item Library_Options
13552 Expression must be a string list. Indicates additional switches that
13553 are to be used when building a shared library.
13556 Expression must be a single string. Designates an alternative to "gcc"
13557 for building shared libraries.
13559 @item Library_Src_Dir
13560 Expression must be a path name. The attribute defines the
13561 directory in which the sources of the interfaces of a Stand-alone Library will
13562 be copied. The directory must exist, must be distinct from the project's
13563 object directory and source directories, and must be writable.
13566 Expression must be a list of strings that are legal file names.
13567 These file names designate existing compilation units in the source directory
13568 that are legal main subprograms.
13570 When a project file is elaborated, as part of the execution of a gnatmake
13571 command, one or several executables are built and placed in the Exec_Dir.
13572 If the gnatmake command does not include explicit file names, the executables
13573 that are built correspond to the files specified by this attribute.
13575 @item Main_Language
13576 This is a simple attribute. Its value is a string that specifies the
13577 language of the main program.
13580 Expression must be a string list. Each string designates
13581 a programming language that is known to GNAT. The strings are case-insensitive.
13583 @item Locally_Removed_Files
13584 This attribute is legal only in a project file that extends another.
13585 Expression must be a list of strings that are legal file names.
13586 Each file name must designate a source that would normally be inherited
13587 by the current project file. It cannot designate an immediate source that is
13588 not inherited. Each of the source files in the list are not considered to
13589 be sources of the project file: they are not inherited.
13592 @node Attribute References
13593 @section Attribute References
13596 Attribute references are used to retrieve the value of previously defined
13597 attribute for a package or project.
13600 attribute_reference ::=
13601 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
13603 attribute_prefix ::=
13605 <project_simple_name | package_identifier |
13606 <project_>simple_name . package_identifier
13610 If an attribute has not been specified for a given package or project, its
13611 value is the null string or the empty list.
13613 @node External Values
13614 @section External Values
13617 An external value is an expression whose value is obtained from the command
13618 that invoked the processing of the current project file (typically a
13624 @b{external} ( string_literal [, string_literal] )
13628 The first string_literal is the string to be used on the command line or
13629 in the environment to specify the external value. The second string_literal,
13630 if present, is the default to use if there is no specification for this
13631 external value either on the command line or in the environment.
13633 @node Case Construction
13634 @section Case Construction
13637 A case construction supports attribute declarations that depend on the value of
13638 a previously declared variable.
13642 case_construction ::=
13643 @b{case} <typed_variable_>name @b{is}
13648 @b{when} discrete_choice_list =>
13649 @{case_construction | attribute_declaration@}
13651 discrete_choice_list ::=
13652 string_literal @{| string_literal@} |
13657 All choices in a choice list must be distinct. The choice lists of two
13658 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
13659 alternatives do not need to include all values of the type. An @code{others}
13660 choice must appear last in the list of alternatives.
13666 A package provides a grouping of variable declarations and attribute
13667 declarations to be used when invoking various GNAT tools. The name of
13668 the package indicates the tool(s) to which it applies.
13672 package_declaration ::=
13673 package_specification | package_renaming
13675 package_specification ::=
13676 @b{package} package_identifier @b{is}
13677 @{simple_declarative_item@}
13678 @b{end} package_identifier ;
13680 package_identifier ::=
13681 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
13682 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
13683 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
13686 @subsection Package Naming
13689 The attributes of a @code{Naming} package specifies the naming conventions
13690 that apply to the source files in a project. When invoking other GNAT tools,
13691 they will use the sources in the source directories that satisfy these
13692 naming conventions.
13694 The following attributes apply to a @code{Naming} package:
13698 This is a simple attribute whose value is a string. Legal values of this
13699 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
13700 These strings are themselves case insensitive.
13703 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
13705 @item Dot_Replacement
13706 This is a simple attribute whose string value satisfies the following
13710 @item It must not be empty
13711 @item It cannot start or end with an alphanumeric character
13712 @item It cannot be a single underscore
13713 @item It cannot start with an underscore followed by an alphanumeric
13714 @item It cannot contain a dot @code{'.'} if longer than one character
13718 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
13721 This is an associative array attribute, defined on language names,
13722 whose image is a string that must satisfy the following
13726 @item It must not be empty
13727 @item It cannot start with an alphanumeric character
13728 @item It cannot start with an underscore followed by an alphanumeric character
13732 For Ada, the attribute denotes the suffix used in file names that contain
13733 library unit declarations, that is to say units that are package and
13734 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
13735 specified, then the default is @code{".ads"}.
13737 For C and C++, the attribute denotes the suffix used in file names that
13738 contain prototypes.
13741 This is an associative array attribute defined on language names,
13742 whose image is a string that must satisfy the following
13746 @item It must not be empty
13747 @item It cannot start with an alphanumeric character
13748 @item It cannot start with an underscore followed by an alphanumeric character
13749 @item It cannot be a suffix of @code{Spec_Suffix}
13753 For Ada, the attribute denotes the suffix used in file names that contain
13754 library bodies, that is to say units that are package and subprogram bodies.
13755 If @code{Body_Suffix ("Ada")} is not specified, then the default is
13758 For C and C++, the attribute denotes the suffix used in file names that contain
13761 @item Separate_Suffix
13762 This is a simple attribute whose value satisfies the same conditions as
13763 @code{Body_Suffix}.
13765 This attribute is specific to Ada. It denotes the suffix used in file names
13766 that contain separate bodies. If it is not specified, then it defaults to same
13767 value as @code{Body_Suffix ("Ada")}.
13770 This is an associative array attribute, specific to Ada, defined over
13771 compilation unit names. The image is a string that is the name of the file
13772 that contains that library unit. The file name is case sensitive if the
13773 conventions of the host operating system require it.
13776 This is an associative array attribute, specific to Ada, defined over
13777 compilation unit names. The image is a string that is the name of the file
13778 that contains the library unit body for the named unit. The file name is case
13779 sensitive if the conventions of the host operating system require it.
13781 @item Specification_Exceptions
13782 This is an associative array attribute defined on language names,
13783 whose value is a list of strings.
13785 This attribute is not significant for Ada.
13787 For C and C++, each string in the list denotes the name of a file that
13788 contains prototypes, but whose suffix is not necessarily the
13789 @code{Spec_Suffix} for the language.
13791 @item Implementation_Exceptions
13792 This is an associative array attribute defined on language names,
13793 whose value is a list of strings.
13795 This attribute is not significant for Ada.
13797 For C and C++, each string in the list denotes the name of a file that
13798 contains source code, but whose suffix is not necessarily the
13799 @code{Body_Suffix} for the language.
13802 The following attributes of package @code{Naming} are obsolescent. They are
13803 kept as synonyms of other attributes for compatibility with previous versions
13804 of the Project Manager.
13807 @item Specification_Suffix
13808 This is a synonym of @code{Spec_Suffix}.
13810 @item Implementation_Suffix
13811 This is a synonym of @code{Body_Suffix}.
13813 @item Specification
13814 This is a synonym of @code{Spec}.
13816 @item Implementation
13817 This is a synonym of @code{Body}.
13820 @subsection package Compiler
13823 The attributes of the @code{Compiler} package specify the compilation options
13824 to be used by the underlying compiler.
13827 @item Default_Switches
13828 This is an associative array attribute. Its
13829 domain is a set of language names. Its range is a string list that
13830 specifies the compilation options to be used when compiling a component
13831 written in that language, for which no file-specific switches have been
13835 This is an associative array attribute. Its domain is
13836 a set of file names. Its range is a string list that specifies the
13837 compilation options to be used when compiling the named file. If a file
13838 is not specified in the Switches attribute, it is compiled with the
13839 settings specified by Default_Switches.
13841 @item Local_Configuration_Pragmas.
13842 This is a simple attribute, whose
13843 value is a path name that designates a file containing configuration pragmas
13844 to be used for all invocations of the compiler for immediate sources of the
13848 This is an associative array attribute. Its domain is
13849 a set of main source file names. Its range is a simple string that specifies
13850 the executable file name to be used when linking the specified main source.
13851 If a main source is not specified in the Executable attribute, the executable
13852 file name is deducted from the main source file name.
13855 @subsection package Builder
13858 The attributes of package @code{Builder} specify the compilation, binding, and
13859 linking options to be used when building an executable for a project. The
13860 following attributes apply to package @code{Builder}:
13863 @item Default_Switches
13869 @item Global_Configuration_Pragmas
13870 This is a simple attribute, whose
13871 value is a path name that designates a file that contains configuration pragmas
13872 to be used in every build of an executable. If both local and global
13873 configuration pragmas are specified, a compilation makes use of both sets.
13876 This is an associative array attribute, defined over
13877 compilation unit names. The image is a string that is the name of the
13878 executable file corresponding to the main source file index.
13879 This attribute has no effect if its value is the empty string.
13881 @item Executable_Suffix
13882 This is a simple attribute whose value is a suffix to be added to
13883 the executables that don't have an attribute Executable specified.
13886 @subsection package Gnatls
13889 The attributes of package @code{Gnatls} specify the tool options to be used
13890 when invoking the library browser @command{gnatls}.
13891 The following attributes apply to package @code{Gnatls}:
13898 @subsection package Binder
13901 The attributes of package @code{Binder} specify the options to be used
13902 when invoking the binder in the construction of an executable.
13903 The following attributes apply to package @code{Binder}:
13906 @item Default_Switches
13912 @subsection package Linker
13915 The attributes of package @code{Linker} specify the options to be used when
13916 invoking the linker in the construction of an executable.
13917 The following attributes apply to package @code{Linker}:
13920 @item Default_Switches
13926 @subsection package Cross_Reference
13929 The attributes of package @code{Cross_Reference} specify the tool options
13931 when invoking the library tool @command{gnatxref}.
13932 The following attributes apply to package @code{Cross_Reference}:
13935 @item Default_Switches
13941 @subsection package Finder
13944 The attributes of package @code{Finder} specify the tool options to be used
13945 when invoking the search tool @command{gnatfind}.
13946 The following attributes apply to package @code{Finder}:
13949 @item Default_Switches
13955 @subsection package Pretty_Printer
13958 The attributes of package @code{Pretty_Printer}
13959 specify the tool options to be used
13960 when invoking the formatting tool @command{gnatpp}.
13961 The following attributes apply to package @code{Pretty_Printer}:
13964 @item Default_switches
13970 @subsection package IDE
13973 The attributes of package @code{IDE} specify the options to be used when using
13974 an Integrated Development Environment such as @command{GPS}.
13978 This is a simple attribute. Its value is a string that designates the remote
13979 host in a cross-compilation environment, to be used for remote compilation and
13980 debugging. This field should not be specified when running on the local
13984 This is a simple attribute. Its value is a string that specifies the
13985 name of IP address of the embedded target in a cross-compilation environment,
13986 on which the program should execute.
13988 @item Communication_Protocol
13989 This is a simple string attribute. Its value is the name of the protocol
13990 to use to communicate with the target in a cross-compilation environment,
13991 e.g. @code{"wtx"} or @code{"vxworks"}.
13993 @item Compiler_Command
13994 This is an associative array attribute, whose domain is a language name. Its
13995 value is string that denotes the command to be used to invoke the compiler.
13996 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
13997 gnatmake, in particular in the handling of switches.
13999 @item Debugger_Command
14000 This is simple attribute, Its value is a string that specifies the name of
14001 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
14003 @item Default_Switches
14004 This is an associative array attribute. Its indexes are the name of the
14005 external tools that the GNAT Programming System (GPS) is supporting. Its
14006 value is a list of switches to use when invoking that tool.
14009 This is a simple attribute. Its value is a string that specifies the name
14010 of the @command{gnatls} utility to be used to retrieve information about the
14011 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
14014 This is a simple atribute. Is value is a string used to specify the
14015 Version Control System (VCS) to be used for this project, e.g CVS, RCS
14016 ClearCase or Perforce.
14018 @item VCS_File_Check
14019 This is a simple attribute. Its value is a string that specifies the
14020 command used by the VCS to check the validity of a file, either
14021 when the user explicitly asks for a check, or as a sanity check before
14022 doing the check-in.
14024 @item VCS_Log_Check
14025 This is a simple attribute. Its value is a string that specifies
14026 the command used by the VCS to check the validity of a log file.
14030 @node Package Renamings
14031 @section Package Renamings
14034 A package can be defined by a renaming declaration. The new package renames
14035 a package declared in a different project file, and has the same attributes
14036 as the package it renames.
14039 package_renaming ::==
14040 @b{package} package_identifier @b{renames}
14041 <project_>simple_name.package_identifier ;
14045 The package_identifier of the renamed package must be the same as the
14046 package_identifier. The project whose name is the prefix of the renamed
14047 package must contain a package declaration with this name. This project
14048 must appear in the context_clause of the enclosing project declaration,
14049 or be the parent project of the enclosing child project.
14055 A project file specifies a set of rules for constructing a software system.
14056 A project file can be self-contained, or depend on other project files.
14057 Dependencies are expressed through a context clause that names other projects.
14063 context_clause project_declaration
14065 project_declaration ::=
14066 simple_project_declaration | project_extension
14068 simple_project_declaration ::=
14069 @b{project} <project_>simple_name @b{is}
14070 @{declarative_item@}
14071 @b{end} <project_>simple_name;
14077 [@b{limited}] @b{with} path_name @{ , path_name @} ;
14084 A path name denotes a project file. A path name can be absolute or relative.
14085 An absolute path name includes a sequence of directories, in the syntax of
14086 the host operating system, that identifies uniquely the project file in the
14087 file system. A relative path name identifies the project file, relative
14088 to the directory that contains the current project, or relative to a
14089 directory listed in the environment variable ADA_PROJECT_PATH.
14090 Path names are case sensitive if file names in the host operating system
14091 are case sensitive.
14093 The syntax of the environment variable ADA_PROJECT_PATH is a list of
14094 directory names separated by colons (semicolons on Windows).
14096 A given project name can appear only once in a context_clause.
14098 It is illegal for a project imported by a context clause to refer, directly
14099 or indirectly, to the project in which this context clause appears (the
14100 dependency graph cannot contain cycles), except when one of the with_clause
14101 in the cycle is a @code{limited with}.
14103 @node Project Extensions
14104 @section Project Extensions
14107 A project extension introduces a new project, which inherits the declarations
14108 of another project.
14112 project_extension ::=
14113 @b{project} <project_>simple_name @b{extends} path_name @b{is}
14114 @{declarative_item@}
14115 @b{end} <project_>simple_name;
14119 The project extension declares a child project. The child project inherits
14120 all the declarations and all the files of the parent project, These inherited
14121 declaration can be overridden in the child project, by means of suitable
14124 @node Project File Elaboration
14125 @section Project File Elaboration
14128 A project file is processed as part of the invocation of a gnat tool that
14129 uses the project option. Elaboration of the process file consists in the
14130 sequential elaboration of all its declarations. The computed values of
14131 attributes and variables in the project are then used to establish the
14132 environment in which the gnat tool will execute.
14135 @c GNU Free Documentation License
14137 @node Index,,GNU Free Documentation License, Top