1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c Copyright (C) 1995-2005 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
22 @settitle GNAT Reference Manual
24 @setchapternewpage odd
27 @include gcc-common.texi
29 @dircategory GNU Ada tools
31 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
35 Copyright @copyright{} 1995-2004, Free Software Foundation
37 Permission is granted to copy, distribute and/or modify this document
38 under the terms of the GNU Free Documentation License, Version 1.2
39 or any later version published by the Free Software Foundation;
40 with the Invariant Sections being ``GNU Free Documentation License'',
41 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
42 no Back-Cover Texts. A copy of the license is included in the section
43 entitled ``GNU Free Documentation License''.
48 @title GNAT Reference Manual
49 @subtitle GNAT, The GNU Ada 95 Compiler
50 @subtitle GCC version @value{version-GCC}
51 @author Ada Core Technologies, Inc.
54 @vskip 0pt plus 1filll
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
68 GNAT, The GNU Ada 95 Compiler@*
69 GCC version @value{version-GCC}@*
76 * Implementation Defined Pragmas::
77 * Implementation Defined Attributes::
78 * Implementation Advice::
79 * Implementation Defined Characteristics::
80 * Intrinsic Subprograms::
81 * Representation Clauses and Pragmas::
82 * Standard Library Routines::
83 * The Implementation of Standard I/O::
85 * Interfacing to Other Languages::
86 * Specialized Needs Annexes::
87 * Implementation of Specific Ada Features::
88 * Project File Reference::
89 * Obsolescent Features::
90 * GNU Free Documentation License::
93 --- The Detailed Node Listing ---
97 * What This Reference Manual Contains::
98 * Related Information::
100 Implementation Defined Pragmas
102 * Pragma Abort_Defer::
109 * Pragma C_Pass_By_Copy::
111 * Pragma Common_Object::
112 * Pragma Compile_Time_Warning::
113 * Pragma Complete_Representation::
114 * Pragma Complex_Representation::
115 * Pragma Component_Alignment::
116 * Pragma Convention_Identifier::
118 * Pragma CPP_Constructor::
119 * Pragma CPP_Virtual::
120 * Pragma CPP_Vtable::
122 * Pragma Debug_Policy::
123 * Pragma Detect_Blocking::
124 * Pragma Elaboration_Checks::
126 * Pragma Export_Exception::
127 * Pragma Export_Function::
128 * Pragma Export_Object::
129 * Pragma Export_Procedure::
130 * Pragma Export_Value::
131 * Pragma Export_Valued_Procedure::
132 * Pragma Extend_System::
134 * Pragma External_Name_Casing::
135 * Pragma Finalize_Storage_Only::
136 * Pragma Float_Representation::
138 * Pragma Import_Exception::
139 * Pragma Import_Function::
140 * Pragma Import_Object::
141 * Pragma Import_Procedure::
142 * Pragma Import_Valued_Procedure::
143 * Pragma Initialize_Scalars::
144 * Pragma Inline_Always::
145 * Pragma Inline_Generic::
147 * Pragma Interface_Name::
148 * Pragma Interrupt_Handler::
149 * Pragma Interrupt_State::
150 * Pragma Keep_Names::
153 * Pragma Linker_Alias::
154 * Pragma Linker_Constructor::
155 * Pragma Linker_Destructor::
156 * Pragma Linker_Section::
157 * Pragma Long_Float::
158 * Pragma Machine_Attribute::
159 * Pragma Main_Storage::
161 * Pragma No_Strict_Aliasing ::
162 * Pragma Normalize_Scalars::
163 * Pragma Obsolescent::
165 * Pragma Persistent_BSS::
167 * Pragma Profile (Ravenscar)::
168 * Pragma Profile (Restricted)::
169 * Pragma Propagate_Exceptions::
170 * Pragma Psect_Object::
171 * Pragma Pure_Function::
172 * Pragma Restriction_Warnings::
173 * Pragma Source_File_Name::
174 * Pragma Source_File_Name_Project::
175 * Pragma Source_Reference::
176 * Pragma Stream_Convert::
177 * Pragma Style_Checks::
179 * Pragma Suppress_All::
180 * Pragma Suppress_Exception_Locations::
181 * Pragma Suppress_Initialization::
184 * Pragma Task_Storage::
185 * Pragma Thread_Body::
186 * Pragma Time_Slice::
188 * Pragma Unchecked_Union::
189 * Pragma Unimplemented_Unit::
190 * Pragma Universal_Data::
191 * Pragma Unreferenced::
192 * Pragma Unreserve_All_Interrupts::
193 * Pragma Unsuppress::
194 * Pragma Use_VADS_Size::
195 * Pragma Validity_Checks::
198 * Pragma Weak_External::
200 Implementation Defined Attributes
210 * Default_Bit_Order::
218 * Has_Access_Values::
219 * Has_Discriminants::
225 * Max_Interrupt_Priority::
227 * Maximum_Alignment::
231 * Passed_By_Reference::
242 * Unconstrained_Array::
243 * Universal_Literal_String::
244 * Unrestricted_Access::
250 The Implementation of Standard I/O
252 * Standard I/O Packages::
258 * Wide_Wide_Text_IO::
262 * Operations on C Streams::
263 * Interfacing to C Streams::
267 * Ada.Characters.Latin_9 (a-chlat9.ads)::
268 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
269 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
270 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
271 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
272 * Ada.Command_Line.Remove (a-colire.ads)::
273 * Ada.Command_Line.Environment (a-colien.ads)::
274 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
275 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
276 * Ada.Exceptions.Traceback (a-exctra.ads)::
277 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
278 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
279 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
280 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
281 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
282 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
283 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
284 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
285 * GNAT.Altivec (g-altive.ads)::
286 * GNAT.Altivec.Conversions (g-altcon.ads)::
287 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
288 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
289 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
290 * GNAT.Array_Split (g-arrspl.ads)::
291 * GNAT.AWK (g-awk.ads)::
292 * GNAT.Bounded_Buffers (g-boubuf.ads)::
293 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
294 * GNAT.Bubble_Sort (g-bubsor.ads)::
295 * GNAT.Bubble_Sort_A (g-busora.ads)::
296 * GNAT.Bubble_Sort_G (g-busorg.ads)::
297 * GNAT.Calendar (g-calend.ads)::
298 * GNAT.Calendar.Time_IO (g-catiio.ads)::
299 * GNAT.Case_Util (g-casuti.ads)::
300 * GNAT.CGI (g-cgi.ads)::
301 * GNAT.CGI.Cookie (g-cgicoo.ads)::
302 * GNAT.CGI.Debug (g-cgideb.ads)::
303 * GNAT.Command_Line (g-comlin.ads)::
304 * GNAT.Compiler_Version (g-comver.ads)::
305 * GNAT.Ctrl_C (g-ctrl_c.ads)::
306 * GNAT.CRC32 (g-crc32.ads)::
307 * GNAT.Current_Exception (g-curexc.ads)::
308 * GNAT.Debug_Pools (g-debpoo.ads)::
309 * GNAT.Debug_Utilities (g-debuti.ads)::
310 * GNAT.Directory_Operations (g-dirope.ads)::
311 * GNAT.Dynamic_HTables (g-dynhta.ads)::
312 * GNAT.Dynamic_Tables (g-dyntab.ads)::
313 * GNAT.Exception_Actions (g-excact.ads)::
314 * GNAT.Exception_Traces (g-exctra.ads)::
315 * GNAT.Exceptions (g-except.ads)::
316 * GNAT.Expect (g-expect.ads)::
317 * GNAT.Float_Control (g-flocon.ads)::
318 * GNAT.Heap_Sort (g-heasor.ads)::
319 * GNAT.Heap_Sort_A (g-hesora.ads)::
320 * GNAT.Heap_Sort_G (g-hesorg.ads)::
321 * GNAT.HTable (g-htable.ads)::
322 * GNAT.IO (g-io.ads)::
323 * GNAT.IO_Aux (g-io_aux.ads)::
324 * GNAT.Lock_Files (g-locfil.ads)::
325 * GNAT.MD5 (g-md5.ads)::
326 * GNAT.Memory_Dump (g-memdum.ads)::
327 * GNAT.Most_Recent_Exception (g-moreex.ads)::
328 * GNAT.OS_Lib (g-os_lib.ads)::
329 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
330 * GNAT.Regexp (g-regexp.ads)::
331 * GNAT.Registry (g-regist.ads)::
332 * GNAT.Regpat (g-regpat.ads)::
333 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
334 * GNAT.Semaphores (g-semaph.ads)::
335 * GNAT.Signals (g-signal.ads)::
336 * GNAT.Sockets (g-socket.ads)::
337 * GNAT.Source_Info (g-souinf.ads)::
338 * GNAT.Spell_Checker (g-speche.ads)::
339 * GNAT.Spitbol.Patterns (g-spipat.ads)::
340 * GNAT.Spitbol (g-spitbo.ads)::
341 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
342 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
343 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
344 * GNAT.Strings (g-string.ads)::
345 * GNAT.String_Split (g-strspl.ads)::
346 * GNAT.Table (g-table.ads)::
347 * GNAT.Task_Lock (g-tasloc.ads)::
348 * GNAT.Threads (g-thread.ads)::
349 * GNAT.Traceback (g-traceb.ads)::
350 * GNAT.Traceback.Symbolic (g-trasym.ads)::
351 * GNAT.Wide_String_Split (g-wistsp.ads)::
352 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
353 * Interfaces.C.Extensions (i-cexten.ads)::
354 * Interfaces.C.Streams (i-cstrea.ads)::
355 * Interfaces.CPP (i-cpp.ads)::
356 * Interfaces.Os2lib (i-os2lib.ads)::
357 * Interfaces.Os2lib.Errors (i-os2err.ads)::
358 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
359 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
360 * Interfaces.Packed_Decimal (i-pacdec.ads)::
361 * Interfaces.VxWorks (i-vxwork.ads)::
362 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
363 * System.Address_Image (s-addima.ads)::
364 * System.Assertions (s-assert.ads)::
365 * System.Memory (s-memory.ads)::
366 * System.Partition_Interface (s-parint.ads)::
367 * System.Restrictions (s-restri.ads)::
368 * System.Rident (s-rident.ads)::
369 * System.Task_Info (s-tasinf.ads)::
370 * System.Wch_Cnv (s-wchcnv.ads)::
371 * System.Wch_Con (s-wchcon.ads)::
375 * Text_IO Stream Pointer Positioning::
376 * Text_IO Reading and Writing Non-Regular Files::
378 * Treating Text_IO Files as Streams::
379 * Text_IO Extensions::
380 * Text_IO Facilities for Unbounded Strings::
384 * Wide_Text_IO Stream Pointer Positioning::
385 * Wide_Text_IO Reading and Writing Non-Regular Files::
389 * Wide_Wide_Text_IO Stream Pointer Positioning::
390 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
392 Interfacing to Other Languages
395 * Interfacing to C++::
396 * Interfacing to COBOL::
397 * Interfacing to Fortran::
398 * Interfacing to non-GNAT Ada code::
400 Specialized Needs Annexes
402 Implementation of Specific Ada Features
403 * Machine Code Insertions::
404 * GNAT Implementation of Tasking::
405 * GNAT Implementation of Shared Passive Packages::
406 * Code Generation for Array Aggregates::
407 * The Size of Discriminated Records with Default Discriminants::
408 * Strict Conformance to the Ada 95 Reference Manual::
410 Project File Reference
414 GNU Free Documentation License
421 @node About This Guide
422 @unnumbered About This Guide
426 This manual contains useful information in writing programs using the
427 GNAT compiler. It includes information on implementation dependent
428 characteristics of GNAT, including all the information required by Annex
434 This manual contains useful information in writing programs using the
435 GNAT Pro compiler. It includes information on implementation dependent
436 characteristics of GNAT Pro, including all the information required by Annex
440 Ada 95 is designed to be highly portable.
441 In general, a program will have the same effect even when compiled by
442 different compilers on different platforms.
443 However, since Ada 95 is designed to be used in a
444 wide variety of applications, it also contains a number of system
445 dependent features to be used in interfacing to the external world.
446 @cindex Implementation-dependent features
449 Note: Any program that makes use of implementation-dependent features
450 may be non-portable. You should follow good programming practice and
451 isolate and clearly document any sections of your program that make use
452 of these features in a non-portable manner.
455 For ease of exposition, ``GNAT Pro'' will be referred to simply as
456 ``GNAT'' in the remainder of this document.
460 * What This Reference Manual Contains::
462 * Related Information::
465 @node What This Reference Manual Contains
466 @unnumberedsec What This Reference Manual Contains
469 This reference manual contains the following chapters:
473 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
474 pragmas, which can be used to extend and enhance the functionality of the
478 @ref{Implementation Defined Attributes}, lists GNAT
479 implementation-dependent attributes which can be used to extend and
480 enhance the functionality of the compiler.
483 @ref{Implementation Advice}, provides information on generally
484 desirable behavior which are not requirements that all compilers must
485 follow since it cannot be provided on all systems, or which may be
486 undesirable on some systems.
489 @ref{Implementation Defined Characteristics}, provides a guide to
490 minimizing implementation dependent features.
493 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
494 implemented by GNAT, and how they can be imported into user
495 application programs.
498 @ref{Representation Clauses and Pragmas}, describes in detail the
499 way that GNAT represents data, and in particular the exact set
500 of representation clauses and pragmas that is accepted.
503 @ref{Standard Library Routines}, provides a listing of packages and a
504 brief description of the functionality that is provided by Ada's
505 extensive set of standard library routines as implemented by GNAT@.
508 @ref{The Implementation of Standard I/O}, details how the GNAT
509 implementation of the input-output facilities.
512 @ref{The GNAT Library}, is a catalog of packages that complement
513 the Ada predefined library.
516 @ref{Interfacing to Other Languages}, describes how programs
517 written in Ada using GNAT can be interfaced to other programming
520 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
521 of the specialized needs annexes.
524 @ref{Implementation of Specific Ada Features}, discusses issues related
525 to GNAT's implementation of machine code insertions, tasking, and several
529 @ref{Project File Reference}, presents the syntax and semantics
533 @ref{Obsolescent Features} documents implementation dependent features,
534 including pragmas and attributes, which are considered obsolescent, since
535 there are other preferred ways of achieving the same results. These
536 obsolescent forms are retained for backwards compatibility.
540 @cindex Ada 95 ISO/ANSI Standard
542 This reference manual assumes that you are familiar with Ada 95
543 language, as described in the International Standard
544 ANSI/ISO/IEC-8652:1995, Jan 1995.
547 @unnumberedsec Conventions
548 @cindex Conventions, typographical
549 @cindex Typographical conventions
552 Following are examples of the typographical and graphic conventions used
557 @code{Functions}, @code{utility program names}, @code{standard names},
564 @file{File Names}, @samp{button names}, and @samp{field names}.
573 [optional information or parameters]
576 Examples are described by text
578 and then shown this way.
583 Commands that are entered by the user are preceded in this manual by the
584 characters @samp{$ } (dollar sign followed by space). If your system uses this
585 sequence as a prompt, then the commands will appear exactly as you see them
586 in the manual. If your system uses some other prompt, then the command will
587 appear with the @samp{$} replaced by whatever prompt character you are using.
589 @node Related Information
590 @unnumberedsec Related Information
592 See the following documents for further information on GNAT:
596 @cite{GNAT User's Guide}, which provides information on how to use
597 the GNAT compiler system.
600 @cite{Ada 95 Reference Manual}, which contains all reference
601 material for the Ada 95 programming language.
604 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
605 of the standard reference manual cited above. The annotations describe
606 detailed aspects of the design decision, and in particular contain useful
607 sections on Ada 83 compatibility.
610 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
611 which contains specific information on compatibility between GNAT and
615 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
616 describes in detail the pragmas and attributes provided by the DEC Ada 83
621 @node Implementation Defined Pragmas
622 @chapter Implementation Defined Pragmas
625 Ada 95 defines a set of pragmas that can be used to supply additional
626 information to the compiler. These language defined pragmas are
627 implemented in GNAT and work as described in the Ada 95 Reference
630 In addition, Ada 95 allows implementations to define additional pragmas
631 whose meaning is defined by the implementation. GNAT provides a number
632 of these implementation-dependent pragmas which can be used to extend
633 and enhance the functionality of the compiler. This section of the GNAT
634 Reference Manual describes these additional pragmas.
636 Note that any program using these pragmas may not be portable to other
637 compilers (although GNAT implements this set of pragmas on all
638 platforms). Therefore if portability to other compilers is an important
639 consideration, the use of these pragmas should be minimized.
642 * Pragma Abort_Defer::
649 * Pragma C_Pass_By_Copy::
651 * Pragma Common_Object::
652 * Pragma Compile_Time_Warning::
653 * Pragma Complete_Representation::
654 * Pragma Complex_Representation::
655 * Pragma Component_Alignment::
656 * Pragma Convention_Identifier::
658 * Pragma CPP_Constructor::
659 * Pragma CPP_Virtual::
660 * Pragma CPP_Vtable::
662 * Pragma Debug_Policy::
663 * Pragma Detect_Blocking::
664 * Pragma Elaboration_Checks::
666 * Pragma Export_Exception::
667 * Pragma Export_Function::
668 * Pragma Export_Object::
669 * Pragma Export_Procedure::
670 * Pragma Export_Value::
671 * Pragma Export_Valued_Procedure::
672 * Pragma Extend_System::
674 * Pragma External_Name_Casing::
675 * Pragma Finalize_Storage_Only::
676 * Pragma Float_Representation::
678 * Pragma Import_Exception::
679 * Pragma Import_Function::
680 * Pragma Import_Object::
681 * Pragma Import_Procedure::
682 * Pragma Import_Valued_Procedure::
683 * Pragma Initialize_Scalars::
684 * Pragma Inline_Always::
685 * Pragma Inline_Generic::
687 * Pragma Interface_Name::
688 * Pragma Interrupt_Handler::
689 * Pragma Interrupt_State::
690 * Pragma Keep_Names::
693 * Pragma Linker_Alias::
694 * Pragma Linker_Constructor::
695 * Pragma Linker_Destructor::
696 * Pragma Linker_Section::
697 * Pragma Long_Float::
698 * Pragma Machine_Attribute::
699 * Pragma Main_Storage::
701 * Pragma No_Strict_Aliasing::
702 * Pragma Normalize_Scalars::
703 * Pragma Obsolescent::
705 * Pragma Persistent_BSS::
707 * Pragma Profile (Ravenscar)::
708 * Pragma Profile (Restricted)::
709 * Pragma Propagate_Exceptions::
710 * Pragma Psect_Object::
711 * Pragma Pure_Function::
712 * Pragma Restriction_Warnings::
713 * Pragma Source_File_Name::
714 * Pragma Source_File_Name_Project::
715 * Pragma Source_Reference::
716 * Pragma Stream_Convert::
717 * Pragma Style_Checks::
719 * Pragma Suppress_All::
720 * Pragma Suppress_Exception_Locations::
721 * Pragma Suppress_Initialization::
724 * Pragma Task_Storage::
725 * Pragma Thread_Body::
726 * Pragma Time_Slice::
728 * Pragma Unchecked_Union::
729 * Pragma Unimplemented_Unit::
730 * Pragma Universal_Data::
731 * Pragma Unreferenced::
732 * Pragma Unreserve_All_Interrupts::
733 * Pragma Unsuppress::
734 * Pragma Use_VADS_Size::
735 * Pragma Validity_Checks::
738 * Pragma Weak_External::
741 @node Pragma Abort_Defer
742 @unnumberedsec Pragma Abort_Defer
744 @cindex Deferring aborts
752 This pragma must appear at the start of the statement sequence of a
753 handled sequence of statements (right after the @code{begin}). It has
754 the effect of deferring aborts for the sequence of statements (but not
755 for the declarations or handlers, if any, associated with this statement
759 @unnumberedsec Pragma Ada_83
768 A configuration pragma that establishes Ada 83 mode for the unit to
769 which it applies, regardless of the mode set by the command line
770 switches. In Ada 83 mode, GNAT attempts to be as compatible with
771 the syntax and semantics of Ada 83, as defined in the original Ada
772 83 Reference Manual as possible. In particular, the new Ada 95
773 keywords are not recognized, optional package bodies are allowed,
774 and generics may name types with unknown discriminants without using
775 the @code{(<>)} notation. In addition, some but not all of the additional
776 restrictions of Ada 83 are enforced.
778 Ada 83 mode is intended for two purposes. Firstly, it allows existing
779 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
780 Secondly, it aids in keeping code backwards compatible with Ada 83.
781 However, there is no guarantee that code that is processed correctly
782 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
783 83 compiler, since GNAT does not enforce all the additional checks
787 @unnumberedsec Pragma Ada_95
796 A configuration pragma that establishes Ada 95 mode for the unit to which
797 it applies, regardless of the mode set by the command line switches.
798 This mode is set automatically for the @code{Ada} and @code{System}
799 packages and their children, so you need not specify it in these
800 contexts. This pragma is useful when writing a reusable component that
801 itself uses Ada 95 features, but which is intended to be usable from
802 either Ada 83 or Ada 95 programs.
805 @unnumberedsec Pragma Ada_05
814 A configuration pragma that establishes Ada 2005 mode for the unit to which
815 it applies, regardless of the mode set by the command line switches.
816 This mode is set automatically for the @code{Ada} and @code{System}
817 packages and their children, so you need not specify it in these
818 contexts. This pragma is useful when writing a reusable component that
819 itself uses Ada 2005 features, but which is intended to be usable from
820 either Ada 83 or Ada 95 programs.
822 @node Pragma Annotate
823 @unnumberedsec Pragma Annotate
828 pragma Annotate (IDENTIFIER @{, ARG@});
830 ARG ::= NAME | EXPRESSION
834 This pragma is used to annotate programs. @var{identifier} identifies
835 the type of annotation. GNAT verifies this is an identifier, but does
836 not otherwise analyze it. The @var{arg} argument
837 can be either a string literal or an
838 expression. String literals are assumed to be of type
839 @code{Standard.String}. Names of entities are simply analyzed as entity
840 names. All other expressions are analyzed as expressions, and must be
843 The analyzed pragma is retained in the tree, but not otherwise processed
844 by any part of the GNAT compiler. This pragma is intended for use by
845 external tools, including ASIS@.
848 @unnumberedsec Pragma Assert
855 [, static_string_EXPRESSION]);
859 The effect of this pragma depends on whether the corresponding command
860 line switch is set to activate assertions. The pragma expands into code
861 equivalent to the following:
864 if assertions-enabled then
865 if not boolean_EXPRESSION then
866 System.Assertions.Raise_Assert_Failure
873 The string argument, if given, is the message that will be associated
874 with the exception occurrence if the exception is raised. If no second
875 argument is given, the default message is @samp{@var{file}:@var{nnn}},
876 where @var{file} is the name of the source file containing the assert,
877 and @var{nnn} is the line number of the assert. A pragma is not a
878 statement, so if a statement sequence contains nothing but a pragma
879 assert, then a null statement is required in addition, as in:
884 pragma Assert (K > 3, "Bad value for K");
890 Note that, as with the @code{if} statement to which it is equivalent, the
891 type of the expression is either @code{Standard.Boolean}, or any type derived
892 from this standard type.
894 If assertions are disabled (switch @code{-gnata} not used), then there
895 is no effect (and in particular, any side effects from the expression
896 are suppressed). More precisely it is not quite true that the pragma
897 has no effect, since the expression is analyzed, and may cause types
898 to be frozen if they are mentioned here for the first time.
900 If assertions are enabled, then the given expression is tested, and if
901 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
902 which results in the raising of @code{Assert_Failure} with the given message.
904 If the boolean expression has side effects, these side effects will turn
905 on and off with the setting of the assertions mode, resulting in
906 assertions that have an effect on the program. You should generally
907 avoid side effects in the expression arguments of this pragma. However,
908 the expressions are analyzed for semantic correctness whether or not
909 assertions are enabled, so turning assertions on and off cannot affect
910 the legality of a program.
912 @node Pragma Ast_Entry
913 @unnumberedsec Pragma Ast_Entry
919 pragma AST_Entry (entry_IDENTIFIER);
923 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
924 argument is the simple name of a single entry; at most one @code{AST_Entry}
925 pragma is allowed for any given entry. This pragma must be used in
926 conjunction with the @code{AST_Entry} attribute, and is only allowed after
927 the entry declaration and in the same task type specification or single task
928 as the entry to which it applies. This pragma specifies that the given entry
929 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
930 resulting from an OpenVMS system service call. The pragma does not affect
931 normal use of the entry. For further details on this pragma, see the
932 DEC Ada Language Reference Manual, section 9.12a.
934 @node Pragma C_Pass_By_Copy
935 @unnumberedsec Pragma C_Pass_By_Copy
936 @cindex Passing by copy
937 @findex C_Pass_By_Copy
941 pragma C_Pass_By_Copy
942 ([Max_Size =>] static_integer_EXPRESSION);
946 Normally the default mechanism for passing C convention records to C
947 convention subprograms is to pass them by reference, as suggested by RM
948 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
949 this default, by requiring that record formal parameters be passed by
950 copy if all of the following conditions are met:
954 The size of the record type does not exceed@*@var{static_integer_expression}.
956 The record type has @code{Convention C}.
958 The formal parameter has this record type, and the subprogram has a
959 foreign (non-Ada) convention.
963 If these conditions are met the argument is passed by copy, i.e.@: in a
964 manner consistent with what C expects if the corresponding formal in the
965 C prototype is a struct (rather than a pointer to a struct).
967 You can also pass records by copy by specifying the convention
968 @code{C_Pass_By_Copy} for the record type, or by using the extended
969 @code{Import} and @code{Export} pragmas, which allow specification of
970 passing mechanisms on a parameter by parameter basis.
973 @unnumberedsec Pragma Comment
979 pragma Comment (static_string_EXPRESSION);
983 This is almost identical in effect to pragma @code{Ident}. It allows the
984 placement of a comment into the object file and hence into the
985 executable file if the operating system permits such usage. The
986 difference is that @code{Comment}, unlike @code{Ident}, has
987 no limitations on placement of the pragma (it can be placed
988 anywhere in the main source unit), and if more than one pragma
989 is used, all comments are retained.
991 @node Pragma Common_Object
992 @unnumberedsec Pragma Common_Object
993 @findex Common_Object
998 pragma Common_Object (
999 [Internal =>] local_NAME,
1000 [, [External =>] EXTERNAL_SYMBOL]
1001 [, [Size =>] EXTERNAL_SYMBOL] );
1005 | static_string_EXPRESSION
1009 This pragma enables the shared use of variables stored in overlaid
1010 linker areas corresponding to the use of @code{COMMON}
1011 in Fortran. The single
1012 object @var{local_NAME} is assigned to the area designated by
1013 the @var{External} argument.
1014 You may define a record to correspond to a series
1015 of fields. The @var{size} argument
1016 is syntax checked in GNAT, but otherwise ignored.
1018 @code{Common_Object} is not supported on all platforms. If no
1019 support is available, then the code generator will issue a message
1020 indicating that the necessary attribute for implementation of this
1021 pragma is not available.
1023 @node Pragma Compile_Time_Warning
1024 @unnumberedsec Pragma Compile_Time_Warning
1025 @findex Compile_Time_Warning
1029 @smallexample @c ada
1030 pragma Compile_Time_Warning
1031 (boolean_EXPRESSION, static_string_EXPRESSION);
1035 This pragma can be used to generate additional compile time warnings. It
1036 is particularly useful in generics, where warnings can be issued for
1037 specific problematic instantiations. The first parameter is a boolean
1038 expression. The pragma is effective only if the value of this expression
1039 is known at compile time, and has the value True. The set of expressions
1040 whose values are known at compile time includes all static boolean
1041 expressions, and also other values which the compiler can determine
1042 at compile time (e.g. the size of a record type set by an explicit
1043 size representation clause, or the value of a variable which was
1044 initialized to a constant and is known not to have been modified).
1045 If these conditions are met, a warning message is generated using
1046 the value given as the second argument. This string value may contain
1047 embedded ASCII.LF characters to break the message into multiple lines.
1049 @node Pragma Complete_Representation
1050 @unnumberedsec Pragma Complete_Representation
1051 @findex Complete_Representation
1055 @smallexample @c ada
1056 pragma Complete_Representation;
1060 This pragma must appear immediately within a record representation
1061 clause. Typical placements are before the first component clause
1062 or after the last component clause. The effect is to give an error
1063 message if any component is missing a component clause. This pragma
1064 may be used to ensure that a record representation clause is
1065 complete, and that this invariant is maintained if fields are
1066 added to the record in the future.
1068 @node Pragma Complex_Representation
1069 @unnumberedsec Pragma Complex_Representation
1070 @findex Complex_Representation
1074 @smallexample @c ada
1075 pragma Complex_Representation
1076 ([Entity =>] local_NAME);
1080 The @var{Entity} argument must be the name of a record type which has
1081 two fields of the same floating-point type. The effect of this pragma is
1082 to force gcc to use the special internal complex representation form for
1083 this record, which may be more efficient. Note that this may result in
1084 the code for this type not conforming to standard ABI (application
1085 binary interface) requirements for the handling of record types. For
1086 example, in some environments, there is a requirement for passing
1087 records by pointer, and the use of this pragma may result in passing
1088 this type in floating-point registers.
1090 @node Pragma Component_Alignment
1091 @unnumberedsec Pragma Component_Alignment
1092 @cindex Alignments of components
1093 @findex Component_Alignment
1097 @smallexample @c ada
1098 pragma Component_Alignment (
1099 [Form =>] ALIGNMENT_CHOICE
1100 [, [Name =>] type_local_NAME]);
1102 ALIGNMENT_CHOICE ::=
1110 Specifies the alignment of components in array or record types.
1111 The meaning of the @var{Form} argument is as follows:
1114 @findex Component_Size
1115 @item Component_Size
1116 Aligns scalar components and subcomponents of the array or record type
1117 on boundaries appropriate to their inherent size (naturally
1118 aligned). For example, 1-byte components are aligned on byte boundaries,
1119 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1120 integer components are aligned on 4-byte boundaries and so on. These
1121 alignment rules correspond to the normal rules for C compilers on all
1122 machines except the VAX@.
1124 @findex Component_Size_4
1125 @item Component_Size_4
1126 Naturally aligns components with a size of four or fewer
1127 bytes. Components that are larger than 4 bytes are placed on the next
1130 @findex Storage_Unit
1132 Specifies that array or record components are byte aligned, i.e.@:
1133 aligned on boundaries determined by the value of the constant
1134 @code{System.Storage_Unit}.
1138 Specifies that array or record components are aligned on default
1139 boundaries, appropriate to the underlying hardware or operating system or
1140 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1141 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1142 the @code{Default} choice is the same as @code{Component_Size} (natural
1147 If the @code{Name} parameter is present, @var{type_local_NAME} must
1148 refer to a local record or array type, and the specified alignment
1149 choice applies to the specified type. The use of
1150 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1151 @code{Component_Alignment} pragma to be ignored. The use of
1152 @code{Component_Alignment} together with a record representation clause
1153 is only effective for fields not specified by the representation clause.
1155 If the @code{Name} parameter is absent, the pragma can be used as either
1156 a configuration pragma, in which case it applies to one or more units in
1157 accordance with the normal rules for configuration pragmas, or it can be
1158 used within a declarative part, in which case it applies to types that
1159 are declared within this declarative part, or within any nested scope
1160 within this declarative part. In either case it specifies the alignment
1161 to be applied to any record or array type which has otherwise standard
1164 If the alignment for a record or array type is not specified (using
1165 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1166 clause), the GNAT uses the default alignment as described previously.
1168 @node Pragma Convention_Identifier
1169 @unnumberedsec Pragma Convention_Identifier
1170 @findex Convention_Identifier
1171 @cindex Conventions, synonyms
1175 @smallexample @c ada
1176 pragma Convention_Identifier (
1177 [Name =>] IDENTIFIER,
1178 [Convention =>] convention_IDENTIFIER);
1182 This pragma provides a mechanism for supplying synonyms for existing
1183 convention identifiers. The @code{Name} identifier can subsequently
1184 be used as a synonym for the given convention in other pragmas (including
1185 for example pragma @code{Import} or another @code{Convention_Identifier}
1186 pragma). As an example of the use of this, suppose you had legacy code
1187 which used Fortran77 as the identifier for Fortran. Then the pragma:
1189 @smallexample @c ada
1190 pragma Convention_Identifier (Fortran77, Fortran);
1194 would allow the use of the convention identifier @code{Fortran77} in
1195 subsequent code, avoiding the need to modify the sources. As another
1196 example, you could use this to parametrize convention requirements
1197 according to systems. Suppose you needed to use @code{Stdcall} on
1198 windows systems, and @code{C} on some other system, then you could
1199 define a convention identifier @code{Library} and use a single
1200 @code{Convention_Identifier} pragma to specify which convention
1201 would be used system-wide.
1203 @node Pragma CPP_Class
1204 @unnumberedsec Pragma CPP_Class
1206 @cindex Interfacing with C++
1210 @smallexample @c ada
1211 pragma CPP_Class ([Entity =>] local_NAME);
1215 The argument denotes an entity in the current declarative region
1216 that is declared as a tagged or untagged record type. It indicates that
1217 the type corresponds to an externally declared C++ class type, and is to
1218 be laid out the same way that C++ would lay out the type.
1220 If (and only if) the type is tagged, at least one component in the
1221 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1222 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1225 Types for which @code{CPP_Class} is specified do not have assignment or
1226 equality operators defined (such operations can be imported or declared
1227 as subprograms as required). Initialization is allowed only by
1228 constructor functions (see pragma @code{CPP_Constructor}).
1230 Pragma @code{CPP_Class} is intended primarily for automatic generation
1231 using an automatic binding generator tool.
1232 See @ref{Interfacing to C++} for related information.
1234 @node Pragma CPP_Constructor
1235 @unnumberedsec Pragma CPP_Constructor
1236 @cindex Interfacing with C++
1237 @findex CPP_Constructor
1241 @smallexample @c ada
1242 pragma CPP_Constructor ([Entity =>] local_NAME);
1246 This pragma identifies an imported function (imported in the usual way
1247 with pragma @code{Import}) as corresponding to a C++
1248 constructor. The argument is a name that must have been
1249 previously mentioned in a pragma @code{Import}
1250 with @code{Convention} = @code{CPP}, and must be of one of the following
1255 @code{function @var{Fname} return @var{T}'Class}
1258 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1262 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1264 The first form is the default constructor, used when an object of type
1265 @var{T} is created on the Ada side with no explicit constructor. Other
1266 constructors (including the copy constructor, which is simply a special
1267 case of the second form in which the one and only argument is of type
1268 @var{T}), can only appear in two contexts:
1272 On the right side of an initialization of an object of type @var{T}.
1274 In an extension aggregate for an object of a type derived from @var{T}.
1278 Although the constructor is described as a function that returns a value
1279 on the Ada side, it is typically a procedure with an extra implicit
1280 argument (the object being initialized) at the implementation
1281 level. GNAT issues the appropriate call, whatever it is, to get the
1282 object properly initialized.
1284 In the case of derived objects, you may use one of two possible forms
1285 for declaring and creating an object:
1288 @item @code{New_Object : Derived_T}
1289 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1293 In the first case the default constructor is called and extension fields
1294 if any are initialized according to the default initialization
1295 expressions in the Ada declaration. In the second case, the given
1296 constructor is called and the extension aggregate indicates the explicit
1297 values of the extension fields.
1299 If no constructors are imported, it is impossible to create any objects
1300 on the Ada side. If no default constructor is imported, only the
1301 initialization forms using an explicit call to a constructor are
1304 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1305 using an automatic binding generator tool.
1306 See @ref{Interfacing to C++} for more related information.
1308 @node Pragma CPP_Virtual
1309 @unnumberedsec Pragma CPP_Virtual
1310 @cindex Interfacing to C++
1315 @smallexample @c ada
1318 [, [Vtable_Ptr =>] vtable_ENTITY,]
1319 [, [Position =>] static_integer_EXPRESSION]);
1323 This pragma serves the same function as pragma @code{Import} in that
1324 case of a virtual function imported from C++. The @var{Entity} argument
1326 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1327 applies. The @var{Vtable_Ptr} argument specifies
1328 the Vtable_Ptr component which contains the
1329 entry for this virtual function. The @var{Position} argument
1330 is the sequential number
1331 counting virtual functions for this Vtable starting at 1.
1333 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1334 there is one Vtable_Ptr present (single inheritance case) and all
1335 virtual functions are imported. In that case the compiler can deduce both
1338 No @code{External_Name} or @code{Link_Name} arguments are required for a
1339 virtual function, since it is always accessed indirectly via the
1340 appropriate Vtable entry.
1342 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1343 using an automatic binding generator tool.
1344 See @ref{Interfacing to C++} for related information.
1346 @node Pragma CPP_Vtable
1347 @unnumberedsec Pragma CPP_Vtable
1348 @cindex Interfacing with C++
1353 @smallexample @c ada
1356 [Vtable_Ptr =>] vtable_ENTITY,
1357 [Entry_Count =>] static_integer_EXPRESSION);
1361 Given a record to which the pragma @code{CPP_Class} applies,
1362 this pragma can be specified for each component of type
1363 @code{CPP.Interfaces.Vtable_Ptr}.
1364 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1365 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1366 the number of virtual functions on the C++ side. Not all of these
1367 functions need to be imported on the Ada side.
1369 You may omit the @code{CPP_Vtable} pragma if there is only one
1370 @code{Vtable_Ptr} component in the record and all virtual functions are
1371 imported on the Ada side (the default value for the entry count in this
1372 case is simply the total number of virtual functions).
1374 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1375 using an automatic binding generator tool.
1376 See @ref{Interfacing to C++} for related information.
1379 @unnumberedsec Pragma Debug
1384 @smallexample @c ada
1385 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1387 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1389 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1393 The procedure call argument has the syntactic form of an expression, meeting
1394 the syntactic requirements for pragmas.
1396 If debug pragmas are not enabled or if the condition is present and evaluates
1397 to False, this pragma has no effect. If debug pragmas are enabled, the
1398 semantics of the pragma is exactly equivalent to the procedure call statement
1399 corresponding to the argument with a terminating semicolon. Pragmas are
1400 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1401 intersperse calls to debug procedures in the middle of declarations. Debug
1402 pragmas can be enabled either by use of the command line switch @code{-gnata}
1403 or by use of the configuration pragma @code{Debug_Policy}.
1405 @node Pragma Debug_Policy
1406 @unnumberedsec Pragma Debug_Policy
1407 @findex Debug_Policy
1411 @smallexample @c ada
1412 pragma Debug_Policy (CHECK | IGNORE);
1416 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1417 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1418 This pragma overrides the effect of the @code{-gnata} switch on the
1421 @node Pragma Detect_Blocking
1422 @unnumberedsec Pragma Detect_Blocking
1423 @findex Detect_Blocking
1427 @smallexample @c ada
1428 pragma Detect_Blocking;
1432 This is a configuration pragma that forces the detection of potentially
1433 blocking operations within a protected operation, and to raise Program_Error
1436 @node Pragma Elaboration_Checks
1437 @unnumberedsec Pragma Elaboration_Checks
1438 @cindex Elaboration control
1439 @findex Elaboration_Checks
1443 @smallexample @c ada
1444 pragma Elaboration_Checks (Dynamic | Static);
1448 This is a configuration pragma that provides control over the
1449 elaboration model used by the compilation affected by the
1450 pragma. If the parameter is @code{Dynamic},
1451 then the dynamic elaboration
1452 model described in the Ada Reference Manual is used, as though
1453 the @code{-gnatE} switch had been specified on the command
1454 line. If the parameter is @code{Static}, then the default GNAT static
1455 model is used. This configuration pragma overrides the setting
1456 of the command line. For full details on the elaboration models
1457 used by the GNAT compiler, see section ``Elaboration Order
1458 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1460 @node Pragma Eliminate
1461 @unnumberedsec Pragma Eliminate
1462 @cindex Elimination of unused subprograms
1467 @smallexample @c ada
1469 [Unit_Name =>] IDENTIFIER |
1470 SELECTED_COMPONENT);
1473 [Unit_Name =>] IDENTIFIER |
1475 [Entity =>] IDENTIFIER |
1476 SELECTED_COMPONENT |
1478 [,OVERLOADING_RESOLUTION]);
1480 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1483 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1486 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1488 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1489 Result_Type => result_SUBTYPE_NAME]
1491 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1492 SUBTYPE_NAME ::= STRING_VALUE
1494 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1495 SOURCE_TRACE ::= STRING_VALUE
1497 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1501 This pragma indicates that the given entity is not used outside the
1502 compilation unit it is defined in. The entity must be an explicitly declared
1503 subprogram; this includes generic subprogram instances and
1504 subprograms declared in generic package instances.
1506 If the entity to be eliminated is a library level subprogram, then
1507 the first form of pragma @code{Eliminate} is used with only a single argument.
1508 In this form, the @code{Unit_Name} argument specifies the name of the
1509 library level unit to be eliminated.
1511 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1512 are required. If item is an entity of a library package, then the first
1513 argument specifies the unit name, and the second argument specifies
1514 the particular entity. If the second argument is in string form, it must
1515 correspond to the internal manner in which GNAT stores entity names (see
1516 compilation unit Namet in the compiler sources for details).
1518 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1519 to distinguish between overloaded subprograms. If a pragma does not contain
1520 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1521 subprograms denoted by the first two parameters.
1523 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1524 to be eliminated in a manner similar to that used for the extended
1525 @code{Import} and @code{Export} pragmas, except that the subtype names are
1526 always given as strings. At the moment, this form of distinguishing
1527 overloaded subprograms is implemented only partially, so we do not recommend
1528 using it for practical subprogram elimination.
1530 Note, that in case of a parameterless procedure its profile is represented
1531 as @code{Parameter_Types => ("")}
1533 Alternatively, the @code{Source_Location} parameter is used to specify
1534 which overloaded alternative is to be eliminated by pointing to the
1535 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1536 source text. The string literal (or concatenation of string literals)
1537 given as SOURCE_TRACE must have the following format:
1539 @smallexample @c ada
1540 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1545 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1546 FILE_NAME ::= STRING_LITERAL
1547 LINE_NUMBER ::= DIGIT @{DIGIT@}
1550 SOURCE_TRACE should be the short name of the source file (with no directory
1551 information), and LINE_NUMBER is supposed to point to the line where the
1552 defining name of the subprogram is located.
1554 For the subprograms that are not a part of generic instantiations, only one
1555 SOURCE_LOCATION is used. If a subprogram is declared in a package
1556 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1557 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1558 second one denotes the declaration of the corresponding subprogram in the
1559 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1560 in case of nested instantiations.
1562 The effect of the pragma is to allow the compiler to eliminate
1563 the code or data associated with the named entity. Any reference to
1564 an eliminated entity outside the compilation unit it is defined in,
1565 causes a compile time or link time error.
1567 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1568 in a system independent manner, with unused entities eliminated, without
1569 the requirement of modifying the source text. Normally the required set
1570 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1571 tool. Elimination of unused entities local to a compilation unit is
1572 automatic, without requiring the use of pragma @code{Eliminate}.
1574 Note that the reason this pragma takes string literals where names might
1575 be expected is that a pragma @code{Eliminate} can appear in a context where the
1576 relevant names are not visible.
1578 Note that any change in the source files that includes removing, splitting of
1579 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1582 @node Pragma Export_Exception
1583 @unnumberedsec Pragma Export_Exception
1585 @findex Export_Exception
1589 @smallexample @c ada
1590 pragma Export_Exception (
1591 [Internal =>] local_NAME,
1592 [, [External =>] EXTERNAL_SYMBOL,]
1593 [, [Form =>] Ada | VMS]
1594 [, [Code =>] static_integer_EXPRESSION]);
1598 | static_string_EXPRESSION
1602 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1603 causes the specified exception to be propagated outside of the Ada program,
1604 so that it can be handled by programs written in other OpenVMS languages.
1605 This pragma establishes an external name for an Ada exception and makes the
1606 name available to the OpenVMS Linker as a global symbol. For further details
1607 on this pragma, see the
1608 DEC Ada Language Reference Manual, section 13.9a3.2.
1610 @node Pragma Export_Function
1611 @unnumberedsec Pragma Export_Function
1612 @cindex Argument passing mechanisms
1613 @findex Export_Function
1618 @smallexample @c ada
1619 pragma Export_Function (
1620 [Internal =>] local_NAME,
1621 [, [External =>] EXTERNAL_SYMBOL]
1622 [, [Parameter_Types =>] PARAMETER_TYPES]
1623 [, [Result_Type =>] result_SUBTYPE_MARK]
1624 [, [Mechanism =>] MECHANISM]
1625 [, [Result_Mechanism =>] MECHANISM_NAME]);
1629 | static_string_EXPRESSION
1634 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1638 | subtype_Name ' Access
1642 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1644 MECHANISM_ASSOCIATION ::=
1645 [formal_parameter_NAME =>] MECHANISM_NAME
1653 Use this pragma to make a function externally callable and optionally
1654 provide information on mechanisms to be used for passing parameter and
1655 result values. We recommend, for the purposes of improving portability,
1656 this pragma always be used in conjunction with a separate pragma
1657 @code{Export}, which must precede the pragma @code{Export_Function}.
1658 GNAT does not require a separate pragma @code{Export}, but if none is
1659 present, @code{Convention Ada} is assumed, which is usually
1660 not what is wanted, so it is usually appropriate to use this
1661 pragma in conjunction with a @code{Export} or @code{Convention}
1662 pragma that specifies the desired foreign convention.
1663 Pragma @code{Export_Function}
1664 (and @code{Export}, if present) must appear in the same declarative
1665 region as the function to which they apply.
1667 @var{internal_name} must uniquely designate the function to which the
1668 pragma applies. If more than one function name exists of this name in
1669 the declarative part you must use the @code{Parameter_Types} and
1670 @code{Result_Type} parameters is mandatory to achieve the required
1671 unique designation. @var{subtype_ mark}s in these parameters must
1672 exactly match the subtypes in the corresponding function specification,
1673 using positional notation to match parameters with subtype marks.
1674 The form with an @code{'Access} attribute can be used to match an
1675 anonymous access parameter.
1678 @cindex Passing by descriptor
1679 Note that passing by descriptor is not supported, even on the OpenVMS
1682 @cindex Suppressing external name
1683 Special treatment is given if the EXTERNAL is an explicit null
1684 string or a static string expressions that evaluates to the null
1685 string. In this case, no external name is generated. This form
1686 still allows the specification of parameter mechanisms.
1688 @node Pragma Export_Object
1689 @unnumberedsec Pragma Export_Object
1690 @findex Export_Object
1694 @smallexample @c ada
1695 pragma Export_Object
1696 [Internal =>] local_NAME,
1697 [, [External =>] EXTERNAL_SYMBOL]
1698 [, [Size =>] EXTERNAL_SYMBOL]
1702 | static_string_EXPRESSION
1706 This pragma designates an object as exported, and apart from the
1707 extended rules for external symbols, is identical in effect to the use of
1708 the normal @code{Export} pragma applied to an object. You may use a
1709 separate Export pragma (and you probably should from the point of view
1710 of portability), but it is not required. @var{Size} is syntax checked,
1711 but otherwise ignored by GNAT@.
1713 @node Pragma Export_Procedure
1714 @unnumberedsec Pragma Export_Procedure
1715 @findex Export_Procedure
1719 @smallexample @c ada
1720 pragma Export_Procedure (
1721 [Internal =>] local_NAME
1722 [, [External =>] EXTERNAL_SYMBOL]
1723 [, [Parameter_Types =>] PARAMETER_TYPES]
1724 [, [Mechanism =>] MECHANISM]);
1728 | static_string_EXPRESSION
1733 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1737 | subtype_Name ' Access
1741 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1743 MECHANISM_ASSOCIATION ::=
1744 [formal_parameter_NAME =>] MECHANISM_NAME
1752 This pragma is identical to @code{Export_Function} except that it
1753 applies to a procedure rather than a function and the parameters
1754 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1755 GNAT does not require a separate pragma @code{Export}, but if none is
1756 present, @code{Convention Ada} is assumed, which is usually
1757 not what is wanted, so it is usually appropriate to use this
1758 pragma in conjunction with a @code{Export} or @code{Convention}
1759 pragma that specifies the desired foreign convention.
1762 @cindex Passing by descriptor
1763 Note that passing by descriptor is not supported, even on the OpenVMS
1766 @cindex Suppressing external name
1767 Special treatment is given if the EXTERNAL is an explicit null
1768 string or a static string expressions that evaluates to the null
1769 string. In this case, no external name is generated. This form
1770 still allows the specification of parameter mechanisms.
1772 @node Pragma Export_Value
1773 @unnumberedsec Pragma Export_Value
1774 @findex Export_Value
1778 @smallexample @c ada
1779 pragma Export_Value (
1780 [Value =>] static_integer_EXPRESSION,
1781 [Link_Name =>] static_string_EXPRESSION);
1785 This pragma serves to export a static integer value for external use.
1786 The first argument specifies the value to be exported. The Link_Name
1787 argument specifies the symbolic name to be associated with the integer
1788 value. This pragma is useful for defining a named static value in Ada
1789 that can be referenced in assembly language units to be linked with
1790 the application. This pragma is currently supported only for the
1791 AAMP target and is ignored for other targets.
1793 @node Pragma Export_Valued_Procedure
1794 @unnumberedsec Pragma Export_Valued_Procedure
1795 @findex Export_Valued_Procedure
1799 @smallexample @c ada
1800 pragma Export_Valued_Procedure (
1801 [Internal =>] local_NAME
1802 [, [External =>] EXTERNAL_SYMBOL]
1803 [, [Parameter_Types =>] PARAMETER_TYPES]
1804 [, [Mechanism =>] MECHANISM]);
1808 | static_string_EXPRESSION
1813 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1817 | subtype_Name ' Access
1821 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1823 MECHANISM_ASSOCIATION ::=
1824 [formal_parameter_NAME =>] MECHANISM_NAME
1832 This pragma is identical to @code{Export_Procedure} except that the
1833 first parameter of @var{local_NAME}, which must be present, must be of
1834 mode @code{OUT}, and externally the subprogram is treated as a function
1835 with this parameter as the result of the function. GNAT provides for
1836 this capability to allow the use of @code{OUT} and @code{IN OUT}
1837 parameters in interfacing to external functions (which are not permitted
1839 GNAT does not require a separate pragma @code{Export}, but if none is
1840 present, @code{Convention Ada} is assumed, which is almost certainly
1841 not what is wanted since the whole point of this pragma is to interface
1842 with foreign language functions, so it is usually appropriate to use this
1843 pragma in conjunction with a @code{Export} or @code{Convention}
1844 pragma that specifies the desired foreign convention.
1847 @cindex Passing by descriptor
1848 Note that passing by descriptor is not supported, even on the OpenVMS
1851 @cindex Suppressing external name
1852 Special treatment is given if the EXTERNAL is an explicit null
1853 string or a static string expressions that evaluates to the null
1854 string. In this case, no external name is generated. This form
1855 still allows the specification of parameter mechanisms.
1857 @node Pragma Extend_System
1858 @unnumberedsec Pragma Extend_System
1859 @cindex @code{system}, extending
1861 @findex Extend_System
1865 @smallexample @c ada
1866 pragma Extend_System ([Name =>] IDENTIFIER);
1870 This pragma is used to provide backwards compatibility with other
1871 implementations that extend the facilities of package @code{System}. In
1872 GNAT, @code{System} contains only the definitions that are present in
1873 the Ada 95 RM@. However, other implementations, notably the DEC Ada 83
1874 implementation, provide many extensions to package @code{System}.
1876 For each such implementation accommodated by this pragma, GNAT provides a
1877 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1878 implementation, which provides the required additional definitions. You
1879 can use this package in two ways. You can @code{with} it in the normal
1880 way and access entities either by selection or using a @code{use}
1881 clause. In this case no special processing is required.
1883 However, if existing code contains references such as
1884 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1885 definitions provided in package @code{System}, you may use this pragma
1886 to extend visibility in @code{System} in a non-standard way that
1887 provides greater compatibility with the existing code. Pragma
1888 @code{Extend_System} is a configuration pragma whose single argument is
1889 the name of the package containing the extended definition
1890 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
1891 control of this pragma will be processed using special visibility
1892 processing that looks in package @code{System.Aux_@var{xxx}} where
1893 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1894 package @code{System}, but not found in package @code{System}.
1896 You can use this pragma either to access a predefined @code{System}
1897 extension supplied with the compiler, for example @code{Aux_DEC} or
1898 you can construct your own extension unit following the above
1899 definition. Note that such a package is a child of @code{System}
1900 and thus is considered part of the implementation. To compile
1901 it you will have to use the appropriate switch for compiling
1902 system units. See the GNAT User's Guide for details.
1904 @node Pragma External
1905 @unnumberedsec Pragma External
1910 @smallexample @c ada
1912 [ Convention =>] convention_IDENTIFIER,
1913 [ Entity =>] local_NAME
1914 [, [External_Name =>] static_string_EXPRESSION ]
1915 [, [Link_Name =>] static_string_EXPRESSION ]);
1919 This pragma is identical in syntax and semantics to pragma
1920 @code{Export} as defined in the Ada Reference Manual. It is
1921 provided for compatibility with some Ada 83 compilers that
1922 used this pragma for exactly the same purposes as pragma
1923 @code{Export} before the latter was standardized.
1925 @node Pragma External_Name_Casing
1926 @unnumberedsec Pragma External_Name_Casing
1927 @cindex Dec Ada 83 casing compatibility
1928 @cindex External Names, casing
1929 @cindex Casing of External names
1930 @findex External_Name_Casing
1934 @smallexample @c ada
1935 pragma External_Name_Casing (
1936 Uppercase | Lowercase
1937 [, Uppercase | Lowercase | As_Is]);
1941 This pragma provides control over the casing of external names associated
1942 with Import and Export pragmas. There are two cases to consider:
1945 @item Implicit external names
1946 Implicit external names are derived from identifiers. The most common case
1947 arises when a standard Ada 95 Import or Export pragma is used with only two
1950 @smallexample @c ada
1951 pragma Import (C, C_Routine);
1955 Since Ada is a case insensitive language, the spelling of the identifier in
1956 the Ada source program does not provide any information on the desired
1957 casing of the external name, and so a convention is needed. In GNAT the
1958 default treatment is that such names are converted to all lower case
1959 letters. This corresponds to the normal C style in many environments.
1960 The first argument of pragma @code{External_Name_Casing} can be used to
1961 control this treatment. If @code{Uppercase} is specified, then the name
1962 will be forced to all uppercase letters. If @code{Lowercase} is specified,
1963 then the normal default of all lower case letters will be used.
1965 This same implicit treatment is also used in the case of extended DEC Ada 83
1966 compatible Import and Export pragmas where an external name is explicitly
1967 specified using an identifier rather than a string.
1969 @item Explicit external names
1970 Explicit external names are given as string literals. The most common case
1971 arises when a standard Ada 95 Import or Export pragma is used with three
1974 @smallexample @c ada
1975 pragma Import (C, C_Routine, "C_routine");
1979 In this case, the string literal normally provides the exact casing required
1980 for the external name. The second argument of pragma
1981 @code{External_Name_Casing} may be used to modify this behavior.
1982 If @code{Uppercase} is specified, then the name
1983 will be forced to all uppercase letters. If @code{Lowercase} is specified,
1984 then the name will be forced to all lowercase letters. A specification of
1985 @code{As_Is} provides the normal default behavior in which the casing is
1986 taken from the string provided.
1990 This pragma may appear anywhere that a pragma is valid. In particular, it
1991 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1992 case it applies to all subsequent compilations, or it can be used as a program
1993 unit pragma, in which case it only applies to the current unit, or it can
1994 be used more locally to control individual Import/Export pragmas.
1996 It is primarily intended for use with OpenVMS systems, where many
1997 compilers convert all symbols to upper case by default. For interfacing to
1998 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2001 @smallexample @c ada
2002 pragma External_Name_Casing (Uppercase, Uppercase);
2006 to enforce the upper casing of all external symbols.
2008 @node Pragma Finalize_Storage_Only
2009 @unnumberedsec Pragma Finalize_Storage_Only
2010 @findex Finalize_Storage_Only
2014 @smallexample @c ada
2015 pragma Finalize_Storage_Only (first_subtype_local_NAME);
2019 This pragma allows the compiler not to emit a Finalize call for objects
2020 defined at the library level. This is mostly useful for types where
2021 finalization is only used to deal with storage reclamation since in most
2022 environments it is not necessary to reclaim memory just before terminating
2023 execution, hence the name.
2025 @node Pragma Float_Representation
2026 @unnumberedsec Pragma Float_Representation
2028 @findex Float_Representation
2032 @smallexample @c ada
2033 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2035 FLOAT_REP ::= VAX_Float | IEEE_Float
2039 In the one argument form, this pragma is a configuration pragma which
2040 allows control over the internal representation chosen for the predefined
2041 floating point types declared in the packages @code{Standard} and
2042 @code{System}. On all systems other than OpenVMS, the argument must
2043 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2044 argument may be @code{VAX_Float} to specify the use of the VAX float
2045 format for the floating-point types in Standard. This requires that
2046 the standard runtime libraries be recompiled. See the
2047 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2048 of the GNAT Users Guide for details on the use of this command.
2050 The two argument form specifies the representation to be used for
2051 the specified floating-point type. On all systems other than OpenVMS,
2053 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2054 argument may be @code{VAX_Float} to specify the use of the VAX float
2059 For digits values up to 6, F float format will be used.
2061 For digits values from 7 to 9, G float format will be used.
2063 For digits values from 10 to 15, F float format will be used.
2065 Digits values above 15 are not allowed.
2069 @unnumberedsec Pragma Ident
2074 @smallexample @c ada
2075 pragma Ident (static_string_EXPRESSION);
2079 This pragma provides a string identification in the generated object file,
2080 if the system supports the concept of this kind of identification string.
2081 This pragma is allowed only in the outermost declarative part or
2082 declarative items of a compilation unit. If more than one @code{Ident}
2083 pragma is given, only the last one processed is effective.
2085 On OpenVMS systems, the effect of the pragma is identical to the effect of
2086 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2087 maximum allowed length is 31 characters, so if it is important to
2088 maintain compatibility with this compiler, you should obey this length
2091 @node Pragma Import_Exception
2092 @unnumberedsec Pragma Import_Exception
2094 @findex Import_Exception
2098 @smallexample @c ada
2099 pragma Import_Exception (
2100 [Internal =>] local_NAME,
2101 [, [External =>] EXTERNAL_SYMBOL,]
2102 [, [Form =>] Ada | VMS]
2103 [, [Code =>] static_integer_EXPRESSION]);
2107 | static_string_EXPRESSION
2111 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2112 It allows OpenVMS conditions (for example, from OpenVMS system services or
2113 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2114 The pragma specifies that the exception associated with an exception
2115 declaration in an Ada program be defined externally (in non-Ada code).
2116 For further details on this pragma, see the
2117 DEC Ada Language Reference Manual, section 13.9a.3.1.
2119 @node Pragma Import_Function
2120 @unnumberedsec Pragma Import_Function
2121 @findex Import_Function
2125 @smallexample @c ada
2126 pragma Import_Function (
2127 [Internal =>] local_NAME,
2128 [, [External =>] EXTERNAL_SYMBOL]
2129 [, [Parameter_Types =>] PARAMETER_TYPES]
2130 [, [Result_Type =>] SUBTYPE_MARK]
2131 [, [Mechanism =>] MECHANISM]
2132 [, [Result_Mechanism =>] MECHANISM_NAME]
2133 [, [First_Optional_Parameter =>] IDENTIFIER]);
2137 | static_string_EXPRESSION
2141 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2145 | subtype_Name ' Access
2149 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2151 MECHANISM_ASSOCIATION ::=
2152 [formal_parameter_NAME =>] MECHANISM_NAME
2157 | Descriptor [([Class =>] CLASS_NAME)]
2159 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2163 This pragma is used in conjunction with a pragma @code{Import} to
2164 specify additional information for an imported function. The pragma
2165 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2166 @code{Import_Function} pragma and both must appear in the same
2167 declarative part as the function specification.
2169 The @var{Internal} argument must uniquely designate
2170 the function to which the
2171 pragma applies. If more than one function name exists of this name in
2172 the declarative part you must use the @code{Parameter_Types} and
2173 @var{Result_Type} parameters to achieve the required unique
2174 designation. Subtype marks in these parameters must exactly match the
2175 subtypes in the corresponding function specification, using positional
2176 notation to match parameters with subtype marks.
2177 The form with an @code{'Access} attribute can be used to match an
2178 anonymous access parameter.
2180 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2181 parameters to specify passing mechanisms for the
2182 parameters and result. If you specify a single mechanism name, it
2183 applies to all parameters. Otherwise you may specify a mechanism on a
2184 parameter by parameter basis using either positional or named
2185 notation. If the mechanism is not specified, the default mechanism
2189 @cindex Passing by descriptor
2190 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2192 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2193 It specifies that the designated parameter and all following parameters
2194 are optional, meaning that they are not passed at the generated code
2195 level (this is distinct from the notion of optional parameters in Ada
2196 where the parameters are passed anyway with the designated optional
2197 parameters). All optional parameters must be of mode @code{IN} and have
2198 default parameter values that are either known at compile time
2199 expressions, or uses of the @code{'Null_Parameter} attribute.
2201 @node Pragma Import_Object
2202 @unnumberedsec Pragma Import_Object
2203 @findex Import_Object
2207 @smallexample @c ada
2208 pragma Import_Object
2209 [Internal =>] local_NAME,
2210 [, [External =>] EXTERNAL_SYMBOL],
2211 [, [Size =>] EXTERNAL_SYMBOL]);
2215 | static_string_EXPRESSION
2219 This pragma designates an object as imported, and apart from the
2220 extended rules for external symbols, is identical in effect to the use of
2221 the normal @code{Import} pragma applied to an object. Unlike the
2222 subprogram case, you need not use a separate @code{Import} pragma,
2223 although you may do so (and probably should do so from a portability
2224 point of view). @var{size} is syntax checked, but otherwise ignored by
2227 @node Pragma Import_Procedure
2228 @unnumberedsec Pragma Import_Procedure
2229 @findex Import_Procedure
2233 @smallexample @c ada
2234 pragma Import_Procedure (
2235 [Internal =>] local_NAME,
2236 [, [External =>] EXTERNAL_SYMBOL]
2237 [, [Parameter_Types =>] PARAMETER_TYPES]
2238 [, [Mechanism =>] MECHANISM]
2239 [, [First_Optional_Parameter =>] IDENTIFIER]);
2243 | static_string_EXPRESSION
2247 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2251 | subtype_Name ' Access
2255 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2257 MECHANISM_ASSOCIATION ::=
2258 [formal_parameter_NAME =>] MECHANISM_NAME
2263 | Descriptor [([Class =>] CLASS_NAME)]
2265 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2269 This pragma is identical to @code{Import_Function} except that it
2270 applies to a procedure rather than a function and the parameters
2271 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2273 @node Pragma Import_Valued_Procedure
2274 @unnumberedsec Pragma Import_Valued_Procedure
2275 @findex Import_Valued_Procedure
2279 @smallexample @c ada
2280 pragma Import_Valued_Procedure (
2281 [Internal =>] local_NAME,
2282 [, [External =>] EXTERNAL_SYMBOL]
2283 [, [Parameter_Types =>] PARAMETER_TYPES]
2284 [, [Mechanism =>] MECHANISM]
2285 [, [First_Optional_Parameter =>] IDENTIFIER]);
2289 | static_string_EXPRESSION
2293 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2297 | subtype_Name ' Access
2301 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2303 MECHANISM_ASSOCIATION ::=
2304 [formal_parameter_NAME =>] MECHANISM_NAME
2309 | Descriptor [([Class =>] CLASS_NAME)]
2311 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2315 This pragma is identical to @code{Import_Procedure} except that the
2316 first parameter of @var{local_NAME}, which must be present, must be of
2317 mode @code{OUT}, and externally the subprogram is treated as a function
2318 with this parameter as the result of the function. The purpose of this
2319 capability is to allow the use of @code{OUT} and @code{IN OUT}
2320 parameters in interfacing to external functions (which are not permitted
2321 in Ada functions). You may optionally use the @code{Mechanism}
2322 parameters to specify passing mechanisms for the parameters.
2323 If you specify a single mechanism name, it applies to all parameters.
2324 Otherwise you may specify a mechanism on a parameter by parameter
2325 basis using either positional or named notation. If the mechanism is not
2326 specified, the default mechanism is used.
2328 Note that it is important to use this pragma in conjunction with a separate
2329 pragma Import that specifies the desired convention, since otherwise the
2330 default convention is Ada, which is almost certainly not what is required.
2332 @node Pragma Initialize_Scalars
2333 @unnumberedsec Pragma Initialize_Scalars
2334 @findex Initialize_Scalars
2335 @cindex debugging with Initialize_Scalars
2339 @smallexample @c ada
2340 pragma Initialize_Scalars;
2344 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2345 two important differences. First, there is no requirement for the pragma
2346 to be used uniformly in all units of a partition, in particular, it is fine
2347 to use this just for some or all of the application units of a partition,
2348 without needing to recompile the run-time library.
2350 In the case where some units are compiled with the pragma, and some without,
2351 then a declaration of a variable where the type is defined in package
2352 Standard or is locally declared will always be subject to initialization,
2353 as will any declaration of a scalar variable. For composite variables,
2354 whether the variable is initialized may also depend on whether the package
2355 in which the type of the variable is declared is compiled with the pragma.
2357 The other important difference is that you can control the value used
2358 for initializing scalar objects. At bind time, you can select several
2359 options for initialization. You can
2360 initialize with invalid values (similar to Normalize_Scalars, though for
2361 Initialize_Scalars it is not always possible to determine the invalid
2362 values in complex cases like signed component fields with non-standard
2363 sizes). You can also initialize with high or
2364 low values, or with a specified bit pattern. See the users guide for binder
2365 options for specifying these cases.
2367 This means that you can compile a program, and then without having to
2368 recompile the program, you can run it with different values being used
2369 for initializing otherwise uninitialized values, to test if your program
2370 behavior depends on the choice. Of course the behavior should not change,
2371 and if it does, then most likely you have an erroneous reference to an
2372 uninitialized value.
2374 It is even possible to change the value at execution time eliminating even
2375 the need to rebind with a different switch using an environment variable.
2376 See the GNAT users guide for details.
2378 Note that pragma @code{Initialize_Scalars} is particularly useful in
2379 conjunction with the enhanced validity checking that is now provided
2380 in GNAT, which checks for invalid values under more conditions.
2381 Using this feature (see description of the @code{-gnatV} flag in the
2382 users guide) in conjunction with pragma @code{Initialize_Scalars}
2383 provides a powerful new tool to assist in the detection of problems
2384 caused by uninitialized variables.
2386 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2387 effect on the generated code. This may cause your code to be
2388 substantially larger. It may also cause an increase in the amount
2389 of stack required, so it is probably a good idea to turn on stack
2390 checking (see description of stack checking in the GNAT users guide)
2391 when using this pragma.
2393 @node Pragma Inline_Always
2394 @unnumberedsec Pragma Inline_Always
2395 @findex Inline_Always
2399 @smallexample @c ada
2400 pragma Inline_Always (NAME [, NAME]);
2404 Similar to pragma @code{Inline} except that inlining is not subject to
2405 the use of option @code{-gnatn} and the inlining happens regardless of
2406 whether this option is used.
2408 @node Pragma Inline_Generic
2409 @unnumberedsec Pragma Inline_Generic
2410 @findex Inline_Generic
2414 @smallexample @c ada
2415 pragma Inline_Generic (generic_package_NAME);
2419 This is implemented for compatibility with DEC Ada 83 and is recognized,
2420 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2421 by default when using GNAT@.
2423 @node Pragma Interface
2424 @unnumberedsec Pragma Interface
2429 @smallexample @c ada
2431 [Convention =>] convention_identifier,
2432 [Entity =>] local_NAME
2433 [, [External_Name =>] static_string_expression],
2434 [, [Link_Name =>] static_string_expression]);
2438 This pragma is identical in syntax and semantics to
2439 the standard Ada 95 pragma @code{Import}. It is provided for compatibility
2440 with Ada 83. The definition is upwards compatible both with pragma
2441 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2442 with some extended implementations of this pragma in certain Ada 83
2445 @node Pragma Interface_Name
2446 @unnumberedsec Pragma Interface_Name
2447 @findex Interface_Name
2451 @smallexample @c ada
2452 pragma Interface_Name (
2453 [Entity =>] local_NAME
2454 [, [External_Name =>] static_string_EXPRESSION]
2455 [, [Link_Name =>] static_string_EXPRESSION]);
2459 This pragma provides an alternative way of specifying the interface name
2460 for an interfaced subprogram, and is provided for compatibility with Ada
2461 83 compilers that use the pragma for this purpose. You must provide at
2462 least one of @var{External_Name} or @var{Link_Name}.
2464 @node Pragma Interrupt_Handler
2465 @unnumberedsec Pragma Interrupt_Handler
2466 @findex Interrupt_Handler
2470 @smallexample @c ada
2471 pragma Interrupt_Handler (procedure_local_NAME);
2475 This program unit pragma is supported for parameterless protected procedures
2476 as described in Annex C of the Ada Reference Manual. On the AAMP target
2477 the pragma can also be specified for nonprotected parameterless procedures
2478 that are declared at the library level (which includes procedures
2479 declared at the top level of a library package). In the case of AAMP,
2480 when this pragma is applied to a nonprotected procedure, the instruction
2481 @code{IERET} is generated for returns from the procedure, enabling
2482 maskable interrupts, in place of the normal return instruction.
2484 @node Pragma Interrupt_State
2485 @unnumberedsec Pragma Interrupt_State
2486 @findex Interrupt_State
2490 @smallexample @c ada
2491 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2495 Normally certain interrupts are reserved to the implementation. Any attempt
2496 to attach an interrupt causes Program_Error to be raised, as described in
2497 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2498 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2499 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2500 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2501 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2502 Ada exceptions, or used to implement run-time functions such as the
2503 @code{abort} statement and stack overflow checking.
2505 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2506 such uses of interrupts. It subsumes the functionality of pragma
2507 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2508 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2509 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2510 and may be used to mark interrupts required by the board support package
2513 Interrupts can be in one of three states:
2517 The interrupt is reserved (no Ada handler can be installed), and the
2518 Ada run-time may not install a handler. As a result you are guaranteed
2519 standard system default action if this interrupt is raised.
2523 The interrupt is reserved (no Ada handler can be installed). The run time
2524 is allowed to install a handler for internal control purposes, but is
2525 not required to do so.
2529 The interrupt is unreserved. The user may install a handler to provide
2534 These states are the allowed values of the @code{State} parameter of the
2535 pragma. The @code{Name} parameter is a value of the type
2536 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2537 @code{Ada.Interrupts.Names}.
2539 This is a configuration pragma, and the binder will check that there
2540 are no inconsistencies between different units in a partition in how a
2541 given interrupt is specified. It may appear anywhere a pragma is legal.
2543 The effect is to move the interrupt to the specified state.
2545 By declaring interrupts to be SYSTEM, you guarantee the standard system
2546 action, such as a core dump.
2548 By declaring interrupts to be USER, you guarantee that you can install
2551 Note that certain signals on many operating systems cannot be caught and
2552 handled by applications. In such cases, the pragma is ignored. See the
2553 operating system documentation, or the value of the array @code{Reserved}
2554 declared in the specification of package @code{System.OS_Interface}.
2556 Overriding the default state of signals used by the Ada runtime may interfere
2557 with an application's runtime behavior in the cases of the synchronous signals,
2558 and in the case of the signal used to implement the @code{abort} statement.
2560 @node Pragma Keep_Names
2561 @unnumberedsec Pragma Keep_Names
2566 @smallexample @c ada
2567 pragma Keep_Names ([On =>] enumeration_first_subtype_local_NAME);
2571 The @var{local_NAME} argument
2572 must refer to an enumeration first subtype
2573 in the current declarative part. The effect is to retain the enumeration
2574 literal names for use by @code{Image} and @code{Value} even if a global
2575 @code{Discard_Names} pragma applies. This is useful when you want to
2576 generally suppress enumeration literal names and for example you therefore
2577 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2578 want to retain the names for specific enumeration types.
2580 @node Pragma License
2581 @unnumberedsec Pragma License
2583 @cindex License checking
2587 @smallexample @c ada
2588 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2592 This pragma is provided to allow automated checking for appropriate license
2593 conditions with respect to the standard and modified GPL@. A pragma
2594 @code{License}, which is a configuration pragma that typically appears at
2595 the start of a source file or in a separate @file{gnat.adc} file, specifies
2596 the licensing conditions of a unit as follows:
2600 This is used for a unit that can be freely used with no license restrictions.
2601 Examples of such units are public domain units, and units from the Ada
2605 This is used for a unit that is licensed under the unmodified GPL, and which
2606 therefore cannot be @code{with}'ed by a restricted unit.
2609 This is used for a unit licensed under the GNAT modified GPL that includes
2610 a special exception paragraph that specifically permits the inclusion of
2611 the unit in programs without requiring the entire program to be released
2615 This is used for a unit that is restricted in that it is not permitted to
2616 depend on units that are licensed under the GPL@. Typical examples are
2617 proprietary code that is to be released under more restrictive license
2618 conditions. Note that restricted units are permitted to @code{with} units
2619 which are licensed under the modified GPL (this is the whole point of the
2625 Normally a unit with no @code{License} pragma is considered to have an
2626 unknown license, and no checking is done. However, standard GNAT headers
2627 are recognized, and license information is derived from them as follows.
2631 A GNAT license header starts with a line containing 78 hyphens. The following
2632 comment text is searched for the appearance of any of the following strings.
2634 If the string ``GNU General Public License'' is found, then the unit is assumed
2635 to have GPL license, unless the string ``As a special exception'' follows, in
2636 which case the license is assumed to be modified GPL@.
2638 If one of the strings
2639 ``This specification is adapted from the Ada Semantic Interface'' or
2640 ``This specification is derived from the Ada Reference Manual'' is found
2641 then the unit is assumed to be unrestricted.
2645 These default actions means that a program with a restricted license pragma
2646 will automatically get warnings if a GPL unit is inappropriately
2647 @code{with}'ed. For example, the program:
2649 @smallexample @c ada
2652 procedure Secret_Stuff is
2658 if compiled with pragma @code{License} (@code{Restricted}) in a
2659 @file{gnat.adc} file will generate the warning:
2664 >>> license of withed unit "Sem_Ch3" is incompatible
2666 2. with GNAT.Sockets;
2667 3. procedure Secret_Stuff is
2671 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2672 compiler and is licensed under the
2673 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2674 run time, and is therefore licensed under the modified GPL@.
2676 @node Pragma Link_With
2677 @unnumberedsec Pragma Link_With
2682 @smallexample @c ada
2683 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2687 This pragma is provided for compatibility with certain Ada 83 compilers.
2688 It has exactly the same effect as pragma @code{Linker_Options} except
2689 that spaces occurring within one of the string expressions are treated
2690 as separators. For example, in the following case:
2692 @smallexample @c ada
2693 pragma Link_With ("-labc -ldef");
2697 results in passing the strings @code{-labc} and @code{-ldef} as two
2698 separate arguments to the linker. In addition pragma Link_With allows
2699 multiple arguments, with the same effect as successive pragmas.
2701 @node Pragma Linker_Alias
2702 @unnumberedsec Pragma Linker_Alias
2703 @findex Linker_Alias
2707 @smallexample @c ada
2708 pragma Linker_Alias (
2709 [Entity =>] local_NAME
2710 [Target =>] static_string_EXPRESSION);
2714 @var{local_NAME} must refer to an object that is declared at the library
2715 level. This pragma establishes the given entity as a linker alias for the
2716 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
2717 and causes @var{local_NAME} to be emitted as an alias for the symbol
2718 @var{static_string_EXPRESSION} in the object file, that is to say no space
2719 is reserved for @var{local_NAME} by the assembler and it will be resolved
2720 to the same address as @var{static_string_EXPRESSION} by the linker.
2722 The actual linker name for the target must be used (e.g. the fully
2723 encoded name with qualification in Ada, or the mangled name in C++),
2724 or it must be declared using the C convention with @code{pragma Import}
2725 or @code{pragma Export}.
2727 Not all target machines support this pragma. On some of them it is accepted
2728 only if @code{pragma Weak_External} has been applied to @var{local_NAME}.
2730 @smallexample @c ada
2731 -- Example of the use of pragma Linker_Alias
2735 pragma Export (C, i);
2737 new_name_for_i : Integer;
2738 pragma Linker_Alias (new_name_for_i, "i");
2742 @node Pragma Linker_Constructor
2743 @unnumberedsec Pragma Linker_Constructor
2744 @findex Linker_Constructor
2748 @smallexample @c ada
2749 pragma Linker_Constructor (procedure_LOCAL_NAME);
2753 @var{procedure_local_NAME} must refer to a parameterless procedure that
2754 is declared at the library level. A procedure to which this pragma is
2755 applied will be treated as an initialization routine by the linker.
2756 It is equivalent to @code{__attribute__((constructor))} in GNU C and
2757 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
2758 of the executable is called (or immediately after the shared library is
2759 loaded if the procedure is linked in a shared library), in particular
2760 before the Ada run-time environment is set up.
2762 Because of these specific contexts, the set of operations such a procedure
2763 can perform is very limited and the type of objects it can manipulate is
2764 essentially restricted to the elementary types. In particular, it must only
2765 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
2767 This pragma is used by GNAT to implement auto-initialization of shared Stand
2768 Alone Libraries, which provides a related capability without the restrictions
2769 listed above. Where possible, the use of Stand Alone Libraries is preferable
2770 to the use of this pragma.
2772 @node Pragma Linker_Destructor
2773 @unnumberedsec Pragma Linker_Destructor
2774 @findex Linker_Destructor
2778 @smallexample @c ada
2779 pragma Linker_Destructor (procedure_LOCAL_NAME);
2783 @var{procedure_local_NAME} must refer to a parameterless procedure that
2784 is declared at the library level. A procedure to which this pragma is
2785 applied will be treated as a finalization routine by the linker.
2786 It is equivalent to @code{__attribute__((destructor))} in GNU C and
2787 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
2788 of the executable has exited (or immediately before the shared library
2789 is unloaded if the procedure is linked in a shared library), in particular
2790 after the Ada run-time environment is shut down.
2792 See @code{pragma Linker_Constructor} for the set of restrictions that apply
2793 because of these specific contexts.
2795 @node Pragma Linker_Section
2796 @unnumberedsec Pragma Linker_Section
2797 @findex Linker_Section
2801 @smallexample @c ada
2802 pragma Linker_Section (
2803 [Entity =>] local_NAME
2804 [Section =>] static_string_EXPRESSION);
2808 @var{local_NAME} must refer to an object that is declared at the library
2809 level. This pragma specifies the name of the linker section for the given
2810 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
2811 causes @var{local_NAME} to be placed in the @var{static_string_EXPRESSION}
2812 section of the executable (assuming the linker doesn't rename the section).
2814 The compiler normally places library-level objects in standard sections
2815 depending on their type: procedures and functions generally go in the
2816 @code{.text} section, initialized variables in the @code{.data} section
2817 and uninitialized variables in the @code{.bss} section.
2819 Other, special sections may exist on given target machines to map special
2820 hardware, for example I/O ports or flash memory. This pragma is a means to
2821 defer the final layout of the executable to the linker, thus fully working
2822 at the symbolic level with the compiler.
2824 Some file formats do not support arbitrary sections so not all target
2825 machines support this pragma. The use of this pragma may cause a program
2826 execution to be erroneous if it is used to place an entity into an
2827 inappropriate section (e.g. a modified variable into the @code{.text}
2828 section). See also @code{pragma Persistent_BSS}.
2830 @smallexample @c ada
2831 -- Example of the use of pragma Linker_Section
2835 pragma Volatile (Port_A);
2836 pragma Linker_Section (Port_A, ".bss.port_a");
2839 pragma Volatile (Port_B);
2840 pragma Linker_Section (Port_B, ".bss.port_b");
2844 @node Pragma Long_Float
2845 @unnumberedsec Pragma Long_Float
2851 @smallexample @c ada
2852 pragma Long_Float (FLOAT_FORMAT);
2854 FLOAT_FORMAT ::= D_Float | G_Float
2858 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2859 It allows control over the internal representation chosen for the predefined
2860 type @code{Long_Float} and for floating point type representations with
2861 @code{digits} specified in the range 7 through 15.
2862 For further details on this pragma, see the
2863 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
2864 this pragma, the standard runtime libraries must be recompiled. See the
2865 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2866 of the GNAT User's Guide for details on the use of this command.
2868 @node Pragma Machine_Attribute
2869 @unnumberedsec Pragma Machine_Attribute
2870 @findex Machine_Attribute
2874 @smallexample @c ada
2875 pragma Machine_Attribute (
2876 [Attribute_Name =>] string_EXPRESSION,
2877 [Entity =>] local_NAME);
2881 Machine-dependent attributes can be specified for types and/or
2882 declarations. This pragma is semantically equivalent to
2883 @code{__attribute__((@var{string_expression}))} in GNU C,
2884 where @code{@var{string_expression}} is
2885 recognized by the target macro @code{TARGET_ATTRIBUTE_TABLE} which is
2886 defined for each machine. See the GCC manual for further information.
2887 It is not possible to specify attributes defined by other languages,
2888 only attributes defined by the machine the code is intended to run on.
2890 @node Pragma Main_Storage
2891 @unnumberedsec Pragma Main_Storage
2893 @findex Main_Storage
2897 @smallexample @c ada
2899 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2901 MAIN_STORAGE_OPTION ::=
2902 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2903 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
2908 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
2909 no effect in GNAT, other than being syntax checked. Note that the pragma
2910 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2912 @node Pragma No_Return
2913 @unnumberedsec Pragma No_Return
2918 @smallexample @c ada
2919 pragma No_Return (procedure_local_NAME);
2923 @var{procedure_local_NAME} must refer to one or more procedure
2924 declarations in the current declarative part. A procedure to which this
2925 pragma is applied may not contain any explicit @code{return} statements,
2926 and also may not contain any implicit return statements from falling off
2927 the end of a statement sequence. One use of this pragma is to identify
2928 procedures whose only purpose is to raise an exception.
2930 Another use of this pragma is to suppress incorrect warnings about
2931 missing returns in functions, where the last statement of a function
2932 statement sequence is a call to such a procedure.
2934 @node Pragma No_Strict_Aliasing
2935 @unnumberedsec Pragma No_Strict_Aliasing
2936 @findex No_Strict_Aliasing
2940 @smallexample @c ada
2941 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
2945 @var{type_LOCAL_NAME} must refer to an access type
2946 declaration in the current declarative part. The effect is to inhibit
2947 strict aliasing optimization for the given type. The form with no
2948 arguments is a configuration pragma which applies to all access types
2949 declared in units to which the pragma applies. For a detailed
2950 description of the strict aliasing optimization, and the situations
2951 in which it must be suppressed, see section
2952 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
2954 @node Pragma Normalize_Scalars
2955 @unnumberedsec Pragma Normalize_Scalars
2956 @findex Normalize_Scalars
2960 @smallexample @c ada
2961 pragma Normalize_Scalars;
2965 This is a language defined pragma which is fully implemented in GNAT@. The
2966 effect is to cause all scalar objects that are not otherwise initialized
2967 to be initialized. The initial values are implementation dependent and
2971 @item Standard.Character
2973 Objects whose root type is Standard.Character are initialized to
2974 Character'Last unless the subtype range excludes NUL (in which case
2975 NUL is used). This choice will always generate an invalid value if
2978 @item Standard.Wide_Character
2980 Objects whose root type is Standard.Wide_Character are initialized to
2981 Wide_Character'Last unless the subtype range excludes NUL (in which case
2982 NUL is used). This choice will always generate an invalid value if
2985 @item Standard.Wide_Wide_Character
2987 Objects whose root type is Standard.Wide_Wide_Character are initialized to
2988 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
2989 which case NUL is used). This choice will always generate an invalid value if
2994 Objects of an integer type are treated differently depending on whether
2995 negative values are present in the subtype. If no negative values are
2996 present, then all one bits is used as the initial value except in the
2997 special case where zero is excluded from the subtype, in which case
2998 all zero bits are used. This choice will always generate an invalid
2999 value if one exists.
3001 For subtypes with negative values present, the largest negative number
3002 is used, except in the unusual case where this largest negative number
3003 is in the subtype, and the largest positive number is not, in which case
3004 the largest positive value is used. This choice will always generate
3005 an invalid value if one exists.
3007 @item Floating-Point Types
3008 Objects of all floating-point types are initialized to all 1-bits. For
3009 standard IEEE format, this corresponds to a NaN (not a number) which is
3010 indeed an invalid value.
3012 @item Fixed-Point Types
3013 Objects of all fixed-point types are treated as described above for integers,
3014 with the rules applying to the underlying integer value used to represent
3015 the fixed-point value.
3018 Objects of a modular type are initialized to all one bits, except in
3019 the special case where zero is excluded from the subtype, in which
3020 case all zero bits are used. This choice will always generate an
3021 invalid value if one exists.
3023 @item Enumeration types
3024 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3025 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3026 whose Pos value is zero, in which case a code of zero is used. This choice
3027 will always generate an invalid value if one exists.
3031 @node Pragma Obsolescent
3032 @unnumberedsec Pragma Obsolescent
3037 @smallexample @c ada
3038 pragma Obsolescent [(static_string_EXPRESSION [,Ada_05])];
3042 This pragma can occur immediately following a subprogram
3043 declaration and indicates that the associated function or procedure
3044 is considered obsolescent and should not be used. Typically this is
3045 used when an API must be modified by eventually removing or modifying
3046 existing subprograms. The pragma can be used at an intermediate stage
3047 when the subprogram is still present, but will be removed later.
3049 The effect of this pragma is to output a warning message on
3050 a call to a program thus marked that the
3051 subprogram is obsolescent if the appropriate warning option in the
3052 compiler is activated. If a parameter is present, then a second
3053 warning message is given containing this text.
3054 In addition, a call to such a program is considered a violation of
3055 pragma Restrictions (No_Obsolescent_Features).
3057 This pragma can also be used as a program unit pragma for a package,
3058 in which case it indicates that the entire package is considered
3059 obsolescent. In this case a client @code{with}'ing such a package
3060 violates the restriction, and the @code{with} statement is
3061 flagged with warnings if the warning option is set.
3063 If the optional second parameter is present (which must be exactly
3064 the identifier Ada_05, no other argument is allowed), then the
3065 indication of obsolescence applies only when compiling in Ada 2005
3066 mode. This is primarily intended for dealing with the situations
3067 in the predefined library where subprograms or packages
3068 have become defined as obsolescent in Ada 2005
3069 (e.g. in Ada.Characters.Handling), but may be used anywhere.
3071 @node Pragma Passive
3072 @unnumberedsec Pragma Passive
3077 @smallexample @c ada
3078 pragma Passive ([Semaphore | No]);
3082 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3083 compatibility with DEC Ada 83 implementations, where it is used within a
3084 task definition to request that a task be made passive. If the argument
3085 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3086 treats the pragma as an assertion that the containing task is passive
3087 and that optimization of context switch with this task is permitted and
3088 desired. If the argument @code{No} is present, the task must not be
3089 optimized. GNAT does not attempt to optimize any tasks in this manner
3090 (since protected objects are available in place of passive tasks).
3092 @node Pragma Persistent_BSS
3093 @unnumberedsec Pragma Persistent_BSS
3094 @findex Persistent_BSS
3098 @smallexample @c ada
3099 pragma Persistent_BSS [local_NAME]
3103 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3104 section. On some targets the linker and loader provide for special
3105 treatment of this section, allowing a program to be reloaded without
3106 affecting the contents of this data (hence the name persistent).
3108 There are two forms of usage. If an argument is given, it must be the
3109 local name of a library level object, with no explicit initialization
3110 and whose type is potentially persistent. If no argument is given, then
3111 the pragma is a configuration pragma, and applies to all library level
3112 objects with no explicit initialization of potentially persistent types.
3114 A potentially persistent type is a scalar type, or a non-tagged,
3115 non-discriminated record, all of whose components have no explicit
3116 initialization and are themselves of a potentially persistent type,
3117 or an array, all of whose constraints are static, and whose component
3118 type is potentially persistent.
3120 If this pragma is used on a target where this feature is not supported,
3121 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3123 @node Pragma Polling
3124 @unnumberedsec Pragma Polling
3129 @smallexample @c ada
3130 pragma Polling (ON | OFF);
3134 This pragma controls the generation of polling code. This is normally off.
3135 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3136 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3137 runtime library, and can be found in file @file{a-excpol.adb}.
3139 Pragma @code{Polling} can appear as a configuration pragma (for example it
3140 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3141 can be used in the statement or declaration sequence to control polling
3144 A call to the polling routine is generated at the start of every loop and
3145 at the start of every subprogram call. This guarantees that the @code{Poll}
3146 routine is called frequently, and places an upper bound (determined by
3147 the complexity of the code) on the period between two @code{Poll} calls.
3149 The primary purpose of the polling interface is to enable asynchronous
3150 aborts on targets that cannot otherwise support it (for example Windows
3151 NT), but it may be used for any other purpose requiring periodic polling.
3152 The standard version is null, and can be replaced by a user program. This
3153 will require re-compilation of the @code{Ada.Exceptions} package that can
3154 be found in files @file{a-except.ads} and @file{a-except.adb}.
3156 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3157 distribution) is used to enable the asynchronous abort capability on
3158 targets that do not normally support the capability. The version of
3159 @code{Poll} in this file makes a call to the appropriate runtime routine
3160 to test for an abort condition.
3162 Note that polling can also be enabled by use of the @code{-gnatP} switch. See
3163 the @cite{GNAT User's Guide} for details.
3165 @node Pragma Profile (Ravenscar)
3166 @unnumberedsec Pragma Profile (Ravenscar)
3171 @smallexample @c ada
3172 pragma Profile (Ravenscar);
3176 A configuration pragma that establishes the following set of configuration
3180 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3181 [RM D.2.2] Tasks are dispatched following a preemptive
3182 priority-ordered scheduling policy.
3184 @item Locking_Policy (Ceiling_Locking)
3185 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3186 the ceiling priority of the corresponding protected object.
3188 @c @item Detect_Blocking
3189 @c This pragma forces the detection of potentially blocking operations within a
3190 @c protected operation, and to raise Program_Error if that happens.
3194 plus the following set of restrictions:
3197 @item Max_Entry_Queue_Length = 1
3198 Defines the maximum number of calls that are queued on a (protected) entry.
3199 Note that this restrictions is checked at run time. Violation of this
3200 restriction results in the raising of Program_Error exception at the point of
3201 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3202 always 1 and hence no task can be queued on a protected entry.
3204 @item Max_Protected_Entries = 1
3205 [RM D.7] Specifies the maximum number of entries per protected type. The
3206 bounds of every entry family of a protected unit shall be static, or shall be
3207 defined by a discriminant of a subtype whose corresponding bound is static.
3208 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3210 @item Max_Task_Entries = 0
3211 [RM D.7] Specifies the maximum number of entries
3212 per task. The bounds of every entry family
3213 of a task unit shall be static, or shall be
3214 defined by a discriminant of a subtype whose
3215 corresponding bound is static. A value of zero
3216 indicates that no rendezvous are possible. For
3217 the Profile (Ravenscar), the value of Max_Task_Entries is always
3220 @item No_Abort_Statements
3221 [RM D.7] There are no abort_statements, and there are
3222 no calls to Task_Identification.Abort_Task.
3224 @item No_Asynchronous_Control
3225 [RM D.7] There are no semantic dependences on the package
3226 Asynchronous_Task_Control.
3229 There are no semantic dependencies on the package Ada.Calendar.
3231 @item No_Dynamic_Attachment
3232 There is no call to any of the operations defined in package Ada.Interrupts
3233 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3234 Detach_Handler, and Reference).
3236 @item No_Dynamic_Priorities
3237 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3239 @item No_Implicit_Heap_Allocations
3240 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3242 @item No_Local_Protected_Objects
3243 Protected objects and access types that designate
3244 such objects shall be declared only at library level.
3246 @item No_Protected_Type_Allocators
3247 There are no allocators for protected types or
3248 types containing protected subcomponents.
3250 @item No_Relative_Delay
3251 There are no delay_relative statements.
3253 @item No_Requeue_Statements
3254 Requeue statements are not allowed.
3256 @item No_Select_Statements
3257 There are no select_statements.
3259 @item No_Task_Allocators
3260 [RM D.7] There are no allocators for task types
3261 or types containing task subcomponents.
3263 @item No_Task_Attributes_Package
3264 There are no semantic dependencies on the Ada.Task_Attributes package.
3266 @item No_Task_Hierarchy
3267 [RM D.7] All (non-environment) tasks depend
3268 directly on the environment task of the partition.
3270 @item No_Task_Termination
3271 Tasks which terminate are erroneous.
3273 @item Simple_Barriers
3274 Entry barrier condition expressions shall be either static
3275 boolean expressions or boolean objects which are declared in
3276 the protected type which contains the entry.
3280 This set of configuration pragmas and restrictions correspond to the
3281 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3282 published by the @cite{International Real-Time Ada Workshop}, 1997,
3283 and whose most recent description is available at
3284 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
3286 The original definition of the profile was revised at subsequent IRTAW
3287 meetings. It has been included in the ISO
3288 @cite{Guide for the Use of the Ada Programming Language in High
3289 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3290 the next revision of the standard. The formal definition given by
3291 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3292 AI-305) available at
3293 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3294 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3297 The above set is a superset of the restrictions provided by pragma
3298 @code{Profile (Restricted)}, it includes six additional restrictions
3299 (@code{Simple_Barriers}, @code{No_Select_Statements},
3300 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3301 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
3302 that pragma @code{Profile (Ravenscar)}, like the pragma
3303 @code{Profile (Restricted)},
3304 automatically causes the use of a simplified,
3305 more efficient version of the tasking run-time system.
3307 @node Pragma Profile (Restricted)
3308 @unnumberedsec Pragma Profile (Restricted)
3309 @findex Restricted Run Time
3313 @smallexample @c ada
3314 pragma Profile (Restricted);
3318 A configuration pragma that establishes the following set of restrictions:
3321 @item No_Abort_Statements
3322 @item No_Entry_Queue
3323 @item No_Task_Hierarchy
3324 @item No_Task_Allocators
3325 @item No_Dynamic_Priorities
3326 @item No_Terminate_Alternatives
3327 @item No_Dynamic_Attachment
3328 @item No_Protected_Type_Allocators
3329 @item No_Local_Protected_Objects
3330 @item No_Requeue_Statements
3331 @item No_Task_Attributes_Package
3332 @item Max_Asynchronous_Select_Nesting = 0
3333 @item Max_Task_Entries = 0
3334 @item Max_Protected_Entries = 1
3335 @item Max_Select_Alternatives = 0
3339 This set of restrictions causes the automatic selection of a simplified
3340 version of the run time that provides improved performance for the
3341 limited set of tasking functionality permitted by this set of restrictions.
3343 @node Pragma Propagate_Exceptions
3344 @unnumberedsec Pragma Propagate_Exceptions
3345 @findex Propagate_Exceptions
3346 @cindex Zero Cost Exceptions
3350 @smallexample @c ada
3351 pragma Propagate_Exceptions (subprogram_local_NAME);
3355 This pragma indicates that the given entity, which is the name of an
3356 imported foreign-language subprogram may receive an Ada exception,
3357 and that the exception should be propagated. It is relevant only if
3358 zero cost exception handling is in use, and is thus never needed if
3359 the alternative @code{longjmp} / @code{setjmp} implementation of
3360 exceptions is used (although it is harmless to use it in such cases).
3362 The implementation of fast exceptions always properly propagates
3363 exceptions through Ada code, as described in the Ada Reference Manual.
3364 However, this manual is silent about the propagation of exceptions
3365 through foreign code. For example, consider the
3366 situation where @code{P1} calls
3367 @code{P2}, and @code{P2} calls @code{P3}, where
3368 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
3369 @code{P3} raises an Ada exception. The question is whether or not
3370 it will be propagated through @code{P2} and can be handled in
3373 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
3374 the answer is always yes. For some targets on which zero cost exception
3375 handling is implemented, the answer is also always yes. However, there
3376 are some targets, notably in the current version all x86 architecture
3377 targets, in which the answer is that such propagation does not
3378 happen automatically. If such propagation is required on these
3379 targets, it is mandatory to use @code{Propagate_Exceptions} to
3380 name all foreign language routines through which Ada exceptions
3383 @node Pragma Psect_Object
3384 @unnumberedsec Pragma Psect_Object
3385 @findex Psect_Object
3389 @smallexample @c ada
3390 pragma Psect_Object (
3391 [Internal =>] local_NAME,
3392 [, [External =>] EXTERNAL_SYMBOL]
3393 [, [Size =>] EXTERNAL_SYMBOL]);
3397 | static_string_EXPRESSION
3401 This pragma is identical in effect to pragma @code{Common_Object}.
3403 @node Pragma Pure_Function
3404 @unnumberedsec Pragma Pure_Function
3405 @findex Pure_Function
3409 @smallexample @c ada
3410 pragma Pure_Function ([Entity =>] function_local_NAME);
3414 This pragma appears in the same declarative part as a function
3415 declaration (or a set of function declarations if more than one
3416 overloaded declaration exists, in which case the pragma applies
3417 to all entities). It specifies that the function @code{Entity} is
3418 to be considered pure for the purposes of code generation. This means
3419 that the compiler can assume that there are no side effects, and
3420 in particular that two calls with identical arguments produce the
3421 same result. It also means that the function can be used in an
3424 Note that, quite deliberately, there are no static checks to try
3425 to ensure that this promise is met, so @code{Pure_Function} can be used
3426 with functions that are conceptually pure, even if they do modify
3427 global variables. For example, a square root function that is
3428 instrumented to count the number of times it is called is still
3429 conceptually pure, and can still be optimized, even though it
3430 modifies a global variable (the count). Memo functions are another
3431 example (where a table of previous calls is kept and consulted to
3432 avoid re-computation).
3435 Note: Most functions in a @code{Pure} package are automatically pure, and
3436 there is no need to use pragma @code{Pure_Function} for such functions. One
3437 exception is any function that has at least one formal of type
3438 @code{System.Address} or a type derived from it. Such functions are not
3439 considered pure by default, since the compiler assumes that the
3440 @code{Address} parameter may be functioning as a pointer and that the
3441 referenced data may change even if the address value does not.
3442 Similarly, imported functions are not considered to be pure by default,
3443 since there is no way of checking that they are in fact pure. The use
3444 of pragma @code{Pure_Function} for such a function will override these default
3445 assumption, and cause the compiler to treat a designated subprogram as pure
3448 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3449 applies to the underlying renamed function. This can be used to
3450 disambiguate cases of overloading where some but not all functions
3451 in a set of overloaded functions are to be designated as pure.
3453 @node Pragma Restriction_Warnings
3454 @unnumberedsec Pragma Restriction_Warnings
3455 @findex Restriction_Warnings
3459 @smallexample @c ada
3460 pragma Restriction_Warnings
3461 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3465 This pragma allows a series of restriction identifiers to be
3466 specified (the list of allowed identifiers is the same as for
3467 pragma @code{Restrictions}). For each of these identifiers
3468 the compiler checks for violations of the restriction, but
3469 generates a warning message rather than an error message
3470 if the restriction is violated.
3472 @node Pragma Source_File_Name
3473 @unnumberedsec Pragma Source_File_Name
3474 @findex Source_File_Name
3478 @smallexample @c ada
3479 pragma Source_File_Name (
3480 [Unit_Name =>] unit_NAME,
3481 Spec_File_Name => STRING_LITERAL);
3483 pragma Source_File_Name (
3484 [Unit_Name =>] unit_NAME,
3485 Body_File_Name => STRING_LITERAL);
3489 Use this to override the normal naming convention. It is a configuration
3490 pragma, and so has the usual applicability of configuration pragmas
3491 (i.e.@: it applies to either an entire partition, or to all units in a
3492 compilation, or to a single unit, depending on how it is used.
3493 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
3494 the second argument is required, and indicates whether this is the file
3495 name for the spec or for the body.
3497 Another form of the @code{Source_File_Name} pragma allows
3498 the specification of patterns defining alternative file naming schemes
3499 to apply to all files.
3501 @smallexample @c ada
3502 pragma Source_File_Name
3503 (Spec_File_Name => STRING_LITERAL
3504 [,Casing => CASING_SPEC]
3505 [,Dot_Replacement => STRING_LITERAL]);
3507 pragma Source_File_Name
3508 (Body_File_Name => STRING_LITERAL
3509 [,Casing => CASING_SPEC]
3510 [,Dot_Replacement => STRING_LITERAL]);
3512 pragma Source_File_Name
3513 (Subunit_File_Name => STRING_LITERAL
3514 [,Casing => CASING_SPEC]
3515 [,Dot_Replacement => STRING_LITERAL]);
3517 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3521 The first argument is a pattern that contains a single asterisk indicating
3522 the point at which the unit name is to be inserted in the pattern string
3523 to form the file name. The second argument is optional. If present it
3524 specifies the casing of the unit name in the resulting file name string.
3525 The default is lower case. Finally the third argument allows for systematic
3526 replacement of any dots in the unit name by the specified string literal.
3528 A pragma Source_File_Name cannot appear after a
3529 @ref{Pragma Source_File_Name_Project}.
3531 For more details on the use of the @code{Source_File_Name} pragma,
3532 see the sections ``Using Other File Names'' and
3533 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3535 @node Pragma Source_File_Name_Project
3536 @unnumberedsec Pragma Source_File_Name_Project
3537 @findex Source_File_Name_Project
3540 This pragma has the same syntax and semantics as pragma Source_File_Name.
3541 It is only allowed as a stand alone configuration pragma.
3542 It cannot appear after a @ref{Pragma Source_File_Name}, and
3543 most importantly, once pragma Source_File_Name_Project appears,
3544 no further Source_File_Name pragmas are allowed.
3546 The intention is that Source_File_Name_Project pragmas are always
3547 generated by the Project Manager in a manner consistent with the naming
3548 specified in a project file, and when naming is controlled in this manner,
3549 it is not permissible to attempt to modify this naming scheme using
3550 Source_File_Name pragmas (which would not be known to the project manager).
3552 @node Pragma Source_Reference
3553 @unnumberedsec Pragma Source_Reference
3554 @findex Source_Reference
3558 @smallexample @c ada
3559 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3563 This pragma must appear as the first line of a source file.
3564 @var{integer_literal} is the logical line number of the line following
3565 the pragma line (for use in error messages and debugging
3566 information). @var{string_literal} is a static string constant that
3567 specifies the file name to be used in error messages and debugging
3568 information. This is most notably used for the output of @code{gnatchop}
3569 with the @code{-r} switch, to make sure that the original unchopped
3570 source file is the one referred to.
3572 The second argument must be a string literal, it cannot be a static
3573 string expression other than a string literal. This is because its value
3574 is needed for error messages issued by all phases of the compiler.
3576 @node Pragma Stream_Convert
3577 @unnumberedsec Pragma Stream_Convert
3578 @findex Stream_Convert
3582 @smallexample @c ada
3583 pragma Stream_Convert (
3584 [Entity =>] type_local_NAME,
3585 [Read =>] function_NAME,
3586 [Write =>] function_NAME);
3590 This pragma provides an efficient way of providing stream functions for
3591 types defined in packages. Not only is it simpler to use than declaring
3592 the necessary functions with attribute representation clauses, but more
3593 significantly, it allows the declaration to made in such a way that the
3594 stream packages are not loaded unless they are needed. The use of
3595 the Stream_Convert pragma adds no overhead at all, unless the stream
3596 attributes are actually used on the designated type.
3598 The first argument specifies the type for which stream functions are
3599 provided. The second parameter provides a function used to read values
3600 of this type. It must name a function whose argument type may be any
3601 subtype, and whose returned type must be the type given as the first
3602 argument to the pragma.
3604 The meaning of the @var{Read}
3605 parameter is that if a stream attribute directly
3606 or indirectly specifies reading of the type given as the first parameter,
3607 then a value of the type given as the argument to the Read function is
3608 read from the stream, and then the Read function is used to convert this
3609 to the required target type.
3611 Similarly the @var{Write} parameter specifies how to treat write attributes
3612 that directly or indirectly apply to the type given as the first parameter.
3613 It must have an input parameter of the type specified by the first parameter,
3614 and the return type must be the same as the input type of the Read function.
3615 The effect is to first call the Write function to convert to the given stream
3616 type, and then write the result type to the stream.
3618 The Read and Write functions must not be overloaded subprograms. If necessary
3619 renamings can be supplied to meet this requirement.
3620 The usage of this attribute is best illustrated by a simple example, taken
3621 from the GNAT implementation of package Ada.Strings.Unbounded:
3623 @smallexample @c ada
3624 function To_Unbounded (S : String)
3625 return Unbounded_String
3626 renames To_Unbounded_String;
3628 pragma Stream_Convert
3629 (Unbounded_String, To_Unbounded, To_String);
3633 The specifications of the referenced functions, as given in the Ada 95
3634 Reference Manual are:
3636 @smallexample @c ada
3637 function To_Unbounded_String (Source : String)
3638 return Unbounded_String;
3640 function To_String (Source : Unbounded_String)
3645 The effect is that if the value of an unbounded string is written to a
3646 stream, then the representation of the item in the stream is in the same
3647 format used for @code{Standard.String}, and this same representation is
3648 expected when a value of this type is read from the stream.
3650 @node Pragma Style_Checks
3651 @unnumberedsec Pragma Style_Checks
3652 @findex Style_Checks
3656 @smallexample @c ada
3657 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3658 On | Off [, local_NAME]);
3662 This pragma is used in conjunction with compiler switches to control the
3663 built in style checking provided by GNAT@. The compiler switches, if set,
3664 provide an initial setting for the switches, and this pragma may be used
3665 to modify these settings, or the settings may be provided entirely by
3666 the use of the pragma. This pragma can be used anywhere that a pragma
3667 is legal, including use as a configuration pragma (including use in
3668 the @file{gnat.adc} file).
3670 The form with a string literal specifies which style options are to be
3671 activated. These are additive, so they apply in addition to any previously
3672 set style check options. The codes for the options are the same as those
3673 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3674 For example the following two methods can be used to enable
3679 @smallexample @c ada
3680 pragma Style_Checks ("l");
3685 gcc -c -gnatyl @dots{}
3690 The form ALL_CHECKS activates all standard checks (its use is equivalent
3691 to the use of the @code{gnaty} switch with no options. See GNAT User's
3694 The forms with @code{Off} and @code{On}
3695 can be used to temporarily disable style checks
3696 as shown in the following example:
3698 @smallexample @c ada
3702 pragma Style_Checks ("k"); -- requires keywords in lower case
3703 pragma Style_Checks (Off); -- turn off style checks
3704 NULL; -- this will not generate an error message
3705 pragma Style_Checks (On); -- turn style checks back on
3706 NULL; -- this will generate an error message
3710 Finally the two argument form is allowed only if the first argument is
3711 @code{On} or @code{Off}. The effect is to turn of semantic style checks
3712 for the specified entity, as shown in the following example:
3714 @smallexample @c ada
3718 pragma Style_Checks ("r"); -- require consistency of identifier casing
3720 Rf1 : Integer := ARG; -- incorrect, wrong case
3721 pragma Style_Checks (Off, Arg);
3722 Rf2 : Integer := ARG; -- OK, no error
3725 @node Pragma Subtitle
3726 @unnumberedsec Pragma Subtitle
3731 @smallexample @c ada
3732 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3736 This pragma is recognized for compatibility with other Ada compilers
3737 but is ignored by GNAT@.
3739 @node Pragma Suppress_All
3740 @unnumberedsec Pragma Suppress_All
3741 @findex Suppress_All
3745 @smallexample @c ada
3746 pragma Suppress_All;
3750 This pragma can only appear immediately following a compilation
3751 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
3752 which it follows. This pragma is implemented for compatibility with DEC
3753 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
3754 configuration pragma is the preferred usage in GNAT@.
3756 @node Pragma Suppress_Exception_Locations
3757 @unnumberedsec Pragma Suppress_Exception_Locations
3758 @findex Suppress_Exception_Locations
3762 @smallexample @c ada
3763 pragma Suppress_Exception_Locations;
3767 In normal mode, a raise statement for an exception by default generates
3768 an exception message giving the file name and line number for the location
3769 of the raise. This is useful for debugging and logging purposes, but this
3770 entails extra space for the strings for the messages. The configuration
3771 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3772 generation of these strings, with the result that space is saved, but the
3773 exception message for such raises is null. This configuration pragma may
3774 appear in a global configuration pragma file, or in a specific unit as
3775 usual. It is not required that this pragma be used consistently within
3776 a partition, so it is fine to have some units within a partition compiled
3777 with this pragma and others compiled in normal mode without it.
3779 @node Pragma Suppress_Initialization
3780 @unnumberedsec Pragma Suppress_Initialization
3781 @findex Suppress_Initialization
3782 @cindex Suppressing initialization
3783 @cindex Initialization, suppression of
3787 @smallexample @c ada
3788 pragma Suppress_Initialization ([Entity =>] type_Name);
3792 This pragma suppresses any implicit or explicit initialization
3793 associated with the given type name for all variables of this type.
3795 @node Pragma Task_Info
3796 @unnumberedsec Pragma Task_Info
3801 @smallexample @c ada
3802 pragma Task_Info (EXPRESSION);
3806 This pragma appears within a task definition (like pragma
3807 @code{Priority}) and applies to the task in which it appears. The
3808 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3809 The @code{Task_Info} pragma provides system dependent control over
3810 aspects of tasking implementation, for example, the ability to map
3811 tasks to specific processors. For details on the facilities available
3812 for the version of GNAT that you are using, see the documentation
3813 in the specification of package System.Task_Info in the runtime
3816 @node Pragma Task_Name
3817 @unnumberedsec Pragma Task_Name
3822 @smallexample @c ada
3823 pragma Task_Name (string_EXPRESSION);
3827 This pragma appears within a task definition (like pragma
3828 @code{Priority}) and applies to the task in which it appears. The
3829 argument must be of type String, and provides a name to be used for
3830 the task instance when the task is created. Note that this expression
3831 is not required to be static, and in particular, it can contain
3832 references to task discriminants. This facility can be used to
3833 provide different names for different tasks as they are created,
3834 as illustrated in the example below.
3836 The task name is recorded internally in the run-time structures
3837 and is accessible to tools like the debugger. In addition the
3838 routine @code{Ada.Task_Identification.Image} will return this
3839 string, with a unique task address appended.
3841 @smallexample @c ada
3842 -- Example of the use of pragma Task_Name
3844 with Ada.Task_Identification;
3845 use Ada.Task_Identification;
3846 with Text_IO; use Text_IO;
3849 type Astring is access String;
3851 task type Task_Typ (Name : access String) is
3852 pragma Task_Name (Name.all);
3855 task body Task_Typ is
3856 Nam : constant String := Image (Current_Task);
3858 Put_Line ("-->" & Nam (1 .. 14) & "<--");
3861 type Ptr_Task is access Task_Typ;
3862 Task_Var : Ptr_Task;
3866 new Task_Typ (new String'("This is task 1"));
3868 new Task_Typ (new String'("This is task 2"));
3872 @node Pragma Task_Storage
3873 @unnumberedsec Pragma Task_Storage
3874 @findex Task_Storage
3877 @smallexample @c ada
3878 pragma Task_Storage (
3879 [Task_Type =>] local_NAME,
3880 [Top_Guard =>] static_integer_EXPRESSION);
3884 This pragma specifies the length of the guard area for tasks. The guard
3885 area is an additional storage area allocated to a task. A value of zero
3886 means that either no guard area is created or a minimal guard area is
3887 created, depending on the target. This pragma can appear anywhere a
3888 @code{Storage_Size} attribute definition clause is allowed for a task
3891 @node Pragma Thread_Body
3892 @unnumberedsec Pragma Thread_Body
3896 @smallexample @c ada
3897 pragma Thread_Body (
3898 [Entity =>] local_NAME,
3899 [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3903 This pragma specifies that the subprogram whose name is given as the
3904 @code{Entity} argument is a thread body, which will be activated
3905 by being called via its Address from foreign code. The purpose is
3906 to allow execution and registration of the foreign thread within the
3907 Ada run-time system.
3909 See the library unit @code{System.Threads} for details on the expansion of
3910 a thread body subprogram, including the calls made to subprograms
3911 within System.Threads to register the task. This unit also lists the
3912 targets and runtime systems for which this pragma is supported.
3914 A thread body subprogram may not be called directly from Ada code, and
3915 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3916 to such a subprogram. The only legitimate way of calling such a subprogram
3917 is to pass its Address to foreign code and then make the call from the
3920 A thread body subprogram may have any parameters, and it may be a function
3921 returning a result. The convention of the thread body subprogram may be
3922 set in the usual manner using @code{pragma Convention}.
3924 The secondary stack size parameter, if given, is used to set the size
3925 of secondary stack for the thread. The secondary stack is allocated as
3926 a local variable of the expanded thread body subprogram, and thus is
3927 allocated out of the main thread stack size. If no secondary stack
3928 size parameter is present, the default size (from the declaration in
3929 @code{System.Secondary_Stack} is used.
3931 @node Pragma Time_Slice
3932 @unnumberedsec Pragma Time_Slice
3937 @smallexample @c ada
3938 pragma Time_Slice (static_duration_EXPRESSION);
3942 For implementations of GNAT on operating systems where it is possible
3943 to supply a time slice value, this pragma may be used for this purpose.
3944 It is ignored if it is used in a system that does not allow this control,
3945 or if it appears in other than the main program unit.
3947 Note that the effect of this pragma is identical to the effect of the
3948 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3951 @unnumberedsec Pragma Title
3956 @smallexample @c ada
3957 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3960 [Title =>] STRING_LITERAL,
3961 | [Subtitle =>] STRING_LITERAL
3965 Syntax checked but otherwise ignored by GNAT@. This is a listing control
3966 pragma used in DEC Ada 83 implementations to provide a title and/or
3967 subtitle for the program listing. The program listing generated by GNAT
3968 does not have titles or subtitles.
3970 Unlike other pragmas, the full flexibility of named notation is allowed
3971 for this pragma, i.e.@: the parameters may be given in any order if named
3972 notation is used, and named and positional notation can be mixed
3973 following the normal rules for procedure calls in Ada.
3975 @node Pragma Unchecked_Union
3976 @unnumberedsec Pragma Unchecked_Union
3978 @findex Unchecked_Union
3982 @smallexample @c ada
3983 pragma Unchecked_Union (first_subtype_local_NAME);
3987 This pragma is used to declare that the specified type should be represented
3989 equivalent to a C union type, and is intended only for use in
3990 interfacing with C code that uses union types. In Ada terms, the named
3991 type must obey the following rules:
3995 It is a non-tagged non-limited record type.
3997 It has a single discrete discriminant with a default value.
3999 The component list consists of a single variant part.
4001 Each variant has a component list with a single component.
4003 No nested variants are allowed.
4005 No component has an explicit default value.
4007 No component has a non-static constraint.
4011 In addition, given a type that meets the above requirements, the
4012 following restrictions apply to its use throughout the program:
4016 The discriminant name can be mentioned only in an aggregate.
4018 No subtypes may be created of this type.
4020 The type may not be constrained by giving a discriminant value.
4022 The type cannot be passed as the actual for a generic formal with a
4027 Equality and inequality operations on @code{unchecked_unions} are not
4028 available, since there is no discriminant to compare and the compiler
4029 does not even know how many bits to compare. It is implementation
4030 dependent whether this is detected at compile time as an illegality or
4031 whether it is undetected and considered to be an erroneous construct. In
4032 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
4033 the composite case (where two composites are compared that contain an
4034 unchecked union component), so such comparisons are simply considered
4037 The layout of the resulting type corresponds exactly to a C union, where
4038 each branch of the union corresponds to a single variant in the Ada
4039 record. The semantics of the Ada program is not changed in any way by
4040 the pragma, i.e.@: provided the above restrictions are followed, and no
4041 erroneous incorrect references to fields or erroneous comparisons occur,
4042 the semantics is exactly as described by the Ada reference manual.
4043 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
4044 type and the default convention is C.
4046 @node Pragma Unimplemented_Unit
4047 @unnumberedsec Pragma Unimplemented_Unit
4048 @findex Unimplemented_Unit
4052 @smallexample @c ada
4053 pragma Unimplemented_Unit;
4057 If this pragma occurs in a unit that is processed by the compiler, GNAT
4058 aborts with the message @samp{@var{xxx} not implemented}, where
4059 @var{xxx} is the name of the current compilation unit. This pragma is
4060 intended to allow the compiler to handle unimplemented library units in
4063 The abort only happens if code is being generated. Thus you can use
4064 specs of unimplemented packages in syntax or semantic checking mode.
4066 @node Pragma Universal_Data
4067 @unnumberedsec Pragma Universal_Data
4068 @findex Universal_Data
4072 @smallexample @c ada
4073 pragma Universal_Data [(library_unit_Name)];
4077 This pragma is supported only for the AAMP target and is ignored for
4078 other targets. The pragma specifies that all library-level objects
4079 (Counter 0 data) associated with the library unit are to be accessed
4080 and updated using universal addressing (24-bit addresses for AAMP5)
4081 rather than the default of 16-bit Data Environment (DENV) addressing.
4082 Use of this pragma will generally result in less efficient code for
4083 references to global data associated with the library unit, but
4084 allows such data to be located anywhere in memory. This pragma is
4085 a library unit pragma, but can also be used as a configuration pragma
4086 (including use in the @file{gnat.adc} file). The functionality
4087 of this pragma is also available by applying the -univ switch on the
4088 compilations of units where universal addressing of the data is desired.
4090 @node Pragma Unreferenced
4091 @unnumberedsec Pragma Unreferenced
4092 @findex Unreferenced
4093 @cindex Warnings, unreferenced
4097 @smallexample @c ada
4098 pragma Unreferenced (local_NAME @{, local_NAME@});
4102 This pragma signals that the entities whose names are listed are
4103 deliberately not referenced in the current source unit. This
4104 suppresses warnings about the
4105 entities being unreferenced, and in addition a warning will be
4106 generated if one of these entities is in fact referenced in the
4107 same unit as the pragma (or in the corresponding body, or one
4110 This is particularly useful for clearly signaling that a particular
4111 parameter is not referenced in some particular subprogram implementation
4112 and that this is deliberate. It can also be useful in the case of
4113 objects declared only for their initialization or finalization side
4116 If @code{local_NAME} identifies more than one matching homonym in the
4117 current scope, then the entity most recently declared is the one to which
4120 The left hand side of an assignment does not count as a reference for the
4121 purpose of this pragma. Thus it is fine to assign to an entity for which
4122 pragma Unreferenced is given.
4124 Note that if a warning is desired for all calls to a given subprogram,
4125 regardless of whether they occur in the same unit as the subprogram
4126 declaration, then this pragma should not be used (calls from another
4127 unit would not be flagged); pragma Obsolescent can be used instead
4128 for this purpose, see @xref{Pragma Obsolescent}.
4130 @node Pragma Unreserve_All_Interrupts
4131 @unnumberedsec Pragma Unreserve_All_Interrupts
4132 @findex Unreserve_All_Interrupts
4136 @smallexample @c ada
4137 pragma Unreserve_All_Interrupts;
4141 Normally certain interrupts are reserved to the implementation. Any attempt
4142 to attach an interrupt causes Program_Error to be raised, as described in
4143 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4144 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
4145 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4146 interrupt execution.
4148 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4149 a program, then all such interrupts are unreserved. This allows the
4150 program to handle these interrupts, but disables their standard
4151 functions. For example, if this pragma is used, then pressing
4152 @kbd{Ctrl-C} will not automatically interrupt execution. However,
4153 a program can then handle the @code{SIGINT} interrupt as it chooses.
4155 For a full list of the interrupts handled in a specific implementation,
4156 see the source code for the specification of @code{Ada.Interrupts.Names} in
4157 file @file{a-intnam.ads}. This is a target dependent file that contains the
4158 list of interrupts recognized for a given target. The documentation in
4159 this file also specifies what interrupts are affected by the use of
4160 the @code{Unreserve_All_Interrupts} pragma.
4162 For a more general facility for controlling what interrupts can be
4163 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4164 of the @code{Unreserve_All_Interrupts} pragma.
4166 @node Pragma Unsuppress
4167 @unnumberedsec Pragma Unsuppress
4172 @smallexample @c ada
4173 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4177 This pragma undoes the effect of a previous pragma @code{Suppress}. If
4178 there is no corresponding pragma @code{Suppress} in effect, it has no
4179 effect. The range of the effect is the same as for pragma
4180 @code{Suppress}. The meaning of the arguments is identical to that used
4181 in pragma @code{Suppress}.
4183 One important application is to ensure that checks are on in cases where
4184 code depends on the checks for its correct functioning, so that the code
4185 will compile correctly even if the compiler switches are set to suppress
4188 @node Pragma Use_VADS_Size
4189 @unnumberedsec Pragma Use_VADS_Size
4190 @cindex @code{Size}, VADS compatibility
4191 @findex Use_VADS_Size
4195 @smallexample @c ada
4196 pragma Use_VADS_Size;
4200 This is a configuration pragma. In a unit to which it applies, any use
4201 of the 'Size attribute is automatically interpreted as a use of the
4202 'VADS_Size attribute. Note that this may result in incorrect semantic
4203 processing of valid Ada 95 programs. This is intended to aid in the
4204 handling of legacy code which depends on the interpretation of Size
4205 as implemented in the VADS compiler. See description of the VADS_Size
4206 attribute for further details.
4208 @node Pragma Validity_Checks
4209 @unnumberedsec Pragma Validity_Checks
4210 @findex Validity_Checks
4214 @smallexample @c ada
4215 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4219 This pragma is used in conjunction with compiler switches to control the
4220 built-in validity checking provided by GNAT@. The compiler switches, if set
4221 provide an initial setting for the switches, and this pragma may be used
4222 to modify these settings, or the settings may be provided entirely by
4223 the use of the pragma. This pragma can be used anywhere that a pragma
4224 is legal, including use as a configuration pragma (including use in
4225 the @file{gnat.adc} file).
4227 The form with a string literal specifies which validity options are to be
4228 activated. The validity checks are first set to include only the default
4229 reference manual settings, and then a string of letters in the string
4230 specifies the exact set of options required. The form of this string
4231 is exactly as described for the @code{-gnatVx} compiler switch (see the
4232 GNAT users guide for details). For example the following two methods
4233 can be used to enable validity checking for mode @code{in} and
4234 @code{in out} subprogram parameters:
4238 @smallexample @c ada
4239 pragma Validity_Checks ("im");
4244 gcc -c -gnatVim @dots{}
4249 The form ALL_CHECKS activates all standard checks (its use is equivalent
4250 to the use of the @code{gnatva} switch.
4252 The forms with @code{Off} and @code{On}
4253 can be used to temporarily disable validity checks
4254 as shown in the following example:
4256 @smallexample @c ada
4260 pragma Validity_Checks ("c"); -- validity checks for copies
4261 pragma Validity_Checks (Off); -- turn off validity checks
4262 A := B; -- B will not be validity checked
4263 pragma Validity_Checks (On); -- turn validity checks back on
4264 A := C; -- C will be validity checked
4267 @node Pragma Volatile
4268 @unnumberedsec Pragma Volatile
4273 @smallexample @c ada
4274 pragma Volatile (local_NAME);
4278 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
4279 implementation is fully conformant with this definition. The reason it
4280 is mentioned in this section is that a pragma of the same name was supplied
4281 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 implementation
4282 of pragma Volatile is upwards compatible with the implementation in
4285 @node Pragma Warnings
4286 @unnumberedsec Pragma Warnings
4291 @smallexample @c ada
4292 pragma Warnings (On | Off [, local_NAME]);
4293 pragma Warnings (static_string_EXPRESSION);
4297 Normally warnings are enabled, with the output being controlled by
4298 the command line switch. Warnings (@code{Off}) turns off generation of
4299 warnings until a Warnings (@code{On}) is encountered or the end of the
4300 current unit. If generation of warnings is turned off using this
4301 pragma, then no warning messages are output, regardless of the
4302 setting of the command line switches.
4304 The form with a single argument is a configuration pragma.
4306 If the @var{local_NAME} parameter is present, warnings are suppressed for
4307 the specified entity. This suppression is effective from the point where
4308 it occurs till the end of the extended scope of the variable (similar to
4309 the scope of @code{Suppress}).
4311 The form with a static_string_EXPRESSION argument provides more precise
4312 control over which warnings are active. The string is a list of letters
4313 specifying which warnings are to be activated and which deactivated. The
4314 code for these letters is the same as the string used in the command
4315 line switch controlling warnings. The following is a brief summary. For
4316 full details see the GNAT Users Guide:
4319 a turn on all optional warnings (except d,h,l)
4320 A turn off all optional warnings
4321 b turn on warnings for bad fixed value (not multiple of small)
4322 B turn off warnings for bad fixed value (not multiple of small)
4323 c turn on warnings for constant conditional
4324 C turn off warnings for constant conditional
4325 d turn on warnings for implicit dereference
4326 D turn off warnings for implicit dereference
4327 e treat all warnings as errors
4328 f turn on warnings for unreferenced formal
4329 F turn off warnings for unreferenced formal
4330 g turn on warnings for unrecognized pragma
4331 G turn off warnings for unrecognized pragma
4332 h turn on warnings for hiding variable
4333 H turn off warnings for hiding variable
4334 i turn on warnings for implementation unit
4335 I turn off warnings for implementation unit
4336 j turn on warnings for obsolescent (annex J) feature
4337 J turn off warnings for obsolescent (annex J) feature
4338 k turn on warnings on constant variable
4339 K turn off warnings on constant variable
4340 l turn on warnings for missing elaboration pragma
4341 L turn off warnings for missing elaboration pragma
4342 m turn on warnings for variable assigned but not read
4343 M turn off warnings for variable assigned but not read
4344 n normal warning mode (cancels s/e)
4345 o turn on warnings for address clause overlay
4346 O turn off warnings for address clause overlay
4347 p turn on warnings for ineffective pragma Inline
4348 P turn off warnings for ineffective pragma Inline
4349 r turn on warnings for redundant construct
4350 R turn off warnings for redundant construct
4351 s suppress all warnings
4352 u turn on warnings for unused entity
4353 U turn off warnings for unused entity
4354 v turn on warnings for unassigned variable
4355 V turn off warnings for unassigned variable
4356 x turn on warnings for export/import
4357 X turn off warnings for export/import
4358 y turn on warnings for Ada 2005 incompatibility
4359 Y turn off warnings for Ada 2005 incompatibility
4360 z turn on size/align warnings for unchecked conversion
4361 Z turn off size/align warnings for unchecked conversion
4365 The specified warnings will be in effect until the end of the program
4366 or another pragma Warnings is encountered. The effect of the pragma is
4367 cumulative. Initially the set of warnings is the standard default set
4368 as possibly modified by compiler switches. Then each pragma Warning
4369 modifies this set of warnings as specified.
4371 @node Pragma Weak_External
4372 @unnumberedsec Pragma Weak_External
4373 @findex Weak_External
4377 @smallexample @c ada
4378 pragma Weak_External ([Entity =>] local_NAME);
4382 @var{local_NAME} must refer to an object that is declared at the library
4383 level. This pragma specifies that the given entity should be marked as a
4384 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
4385 in GNU C and causes @var{local_NAME} to be emitted as a weak symbol instead
4386 of a regular symbol, that is to say a symbol that does not have to be
4387 resolved by the linker if used in conjunction with a pragma Import.
4389 When a weak symbol is not resolved by the linker, its address is set to
4390 zero. This is useful in writing interfaces to external modules that may
4391 or may not be linked in the final executable, for example depending on
4392 configuration settings.
4394 If a program references at run time an entity to which this pragma has been
4395 applied, and the corresponding symbol was not resolved at link time, then
4396 the execution of the program is erroneous. It is not erroneous to take the
4397 Address of such an entity, for example to guard potential references,
4398 as shown in the example below.
4400 Some file formats do not support weak symbols so not all target machines
4401 support this pragma.
4403 @smallexample @c ada
4404 -- Example of the use of pragma Weak_External
4406 package External_Module is
4408 pragma Import (C, key);
4409 pragma Weak_External (key);
4410 function Present return boolean;
4411 end External_Module;
4413 with System; use System;
4414 package body External_Module is
4415 function Present return boolean is
4417 return key'Address /= System.Null_Address;
4419 end External_Module;
4422 @node Implementation Defined Attributes
4423 @chapter Implementation Defined Attributes
4424 Ada 95 defines (throughout the Ada 95 reference manual,
4425 summarized in annex K),
4426 a set of attributes that provide useful additional functionality in all
4427 areas of the language. These language defined attributes are implemented
4428 in GNAT and work as described in the Ada 95 Reference Manual.
4430 In addition, Ada 95 allows implementations to define additional
4431 attributes whose meaning is defined by the implementation. GNAT provides
4432 a number of these implementation-dependent attributes which can be used
4433 to extend and enhance the functionality of the compiler. This section of
4434 the GNAT reference manual describes these additional attributes.
4436 Note that any program using these attributes may not be portable to
4437 other compilers (although GNAT implements this set of attributes on all
4438 platforms). Therefore if portability to other compilers is an important
4439 consideration, you should minimize the use of these attributes.
4450 * Default_Bit_Order::
4458 * Has_Access_Values::
4459 * Has_Discriminants::
4465 * Max_Interrupt_Priority::
4467 * Maximum_Alignment::
4471 * Passed_By_Reference::
4482 * Unconstrained_Array::
4483 * Universal_Literal_String::
4484 * Unrestricted_Access::
4492 @unnumberedsec Abort_Signal
4493 @findex Abort_Signal
4495 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4496 prefix) provides the entity for the special exception used to signal
4497 task abort or asynchronous transfer of control. Normally this attribute
4498 should only be used in the tasking runtime (it is highly peculiar, and
4499 completely outside the normal semantics of Ada, for a user program to
4500 intercept the abort exception).
4503 @unnumberedsec Address_Size
4504 @cindex Size of @code{Address}
4505 @findex Address_Size
4507 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4508 prefix) is a static constant giving the number of bits in an
4509 @code{Address}. It is the same value as System.Address'Size,
4510 but has the advantage of being static, while a direct
4511 reference to System.Address'Size is non-static because Address
4515 @unnumberedsec Asm_Input
4518 The @code{Asm_Input} attribute denotes a function that takes two
4519 parameters. The first is a string, the second is an expression of the
4520 type designated by the prefix. The first (string) argument is required
4521 to be a static expression, and is the constraint for the parameter,
4522 (e.g.@: what kind of register is required). The second argument is the
4523 value to be used as the input argument. The possible values for the
4524 constant are the same as those used in the RTL, and are dependent on
4525 the configuration file used to built the GCC back end.
4526 @ref{Machine Code Insertions}
4529 @unnumberedsec Asm_Output
4532 The @code{Asm_Output} attribute denotes a function that takes two
4533 parameters. The first is a string, the second is the name of a variable
4534 of the type designated by the attribute prefix. The first (string)
4535 argument is required to be a static expression and designates the
4536 constraint for the parameter (e.g.@: what kind of register is
4537 required). The second argument is the variable to be updated with the
4538 result. The possible values for constraint are the same as those used in
4539 the RTL, and are dependent on the configuration file used to build the
4540 GCC back end. If there are no output operands, then this argument may
4541 either be omitted, or explicitly given as @code{No_Output_Operands}.
4542 @ref{Machine Code Insertions}
4545 @unnumberedsec AST_Entry
4549 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
4550 the name of an entry, it yields a value of the predefined type AST_Handler
4551 (declared in the predefined package System, as extended by the use of
4552 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
4553 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
4554 Language Reference Manual}, section 9.12a.
4559 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4560 offset within the storage unit (byte) that contains the first bit of
4561 storage allocated for the object. The value of this attribute is of the
4562 type @code{Universal_Integer}, and is always a non-negative number not
4563 exceeding the value of @code{System.Storage_Unit}.
4565 For an object that is a variable or a constant allocated in a register,
4566 the value is zero. (The use of this attribute does not force the
4567 allocation of a variable to memory).
4569 For an object that is a formal parameter, this attribute applies
4570 to either the matching actual parameter or to a copy of the
4571 matching actual parameter.
4573 For an access object the value is zero. Note that
4574 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4575 designated object. Similarly for a record component
4576 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4577 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4578 are subject to index checks.
4580 This attribute is designed to be compatible with the DEC Ada 83 definition
4581 and implementation of the @code{Bit} attribute.
4584 @unnumberedsec Bit_Position
4585 @findex Bit_Position
4587 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4588 of the fields of the record type, yields the bit
4589 offset within the record contains the first bit of
4590 storage allocated for the object. The value of this attribute is of the
4591 type @code{Universal_Integer}. The value depends only on the field
4592 @var{C} and is independent of the alignment of
4593 the containing record @var{R}.
4596 @unnumberedsec Code_Address
4597 @findex Code_Address
4598 @cindex Subprogram address
4599 @cindex Address of subprogram code
4602 attribute may be applied to subprograms in Ada 95, but the
4603 intended effect from the Ada 95 reference manual seems to be to provide
4604 an address value which can be used to call the subprogram by means of
4605 an address clause as in the following example:
4607 @smallexample @c ada
4608 procedure K is @dots{}
4611 for L'Address use K'Address;
4612 pragma Import (Ada, L);
4616 A call to @code{L} is then expected to result in a call to @code{K}@.
4617 In Ada 83, where there were no access-to-subprogram values, this was
4618 a common work around for getting the effect of an indirect call.
4619 GNAT implements the above use of @code{Address} and the technique
4620 illustrated by the example code works correctly.
4622 However, for some purposes, it is useful to have the address of the start
4623 of the generated code for the subprogram. On some architectures, this is
4624 not necessarily the same as the @code{Address} value described above.
4625 For example, the @code{Address} value may reference a subprogram
4626 descriptor rather than the subprogram itself.
4628 The @code{'Code_Address} attribute, which can only be applied to
4629 subprogram entities, always returns the address of the start of the
4630 generated code of the specified subprogram, which may or may not be
4631 the same value as is returned by the corresponding @code{'Address}
4634 @node Default_Bit_Order
4635 @unnumberedsec Default_Bit_Order
4637 @cindex Little endian
4638 @findex Default_Bit_Order
4640 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4641 permissible prefix), provides the value @code{System.Default_Bit_Order}
4642 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4643 @code{Low_Order_First}). This is used to construct the definition of
4644 @code{Default_Bit_Order} in package @code{System}.
4647 @unnumberedsec Elaborated
4650 The prefix of the @code{'Elaborated} attribute must be a unit name. The
4651 value is a Boolean which indicates whether or not the given unit has been
4652 elaborated. This attribute is primarily intended for internal use by the
4653 generated code for dynamic elaboration checking, but it can also be used
4654 in user programs. The value will always be True once elaboration of all
4655 units has been completed. An exception is for units which need no
4656 elaboration, the value is always False for such units.
4659 @unnumberedsec Elab_Body
4662 This attribute can only be applied to a program unit name. It returns
4663 the entity for the corresponding elaboration procedure for elaborating
4664 the body of the referenced unit. This is used in the main generated
4665 elaboration procedure by the binder and is not normally used in any
4666 other context. However, there may be specialized situations in which it
4667 is useful to be able to call this elaboration procedure from Ada code,
4668 e.g.@: if it is necessary to do selective re-elaboration to fix some
4672 @unnumberedsec Elab_Spec
4675 This attribute can only be applied to a program unit name. It returns
4676 the entity for the corresponding elaboration procedure for elaborating
4677 the specification of the referenced unit. This is used in the main
4678 generated elaboration procedure by the binder and is not normally used
4679 in any other context. However, there may be specialized situations in
4680 which it is useful to be able to call this elaboration procedure from
4681 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4686 @cindex Ada 83 attributes
4689 The @code{Emax} attribute is provided for compatibility with Ada 83. See
4690 the Ada 83 reference manual for an exact description of the semantics of
4694 @unnumberedsec Enum_Rep
4695 @cindex Representation of enums
4698 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4699 function with the following spec:
4701 @smallexample @c ada
4702 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4703 return @i{Universal_Integer};
4707 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4708 enumeration type or to a non-overloaded enumeration
4709 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
4710 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4711 enumeration literal or object.
4713 The function returns the representation value for the given enumeration
4714 value. This will be equal to value of the @code{Pos} attribute in the
4715 absence of an enumeration representation clause. This is a static
4716 attribute (i.e.@: the result is static if the argument is static).
4718 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4719 in which case it simply returns the integer value. The reason for this
4720 is to allow it to be used for @code{(<>)} discrete formal arguments in
4721 a generic unit that can be instantiated with either enumeration types
4722 or integer types. Note that if @code{Enum_Rep} is used on a modular
4723 type whose upper bound exceeds the upper bound of the largest signed
4724 integer type, and the argument is a variable, so that the universal
4725 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4726 may raise @code{Constraint_Error}.
4729 @unnumberedsec Epsilon
4730 @cindex Ada 83 attributes
4733 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
4734 the Ada 83 reference manual for an exact description of the semantics of
4738 @unnumberedsec Fixed_Value
4741 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4742 function with the following specification:
4744 @smallexample @c ada
4745 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4750 The value returned is the fixed-point value @var{V} such that
4752 @smallexample @c ada
4753 @var{V} = Arg * @var{S}'Small
4757 The effect is thus similar to first converting the argument to the
4758 integer type used to represent @var{S}, and then doing an unchecked
4759 conversion to the fixed-point type. The difference is
4760 that there are full range checks, to ensure that the result is in range.
4761 This attribute is primarily intended for use in implementation of the
4762 input-output functions for fixed-point values.
4764 @node Has_Access_Values
4765 @unnumberedsec Has_Access_Values
4766 @cindex Access values, testing for
4767 @findex Has_Access_Values
4769 The prefix of the @code{Has_Access_Values} attribute is a type. The result
4770 is a Boolean value which is True if the is an access type, or is a composite
4771 type with a component (at any nesting depth) that is an access type, and is
4773 The intended use of this attribute is in conjunction with generic
4774 definitions. If the attribute is applied to a generic private type, it
4775 indicates whether or not the corresponding actual type has access values.
4777 @node Has_Discriminants
4778 @unnumberedsec Has_Discriminants
4779 @cindex Discriminants, testing for
4780 @findex Has_Discriminants
4782 The prefix of the @code{Has_Discriminants} attribute is a type. The result
4783 is a Boolean value which is True if the type has discriminants, and False
4784 otherwise. The intended use of this attribute is in conjunction with generic
4785 definitions. If the attribute is applied to a generic private type, it
4786 indicates whether or not the corresponding actual type has discriminants.
4792 The @code{Img} attribute differs from @code{Image} in that it may be
4793 applied to objects as well as types, in which case it gives the
4794 @code{Image} for the subtype of the object. This is convenient for
4797 @smallexample @c ada
4798 Put_Line ("X = " & X'Img);
4802 has the same meaning as the more verbose:
4804 @smallexample @c ada
4805 Put_Line ("X = " & @var{T}'Image (X));
4809 where @var{T} is the (sub)type of the object @code{X}.
4812 @unnumberedsec Integer_Value
4813 @findex Integer_Value
4815 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4816 function with the following spec:
4818 @smallexample @c ada
4819 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4824 The value returned is the integer value @var{V}, such that
4826 @smallexample @c ada
4827 Arg = @var{V} * @var{T}'Small
4831 where @var{T} is the type of @code{Arg}.
4832 The effect is thus similar to first doing an unchecked conversion from
4833 the fixed-point type to its corresponding implementation type, and then
4834 converting the result to the target integer type. The difference is
4835 that there are full range checks, to ensure that the result is in range.
4836 This attribute is primarily intended for use in implementation of the
4837 standard input-output functions for fixed-point values.
4840 @unnumberedsec Large
4841 @cindex Ada 83 attributes
4844 The @code{Large} attribute is provided for compatibility with Ada 83. See
4845 the Ada 83 reference manual for an exact description of the semantics of
4849 @unnumberedsec Machine_Size
4850 @findex Machine_Size
4852 This attribute is identical to the @code{Object_Size} attribute. It is
4853 provided for compatibility with the DEC Ada 83 attribute of this name.
4856 @unnumberedsec Mantissa
4857 @cindex Ada 83 attributes
4860 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
4861 the Ada 83 reference manual for an exact description of the semantics of
4864 @node Max_Interrupt_Priority
4865 @unnumberedsec Max_Interrupt_Priority
4866 @cindex Interrupt priority, maximum
4867 @findex Max_Interrupt_Priority
4869 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4870 permissible prefix), provides the same value as
4871 @code{System.Max_Interrupt_Priority}.
4874 @unnumberedsec Max_Priority
4875 @cindex Priority, maximum
4876 @findex Max_Priority
4878 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4879 prefix) provides the same value as @code{System.Max_Priority}.
4881 @node Maximum_Alignment
4882 @unnumberedsec Maximum_Alignment
4883 @cindex Alignment, maximum
4884 @findex Maximum_Alignment
4886 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4887 permissible prefix) provides the maximum useful alignment value for the
4888 target. This is a static value that can be used to specify the alignment
4889 for an object, guaranteeing that it is properly aligned in all
4892 @node Mechanism_Code
4893 @unnumberedsec Mechanism_Code
4894 @cindex Return values, passing mechanism
4895 @cindex Parameters, passing mechanism
4896 @findex Mechanism_Code
4898 @code{@var{function}'Mechanism_Code} yields an integer code for the
4899 mechanism used for the result of function, and
4900 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4901 used for formal parameter number @var{n} (a static integer value with 1
4902 meaning the first parameter) of @var{subprogram}. The code returned is:
4910 by descriptor (default descriptor class)
4912 by descriptor (UBS: unaligned bit string)
4914 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4916 by descriptor (UBA: unaligned bit array)
4918 by descriptor (S: string, also scalar access type parameter)
4920 by descriptor (SB: string with arbitrary bounds)
4922 by descriptor (A: contiguous array)
4924 by descriptor (NCA: non-contiguous array)
4928 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4931 @node Null_Parameter
4932 @unnumberedsec Null_Parameter
4933 @cindex Zero address, passing
4934 @findex Null_Parameter
4936 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4937 type or subtype @var{T} allocated at machine address zero. The attribute
4938 is allowed only as the default expression of a formal parameter, or as
4939 an actual expression of a subprogram call. In either case, the
4940 subprogram must be imported.
4942 The identity of the object is represented by the address zero in the
4943 argument list, independent of the passing mechanism (explicit or
4946 This capability is needed to specify that a zero address should be
4947 passed for a record or other composite object passed by reference.
4948 There is no way of indicating this without the @code{Null_Parameter}
4952 @unnumberedsec Object_Size
4953 @cindex Size, used for objects
4956 The size of an object is not necessarily the same as the size of the type
4957 of an object. This is because by default object sizes are increased to be
4958 a multiple of the alignment of the object. For example,
4959 @code{Natural'Size} is
4960 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4961 Similarly, a record containing an integer and a character:
4963 @smallexample @c ada
4971 will have a size of 40 (that is @code{Rec'Size} will be 40. The
4972 alignment will be 4, because of the
4973 integer field, and so the default size of record objects for this type
4974 will be 64 (8 bytes).
4976 The @code{@var{type}'Object_Size} attribute
4977 has been added to GNAT to allow the
4978 default object size of a type to be easily determined. For example,
4979 @code{Natural'Object_Size} is 32, and
4980 @code{Rec'Object_Size} (for the record type in the above example) will be
4981 64. Note also that, unlike the situation with the
4982 @code{Size} attribute as defined in the Ada RM, the
4983 @code{Object_Size} attribute can be specified individually
4984 for different subtypes. For example:
4986 @smallexample @c ada
4987 type R is new Integer;
4988 subtype R1 is R range 1 .. 10;
4989 subtype R2 is R range 1 .. 10;
4990 for R2'Object_Size use 8;
4994 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4995 32 since the default object size for a subtype is the same as the object size
4996 for the parent subtype. This means that objects of type @code{R}
4998 by default be 32 bits (four bytes). But objects of type
4999 @code{R2} will be only
5000 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
5002 @node Passed_By_Reference
5003 @unnumberedsec Passed_By_Reference
5004 @cindex Parameters, when passed by reference
5005 @findex Passed_By_Reference
5007 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5008 a value of type @code{Boolean} value that is @code{True} if the type is
5009 normally passed by reference and @code{False} if the type is normally
5010 passed by copy in calls. For scalar types, the result is always @code{False}
5011 and is static. For non-scalar types, the result is non-static.
5014 @unnumberedsec Range_Length
5015 @findex Range_Length
5017 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5018 the number of values represented by the subtype (zero for a null
5019 range). The result is static for static subtypes. @code{Range_Length}
5020 applied to the index subtype of a one dimensional array always gives the
5021 same result as @code{Range} applied to the array itself.
5024 @unnumberedsec Safe_Emax
5025 @cindex Ada 83 attributes
5028 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
5029 the Ada 83 reference manual for an exact description of the semantics of
5033 @unnumberedsec Safe_Large
5034 @cindex Ada 83 attributes
5037 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
5038 the Ada 83 reference manual for an exact description of the semantics of
5042 @unnumberedsec Small
5043 @cindex Ada 83 attributes
5046 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
5047 GNAT also allows this attribute to be applied to floating-point types
5048 for compatibility with Ada 83. See
5049 the Ada 83 reference manual for an exact description of the semantics of
5050 this attribute when applied to floating-point types.
5053 @unnumberedsec Storage_Unit
5054 @findex Storage_Unit
5056 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5057 prefix) provides the same value as @code{System.Storage_Unit}.
5060 @unnumberedsec Target_Name
5063 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5064 prefix) provides a static string value that identifies the target
5065 for the current compilation. For GCC implementations, this is the
5066 standard gcc target name without the terminating slash (for
5067 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5073 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5074 provides the same value as @code{System.Tick},
5077 @unnumberedsec To_Address
5080 The @code{System'To_Address}
5081 (@code{System} is the only permissible prefix)
5082 denotes a function identical to
5083 @code{System.Storage_Elements.To_Address} except that
5084 it is a static attribute. This means that if its argument is
5085 a static expression, then the result of the attribute is a
5086 static expression. The result is that such an expression can be
5087 used in contexts (e.g.@: preelaborable packages) which require a
5088 static expression and where the function call could not be used
5089 (since the function call is always non-static, even if its
5090 argument is static).
5093 @unnumberedsec Type_Class
5096 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5097 the value of the type class for the full type of @var{type}. If
5098 @var{type} is a generic formal type, the value is the value for the
5099 corresponding actual subtype. The value of this attribute is of type
5100 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5102 @smallexample @c ada
5104 (Type_Class_Enumeration,
5106 Type_Class_Fixed_Point,
5107 Type_Class_Floating_Point,
5112 Type_Class_Address);
5116 Protected types yield the value @code{Type_Class_Task}, which thus
5117 applies to all concurrent types. This attribute is designed to
5118 be compatible with the DEC Ada 83 attribute of the same name.
5121 @unnumberedsec UET_Address
5124 The @code{UET_Address} attribute can only be used for a prefix which
5125 denotes a library package. It yields the address of the unit exception
5126 table when zero cost exception handling is used. This attribute is
5127 intended only for use within the GNAT implementation. See the unit
5128 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5129 for details on how this attribute is used in the implementation.
5131 @node Unconstrained_Array
5132 @unnumberedsec Unconstrained_Array
5133 @findex Unconstrained_Array
5135 The @code{Unconstrained_Array} attribute can be used with a prefix that
5136 denotes any type or subtype. It is a static attribute that yields
5137 @code{True} if the prefix designates an unconstrained array,
5138 and @code{False} otherwise. In a generic instance, the result is
5139 still static, and yields the result of applying this test to the
5142 @node Universal_Literal_String
5143 @unnumberedsec Universal_Literal_String
5144 @cindex Named numbers, representation of
5145 @findex Universal_Literal_String
5147 The prefix of @code{Universal_Literal_String} must be a named
5148 number. The static result is the string consisting of the characters of
5149 the number as defined in the original source. This allows the user
5150 program to access the actual text of named numbers without intermediate
5151 conversions and without the need to enclose the strings in quotes (which
5152 would preclude their use as numbers). This is used internally for the
5153 construction of values of the floating-point attributes from the file
5154 @file{ttypef.ads}, but may also be used by user programs.
5156 @node Unrestricted_Access
5157 @unnumberedsec Unrestricted_Access
5158 @cindex @code{Access}, unrestricted
5159 @findex Unrestricted_Access
5161 The @code{Unrestricted_Access} attribute is similar to @code{Access}
5162 except that all accessibility and aliased view checks are omitted. This
5163 is a user-beware attribute. It is similar to
5164 @code{Address}, for which it is a desirable replacement where the value
5165 desired is an access type. In other words, its effect is identical to
5166 first applying the @code{Address} attribute and then doing an unchecked
5167 conversion to a desired access type. In GNAT, but not necessarily in
5168 other implementations, the use of static chains for inner level
5169 subprograms means that @code{Unrestricted_Access} applied to a
5170 subprogram yields a value that can be called as long as the subprogram
5171 is in scope (normal Ada 95 accessibility rules restrict this usage).
5173 It is possible to use @code{Unrestricted_Access} for any type, but care
5174 must be exercised if it is used to create pointers to unconstrained
5175 objects. In this case, the resulting pointer has the same scope as the
5176 context of the attribute, and may not be returned to some enclosing
5177 scope. For instance, a function cannot use @code{Unrestricted_Access}
5178 to create a unconstrained pointer and then return that value to the
5182 @unnumberedsec VADS_Size
5183 @cindex @code{Size}, VADS compatibility
5186 The @code{'VADS_Size} attribute is intended to make it easier to port
5187 legacy code which relies on the semantics of @code{'Size} as implemented
5188 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
5189 same semantic interpretation. In particular, @code{'VADS_Size} applied
5190 to a predefined or other primitive type with no Size clause yields the
5191 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
5192 typical machines). In addition @code{'VADS_Size} applied to an object
5193 gives the result that would be obtained by applying the attribute to
5194 the corresponding type.
5197 @unnumberedsec Value_Size
5198 @cindex @code{Size}, setting for not-first subtype
5200 @code{@var{type}'Value_Size} is the number of bits required to represent
5201 a value of the given subtype. It is the same as @code{@var{type}'Size},
5202 but, unlike @code{Size}, may be set for non-first subtypes.
5205 @unnumberedsec Wchar_T_Size
5206 @findex Wchar_T_Size
5207 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
5208 prefix) provides the size in bits of the C @code{wchar_t} type
5209 primarily for constructing the definition of this type in
5210 package @code{Interfaces.C}.
5213 @unnumberedsec Word_Size
5215 @code{Standard'Word_Size} (@code{Standard} is the only permissible
5216 prefix) provides the value @code{System.Word_Size}.
5218 @c ------------------------
5219 @node Implementation Advice
5220 @chapter Implementation Advice
5222 The main text of the Ada 95 Reference Manual describes the required
5223 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
5226 In addition, there are sections throughout the Ada 95
5227 reference manual headed
5228 by the phrase ``implementation advice''. These sections are not normative,
5229 i.e.@: they do not specify requirements that all compilers must
5230 follow. Rather they provide advice on generally desirable behavior. You
5231 may wonder why they are not requirements. The most typical answer is
5232 that they describe behavior that seems generally desirable, but cannot
5233 be provided on all systems, or which may be undesirable on some systems.
5235 As far as practical, GNAT follows the implementation advice sections in
5236 the Ada 95 Reference Manual. This chapter contains a table giving the
5237 reference manual section number, paragraph number and several keywords
5238 for each advice. Each entry consists of the text of the advice followed
5239 by the GNAT interpretation of this advice. Most often, this simply says
5240 ``followed'', which means that GNAT follows the advice. However, in a
5241 number of cases, GNAT deliberately deviates from this advice, in which
5242 case the text describes what GNAT does and why.
5244 @cindex Error detection
5245 @unnumberedsec 1.1.3(20): Error Detection
5248 If an implementation detects the use of an unsupported Specialized Needs
5249 Annex feature at run time, it should raise @code{Program_Error} if
5252 Not relevant. All specialized needs annex features are either supported,
5253 or diagnosed at compile time.
5256 @unnumberedsec 1.1.3(31): Child Units
5259 If an implementation wishes to provide implementation-defined
5260 extensions to the functionality of a language-defined library unit, it
5261 should normally do so by adding children to the library unit.
5265 @cindex Bounded errors
5266 @unnumberedsec 1.1.5(12): Bounded Errors
5269 If an implementation detects a bounded error or erroneous
5270 execution, it should raise @code{Program_Error}.
5272 Followed in all cases in which the implementation detects a bounded
5273 error or erroneous execution. Not all such situations are detected at
5277 @unnumberedsec 2.8(16): Pragmas
5280 Normally, implementation-defined pragmas should have no semantic effect
5281 for error-free programs; that is, if the implementation-defined pragmas
5282 are removed from a working program, the program should still be legal,
5283 and should still have the same semantics.
5285 The following implementation defined pragmas are exceptions to this
5297 @item CPP_Constructor
5305 @item Interface_Name
5307 @item Machine_Attribute
5309 @item Unimplemented_Unit
5311 @item Unchecked_Union
5316 In each of the above cases, it is essential to the purpose of the pragma
5317 that this advice not be followed. For details see the separate section
5318 on implementation defined pragmas.
5320 @unnumberedsec 2.8(17-19): Pragmas
5323 Normally, an implementation should not define pragmas that can
5324 make an illegal program legal, except as follows:
5328 A pragma used to complete a declaration, such as a pragma @code{Import};
5332 A pragma used to configure the environment by adding, removing, or
5333 replacing @code{library_items}.
5335 See response to paragraph 16 of this same section.
5337 @cindex Character Sets
5338 @cindex Alternative Character Sets
5339 @unnumberedsec 3.5.2(5): Alternative Character Sets
5342 If an implementation supports a mode with alternative interpretations
5343 for @code{Character} and @code{Wide_Character}, the set of graphic
5344 characters of @code{Character} should nevertheless remain a proper
5345 subset of the set of graphic characters of @code{Wide_Character}. Any
5346 character set ``localizations'' should be reflected in the results of
5347 the subprograms defined in the language-defined package
5348 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
5349 an alternative interpretation of @code{Character}, the implementation should
5350 also support a corresponding change in what is a legal
5351 @code{identifier_letter}.
5353 Not all wide character modes follow this advice, in particular the JIS
5354 and IEC modes reflect standard usage in Japan, and in these encoding,
5355 the upper half of the Latin-1 set is not part of the wide-character
5356 subset, since the most significant bit is used for wide character
5357 encoding. However, this only applies to the external forms. Internally
5358 there is no such restriction.
5360 @cindex Integer types
5361 @unnumberedsec 3.5.4(28): Integer Types
5365 An implementation should support @code{Long_Integer} in addition to
5366 @code{Integer} if the target machine supports 32-bit (or longer)
5367 arithmetic. No other named integer subtypes are recommended for package
5368 @code{Standard}. Instead, appropriate named integer subtypes should be
5369 provided in the library package @code{Interfaces} (see B.2).
5371 @code{Long_Integer} is supported. Other standard integer types are supported
5372 so this advice is not fully followed. These types
5373 are supported for convenient interface to C, and so that all hardware
5374 types of the machine are easily available.
5375 @unnumberedsec 3.5.4(29): Integer Types
5379 An implementation for a two's complement machine should support
5380 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
5381 implementation should support a non-binary modules up to @code{Integer'Last}.
5385 @cindex Enumeration values
5386 @unnumberedsec 3.5.5(8): Enumeration Values
5389 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5390 subtype, if the value of the operand does not correspond to the internal
5391 code for any enumeration literal of its type (perhaps due to an
5392 un-initialized variable), then the implementation should raise
5393 @code{Program_Error}. This is particularly important for enumeration
5394 types with noncontiguous internal codes specified by an
5395 enumeration_representation_clause.
5400 @unnumberedsec 3.5.7(17): Float Types
5403 An implementation should support @code{Long_Float} in addition to
5404 @code{Float} if the target machine supports 11 or more digits of
5405 precision. No other named floating point subtypes are recommended for
5406 package @code{Standard}. Instead, appropriate named floating point subtypes
5407 should be provided in the library package @code{Interfaces} (see B.2).
5409 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
5410 former provides improved compatibility with other implementations
5411 supporting this type. The latter corresponds to the highest precision
5412 floating-point type supported by the hardware. On most machines, this
5413 will be the same as @code{Long_Float}, but on some machines, it will
5414 correspond to the IEEE extended form. The notable case is all ia32
5415 (x86) implementations, where @code{Long_Long_Float} corresponds to
5416 the 80-bit extended precision format supported in hardware on this
5417 processor. Note that the 128-bit format on SPARC is not supported,
5418 since this is a software rather than a hardware format.
5420 @cindex Multidimensional arrays
5421 @cindex Arrays, multidimensional
5422 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5425 An implementation should normally represent multidimensional arrays in
5426 row-major order, consistent with the notation used for multidimensional
5427 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
5428 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5429 column-major order should be used instead (see B.5, ``Interfacing with
5434 @findex Duration'Small
5435 @unnumberedsec 9.6(30-31): Duration'Small
5438 Whenever possible in an implementation, the value of @code{Duration'Small}
5439 should be no greater than 100 microseconds.
5441 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
5445 The time base for @code{delay_relative_statements} should be monotonic;
5446 it need not be the same time base as used for @code{Calendar.Clock}.
5450 @unnumberedsec 10.2.1(12): Consistent Representation
5453 In an implementation, a type declared in a pre-elaborated package should
5454 have the same representation in every elaboration of a given version of
5455 the package, whether the elaborations occur in distinct executions of
5456 the same program, or in executions of distinct programs or partitions
5457 that include the given version.
5459 Followed, except in the case of tagged types. Tagged types involve
5460 implicit pointers to a local copy of a dispatch table, and these pointers
5461 have representations which thus depend on a particular elaboration of the
5462 package. It is not easy to see how it would be possible to follow this
5463 advice without severely impacting efficiency of execution.
5465 @cindex Exception information
5466 @unnumberedsec 11.4.1(19): Exception Information
5469 @code{Exception_Message} by default and @code{Exception_Information}
5470 should produce information useful for
5471 debugging. @code{Exception_Message} should be short, about one
5472 line. @code{Exception_Information} can be long. @code{Exception_Message}
5473 should not include the
5474 @code{Exception_Name}. @code{Exception_Information} should include both
5475 the @code{Exception_Name} and the @code{Exception_Message}.
5477 Followed. For each exception that doesn't have a specified
5478 @code{Exception_Message}, the compiler generates one containing the location
5479 of the raise statement. This location has the form ``file:line'', where
5480 file is the short file name (without path information) and line is the line
5481 number in the file. Note that in the case of the Zero Cost Exception
5482 mechanism, these messages become redundant with the Exception_Information that
5483 contains a full backtrace of the calling sequence, so they are disabled.
5484 To disable explicitly the generation of the source location message, use the
5485 Pragma @code{Discard_Names}.
5487 @cindex Suppression of checks
5488 @cindex Checks, suppression of
5489 @unnumberedsec 11.5(28): Suppression of Checks
5492 The implementation should minimize the code executed for checks that
5493 have been suppressed.
5497 @cindex Representation clauses
5498 @unnumberedsec 13.1 (21-24): Representation Clauses
5501 The recommended level of support for all representation items is
5502 qualified as follows:
5506 An implementation need not support representation items containing
5507 non-static expressions, except that an implementation should support a
5508 representation item for a given entity if each non-static expression in
5509 the representation item is a name that statically denotes a constant
5510 declared before the entity.
5512 Followed. In fact, GNAT goes beyond the recommended level of support
5513 by allowing nonstatic expressions in some representation clauses even
5514 without the need to declare constants initialized with the values of
5518 @smallexample @c ada
5521 for Y'Address use X'Address;>>
5527 An implementation need not support a specification for the @code{Size}
5528 for a given composite subtype, nor the size or storage place for an
5529 object (including a component) of a given composite subtype, unless the
5530 constraints on the subtype and its composite subcomponents (if any) are
5531 all static constraints.
5533 Followed. Size Clauses are not permitted on non-static components, as
5538 An aliased component, or a component whose type is by-reference, should
5539 always be allocated at an addressable location.
5543 @cindex Packed types
5544 @unnumberedsec 13.2(6-8): Packed Types
5547 If a type is packed, then the implementation should try to minimize
5548 storage allocated to objects of the type, possibly at the expense of
5549 speed of accessing components, subject to reasonable complexity in
5550 addressing calculations.
5554 The recommended level of support pragma @code{Pack} is:
5556 For a packed record type, the components should be packed as tightly as
5557 possible subject to the Sizes of the component subtypes, and subject to
5558 any @code{record_representation_clause} that applies to the type; the
5559 implementation may, but need not, reorder components or cross aligned
5560 word boundaries to improve the packing. A component whose @code{Size} is
5561 greater than the word size may be allocated an integral number of words.
5563 Followed. Tight packing of arrays is supported for all component sizes
5564 up to 64-bits. If the array component size is 1 (that is to say, if
5565 the component is a boolean type or an enumeration type with two values)
5566 then values of the type are implicitly initialized to zero. This
5567 happens both for objects of the packed type, and for objects that have a
5568 subcomponent of the packed type.
5572 An implementation should support Address clauses for imported
5576 @cindex @code{Address} clauses
5577 @unnumberedsec 13.3(14-19): Address Clauses
5581 For an array @var{X}, @code{@var{X}'Address} should point at the first
5582 component of the array, and not at the array bounds.
5588 The recommended level of support for the @code{Address} attribute is:
5590 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5591 object that is aliased or of a by-reference type, or is an entity whose
5592 @code{Address} has been specified.
5594 Followed. A valid address will be produced even if none of those
5595 conditions have been met. If necessary, the object is forced into
5596 memory to ensure the address is valid.
5600 An implementation should support @code{Address} clauses for imported
5607 Objects (including subcomponents) that are aliased or of a by-reference
5608 type should be allocated on storage element boundaries.
5614 If the @code{Address} of an object is specified, or it is imported or exported,
5615 then the implementation should not perform optimizations based on
5616 assumptions of no aliases.
5620 @cindex @code{Alignment} clauses
5621 @unnumberedsec 13.3(29-35): Alignment Clauses
5624 The recommended level of support for the @code{Alignment} attribute for
5627 An implementation should support specified Alignments that are factors
5628 and multiples of the number of storage elements per word, subject to the
5635 An implementation need not support specified @code{Alignment}s for
5636 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5637 loaded and stored by available machine instructions.
5643 An implementation need not support specified @code{Alignment}s that are
5644 greater than the maximum @code{Alignment} the implementation ever returns by
5651 The recommended level of support for the @code{Alignment} attribute for
5654 Same as above, for subtypes, but in addition:
5660 For stand-alone library-level objects of statically constrained
5661 subtypes, the implementation should support all @code{Alignment}s
5662 supported by the target linker. For example, page alignment is likely to
5663 be supported for such objects, but not for subtypes.
5667 @cindex @code{Size} clauses
5668 @unnumberedsec 13.3(42-43): Size Clauses
5671 The recommended level of support for the @code{Size} attribute of
5674 A @code{Size} clause should be supported for an object if the specified
5675 @code{Size} is at least as large as its subtype's @code{Size}, and
5676 corresponds to a size in storage elements that is a multiple of the
5677 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5681 @unnumberedsec 13.3(50-56): Size Clauses
5684 If the @code{Size} of a subtype is specified, and allows for efficient
5685 independent addressability (see 9.10) on the target architecture, then
5686 the @code{Size} of the following objects of the subtype should equal the
5687 @code{Size} of the subtype:
5689 Aliased objects (including components).
5695 @code{Size} clause on a composite subtype should not affect the
5696 internal layout of components.
5702 The recommended level of support for the @code{Size} attribute of subtypes is:
5706 The @code{Size} (if not specified) of a static discrete or fixed point
5707 subtype should be the number of bits needed to represent each value
5708 belonging to the subtype using an unbiased representation, leaving space
5709 for a sign bit only if the subtype contains negative values. If such a
5710 subtype is a first subtype, then an implementation should support a
5711 specified @code{Size} for it that reflects this representation.
5717 For a subtype implemented with levels of indirection, the @code{Size}
5718 should include the size of the pointers, but not the size of what they
5723 @cindex @code{Component_Size} clauses
5724 @unnumberedsec 13.3(71-73): Component Size Clauses
5727 The recommended level of support for the @code{Component_Size}
5732 An implementation need not support specified @code{Component_Sizes} that are
5733 less than the @code{Size} of the component subtype.
5739 An implementation should support specified @code{Component_Size}s that
5740 are factors and multiples of the word size. For such
5741 @code{Component_Size}s, the array should contain no gaps between
5742 components. For other @code{Component_Size}s (if supported), the array
5743 should contain no gaps between components when packing is also
5744 specified; the implementation should forbid this combination in cases
5745 where it cannot support a no-gaps representation.
5749 @cindex Enumeration representation clauses
5750 @cindex Representation clauses, enumeration
5751 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5754 The recommended level of support for enumeration representation clauses
5757 An implementation need not support enumeration representation clauses
5758 for boolean types, but should at minimum support the internal codes in
5759 the range @code{System.Min_Int.System.Max_Int}.
5763 @cindex Record representation clauses
5764 @cindex Representation clauses, records
5765 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5768 The recommended level of support for
5769 @*@code{record_representation_clauses} is:
5771 An implementation should support storage places that can be extracted
5772 with a load, mask, shift sequence of machine code, and set with a load,
5773 shift, mask, store sequence, given the available machine instructions
5780 A storage place should be supported if its size is equal to the
5781 @code{Size} of the component subtype, and it starts and ends on a
5782 boundary that obeys the @code{Alignment} of the component subtype.
5788 If the default bit ordering applies to the declaration of a given type,
5789 then for a component whose subtype's @code{Size} is less than the word
5790 size, any storage place that does not cross an aligned word boundary
5791 should be supported.
5797 An implementation may reserve a storage place for the tag field of a
5798 tagged type, and disallow other components from overlapping that place.
5800 Followed. The storage place for the tag field is the beginning of the tagged
5801 record, and its size is Address'Size. GNAT will reject an explicit component
5802 clause for the tag field.
5806 An implementation need not support a @code{component_clause} for a
5807 component of an extension part if the storage place is not after the
5808 storage places of all components of the parent type, whether or not
5809 those storage places had been specified.
5811 Followed. The above advice on record representation clauses is followed,
5812 and all mentioned features are implemented.
5814 @cindex Storage place attributes
5815 @unnumberedsec 13.5.2(5): Storage Place Attributes
5818 If a component is represented using some form of pointer (such as an
5819 offset) to the actual data of the component, and this data is contiguous
5820 with the rest of the object, then the storage place attributes should
5821 reflect the place of the actual data, not the pointer. If a component is
5822 allocated discontinuously from the rest of the object, then a warning
5823 should be generated upon reference to one of its storage place
5826 Followed. There are no such components in GNAT@.
5828 @cindex Bit ordering
5829 @unnumberedsec 13.5.3(7-8): Bit Ordering
5832 The recommended level of support for the non-default bit ordering is:
5836 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5837 should support the non-default bit ordering in addition to the default
5840 Followed. Word size does not equal storage size in this implementation.
5841 Thus non-default bit ordering is not supported.
5843 @cindex @code{Address}, as private type
5844 @unnumberedsec 13.7(37): Address as Private
5847 @code{Address} should be of a private type.
5851 @cindex Operations, on @code{Address}
5852 @cindex @code{Address}, operations of
5853 @unnumberedsec 13.7.1(16): Address Operations
5856 Operations in @code{System} and its children should reflect the target
5857 environment semantics as closely as is reasonable. For example, on most
5858 machines, it makes sense for address arithmetic to ``wrap around''.
5859 Operations that do not make sense should raise @code{Program_Error}.
5861 Followed. Address arithmetic is modular arithmetic that wraps around. No
5862 operation raises @code{Program_Error}, since all operations make sense.
5864 @cindex Unchecked conversion
5865 @unnumberedsec 13.9(14-17): Unchecked Conversion
5868 The @code{Size} of an array object should not include its bounds; hence,
5869 the bounds should not be part of the converted data.
5875 The implementation should not generate unnecessary run-time checks to
5876 ensure that the representation of @var{S} is a representation of the
5877 target type. It should take advantage of the permission to return by
5878 reference when possible. Restrictions on unchecked conversions should be
5879 avoided unless required by the target environment.
5881 Followed. There are no restrictions on unchecked conversion. A warning is
5882 generated if the source and target types do not have the same size since
5883 the semantics in this case may be target dependent.
5887 The recommended level of support for unchecked conversions is:
5891 Unchecked conversions should be supported and should be reversible in
5892 the cases where this clause defines the result. To enable meaningful use
5893 of unchecked conversion, a contiguous representation should be used for
5894 elementary subtypes, for statically constrained array subtypes whose
5895 component subtype is one of the subtypes described in this paragraph,
5896 and for record subtypes without discriminants whose component subtypes
5897 are described in this paragraph.
5901 @cindex Heap usage, implicit
5902 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5905 An implementation should document any cases in which it dynamically
5906 allocates heap storage for a purpose other than the evaluation of an
5909 Followed, the only other points at which heap storage is dynamically
5910 allocated are as follows:
5914 At initial elaboration time, to allocate dynamically sized global
5918 To allocate space for a task when a task is created.
5921 To extend the secondary stack dynamically when needed. The secondary
5922 stack is used for returning variable length results.
5927 A default (implementation-provided) storage pool for an
5928 access-to-constant type should not have overhead to support deallocation of
5935 A storage pool for an anonymous access type should be created at the
5936 point of an allocator for the type, and be reclaimed when the designated
5937 object becomes inaccessible.
5941 @cindex Unchecked deallocation
5942 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5945 For a standard storage pool, @code{Free} should actually reclaim the
5950 @cindex Stream oriented attributes
5951 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5954 If a stream element is the same size as a storage element, then the
5955 normal in-memory representation should be used by @code{Read} and
5956 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
5957 should use the smallest number of stream elements needed to represent
5958 all values in the base range of the scalar type.
5961 Followed. By default, GNAT uses the interpretation suggested by AI-195,
5962 which specifies using the size of the first subtype.
5963 However, such an implementation is based on direct binary
5964 representations and is therefore target- and endianness-dependent.
5965 To address this issue, GNAT also supplies an alternate implementation
5966 of the stream attributes @code{Read} and @code{Write},
5967 which uses the target-independent XDR standard representation
5969 @cindex XDR representation
5970 @cindex @code{Read} attribute
5971 @cindex @code{Write} attribute
5972 @cindex Stream oriented attributes
5973 The XDR implementation is provided as an alternative body of the
5974 @code{System.Stream_Attributes} package, in the file
5975 @file{s-strxdr.adb} in the GNAT library.
5976 There is no @file{s-strxdr.ads} file.
5977 In order to install the XDR implementation, do the following:
5979 @item Replace the default implementation of the
5980 @code{System.Stream_Attributes} package with the XDR implementation.
5981 For example on a Unix platform issue the commands:
5983 $ mv s-stratt.adb s-strold.adb
5984 $ mv s-strxdr.adb s-stratt.adb
5988 Rebuild the GNAT run-time library as documented in the
5989 @cite{GNAT User's Guide}
5992 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5995 If an implementation provides additional named predefined integer types,
5996 then the names should end with @samp{Integer} as in
5997 @samp{Long_Integer}. If an implementation provides additional named
5998 predefined floating point types, then the names should end with
5999 @samp{Float} as in @samp{Long_Float}.
6003 @findex Ada.Characters.Handling
6004 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6007 If an implementation provides a localized definition of @code{Character}
6008 or @code{Wide_Character}, then the effects of the subprograms in
6009 @code{Characters.Handling} should reflect the localizations. See also
6012 Followed. GNAT provides no such localized definitions.
6014 @cindex Bounded-length strings
6015 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6018 Bounded string objects should not be implemented by implicit pointers
6019 and dynamic allocation.
6021 Followed. No implicit pointers or dynamic allocation are used.
6023 @cindex Random number generation
6024 @unnumberedsec A.5.2(46-47): Random Number Generation
6027 Any storage associated with an object of type @code{Generator} should be
6028 reclaimed on exit from the scope of the object.
6034 If the generator period is sufficiently long in relation to the number
6035 of distinct initiator values, then each possible value of
6036 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6037 random numbers that does not, in a practical sense, overlap the sequence
6038 initiated by any other value. If this is not possible, then the mapping
6039 between initiator values and generator states should be a rapidly
6040 varying function of the initiator value.
6042 Followed. The generator period is sufficiently long for the first
6043 condition here to hold true.
6045 @findex Get_Immediate
6046 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6049 The @code{Get_Immediate} procedures should be implemented with
6050 unbuffered input. For a device such as a keyboard, input should be
6051 @dfn{available} if a key has already been typed, whereas for a disk
6052 file, input should always be available except at end of file. For a file
6053 associated with a keyboard-like device, any line-editing features of the
6054 underlying operating system should be disabled during the execution of
6055 @code{Get_Immediate}.
6057 Followed on all targets except VxWorks. For VxWorks, there is no way to
6058 provide this functionality that does not result in the input buffer being
6059 flushed before the @code{Get_Immediate} call. A special unit
6060 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6064 @unnumberedsec B.1(39-41): Pragma @code{Export}
6067 If an implementation supports pragma @code{Export} to a given language,
6068 then it should also allow the main subprogram to be written in that
6069 language. It should support some mechanism for invoking the elaboration
6070 of the Ada library units included in the system, and for invoking the
6071 finalization of the environment task. On typical systems, the
6072 recommended mechanism is to provide two subprograms whose link names are
6073 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
6074 elaboration code for library units. @code{adafinal} should contain the
6075 finalization code. These subprograms should have no effect the second
6076 and subsequent time they are called.
6082 Automatic elaboration of pre-elaborated packages should be
6083 provided when pragma @code{Export} is supported.
6085 Followed when the main program is in Ada. If the main program is in a
6086 foreign language, then
6087 @code{adainit} must be called to elaborate pre-elaborated
6092 For each supported convention @var{L} other than @code{Intrinsic}, an
6093 implementation should support @code{Import} and @code{Export} pragmas
6094 for objects of @var{L}-compatible types and for subprograms, and pragma
6095 @code{Convention} for @var{L}-eligible types and for subprograms,
6096 presuming the other language has corresponding features. Pragma
6097 @code{Convention} need not be supported for scalar types.
6101 @cindex Package @code{Interfaces}
6103 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6106 For each implementation-defined convention identifier, there should be a
6107 child package of package Interfaces with the corresponding name. This
6108 package should contain any declarations that would be useful for
6109 interfacing to the language (implementation) represented by the
6110 convention. Any declarations useful for interfacing to any language on
6111 the given hardware architecture should be provided directly in
6114 Followed. An additional package not defined
6115 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
6116 for interfacing to C++.
6120 An implementation supporting an interface to C, COBOL, or Fortran should
6121 provide the corresponding package or packages described in the following
6124 Followed. GNAT provides all the packages described in this section.
6126 @cindex C, interfacing with
6127 @unnumberedsec B.3(63-71): Interfacing with C
6130 An implementation should support the following interface correspondences
6137 An Ada procedure corresponds to a void-returning C function.
6143 An Ada function corresponds to a non-void C function.
6149 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
6156 An Ada @code{in} parameter of an access-to-object type with designated
6157 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
6158 where @var{t} is the C type corresponding to the Ada type @var{T}.
6164 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
6165 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
6166 argument to a C function, where @var{t} is the C type corresponding to
6167 the Ada type @var{T}. In the case of an elementary @code{out} or
6168 @code{in out} parameter, a pointer to a temporary copy is used to
6169 preserve by-copy semantics.
6175 An Ada parameter of a record type @var{T}, of any mode, is passed as a
6176 @code{@var{t}*} argument to a C function, where @var{t} is the C
6177 structure corresponding to the Ada type @var{T}.
6179 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
6180 pragma, or Convention, or by explicitly specifying the mechanism for a given
6181 call using an extended import or export pragma.
6185 An Ada parameter of an array type with component type @var{T}, of any
6186 mode, is passed as a @code{@var{t}*} argument to a C function, where
6187 @var{t} is the C type corresponding to the Ada type @var{T}.
6193 An Ada parameter of an access-to-subprogram type is passed as a pointer
6194 to a C function whose prototype corresponds to the designated
6195 subprogram's specification.
6199 @cindex COBOL, interfacing with
6200 @unnumberedsec B.4(95-98): Interfacing with COBOL
6203 An Ada implementation should support the following interface
6204 correspondences between Ada and COBOL@.
6210 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
6211 the COBOL type corresponding to @var{T}.
6217 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
6218 the corresponding COBOL type.
6224 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
6225 COBOL type corresponding to the Ada parameter type; for scalars, a local
6226 copy is used if necessary to ensure by-copy semantics.
6230 @cindex Fortran, interfacing with
6231 @unnumberedsec B.5(22-26): Interfacing with Fortran
6234 An Ada implementation should support the following interface
6235 correspondences between Ada and Fortran:
6241 An Ada procedure corresponds to a Fortran subroutine.
6247 An Ada function corresponds to a Fortran function.
6253 An Ada parameter of an elementary, array, or record type @var{T} is
6254 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
6255 the Fortran type corresponding to the Ada type @var{T}, and where the
6256 INTENT attribute of the corresponding dummy argument matches the Ada
6257 formal parameter mode; the Fortran implementation's parameter passing
6258 conventions are used. For elementary types, a local copy is used if
6259 necessary to ensure by-copy semantics.
6265 An Ada parameter of an access-to-subprogram type is passed as a
6266 reference to a Fortran procedure whose interface corresponds to the
6267 designated subprogram's specification.
6271 @cindex Machine operations
6272 @unnumberedsec C.1(3-5): Access to Machine Operations
6275 The machine code or intrinsic support should allow access to all
6276 operations normally available to assembly language programmers for the
6277 target environment, including privileged instructions, if any.
6283 The interfacing pragmas (see Annex B) should support interface to
6284 assembler; the default assembler should be associated with the
6285 convention identifier @code{Assembler}.
6291 If an entity is exported to assembly language, then the implementation
6292 should allocate it at an addressable location, and should ensure that it
6293 is retained by the linking process, even if not otherwise referenced
6294 from the Ada code. The implementation should assume that any call to a
6295 machine code or assembler subprogram is allowed to read or update every
6296 object that is specified as exported.
6300 @unnumberedsec C.1(10-16): Access to Machine Operations
6303 The implementation should ensure that little or no overhead is
6304 associated with calling intrinsic and machine-code subprograms.
6306 Followed for both intrinsics and machine-code subprograms.
6310 It is recommended that intrinsic subprograms be provided for convenient
6311 access to any machine operations that provide special capabilities or
6312 efficiency and that are not otherwise available through the language
6315 Followed. A full set of machine operation intrinsic subprograms is provided.
6319 Atomic read-modify-write operations---e.g.@:, test and set, compare and
6320 swap, decrement and test, enqueue/dequeue.
6322 Followed on any target supporting such operations.
6326 Standard numeric functions---e.g.@:, sin, log.
6328 Followed on any target supporting such operations.
6332 String manipulation operations---e.g.@:, translate and test.
6334 Followed on any target supporting such operations.
6338 Vector operations---e.g.@:, compare vector against thresholds.
6340 Followed on any target supporting such operations.
6344 Direct operations on I/O ports.
6346 Followed on any target supporting such operations.
6348 @cindex Interrupt support
6349 @unnumberedsec C.3(28): Interrupt Support
6352 If the @code{Ceiling_Locking} policy is not in effect, the
6353 implementation should provide means for the application to specify which
6354 interrupts are to be blocked during protected actions, if the underlying
6355 system allows for a finer-grain control of interrupt blocking.
6357 Followed. The underlying system does not allow for finer-grain control
6358 of interrupt blocking.
6360 @cindex Protected procedure handlers
6361 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6364 Whenever possible, the implementation should allow interrupt handlers to
6365 be called directly by the hardware.
6369 This is never possible under IRIX, so this is followed by default.
6371 Followed on any target where the underlying operating system permits
6376 Whenever practical, violations of any
6377 implementation-defined restrictions should be detected before run time.
6379 Followed. Compile time warnings are given when possible.
6381 @cindex Package @code{Interrupts}
6383 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6387 If implementation-defined forms of interrupt handler procedures are
6388 supported, such as protected procedures with parameters, then for each
6389 such form of a handler, a type analogous to @code{Parameterless_Handler}
6390 should be specified in a child package of @code{Interrupts}, with the
6391 same operations as in the predefined package Interrupts.
6395 @cindex Pre-elaboration requirements
6396 @unnumberedsec C.4(14): Pre-elaboration Requirements
6399 It is recommended that pre-elaborated packages be implemented in such a
6400 way that there should be little or no code executed at run time for the
6401 elaboration of entities not already covered by the Implementation
6404 Followed. Executable code is generated in some cases, e.g.@: loops
6405 to initialize large arrays.
6407 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6411 If the pragma applies to an entity, then the implementation should
6412 reduce the amount of storage used for storing names associated with that
6417 @cindex Package @code{Task_Attributes}
6418 @findex Task_Attributes
6419 @unnumberedsec C.7.2(30): The Package Task_Attributes
6422 Some implementations are targeted to domains in which memory use at run
6423 time must be completely deterministic. For such implementations, it is
6424 recommended that the storage for task attributes will be pre-allocated
6425 statically and not from the heap. This can be accomplished by either
6426 placing restrictions on the number and the size of the task's
6427 attributes, or by using the pre-allocated storage for the first @var{N}
6428 attribute objects, and the heap for the others. In the latter case,
6429 @var{N} should be documented.
6431 Not followed. This implementation is not targeted to such a domain.
6433 @cindex Locking Policies
6434 @unnumberedsec D.3(17): Locking Policies
6438 The implementation should use names that end with @samp{_Locking} for
6439 locking policies defined by the implementation.
6441 Followed. A single implementation-defined locking policy is defined,
6442 whose name (@code{Inheritance_Locking}) follows this suggestion.
6444 @cindex Entry queuing policies
6445 @unnumberedsec D.4(16): Entry Queuing Policies
6448 Names that end with @samp{_Queuing} should be used
6449 for all implementation-defined queuing policies.
6451 Followed. No such implementation-defined queuing policies exist.
6453 @cindex Preemptive abort
6454 @unnumberedsec D.6(9-10): Preemptive Abort
6457 Even though the @code{abort_statement} is included in the list of
6458 potentially blocking operations (see 9.5.1), it is recommended that this
6459 statement be implemented in a way that never requires the task executing
6460 the @code{abort_statement} to block.
6466 On a multi-processor, the delay associated with aborting a task on
6467 another processor should be bounded; the implementation should use
6468 periodic polling, if necessary, to achieve this.
6472 @cindex Tasking restrictions
6473 @unnumberedsec D.7(21): Tasking Restrictions
6476 When feasible, the implementation should take advantage of the specified
6477 restrictions to produce a more efficient implementation.
6479 GNAT currently takes advantage of these restrictions by providing an optimized
6480 run time when the Ravenscar profile and the GNAT restricted run time set
6481 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
6482 pragma @code{Profile (Restricted)} for more details.
6484 @cindex Time, monotonic
6485 @unnumberedsec D.8(47-49): Monotonic Time
6488 When appropriate, implementations should provide configuration
6489 mechanisms to change the value of @code{Tick}.
6491 Such configuration mechanisms are not appropriate to this implementation
6492 and are thus not supported.
6496 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6497 be implemented as transformations of the same time base.
6503 It is recommended that the @dfn{best} time base which exists in
6504 the underlying system be available to the application through
6505 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
6509 @cindex Partition communication subsystem
6511 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6514 Whenever possible, the PCS on the called partition should allow for
6515 multiple tasks to call the RPC-receiver with different messages and
6516 should allow them to block until the corresponding subprogram body
6519 Followed by GLADE, a separately supplied PCS that can be used with
6524 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6525 should raise @code{Storage_Error} if it runs out of space trying to
6526 write the @code{Item} into the stream.
6528 Followed by GLADE, a separately supplied PCS that can be used with
6531 @cindex COBOL support
6532 @unnumberedsec F(7): COBOL Support
6535 If COBOL (respectively, C) is widely supported in the target
6536 environment, implementations supporting the Information Systems Annex
6537 should provide the child package @code{Interfaces.COBOL} (respectively,
6538 @code{Interfaces.C}) specified in Annex B and should support a
6539 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6540 pragmas (see Annex B), thus allowing Ada programs to interface with
6541 programs written in that language.
6545 @cindex Decimal radix support
6546 @unnumberedsec F.1(2): Decimal Radix Support
6549 Packed decimal should be used as the internal representation for objects
6550 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6552 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
6556 @unnumberedsec G: Numerics
6559 If Fortran (respectively, C) is widely supported in the target
6560 environment, implementations supporting the Numerics Annex
6561 should provide the child package @code{Interfaces.Fortran} (respectively,
6562 @code{Interfaces.C}) specified in Annex B and should support a
6563 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6564 pragmas (see Annex B), thus allowing Ada programs to interface with
6565 programs written in that language.
6569 @cindex Complex types
6570 @unnumberedsec G.1.1(56-58): Complex Types
6573 Because the usual mathematical meaning of multiplication of a complex
6574 operand and a real operand is that of the scaling of both components of
6575 the former by the latter, an implementation should not perform this
6576 operation by first promoting the real operand to complex type and then
6577 performing a full complex multiplication. In systems that, in the
6578 future, support an Ada binding to IEC 559:1989, the latter technique
6579 will not generate the required result when one of the components of the
6580 complex operand is infinite. (Explicit multiplication of the infinite
6581 component by the zero component obtained during promotion yields a NaN
6582 that propagates into the final result.) Analogous advice applies in the
6583 case of multiplication of a complex operand and a pure-imaginary
6584 operand, and in the case of division of a complex operand by a real or
6585 pure-imaginary operand.
6591 Similarly, because the usual mathematical meaning of addition of a
6592 complex operand and a real operand is that the imaginary operand remains
6593 unchanged, an implementation should not perform this operation by first
6594 promoting the real operand to complex type and then performing a full
6595 complex addition. In implementations in which the @code{Signed_Zeros}
6596 attribute of the component type is @code{True} (and which therefore
6597 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6598 predefined arithmetic operations), the latter technique will not
6599 generate the required result when the imaginary component of the complex
6600 operand is a negatively signed zero. (Explicit addition of the negative
6601 zero to the zero obtained during promotion yields a positive zero.)
6602 Analogous advice applies in the case of addition of a complex operand
6603 and a pure-imaginary operand, and in the case of subtraction of a
6604 complex operand and a real or pure-imaginary operand.
6610 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6611 attempt to provide a rational treatment of the signs of zero results and
6612 result components. As one example, the result of the @code{Argument}
6613 function should have the sign of the imaginary component of the
6614 parameter @code{X} when the point represented by that parameter lies on
6615 the positive real axis; as another, the sign of the imaginary component
6616 of the @code{Compose_From_Polar} function should be the same as
6617 (respectively, the opposite of) that of the @code{Argument} parameter when that
6618 parameter has a value of zero and the @code{Modulus} parameter has a
6619 nonnegative (respectively, negative) value.
6623 @cindex Complex elementary functions
6624 @unnumberedsec G.1.2(49): Complex Elementary Functions
6627 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6628 @code{True} should attempt to provide a rational treatment of the signs
6629 of zero results and result components. For example, many of the complex
6630 elementary functions have components that are odd functions of one of
6631 the parameter components; in these cases, the result component should
6632 have the sign of the parameter component at the origin. Other complex
6633 elementary functions have zero components whose sign is opposite that of
6634 a parameter component at the origin, or is always positive or always
6639 @cindex Accuracy requirements
6640 @unnumberedsec G.2.4(19): Accuracy Requirements
6643 The versions of the forward trigonometric functions without a
6644 @code{Cycle} parameter should not be implemented by calling the
6645 corresponding version with a @code{Cycle} parameter of
6646 @code{2.0*Numerics.Pi}, since this will not provide the required
6647 accuracy in some portions of the domain. For the same reason, the
6648 version of @code{Log} without a @code{Base} parameter should not be
6649 implemented by calling the corresponding version with a @code{Base}
6650 parameter of @code{Numerics.e}.
6654 @cindex Complex arithmetic accuracy
6655 @cindex Accuracy, complex arithmetic
6656 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6660 The version of the @code{Compose_From_Polar} function without a
6661 @code{Cycle} parameter should not be implemented by calling the
6662 corresponding version with a @code{Cycle} parameter of
6663 @code{2.0*Numerics.Pi}, since this will not provide the required
6664 accuracy in some portions of the domain.
6668 @c -----------------------------------------
6669 @node Implementation Defined Characteristics
6670 @chapter Implementation Defined Characteristics
6673 In addition to the implementation dependent pragmas and attributes, and
6674 the implementation advice, there are a number of other features of Ada
6675 95 that are potentially implementation dependent. These are mentioned
6676 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6678 A requirement for conforming Ada compilers is that they provide
6679 documentation describing how the implementation deals with each of these
6680 issues. In this chapter, you will find each point in annex M listed
6681 followed by a description in italic font of how GNAT
6685 implementation on IRIX 5.3 operating system or greater
6687 handles the implementation dependence.
6689 You can use this chapter as a guide to minimizing implementation
6690 dependent features in your programs if portability to other compilers
6691 and other operating systems is an important consideration. The numbers
6692 in each section below correspond to the paragraph number in the Ada 95
6698 @strong{2}. Whether or not each recommendation given in Implementation
6699 Advice is followed. See 1.1.2(37).
6702 @xref{Implementation Advice}.
6707 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
6710 The complexity of programs that can be processed is limited only by the
6711 total amount of available virtual memory, and disk space for the
6712 generated object files.
6717 @strong{4}. Variations from the standard that are impractical to avoid
6718 given the implementation's execution environment. See 1.1.3(6).
6721 There are no variations from the standard.
6726 @strong{5}. Which @code{code_statement}s cause external
6727 interactions. See 1.1.3(10).
6730 Any @code{code_statement} can potentially cause external interactions.
6735 @strong{6}. The coded representation for the text of an Ada
6736 program. See 2.1(4).
6739 See separate section on source representation.
6744 @strong{7}. The control functions allowed in comments. See 2.1(14).
6747 See separate section on source representation.
6752 @strong{8}. The representation for an end of line. See 2.2(2).
6755 See separate section on source representation.
6760 @strong{9}. Maximum supported line length and lexical element
6761 length. See 2.2(15).
6764 The maximum line length is 255 characters an the maximum length of a
6765 lexical element is also 255 characters.
6770 @strong{10}. Implementation defined pragmas. See 2.8(14).
6774 @xref{Implementation Defined Pragmas}.
6779 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
6782 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6783 parameter, checks that the optimization flag is set, and aborts if it is
6789 @strong{12}. The sequence of characters of the value returned by
6790 @code{@var{S}'Image} when some of the graphic characters of
6791 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
6795 The sequence of characters is as defined by the wide character encoding
6796 method used for the source. See section on source representation for
6802 @strong{13}. The predefined integer types declared in
6803 @code{Standard}. See 3.5.4(25).
6807 @item Short_Short_Integer
6810 (Short) 16 bit signed
6814 64 bit signed (Alpha OpenVMS only)
6815 32 bit signed (all other targets)
6816 @item Long_Long_Integer
6823 @strong{14}. Any nonstandard integer types and the operators defined
6824 for them. See 3.5.4(26).
6827 There are no nonstandard integer types.
6832 @strong{15}. Any nonstandard real types and the operators defined for
6836 There are no nonstandard real types.
6841 @strong{16}. What combinations of requested decimal precision and range
6842 are supported for floating point types. See 3.5.7(7).
6845 The precision and range is as defined by the IEEE standard.
6850 @strong{17}. The predefined floating point types declared in
6851 @code{Standard}. See 3.5.7(16).
6858 (Short) 32 bit IEEE short
6861 @item Long_Long_Float
6862 64 bit IEEE long (80 bit IEEE long on x86 processors)
6868 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
6871 @code{Fine_Delta} is 2**(@minus{}63)
6876 @strong{19}. What combinations of small, range, and digits are
6877 supported for fixed point types. See 3.5.9(10).
6880 Any combinations are permitted that do not result in a small less than
6881 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6882 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6883 is 64 bits (true of all architectures except ia32), then the output from
6884 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
6885 is because floating-point conversions are used to convert fixed point.
6890 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
6891 within an unnamed @code{block_statement}. See 3.9(10).
6894 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6895 decimal integer are allocated.
6900 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
6903 @xref{Implementation Defined Attributes}.
6908 @strong{22}. Any implementation-defined time types. See 9.6(6).
6911 There are no implementation-defined time types.
6916 @strong{23}. The time base associated with relative delays.
6919 See 9.6(20). The time base used is that provided by the C library
6920 function @code{gettimeofday}.
6925 @strong{24}. The time base of the type @code{Calendar.Time}. See
6929 The time base used is that provided by the C library function
6930 @code{gettimeofday}.
6935 @strong{25}. The time zone used for package @code{Calendar}
6936 operations. See 9.6(24).
6939 The time zone used by package @code{Calendar} is the current system time zone
6940 setting for local time, as accessed by the C library function
6946 @strong{26}. Any limit on @code{delay_until_statements} of
6947 @code{select_statements}. See 9.6(29).
6950 There are no such limits.
6955 @strong{27}. Whether or not two non overlapping parts of a composite
6956 object are independently addressable, in the case where packing, record
6957 layout, or @code{Component_Size} is specified for the object. See
6961 Separate components are independently addressable if they do not share
6962 overlapping storage units.
6967 @strong{28}. The representation for a compilation. See 10.1(2).
6970 A compilation is represented by a sequence of files presented to the
6971 compiler in a single invocation of the @code{gcc} command.
6976 @strong{29}. Any restrictions on compilations that contain multiple
6977 compilation_units. See 10.1(4).
6980 No single file can contain more than one compilation unit, but any
6981 sequence of files can be presented to the compiler as a single
6987 @strong{30}. The mechanisms for creating an environment and for adding
6988 and replacing compilation units. See 10.1.4(3).
6991 See separate section on compilation model.
6996 @strong{31}. The manner of explicitly assigning library units to a
6997 partition. See 10.2(2).
7000 If a unit contains an Ada main program, then the Ada units for the partition
7001 are determined by recursive application of the rules in the Ada Reference
7002 Manual section 10.2(2-6). In other words, the Ada units will be those that
7003 are needed by the main program, and then this definition of need is applied
7004 recursively to those units, and the partition contains the transitive
7005 closure determined by this relationship. In short, all the necessary units
7006 are included, with no need to explicitly specify the list. If additional
7007 units are required, e.g.@: by foreign language units, then all units must be
7008 mentioned in the context clause of one of the needed Ada units.
7010 If the partition contains no main program, or if the main program is in
7011 a language other than Ada, then GNAT
7012 provides the binder options @code{-z} and @code{-n} respectively, and in
7013 this case a list of units can be explicitly supplied to the binder for
7014 inclusion in the partition (all units needed by these units will also
7015 be included automatically). For full details on the use of these
7016 options, refer to the @cite{GNAT User's Guide} sections on Binding
7022 @strong{32}. The implementation-defined means, if any, of specifying
7023 which compilation units are needed by a given compilation unit. See
7027 The units needed by a given compilation unit are as defined in
7028 the Ada Reference Manual section 10.2(2-6). There are no
7029 implementation-defined pragmas or other implementation-defined
7030 means for specifying needed units.
7035 @strong{33}. The manner of designating the main subprogram of a
7036 partition. See 10.2(7).
7039 The main program is designated by providing the name of the
7040 corresponding @file{ALI} file as the input parameter to the binder.
7045 @strong{34}. The order of elaboration of @code{library_items}. See
7049 The first constraint on ordering is that it meets the requirements of
7050 chapter 10 of the Ada 95 Reference Manual. This still leaves some
7051 implementation dependent choices, which are resolved by first
7052 elaborating bodies as early as possible (i.e.@: in preference to specs
7053 where there is a choice), and second by evaluating the immediate with
7054 clauses of a unit to determine the probably best choice, and
7055 third by elaborating in alphabetical order of unit names
7056 where a choice still remains.
7061 @strong{35}. Parameter passing and function return for the main
7062 subprogram. See 10.2(21).
7065 The main program has no parameters. It may be a procedure, or a function
7066 returning an integer type. In the latter case, the returned integer
7067 value is the return code of the program (overriding any value that
7068 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7073 @strong{36}. The mechanisms for building and running partitions. See
7077 GNAT itself supports programs with only a single partition. The GNATDIST
7078 tool provided with the GLADE package (which also includes an implementation
7079 of the PCS) provides a completely flexible method for building and running
7080 programs consisting of multiple partitions. See the separate GLADE manual
7086 @strong{37}. The details of program execution, including program
7087 termination. See 10.2(25).
7090 See separate section on compilation model.
7095 @strong{38}. The semantics of any non-active partitions supported by the
7096 implementation. See 10.2(28).
7099 Passive partitions are supported on targets where shared memory is
7100 provided by the operating system. See the GLADE reference manual for
7106 @strong{39}. The information returned by @code{Exception_Message}. See
7110 Exception message returns the null string unless a specific message has
7111 been passed by the program.
7116 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
7117 declared within an unnamed @code{block_statement}. See 11.4.1(12).
7120 Blocks have implementation defined names of the form @code{B@var{nnn}}
7121 where @var{nnn} is an integer.
7126 @strong{41}. The information returned by
7127 @code{Exception_Information}. See 11.4.1(13).
7130 @code{Exception_Information} returns a string in the following format:
7133 @emph{Exception_Name:} nnnnn
7134 @emph{Message:} mmmmm
7136 @emph{Call stack traceback locations:}
7137 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
7145 @code{nnnn} is the fully qualified name of the exception in all upper
7146 case letters. This line is always present.
7149 @code{mmmm} is the message (this line present only if message is non-null)
7152 @code{ppp} is the Process Id value as a decimal integer (this line is
7153 present only if the Process Id is non-zero). Currently we are
7154 not making use of this field.
7157 The Call stack traceback locations line and the following values
7158 are present only if at least one traceback location was recorded.
7159 The values are given in C style format, with lower case letters
7160 for a-f, and only as many digits present as are necessary.
7164 The line terminator sequence at the end of each line, including
7165 the last line is a single @code{LF} character (@code{16#0A#}).
7170 @strong{42}. Implementation-defined check names. See 11.5(27).
7173 No implementation-defined check names are supported.
7178 @strong{43}. The interpretation of each aspect of representation. See
7182 See separate section on data representations.
7187 @strong{44}. Any restrictions placed upon representation items. See
7191 See separate section on data representations.
7196 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
7200 Size for an indefinite subtype is the maximum possible size, except that
7201 for the case of a subprogram parameter, the size of the parameter object
7207 @strong{46}. The default external representation for a type tag. See
7211 The default external representation for a type tag is the fully expanded
7212 name of the type in upper case letters.
7217 @strong{47}. What determines whether a compilation unit is the same in
7218 two different partitions. See 13.3(76).
7221 A compilation unit is the same in two different partitions if and only
7222 if it derives from the same source file.
7227 @strong{48}. Implementation-defined components. See 13.5.1(15).
7230 The only implementation defined component is the tag for a tagged type,
7231 which contains a pointer to the dispatching table.
7236 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
7237 ordering. See 13.5.3(5).
7240 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
7241 implementation, so no non-default bit ordering is supported. The default
7242 bit ordering corresponds to the natural endianness of the target architecture.
7247 @strong{50}. The contents of the visible part of package @code{System}
7248 and its language-defined children. See 13.7(2).
7251 See the definition of these packages in files @file{system.ads} and
7252 @file{s-stoele.ads}.
7257 @strong{51}. The contents of the visible part of package
7258 @code{System.Machine_Code}, and the meaning of
7259 @code{code_statements}. See 13.8(7).
7262 See the definition and documentation in file @file{s-maccod.ads}.
7267 @strong{52}. The effect of unchecked conversion. See 13.9(11).
7270 Unchecked conversion between types of the same size
7271 results in an uninterpreted transmission of the bits from one type
7272 to the other. If the types are of unequal sizes, then in the case of
7273 discrete types, a shorter source is first zero or sign extended as
7274 necessary, and a shorter target is simply truncated on the left.
7275 For all non-discrete types, the source is first copied if necessary
7276 to ensure that the alignment requirements of the target are met, then
7277 a pointer is constructed to the source value, and the result is obtained
7278 by dereferencing this pointer after converting it to be a pointer to the
7279 target type. Unchecked conversions where the target subtype is an
7280 unconstrained array are not permitted. If the target alignment is
7281 greater than the source alignment, then a copy of the result is
7282 made with appropriate alignment
7287 @strong{53}. The manner of choosing a storage pool for an access type
7288 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
7291 There are 3 different standard pools used by the compiler when
7292 @code{Storage_Pool} is not specified depending whether the type is local
7293 to a subprogram or defined at the library level and whether
7294 @code{Storage_Size}is specified or not. See documentation in the runtime
7295 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
7296 @code{System.Pool_Local} in files @file{s-poosiz.ads},
7297 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
7303 @strong{54}. Whether or not the implementation provides user-accessible
7304 names for the standard pool type(s). See 13.11(17).
7308 See documentation in the sources of the run time mentioned in paragraph
7309 @strong{53} . All these pools are accessible by means of @code{with}'ing
7315 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
7318 @code{Storage_Size} is measured in storage units, and refers to the
7319 total space available for an access type collection, or to the primary
7320 stack space for a task.
7325 @strong{56}. Implementation-defined aspects of storage pools. See
7329 See documentation in the sources of the run time mentioned in paragraph
7330 @strong{53} for details on GNAT-defined aspects of storage pools.
7335 @strong{57}. The set of restrictions allowed in a pragma
7336 @code{Restrictions}. See 13.12(7).
7339 All RM defined Restriction identifiers are implemented. The following
7340 additional restriction identifiers are provided. There are two separate
7341 lists of implementation dependent restriction identifiers. The first
7342 set requires consistency throughout a partition (in other words, if the
7343 restriction identifier is used for any compilation unit in the partition,
7344 then all compilation units in the partition must obey the restriction.
7348 @item Simple_Barriers
7349 @findex Simple_Barriers
7350 This restriction ensures at compile time that barriers in entry declarations
7351 for protected types are restricted to either static boolean expressions or
7352 references to simple boolean variables defined in the private part of the
7353 protected type. No other form of entry barriers is permitted. This is one
7354 of the restrictions of the Ravenscar profile for limited tasking (see also
7355 pragma @code{Profile (Ravenscar)}).
7357 @item Max_Entry_Queue_Length => Expr
7358 @findex Max_Entry_Queue_Length
7359 This restriction is a declaration that any protected entry compiled in
7360 the scope of the restriction has at most the specified number of
7361 tasks waiting on the entry
7362 at any one time, and so no queue is required. This restriction is not
7363 checked at compile time. A program execution is erroneous if an attempt
7364 is made to queue more than the specified number of tasks on such an entry.
7368 This restriction ensures at compile time that there is no implicit or
7369 explicit dependence on the package @code{Ada.Calendar}.
7371 @item No_Direct_Boolean_Operators
7372 @findex No_Direct_Boolean_Operators
7373 This restriction ensures that no logical (and/or/xor) or comparison
7374 operators are used on operands of type Boolean (or any type derived
7375 from Boolean). This is intended for use in safety critical programs
7376 where the certification protocol requires the use of short-circuit
7377 (and then, or else) forms for all composite boolean operations.
7379 @item No_Dynamic_Attachment
7380 @findex No_Dynamic_Attachment
7381 This restriction ensures that there is no call to any of the operations
7382 defined in package Ada.Interrupts.
7384 @item No_Enumeration_Maps
7385 @findex No_Enumeration_Maps
7386 This restriction ensures at compile time that no operations requiring
7387 enumeration maps are used (that is Image and Value attributes applied
7388 to enumeration types).
7390 @item No_Entry_Calls_In_Elaboration_Code
7391 @findex No_Entry_Calls_In_Elaboration_Code
7392 This restriction ensures at compile time that no task or protected entry
7393 calls are made during elaboration code. As a result of the use of this
7394 restriction, the compiler can assume that no code past an accept statement
7395 in a task can be executed at elaboration time.
7397 @item No_Exception_Handlers
7398 @findex No_Exception_Handlers
7399 This restriction ensures at compile time that there are no explicit
7400 exception handlers. It also indicates that no exception propagation will
7401 be provided. In this mode, exceptions may be raised but will result in
7402 an immediate call to the last chance handler, a routine that the user
7403 must define with the following profile:
7405 procedure Last_Chance_Handler
7406 (Source_Location : System.Address; Line : Integer);
7407 pragma Export (C, Last_Chance_Handler,
7408 "__gnat_last_chance_handler");
7410 The parameter is a C null-terminated string representing a message to be
7411 associated with the exception (typically the source location of the raise
7412 statement generated by the compiler). The Line parameter when non-zero
7413 represents the line number in the source program where the raise occurs.
7415 @item No_Exception_Streams
7416 @findex No_Exception_Streams
7417 This restriction ensures at compile time that no stream operations for
7418 types Exception_Id or Exception_Occurrence are used. This also makes it
7419 impossible to pass exceptions to or from a partition with this restriction
7420 in a distributed environment. If this exception is active, then the generated
7421 code is simplified by omitting the otherwise-required global registration
7422 of exceptions when they are declared.
7424 @item No_Implicit_Conditionals
7425 @findex No_Implicit_Conditionals
7426 This restriction ensures that the generated code does not contain any
7427 implicit conditionals, either by modifying the generated code where possible,
7428 or by rejecting any construct that would otherwise generate an implicit
7429 conditional. Note that this check does not include run time constraint
7430 checks, which on some targets may generate implicit conditionals as
7431 well. To control the latter, constraint checks can be suppressed in the
7434 @item No_Implicit_Dynamic_Code
7435 @findex No_Implicit_Dynamic_Code
7436 This restriction prevents the compiler from building ``trampolines''.
7437 This is a structure that is built on the stack and contains dynamic
7438 code to be executed at run time. A trampoline is needed to indirectly
7439 address a nested subprogram (that is a subprogram that is not at the
7440 library level). The restriction prevents the use of any of the
7441 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
7442 being applied to a subprogram that is not at the library level.
7444 @item No_Implicit_Loops
7445 @findex No_Implicit_Loops
7446 This restriction ensures that the generated code does not contain any
7447 implicit @code{for} loops, either by modifying
7448 the generated code where possible,
7449 or by rejecting any construct that would otherwise generate an implicit
7452 @item No_Initialize_Scalars
7453 @findex No_Initialize_Scalars
7454 This restriction ensures that no unit in the partition is compiled with
7455 pragma Initialize_Scalars. This allows the generation of more efficient
7456 code, and in particular eliminates dummy null initialization routines that
7457 are otherwise generated for some record and array types.
7459 @item No_Local_Protected_Objects
7460 @findex No_Local_Protected_Objects
7461 This restriction ensures at compile time that protected objects are
7462 only declared at the library level.
7464 @item No_Protected_Type_Allocators
7465 @findex No_Protected_Type_Allocators
7466 This restriction ensures at compile time that there are no allocator
7467 expressions that attempt to allocate protected objects.
7469 @item No_Secondary_Stack
7470 @findex No_Secondary_Stack
7471 This restriction ensures at compile time that the generated code does not
7472 contain any reference to the secondary stack. The secondary stack is used
7473 to implement functions returning unconstrained objects (arrays or records)
7476 @item No_Select_Statements
7477 @findex No_Select_Statements
7478 This restriction ensures at compile time no select statements of any kind
7479 are permitted, that is the keyword @code{select} may not appear.
7480 This is one of the restrictions of the Ravenscar
7481 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7483 @item No_Standard_Storage_Pools
7484 @findex No_Standard_Storage_Pools
7485 This restriction ensures at compile time that no access types
7486 use the standard default storage pool. Any access type declared must
7487 have an explicit Storage_Pool attribute defined specifying a
7488 user-defined storage pool.
7492 This restriction ensures at compile/bind time that there are no
7493 stream objects created (and therefore no actual stream operations).
7494 This restriction does not forbid dependences on the package
7495 @code{Ada.Streams}. So it is permissible to with
7496 @code{Ada.Streams} (or another package that does so itself)
7497 as long as no actual stream objects are created.
7499 @item No_Task_Attributes_Package
7500 @findex No_Task_Attributes_Package
7501 This restriction ensures at compile time that there are no implicit or
7502 explicit dependencies on the package @code{Ada.Task_Attributes}.
7504 @item No_Task_Termination
7505 @findex No_Task_Termination
7506 This restriction ensures at compile time that no terminate alternatives
7507 appear in any task body.
7511 This restriction prevents the declaration of tasks or task types throughout
7512 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
7513 except that violations are caught at compile time and cause an error message
7514 to be output either by the compiler or binder.
7516 @item No_Wide_Characters
7517 @findex No_Wide_Characters
7518 This restriction ensures at compile time that no uses of the types
7519 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7521 appear, and that no wide or wide wide string or character literals
7522 appear in the program (that is literals representing characters not in
7523 type @code{Character}.
7525 @item Static_Priorities
7526 @findex Static_Priorities
7527 This restriction ensures at compile time that all priority expressions
7528 are static, and that there are no dependencies on the package
7529 @code{Ada.Dynamic_Priorities}.
7531 @item Static_Storage_Size
7532 @findex Static_Storage_Size
7533 This restriction ensures at compile time that any expression appearing
7534 in a Storage_Size pragma or attribute definition clause is static.
7539 The second set of implementation dependent restriction identifiers
7540 does not require partition-wide consistency.
7541 The restriction may be enforced for a single
7542 compilation unit without any effect on any of the
7543 other compilation units in the partition.
7547 @item No_Elaboration_Code
7548 @findex No_Elaboration_Code
7549 This restriction ensures at compile time that no elaboration code is
7550 generated. Note that this is not the same condition as is enforced
7551 by pragma @code{Preelaborate}. There are cases in which pragma
7552 @code{Preelaborate} still permits code to be generated (e.g.@: code
7553 to initialize a large array to all zeroes), and there are cases of units
7554 which do not meet the requirements for pragma @code{Preelaborate},
7555 but for which no elaboration code is generated. Generally, it is
7556 the case that preelaborable units will meet the restrictions, with
7557 the exception of large aggregates initialized with an others_clause,
7558 and exception declarations (which generate calls to a run-time
7559 registry procedure). This restriction is enforced on
7560 a unit by unit basis, it need not be obeyed consistently
7561 throughout a partition.
7563 It is not possible to precisely document
7564 the constructs which are compatible with this restriction, since,
7565 unlike most other restrictions, this is not a restriction on the
7566 source code, but a restriction on the generated object code. For
7567 example, if the source contains a declaration:
7570 Val : constant Integer := X;
7574 where X is not a static constant, it may be possible, depending
7575 on complex optimization circuitry, for the compiler to figure
7576 out the value of X at compile time, in which case this initialization
7577 can be done by the loader, and requires no initialization code. It
7578 is not possible to document the precise conditions under which the
7579 optimizer can figure this out.
7581 @item No_Entry_Queue
7582 @findex No_Entry_Queue
7583 This restriction is a declaration that any protected entry compiled in
7584 the scope of the restriction has at most one task waiting on the entry
7585 at any one time, and so no queue is required. This restriction is not
7586 checked at compile time. A program execution is erroneous if an attempt
7587 is made to queue a second task on such an entry.
7589 @item No_Implementation_Attributes
7590 @findex No_Implementation_Attributes
7591 This restriction checks at compile time that no GNAT-defined attributes
7592 are present. With this restriction, the only attributes that can be used
7593 are those defined in the Ada 95 Reference Manual.
7595 @item No_Implementation_Pragmas
7596 @findex No_Implementation_Pragmas
7597 This restriction checks at compile time that no GNAT-defined pragmas
7598 are present. With this restriction, the only pragmas that can be used
7599 are those defined in the Ada 95 Reference Manual.
7601 @item No_Implementation_Restrictions
7602 @findex No_Implementation_Restrictions
7603 This restriction checks at compile time that no GNAT-defined restriction
7604 identifiers (other than @code{No_Implementation_Restrictions} itself)
7605 are present. With this restriction, the only other restriction identifiers
7606 that can be used are those defined in the Ada 95 Reference Manual.
7613 @strong{58}. The consequences of violating limitations on
7614 @code{Restrictions} pragmas. See 13.12(9).
7617 Restrictions that can be checked at compile time result in illegalities
7618 if violated. Currently there are no other consequences of violating
7624 @strong{59}. The representation used by the @code{Read} and
7625 @code{Write} attributes of elementary types in terms of stream
7626 elements. See 13.13.2(9).
7629 The representation is the in-memory representation of the base type of
7630 the type, using the number of bits corresponding to the
7631 @code{@var{type}'Size} value, and the natural ordering of the machine.
7636 @strong{60}. The names and characteristics of the numeric subtypes
7637 declared in the visible part of package @code{Standard}. See A.1(3).
7640 See items describing the integer and floating-point types supported.
7645 @strong{61}. The accuracy actually achieved by the elementary
7646 functions. See A.5.1(1).
7649 The elementary functions correspond to the functions available in the C
7650 library. Only fast math mode is implemented.
7655 @strong{62}. The sign of a zero result from some of the operators or
7656 functions in @code{Numerics.Generic_Elementary_Functions}, when
7657 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
7660 The sign of zeroes follows the requirements of the IEEE 754 standard on
7666 @strong{63}. The value of
7667 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
7670 Maximum image width is 649, see library file @file{a-numran.ads}.
7675 @strong{64}. The value of
7676 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
7679 Maximum image width is 80, see library file @file{a-nudira.ads}.
7684 @strong{65}. The algorithms for random number generation. See
7688 The algorithm is documented in the source files @file{a-numran.ads} and
7689 @file{a-numran.adb}.
7694 @strong{66}. The string representation of a random number generator's
7695 state. See A.5.2(38).
7698 See the documentation contained in the file @file{a-numran.adb}.
7703 @strong{67}. The minimum time interval between calls to the
7704 time-dependent Reset procedure that are guaranteed to initiate different
7705 random number sequences. See A.5.2(45).
7708 The minimum period between reset calls to guarantee distinct series of
7709 random numbers is one microsecond.
7714 @strong{68}. The values of the @code{Model_Mantissa},
7715 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7716 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7717 Annex is not supported. See A.5.3(72).
7720 See the source file @file{ttypef.ads} for the values of all numeric
7726 @strong{69}. Any implementation-defined characteristics of the
7727 input-output packages. See A.7(14).
7730 There are no special implementation defined characteristics for these
7736 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
7740 All type representations are contiguous, and the @code{Buffer_Size} is
7741 the value of @code{@var{type}'Size} rounded up to the next storage unit
7747 @strong{71}. External files for standard input, standard output, and
7748 standard error See A.10(5).
7751 These files are mapped onto the files provided by the C streams
7752 libraries. See source file @file{i-cstrea.ads} for further details.
7757 @strong{72}. The accuracy of the value produced by @code{Put}. See
7761 If more digits are requested in the output than are represented by the
7762 precision of the value, zeroes are output in the corresponding least
7763 significant digit positions.
7768 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
7769 @code{Command_Name}. See A.15(1).
7772 These are mapped onto the @code{argv} and @code{argc} parameters of the
7773 main program in the natural manner.
7778 @strong{74}. Implementation-defined convention names. See B.1(11).
7781 The following convention names are supported
7789 Synonym for Assembler
7791 Synonym for Assembler
7794 @item C_Pass_By_Copy
7795 Allowed only for record types, like C, but also notes that record
7796 is to be passed by copy rather than reference.
7802 Treated the same as C
7804 Treated the same as C
7808 For support of pragma @code{Import} with convention Intrinsic, see
7809 separate section on Intrinsic Subprograms.
7811 Stdcall (used for Windows implementations only). This convention correspond
7812 to the WINAPI (previously called Pascal convention) C/C++ convention under
7813 Windows. A function with this convention cleans the stack before exit.
7819 Stubbed is a special convention used to indicate that the body of the
7820 subprogram will be entirely ignored. Any call to the subprogram
7821 is converted into a raise of the @code{Program_Error} exception. If a
7822 pragma @code{Import} specifies convention @code{stubbed} then no body need
7823 be present at all. This convention is useful during development for the
7824 inclusion of subprograms whose body has not yet been written.
7828 In addition, all otherwise unrecognized convention names are also
7829 treated as being synonymous with convention C@. In all implementations
7830 except for VMS, use of such other names results in a warning. In VMS
7831 implementations, these names are accepted silently.
7836 @strong{75}. The meaning of link names. See B.1(36).
7839 Link names are the actual names used by the linker.
7844 @strong{76}. The manner of choosing link names when neither the link
7845 name nor the address of an imported or exported entity is specified. See
7849 The default linker name is that which would be assigned by the relevant
7850 external language, interpreting the Ada name as being in all lower case
7856 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
7859 The string passed to @code{Linker_Options} is presented uninterpreted as
7860 an argument to the link command, unless it contains Ascii.NUL characters.
7861 NUL characters if they appear act as argument separators, so for example
7863 @smallexample @c ada
7864 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7868 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7869 linker. The order of linker options is preserved for a given unit. The final
7870 list of options passed to the linker is in reverse order of the elaboration
7871 order. For example, linker options fo a body always appear before the options
7872 from the corresponding package spec.
7877 @strong{78}. The contents of the visible part of package
7878 @code{Interfaces} and its language-defined descendants. See B.2(1).
7881 See files with prefix @file{i-} in the distributed library.
7886 @strong{79}. Implementation-defined children of package
7887 @code{Interfaces}. The contents of the visible part of package
7888 @code{Interfaces}. See B.2(11).
7891 See files with prefix @file{i-} in the distributed library.
7896 @strong{80}. The types @code{Floating}, @code{Long_Floating},
7897 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7898 @code{COBOL_Character}; and the initialization of the variables
7899 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7900 @code{Interfaces.COBOL}. See B.4(50).
7907 (Floating) Long_Float
7912 @item Decimal_Element
7914 @item COBOL_Character
7919 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7924 @strong{81}. Support for access to machine instructions. See C.1(1).
7927 See documentation in file @file{s-maccod.ads} in the distributed library.
7932 @strong{82}. Implementation-defined aspects of access to machine
7933 operations. See C.1(9).
7936 See documentation in file @file{s-maccod.ads} in the distributed library.
7941 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
7944 Interrupts are mapped to signals or conditions as appropriate. See
7946 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7947 on the interrupts supported on a particular target.
7952 @strong{84}. Implementation-defined aspects of pre-elaboration. See
7956 GNAT does not permit a partition to be restarted without reloading,
7957 except under control of the debugger.
7962 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
7965 Pragma @code{Discard_Names} causes names of enumeration literals to
7966 be suppressed. In the presence of this pragma, the Image attribute
7967 provides the image of the Pos of the literal, and Value accepts
7973 @strong{86}. The result of the @code{Task_Identification.Image}
7974 attribute. See C.7.1(7).
7977 The result of this attribute is an 8-digit hexadecimal string
7978 representing the virtual address of the task control block.
7983 @strong{87}. The value of @code{Current_Task} when in a protected entry
7984 or interrupt handler. See C.7.1(17).
7987 Protected entries or interrupt handlers can be executed by any
7988 convenient thread, so the value of @code{Current_Task} is undefined.
7993 @strong{88}. The effect of calling @code{Current_Task} from an entry
7994 body or interrupt handler. See C.7.1(19).
7997 The effect of calling @code{Current_Task} from an entry body or
7998 interrupt handler is to return the identification of the task currently
8004 @strong{89}. Implementation-defined aspects of
8005 @code{Task_Attributes}. See C.7.2(19).
8008 There are no implementation-defined aspects of @code{Task_Attributes}.
8013 @strong{90}. Values of all @code{Metrics}. See D(2).
8016 The metrics information for GNAT depends on the performance of the
8017 underlying operating system. The sources of the run-time for tasking
8018 implementation, together with the output from @code{-gnatG} can be
8019 used to determine the exact sequence of operating systems calls made
8020 to implement various tasking constructs. Together with appropriate
8021 information on the performance of the underlying operating system,
8022 on the exact target in use, this information can be used to determine
8023 the required metrics.
8028 @strong{91}. The declarations of @code{Any_Priority} and
8029 @code{Priority}. See D.1(11).
8032 See declarations in file @file{system.ads}.
8037 @strong{92}. Implementation-defined execution resources. See D.1(15).
8040 There are no implementation-defined execution resources.
8045 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
8046 access to a protected object keeps its processor busy. See D.2.1(3).
8049 On a multi-processor, a task that is waiting for access to a protected
8050 object does not keep its processor busy.
8055 @strong{94}. The affect of implementation defined execution resources
8056 on task dispatching. See D.2.1(9).
8061 Tasks map to IRIX threads, and the dispatching policy is as defined by
8062 the IRIX implementation of threads.
8064 Tasks map to threads in the threads package used by GNAT@. Where possible
8065 and appropriate, these threads correspond to native threads of the
8066 underlying operating system.
8071 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
8072 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
8075 There are no implementation-defined policy-identifiers allowed in this
8081 @strong{96}. Implementation-defined aspects of priority inversion. See
8085 Execution of a task cannot be preempted by the implementation processing
8086 of delay expirations for lower priority tasks.
8091 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
8096 Tasks map to IRIX threads, and the dispatching policy is as defined by
8097 the IRIX implementation of threads.
8099 The policy is the same as that of the underlying threads implementation.
8104 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
8105 in a pragma @code{Locking_Policy}. See D.3(4).
8108 The only implementation defined policy permitted in GNAT is
8109 @code{Inheritance_Locking}. On targets that support this policy, locking
8110 is implemented by inheritance, i.e.@: the task owning the lock operates
8111 at a priority equal to the highest priority of any task currently
8112 requesting the lock.
8117 @strong{99}. Default ceiling priorities. See D.3(10).
8120 The ceiling priority of protected objects of the type
8121 @code{System.Interrupt_Priority'Last} as described in the Ada 95
8122 Reference Manual D.3(10),
8127 @strong{100}. The ceiling of any protected object used internally by
8128 the implementation. See D.3(16).
8131 The ceiling priority of internal protected objects is
8132 @code{System.Priority'Last}.
8137 @strong{101}. Implementation-defined queuing policies. See D.4(1).
8140 There are no implementation-defined queueing policies.
8145 @strong{102}. On a multiprocessor, any conditions that cause the
8146 completion of an aborted construct to be delayed later than what is
8147 specified for a single processor. See D.6(3).
8150 The semantics for abort on a multi-processor is the same as on a single
8151 processor, there are no further delays.
8156 @strong{103}. Any operations that implicitly require heap storage
8157 allocation. See D.7(8).
8160 The only operation that implicitly requires heap storage allocation is
8166 @strong{104}. Implementation-defined aspects of pragma
8167 @code{Restrictions}. See D.7(20).
8170 There are no such implementation-defined aspects.
8175 @strong{105}. Implementation-defined aspects of package
8176 @code{Real_Time}. See D.8(17).
8179 There are no implementation defined aspects of package @code{Real_Time}.
8184 @strong{106}. Implementation-defined aspects of
8185 @code{delay_statements}. See D.9(8).
8188 Any difference greater than one microsecond will cause the task to be
8189 delayed (see D.9(7)).
8194 @strong{107}. The upper bound on the duration of interrupt blocking
8195 caused by the implementation. See D.12(5).
8198 The upper bound is determined by the underlying operating system. In
8199 no cases is it more than 10 milliseconds.
8204 @strong{108}. The means for creating and executing distributed
8208 The GLADE package provides a utility GNATDIST for creating and executing
8209 distributed programs. See the GLADE reference manual for further details.
8214 @strong{109}. Any events that can result in a partition becoming
8215 inaccessible. See E.1(7).
8218 See the GLADE reference manual for full details on such events.
8223 @strong{110}. The scheduling policies, treatment of priorities, and
8224 management of shared resources between partitions in certain cases. See
8228 See the GLADE reference manual for full details on these aspects of
8229 multi-partition execution.
8234 @strong{111}. Events that cause the version of a compilation unit to
8238 Editing the source file of a compilation unit, or the source files of
8239 any units on which it is dependent in a significant way cause the version
8240 to change. No other actions cause the version number to change. All changes
8241 are significant except those which affect only layout, capitalization or
8247 @strong{112}. Whether the execution of the remote subprogram is
8248 immediately aborted as a result of cancellation. See E.4(13).
8251 See the GLADE reference manual for details on the effect of abort in
8252 a distributed application.
8257 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
8260 See the GLADE reference manual for a full description of all implementation
8261 defined aspects of the PCS@.
8266 @strong{114}. Implementation-defined interfaces in the PCS@. See
8270 See the GLADE reference manual for a full description of all
8271 implementation defined interfaces.
8276 @strong{115}. The values of named numbers in the package
8277 @code{Decimal}. See F.2(7).
8289 @item Max_Decimal_Digits
8296 @strong{116}. The value of @code{Max_Picture_Length} in the package
8297 @code{Text_IO.Editing}. See F.3.3(16).
8305 @strong{117}. The value of @code{Max_Picture_Length} in the package
8306 @code{Wide_Text_IO.Editing}. See F.3.4(5).
8314 @strong{118}. The accuracy actually achieved by the complex elementary
8315 functions and by other complex arithmetic operations. See G.1(1).
8318 Standard library functions are used for the complex arithmetic
8319 operations. Only fast math mode is currently supported.
8324 @strong{119}. The sign of a zero result (or a component thereof) from
8325 any operator or function in @code{Numerics.Generic_Complex_Types}, when
8326 @code{Real'Signed_Zeros} is True. See G.1.1(53).
8329 The signs of zero values are as recommended by the relevant
8330 implementation advice.
8335 @strong{120}. The sign of a zero result (or a component thereof) from
8336 any operator or function in
8337 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8338 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
8341 The signs of zero values are as recommended by the relevant
8342 implementation advice.
8347 @strong{121}. Whether the strict mode or the relaxed mode is the
8348 default. See G.2(2).
8351 The strict mode is the default. There is no separate relaxed mode. GNAT
8352 provides a highly efficient implementation of strict mode.
8357 @strong{122}. The result interval in certain cases of fixed-to-float
8358 conversion. See G.2.1(10).
8361 For cases where the result interval is implementation dependent, the
8362 accuracy is that provided by performing all operations in 64-bit IEEE
8363 floating-point format.
8368 @strong{123}. The result of a floating point arithmetic operation in
8369 overflow situations, when the @code{Machine_Overflows} attribute of the
8370 result type is @code{False}. See G.2.1(13).
8373 Infinite and NaN values are produced as dictated by the IEEE
8374 floating-point standard.
8376 Note that on machines that are not fully compliant with the IEEE
8377 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
8378 must be used for achieving IEEE confirming behavior (although at the cost
8379 of a significant performance penalty), so infinite and NaN values are
8385 @strong{124}. The result interval for division (or exponentiation by a
8386 negative exponent), when the floating point hardware implements division
8387 as multiplication by a reciprocal. See G.2.1(16).
8390 Not relevant, division is IEEE exact.
8395 @strong{125}. The definition of close result set, which determines the
8396 accuracy of certain fixed point multiplications and divisions. See
8400 Operations in the close result set are performed using IEEE long format
8401 floating-point arithmetic. The input operands are converted to
8402 floating-point, the operation is done in floating-point, and the result
8403 is converted to the target type.
8408 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
8409 point multiplication or division for which the result shall be in the
8410 perfect result set. See G.2.3(22).
8413 The result is only defined to be in the perfect result set if the result
8414 can be computed by a single scaling operation involving a scale factor
8415 representable in 64-bits.
8420 @strong{127}. The result of a fixed point arithmetic operation in
8421 overflow situations, when the @code{Machine_Overflows} attribute of the
8422 result type is @code{False}. See G.2.3(27).
8425 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8431 @strong{128}. The result of an elementary function reference in
8432 overflow situations, when the @code{Machine_Overflows} attribute of the
8433 result type is @code{False}. See G.2.4(4).
8436 IEEE infinite and Nan values are produced as appropriate.
8441 @strong{129}. The value of the angle threshold, within which certain
8442 elementary functions, complex arithmetic operations, and complex
8443 elementary functions yield results conforming to a maximum relative
8444 error bound. See G.2.4(10).
8447 Information on this subject is not yet available.
8452 @strong{130}. The accuracy of certain elementary functions for
8453 parameters beyond the angle threshold. See G.2.4(10).
8456 Information on this subject is not yet available.
8461 @strong{131}. The result of a complex arithmetic operation or complex
8462 elementary function reference in overflow situations, when the
8463 @code{Machine_Overflows} attribute of the corresponding real type is
8464 @code{False}. See G.2.6(5).
8467 IEEE infinite and Nan values are produced as appropriate.
8472 @strong{132}. The accuracy of certain complex arithmetic operations and
8473 certain complex elementary functions for parameters (or components
8474 thereof) beyond the angle threshold. See G.2.6(8).
8477 Information on those subjects is not yet available.
8482 @strong{133}. Information regarding bounded errors and erroneous
8483 execution. See H.2(1).
8486 Information on this subject is not yet available.
8491 @strong{134}. Implementation-defined aspects of pragma
8492 @code{Inspection_Point}. See H.3.2(8).
8495 Pragma @code{Inspection_Point} ensures that the variable is live and can
8496 be examined by the debugger at the inspection point.
8501 @strong{135}. Implementation-defined aspects of pragma
8502 @code{Restrictions}. See H.4(25).
8505 There are no implementation-defined aspects of pragma @code{Restrictions}. The
8506 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8507 generated code. Checks must suppressed by use of pragma @code{Suppress}.
8512 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
8516 There are no restrictions on pragma @code{Restrictions}.
8518 @node Intrinsic Subprograms
8519 @chapter Intrinsic Subprograms
8520 @cindex Intrinsic Subprograms
8523 * Intrinsic Operators::
8524 * Enclosing_Entity::
8525 * Exception_Information::
8526 * Exception_Message::
8534 * Shift_Right_Arithmetic::
8539 GNAT allows a user application program to write the declaration:
8541 @smallexample @c ada
8542 pragma Import (Intrinsic, name);
8546 providing that the name corresponds to one of the implemented intrinsic
8547 subprograms in GNAT, and that the parameter profile of the referenced
8548 subprogram meets the requirements. This chapter describes the set of
8549 implemented intrinsic subprograms, and the requirements on parameter profiles.
8550 Note that no body is supplied; as with other uses of pragma Import, the
8551 body is supplied elsewhere (in this case by the compiler itself). Note
8552 that any use of this feature is potentially non-portable, since the
8553 Ada standard does not require Ada compilers to implement this feature.
8555 @node Intrinsic Operators
8556 @section Intrinsic Operators
8557 @cindex Intrinsic operator
8560 All the predefined numeric operators in package Standard
8561 in @code{pragma Import (Intrinsic,..)}
8562 declarations. In the binary operator case, the operands must have the same
8563 size. The operand or operands must also be appropriate for
8564 the operator. For example, for addition, the operands must
8565 both be floating-point or both be fixed-point, and the
8566 right operand for @code{"**"} must have a root type of
8567 @code{Standard.Integer'Base}.
8568 You can use an intrinsic operator declaration as in the following example:
8570 @smallexample @c ada
8571 type Int1 is new Integer;
8572 type Int2 is new Integer;
8574 function "+" (X1 : Int1; X2 : Int2) return Int1;
8575 function "+" (X1 : Int1; X2 : Int2) return Int2;
8576 pragma Import (Intrinsic, "+");
8580 This declaration would permit ``mixed mode'' arithmetic on items
8581 of the differing types @code{Int1} and @code{Int2}.
8582 It is also possible to specify such operators for private types, if the
8583 full views are appropriate arithmetic types.
8585 @node Enclosing_Entity
8586 @section Enclosing_Entity
8587 @cindex Enclosing_Entity
8589 This intrinsic subprogram is used in the implementation of the
8590 library routine @code{GNAT.Source_Info}. The only useful use of the
8591 intrinsic import in this case is the one in this unit, so an
8592 application program should simply call the function
8593 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8594 the current subprogram, package, task, entry, or protected subprogram.
8596 @node Exception_Information
8597 @section Exception_Information
8598 @cindex Exception_Information'
8600 This intrinsic subprogram is used in the implementation of the
8601 library routine @code{GNAT.Current_Exception}. The only useful
8602 use of the intrinsic import in this case is the one in this unit,
8603 so an application program should simply call the function
8604 @code{GNAT.Current_Exception.Exception_Information} to obtain
8605 the exception information associated with the current exception.
8607 @node Exception_Message
8608 @section Exception_Message
8609 @cindex Exception_Message
8611 This intrinsic subprogram is used in the implementation of the
8612 library routine @code{GNAT.Current_Exception}. The only useful
8613 use of the intrinsic import in this case is the one in this unit,
8614 so an application program should simply call the function
8615 @code{GNAT.Current_Exception.Exception_Message} to obtain
8616 the message associated with the current exception.
8618 @node Exception_Name
8619 @section Exception_Name
8620 @cindex Exception_Name
8622 This intrinsic subprogram is used in the implementation of the
8623 library routine @code{GNAT.Current_Exception}. The only useful
8624 use of the intrinsic import in this case is the one in this unit,
8625 so an application program should simply call the function
8626 @code{GNAT.Current_Exception.Exception_Name} to obtain
8627 the name of the current exception.
8633 This intrinsic subprogram is used in the implementation of the
8634 library routine @code{GNAT.Source_Info}. The only useful use of the
8635 intrinsic import in this case is the one in this unit, so an
8636 application program should simply call the function
8637 @code{GNAT.Source_Info.File} to obtain the name of the current
8644 This intrinsic subprogram is used in the implementation of the
8645 library routine @code{GNAT.Source_Info}. The only useful use of the
8646 intrinsic import in this case is the one in this unit, so an
8647 application program should simply call the function
8648 @code{GNAT.Source_Info.Line} to obtain the number of the current
8652 @section Rotate_Left
8655 In standard Ada 95, the @code{Rotate_Left} function is available only
8656 for the predefined modular types in package @code{Interfaces}. However, in
8657 GNAT it is possible to define a Rotate_Left function for a user
8658 defined modular type or any signed integer type as in this example:
8660 @smallexample @c ada
8662 (Value : My_Modular_Type;
8664 return My_Modular_Type;
8668 The requirements are that the profile be exactly as in the example
8669 above. The only modifications allowed are in the formal parameter
8670 names, and in the type of @code{Value} and the return type, which
8671 must be the same, and must be either a signed integer type, or
8672 a modular integer type with a binary modulus, and the size must
8673 be 8. 16, 32 or 64 bits.
8676 @section Rotate_Right
8677 @cindex Rotate_Right
8679 A @code{Rotate_Right} function can be defined for any user defined
8680 binary modular integer type, or signed integer type, as described
8681 above for @code{Rotate_Left}.
8687 A @code{Shift_Left} function can be defined for any user defined
8688 binary modular integer type, or signed integer type, as described
8689 above for @code{Rotate_Left}.
8692 @section Shift_Right
8695 A @code{Shift_Right} function can be defined for any user defined
8696 binary modular integer type, or signed integer type, as described
8697 above for @code{Rotate_Left}.
8699 @node Shift_Right_Arithmetic
8700 @section Shift_Right_Arithmetic
8701 @cindex Shift_Right_Arithmetic
8703 A @code{Shift_Right_Arithmetic} function can be defined for any user
8704 defined binary modular integer type, or signed integer type, as described
8705 above for @code{Rotate_Left}.
8707 @node Source_Location
8708 @section Source_Location
8709 @cindex Source_Location
8711 This intrinsic subprogram is used in the implementation of the
8712 library routine @code{GNAT.Source_Info}. The only useful use of the
8713 intrinsic import in this case is the one in this unit, so an
8714 application program should simply call the function
8715 @code{GNAT.Source_Info.Source_Location} to obtain the current
8716 source file location.
8718 @node Representation Clauses and Pragmas
8719 @chapter Representation Clauses and Pragmas
8720 @cindex Representation Clauses
8723 * Alignment Clauses::
8725 * Storage_Size Clauses::
8726 * Size of Variant Record Objects::
8727 * Biased Representation ::
8728 * Value_Size and Object_Size Clauses::
8729 * Component_Size Clauses::
8730 * Bit_Order Clauses::
8731 * Effect of Bit_Order on Byte Ordering::
8732 * Pragma Pack for Arrays::
8733 * Pragma Pack for Records::
8734 * Record Representation Clauses::
8735 * Enumeration Clauses::
8737 * Effect of Convention on Representation::
8738 * Determining the Representations chosen by GNAT::
8742 @cindex Representation Clause
8743 @cindex Representation Pragma
8744 @cindex Pragma, representation
8745 This section describes the representation clauses accepted by GNAT, and
8746 their effect on the representation of corresponding data objects.
8748 GNAT fully implements Annex C (Systems Programming). This means that all
8749 the implementation advice sections in chapter 13 are fully implemented.
8750 However, these sections only require a minimal level of support for
8751 representation clauses. GNAT provides much more extensive capabilities,
8752 and this section describes the additional capabilities provided.
8754 @node Alignment Clauses
8755 @section Alignment Clauses
8756 @cindex Alignment Clause
8759 GNAT requires that all alignment clauses specify a power of 2, and all
8760 default alignments are always a power of 2. The default alignment
8761 values are as follows:
8764 @item @emph{Primitive Types}.
8765 For primitive types, the alignment is the minimum of the actual size of
8766 objects of the type divided by @code{Storage_Unit},
8767 and the maximum alignment supported by the target.
8768 (This maximum alignment is given by the GNAT-specific attribute
8769 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8770 @cindex @code{Maximum_Alignment} attribute
8771 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8772 default alignment will be 8 on any target that supports alignments
8773 this large, but on some targets, the maximum alignment may be smaller
8774 than 8, in which case objects of type @code{Long_Float} will be maximally
8777 @item @emph{Arrays}.
8778 For arrays, the alignment is equal to the alignment of the component type
8779 for the normal case where no packing or component size is given. If the
8780 array is packed, and the packing is effective (see separate section on
8781 packed arrays), then the alignment will be one for long packed arrays,
8782 or arrays whose length is not known at compile time. For short packed
8783 arrays, which are handled internally as modular types, the alignment
8784 will be as described for primitive types, e.g.@: a packed array of length
8785 31 bits will have an object size of four bytes, and an alignment of 4.
8787 @item @emph{Records}.
8788 For the normal non-packed case, the alignment of a record is equal to
8789 the maximum alignment of any of its components. For tagged records, this
8790 includes the implicit access type used for the tag. If a pragma @code{Pack} is
8791 used and all fields are packable (see separate section on pragma @code{Pack}),
8792 then the resulting alignment is 1.
8794 A special case is when:
8797 the size of the record is given explicitly, or a
8798 full record representation clause is given, and
8800 the size of the record is 2, 4, or 8 bytes.
8803 In this case, an alignment is chosen to match the
8804 size of the record. For example, if we have:
8806 @smallexample @c ada
8807 type Small is record
8810 for Small'Size use 16;
8814 then the default alignment of the record type @code{Small} is 2, not 1. This
8815 leads to more efficient code when the record is treated as a unit, and also
8816 allows the type to specified as @code{Atomic} on architectures requiring
8822 An alignment clause may
8823 always specify a larger alignment than the default value, up to some
8824 maximum value dependent on the target (obtainable by using the
8825 attribute reference @code{Standard'Maximum_Alignment}).
8827 it is permissible to specify a smaller alignment than the default value
8828 is for a record with a record representation clause.
8829 In this case, packable fields for which a component clause is
8830 given still result in a default alignment corresponding to the original
8831 type, but this may be overridden, since these components in fact only
8832 require an alignment of one byte. For example, given
8834 @smallexample @c ada
8840 A at 0 range 0 .. 31;
8843 for V'alignment use 1;
8847 @cindex Alignment, default
8848 The default alignment for the type @code{V} is 4, as a result of the
8849 Integer field in the record, but since this field is placed with a
8850 component clause, it is permissible, as shown, to override the default
8851 alignment of the record with a smaller value.
8854 @section Size Clauses
8858 The default size for a type @code{T} is obtainable through the
8859 language-defined attribute @code{T'Size} and also through the
8860 equivalent GNAT-defined attribute @code{T'Value_Size}.
8861 For objects of type @code{T}, GNAT will generally increase the type size
8862 so that the object size (obtainable through the GNAT-defined attribute
8863 @code{T'Object_Size})
8864 is a multiple of @code{T'Alignment * Storage_Unit}.
8867 @smallexample @c ada
8868 type Smallint is range 1 .. 6;
8877 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8878 as specified by the RM rules,
8879 but objects of this type will have a size of 8
8880 (@code{Smallint'Object_Size} = 8),
8881 since objects by default occupy an integral number
8882 of storage units. On some targets, notably older
8883 versions of the Digital Alpha, the size of stand
8884 alone objects of this type may be 32, reflecting
8885 the inability of the hardware to do byte load/stores.
8887 Similarly, the size of type @code{Rec} is 40 bits
8888 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8889 the alignment is 4, so objects of this type will have
8890 their size increased to 64 bits so that it is a multiple
8891 of the alignment (in bits). This decision is
8892 in accordance with the specific Implementation Advice in RM 13.3(43):
8895 A @code{Size} clause should be supported for an object if the specified
8896 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8897 to a size in storage elements that is a multiple of the object's
8898 @code{Alignment} (if the @code{Alignment} is nonzero).
8902 An explicit size clause may be used to override the default size by
8903 increasing it. For example, if we have:
8905 @smallexample @c ada
8906 type My_Boolean is new Boolean;
8907 for My_Boolean'Size use 32;
8911 then values of this type will always be 32 bits long. In the case of
8912 discrete types, the size can be increased up to 64 bits, with the effect
8913 that the entire specified field is used to hold the value, sign- or
8914 zero-extended as appropriate. If more than 64 bits is specified, then
8915 padding space is allocated after the value, and a warning is issued that
8916 there are unused bits.
8918 Similarly the size of records and arrays may be increased, and the effect
8919 is to add padding bits after the value. This also causes a warning message
8922 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
8923 Size in bits, this corresponds to an object of size 256 megabytes (minus
8924 one). This limitation is true on all targets. The reason for this
8925 limitation is that it improves the quality of the code in many cases
8926 if it is known that a Size value can be accommodated in an object of
8929 @node Storage_Size Clauses
8930 @section Storage_Size Clauses
8931 @cindex Storage_Size Clause
8934 For tasks, the @code{Storage_Size} clause specifies the amount of space
8935 to be allocated for the task stack. This cannot be extended, and if the
8936 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8937 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
8938 or a @code{Storage_Size} pragma in the task definition to set the
8939 appropriate required size. A useful technique is to include in every
8940 task definition a pragma of the form:
8942 @smallexample @c ada
8943 pragma Storage_Size (Default_Stack_Size);
8947 Then @code{Default_Stack_Size} can be defined in a global package, and
8948 modified as required. Any tasks requiring stack sizes different from the
8949 default can have an appropriate alternative reference in the pragma.
8951 For access types, the @code{Storage_Size} clause specifies the maximum
8952 space available for allocation of objects of the type. If this space is
8953 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8954 In the case where the access type is declared local to a subprogram, the
8955 use of a @code{Storage_Size} clause triggers automatic use of a special
8956 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8957 space for the pool is automatically reclaimed on exit from the scope in
8958 which the type is declared.
8960 A special case recognized by the compiler is the specification of a
8961 @code{Storage_Size} of zero for an access type. This means that no
8962 items can be allocated from the pool, and this is recognized at compile
8963 time, and all the overhead normally associated with maintaining a fixed
8964 size storage pool is eliminated. Consider the following example:
8966 @smallexample @c ada
8968 type R is array (Natural) of Character;
8969 type P is access all R;
8970 for P'Storage_Size use 0;
8971 -- Above access type intended only for interfacing purposes
8975 procedure g (m : P);
8976 pragma Import (C, g);
8987 As indicated in this example, these dummy storage pools are often useful in
8988 connection with interfacing where no object will ever be allocated. If you
8989 compile the above example, you get the warning:
8992 p.adb:16:09: warning: allocation from empty storage pool
8993 p.adb:16:09: warning: Storage_Error will be raised at run time
8997 Of course in practice, there will not be any explicit allocators in the
8998 case of such an access declaration.
9000 @node Size of Variant Record Objects
9001 @section Size of Variant Record Objects
9002 @cindex Size, variant record objects
9003 @cindex Variant record objects, size
9006 In the case of variant record objects, there is a question whether Size gives
9007 information about a particular variant, or the maximum size required
9008 for any variant. Consider the following program
9010 @smallexample @c ada
9011 with Text_IO; use Text_IO;
9013 type R1 (A : Boolean := False) is record
9015 when True => X : Character;
9024 Put_Line (Integer'Image (V1'Size));
9025 Put_Line (Integer'Image (V2'Size));
9030 Here we are dealing with a variant record, where the True variant
9031 requires 16 bits, and the False variant requires 8 bits.
9032 In the above example, both V1 and V2 contain the False variant,
9033 which is only 8 bits long. However, the result of running the
9042 The reason for the difference here is that the discriminant value of
9043 V1 is fixed, and will always be False. It is not possible to assign
9044 a True variant value to V1, therefore 8 bits is sufficient. On the
9045 other hand, in the case of V2, the initial discriminant value is
9046 False (from the default), but it is possible to assign a True
9047 variant value to V2, therefore 16 bits must be allocated for V2
9048 in the general case, even fewer bits may be needed at any particular
9049 point during the program execution.
9051 As can be seen from the output of this program, the @code{'Size}
9052 attribute applied to such an object in GNAT gives the actual allocated
9053 size of the variable, which is the largest size of any of the variants.
9054 The Ada Reference Manual is not completely clear on what choice should
9055 be made here, but the GNAT behavior seems most consistent with the
9056 language in the RM@.
9058 In some cases, it may be desirable to obtain the size of the current
9059 variant, rather than the size of the largest variant. This can be
9060 achieved in GNAT by making use of the fact that in the case of a
9061 subprogram parameter, GNAT does indeed return the size of the current
9062 variant (because a subprogram has no way of knowing how much space
9063 is actually allocated for the actual).
9065 Consider the following modified version of the above program:
9067 @smallexample @c ada
9068 with Text_IO; use Text_IO;
9070 type R1 (A : Boolean := False) is record
9072 when True => X : Character;
9079 function Size (V : R1) return Integer is
9085 Put_Line (Integer'Image (V2'Size));
9086 Put_Line (Integer'IMage (Size (V2)));
9088 Put_Line (Integer'Image (V2'Size));
9089 Put_Line (Integer'IMage (Size (V2)));
9094 The output from this program is
9104 Here we see that while the @code{'Size} attribute always returns
9105 the maximum size, regardless of the current variant value, the
9106 @code{Size} function does indeed return the size of the current
9109 @node Biased Representation
9110 @section Biased Representation
9111 @cindex Size for biased representation
9112 @cindex Biased representation
9115 In the case of scalars with a range starting at other than zero, it is
9116 possible in some cases to specify a size smaller than the default minimum
9117 value, and in such cases, GNAT uses an unsigned biased representation,
9118 in which zero is used to represent the lower bound, and successive values
9119 represent successive values of the type.
9121 For example, suppose we have the declaration:
9123 @smallexample @c ada
9124 type Small is range -7 .. -4;
9125 for Small'Size use 2;
9129 Although the default size of type @code{Small} is 4, the @code{Size}
9130 clause is accepted by GNAT and results in the following representation
9134 -7 is represented as 2#00#
9135 -6 is represented as 2#01#
9136 -5 is represented as 2#10#
9137 -4 is represented as 2#11#
9141 Biased representation is only used if the specified @code{Size} clause
9142 cannot be accepted in any other manner. These reduced sizes that force
9143 biased representation can be used for all discrete types except for
9144 enumeration types for which a representation clause is given.
9146 @node Value_Size and Object_Size Clauses
9147 @section Value_Size and Object_Size Clauses
9150 @cindex Size, of objects
9153 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
9154 required to hold values of type @code{T}. Although this interpretation was
9155 allowed in Ada 83, it was not required, and this requirement in practice
9156 can cause some significant difficulties. For example, in most Ada 83
9157 compilers, @code{Natural'Size} was 32. However, in Ada 95,
9158 @code{Natural'Size} is
9159 typically 31. This means that code may change in behavior when moving
9160 from Ada 83 to Ada 95. For example, consider:
9162 @smallexample @c ada
9169 at 0 range 0 .. Natural'Size - 1;
9170 at 0 range Natural'Size .. 2 * Natural'Size - 1;
9175 In the above code, since the typical size of @code{Natural} objects
9176 is 32 bits and @code{Natural'Size} is 31, the above code can cause
9177 unexpected inefficient packing in Ada 95, and in general there are
9178 cases where the fact that the object size can exceed the
9179 size of the type causes surprises.
9181 To help get around this problem GNAT provides two implementation
9182 defined attributes, @code{Value_Size} and @code{Object_Size}. When
9183 applied to a type, these attributes yield the size of the type
9184 (corresponding to the RM defined size attribute), and the size of
9185 objects of the type respectively.
9187 The @code{Object_Size} is used for determining the default size of
9188 objects and components. This size value can be referred to using the
9189 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
9190 the basis of the determination of the size. The backend is free to
9191 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
9192 character might be stored in 32 bits on a machine with no efficient
9193 byte access instructions such as the Alpha.
9195 The default rules for the value of @code{Object_Size} for
9196 discrete types are as follows:
9200 The @code{Object_Size} for base subtypes reflect the natural hardware
9201 size in bits (run the compiler with @option{-gnatS} to find those values
9202 for numeric types). Enumeration types and fixed-point base subtypes have
9203 8, 16, 32 or 64 bits for this size, depending on the range of values
9207 The @code{Object_Size} of a subtype is the same as the
9208 @code{Object_Size} of
9209 the type from which it is obtained.
9212 The @code{Object_Size} of a derived base type is copied from the parent
9213 base type, and the @code{Object_Size} of a derived first subtype is copied
9214 from the parent first subtype.
9218 The @code{Value_Size} attribute
9219 is the (minimum) number of bits required to store a value
9221 This value is used to determine how tightly to pack
9222 records or arrays with components of this type, and also affects
9223 the semantics of unchecked conversion (unchecked conversions where
9224 the @code{Value_Size} values differ generate a warning, and are potentially
9227 The default rules for the value of @code{Value_Size} are as follows:
9231 The @code{Value_Size} for a base subtype is the minimum number of bits
9232 required to store all values of the type (including the sign bit
9233 only if negative values are possible).
9236 If a subtype statically matches the first subtype of a given type, then it has
9237 by default the same @code{Value_Size} as the first subtype. This is a
9238 consequence of RM 13.1(14) (``if two subtypes statically match,
9239 then their subtype-specific aspects are the same''.)
9242 All other subtypes have a @code{Value_Size} corresponding to the minimum
9243 number of bits required to store all values of the subtype. For
9244 dynamic bounds, it is assumed that the value can range down or up
9245 to the corresponding bound of the ancestor
9249 The RM defined attribute @code{Size} corresponds to the
9250 @code{Value_Size} attribute.
9252 The @code{Size} attribute may be defined for a first-named subtype. This sets
9253 the @code{Value_Size} of
9254 the first-named subtype to the given value, and the
9255 @code{Object_Size} of this first-named subtype to the given value padded up
9256 to an appropriate boundary. It is a consequence of the default rules
9257 above that this @code{Object_Size} will apply to all further subtypes. On the
9258 other hand, @code{Value_Size} is affected only for the first subtype, any
9259 dynamic subtypes obtained from it directly, and any statically matching
9260 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
9262 @code{Value_Size} and
9263 @code{Object_Size} may be explicitly set for any subtype using
9264 an attribute definition clause. Note that the use of these attributes
9265 can cause the RM 13.1(14) rule to be violated. If two access types
9266 reference aliased objects whose subtypes have differing @code{Object_Size}
9267 values as a result of explicit attribute definition clauses, then it
9268 is erroneous to convert from one access subtype to the other.
9270 At the implementation level, Esize stores the Object_Size and the
9271 RM_Size field stores the @code{Value_Size} (and hence the value of the
9272 @code{Size} attribute,
9273 which, as noted above, is equivalent to @code{Value_Size}).
9275 To get a feel for the difference, consider the following examples (note
9276 that in each case the base is @code{Short_Short_Integer} with a size of 8):
9279 Object_Size Value_Size
9281 type x1 is range 0 .. 5; 8 3
9283 type x2 is range 0 .. 5;
9284 for x2'size use 12; 16 12
9286 subtype x3 is x2 range 0 .. 3; 16 2
9288 subtype x4 is x2'base range 0 .. 10; 8 4
9290 subtype x5 is x2 range 0 .. dynamic; 16 3*
9292 subtype x6 is x2'base range 0 .. dynamic; 8 3*
9297 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
9298 but it seems in the spirit of the RM rules to allocate the minimum number
9299 of bits (here 3, given the range for @code{x2})
9300 known to be large enough to hold the given range of values.
9302 So far, so good, but GNAT has to obey the RM rules, so the question is
9303 under what conditions must the RM @code{Size} be used.
9304 The following is a list
9305 of the occasions on which the RM @code{Size} must be used:
9309 Component size for packed arrays or records
9312 Value of the attribute @code{Size} for a type
9315 Warning about sizes not matching for unchecked conversion
9319 For record types, the @code{Object_Size} is always a multiple of the
9320 alignment of the type (this is true for all types). In some cases the
9321 @code{Value_Size} can be smaller. Consider:
9331 On a typical 32-bit architecture, the X component will be four bytes, and
9332 require four-byte alignment, and the Y component will be one byte. In this
9333 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
9334 required to store a value of this type, and for example, it is permissible
9335 to have a component of type R in an outer record whose component size is
9336 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9337 since it must be rounded up so that this value is a multiple of the
9338 alignment (4 bytes = 32 bits).
9341 For all other types, the @code{Object_Size}
9342 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9343 Only @code{Size} may be specified for such types.
9345 @node Component_Size Clauses
9346 @section Component_Size Clauses
9347 @cindex Component_Size Clause
9350 Normally, the value specified in a component size clause must be consistent
9351 with the subtype of the array component with regard to size and alignment.
9352 In other words, the value specified must be at least equal to the size
9353 of this subtype, and must be a multiple of the alignment value.
9355 In addition, component size clauses are allowed which cause the array
9356 to be packed, by specifying a smaller value. The cases in which this
9357 is allowed are for component size values in the range 1 through 63. The value
9358 specified must not be smaller than the Size of the subtype. GNAT will
9359 accurately honor all packing requests in this range. For example, if
9362 @smallexample @c ada
9363 type r is array (1 .. 8) of Natural;
9364 for r'Component_Size use 31;
9368 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9369 Of course access to the components of such an array is considerably
9370 less efficient than if the natural component size of 32 is used.
9372 Note that there is no point in giving both a component size clause
9373 and a pragma Pack for the same array type. if such duplicate
9374 clauses are given, the pragma Pack will be ignored.
9376 @node Bit_Order Clauses
9377 @section Bit_Order Clauses
9378 @cindex Bit_Order Clause
9379 @cindex bit ordering
9380 @cindex ordering, of bits
9383 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9384 attribute. The specification may either correspond to the default bit
9385 order for the target, in which case the specification has no effect and
9386 places no additional restrictions, or it may be for the non-standard
9387 setting (that is the opposite of the default).
9389 In the case where the non-standard value is specified, the effect is
9390 to renumber bits within each byte, but the ordering of bytes is not
9391 affected. There are certain
9392 restrictions placed on component clauses as follows:
9396 @item Components fitting within a single storage unit.
9398 These are unrestricted, and the effect is merely to renumber bits. For
9399 example if we are on a little-endian machine with @code{Low_Order_First}
9400 being the default, then the following two declarations have exactly
9403 @smallexample @c ada
9406 B : Integer range 1 .. 120;
9410 A at 0 range 0 .. 0;
9411 B at 0 range 1 .. 7;
9416 B : Integer range 1 .. 120;
9419 for R2'Bit_Order use High_Order_First;
9422 A at 0 range 7 .. 7;
9423 B at 0 range 0 .. 6;
9428 The useful application here is to write the second declaration with the
9429 @code{Bit_Order} attribute definition clause, and know that it will be treated
9430 the same, regardless of whether the target is little-endian or big-endian.
9432 @item Components occupying an integral number of bytes.
9434 These are components that exactly fit in two or more bytes. Such component
9435 declarations are allowed, but have no effect, since it is important to realize
9436 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9437 In particular, the following attempt at getting an endian-independent integer
9440 @smallexample @c ada
9445 for R2'Bit_Order use High_Order_First;
9448 A at 0 range 0 .. 31;
9453 This declaration will result in a little-endian integer on a
9454 little-endian machine, and a big-endian integer on a big-endian machine.
9455 If byte flipping is required for interoperability between big- and
9456 little-endian machines, this must be explicitly programmed. This capability
9457 is not provided by @code{Bit_Order}.
9459 @item Components that are positioned across byte boundaries
9461 but do not occupy an integral number of bytes. Given that bytes are not
9462 reordered, such fields would occupy a non-contiguous sequence of bits
9463 in memory, requiring non-trivial code to reassemble. They are for this
9464 reason not permitted, and any component clause specifying such a layout
9465 will be flagged as illegal by GNAT@.
9470 Since the misconception that Bit_Order automatically deals with all
9471 endian-related incompatibilities is a common one, the specification of
9472 a component field that is an integral number of bytes will always
9473 generate a warning. This warning may be suppressed using
9474 @code{pragma Suppress} if desired. The following section contains additional
9475 details regarding the issue of byte ordering.
9477 @node Effect of Bit_Order on Byte Ordering
9478 @section Effect of Bit_Order on Byte Ordering
9479 @cindex byte ordering
9480 @cindex ordering, of bytes
9483 In this section we will review the effect of the @code{Bit_Order} attribute
9484 definition clause on byte ordering. Briefly, it has no effect at all, but
9485 a detailed example will be helpful. Before giving this
9486 example, let us review the precise
9487 definition of the effect of defining @code{Bit_Order}. The effect of a
9488 non-standard bit order is described in section 15.5.3 of the Ada
9492 2 A bit ordering is a method of interpreting the meaning of
9493 the storage place attributes.
9497 To understand the precise definition of storage place attributes in
9498 this context, we visit section 13.5.1 of the manual:
9501 13 A record_representation_clause (without the mod_clause)
9502 specifies the layout. The storage place attributes (see 13.5.2)
9503 are taken from the values of the position, first_bit, and last_bit
9504 expressions after normalizing those values so that first_bit is
9505 less than Storage_Unit.
9509 The critical point here is that storage places are taken from
9510 the values after normalization, not before. So the @code{Bit_Order}
9511 interpretation applies to normalized values. The interpretation
9512 is described in the later part of the 15.5.3 paragraph:
9515 2 A bit ordering is a method of interpreting the meaning of
9516 the storage place attributes. High_Order_First (known in the
9517 vernacular as ``big endian'') means that the first bit of a
9518 storage element (bit 0) is the most significant bit (interpreting
9519 the sequence of bits that represent a component as an unsigned
9520 integer value). Low_Order_First (known in the vernacular as
9521 ``little endian'') means the opposite: the first bit is the
9526 Note that the numbering is with respect to the bits of a storage
9527 unit. In other words, the specification affects only the numbering
9528 of bits within a single storage unit.
9530 We can make the effect clearer by giving an example.
9532 Suppose that we have an external device which presents two bytes, the first
9533 byte presented, which is the first (low addressed byte) of the two byte
9534 record is called Master, and the second byte is called Slave.
9536 The left most (most significant bit is called Control for each byte, and
9537 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9538 (least significant) bit.
9540 On a big-endian machine, we can write the following representation clause
9542 @smallexample @c ada
9544 Master_Control : Bit;
9552 Slave_Control : Bit;
9563 Master_Control at 0 range 0 .. 0;
9564 Master_V1 at 0 range 1 .. 1;
9565 Master_V2 at 0 range 2 .. 2;
9566 Master_V3 at 0 range 3 .. 3;
9567 Master_V4 at 0 range 4 .. 4;
9568 Master_V5 at 0 range 5 .. 5;
9569 Master_V6 at 0 range 6 .. 6;
9570 Master_V7 at 0 range 7 .. 7;
9571 Slave_Control at 1 range 0 .. 0;
9572 Slave_V1 at 1 range 1 .. 1;
9573 Slave_V2 at 1 range 2 .. 2;
9574 Slave_V3 at 1 range 3 .. 3;
9575 Slave_V4 at 1 range 4 .. 4;
9576 Slave_V5 at 1 range 5 .. 5;
9577 Slave_V6 at 1 range 6 .. 6;
9578 Slave_V7 at 1 range 7 .. 7;
9583 Now if we move this to a little endian machine, then the bit ordering within
9584 the byte is backwards, so we have to rewrite the record rep clause as:
9586 @smallexample @c ada
9588 Master_Control at 0 range 7 .. 7;
9589 Master_V1 at 0 range 6 .. 6;
9590 Master_V2 at 0 range 5 .. 5;
9591 Master_V3 at 0 range 4 .. 4;
9592 Master_V4 at 0 range 3 .. 3;
9593 Master_V5 at 0 range 2 .. 2;
9594 Master_V6 at 0 range 1 .. 1;
9595 Master_V7 at 0 range 0 .. 0;
9596 Slave_Control at 1 range 7 .. 7;
9597 Slave_V1 at 1 range 6 .. 6;
9598 Slave_V2 at 1 range 5 .. 5;
9599 Slave_V3 at 1 range 4 .. 4;
9600 Slave_V4 at 1 range 3 .. 3;
9601 Slave_V5 at 1 range 2 .. 2;
9602 Slave_V6 at 1 range 1 .. 1;
9603 Slave_V7 at 1 range 0 .. 0;
9608 It is a nuisance to have to rewrite the clause, especially if
9609 the code has to be maintained on both machines. However,
9610 this is a case that we can handle with the
9611 @code{Bit_Order} attribute if it is implemented.
9612 Note that the implementation is not required on byte addressed
9613 machines, but it is indeed implemented in GNAT.
9614 This means that we can simply use the
9615 first record clause, together with the declaration
9617 @smallexample @c ada
9618 for Data'Bit_Order use High_Order_First;
9622 and the effect is what is desired, namely the layout is exactly the same,
9623 independent of whether the code is compiled on a big-endian or little-endian
9626 The important point to understand is that byte ordering is not affected.
9627 A @code{Bit_Order} attribute definition never affects which byte a field
9628 ends up in, only where it ends up in that byte.
9629 To make this clear, let us rewrite the record rep clause of the previous
9632 @smallexample @c ada
9633 for Data'Bit_Order use High_Order_First;
9635 Master_Control at 0 range 0 .. 0;
9636 Master_V1 at 0 range 1 .. 1;
9637 Master_V2 at 0 range 2 .. 2;
9638 Master_V3 at 0 range 3 .. 3;
9639 Master_V4 at 0 range 4 .. 4;
9640 Master_V5 at 0 range 5 .. 5;
9641 Master_V6 at 0 range 6 .. 6;
9642 Master_V7 at 0 range 7 .. 7;
9643 Slave_Control at 0 range 8 .. 8;
9644 Slave_V1 at 0 range 9 .. 9;
9645 Slave_V2 at 0 range 10 .. 10;
9646 Slave_V3 at 0 range 11 .. 11;
9647 Slave_V4 at 0 range 12 .. 12;
9648 Slave_V5 at 0 range 13 .. 13;
9649 Slave_V6 at 0 range 14 .. 14;
9650 Slave_V7 at 0 range 15 .. 15;
9655 This is exactly equivalent to saying (a repeat of the first example):
9657 @smallexample @c ada
9658 for Data'Bit_Order use High_Order_First;
9660 Master_Control at 0 range 0 .. 0;
9661 Master_V1 at 0 range 1 .. 1;
9662 Master_V2 at 0 range 2 .. 2;
9663 Master_V3 at 0 range 3 .. 3;
9664 Master_V4 at 0 range 4 .. 4;
9665 Master_V5 at 0 range 5 .. 5;
9666 Master_V6 at 0 range 6 .. 6;
9667 Master_V7 at 0 range 7 .. 7;
9668 Slave_Control at 1 range 0 .. 0;
9669 Slave_V1 at 1 range 1 .. 1;
9670 Slave_V2 at 1 range 2 .. 2;
9671 Slave_V3 at 1 range 3 .. 3;
9672 Slave_V4 at 1 range 4 .. 4;
9673 Slave_V5 at 1 range 5 .. 5;
9674 Slave_V6 at 1 range 6 .. 6;
9675 Slave_V7 at 1 range 7 .. 7;
9680 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9681 field. The storage place attributes are obtained by normalizing the
9682 values given so that the @code{First_Bit} value is less than 8. After
9683 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9684 we specified in the other case.
9686 Now one might expect that the @code{Bit_Order} attribute might affect
9687 bit numbering within the entire record component (two bytes in this
9688 case, thus affecting which byte fields end up in), but that is not
9689 the way this feature is defined, it only affects numbering of bits,
9690 not which byte they end up in.
9692 Consequently it never makes sense to specify a starting bit number
9693 greater than 7 (for a byte addressable field) if an attribute
9694 definition for @code{Bit_Order} has been given, and indeed it
9695 may be actively confusing to specify such a value, so the compiler
9696 generates a warning for such usage.
9698 If you do need to control byte ordering then appropriate conditional
9699 values must be used. If in our example, the slave byte came first on
9700 some machines we might write:
9702 @smallexample @c ada
9703 Master_Byte_First constant Boolean := @dots{};
9705 Master_Byte : constant Natural :=
9706 1 - Boolean'Pos (Master_Byte_First);
9707 Slave_Byte : constant Natural :=
9708 Boolean'Pos (Master_Byte_First);
9710 for Data'Bit_Order use High_Order_First;
9712 Master_Control at Master_Byte range 0 .. 0;
9713 Master_V1 at Master_Byte range 1 .. 1;
9714 Master_V2 at Master_Byte range 2 .. 2;
9715 Master_V3 at Master_Byte range 3 .. 3;
9716 Master_V4 at Master_Byte range 4 .. 4;
9717 Master_V5 at Master_Byte range 5 .. 5;
9718 Master_V6 at Master_Byte range 6 .. 6;
9719 Master_V7 at Master_Byte range 7 .. 7;
9720 Slave_Control at Slave_Byte range 0 .. 0;
9721 Slave_V1 at Slave_Byte range 1 .. 1;
9722 Slave_V2 at Slave_Byte range 2 .. 2;
9723 Slave_V3 at Slave_Byte range 3 .. 3;
9724 Slave_V4 at Slave_Byte range 4 .. 4;
9725 Slave_V5 at Slave_Byte range 5 .. 5;
9726 Slave_V6 at Slave_Byte range 6 .. 6;
9727 Slave_V7 at Slave_Byte range 7 .. 7;
9732 Now to switch between machines, all that is necessary is
9733 to set the boolean constant @code{Master_Byte_First} in
9734 an appropriate manner.
9736 @node Pragma Pack for Arrays
9737 @section Pragma Pack for Arrays
9738 @cindex Pragma Pack (for arrays)
9741 Pragma @code{Pack} applied to an array has no effect unless the component type
9742 is packable. For a component type to be packable, it must be one of the
9749 Any type whose size is specified with a size clause
9751 Any packed array type with a static size
9755 For all these cases, if the component subtype size is in the range
9756 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9757 component size were specified giving the component subtype size.
9758 For example if we have:
9760 @smallexample @c ada
9761 type r is range 0 .. 17;
9763 type ar is array (1 .. 8) of r;
9768 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9769 and the size of the array @code{ar} will be exactly 40 bits.
9771 Note that in some cases this rather fierce approach to packing can produce
9772 unexpected effects. For example, in Ada 95, type Natural typically has a
9773 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9774 close packing, which saves a few bits, but results in far less efficient
9775 access. Since many other Ada compilers will ignore such a packing request,
9776 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9777 might not be what is intended. You can easily remove this warning by
9778 using an explicit @code{Component_Size} setting instead, which never generates
9779 a warning, since the intention of the programmer is clear in this case.
9781 GNAT treats packed arrays in one of two ways. If the size of the array is
9782 known at compile time and is less than 64 bits, then internally the array
9783 is represented as a single modular type, of exactly the appropriate number
9784 of bits. If the length is greater than 63 bits, or is not known at compile
9785 time, then the packed array is represented as an array of bytes, and the
9786 length is always a multiple of 8 bits.
9788 Note that to represent a packed array as a modular type, the alignment must
9789 be suitable for the modular type involved. For example, on typical machines
9790 a 32-bit packed array will be represented by a 32-bit modular integer with
9791 an alignment of four bytes. If you explicitly override the default alignment
9792 with an alignment clause that is too small, the modular representation
9793 cannot be used. For example, consider the following set of declarations:
9795 @smallexample @c ada
9796 type R is range 1 .. 3;
9797 type S is array (1 .. 31) of R;
9798 for S'Component_Size use 2;
9800 for S'Alignment use 1;
9804 If the alignment clause were not present, then a 62-bit modular
9805 representation would be chosen (typically with an alignment of 4 or 8
9806 bytes depending on the target). But the default alignment is overridden
9807 with the explicit alignment clause. This means that the modular
9808 representation cannot be used, and instead the array of bytes
9809 representation must be used, meaning that the length must be a multiple
9810 of 8. Thus the above set of declarations will result in a diagnostic
9811 rejecting the size clause and noting that the minimum size allowed is 64.
9813 @cindex Pragma Pack (for type Natural)
9814 @cindex Pragma Pack warning
9816 One special case that is worth noting occurs when the base type of the
9817 component size is 8/16/32 and the subtype is one bit less. Notably this
9818 occurs with subtype @code{Natural}. Consider:
9820 @smallexample @c ada
9821 type Arr is array (1 .. 32) of Natural;
9826 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9827 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9828 Ada 83 compilers did not attempt 31 bit packing.
9830 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9831 does pack 31-bit subtype to 31 bits. This may result in a substantial
9832 unintended performance penalty when porting legacy Ada 83 code. To help
9833 prevent this, GNAT generates a warning in such cases. If you really want 31
9834 bit packing in a case like this, you can set the component size explicitly:
9836 @smallexample @c ada
9837 type Arr is array (1 .. 32) of Natural;
9838 for Arr'Component_Size use 31;
9842 Here 31-bit packing is achieved as required, and no warning is generated,
9843 since in this case the programmer intention is clear.
9845 @node Pragma Pack for Records
9846 @section Pragma Pack for Records
9847 @cindex Pragma Pack (for records)
9850 Pragma @code{Pack} applied to a record will pack the components to reduce
9851 wasted space from alignment gaps and by reducing the amount of space
9852 taken by components. We distinguish between @emph{packable} components and
9853 @emph{non-packable} components.
9854 Components of the following types are considered packable:
9857 All primitive types are packable.
9860 Small packed arrays, whose size does not exceed 64 bits, and where the
9861 size is statically known at compile time, are represented internally
9862 as modular integers, and so they are also packable.
9867 All packable components occupy the exact number of bits corresponding to
9868 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9869 can start on an arbitrary bit boundary.
9871 All other types are non-packable, they occupy an integral number of
9873 are placed at a boundary corresponding to their alignment requirements.
9875 For example, consider the record
9877 @smallexample @c ada
9878 type Rb1 is array (1 .. 13) of Boolean;
9881 type Rb2 is array (1 .. 65) of Boolean;
9896 The representation for the record x2 is as follows:
9898 @smallexample @c ada
9899 for x2'Size use 224;
9901 l1 at 0 range 0 .. 0;
9902 l2 at 0 range 1 .. 64;
9903 l3 at 12 range 0 .. 31;
9904 l4 at 16 range 0 .. 0;
9905 l5 at 16 range 1 .. 13;
9906 l6 at 18 range 0 .. 71;
9911 Studying this example, we see that the packable fields @code{l1}
9913 of length equal to their sizes, and placed at specific bit boundaries (and
9914 not byte boundaries) to
9915 eliminate padding. But @code{l3} is of a non-packable float type, so
9916 it is on the next appropriate alignment boundary.
9918 The next two fields are fully packable, so @code{l4} and @code{l5} are
9919 minimally packed with no gaps. However, type @code{Rb2} is a packed
9920 array that is longer than 64 bits, so it is itself non-packable. Thus
9921 the @code{l6} field is aligned to the next byte boundary, and takes an
9922 integral number of bytes, i.e.@: 72 bits.
9924 @node Record Representation Clauses
9925 @section Record Representation Clauses
9926 @cindex Record Representation Clause
9929 Record representation clauses may be given for all record types, including
9930 types obtained by record extension. Component clauses are allowed for any
9931 static component. The restrictions on component clauses depend on the type
9934 @cindex Component Clause
9935 For all components of an elementary type, the only restriction on component
9936 clauses is that the size must be at least the 'Size value of the type
9937 (actually the Value_Size). There are no restrictions due to alignment,
9938 and such components may freely cross storage boundaries.
9940 Packed arrays with a size up to and including 64 bits are represented
9941 internally using a modular type with the appropriate number of bits, and
9942 thus the same lack of restriction applies. For example, if you declare:
9944 @smallexample @c ada
9945 type R is array (1 .. 49) of Boolean;
9951 then a component clause for a component of type R may start on any
9952 specified bit boundary, and may specify a value of 49 bits or greater.
9954 For packed bit arrays that are longer than 64 bits, there are two
9955 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
9956 including the important case of single bits or boolean values, then
9957 there are no limitations on placement of such components, and they
9958 may start and end at arbitrary bit boundaries.
9960 If the component size is not a power of 2 (e.g. 3 or 5), then
9961 an array of this type longer than 64 bits must always be placed on
9962 on a storage unit (byte) boundary and occupy an integral number
9963 of storage units (bytes). Any component clause that does not
9964 meet this requirement will be rejected.
9966 Any aliased component, or component of an aliased type, must
9967 have its normal alignment and size. A component clause that
9968 does not meet this requirement will be rejected.
9970 The tag field of a tagged type always occupies an address sized field at
9971 the start of the record. No component clause may attempt to overlay this
9972 tag. When a tagged type appears as a component, the tag field must have
9975 In the case of a record extension T1, of a type T, no component clause applied
9976 to the type T1 can specify a storage location that would overlap the first
9977 T'Size bytes of the record.
9979 For all other component types, including non-bit-packed arrays,
9980 the component can be placed at an arbitrary bit boundary,
9981 so for example, the following is permitted:
9983 @smallexample @c ada
9984 type R is array (1 .. 10) of Boolean;
9993 G at 0 range 0 .. 0;
9994 H at 0 range 1 .. 1;
9995 L at 0 range 2 .. 81;
9996 R at 0 range 82 .. 161;
10001 Note: the above rules apply to recent releases of GNAT 5.
10002 In GNAT 3, there are more severe restrictions on larger components.
10003 For non-primitive types, including packed arrays with a size greater than
10004 64 bits, component clauses must respect the alignment requirement of the
10005 type, in particular, always starting on a byte boundary, and the length
10006 must be a multiple of the storage unit.
10008 @node Enumeration Clauses
10009 @section Enumeration Clauses
10011 The only restriction on enumeration clauses is that the range of values
10012 must be representable. For the signed case, if one or more of the
10013 representation values are negative, all values must be in the range:
10015 @smallexample @c ada
10016 System.Min_Int .. System.Max_Int
10020 For the unsigned case, where all values are non negative, the values must
10023 @smallexample @c ada
10024 0 .. System.Max_Binary_Modulus;
10028 A @emph{confirming} representation clause is one in which the values range
10029 from 0 in sequence, i.e.@: a clause that confirms the default representation
10030 for an enumeration type.
10031 Such a confirming representation
10032 is permitted by these rules, and is specially recognized by the compiler so
10033 that no extra overhead results from the use of such a clause.
10035 If an array has an index type which is an enumeration type to which an
10036 enumeration clause has been applied, then the array is stored in a compact
10037 manner. Consider the declarations:
10039 @smallexample @c ada
10040 type r is (A, B, C);
10041 for r use (A => 1, B => 5, C => 10);
10042 type t is array (r) of Character;
10046 The array type t corresponds to a vector with exactly three elements and
10047 has a default size equal to @code{3*Character'Size}. This ensures efficient
10048 use of space, but means that accesses to elements of the array will incur
10049 the overhead of converting representation values to the corresponding
10050 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
10052 @node Address Clauses
10053 @section Address Clauses
10054 @cindex Address Clause
10056 The reference manual allows a general restriction on representation clauses,
10057 as found in RM 13.1(22):
10060 An implementation need not support representation
10061 items containing nonstatic expressions, except that
10062 an implementation should support a representation item
10063 for a given entity if each nonstatic expression in the
10064 representation item is a name that statically denotes
10065 a constant declared before the entity.
10069 In practice this is applicable only to address clauses, since this is the
10070 only case in which a non-static expression is permitted by the syntax. As
10071 the AARM notes in sections 13.1 (22.a-22.h):
10074 22.a Reason: This is to avoid the following sort of thing:
10076 22.b X : Integer := F(@dots{});
10077 Y : Address := G(@dots{});
10078 for X'Address use Y;
10080 22.c In the above, we have to evaluate the
10081 initialization expression for X before we
10082 know where to put the result. This seems
10083 like an unreasonable implementation burden.
10085 22.d The above code should instead be written
10088 22.e Y : constant Address := G(@dots{});
10089 X : Integer := F(@dots{});
10090 for X'Address use Y;
10092 22.f This allows the expression ``Y'' to be safely
10093 evaluated before X is created.
10095 22.g The constant could be a formal parameter of mode in.
10097 22.h An implementation can support other nonstatic
10098 expressions if it wants to. Expressions of type
10099 Address are hardly ever static, but their value
10100 might be known at compile time anyway in many
10105 GNAT does indeed permit many additional cases of non-static expressions. In
10106 particular, if the type involved is elementary there are no restrictions
10107 (since in this case, holding a temporary copy of the initialization value,
10108 if one is present, is inexpensive). In addition, if there is no implicit or
10109 explicit initialization, then there are no restrictions. GNAT will reject
10110 only the case where all three of these conditions hold:
10115 The type of the item is non-elementary (e.g.@: a record or array).
10118 There is explicit or implicit initialization required for the object.
10119 Note that access values are always implicitly initialized, and also
10120 in GNAT, certain bit-packed arrays (those having a dynamic length or
10121 a length greater than 64) will also be implicitly initialized to zero.
10124 The address value is non-static. Here GNAT is more permissive than the
10125 RM, and allows the address value to be the address of a previously declared
10126 stand-alone variable, as long as it does not itself have an address clause.
10128 @smallexample @c ada
10129 Anchor : Some_Initialized_Type;
10130 Overlay : Some_Initialized_Type;
10131 for Overlay'Address use Anchor'Address;
10135 However, the prefix of the address clause cannot be an array component, or
10136 a component of a discriminated record.
10141 As noted above in section 22.h, address values are typically non-static. In
10142 particular the To_Address function, even if applied to a literal value, is
10143 a non-static function call. To avoid this minor annoyance, GNAT provides
10144 the implementation defined attribute 'To_Address. The following two
10145 expressions have identical values:
10149 @smallexample @c ada
10150 To_Address (16#1234_0000#)
10151 System'To_Address (16#1234_0000#);
10155 except that the second form is considered to be a static expression, and
10156 thus when used as an address clause value is always permitted.
10159 Additionally, GNAT treats as static an address clause that is an
10160 unchecked_conversion of a static integer value. This simplifies the porting
10161 of legacy code, and provides a portable equivalent to the GNAT attribute
10164 Another issue with address clauses is the interaction with alignment
10165 requirements. When an address clause is given for an object, the address
10166 value must be consistent with the alignment of the object (which is usually
10167 the same as the alignment of the type of the object). If an address clause
10168 is given that specifies an inappropriately aligned address value, then the
10169 program execution is erroneous.
10171 Since this source of erroneous behavior can have unfortunate effects, GNAT
10172 checks (at compile time if possible, generating a warning, or at execution
10173 time with a run-time check) that the alignment is appropriate. If the
10174 run-time check fails, then @code{Program_Error} is raised. This run-time
10175 check is suppressed if range checks are suppressed, or if
10176 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
10179 An address clause cannot be given for an exported object. More
10180 understandably the real restriction is that objects with an address
10181 clause cannot be exported. This is because such variables are not
10182 defined by the Ada program, so there is no external object to export.
10185 It is permissible to give an address clause and a pragma Import for the
10186 same object. In this case, the variable is not really defined by the
10187 Ada program, so there is no external symbol to be linked. The link name
10188 and the external name are ignored in this case. The reason that we allow this
10189 combination is that it provides a useful idiom to avoid unwanted
10190 initializations on objects with address clauses.
10192 When an address clause is given for an object that has implicit or
10193 explicit initialization, then by default initialization takes place. This
10194 means that the effect of the object declaration is to overwrite the
10195 memory at the specified address. This is almost always not what the
10196 programmer wants, so GNAT will output a warning:
10206 for Ext'Address use System'To_Address (16#1234_1234#);
10208 >>> warning: implicit initialization of "Ext" may
10209 modify overlaid storage
10210 >>> warning: use pragma Import for "Ext" to suppress
10211 initialization (RM B(24))
10217 As indicated by the warning message, the solution is to use a (dummy) pragma
10218 Import to suppress this initialization. The pragma tell the compiler that the
10219 object is declared and initialized elsewhere. The following package compiles
10220 without warnings (and the initialization is suppressed):
10222 @smallexample @c ada
10230 for Ext'Address use System'To_Address (16#1234_1234#);
10231 pragma Import (Ada, Ext);
10236 A final issue with address clauses involves their use for overlaying
10237 variables, as in the following example:
10238 @cindex Overlaying of objects
10240 @smallexample @c ada
10243 for B'Address use A'Address;
10247 or alternatively, using the form recommended by the RM:
10249 @smallexample @c ada
10251 Addr : constant Address := A'Address;
10253 for B'Address use Addr;
10257 In both of these cases, @code{A}
10258 and @code{B} become aliased to one another via the
10259 address clause. This use of address clauses to overlay
10260 variables, achieving an effect similar to unchecked
10261 conversion was erroneous in Ada 83, but in Ada 95
10262 the effect is implementation defined. Furthermore, the
10263 Ada 95 RM specifically recommends that in a situation
10264 like this, @code{B} should be subject to the following
10265 implementation advice (RM 13.3(19)):
10268 19 If the Address of an object is specified, or it is imported
10269 or exported, then the implementation should not perform
10270 optimizations based on assumptions of no aliases.
10274 GNAT follows this recommendation, and goes further by also applying
10275 this recommendation to the overlaid variable (@code{A}
10276 in the above example) in this case. This means that the overlay
10277 works "as expected", in that a modification to one of the variables
10278 will affect the value of the other.
10280 @node Effect of Convention on Representation
10281 @section Effect of Convention on Representation
10282 @cindex Convention, effect on representation
10285 Normally the specification of a foreign language convention for a type or
10286 an object has no effect on the chosen representation. In particular, the
10287 representation chosen for data in GNAT generally meets the standard system
10288 conventions, and for example records are laid out in a manner that is
10289 consistent with C@. This means that specifying convention C (for example)
10292 There are three exceptions to this general rule:
10296 @item Convention Fortran and array subtypes
10297 If pragma Convention Fortran is specified for an array subtype, then in
10298 accordance with the implementation advice in section 3.6.2(11) of the
10299 Ada Reference Manual, the array will be stored in a Fortran-compatible
10300 column-major manner, instead of the normal default row-major order.
10302 @item Convention C and enumeration types
10303 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
10304 to accommodate all values of the type. For example, for the enumeration
10307 @smallexample @c ada
10308 type Color is (Red, Green, Blue);
10312 8 bits is sufficient to store all values of the type, so by default, objects
10313 of type @code{Color} will be represented using 8 bits. However, normal C
10314 convention is to use 32 bits for all enum values in C, since enum values
10315 are essentially of type int. If pragma @code{Convention C} is specified for an
10316 Ada enumeration type, then the size is modified as necessary (usually to
10317 32 bits) to be consistent with the C convention for enum values.
10319 @item Convention C/Fortran and Boolean types
10320 In C, the usual convention for boolean values, that is values used for
10321 conditions, is that zero represents false, and nonzero values represent
10322 true. In Ada, the normal convention is that two specific values, typically
10323 0/1, are used to represent false/true respectively.
10325 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
10326 value represents true).
10328 To accommodate the Fortran and C conventions, if a pragma Convention specifies
10329 C or Fortran convention for a derived Boolean, as in the following example:
10331 @smallexample @c ada
10332 type C_Switch is new Boolean;
10333 pragma Convention (C, C_Switch);
10337 then the GNAT generated code will treat any nonzero value as true. For truth
10338 values generated by GNAT, the conventional value 1 will be used for True, but
10339 when one of these values is read, any nonzero value is treated as True.
10343 @node Determining the Representations chosen by GNAT
10344 @section Determining the Representations chosen by GNAT
10345 @cindex Representation, determination of
10346 @cindex @code{-gnatR} switch
10349 Although the descriptions in this section are intended to be complete, it is
10350 often easier to simply experiment to see what GNAT accepts and what the
10351 effect is on the layout of types and objects.
10353 As required by the Ada RM, if a representation clause is not accepted, then
10354 it must be rejected as illegal by the compiler. However, when a
10355 representation clause or pragma is accepted, there can still be questions
10356 of what the compiler actually does. For example, if a partial record
10357 representation clause specifies the location of some components and not
10358 others, then where are the non-specified components placed? Or if pragma
10359 @code{Pack} is used on a record, then exactly where are the resulting
10360 fields placed? The section on pragma @code{Pack} in this chapter can be
10361 used to answer the second question, but it is often easier to just see
10362 what the compiler does.
10364 For this purpose, GNAT provides the option @code{-gnatR}. If you compile
10365 with this option, then the compiler will output information on the actual
10366 representations chosen, in a format similar to source representation
10367 clauses. For example, if we compile the package:
10369 @smallexample @c ada
10371 type r (x : boolean) is tagged record
10373 when True => S : String (1 .. 100);
10374 when False => null;
10378 type r2 is new r (false) with record
10383 y2 at 16 range 0 .. 31;
10390 type x1 is array (1 .. 10) of x;
10391 for x1'component_size use 11;
10393 type ia is access integer;
10395 type Rb1 is array (1 .. 13) of Boolean;
10398 type Rb2 is array (1 .. 65) of Boolean;
10414 using the switch @code{-gnatR} we obtain the following output:
10417 Representation information for unit q
10418 -------------------------------------
10421 for r'Alignment use 4;
10423 x at 4 range 0 .. 7;
10424 _tag at 0 range 0 .. 31;
10425 s at 5 range 0 .. 799;
10428 for r2'Size use 160;
10429 for r2'Alignment use 4;
10431 x at 4 range 0 .. 7;
10432 _tag at 0 range 0 .. 31;
10433 _parent at 0 range 0 .. 63;
10434 y2 at 16 range 0 .. 31;
10438 for x'Alignment use 1;
10440 y at 0 range 0 .. 7;
10443 for x1'Size use 112;
10444 for x1'Alignment use 1;
10445 for x1'Component_Size use 11;
10447 for rb1'Size use 13;
10448 for rb1'Alignment use 2;
10449 for rb1'Component_Size use 1;
10451 for rb2'Size use 72;
10452 for rb2'Alignment use 1;
10453 for rb2'Component_Size use 1;
10455 for x2'Size use 224;
10456 for x2'Alignment use 4;
10458 l1 at 0 range 0 .. 0;
10459 l2 at 0 range 1 .. 64;
10460 l3 at 12 range 0 .. 31;
10461 l4 at 16 range 0 .. 0;
10462 l5 at 16 range 1 .. 13;
10463 l6 at 18 range 0 .. 71;
10468 The Size values are actually the Object_Size, i.e.@: the default size that
10469 will be allocated for objects of the type.
10470 The ?? size for type r indicates that we have a variant record, and the
10471 actual size of objects will depend on the discriminant value.
10473 The Alignment values show the actual alignment chosen by the compiler
10474 for each record or array type.
10476 The record representation clause for type r shows where all fields
10477 are placed, including the compiler generated tag field (whose location
10478 cannot be controlled by the programmer).
10480 The record representation clause for the type extension r2 shows all the
10481 fields present, including the parent field, which is a copy of the fields
10482 of the parent type of r2, i.e.@: r1.
10484 The component size and size clauses for types rb1 and rb2 show
10485 the exact effect of pragma @code{Pack} on these arrays, and the record
10486 representation clause for type x2 shows how pragma @code{Pack} affects
10489 In some cases, it may be useful to cut and paste the representation clauses
10490 generated by the compiler into the original source to fix and guarantee
10491 the actual representation to be used.
10493 @node Standard Library Routines
10494 @chapter Standard Library Routines
10497 The Ada 95 Reference Manual contains in Annex A a full description of an
10498 extensive set of standard library routines that can be used in any Ada
10499 program, and which must be provided by all Ada compilers. They are
10500 analogous to the standard C library used by C programs.
10502 GNAT implements all of the facilities described in annex A, and for most
10503 purposes the description in the Ada 95
10504 reference manual, or appropriate Ada
10505 text book, will be sufficient for making use of these facilities.
10507 In the case of the input-output facilities,
10508 @xref{The Implementation of Standard I/O},
10509 gives details on exactly how GNAT interfaces to the
10510 file system. For the remaining packages, the Ada 95 reference manual
10511 should be sufficient. The following is a list of the packages included,
10512 together with a brief description of the functionality that is provided.
10514 For completeness, references are included to other predefined library
10515 routines defined in other sections of the Ada 95 reference manual (these are
10516 cross-indexed from annex A).
10520 This is a parent package for all the standard library packages. It is
10521 usually included implicitly in your program, and itself contains no
10522 useful data or routines.
10524 @item Ada.Calendar (9.6)
10525 @code{Calendar} provides time of day access, and routines for
10526 manipulating times and durations.
10528 @item Ada.Characters (A.3.1)
10529 This is a dummy parent package that contains no useful entities
10531 @item Ada.Characters.Handling (A.3.2)
10532 This package provides some basic character handling capabilities,
10533 including classification functions for classes of characters (e.g.@: test
10534 for letters, or digits).
10536 @item Ada.Characters.Latin_1 (A.3.3)
10537 This package includes a complete set of definitions of the characters
10538 that appear in type CHARACTER@. It is useful for writing programs that
10539 will run in international environments. For example, if you want an
10540 upper case E with an acute accent in a string, it is often better to use
10541 the definition of @code{UC_E_Acute} in this package. Then your program
10542 will print in an understandable manner even if your environment does not
10543 support these extended characters.
10545 @item Ada.Command_Line (A.15)
10546 This package provides access to the command line parameters and the name
10547 of the current program (analogous to the use of @code{argc} and @code{argv}
10548 in C), and also allows the exit status for the program to be set in a
10549 system-independent manner.
10551 @item Ada.Decimal (F.2)
10552 This package provides constants describing the range of decimal numbers
10553 implemented, and also a decimal divide routine (analogous to the COBOL
10554 verb DIVIDE .. GIVING .. REMAINDER ..)
10556 @item Ada.Direct_IO (A.8.4)
10557 This package provides input-output using a model of a set of records of
10558 fixed-length, containing an arbitrary definite Ada type, indexed by an
10559 integer record number.
10561 @item Ada.Dynamic_Priorities (D.5)
10562 This package allows the priorities of a task to be adjusted dynamically
10563 as the task is running.
10565 @item Ada.Exceptions (11.4.1)
10566 This package provides additional information on exceptions, and also
10567 contains facilities for treating exceptions as data objects, and raising
10568 exceptions with associated messages.
10570 @item Ada.Finalization (7.6)
10571 This package contains the declarations and subprograms to support the
10572 use of controlled types, providing for automatic initialization and
10573 finalization (analogous to the constructors and destructors of C++)
10575 @item Ada.Interrupts (C.3.2)
10576 This package provides facilities for interfacing to interrupts, which
10577 includes the set of signals or conditions that can be raised and
10578 recognized as interrupts.
10580 @item Ada.Interrupts.Names (C.3.2)
10581 This package provides the set of interrupt names (actually signal
10582 or condition names) that can be handled by GNAT@.
10584 @item Ada.IO_Exceptions (A.13)
10585 This package defines the set of exceptions that can be raised by use of
10586 the standard IO packages.
10589 This package contains some standard constants and exceptions used
10590 throughout the numerics packages. Note that the constants pi and e are
10591 defined here, and it is better to use these definitions than rolling
10594 @item Ada.Numerics.Complex_Elementary_Functions
10595 Provides the implementation of standard elementary functions (such as
10596 log and trigonometric functions) operating on complex numbers using the
10597 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10598 created by the package @code{Numerics.Complex_Types}.
10600 @item Ada.Numerics.Complex_Types
10601 This is a predefined instantiation of
10602 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10603 build the type @code{Complex} and @code{Imaginary}.
10605 @item Ada.Numerics.Discrete_Random
10606 This package provides a random number generator suitable for generating
10607 random integer values from a specified range.
10609 @item Ada.Numerics.Float_Random
10610 This package provides a random number generator suitable for generating
10611 uniformly distributed floating point values.
10613 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10614 This is a generic version of the package that provides the
10615 implementation of standard elementary functions (such as log and
10616 trigonometric functions) for an arbitrary complex type.
10618 The following predefined instantiations of this package are provided:
10622 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10624 @code{Ada.Numerics.Complex_Elementary_Functions}
10626 @code{Ada.Numerics.
10627 Long_Complex_Elementary_Functions}
10630 @item Ada.Numerics.Generic_Complex_Types
10631 This is a generic package that allows the creation of complex types,
10632 with associated complex arithmetic operations.
10634 The following predefined instantiations of this package exist
10637 @code{Ada.Numerics.Short_Complex_Complex_Types}
10639 @code{Ada.Numerics.Complex_Complex_Types}
10641 @code{Ada.Numerics.Long_Complex_Complex_Types}
10644 @item Ada.Numerics.Generic_Elementary_Functions
10645 This is a generic package that provides the implementation of standard
10646 elementary functions (such as log an trigonometric functions) for an
10647 arbitrary float type.
10649 The following predefined instantiations of this package exist
10653 @code{Ada.Numerics.Short_Elementary_Functions}
10655 @code{Ada.Numerics.Elementary_Functions}
10657 @code{Ada.Numerics.Long_Elementary_Functions}
10660 @item Ada.Real_Time (D.8)
10661 This package provides facilities similar to those of @code{Calendar}, but
10662 operating with a finer clock suitable for real time control. Note that
10663 annex D requires that there be no backward clock jumps, and GNAT generally
10664 guarantees this behavior, but of course if the external clock on which
10665 the GNAT runtime depends is deliberately reset by some external event,
10666 then such a backward jump may occur.
10668 @item Ada.Sequential_IO (A.8.1)
10669 This package provides input-output facilities for sequential files,
10670 which can contain a sequence of values of a single type, which can be
10671 any Ada type, including indefinite (unconstrained) types.
10673 @item Ada.Storage_IO (A.9)
10674 This package provides a facility for mapping arbitrary Ada types to and
10675 from a storage buffer. It is primarily intended for the creation of new
10678 @item Ada.Streams (13.13.1)
10679 This is a generic package that provides the basic support for the
10680 concept of streams as used by the stream attributes (@code{Input},
10681 @code{Output}, @code{Read} and @code{Write}).
10683 @item Ada.Streams.Stream_IO (A.12.1)
10684 This package is a specialization of the type @code{Streams} defined in
10685 package @code{Streams} together with a set of operations providing
10686 Stream_IO capability. The Stream_IO model permits both random and
10687 sequential access to a file which can contain an arbitrary set of values
10688 of one or more Ada types.
10690 @item Ada.Strings (A.4.1)
10691 This package provides some basic constants used by the string handling
10694 @item Ada.Strings.Bounded (A.4.4)
10695 This package provides facilities for handling variable length
10696 strings. The bounded model requires a maximum length. It is thus
10697 somewhat more limited than the unbounded model, but avoids the use of
10698 dynamic allocation or finalization.
10700 @item Ada.Strings.Fixed (A.4.3)
10701 This package provides facilities for handling fixed length strings.
10703 @item Ada.Strings.Maps (A.4.2)
10704 This package provides facilities for handling character mappings and
10705 arbitrarily defined subsets of characters. For instance it is useful in
10706 defining specialized translation tables.
10708 @item Ada.Strings.Maps.Constants (A.4.6)
10709 This package provides a standard set of predefined mappings and
10710 predefined character sets. For example, the standard upper to lower case
10711 conversion table is found in this package. Note that upper to lower case
10712 conversion is non-trivial if you want to take the entire set of
10713 characters, including extended characters like E with an acute accent,
10714 into account. You should use the mappings in this package (rather than
10715 adding 32 yourself) to do case mappings.
10717 @item Ada.Strings.Unbounded (A.4.5)
10718 This package provides facilities for handling variable length
10719 strings. The unbounded model allows arbitrary length strings, but
10720 requires the use of dynamic allocation and finalization.
10722 @item Ada.Strings.Wide_Bounded (A.4.7)
10723 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10724 @itemx Ada.Strings.Wide_Maps (A.4.7)
10725 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10726 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10727 These packages provide analogous capabilities to the corresponding
10728 packages without @samp{Wide_} in the name, but operate with the types
10729 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10730 and @code{Character}.
10732 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
10733 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
10734 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
10735 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
10736 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
10737 These packages provide analogous capabilities to the corresponding
10738 packages without @samp{Wide_} in the name, but operate with the types
10739 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
10740 of @code{String} and @code{Character}.
10742 @item Ada.Synchronous_Task_Control (D.10)
10743 This package provides some standard facilities for controlling task
10744 communication in a synchronous manner.
10747 This package contains definitions for manipulation of the tags of tagged
10750 @item Ada.Task_Attributes
10751 This package provides the capability of associating arbitrary
10752 task-specific data with separate tasks.
10755 This package provides basic text input-output capabilities for
10756 character, string and numeric data. The subpackages of this
10757 package are listed next.
10759 @item Ada.Text_IO.Decimal_IO
10760 Provides input-output facilities for decimal fixed-point types
10762 @item Ada.Text_IO.Enumeration_IO
10763 Provides input-output facilities for enumeration types.
10765 @item Ada.Text_IO.Fixed_IO
10766 Provides input-output facilities for ordinary fixed-point types.
10768 @item Ada.Text_IO.Float_IO
10769 Provides input-output facilities for float types. The following
10770 predefined instantiations of this generic package are available:
10774 @code{Short_Float_Text_IO}
10776 @code{Float_Text_IO}
10778 @code{Long_Float_Text_IO}
10781 @item Ada.Text_IO.Integer_IO
10782 Provides input-output facilities for integer types. The following
10783 predefined instantiations of this generic package are available:
10786 @item Short_Short_Integer
10787 @code{Ada.Short_Short_Integer_Text_IO}
10788 @item Short_Integer
10789 @code{Ada.Short_Integer_Text_IO}
10791 @code{Ada.Integer_Text_IO}
10793 @code{Ada.Long_Integer_Text_IO}
10794 @item Long_Long_Integer
10795 @code{Ada.Long_Long_Integer_Text_IO}
10798 @item Ada.Text_IO.Modular_IO
10799 Provides input-output facilities for modular (unsigned) types
10801 @item Ada.Text_IO.Complex_IO (G.1.3)
10802 This package provides basic text input-output capabilities for complex
10805 @item Ada.Text_IO.Editing (F.3.3)
10806 This package contains routines for edited output, analogous to the use
10807 of pictures in COBOL@. The picture formats used by this package are a
10808 close copy of the facility in COBOL@.
10810 @item Ada.Text_IO.Text_Streams (A.12.2)
10811 This package provides a facility that allows Text_IO files to be treated
10812 as streams, so that the stream attributes can be used for writing
10813 arbitrary data, including binary data, to Text_IO files.
10815 @item Ada.Unchecked_Conversion (13.9)
10816 This generic package allows arbitrary conversion from one type to
10817 another of the same size, providing for breaking the type safety in
10818 special circumstances.
10820 If the types have the same Size (more accurately the same Value_Size),
10821 then the effect is simply to transfer the bits from the source to the
10822 target type without any modification. This usage is well defined, and
10823 for simple types whose representation is typically the same across
10824 all implementations, gives a portable method of performing such
10827 If the types do not have the same size, then the result is implementation
10828 defined, and thus may be non-portable. The following describes how GNAT
10829 handles such unchecked conversion cases.
10831 If the types are of different sizes, and are both discrete types, then
10832 the effect is of a normal type conversion without any constraint checking.
10833 In particular if the result type has a larger size, the result will be
10834 zero or sign extended. If the result type has a smaller size, the result
10835 will be truncated by ignoring high order bits.
10837 If the types are of different sizes, and are not both discrete types,
10838 then the conversion works as though pointers were created to the source
10839 and target, and the pointer value is converted. The effect is that bits
10840 are copied from successive low order storage units and bits of the source
10841 up to the length of the target type.
10843 A warning is issued if the lengths differ, since the effect in this
10844 case is implementation dependent, and the above behavior may not match
10845 that of some other compiler.
10847 A pointer to one type may be converted to a pointer to another type using
10848 unchecked conversion. The only case in which the effect is undefined is
10849 when one or both pointers are pointers to unconstrained array types. In
10850 this case, the bounds information may get incorrectly transferred, and in
10851 particular, GNAT uses double size pointers for such types, and it is
10852 meaningless to convert between such pointer types. GNAT will issue a
10853 warning if the alignment of the target designated type is more strict
10854 than the alignment of the source designated type (since the result may
10855 be unaligned in this case).
10857 A pointer other than a pointer to an unconstrained array type may be
10858 converted to and from System.Address. Such usage is common in Ada 83
10859 programs, but note that Ada.Address_To_Access_Conversions is the
10860 preferred method of performing such conversions in Ada 95. Neither
10861 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10862 used in conjunction with pointers to unconstrained objects, since
10863 the bounds information cannot be handled correctly in this case.
10865 @item Ada.Unchecked_Deallocation (13.11.2)
10866 This generic package allows explicit freeing of storage previously
10867 allocated by use of an allocator.
10869 @item Ada.Wide_Text_IO (A.11)
10870 This package is similar to @code{Ada.Text_IO}, except that the external
10871 file supports wide character representations, and the internal types are
10872 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10873 and @code{String}. It contains generic subpackages listed next.
10875 @item Ada.Wide_Text_IO.Decimal_IO
10876 Provides input-output facilities for decimal fixed-point types
10878 @item Ada.Wide_Text_IO.Enumeration_IO
10879 Provides input-output facilities for enumeration types.
10881 @item Ada.Wide_Text_IO.Fixed_IO
10882 Provides input-output facilities for ordinary fixed-point types.
10884 @item Ada.Wide_Text_IO.Float_IO
10885 Provides input-output facilities for float types. The following
10886 predefined instantiations of this generic package are available:
10890 @code{Short_Float_Wide_Text_IO}
10892 @code{Float_Wide_Text_IO}
10894 @code{Long_Float_Wide_Text_IO}
10897 @item Ada.Wide_Text_IO.Integer_IO
10898 Provides input-output facilities for integer types. The following
10899 predefined instantiations of this generic package are available:
10902 @item Short_Short_Integer
10903 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10904 @item Short_Integer
10905 @code{Ada.Short_Integer_Wide_Text_IO}
10907 @code{Ada.Integer_Wide_Text_IO}
10909 @code{Ada.Long_Integer_Wide_Text_IO}
10910 @item Long_Long_Integer
10911 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10914 @item Ada.Wide_Text_IO.Modular_IO
10915 Provides input-output facilities for modular (unsigned) types
10917 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10918 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10919 external file supports wide character representations.
10921 @item Ada.Wide_Text_IO.Editing (F.3.4)
10922 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10923 types are @code{Wide_Character} and @code{Wide_String} instead of
10924 @code{Character} and @code{String}.
10926 @item Ada.Wide_Text_IO.Streams (A.12.3)
10927 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10928 types are @code{Wide_Character} and @code{Wide_String} instead of
10929 @code{Character} and @code{String}.
10931 @item Ada.Wide_Wide_Text_IO (A.11)
10932 This package is similar to @code{Ada.Text_IO}, except that the external
10933 file supports wide character representations, and the internal types are
10934 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10935 and @code{String}. It contains generic subpackages listed next.
10937 @item Ada.Wide_Wide_Text_IO.Decimal_IO
10938 Provides input-output facilities for decimal fixed-point types
10940 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
10941 Provides input-output facilities for enumeration types.
10943 @item Ada.Wide_Wide_Text_IO.Fixed_IO
10944 Provides input-output facilities for ordinary fixed-point types.
10946 @item Ada.Wide_Wide_Text_IO.Float_IO
10947 Provides input-output facilities for float types. The following
10948 predefined instantiations of this generic package are available:
10952 @code{Short_Float_Wide_Wide_Text_IO}
10954 @code{Float_Wide_Wide_Text_IO}
10956 @code{Long_Float_Wide_Wide_Text_IO}
10959 @item Ada.Wide_Wide_Text_IO.Integer_IO
10960 Provides input-output facilities for integer types. The following
10961 predefined instantiations of this generic package are available:
10964 @item Short_Short_Integer
10965 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
10966 @item Short_Integer
10967 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
10969 @code{Ada.Integer_Wide_Wide_Text_IO}
10971 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
10972 @item Long_Long_Integer
10973 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
10976 @item Ada.Wide_Wide_Text_IO.Modular_IO
10977 Provides input-output facilities for modular (unsigned) types
10979 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
10980 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10981 external file supports wide character representations.
10983 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
10984 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10985 types are @code{Wide_Character} and @code{Wide_String} instead of
10986 @code{Character} and @code{String}.
10988 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
10989 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10990 types are @code{Wide_Character} and @code{Wide_String} instead of
10991 @code{Character} and @code{String}.
10996 @node The Implementation of Standard I/O
10997 @chapter The Implementation of Standard I/O
11000 GNAT implements all the required input-output facilities described in
11001 A.6 through A.14. These sections of the Ada 95 reference manual describe the
11002 required behavior of these packages from the Ada point of view, and if
11003 you are writing a portable Ada program that does not need to know the
11004 exact manner in which Ada maps to the outside world when it comes to
11005 reading or writing external files, then you do not need to read this
11006 chapter. As long as your files are all regular files (not pipes or
11007 devices), and as long as you write and read the files only from Ada, the
11008 description in the Ada 95 reference manual is sufficient.
11010 However, if you want to do input-output to pipes or other devices, such
11011 as the keyboard or screen, or if the files you are dealing with are
11012 either generated by some other language, or to be read by some other
11013 language, then you need to know more about the details of how the GNAT
11014 implementation of these input-output facilities behaves.
11016 In this chapter we give a detailed description of exactly how GNAT
11017 interfaces to the file system. As always, the sources of the system are
11018 available to you for answering questions at an even more detailed level,
11019 but for most purposes the information in this chapter will suffice.
11021 Another reason that you may need to know more about how input-output is
11022 implemented arises when you have a program written in mixed languages
11023 where, for example, files are shared between the C and Ada sections of
11024 the same program. GNAT provides some additional facilities, in the form
11025 of additional child library packages, that facilitate this sharing, and
11026 these additional facilities are also described in this chapter.
11029 * Standard I/O Packages::
11035 * Wide_Wide_Text_IO::
11039 * Operations on C Streams::
11040 * Interfacing to C Streams::
11043 @node Standard I/O Packages
11044 @section Standard I/O Packages
11047 The Standard I/O packages described in Annex A for
11053 Ada.Text_IO.Complex_IO
11055 Ada.Text_IO.Text_Streams
11059 Ada.Wide_Text_IO.Complex_IO
11061 Ada.Wide_Text_IO.Text_Streams
11063 Ada.Wide_Wide_Text_IO
11065 Ada.Wide_Wide_Text_IO.Complex_IO
11067 Ada.Wide_Wide_Text_IO.Text_Streams
11077 are implemented using the C
11078 library streams facility; where
11082 All files are opened using @code{fopen}.
11084 All input/output operations use @code{fread}/@code{fwrite}.
11088 There is no internal buffering of any kind at the Ada library level. The only
11089 buffering is that provided at the system level in the implementation of the
11090 library routines that support streams. This facilitates shared use of these
11091 streams by mixed language programs. Note though that system level buffering is
11092 explictly enabled at elaboration of the standard I/O packages and that can have
11093 an impact on mixed language programs, in particular those using I/O before
11094 calling the Ada elaboration routine (e.g. adainit). It is recommended to call
11095 the Ada elaboration routine before performing any I/O or when impractical,
11096 flush the common I/O streams and in particular Standard_Output before
11097 elaborating the Ada code.
11100 @section FORM Strings
11103 The format of a FORM string in GNAT is:
11106 "keyword=value,keyword=value,@dots{},keyword=value"
11110 where letters may be in upper or lower case, and there are no spaces
11111 between values. The order of the entries is not important. Currently
11112 there are two keywords defined.
11120 The use of these parameters is described later in this section.
11126 Direct_IO can only be instantiated for definite types. This is a
11127 restriction of the Ada language, which means that the records are fixed
11128 length (the length being determined by @code{@var{type}'Size}, rounded
11129 up to the next storage unit boundary if necessary).
11131 The records of a Direct_IO file are simply written to the file in index
11132 sequence, with the first record starting at offset zero, and subsequent
11133 records following. There is no control information of any kind. For
11134 example, if 32-bit integers are being written, each record takes
11135 4-bytes, so the record at index @var{K} starts at offset
11136 (@var{K}@minus{}1)*4.
11138 There is no limit on the size of Direct_IO files, they are expanded as
11139 necessary to accommodate whatever records are written to the file.
11141 @node Sequential_IO
11142 @section Sequential_IO
11145 Sequential_IO may be instantiated with either a definite (constrained)
11146 or indefinite (unconstrained) type.
11148 For the definite type case, the elements written to the file are simply
11149 the memory images of the data values with no control information of any
11150 kind. The resulting file should be read using the same type, no validity
11151 checking is performed on input.
11153 For the indefinite type case, the elements written consist of two
11154 parts. First is the size of the data item, written as the memory image
11155 of a @code{Interfaces.C.size_t} value, followed by the memory image of
11156 the data value. The resulting file can only be read using the same
11157 (unconstrained) type. Normal assignment checks are performed on these
11158 read operations, and if these checks fail, @code{Data_Error} is
11159 raised. In particular, in the array case, the lengths must match, and in
11160 the variant record case, if the variable for a particular read operation
11161 is constrained, the discriminants must match.
11163 Note that it is not possible to use Sequential_IO to write variable
11164 length array items, and then read the data back into different length
11165 arrays. For example, the following will raise @code{Data_Error}:
11167 @smallexample @c ada
11168 package IO is new Sequential_IO (String);
11173 IO.Write (F, "hello!")
11174 IO.Reset (F, Mode=>In_File);
11181 On some Ada implementations, this will print @code{hell}, but the program is
11182 clearly incorrect, since there is only one element in the file, and that
11183 element is the string @code{hello!}.
11185 In Ada 95, this kind of behavior can be legitimately achieved using
11186 Stream_IO, and this is the preferred mechanism. In particular, the above
11187 program fragment rewritten to use Stream_IO will work correctly.
11193 Text_IO files consist of a stream of characters containing the following
11194 special control characters:
11197 LF (line feed, 16#0A#) Line Mark
11198 FF (form feed, 16#0C#) Page Mark
11202 A canonical Text_IO file is defined as one in which the following
11203 conditions are met:
11207 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
11211 The character @code{FF} is used only as a page mark, i.e.@: to mark the
11212 end of a page and consequently can appear only immediately following a
11213 @code{LF} (line mark) character.
11216 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
11217 (line mark, page mark). In the former case, the page mark is implicitly
11218 assumed to be present.
11222 A file written using Text_IO will be in canonical form provided that no
11223 explicit @code{LF} or @code{FF} characters are written using @code{Put}
11224 or @code{Put_Line}. There will be no @code{FF} character at the end of
11225 the file unless an explicit @code{New_Page} operation was performed
11226 before closing the file.
11228 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
11229 pipe, can be read using any of the routines in Text_IO@. The
11230 semantics in this case will be exactly as defined in the Ada 95 reference
11231 manual and all the routines in Text_IO are fully implemented.
11233 A text file that does not meet the requirements for a canonical Text_IO
11234 file has one of the following:
11238 The file contains @code{FF} characters not immediately following a
11239 @code{LF} character.
11242 The file contains @code{LF} or @code{FF} characters written by
11243 @code{Put} or @code{Put_Line}, which are not logically considered to be
11244 line marks or page marks.
11247 The file ends in a character other than @code{LF} or @code{FF},
11248 i.e.@: there is no explicit line mark or page mark at the end of the file.
11252 Text_IO can be used to read such non-standard text files but subprograms
11253 to do with line or page numbers do not have defined meanings. In
11254 particular, a @code{FF} character that does not follow a @code{LF}
11255 character may or may not be treated as a page mark from the point of
11256 view of page and line numbering. Every @code{LF} character is considered
11257 to end a line, and there is an implied @code{LF} character at the end of
11261 * Text_IO Stream Pointer Positioning::
11262 * Text_IO Reading and Writing Non-Regular Files::
11264 * Treating Text_IO Files as Streams::
11265 * Text_IO Extensions::
11266 * Text_IO Facilities for Unbounded Strings::
11269 @node Text_IO Stream Pointer Positioning
11270 @subsection Stream Pointer Positioning
11273 @code{Ada.Text_IO} has a definition of current position for a file that
11274 is being read. No internal buffering occurs in Text_IO, and usually the
11275 physical position in the stream used to implement the file corresponds
11276 to this logical position defined by Text_IO@. There are two exceptions:
11280 After a call to @code{End_Of_Page} that returns @code{True}, the stream
11281 is positioned past the @code{LF} (line mark) that precedes the page
11282 mark. Text_IO maintains an internal flag so that subsequent read
11283 operations properly handle the logical position which is unchanged by
11284 the @code{End_Of_Page} call.
11287 After a call to @code{End_Of_File} that returns @code{True}, if the
11288 Text_IO file was positioned before the line mark at the end of file
11289 before the call, then the logical position is unchanged, but the stream
11290 is physically positioned right at the end of file (past the line mark,
11291 and past a possible page mark following the line mark. Again Text_IO
11292 maintains internal flags so that subsequent read operations properly
11293 handle the logical position.
11297 These discrepancies have no effect on the observable behavior of
11298 Text_IO, but if a single Ada stream is shared between a C program and
11299 Ada program, or shared (using @samp{shared=yes} in the form string)
11300 between two Ada files, then the difference may be observable in some
11303 @node Text_IO Reading and Writing Non-Regular Files
11304 @subsection Reading and Writing Non-Regular Files
11307 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
11308 can be used for reading and writing. Writing is not affected and the
11309 sequence of characters output is identical to the normal file case, but
11310 for reading, the behavior of Text_IO is modified to avoid undesirable
11311 look-ahead as follows:
11313 An input file that is not a regular file is considered to have no page
11314 marks. Any @code{Ascii.FF} characters (the character normally used for a
11315 page mark) appearing in the file are considered to be data
11316 characters. In particular:
11320 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
11321 following a line mark. If a page mark appears, it will be treated as a
11325 This avoids the need to wait for an extra character to be typed or
11326 entered from the pipe to complete one of these operations.
11329 @code{End_Of_Page} always returns @code{False}
11332 @code{End_Of_File} will return @code{False} if there is a page mark at
11333 the end of the file.
11337 Output to non-regular files is the same as for regular files. Page marks
11338 may be written to non-regular files using @code{New_Page}, but as noted
11339 above they will not be treated as page marks on input if the output is
11340 piped to another Ada program.
11342 Another important discrepancy when reading non-regular files is that the end
11343 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
11344 pressing the @key{EOT} key,
11346 is signaled once (i.e.@: the test @code{End_Of_File}
11347 will yield @code{True}, or a read will
11348 raise @code{End_Error}), but then reading can resume
11349 to read data past that end of
11350 file indication, until another end of file indication is entered.
11352 @node Get_Immediate
11353 @subsection Get_Immediate
11354 @cindex Get_Immediate
11357 Get_Immediate returns the next character (including control characters)
11358 from the input file. In particular, Get_Immediate will return LF or FF
11359 characters used as line marks or page marks. Such operations leave the
11360 file positioned past the control character, and it is thus not treated
11361 as having its normal function. This means that page, line and column
11362 counts after this kind of Get_Immediate call are set as though the mark
11363 did not occur. In the case where a Get_Immediate leaves the file
11364 positioned between the line mark and page mark (which is not normally
11365 possible), it is undefined whether the FF character will be treated as a
11368 @node Treating Text_IO Files as Streams
11369 @subsection Treating Text_IO Files as Streams
11370 @cindex Stream files
11373 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11374 as a stream. Data written to a Text_IO file in this stream mode is
11375 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
11376 16#0C# (@code{FF}), the resulting file may have non-standard
11377 format. Similarly if read operations are used to read from a Text_IO
11378 file treated as a stream, then @code{LF} and @code{FF} characters may be
11379 skipped and the effect is similar to that described above for
11380 @code{Get_Immediate}.
11382 @node Text_IO Extensions
11383 @subsection Text_IO Extensions
11384 @cindex Text_IO extensions
11387 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11388 to the standard @code{Text_IO} package:
11391 @item function File_Exists (Name : String) return Boolean;
11392 Determines if a file of the given name exists.
11394 @item function Get_Line return String;
11395 Reads a string from the standard input file. The value returned is exactly
11396 the length of the line that was read.
11398 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11399 Similar, except that the parameter File specifies the file from which
11400 the string is to be read.
11404 @node Text_IO Facilities for Unbounded Strings
11405 @subsection Text_IO Facilities for Unbounded Strings
11406 @cindex Text_IO for unbounded strings
11407 @cindex Unbounded_String, Text_IO operations
11410 The package @code{Ada.Strings.Unbounded.Text_IO}
11411 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11412 subprograms useful for Text_IO operations on unbounded strings:
11416 @item function Get_Line (File : File_Type) return Unbounded_String;
11417 Reads a line from the specified file
11418 and returns the result as an unbounded string.
11420 @item procedure Put (File : File_Type; U : Unbounded_String);
11421 Writes the value of the given unbounded string to the specified file
11422 Similar to the effect of
11423 @code{Put (To_String (U))} except that an extra copy is avoided.
11425 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11426 Writes the value of the given unbounded string to the specified file,
11427 followed by a @code{New_Line}.
11428 Similar to the effect of @code{Put_Line (To_String (U))} except
11429 that an extra copy is avoided.
11433 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11434 and is optional. If the parameter is omitted, then the standard input or
11435 output file is referenced as appropriate.
11437 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11438 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11439 @code{Wide_Text_IO} functionality for unbounded wide strings.
11441 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11442 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11443 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11446 @section Wide_Text_IO
11449 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11450 both input and output files may contain special sequences that represent
11451 wide character values. The encoding scheme for a given file may be
11452 specified using a FORM parameter:
11459 as part of the FORM string (WCEM = wide character encoding method),
11460 where @var{x} is one of the following characters
11466 Upper half encoding
11478 The encoding methods match those that
11479 can be used in a source
11480 program, but there is no requirement that the encoding method used for
11481 the source program be the same as the encoding method used for files,
11482 and different files may use different encoding methods.
11484 The default encoding method for the standard files, and for opened files
11485 for which no WCEM parameter is given in the FORM string matches the
11486 wide character encoding specified for the main program (the default
11487 being brackets encoding if no coding method was specified with -gnatW).
11491 In this encoding, a wide character is represented by a five character
11499 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
11500 characters (using upper case letters) of the wide character code. For
11501 example, ESC A345 is used to represent the wide character with code
11502 16#A345#. This scheme is compatible with use of the full
11503 @code{Wide_Character} set.
11505 @item Upper Half Coding
11506 The wide character with encoding 16#abcd#, where the upper bit is on
11507 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
11508 16#cd#. The second byte may never be a format control character, but is
11509 not required to be in the upper half. This method can be also used for
11510 shift-JIS or EUC where the internal coding matches the external coding.
11512 @item Shift JIS Coding
11513 A wide character is represented by a two character sequence 16#ab# and
11514 16#cd#, with the restrictions described for upper half encoding as
11515 described above. The internal character code is the corresponding JIS
11516 character according to the standard algorithm for Shift-JIS
11517 conversion. Only characters defined in the JIS code set table can be
11518 used with this encoding method.
11521 A wide character is represented by a two character sequence 16#ab# and
11522 16#cd#, with both characters being in the upper half. The internal
11523 character code is the corresponding JIS character according to the EUC
11524 encoding algorithm. Only characters defined in the JIS code set table
11525 can be used with this encoding method.
11528 A wide character is represented using
11529 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11530 10646-1/Am.2. Depending on the character value, the representation
11531 is a one, two, or three byte sequence:
11534 16#0000#-16#007f#: 2#0xxxxxxx#
11535 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
11536 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11540 where the xxx bits correspond to the left-padded bits of the
11541 16-bit character value. Note that all lower half ASCII characters
11542 are represented as ASCII bytes and all upper half characters and
11543 other wide characters are represented as sequences of upper-half
11544 (The full UTF-8 scheme allows for encoding 31-bit characters as
11545 6-byte sequences, but in this implementation, all UTF-8 sequences
11546 of four or more bytes length will raise a Constraint_Error, as
11547 will all invalid UTF-8 sequences.)
11549 @item Brackets Coding
11550 In this encoding, a wide character is represented by the following eight
11551 character sequence:
11558 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11559 characters (using uppercase letters) of the wide character code. For
11560 example, @code{["A345"]} is used to represent the wide character with code
11562 This scheme is compatible with use of the full Wide_Character set.
11563 On input, brackets coding can also be used for upper half characters,
11564 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
11565 is only used for wide characters with a code greater than @code{16#FF#}.
11570 For the coding schemes other than Hex and Brackets encoding,
11571 not all wide character
11572 values can be represented. An attempt to output a character that cannot
11573 be represented using the encoding scheme for the file causes
11574 Constraint_Error to be raised. An invalid wide character sequence on
11575 input also causes Constraint_Error to be raised.
11578 * Wide_Text_IO Stream Pointer Positioning::
11579 * Wide_Text_IO Reading and Writing Non-Regular Files::
11582 @node Wide_Text_IO Stream Pointer Positioning
11583 @subsection Stream Pointer Positioning
11586 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11587 of stream pointer positioning (@pxref{Text_IO}). There is one additional
11590 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
11591 normal lower ASCII set (i.e.@: a character in the range:
11593 @smallexample @c ada
11594 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
11598 then although the logical position of the file pointer is unchanged by
11599 the @code{Look_Ahead} call, the stream is physically positioned past the
11600 wide character sequence. Again this is to avoid the need for buffering
11601 or backup, and all @code{Wide_Text_IO} routines check the internal
11602 indication that this situation has occurred so that this is not visible
11603 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
11604 can be observed if the wide text file shares a stream with another file.
11606 @node Wide_Text_IO Reading and Writing Non-Regular Files
11607 @subsection Reading and Writing Non-Regular Files
11610 As in the case of Text_IO, when a non-regular file is read, it is
11611 assumed that the file contains no page marks (any form characters are
11612 treated as data characters), and @code{End_Of_Page} always returns
11613 @code{False}. Similarly, the end of file indication is not sticky, so
11614 it is possible to read beyond an end of file.
11616 @node Wide_Wide_Text_IO
11617 @section Wide_Wide_Text_IO
11620 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
11621 both input and output files may contain special sequences that represent
11622 wide wide character values. The encoding scheme for a given file may be
11623 specified using a FORM parameter:
11630 as part of the FORM string (WCEM = wide character encoding method),
11631 where @var{x} is one of the following characters
11637 Upper half encoding
11649 The encoding methods match those that
11650 can be used in a source
11651 program, but there is no requirement that the encoding method used for
11652 the source program be the same as the encoding method used for files,
11653 and different files may use different encoding methods.
11655 The default encoding method for the standard files, and for opened files
11656 for which no WCEM parameter is given in the FORM string matches the
11657 wide character encoding specified for the main program (the default
11658 being brackets encoding if no coding method was specified with -gnatW).
11663 A wide character is represented using
11664 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11665 10646-1/Am.2. Depending on the character value, the representation
11666 is a one, two, three, or four byte sequence:
11669 16#000000#-16#00007f#: 2#0xxxxxxx#
11670 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
11671 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11672 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
11676 where the xxx bits correspond to the left-padded bits of the
11677 21-bit character value. Note that all lower half ASCII characters
11678 are represented as ASCII bytes and all upper half characters and
11679 other wide characters are represented as sequences of upper-half
11682 @item Brackets Coding
11683 In this encoding, a wide wide character is represented by the following eight
11684 character sequence if is in wide character range
11690 and by the following ten character sequence if not
11693 [ " a b c d e f " ]
11697 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
11698 are the four or six hexadecimal
11699 characters (using uppercase letters) of the wide wide character code. For
11700 example, @code{["01A345"]} is used to represent the wide wide character
11701 with code @code{16#01A345#}.
11703 This scheme is compatible with use of the full Wide_Wide_Character set.
11704 On input, brackets coding can also be used for upper half characters,
11705 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
11706 is only used for wide characters with a code greater than @code{16#FF#}.
11711 If is also possible to use the other Wide_Character encoding methods,
11712 such as Shift-JIS, but the other schemes cannot support the full range
11713 of wide wide characters.
11714 An attempt to output a character that cannot
11715 be represented using the encoding scheme for the file causes
11716 Constraint_Error to be raised. An invalid wide character sequence on
11717 input also causes Constraint_Error to be raised.
11720 * Wide_Wide_Text_IO Stream Pointer Positioning::
11721 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
11724 @node Wide_Wide_Text_IO Stream Pointer Positioning
11725 @subsection Stream Pointer Positioning
11728 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11729 of stream pointer positioning (@pxref{Text_IO}). There is one additional
11732 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
11733 normal lower ASCII set (i.e.@: a character in the range:
11735 @smallexample @c ada
11736 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
11740 then although the logical position of the file pointer is unchanged by
11741 the @code{Look_Ahead} call, the stream is physically positioned past the
11742 wide character sequence. Again this is to avoid the need for buffering
11743 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
11744 indication that this situation has occurred so that this is not visible
11745 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
11746 can be observed if the wide text file shares a stream with another file.
11748 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
11749 @subsection Reading and Writing Non-Regular Files
11752 As in the case of Text_IO, when a non-regular file is read, it is
11753 assumed that the file contains no page marks (any form characters are
11754 treated as data characters), and @code{End_Of_Page} always returns
11755 @code{False}. Similarly, the end of file indication is not sticky, so
11756 it is possible to read beyond an end of file.
11762 A stream file is a sequence of bytes, where individual elements are
11763 written to the file as described in the Ada 95 reference manual. The type
11764 @code{Stream_Element} is simply a byte. There are two ways to read or
11765 write a stream file.
11769 The operations @code{Read} and @code{Write} directly read or write a
11770 sequence of stream elements with no control information.
11773 The stream attributes applied to a stream file transfer data in the
11774 manner described for stream attributes.
11778 @section Shared Files
11781 Section A.14 of the Ada 95 Reference Manual allows implementations to
11782 provide a wide variety of behavior if an attempt is made to access the
11783 same external file with two or more internal files.
11785 To provide a full range of functionality, while at the same time
11786 minimizing the problems of portability caused by this implementation
11787 dependence, GNAT handles file sharing as follows:
11791 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11792 to open two or more files with the same full name is considered an error
11793 and is not supported. The exception @code{Use_Error} will be
11794 raised. Note that a file that is not explicitly closed by the program
11795 remains open until the program terminates.
11798 If the form parameter @samp{shared=no} appears in the form string, the
11799 file can be opened or created with its own separate stream identifier,
11800 regardless of whether other files sharing the same external file are
11801 opened. The exact effect depends on how the C stream routines handle
11802 multiple accesses to the same external files using separate streams.
11805 If the form parameter @samp{shared=yes} appears in the form string for
11806 each of two or more files opened using the same full name, the same
11807 stream is shared between these files, and the semantics are as described
11808 in Ada 95 Reference Manual, Section A.14.
11812 When a program that opens multiple files with the same name is ported
11813 from another Ada compiler to GNAT, the effect will be that
11814 @code{Use_Error} is raised.
11816 The documentation of the original compiler and the documentation of the
11817 program should then be examined to determine if file sharing was
11818 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11819 and @code{Create} calls as required.
11821 When a program is ported from GNAT to some other Ada compiler, no
11822 special attention is required unless the @samp{shared=@var{xxx}} form
11823 parameter is used in the program. In this case, you must examine the
11824 documentation of the new compiler to see if it supports the required
11825 file sharing semantics, and form strings modified appropriately. Of
11826 course it may be the case that the program cannot be ported if the
11827 target compiler does not support the required functionality. The best
11828 approach in writing portable code is to avoid file sharing (and hence
11829 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11832 One common use of file sharing in Ada 83 is the use of instantiations of
11833 Sequential_IO on the same file with different types, to achieve
11834 heterogeneous input-output. Although this approach will work in GNAT if
11835 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11836 for this purpose (using the stream attributes)
11839 @section Open Modes
11842 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11843 using the mode shown in the following table:
11846 @center @code{Open} and @code{Create} Call Modes
11848 @b{OPEN } @b{CREATE}
11849 Append_File "r+" "w+"
11851 Out_File (Direct_IO) "r+" "w"
11852 Out_File (all other cases) "w" "w"
11853 Inout_File "r+" "w+"
11857 If text file translation is required, then either @samp{b} or @samp{t}
11858 is added to the mode, depending on the setting of Text. Text file
11859 translation refers to the mapping of CR/LF sequences in an external file
11860 to LF characters internally. This mapping only occurs in DOS and
11861 DOS-like systems, and is not relevant to other systems.
11863 A special case occurs with Stream_IO@. As shown in the above table, the
11864 file is initially opened in @samp{r} or @samp{w} mode for the
11865 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
11866 subsequently requires switching from reading to writing or vice-versa,
11867 then the file is reopened in @samp{r+} mode to permit the required operation.
11869 @node Operations on C Streams
11870 @section Operations on C Streams
11871 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11872 access to the C library functions for operations on C streams:
11874 @smallexample @c adanocomment
11875 package Interfaces.C_Streams is
11876 -- Note: the reason we do not use the types that are in
11877 -- Interfaces.C is that we want to avoid dragging in the
11878 -- code in this unit if possible.
11879 subtype chars is System.Address;
11880 -- Pointer to null-terminated array of characters
11881 subtype FILEs is System.Address;
11882 -- Corresponds to the C type FILE*
11883 subtype voids is System.Address;
11884 -- Corresponds to the C type void*
11885 subtype int is Integer;
11886 subtype long is Long_Integer;
11887 -- Note: the above types are subtypes deliberately, and it
11888 -- is part of this spec that the above correspondences are
11889 -- guaranteed. This means that it is legitimate to, for
11890 -- example, use Integer instead of int. We provide these
11891 -- synonyms for clarity, but in some cases it may be
11892 -- convenient to use the underlying types (for example to
11893 -- avoid an unnecessary dependency of a spec on the spec
11895 type size_t is mod 2 ** Standard'Address_Size;
11896 NULL_Stream : constant FILEs;
11897 -- Value returned (NULL in C) to indicate an
11898 -- fdopen/fopen/tmpfile error
11899 ----------------------------------
11900 -- Constants Defined in stdio.h --
11901 ----------------------------------
11902 EOF : constant int;
11903 -- Used by a number of routines to indicate error or
11905 IOFBF : constant int;
11906 IOLBF : constant int;
11907 IONBF : constant int;
11908 -- Used to indicate buffering mode for setvbuf call
11909 SEEK_CUR : constant int;
11910 SEEK_END : constant int;
11911 SEEK_SET : constant int;
11912 -- Used to indicate origin for fseek call
11913 function stdin return FILEs;
11914 function stdout return FILEs;
11915 function stderr return FILEs;
11916 -- Streams associated with standard files
11917 --------------------------
11918 -- Standard C functions --
11919 --------------------------
11920 -- The functions selected below are ones that are
11921 -- available in DOS, OS/2, UNIX and Xenix (but not
11922 -- necessarily in ANSI C). These are very thin interfaces
11923 -- which copy exactly the C headers. For more
11924 -- documentation on these functions, see the Microsoft C
11925 -- "Run-Time Library Reference" (Microsoft Press, 1990,
11926 -- ISBN 1-55615-225-6), which includes useful information
11927 -- on system compatibility.
11928 procedure clearerr (stream : FILEs);
11929 function fclose (stream : FILEs) return int;
11930 function fdopen (handle : int; mode : chars) return FILEs;
11931 function feof (stream : FILEs) return int;
11932 function ferror (stream : FILEs) return int;
11933 function fflush (stream : FILEs) return int;
11934 function fgetc (stream : FILEs) return int;
11935 function fgets (strng : chars; n : int; stream : FILEs)
11937 function fileno (stream : FILEs) return int;
11938 function fopen (filename : chars; Mode : chars)
11940 -- Note: to maintain target independence, use
11941 -- text_translation_required, a boolean variable defined in
11942 -- a-sysdep.c to deal with the target dependent text
11943 -- translation requirement. If this variable is set,
11944 -- then b/t should be appended to the standard mode
11945 -- argument to set the text translation mode off or on
11947 function fputc (C : int; stream : FILEs) return int;
11948 function fputs (Strng : chars; Stream : FILEs) return int;
11965 function ftell (stream : FILEs) return long;
11972 function isatty (handle : int) return int;
11973 procedure mktemp (template : chars);
11974 -- The return value (which is just a pointer to template)
11976 procedure rewind (stream : FILEs);
11977 function rmtmp return int;
11985 function tmpfile return FILEs;
11986 function ungetc (c : int; stream : FILEs) return int;
11987 function unlink (filename : chars) return int;
11988 ---------------------
11989 -- Extra functions --
11990 ---------------------
11991 -- These functions supply slightly thicker bindings than
11992 -- those above. They are derived from functions in the
11993 -- C Run-Time Library, but may do a bit more work than
11994 -- just directly calling one of the Library functions.
11995 function is_regular_file (handle : int) return int;
11996 -- Tests if given handle is for a regular file (result 1)
11997 -- or for a non-regular file (pipe or device, result 0).
11998 ---------------------------------
11999 -- Control of Text/Binary Mode --
12000 ---------------------------------
12001 -- If text_translation_required is true, then the following
12002 -- functions may be used to dynamically switch a file from
12003 -- binary to text mode or vice versa. These functions have
12004 -- no effect if text_translation_required is false (i.e. in
12005 -- normal UNIX mode). Use fileno to get a stream handle.
12006 procedure set_binary_mode (handle : int);
12007 procedure set_text_mode (handle : int);
12008 ----------------------------
12009 -- Full Path Name support --
12010 ----------------------------
12011 procedure full_name (nam : chars; buffer : chars);
12012 -- Given a NUL terminated string representing a file
12013 -- name, returns in buffer a NUL terminated string
12014 -- representing the full path name for the file name.
12015 -- On systems where it is relevant the drive is also
12016 -- part of the full path name. It is the responsibility
12017 -- of the caller to pass an actual parameter for buffer
12018 -- that is big enough for any full path name. Use
12019 -- max_path_len given below as the size of buffer.
12020 max_path_len : integer;
12021 -- Maximum length of an allowable full path name on the
12022 -- system, including a terminating NUL character.
12023 end Interfaces.C_Streams;
12026 @node Interfacing to C Streams
12027 @section Interfacing to C Streams
12030 The packages in this section permit interfacing Ada files to C Stream
12033 @smallexample @c ada
12034 with Interfaces.C_Streams;
12035 package Ada.Sequential_IO.C_Streams is
12036 function C_Stream (F : File_Type)
12037 return Interfaces.C_Streams.FILEs;
12039 (File : in out File_Type;
12040 Mode : in File_Mode;
12041 C_Stream : in Interfaces.C_Streams.FILEs;
12042 Form : in String := "");
12043 end Ada.Sequential_IO.C_Streams;
12045 with Interfaces.C_Streams;
12046 package Ada.Direct_IO.C_Streams is
12047 function C_Stream (F : File_Type)
12048 return Interfaces.C_Streams.FILEs;
12050 (File : in out File_Type;
12051 Mode : in File_Mode;
12052 C_Stream : in Interfaces.C_Streams.FILEs;
12053 Form : in String := "");
12054 end Ada.Direct_IO.C_Streams;
12056 with Interfaces.C_Streams;
12057 package Ada.Text_IO.C_Streams is
12058 function C_Stream (F : File_Type)
12059 return Interfaces.C_Streams.FILEs;
12061 (File : in out File_Type;
12062 Mode : in File_Mode;
12063 C_Stream : in Interfaces.C_Streams.FILEs;
12064 Form : in String := "");
12065 end Ada.Text_IO.C_Streams;
12067 with Interfaces.C_Streams;
12068 package Ada.Wide_Text_IO.C_Streams is
12069 function C_Stream (F : File_Type)
12070 return Interfaces.C_Streams.FILEs;
12072 (File : in out File_Type;
12073 Mode : in File_Mode;
12074 C_Stream : in Interfaces.C_Streams.FILEs;
12075 Form : in String := "");
12076 end Ada.Wide_Text_IO.C_Streams;
12078 with Interfaces.C_Streams;
12079 package Ada.Wide_Wide_Text_IO.C_Streams is
12080 function C_Stream (F : File_Type)
12081 return Interfaces.C_Streams.FILEs;
12083 (File : in out File_Type;
12084 Mode : in File_Mode;
12085 C_Stream : in Interfaces.C_Streams.FILEs;
12086 Form : in String := "");
12087 end Ada.Wide_Wide_Text_IO.C_Streams;
12089 with Interfaces.C_Streams;
12090 package Ada.Stream_IO.C_Streams is
12091 function C_Stream (F : File_Type)
12092 return Interfaces.C_Streams.FILEs;
12094 (File : in out File_Type;
12095 Mode : in File_Mode;
12096 C_Stream : in Interfaces.C_Streams.FILEs;
12097 Form : in String := "");
12098 end Ada.Stream_IO.C_Streams;
12102 In each of these six packages, the @code{C_Stream} function obtains the
12103 @code{FILE} pointer from a currently opened Ada file. It is then
12104 possible to use the @code{Interfaces.C_Streams} package to operate on
12105 this stream, or the stream can be passed to a C program which can
12106 operate on it directly. Of course the program is responsible for
12107 ensuring that only appropriate sequences of operations are executed.
12109 One particular use of relevance to an Ada program is that the
12110 @code{setvbuf} function can be used to control the buffering of the
12111 stream used by an Ada file. In the absence of such a call the standard
12112 default buffering is used.
12114 The @code{Open} procedures in these packages open a file giving an
12115 existing C Stream instead of a file name. Typically this stream is
12116 imported from a C program, allowing an Ada file to operate on an
12119 @node The GNAT Library
12120 @chapter The GNAT Library
12123 The GNAT library contains a number of general and special purpose packages.
12124 It represents functionality that the GNAT developers have found useful, and
12125 which is made available to GNAT users. The packages described here are fully
12126 supported, and upwards compatibility will be maintained in future releases,
12127 so you can use these facilities with the confidence that the same functionality
12128 will be available in future releases.
12130 The chapter here simply gives a brief summary of the facilities available.
12131 The full documentation is found in the spec file for the package. The full
12132 sources of these library packages, including both spec and body, are provided
12133 with all GNAT releases. For example, to find out the full specifications of
12134 the SPITBOL pattern matching capability, including a full tutorial and
12135 extensive examples, look in the @file{g-spipat.ads} file in the library.
12137 For each entry here, the package name (as it would appear in a @code{with}
12138 clause) is given, followed by the name of the corresponding spec file in
12139 parentheses. The packages are children in four hierarchies, @code{Ada},
12140 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
12141 GNAT-specific hierarchy.
12143 Note that an application program should only use packages in one of these
12144 four hierarchies if the package is defined in the Ada Reference Manual,
12145 or is listed in this section of the GNAT Programmers Reference Manual.
12146 All other units should be considered internal implementation units and
12147 should not be directly @code{with}'ed by application code. The use of
12148 a @code{with} statement that references one of these internal implementation
12149 units makes an application potentially dependent on changes in versions
12150 of GNAT, and will generate a warning message.
12153 * Ada.Characters.Latin_9 (a-chlat9.ads)::
12154 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
12155 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
12156 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
12157 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
12158 * Ada.Command_Line.Remove (a-colire.ads)::
12159 * Ada.Command_Line.Environment (a-colien.ads)::
12160 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
12161 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
12162 * Ada.Exceptions.Traceback (a-exctra.ads)::
12163 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
12164 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
12165 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
12166 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
12167 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
12168 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
12169 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
12170 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
12171 * GNAT.Altivec (g-altive.ads)::
12172 * GNAT.Altivec.Conversions (g-altcon.ads)::
12173 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
12174 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
12175 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
12176 * GNAT.Array_Split (g-arrspl.ads)::
12177 * GNAT.AWK (g-awk.ads)::
12178 * GNAT.Bounded_Buffers (g-boubuf.ads)::
12179 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
12180 * GNAT.Bubble_Sort (g-bubsor.ads)::
12181 * GNAT.Bubble_Sort_A (g-busora.ads)::
12182 * GNAT.Bubble_Sort_G (g-busorg.ads)::
12183 * GNAT.Calendar (g-calend.ads)::
12184 * GNAT.Calendar.Time_IO (g-catiio.ads)::
12185 * GNAT.CRC32 (g-crc32.ads)::
12186 * GNAT.Case_Util (g-casuti.ads)::
12187 * GNAT.CGI (g-cgi.ads)::
12188 * GNAT.CGI.Cookie (g-cgicoo.ads)::
12189 * GNAT.CGI.Debug (g-cgideb.ads)::
12190 * GNAT.Command_Line (g-comlin.ads)::
12191 * GNAT.Compiler_Version (g-comver.ads)::
12192 * GNAT.Ctrl_C (g-ctrl_c.ads)::
12193 * GNAT.Current_Exception (g-curexc.ads)::
12194 * GNAT.Debug_Pools (g-debpoo.ads)::
12195 * GNAT.Debug_Utilities (g-debuti.ads)::
12196 * GNAT.Directory_Operations (g-dirope.ads)::
12197 * GNAT.Dynamic_HTables (g-dynhta.ads)::
12198 * GNAT.Dynamic_Tables (g-dyntab.ads)::
12199 * GNAT.Exception_Actions (g-excact.ads)::
12200 * GNAT.Exception_Traces (g-exctra.ads)::
12201 * GNAT.Exceptions (g-except.ads)::
12202 * GNAT.Expect (g-expect.ads)::
12203 * GNAT.Float_Control (g-flocon.ads)::
12204 * GNAT.Heap_Sort (g-heasor.ads)::
12205 * GNAT.Heap_Sort_A (g-hesora.ads)::
12206 * GNAT.Heap_Sort_G (g-hesorg.ads)::
12207 * GNAT.HTable (g-htable.ads)::
12208 * GNAT.IO (g-io.ads)::
12209 * GNAT.IO_Aux (g-io_aux.ads)::
12210 * GNAT.Lock_Files (g-locfil.ads)::
12211 * GNAT.MD5 (g-md5.ads)::
12212 * GNAT.Memory_Dump (g-memdum.ads)::
12213 * GNAT.Most_Recent_Exception (g-moreex.ads)::
12214 * GNAT.OS_Lib (g-os_lib.ads)::
12215 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
12216 * GNAT.Regexp (g-regexp.ads)::
12217 * GNAT.Registry (g-regist.ads)::
12218 * GNAT.Regpat (g-regpat.ads)::
12219 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
12220 * GNAT.Semaphores (g-semaph.ads)::
12221 * GNAT.Signals (g-signal.ads)::
12222 * GNAT.Sockets (g-socket.ads)::
12223 * GNAT.Source_Info (g-souinf.ads)::
12224 * GNAT.Spell_Checker (g-speche.ads)::
12225 * GNAT.Spitbol.Patterns (g-spipat.ads)::
12226 * GNAT.Spitbol (g-spitbo.ads)::
12227 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
12228 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
12229 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
12230 * GNAT.Strings (g-string.ads)::
12231 * GNAT.String_Split (g-strspl.ads)::
12232 * GNAT.UTF_32 (g-utf_32.ads)::
12233 * GNAT.Table (g-table.ads)::
12234 * GNAT.Task_Lock (g-tasloc.ads)::
12235 * GNAT.Threads (g-thread.ads)::
12236 * GNAT.Traceback (g-traceb.ads)::
12237 * GNAT.Traceback.Symbolic (g-trasym.ads)::
12238 * GNAT.Wide_String_Split (g-wistsp.ads)::
12239 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
12240 * Interfaces.C.Extensions (i-cexten.ads)::
12241 * Interfaces.C.Streams (i-cstrea.ads)::
12242 * Interfaces.CPP (i-cpp.ads)::
12243 * Interfaces.Os2lib (i-os2lib.ads)::
12244 * Interfaces.Os2lib.Errors (i-os2err.ads)::
12245 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
12246 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
12247 * Interfaces.Packed_Decimal (i-pacdec.ads)::
12248 * Interfaces.VxWorks (i-vxwork.ads)::
12249 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
12250 * System.Address_Image (s-addima.ads)::
12251 * System.Assertions (s-assert.ads)::
12252 * System.Memory (s-memory.ads)::
12253 * System.Partition_Interface (s-parint.ads)::
12254 * System.Restrictions (s-restri.ads)::
12255 * System.Rident (s-rident.ads)::
12256 * System.Task_Info (s-tasinf.ads)::
12257 * System.Wch_Cnv (s-wchcnv.ads)::
12258 * System.Wch_Con (s-wchcon.ads)::
12261 @node Ada.Characters.Latin_9 (a-chlat9.ads)
12262 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12263 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12264 @cindex Latin_9 constants for Character
12267 This child of @code{Ada.Characters}
12268 provides a set of definitions corresponding to those in the
12269 RM-defined package @code{Ada.Characters.Latin_1} but with the
12270 few modifications required for @code{Latin-9}
12271 The provision of such a package
12272 is specifically authorized by the Ada Reference Manual
12275 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
12276 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12277 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12278 @cindex Latin_1 constants for Wide_Character
12281 This child of @code{Ada.Characters}
12282 provides a set of definitions corresponding to those in the
12283 RM-defined package @code{Ada.Characters.Latin_1} but with the
12284 types of the constants being @code{Wide_Character}
12285 instead of @code{Character}. The provision of such a package
12286 is specifically authorized by the Ada Reference Manual
12289 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
12290 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12291 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12292 @cindex Latin_9 constants for Wide_Character
12295 This child of @code{Ada.Characters}
12296 provides a set of definitions corresponding to those in the
12297 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12298 types of the constants being @code{Wide_Character}
12299 instead of @code{Character}. The provision of such a package
12300 is specifically authorized by the Ada Reference Manual
12303 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
12304 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12305 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12306 @cindex Latin_1 constants for Wide_Wide_Character
12309 This child of @code{Ada.Characters}
12310 provides a set of definitions corresponding to those in the
12311 RM-defined package @code{Ada.Characters.Latin_1} but with the
12312 types of the constants being @code{Wide_Wide_Character}
12313 instead of @code{Character}. The provision of such a package
12314 is specifically authorized by the Ada Reference Manual
12317 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
12318 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12319 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12320 @cindex Latin_9 constants for Wide_Wide_Character
12323 This child of @code{Ada.Characters}
12324 provides a set of definitions corresponding to those in the
12325 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12326 types of the constants being @code{Wide_Wide_Character}
12327 instead of @code{Character}. The provision of such a package
12328 is specifically authorized by the Ada Reference Manual
12331 @node Ada.Command_Line.Remove (a-colire.ads)
12332 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12333 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12334 @cindex Removing command line arguments
12335 @cindex Command line, argument removal
12338 This child of @code{Ada.Command_Line}
12339 provides a mechanism for logically removing
12340 arguments from the argument list. Once removed, an argument is not visible
12341 to further calls on the subprograms in @code{Ada.Command_Line} will not
12342 see the removed argument.
12344 @node Ada.Command_Line.Environment (a-colien.ads)
12345 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12346 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12347 @cindex Environment entries
12350 This child of @code{Ada.Command_Line}
12351 provides a mechanism for obtaining environment values on systems
12352 where this concept makes sense.
12354 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12355 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12356 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12357 @cindex C Streams, Interfacing with Direct_IO
12360 This package provides subprograms that allow interfacing between
12361 C streams and @code{Direct_IO}. The stream identifier can be
12362 extracted from a file opened on the Ada side, and an Ada file
12363 can be constructed from a stream opened on the C side.
12365 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12366 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12367 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12368 @cindex Null_Occurrence, testing for
12371 This child subprogram provides a way of testing for the null
12372 exception occurrence (@code{Null_Occurrence}) without raising
12375 @node Ada.Exceptions.Traceback (a-exctra.ads)
12376 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12377 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12378 @cindex Traceback for Exception Occurrence
12381 This child package provides the subprogram (@code{Tracebacks}) to
12382 give a traceback array of addresses based on an exception
12385 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12386 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12387 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12388 @cindex C Streams, Interfacing with Sequential_IO
12391 This package provides subprograms that allow interfacing between
12392 C streams and @code{Sequential_IO}. The stream identifier can be
12393 extracted from a file opened on the Ada side, and an Ada file
12394 can be constructed from a stream opened on the C side.
12396 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12397 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12398 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12399 @cindex C Streams, Interfacing with Stream_IO
12402 This package provides subprograms that allow interfacing between
12403 C streams and @code{Stream_IO}. The stream identifier can be
12404 extracted from a file opened on the Ada side, and an Ada file
12405 can be constructed from a stream opened on the C side.
12407 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
12408 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12409 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12410 @cindex @code{Unbounded_String}, IO support
12411 @cindex @code{Text_IO}, extensions for unbounded strings
12414 This package provides subprograms for Text_IO for unbounded
12415 strings, avoiding the necessity for an intermediate operation
12416 with ordinary strings.
12418 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
12419 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12420 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12421 @cindex @code{Unbounded_Wide_String}, IO support
12422 @cindex @code{Text_IO}, extensions for unbounded wide strings
12425 This package provides subprograms for Text_IO for unbounded
12426 wide strings, avoiding the necessity for an intermediate operation
12427 with ordinary wide strings.
12429 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
12430 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12431 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12432 @cindex @code{Unbounded_Wide_Wide_String}, IO support
12433 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
12436 This package provides subprograms for Text_IO for unbounded
12437 wide wide strings, avoiding the necessity for an intermediate operation
12438 with ordinary wide wide strings.
12440 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
12441 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12442 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12443 @cindex C Streams, Interfacing with @code{Text_IO}
12446 This package provides subprograms that allow interfacing between
12447 C streams and @code{Text_IO}. The stream identifier can be
12448 extracted from a file opened on the Ada side, and an Ada file
12449 can be constructed from a stream opened on the C side.
12451 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
12452 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12453 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12454 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
12457 This package provides subprograms that allow interfacing between
12458 C streams and @code{Wide_Text_IO}. The stream identifier can be
12459 extracted from a file opened on the Ada side, and an Ada file
12460 can be constructed from a stream opened on the C side.
12462 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
12463 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12464 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12465 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
12468 This package provides subprograms that allow interfacing between
12469 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
12470 extracted from a file opened on the Ada side, and an Ada file
12471 can be constructed from a stream opened on the C side.
12473 @node GNAT.Altivec (g-altive.ads)
12474 @section @code{GNAT.Altivec} (@file{g-altive.ads})
12475 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
12479 This is the root package of the GNAT AltiVec binding. It provides
12480 definitions of constants and types common to all the versions of the
12483 @node GNAT.Altivec.Conversions (g-altcon.ads)
12484 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12485 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12489 This package provides the Vector/View conversion routines.
12491 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
12492 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12493 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12497 This package exposes the Ada interface to the AltiVec operations on
12498 vector objects. A soft emulation is included by default in the GNAT
12499 library. The hard binding is provided as a separate package. This unit
12500 is common to both bindings.
12502 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
12503 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12504 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12508 This package exposes the various vector types part of the Ada binding
12509 to AltiVec facilities.
12511 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
12512 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12513 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12517 This package provides public 'View' data types from/to which private
12518 vector representations can be converted via
12519 GNAT.Altivec.Conversions. This allows convenient access to individual
12520 vector elements and provides a simple way to initialize vector
12523 @node GNAT.Array_Split (g-arrspl.ads)
12524 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12525 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12526 @cindex Array splitter
12529 Useful array-manipulation routines: given a set of separators, split
12530 an array wherever the separators appear, and provide direct access
12531 to the resulting slices.
12533 @node GNAT.AWK (g-awk.ads)
12534 @section @code{GNAT.AWK} (@file{g-awk.ads})
12535 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
12540 Provides AWK-like parsing functions, with an easy interface for parsing one
12541 or more files containing formatted data. The file is viewed as a database
12542 where each record is a line and a field is a data element in this line.
12544 @node GNAT.Bounded_Buffers (g-boubuf.ads)
12545 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12546 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12548 @cindex Bounded Buffers
12551 Provides a concurrent generic bounded buffer abstraction. Instances are
12552 useful directly or as parts of the implementations of other abstractions,
12555 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
12556 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12557 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12562 Provides a thread-safe asynchronous intertask mailbox communication facility.
12564 @node GNAT.Bubble_Sort (g-bubsor.ads)
12565 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12566 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12568 @cindex Bubble sort
12571 Provides a general implementation of bubble sort usable for sorting arbitrary
12572 data items. Exchange and comparison procedures are provided by passing
12573 access-to-procedure values.
12575 @node GNAT.Bubble_Sort_A (g-busora.ads)
12576 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12577 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12579 @cindex Bubble sort
12582 Provides a general implementation of bubble sort usable for sorting arbitrary
12583 data items. Move and comparison procedures are provided by passing
12584 access-to-procedure values. This is an older version, retained for
12585 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
12587 @node GNAT.Bubble_Sort_G (g-busorg.ads)
12588 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12589 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12591 @cindex Bubble sort
12594 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
12595 are provided as generic parameters, this improves efficiency, especially
12596 if the procedures can be inlined, at the expense of duplicating code for
12597 multiple instantiations.
12599 @node GNAT.Calendar (g-calend.ads)
12600 @section @code{GNAT.Calendar} (@file{g-calend.ads})
12601 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
12602 @cindex @code{Calendar}
12605 Extends the facilities provided by @code{Ada.Calendar} to include handling
12606 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
12607 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
12608 C @code{timeval} format.
12610 @node GNAT.Calendar.Time_IO (g-catiio.ads)
12611 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12612 @cindex @code{Calendar}
12614 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12616 @node GNAT.CRC32 (g-crc32.ads)
12617 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
12618 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
12620 @cindex Cyclic Redundancy Check
12623 This package implements the CRC-32 algorithm. For a full description
12624 of this algorithm see
12625 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
12626 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
12627 Aug.@: 1988. Sarwate, D.V@.
12630 Provides an extended capability for formatted output of time values with
12631 full user control over the format. Modeled on the GNU Date specification.
12633 @node GNAT.Case_Util (g-casuti.ads)
12634 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
12635 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
12636 @cindex Casing utilities
12637 @cindex Character handling (@code{GNAT.Case_Util})
12640 A set of simple routines for handling upper and lower casing of strings
12641 without the overhead of the full casing tables
12642 in @code{Ada.Characters.Handling}.
12644 @node GNAT.CGI (g-cgi.ads)
12645 @section @code{GNAT.CGI} (@file{g-cgi.ads})
12646 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
12647 @cindex CGI (Common Gateway Interface)
12650 This is a package for interfacing a GNAT program with a Web server via the
12651 Common Gateway Interface (CGI)@. Basically this package parses the CGI
12652 parameters, which are a set of key/value pairs sent by the Web server. It
12653 builds a table whose index is the key and provides some services to deal
12656 @node GNAT.CGI.Cookie (g-cgicoo.ads)
12657 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12658 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12659 @cindex CGI (Common Gateway Interface) cookie support
12660 @cindex Cookie support in CGI
12663 This is a package to interface a GNAT program with a Web server via the
12664 Common Gateway Interface (CGI). It exports services to deal with Web
12665 cookies (piece of information kept in the Web client software).
12667 @node GNAT.CGI.Debug (g-cgideb.ads)
12668 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12669 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12670 @cindex CGI (Common Gateway Interface) debugging
12673 This is a package to help debugging CGI (Common Gateway Interface)
12674 programs written in Ada.
12676 @node GNAT.Command_Line (g-comlin.ads)
12677 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
12678 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
12679 @cindex Command line
12682 Provides a high level interface to @code{Ada.Command_Line} facilities,
12683 including the ability to scan for named switches with optional parameters
12684 and expand file names using wild card notations.
12686 @node GNAT.Compiler_Version (g-comver.ads)
12687 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12688 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12689 @cindex Compiler Version
12690 @cindex Version, of compiler
12693 Provides a routine for obtaining the version of the compiler used to
12694 compile the program. More accurately this is the version of the binder
12695 used to bind the program (this will normally be the same as the version
12696 of the compiler if a consistent tool set is used to compile all units
12699 @node GNAT.Ctrl_C (g-ctrl_c.ads)
12700 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12701 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12705 Provides a simple interface to handle Ctrl-C keyboard events.
12707 @node GNAT.Current_Exception (g-curexc.ads)
12708 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12709 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12710 @cindex Current exception
12711 @cindex Exception retrieval
12714 Provides access to information on the current exception that has been raised
12715 without the need for using the Ada-95 exception choice parameter specification
12716 syntax. This is particularly useful in simulating typical facilities for
12717 obtaining information about exceptions provided by Ada 83 compilers.
12719 @node GNAT.Debug_Pools (g-debpoo.ads)
12720 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12721 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12723 @cindex Debug pools
12724 @cindex Memory corruption debugging
12727 Provide a debugging storage pools that helps tracking memory corruption
12728 problems. See section ``Finding memory problems with GNAT Debug Pool'' in
12729 the @cite{GNAT User's Guide}.
12731 @node GNAT.Debug_Utilities (g-debuti.ads)
12732 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12733 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12737 Provides a few useful utilities for debugging purposes, including conversion
12738 to and from string images of address values. Supports both C and Ada formats
12739 for hexadecimal literals.
12741 @node GNAT.Directory_Operations (g-dirope.ads)
12742 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
12743 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
12744 @cindex Directory operations
12747 Provides a set of routines for manipulating directories, including changing
12748 the current directory, making new directories, and scanning the files in a
12751 @node GNAT.Dynamic_HTables (g-dynhta.ads)
12752 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12753 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12754 @cindex Hash tables
12757 A generic implementation of hash tables that can be used to hash arbitrary
12758 data. Provided in two forms, a simple form with built in hash functions,
12759 and a more complex form in which the hash function is supplied.
12762 This package provides a facility similar to that of @code{GNAT.HTable},
12763 except that this package declares a type that can be used to define
12764 dynamic instances of the hash table, while an instantiation of
12765 @code{GNAT.HTable} creates a single instance of the hash table.
12767 @node GNAT.Dynamic_Tables (g-dyntab.ads)
12768 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12769 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12770 @cindex Table implementation
12771 @cindex Arrays, extendable
12774 A generic package providing a single dimension array abstraction where the
12775 length of the array can be dynamically modified.
12778 This package provides a facility similar to that of @code{GNAT.Table},
12779 except that this package declares a type that can be used to define
12780 dynamic instances of the table, while an instantiation of
12781 @code{GNAT.Table} creates a single instance of the table type.
12783 @node GNAT.Exception_Actions (g-excact.ads)
12784 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
12785 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
12786 @cindex Exception actions
12789 Provides callbacks when an exception is raised. Callbacks can be registered
12790 for specific exceptions, or when any exception is raised. This
12791 can be used for instance to force a core dump to ease debugging.
12793 @node GNAT.Exception_Traces (g-exctra.ads)
12794 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
12795 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
12796 @cindex Exception traces
12800 Provides an interface allowing to control automatic output upon exception
12803 @node GNAT.Exceptions (g-except.ads)
12804 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
12805 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
12806 @cindex Exceptions, Pure
12807 @cindex Pure packages, exceptions
12810 Normally it is not possible to raise an exception with
12811 a message from a subprogram in a pure package, since the
12812 necessary types and subprograms are in @code{Ada.Exceptions}
12813 which is not a pure unit. @code{GNAT.Exceptions} provides a
12814 facility for getting around this limitation for a few
12815 predefined exceptions, and for example allow raising
12816 @code{Constraint_Error} with a message from a pure subprogram.
12818 @node GNAT.Expect (g-expect.ads)
12819 @section @code{GNAT.Expect} (@file{g-expect.ads})
12820 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
12823 Provides a set of subprograms similar to what is available
12824 with the standard Tcl Expect tool.
12825 It allows you to easily spawn and communicate with an external process.
12826 You can send commands or inputs to the process, and compare the output
12827 with some expected regular expression. Currently @code{GNAT.Expect}
12828 is implemented on all native GNAT ports except for OpenVMS@.
12829 It is not implemented for cross ports, and in particular is not
12830 implemented for VxWorks or LynxOS@.
12832 @node GNAT.Float_Control (g-flocon.ads)
12833 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
12834 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
12835 @cindex Floating-Point Processor
12838 Provides an interface for resetting the floating-point processor into the
12839 mode required for correct semantic operation in Ada. Some third party
12840 library calls may cause this mode to be modified, and the Reset procedure
12841 in this package can be used to reestablish the required mode.
12843 @node GNAT.Heap_Sort (g-heasor.ads)
12844 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12845 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12849 Provides a general implementation of heap sort usable for sorting arbitrary
12850 data items. Exchange and comparison procedures are provided by passing
12851 access-to-procedure values. The algorithm used is a modified heap sort
12852 that performs approximately N*log(N) comparisons in the worst case.
12854 @node GNAT.Heap_Sort_A (g-hesora.ads)
12855 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12856 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12860 Provides a general implementation of heap sort usable for sorting arbitrary
12861 data items. Move and comparison procedures are provided by passing
12862 access-to-procedure values. The algorithm used is a modified heap sort
12863 that performs approximately N*log(N) comparisons in the worst case.
12864 This differs from @code{GNAT.Heap_Sort} in having a less convenient
12865 interface, but may be slightly more efficient.
12867 @node GNAT.Heap_Sort_G (g-hesorg.ads)
12868 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12869 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12873 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
12874 are provided as generic parameters, this improves efficiency, especially
12875 if the procedures can be inlined, at the expense of duplicating code for
12876 multiple instantiations.
12878 @node GNAT.HTable (g-htable.ads)
12879 @section @code{GNAT.HTable} (@file{g-htable.ads})
12880 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
12881 @cindex Hash tables
12884 A generic implementation of hash tables that can be used to hash arbitrary
12885 data. Provides two approaches, one a simple static approach, and the other
12886 allowing arbitrary dynamic hash tables.
12888 @node GNAT.IO (g-io.ads)
12889 @section @code{GNAT.IO} (@file{g-io.ads})
12890 @cindex @code{GNAT.IO} (@file{g-io.ads})
12892 @cindex Input/Output facilities
12895 A simple preelaborable input-output package that provides a subset of
12896 simple Text_IO functions for reading characters and strings from
12897 Standard_Input, and writing characters, strings and integers to either
12898 Standard_Output or Standard_Error.
12900 @node GNAT.IO_Aux (g-io_aux.ads)
12901 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12902 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12904 @cindex Input/Output facilities
12906 Provides some auxiliary functions for use with Text_IO, including a test
12907 for whether a file exists, and functions for reading a line of text.
12909 @node GNAT.Lock_Files (g-locfil.ads)
12910 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12911 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12912 @cindex File locking
12913 @cindex Locking using files
12916 Provides a general interface for using files as locks. Can be used for
12917 providing program level synchronization.
12919 @node GNAT.MD5 (g-md5.ads)
12920 @section @code{GNAT.MD5} (@file{g-md5.ads})
12921 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12922 @cindex Message Digest MD5
12925 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12927 @node GNAT.Memory_Dump (g-memdum.ads)
12928 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12929 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12930 @cindex Dump Memory
12933 Provides a convenient routine for dumping raw memory to either the
12934 standard output or standard error files. Uses GNAT.IO for actual
12937 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12938 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12939 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12940 @cindex Exception, obtaining most recent
12943 Provides access to the most recently raised exception. Can be used for
12944 various logging purposes, including duplicating functionality of some
12945 Ada 83 implementation dependent extensions.
12947 @node GNAT.OS_Lib (g-os_lib.ads)
12948 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12949 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12950 @cindex Operating System interface
12951 @cindex Spawn capability
12954 Provides a range of target independent operating system interface functions,
12955 including time/date management, file operations, subprocess management,
12956 including a portable spawn procedure, and access to environment variables
12957 and error return codes.
12959 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
12960 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
12961 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
12962 @cindex Hash functions
12965 Provides a generator of static minimal perfect hash functions. No
12966 collisions occur and each item can be retrieved from the table in one
12967 probe (perfect property). The hash table size corresponds to the exact
12968 size of the key set and no larger (minimal property). The key set has to
12969 be know in advance (static property). The hash functions are also order
12970 preserving. If w2 is inserted after w1 in the generator, their
12971 hashcode are in the same order. These hashing functions are very
12972 convenient for use with realtime applications.
12974 @node GNAT.Regexp (g-regexp.ads)
12975 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12976 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12977 @cindex Regular expressions
12978 @cindex Pattern matching
12981 A simple implementation of regular expressions, using a subset of regular
12982 expression syntax copied from familiar Unix style utilities. This is the
12983 simples of the three pattern matching packages provided, and is particularly
12984 suitable for ``file globbing'' applications.
12986 @node GNAT.Registry (g-regist.ads)
12987 @section @code{GNAT.Registry} (@file{g-regist.ads})
12988 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12989 @cindex Windows Registry
12992 This is a high level binding to the Windows registry. It is possible to
12993 do simple things like reading a key value, creating a new key. For full
12994 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12995 package provided with the Win32Ada binding
12997 @node GNAT.Regpat (g-regpat.ads)
12998 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12999 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
13000 @cindex Regular expressions
13001 @cindex Pattern matching
13004 A complete implementation of Unix-style regular expression matching, copied
13005 from the original V7 style regular expression library written in C by
13006 Henry Spencer (and binary compatible with this C library).
13008 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
13009 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13010 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13011 @cindex Secondary Stack Info
13014 Provide the capability to query the high water mark of the current task's
13017 @node GNAT.Semaphores (g-semaph.ads)
13018 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
13019 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
13023 Provides classic counting and binary semaphores using protected types.
13025 @node GNAT.Signals (g-signal.ads)
13026 @section @code{GNAT.Signals} (@file{g-signal.ads})
13027 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
13031 Provides the ability to manipulate the blocked status of signals on supported
13034 @node GNAT.Sockets (g-socket.ads)
13035 @section @code{GNAT.Sockets} (@file{g-socket.ads})
13036 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
13040 A high level and portable interface to develop sockets based applications.
13041 This package is based on the sockets thin binding found in
13042 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
13043 on all native GNAT ports except for OpenVMS@. It is not implemented
13044 for the LynxOS@ cross port.
13046 @node GNAT.Source_Info (g-souinf.ads)
13047 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
13048 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
13049 @cindex Source Information
13052 Provides subprograms that give access to source code information known at
13053 compile time, such as the current file name and line number.
13055 @node GNAT.Spell_Checker (g-speche.ads)
13056 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13057 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13058 @cindex Spell checking
13061 Provides a function for determining whether one string is a plausible
13062 near misspelling of another string.
13064 @node GNAT.Spitbol.Patterns (g-spipat.ads)
13065 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13066 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13067 @cindex SPITBOL pattern matching
13068 @cindex Pattern matching
13071 A complete implementation of SNOBOL4 style pattern matching. This is the
13072 most elaborate of the pattern matching packages provided. It fully duplicates
13073 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
13074 efficient algorithm developed by Robert Dewar for the SPITBOL system.
13076 @node GNAT.Spitbol (g-spitbo.ads)
13077 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13078 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13079 @cindex SPITBOL interface
13082 The top level package of the collection of SPITBOL-style functionality, this
13083 package provides basic SNOBOL4 string manipulation functions, such as
13084 Pad, Reverse, Trim, Substr capability, as well as a generic table function
13085 useful for constructing arbitrary mappings from strings in the style of
13086 the SNOBOL4 TABLE function.
13088 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
13089 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13090 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13091 @cindex Sets of strings
13092 @cindex SPITBOL Tables
13095 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13096 for type @code{Standard.Boolean}, giving an implementation of sets of
13099 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
13100 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13101 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13102 @cindex Integer maps
13104 @cindex SPITBOL Tables
13107 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13108 for type @code{Standard.Integer}, giving an implementation of maps
13109 from string to integer values.
13111 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
13112 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13113 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13114 @cindex String maps
13116 @cindex SPITBOL Tables
13119 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
13120 a variable length string type, giving an implementation of general
13121 maps from strings to strings.
13123 @node GNAT.Strings (g-string.ads)
13124 @section @code{GNAT.Strings} (@file{g-string.ads})
13125 @cindex @code{GNAT.Strings} (@file{g-string.ads})
13128 Common String access types and related subprograms. Basically it
13129 defines a string access and an array of string access types.
13131 @node GNAT.String_Split (g-strspl.ads)
13132 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
13133 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
13134 @cindex String splitter
13137 Useful string manipulation routines: given a set of separators, split
13138 a string wherever the separators appear, and provide direct access
13139 to the resulting slices. This package is instantiated from
13140 @code{GNAT.Array_Split}.
13142 @node GNAT.UTF_32 (g-utf_32.ads)
13143 @section @code{GNAT.UTF_32} (@file{g-table.ads})
13144 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
13145 @cindex Wide character codes
13148 This is a package intended to be used in conjunction with the
13149 @code{Wide_Character} type in Ada 95 and the
13150 @code{Wide_Wide_Character} type in Ada 2005 (available
13151 in @code{GNAT} in Ada 2005 mode). This package contains
13152 Unicode categorization routines, as well as lexical
13153 categorization routines corresponding to the Ada 2005
13154 lexical rules for identifiers and strings, and also a
13155 lower case to upper case fold routine corresponding to
13156 the Ada 2005 rules for identifier equivalence.
13158 @node GNAT.Table (g-table.ads)
13159 @section @code{GNAT.Table} (@file{g-table.ads})
13160 @cindex @code{GNAT.Table} (@file{g-table.ads})
13161 @cindex Table implementation
13162 @cindex Arrays, extendable
13165 A generic package providing a single dimension array abstraction where the
13166 length of the array can be dynamically modified.
13169 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
13170 except that this package declares a single instance of the table type,
13171 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
13172 used to define dynamic instances of the table.
13174 @node GNAT.Task_Lock (g-tasloc.ads)
13175 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13176 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13177 @cindex Task synchronization
13178 @cindex Task locking
13182 A very simple facility for locking and unlocking sections of code using a
13183 single global task lock. Appropriate for use in situations where contention
13184 between tasks is very rarely expected.
13186 @node GNAT.Threads (g-thread.ads)
13187 @section @code{GNAT.Threads} (@file{g-thread.ads})
13188 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
13189 @cindex Foreign threads
13190 @cindex Threads, foreign
13193 Provides facilities for creating and destroying threads with explicit calls.
13194 These threads are known to the GNAT run-time system. These subprograms are
13195 exported C-convention procedures intended to be called from foreign code.
13196 By using these primitives rather than directly calling operating systems
13197 routines, compatibility with the Ada tasking run-time is provided.
13199 @node GNAT.Traceback (g-traceb.ads)
13200 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
13201 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
13202 @cindex Trace back facilities
13205 Provides a facility for obtaining non-symbolic traceback information, useful
13206 in various debugging situations.
13208 @node GNAT.Traceback.Symbolic (g-trasym.ads)
13209 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13210 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13211 @cindex Trace back facilities
13214 Provides symbolic traceback information that includes the subprogram
13215 name and line number information.
13217 @node GNAT.Wide_String_Split (g-wistsp.ads)
13218 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13219 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13220 @cindex Wide_String splitter
13223 Useful wide string manipulation routines: given a set of separators, split
13224 a wide string wherever the separators appear, and provide direct access
13225 to the resulting slices. This package is instantiated from
13226 @code{GNAT.Array_Split}.
13228 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
13229 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13230 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13231 @cindex Wide_Wide_String splitter
13234 Useful wide wide string manipulation routines: given a set of separators, split
13235 a wide wide string wherever the separators appear, and provide direct access
13236 to the resulting slices. This package is instantiated from
13237 @code{GNAT.Array_Split}.
13239 @node Interfaces.C.Extensions (i-cexten.ads)
13240 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13241 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13244 This package contains additional C-related definitions, intended
13245 for use with either manually or automatically generated bindings
13248 @node Interfaces.C.Streams (i-cstrea.ads)
13249 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13250 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13251 @cindex C streams, interfacing
13254 This package is a binding for the most commonly used operations
13257 @node Interfaces.CPP (i-cpp.ads)
13258 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
13259 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
13260 @cindex C++ interfacing
13261 @cindex Interfacing, to C++
13264 This package provides facilities for use in interfacing to C++. It
13265 is primarily intended to be used in connection with automated tools
13266 for the generation of C++ interfaces.
13268 @node Interfaces.Os2lib (i-os2lib.ads)
13269 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13270 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13271 @cindex Interfacing, to OS/2
13272 @cindex OS/2 interfacing
13275 This package provides interface definitions to the OS/2 library.
13276 It is a thin binding which is a direct translation of the
13277 various @file{<bse@.h>} files.
13279 @node Interfaces.Os2lib.Errors (i-os2err.ads)
13280 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13281 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13282 @cindex OS/2 Error codes
13283 @cindex Interfacing, to OS/2
13284 @cindex OS/2 interfacing
13287 This package provides definitions of the OS/2 error codes.
13289 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
13290 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13291 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13292 @cindex Interfacing, to OS/2
13293 @cindex Synchronization, OS/2
13294 @cindex OS/2 synchronization primitives
13297 This is a child package that provides definitions for interfacing
13298 to the @code{OS/2} synchronization primitives.
13300 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
13301 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13302 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13303 @cindex Interfacing, to OS/2
13304 @cindex Thread control, OS/2
13305 @cindex OS/2 thread interfacing
13308 This is a child package that provides definitions for interfacing
13309 to the @code{OS/2} thread primitives.
13311 @node Interfaces.Packed_Decimal (i-pacdec.ads)
13312 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13313 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13314 @cindex IBM Packed Format
13315 @cindex Packed Decimal
13318 This package provides a set of routines for conversions to and
13319 from a packed decimal format compatible with that used on IBM
13322 @node Interfaces.VxWorks (i-vxwork.ads)
13323 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13324 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13325 @cindex Interfacing to VxWorks
13326 @cindex VxWorks, interfacing
13329 This package provides a limited binding to the VxWorks API.
13330 In particular, it interfaces with the
13331 VxWorks hardware interrupt facilities.
13333 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
13334 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13335 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13336 @cindex Interfacing to VxWorks' I/O
13337 @cindex VxWorks, I/O interfacing
13338 @cindex VxWorks, Get_Immediate
13339 @cindex Get_Immediate, VxWorks
13342 This package provides a binding to the ioctl (IO/Control)
13343 function of VxWorks, defining a set of option values and
13344 function codes. A particular use of this package is
13345 to enable the use of Get_Immediate under VxWorks.
13347 @node System.Address_Image (s-addima.ads)
13348 @section @code{System.Address_Image} (@file{s-addima.ads})
13349 @cindex @code{System.Address_Image} (@file{s-addima.ads})
13350 @cindex Address image
13351 @cindex Image, of an address
13354 This function provides a useful debugging
13355 function that gives an (implementation dependent)
13356 string which identifies an address.
13358 @node System.Assertions (s-assert.ads)
13359 @section @code{System.Assertions} (@file{s-assert.ads})
13360 @cindex @code{System.Assertions} (@file{s-assert.ads})
13362 @cindex Assert_Failure, exception
13365 This package provides the declaration of the exception raised
13366 by an run-time assertion failure, as well as the routine that
13367 is used internally to raise this assertion.
13369 @node System.Memory (s-memory.ads)
13370 @section @code{System.Memory} (@file{s-memory.ads})
13371 @cindex @code{System.Memory} (@file{s-memory.ads})
13372 @cindex Memory allocation
13375 This package provides the interface to the low level routines used
13376 by the generated code for allocation and freeing storage for the
13377 default storage pool (analogous to the C routines malloc and free.
13378 It also provides a reallocation interface analogous to the C routine
13379 realloc. The body of this unit may be modified to provide alternative
13380 allocation mechanisms for the default pool, and in addition, direct
13381 calls to this unit may be made for low level allocation uses (for
13382 example see the body of @code{GNAT.Tables}).
13384 @node System.Partition_Interface (s-parint.ads)
13385 @section @code{System.Partition_Interface} (@file{s-parint.ads})
13386 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
13387 @cindex Partition interfacing functions
13390 This package provides facilities for partition interfacing. It
13391 is used primarily in a distribution context when using Annex E
13394 @node System.Restrictions (s-restri.ads)
13395 @section @code{System.Restrictions} (@file{s-restri.ads})
13396 @cindex @code{System.Restrictions} (@file{s-restri.ads})
13397 @cindex Run-time restrictions access
13400 This package provides facilities for accessing at run-time
13401 the status of restrictions specified at compile time for
13402 the partition. Information is available both with regard
13403 to actual restrictions specified, and with regard to
13404 compiler determined information on which restrictions
13405 are violated by one or more packages in the partition.
13407 @node System.Rident (s-rident.ads)
13408 @section @code{System.Rident} (@file{s-rident.ads})
13409 @cindex @code{System.Rident} (@file{s-rident.ads})
13410 @cindex Restrictions definitions
13413 This package provides definitions of the restrictions
13414 identifiers supported by GNAT, and also the format of
13415 the restrictions provided in package System.Restrictions.
13416 It is not normally necessary to @code{with} this generic package
13417 since the necessary instantiation is included in
13418 package System.Restrictions.
13420 @node System.Task_Info (s-tasinf.ads)
13421 @section @code{System.Task_Info} (@file{s-tasinf.ads})
13422 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
13423 @cindex Task_Info pragma
13426 This package provides target dependent functionality that is used
13427 to support the @code{Task_Info} pragma
13429 @node System.Wch_Cnv (s-wchcnv.ads)
13430 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13431 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13432 @cindex Wide Character, Representation
13433 @cindex Wide String, Conversion
13434 @cindex Representation of wide characters
13437 This package provides routines for converting between
13438 wide and wide wide characters and a representation as a value of type
13439 @code{Standard.String}, using a specified wide character
13440 encoding method. It uses definitions in
13441 package @code{System.Wch_Con}.
13443 @node System.Wch_Con (s-wchcon.ads)
13444 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
13445 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
13448 This package provides definitions and descriptions of
13449 the various methods used for encoding wide characters
13450 in ordinary strings. These definitions are used by
13451 the package @code{System.Wch_Cnv}.
13453 @node Interfacing to Other Languages
13454 @chapter Interfacing to Other Languages
13456 The facilities in annex B of the Ada 95 Reference Manual are fully
13457 implemented in GNAT, and in addition, a full interface to C++ is
13461 * Interfacing to C::
13462 * Interfacing to C++::
13463 * Interfacing to COBOL::
13464 * Interfacing to Fortran::
13465 * Interfacing to non-GNAT Ada code::
13468 @node Interfacing to C
13469 @section Interfacing to C
13472 Interfacing to C with GNAT can use one of two approaches:
13476 The types in the package @code{Interfaces.C} may be used.
13478 Standard Ada types may be used directly. This may be less portable to
13479 other compilers, but will work on all GNAT compilers, which guarantee
13480 correspondence between the C and Ada types.
13484 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
13485 effect, since this is the default. The following table shows the
13486 correspondence between Ada scalar types and the corresponding C types.
13491 @item Short_Integer
13493 @item Short_Short_Integer
13497 @item Long_Long_Integer
13505 @item Long_Long_Float
13506 This is the longest floating-point type supported by the hardware.
13510 Additionally, there are the following general correspondences between Ada
13514 Ada enumeration types map to C enumeration types directly if pragma
13515 @code{Convention C} is specified, which causes them to have int
13516 length. Without pragma @code{Convention C}, Ada enumeration types map to
13517 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
13518 @code{int}, respectively) depending on the number of values passed.
13519 This is the only case in which pragma @code{Convention C} affects the
13520 representation of an Ada type.
13523 Ada access types map to C pointers, except for the case of pointers to
13524 unconstrained types in Ada, which have no direct C equivalent.
13527 Ada arrays map directly to C arrays.
13530 Ada records map directly to C structures.
13533 Packed Ada records map to C structures where all members are bit fields
13534 of the length corresponding to the @code{@var{type}'Size} value in Ada.
13537 @node Interfacing to C++
13538 @section Interfacing to C++
13541 The interface to C++ makes use of the following pragmas, which are
13542 primarily intended to be constructed automatically using a binding generator
13543 tool, although it is possible to construct them by hand. No suitable binding
13544 generator tool is supplied with GNAT though.
13546 Using these pragmas it is possible to achieve complete
13547 inter-operability between Ada tagged types and C class definitions.
13548 See @ref{Implementation Defined Pragmas}, for more details.
13551 @item pragma CPP_Class ([Entity =>] @var{local_NAME})
13552 The argument denotes an entity in the current declarative region that is
13553 declared as a tagged or untagged record type. It indicates that the type
13554 corresponds to an externally declared C++ class type, and is to be laid
13555 out the same way that C++ would lay out the type.
13557 @item pragma CPP_Constructor ([Entity =>] @var{local_NAME})
13558 This pragma identifies an imported function (imported in the usual way
13559 with pragma @code{Import}) as corresponding to a C++ constructor.
13561 @item pragma CPP_Vtable @dots{}
13562 One @code{CPP_Vtable} pragma can be present for each component of type
13563 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
13567 @node Interfacing to COBOL
13568 @section Interfacing to COBOL
13571 Interfacing to COBOL is achieved as described in section B.4 of
13572 the Ada 95 reference manual.
13574 @node Interfacing to Fortran
13575 @section Interfacing to Fortran
13578 Interfacing to Fortran is achieved as described in section B.5 of the
13579 reference manual. The pragma @code{Convention Fortran}, applied to a
13580 multi-dimensional array causes the array to be stored in column-major
13581 order as required for convenient interface to Fortran.
13583 @node Interfacing to non-GNAT Ada code
13584 @section Interfacing to non-GNAT Ada code
13586 It is possible to specify the convention @code{Ada} in a pragma
13587 @code{Import} or pragma @code{Export}. However this refers to
13588 the calling conventions used by GNAT, which may or may not be
13589 similar enough to those used by some other Ada 83 or Ada 95
13590 compiler to allow interoperation.
13592 If arguments types are kept simple, and if the foreign compiler generally
13593 follows system calling conventions, then it may be possible to integrate
13594 files compiled by other Ada compilers, provided that the elaboration
13595 issues are adequately addressed (for example by eliminating the
13596 need for any load time elaboration).
13598 In particular, GNAT running on VMS is designed to
13599 be highly compatible with the DEC Ada 83 compiler, so this is one
13600 case in which it is possible to import foreign units of this type,
13601 provided that the data items passed are restricted to simple scalar
13602 values or simple record types without variants, or simple array
13603 types with fixed bounds.
13605 @node Specialized Needs Annexes
13606 @chapter Specialized Needs Annexes
13609 Ada 95 defines a number of specialized needs annexes, which are not
13610 required in all implementations. However, as described in this chapter,
13611 GNAT implements all of these special needs annexes:
13614 @item Systems Programming (Annex C)
13615 The Systems Programming Annex is fully implemented.
13617 @item Real-Time Systems (Annex D)
13618 The Real-Time Systems Annex is fully implemented.
13620 @item Distributed Systems (Annex E)
13621 Stub generation is fully implemented in the GNAT compiler. In addition,
13622 a complete compatible PCS is available as part of the GLADE system,
13623 a separate product. When the two
13624 products are used in conjunction, this annex is fully implemented.
13626 @item Information Systems (Annex F)
13627 The Information Systems annex is fully implemented.
13629 @item Numerics (Annex G)
13630 The Numerics Annex is fully implemented.
13632 @item Safety and Security (Annex H)
13633 The Safety and Security annex is fully implemented.
13636 @node Implementation of Specific Ada Features
13637 @chapter Implementation of Specific Ada Features
13640 This chapter describes the GNAT implementation of several Ada language
13644 * Machine Code Insertions::
13645 * GNAT Implementation of Tasking::
13646 * GNAT Implementation of Shared Passive Packages::
13647 * Code Generation for Array Aggregates::
13648 * The Size of Discriminated Records with Default Discriminants::
13649 * Strict Conformance to the Ada 95 Reference Manual::
13652 @node Machine Code Insertions
13653 @section Machine Code Insertions
13656 Package @code{Machine_Code} provides machine code support as described
13657 in the Ada 95 Reference Manual in two separate forms:
13660 Machine code statements, consisting of qualified expressions that
13661 fit the requirements of RM section 13.8.
13663 An intrinsic callable procedure, providing an alternative mechanism of
13664 including machine instructions in a subprogram.
13668 The two features are similar, and both are closely related to the mechanism
13669 provided by the asm instruction in the GNU C compiler. Full understanding
13670 and use of the facilities in this package requires understanding the asm
13671 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
13672 by Richard Stallman. The relevant section is titled ``Extensions to the C
13673 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
13675 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
13676 semantic restrictions and effects as described below. Both are provided so
13677 that the procedure call can be used as a statement, and the function call
13678 can be used to form a code_statement.
13680 The first example given in the GCC documentation is the C @code{asm}
13683 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
13687 The equivalent can be written for GNAT as:
13689 @smallexample @c ada
13690 Asm ("fsinx %1 %0",
13691 My_Float'Asm_Output ("=f", result),
13692 My_Float'Asm_Input ("f", angle));
13696 The first argument to @code{Asm} is the assembler template, and is
13697 identical to what is used in GNU C@. This string must be a static
13698 expression. The second argument is the output operand list. It is
13699 either a single @code{Asm_Output} attribute reference, or a list of such
13700 references enclosed in parentheses (technically an array aggregate of
13703 The @code{Asm_Output} attribute denotes a function that takes two
13704 parameters. The first is a string, the second is the name of a variable
13705 of the type designated by the attribute prefix. The first (string)
13706 argument is required to be a static expression and designates the
13707 constraint for the parameter (e.g.@: what kind of register is
13708 required). The second argument is the variable to be updated with the
13709 result. The possible values for constraint are the same as those used in
13710 the RTL, and are dependent on the configuration file used to build the
13711 GCC back end. If there are no output operands, then this argument may
13712 either be omitted, or explicitly given as @code{No_Output_Operands}.
13714 The second argument of @code{@var{my_float}'Asm_Output} functions as
13715 though it were an @code{out} parameter, which is a little curious, but
13716 all names have the form of expressions, so there is no syntactic
13717 irregularity, even though normally functions would not be permitted
13718 @code{out} parameters. The third argument is the list of input
13719 operands. It is either a single @code{Asm_Input} attribute reference, or
13720 a list of such references enclosed in parentheses (technically an array
13721 aggregate of such references).
13723 The @code{Asm_Input} attribute denotes a function that takes two
13724 parameters. The first is a string, the second is an expression of the
13725 type designated by the prefix. The first (string) argument is required
13726 to be a static expression, and is the constraint for the parameter,
13727 (e.g.@: what kind of register is required). The second argument is the
13728 value to be used as the input argument. The possible values for the
13729 constant are the same as those used in the RTL, and are dependent on
13730 the configuration file used to built the GCC back end.
13732 If there are no input operands, this argument may either be omitted, or
13733 explicitly given as @code{No_Input_Operands}. The fourth argument, not
13734 present in the above example, is a list of register names, called the
13735 @dfn{clobber} argument. This argument, if given, must be a static string
13736 expression, and is a space or comma separated list of names of registers
13737 that must be considered destroyed as a result of the @code{Asm} call. If
13738 this argument is the null string (the default value), then the code
13739 generator assumes that no additional registers are destroyed.
13741 The fifth argument, not present in the above example, called the
13742 @dfn{volatile} argument, is by default @code{False}. It can be set to
13743 the literal value @code{True} to indicate to the code generator that all
13744 optimizations with respect to the instruction specified should be
13745 suppressed, and that in particular, for an instruction that has outputs,
13746 the instruction will still be generated, even if none of the outputs are
13747 used. See the full description in the GCC manual for further details.
13749 The @code{Asm} subprograms may be used in two ways. First the procedure
13750 forms can be used anywhere a procedure call would be valid, and
13751 correspond to what the RM calls ``intrinsic'' routines. Such calls can
13752 be used to intersperse machine instructions with other Ada statements.
13753 Second, the function forms, which return a dummy value of the limited
13754 private type @code{Asm_Insn}, can be used in code statements, and indeed
13755 this is the only context where such calls are allowed. Code statements
13756 appear as aggregates of the form:
13758 @smallexample @c ada
13759 Asm_Insn'(Asm (@dots{}));
13760 Asm_Insn'(Asm_Volatile (@dots{}));
13764 In accordance with RM rules, such code statements are allowed only
13765 within subprograms whose entire body consists of such statements. It is
13766 not permissible to intermix such statements with other Ada statements.
13768 Typically the form using intrinsic procedure calls is more convenient
13769 and more flexible. The code statement form is provided to meet the RM
13770 suggestion that such a facility should be made available. The following
13771 is the exact syntax of the call to @code{Asm}. As usual, if named notation
13772 is used, the arguments may be given in arbitrary order, following the
13773 normal rules for use of positional and named arguments)
13777 [Template =>] static_string_EXPRESSION
13778 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
13779 [,[Inputs =>] INPUT_OPERAND_LIST ]
13780 [,[Clobber =>] static_string_EXPRESSION ]
13781 [,[Volatile =>] static_boolean_EXPRESSION] )
13783 OUTPUT_OPERAND_LIST ::=
13784 [PREFIX.]No_Output_Operands
13785 | OUTPUT_OPERAND_ATTRIBUTE
13786 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
13788 OUTPUT_OPERAND_ATTRIBUTE ::=
13789 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
13791 INPUT_OPERAND_LIST ::=
13792 [PREFIX.]No_Input_Operands
13793 | INPUT_OPERAND_ATTRIBUTE
13794 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
13796 INPUT_OPERAND_ATTRIBUTE ::=
13797 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
13801 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
13802 are declared in the package @code{Machine_Code} and must be referenced
13803 according to normal visibility rules. In particular if there is no
13804 @code{use} clause for this package, then appropriate package name
13805 qualification is required.
13807 @node GNAT Implementation of Tasking
13808 @section GNAT Implementation of Tasking
13811 This chapter outlines the basic GNAT approach to tasking (in particular,
13812 a multi-layered library for portability) and discusses issues related
13813 to compliance with the Real-Time Systems Annex.
13816 * Mapping Ada Tasks onto the Underlying Kernel Threads::
13817 * Ensuring Compliance with the Real-Time Annex::
13820 @node Mapping Ada Tasks onto the Underlying Kernel Threads
13821 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
13824 GNAT's run-time support comprises two layers:
13827 @item GNARL (GNAT Run-time Layer)
13828 @item GNULL (GNAT Low-level Library)
13832 In GNAT, Ada's tasking services rely on a platform and OS independent
13833 layer known as GNARL@. This code is responsible for implementing the
13834 correct semantics of Ada's task creation, rendezvous, protected
13837 GNARL decomposes Ada's tasking semantics into simpler lower level
13838 operations such as create a thread, set the priority of a thread,
13839 yield, create a lock, lock/unlock, etc. The spec for these low-level
13840 operations constitutes GNULLI, the GNULL Interface. This interface is
13841 directly inspired from the POSIX real-time API@.
13843 If the underlying executive or OS implements the POSIX standard
13844 faithfully, the GNULL Interface maps as is to the services offered by
13845 the underlying kernel. Otherwise, some target dependent glue code maps
13846 the services offered by the underlying kernel to the semantics expected
13849 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
13850 key point is that each Ada task is mapped on a thread in the underlying
13851 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
13853 In addition Ada task priorities map onto the underlying thread priorities.
13854 Mapping Ada tasks onto the underlying kernel threads has several advantages:
13858 The underlying scheduler is used to schedule the Ada tasks. This
13859 makes Ada tasks as efficient as kernel threads from a scheduling
13863 Interaction with code written in C containing threads is eased
13864 since at the lowest level Ada tasks and C threads map onto the same
13865 underlying kernel concept.
13868 When an Ada task is blocked during I/O the remaining Ada tasks are
13872 On multiprocessor systems Ada tasks can execute in parallel.
13876 Some threads libraries offer a mechanism to fork a new process, with the
13877 child process duplicating the threads from the parent.
13879 support this functionality when the parent contains more than one task.
13880 @cindex Forking a new process
13882 @node Ensuring Compliance with the Real-Time Annex
13883 @subsection Ensuring Compliance with the Real-Time Annex
13884 @cindex Real-Time Systems Annex compliance
13887 Although mapping Ada tasks onto
13888 the underlying threads has significant advantages, it does create some
13889 complications when it comes to respecting the scheduling semantics
13890 specified in the real-time annex (Annex D).
13892 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
13893 scheduling policy states:
13896 @emph{When the active priority of a ready task that is not running
13897 changes, or the setting of its base priority takes effect, the
13898 task is removed from the ready queue for its old active priority
13899 and is added at the tail of the ready queue for its new active
13900 priority, except in the case where the active priority is lowered
13901 due to the loss of inherited priority, in which case the task is
13902 added at the head of the ready queue for its new active priority.}
13906 While most kernels do put tasks at the end of the priority queue when
13907 a task changes its priority, (which respects the main
13908 FIFO_Within_Priorities requirement), almost none keep a thread at the
13909 beginning of its priority queue when its priority drops from the loss
13910 of inherited priority.
13912 As a result most vendors have provided incomplete Annex D implementations.
13914 The GNAT run-time, has a nice cooperative solution to this problem
13915 which ensures that accurate FIFO_Within_Priorities semantics are
13918 The principle is as follows. When an Ada task T is about to start
13919 running, it checks whether some other Ada task R with the same
13920 priority as T has been suspended due to the loss of priority
13921 inheritance. If this is the case, T yields and is placed at the end of
13922 its priority queue. When R arrives at the front of the queue it
13925 Note that this simple scheme preserves the relative order of the tasks
13926 that were ready to execute in the priority queue where R has been
13929 @node GNAT Implementation of Shared Passive Packages
13930 @section GNAT Implementation of Shared Passive Packages
13931 @cindex Shared passive packages
13934 GNAT fully implements the pragma @code{Shared_Passive} for
13935 @cindex pragma @code{Shared_Passive}
13936 the purpose of designating shared passive packages.
13937 This allows the use of passive partitions in the
13938 context described in the Ada Reference Manual; i.e. for communication
13939 between separate partitions of a distributed application using the
13940 features in Annex E.
13942 @cindex Distribution Systems Annex
13944 However, the implementation approach used by GNAT provides for more
13945 extensive usage as follows:
13948 @item Communication between separate programs
13950 This allows separate programs to access the data in passive
13951 partitions, using protected objects for synchronization where
13952 needed. The only requirement is that the two programs have a
13953 common shared file system. It is even possible for programs
13954 running on different machines with different architectures
13955 (e.g. different endianness) to communicate via the data in
13956 a passive partition.
13958 @item Persistence between program runs
13960 The data in a passive package can persist from one run of a
13961 program to another, so that a later program sees the final
13962 values stored by a previous run of the same program.
13967 The implementation approach used is to store the data in files. A
13968 separate stream file is created for each object in the package, and
13969 an access to an object causes the corresponding file to be read or
13972 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
13973 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
13974 set to the directory to be used for these files.
13975 The files in this directory
13976 have names that correspond to their fully qualified names. For
13977 example, if we have the package
13979 @smallexample @c ada
13981 pragma Shared_Passive (X);
13988 and the environment variable is set to @code{/stemp/}, then the files created
13989 will have the names:
13997 These files are created when a value is initially written to the object, and
13998 the files are retained until manually deleted. This provides the persistence
13999 semantics. If no file exists, it means that no partition has assigned a value
14000 to the variable; in this case the initial value declared in the package
14001 will be used. This model ensures that there are no issues in synchronizing
14002 the elaboration process, since elaboration of passive packages elaborates the
14003 initial values, but does not create the files.
14005 The files are written using normal @code{Stream_IO} access.
14006 If you want to be able
14007 to communicate between programs or partitions running on different
14008 architectures, then you should use the XDR versions of the stream attribute
14009 routines, since these are architecture independent.
14011 If active synchronization is required for access to the variables in the
14012 shared passive package, then as described in the Ada Reference Manual, the
14013 package may contain protected objects used for this purpose. In this case
14014 a lock file (whose name is @file{___lock} (three underscores)
14015 is created in the shared memory directory.
14016 @cindex @file{___lock} file (for shared passive packages)
14017 This is used to provide the required locking
14018 semantics for proper protected object synchronization.
14020 As of January 2003, GNAT supports shared passive packages on all platforms
14021 except for OpenVMS.
14023 @node Code Generation for Array Aggregates
14024 @section Code Generation for Array Aggregates
14027 * Static constant aggregates with static bounds::
14028 * Constant aggregates with an unconstrained nominal types::
14029 * Aggregates with static bounds::
14030 * Aggregates with non-static bounds::
14031 * Aggregates in assignment statements::
14035 Aggregate have a rich syntax and allow the user to specify the values of
14036 complex data structures by means of a single construct. As a result, the
14037 code generated for aggregates can be quite complex and involve loops, case
14038 statements and multiple assignments. In the simplest cases, however, the
14039 compiler will recognize aggregates whose components and constraints are
14040 fully static, and in those cases the compiler will generate little or no
14041 executable code. The following is an outline of the code that GNAT generates
14042 for various aggregate constructs. For further details, the user will find it
14043 useful to examine the output produced by the -gnatG flag to see the expanded
14044 source that is input to the code generator. The user will also want to examine
14045 the assembly code generated at various levels of optimization.
14047 The code generated for aggregates depends on the context, the component values,
14048 and the type. In the context of an object declaration the code generated is
14049 generally simpler than in the case of an assignment. As a general rule, static
14050 component values and static subtypes also lead to simpler code.
14052 @node Static constant aggregates with static bounds
14053 @subsection Static constant aggregates with static bounds
14056 For the declarations:
14057 @smallexample @c ada
14058 type One_Dim is array (1..10) of integer;
14059 ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
14063 GNAT generates no executable code: the constant ar0 is placed in static memory.
14064 The same is true for constant aggregates with named associations:
14066 @smallexample @c ada
14067 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
14068 Cr3 : constant One_Dim := (others => 7777);
14072 The same is true for multidimensional constant arrays such as:
14074 @smallexample @c ada
14075 type two_dim is array (1..3, 1..3) of integer;
14076 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
14080 The same is true for arrays of one-dimensional arrays: the following are
14083 @smallexample @c ada
14084 type ar1b is array (1..3) of boolean;
14085 type ar_ar is array (1..3) of ar1b;
14086 None : constant ar1b := (others => false); -- fully static
14087 None2 : constant ar_ar := (1..3 => None); -- fully static
14091 However, for multidimensional aggregates with named associations, GNAT will
14092 generate assignments and loops, even if all associations are static. The
14093 following two declarations generate a loop for the first dimension, and
14094 individual component assignments for the second dimension:
14096 @smallexample @c ada
14097 Zero1: constant two_dim := (1..3 => (1..3 => 0));
14098 Zero2: constant two_dim := (others => (others => 0));
14101 @node Constant aggregates with an unconstrained nominal types
14102 @subsection Constant aggregates with an unconstrained nominal types
14105 In such cases the aggregate itself establishes the subtype, so that
14106 associations with @code{others} cannot be used. GNAT determines the
14107 bounds for the actual subtype of the aggregate, and allocates the
14108 aggregate statically as well. No code is generated for the following:
14110 @smallexample @c ada
14111 type One_Unc is array (natural range <>) of integer;
14112 Cr_Unc : constant One_Unc := (12,24,36);
14115 @node Aggregates with static bounds
14116 @subsection Aggregates with static bounds
14119 In all previous examples the aggregate was the initial (and immutable) value
14120 of a constant. If the aggregate initializes a variable, then code is generated
14121 for it as a combination of individual assignments and loops over the target
14122 object. The declarations
14124 @smallexample @c ada
14125 Cr_Var1 : One_Dim := (2, 5, 7, 11);
14126 Cr_Var2 : One_Dim := (others > -1);
14130 generate the equivalent of
14132 @smallexample @c ada
14138 for I in Cr_Var2'range loop
14139 Cr_Var2 (I) := =-1;
14143 @node Aggregates with non-static bounds
14144 @subsection Aggregates with non-static bounds
14147 If the bounds of the aggregate are not statically compatible with the bounds
14148 of the nominal subtype of the target, then constraint checks have to be
14149 generated on the bounds. For a multidimensional array, constraint checks may
14150 have to be applied to sub-arrays individually, if they do not have statically
14151 compatible subtypes.
14153 @node Aggregates in assignment statements
14154 @subsection Aggregates in assignment statements
14157 In general, aggregate assignment requires the construction of a temporary,
14158 and a copy from the temporary to the target of the assignment. This is because
14159 it is not always possible to convert the assignment into a series of individual
14160 component assignments. For example, consider the simple case:
14162 @smallexample @c ada
14167 This cannot be converted into:
14169 @smallexample @c ada
14175 So the aggregate has to be built first in a separate location, and then
14176 copied into the target. GNAT recognizes simple cases where this intermediate
14177 step is not required, and the assignments can be performed in place, directly
14178 into the target. The following sufficient criteria are applied:
14182 The bounds of the aggregate are static, and the associations are static.
14184 The components of the aggregate are static constants, names of
14185 simple variables that are not renamings, or expressions not involving
14186 indexed components whose operands obey these rules.
14190 If any of these conditions are violated, the aggregate will be built in
14191 a temporary (created either by the front-end or the code generator) and then
14192 that temporary will be copied onto the target.
14195 @node The Size of Discriminated Records with Default Discriminants
14196 @section The Size of Discriminated Records with Default Discriminants
14199 If a discriminated type @code{T} has discriminants with default values, it is
14200 possible to declare an object of this type without providing an explicit
14203 @smallexample @c ada
14205 type Size is range 1..100;
14207 type Rec (D : Size := 15) is record
14208 Name : String (1..D);
14216 Such an object is said to be @emph{unconstrained}.
14217 The discriminant of the object
14218 can be modified by a full assignment to the object, as long as it preserves the
14219 relation between the value of the discriminant, and the value of the components
14222 @smallexample @c ada
14224 Word := (3, "yes");
14226 Word := (5, "maybe");
14228 Word := (5, "no"); -- raises Constraint_Error
14233 In order to support this behavior efficiently, an unconstrained object is
14234 given the maximum size that any value of the type requires. In the case
14235 above, @code{Word} has storage for the discriminant and for
14236 a @code{String} of length 100.
14237 It is important to note that unconstrained objects do not require dynamic
14238 allocation. It would be an improper implementation to place on the heap those
14239 components whose size depends on discriminants. (This improper implementation
14240 was used by some Ada83 compilers, where the @code{Name} component above
14242 been stored as a pointer to a dynamic string). Following the principle that
14243 dynamic storage management should never be introduced implicitly,
14244 an Ada95 compiler should reserve the full size for an unconstrained declared
14245 object, and place it on the stack.
14247 This maximum size approach
14248 has been a source of surprise to some users, who expect the default
14249 values of the discriminants to determine the size reserved for an
14250 unconstrained object: ``If the default is 15, why should the object occupy
14252 The answer, of course, is that the discriminant may be later modified,
14253 and its full range of values must be taken into account. This is why the
14258 type Rec (D : Positive := 15) is record
14259 Name : String (1..D);
14267 is flagged by the compiler with a warning:
14268 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
14269 because the required size includes @code{Positive'Last}
14270 bytes. As the first example indicates, the proper approach is to declare an
14271 index type of ``reasonable'' range so that unconstrained objects are not too
14274 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
14275 created in the heap by means of an allocator, then it is @emph{not}
14277 it is constrained by the default values of the discriminants, and those values
14278 cannot be modified by full assignment. This is because in the presence of
14279 aliasing all views of the object (which may be manipulated by different tasks,
14280 say) must be consistent, so it is imperative that the object, once created,
14283 @node Strict Conformance to the Ada 95 Reference Manual
14284 @section Strict Conformance to the Ada 95 Reference Manual
14287 The dynamic semantics defined by the Ada 95 Reference Manual impose a set of
14288 run-time checks to be generated. By default, the GNAT compiler will insert many
14289 run-time checks into the compiled code, including most of those required by the
14290 Ada 95 Reference Manual. However, there are three checks that are not enabled
14291 in the default mode for efficiency reasons: arithmetic overflow checking for
14292 integer operations (including division by zero), checks for access before
14293 elaboration on subprogram calls, and stack overflow checking (most operating
14294 systems do not perform this check by default).
14296 Strict conformance to the Ada 95 Reference Manual can be achieved by adding
14297 three compiler options for overflow checking for integer operations
14298 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
14299 calls and generic instantiations (@option{-gnatE}), and stack overflow
14300 checking (@option{-fstack-check}).
14302 Note that the result of a floating point arithmetic operation in overflow and
14303 invalid situations, when the @code{Machine_Overflows} attribute of the result
14304 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
14305 case for machines compliant with the IEEE floating-point standard, but on
14306 machines that are not fully compliant with this standard, such as Alpha, the
14307 @option{-mieee} compiler flag must be used for achieving IEEE confirming
14308 behavior (although at the cost of a significant performance penalty), so
14309 infinite and and NaN values are properly generated.
14312 @node Project File Reference
14313 @chapter Project File Reference
14316 This chapter describes the syntax and semantics of project files.
14317 Project files specify the options to be used when building a system.
14318 Project files can specify global settings for all tools,
14319 as well as tool-specific settings.
14320 See the chapter on project files in the GNAT Users guide for examples of use.
14324 * Lexical Elements::
14326 * Empty declarations::
14327 * Typed string declarations::
14331 * Project Attributes::
14332 * Attribute References::
14333 * External Values::
14334 * Case Construction::
14336 * Package Renamings::
14338 * Project Extensions::
14339 * Project File Elaboration::
14342 @node Reserved Words
14343 @section Reserved Words
14346 All Ada95 reserved words are reserved in project files, and cannot be used
14347 as variable names or project names. In addition, the following are
14348 also reserved in project files:
14351 @item @code{extends}
14353 @item @code{external}
14355 @item @code{project}
14359 @node Lexical Elements
14360 @section Lexical Elements
14363 Rules for identifiers are the same as in Ada95. Identifiers
14364 are case-insensitive. Strings are case sensitive, except where noted.
14365 Comments have the same form as in Ada95.
14375 simple_name @{. simple_name@}
14379 @section Declarations
14382 Declarations introduce new entities that denote types, variables, attributes,
14383 and packages. Some declarations can only appear immediately within a project
14384 declaration. Others can appear within a project or within a package.
14388 declarative_item ::=
14389 simple_declarative_item |
14390 typed_string_declaration |
14391 package_declaration
14393 simple_declarative_item ::=
14394 variable_declaration |
14395 typed_variable_declaration |
14396 attribute_declaration |
14397 case_construction |
14401 @node Empty declarations
14402 @section Empty declarations
14405 empty_declaration ::=
14409 An empty declaration is allowed anywhere a declaration is allowed.
14412 @node Typed string declarations
14413 @section Typed string declarations
14416 Typed strings are sequences of string literals. Typed strings are the only
14417 named types in project files. They are used in case constructions, where they
14418 provide support for conditional attribute definitions.
14422 typed_string_declaration ::=
14423 @b{type} <typed_string_>_simple_name @b{is}
14424 ( string_literal @{, string_literal@} );
14428 A typed string declaration can only appear immediately within a project
14431 All the string literals in a typed string declaration must be distinct.
14437 Variables denote values, and appear as constituents of expressions.
14440 typed_variable_declaration ::=
14441 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
14443 variable_declaration ::=
14444 <variable_>simple_name := expression;
14448 The elaboration of a variable declaration introduces the variable and
14449 assigns to it the value of the expression. The name of the variable is
14450 available after the assignment symbol.
14453 A typed_variable can only be declare once.
14456 a non typed variable can be declared multiple times.
14459 Before the completion of its first declaration, the value of variable
14460 is the null string.
14463 @section Expressions
14466 An expression is a formula that defines a computation or retrieval of a value.
14467 In a project file the value of an expression is either a string or a list
14468 of strings. A string value in an expression is either a literal, the current
14469 value of a variable, an external value, an attribute reference, or a
14470 concatenation operation.
14483 attribute_reference
14489 ( <string_>expression @{ , <string_>expression @} )
14492 @subsection Concatenation
14494 The following concatenation functions are defined:
14496 @smallexample @c ada
14497 function "&" (X : String; Y : String) return String;
14498 function "&" (X : String_List; Y : String) return String_List;
14499 function "&" (X : String_List; Y : String_List) return String_List;
14503 @section Attributes
14506 An attribute declaration defines a property of a project or package. This
14507 property can later be queried by means of an attribute reference.
14508 Attribute values are strings or string lists.
14510 Some attributes are associative arrays. These attributes are mappings whose
14511 domain is a set of strings. These attributes are declared one association
14512 at a time, by specifying a point in the domain and the corresponding image
14513 of the attribute. They may also be declared as a full associative array,
14514 getting the same associations as the corresponding attribute in an imported
14515 or extended project.
14517 Attributes that are not associative arrays are called simple attributes.
14521 attribute_declaration ::=
14522 full_associative_array_declaration |
14523 @b{for} attribute_designator @b{use} expression ;
14525 full_associative_array_declaration ::=
14526 @b{for} <associative_array_attribute_>simple_name @b{use}
14527 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
14529 attribute_designator ::=
14530 <simple_attribute_>simple_name |
14531 <associative_array_attribute_>simple_name ( string_literal )
14535 Some attributes are project-specific, and can only appear immediately within
14536 a project declaration. Others are package-specific, and can only appear within
14537 the proper package.
14539 The expression in an attribute definition must be a string or a string_list.
14540 The string literal appearing in the attribute_designator of an associative
14541 array attribute is case-insensitive.
14543 @node Project Attributes
14544 @section Project Attributes
14547 The following attributes apply to a project. All of them are simple
14552 Expression must be a path name. The attribute defines the
14553 directory in which the object files created by the build are to be placed. If
14554 not specified, object files are placed in the project directory.
14557 Expression must be a path name. The attribute defines the
14558 directory in which the executables created by the build are to be placed.
14559 If not specified, executables are placed in the object directory.
14562 Expression must be a list of path names. The attribute
14563 defines the directories in which the source files for the project are to be
14564 found. If not specified, source files are found in the project directory.
14567 Expression must be a list of file names. The attribute
14568 defines the individual files, in the project directory, which are to be used
14569 as sources for the project. File names are path_names that contain no directory
14570 information. If the project has no sources the attribute must be declared
14571 explicitly with an empty list.
14573 @item Source_List_File
14574 Expression must a single path name. The attribute
14575 defines a text file that contains a list of source file names to be used
14576 as sources for the project
14579 Expression must be a path name. The attribute defines the
14580 directory in which a library is to be built. The directory must exist, must
14581 be distinct from the project's object directory, and must be writable.
14584 Expression must be a string that is a legal file name,
14585 without extension. The attribute defines a string that is used to generate
14586 the name of the library to be built by the project.
14589 Argument must be a string value that must be one of the
14590 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
14591 string is case-insensitive. If this attribute is not specified, the library is
14592 a static library. Otherwise, the library may be dynamic or relocatable. This
14593 distinction is operating-system dependent.
14595 @item Library_Version
14596 Expression must be a string value whose interpretation
14597 is platform dependent. On UNIX, it is used only for dynamic/relocatable
14598 libraries as the internal name of the library (the @code{"soname"}). If the
14599 library file name (built from the @code{Library_Name}) is different from the
14600 @code{Library_Version}, then the library file will be a symbolic link to the
14601 actual file whose name will be @code{Library_Version}.
14603 @item Library_Interface
14604 Expression must be a string list. Each element of the string list
14605 must designate a unit of the project.
14606 If this attribute is present in a Library Project File, then the project
14607 file is a Stand-alone Library_Project_File.
14609 @item Library_Auto_Init
14610 Expression must be a single string "true" or "false", case-insensitive.
14611 If this attribute is present in a Stand-alone Library Project File,
14612 it indicates if initialization is automatic when the dynamic library
14615 @item Library_Options
14616 Expression must be a string list. Indicates additional switches that
14617 are to be used when building a shared library.
14620 Expression must be a single string. Designates an alternative to "gcc"
14621 for building shared libraries.
14623 @item Library_Src_Dir
14624 Expression must be a path name. The attribute defines the
14625 directory in which the sources of the interfaces of a Stand-alone Library will
14626 be copied. The directory must exist, must be distinct from the project's
14627 object directory and source directories of all project in the project tree,
14628 and must be writable.
14630 @item Library_Src_Dir
14631 Expression must be a path name. The attribute defines the
14632 directory in which the ALI files of a Library will
14633 be copied. The directory must exist, must be distinct from the project's
14634 object directory and source directoriesof all project in the project tree,
14635 and must be writable.
14637 @item Library_Symbol_File
14638 Expression must be a single string. Its value is the single file name of a
14639 symbol file to be created when building a stand-alone library when the
14640 symbol policy is either "compliant", "controlled" or "restricted",
14641 on platforms that support symbol control, such as VMS.
14643 @item Library_Reference_Symbol_File
14644 Expression must be a single string. Its value is the single file name of a
14645 reference symbol file that is read when the symbol policy is either
14646 "compliant" or "controlled", on platforms that support symbol control,
14647 such as VMS, when building a stand-alone library.
14649 @item Library_Symbol_Policy
14650 Expression must be a single string. Its case-insensitive value can only be
14651 "autonomous", "default", "compliant", "controlled" or "restricted".
14653 This attribute is not taken into account on all platforms. It controls the
14654 policy for exported symbols and, on some platforms (like VMS) that have the
14655 notions of major and minor IDs built in the library files, it controls
14656 the setting of these IDs.
14658 "autonomous" or "default": exported symbols are not controlled.
14660 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
14661 it is equivalent to policy "autonomous". If there are exported symbols in
14662 the reference symbol file that are not in the object files of the interfaces,
14663 the major ID of the library is increased. If there are symbols in the
14664 object files of the interfaces that are not in the reference symbol file,
14665 these symbols are put at the end of the list in the newly created symbol file
14666 and the minor ID is increased.
14668 "controlled": the attribute Library_Reference_Symbol_File must be difined.
14669 The library will fail to build if the exported symbols in the object files of
14670 the interfaces do not match exactly the symbol in the symbol file.
14672 "restricted": The attribute Library_Symbol_File must be defined. The library
14673 will fail to build if there are symbols in the symbol file that are not in
14674 the exported symbols of the object files of the interfaces. Additional symbols
14675 in the object files are not added to the symbol file.
14678 Expression must be a list of strings that are legal file names.
14679 These file names designate existing compilation units in the source directory
14680 that are legal main subprograms.
14682 When a project file is elaborated, as part of the execution of a gnatmake
14683 command, one or several executables are built and placed in the Exec_Dir.
14684 If the gnatmake command does not include explicit file names, the executables
14685 that are built correspond to the files specified by this attribute.
14687 @item Externally_Built
14688 Expression must be a single string. Its value must be either "true" of "false",
14689 case-insensitive. The default is "false". When the value of this attribute is
14690 "true", no attempt is made to compile the sources or to build the library,
14691 when the project is a library project.
14693 @item Main_Language
14694 This is a simple attribute. Its value is a string that specifies the
14695 language of the main program.
14698 Expression must be a string list. Each string designates
14699 a programming language that is known to GNAT. The strings are case-insensitive.
14701 @item Locally_Removed_Files
14702 This attribute is legal only in a project file that extends another.
14703 Expression must be a list of strings that are legal file names.
14704 Each file name must designate a source that would normally be inherited
14705 by the current project file. It cannot designate an immediate source that is
14706 not inherited. Each of the source files in the list are not considered to
14707 be sources of the project file: they are not inherited.
14710 @node Attribute References
14711 @section Attribute References
14714 Attribute references are used to retrieve the value of previously defined
14715 attribute for a package or project.
14718 attribute_reference ::=
14719 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
14721 attribute_prefix ::=
14723 <project_simple_name | package_identifier |
14724 <project_>simple_name . package_identifier
14728 If an attribute has not been specified for a given package or project, its
14729 value is the null string or the empty list.
14731 @node External Values
14732 @section External Values
14735 An external value is an expression whose value is obtained from the command
14736 that invoked the processing of the current project file (typically a
14742 @b{external} ( string_literal [, string_literal] )
14746 The first string_literal is the string to be used on the command line or
14747 in the environment to specify the external value. The second string_literal,
14748 if present, is the default to use if there is no specification for this
14749 external value either on the command line or in the environment.
14751 @node Case Construction
14752 @section Case Construction
14755 A case construction supports attribute declarations that depend on the value of
14756 a previously declared variable.
14760 case_construction ::=
14761 @b{case} <typed_variable_>name @b{is}
14766 @b{when} discrete_choice_list =>
14767 @{case_construction | attribute_declaration | empty_declaration@}
14769 discrete_choice_list ::=
14770 string_literal @{| string_literal@} |
14775 All choices in a choice list must be distinct. The choice lists of two
14776 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
14777 alternatives do not need to include all values of the type. An @code{others}
14778 choice must appear last in the list of alternatives.
14784 A package provides a grouping of variable declarations and attribute
14785 declarations to be used when invoking various GNAT tools. The name of
14786 the package indicates the tool(s) to which it applies.
14790 package_declaration ::=
14791 package_specification | package_renaming
14793 package_specification ::=
14794 @b{package} package_identifier @b{is}
14795 @{simple_declarative_item@}
14796 @b{end} package_identifier ;
14798 package_identifier ::=
14799 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
14800 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
14801 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
14804 @subsection Package Naming
14807 The attributes of a @code{Naming} package specifies the naming conventions
14808 that apply to the source files in a project. When invoking other GNAT tools,
14809 they will use the sources in the source directories that satisfy these
14810 naming conventions.
14812 The following attributes apply to a @code{Naming} package:
14816 This is a simple attribute whose value is a string. Legal values of this
14817 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
14818 These strings are themselves case insensitive.
14821 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
14823 @item Dot_Replacement
14824 This is a simple attribute whose string value satisfies the following
14828 @item It must not be empty
14829 @item It cannot start or end with an alphanumeric character
14830 @item It cannot be a single underscore
14831 @item It cannot start with an underscore followed by an alphanumeric
14832 @item It cannot contain a dot @code{'.'} if longer than one character
14836 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
14839 This is an associative array attribute, defined on language names,
14840 whose image is a string that must satisfy the following
14844 @item It must not be empty
14845 @item It cannot start with an alphanumeric character
14846 @item It cannot start with an underscore followed by an alphanumeric character
14850 For Ada, the attribute denotes the suffix used in file names that contain
14851 library unit declarations, that is to say units that are package and
14852 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
14853 specified, then the default is @code{".ads"}.
14855 For C and C++, the attribute denotes the suffix used in file names that
14856 contain prototypes.
14859 This is an associative array attribute defined on language names,
14860 whose image is a string that must satisfy the following
14864 @item It must not be empty
14865 @item It cannot start with an alphanumeric character
14866 @item It cannot start with an underscore followed by an alphanumeric character
14867 @item It cannot be a suffix of @code{Spec_Suffix}
14871 For Ada, the attribute denotes the suffix used in file names that contain
14872 library bodies, that is to say units that are package and subprogram bodies.
14873 If @code{Body_Suffix ("Ada")} is not specified, then the default is
14876 For C and C++, the attribute denotes the suffix used in file names that contain
14879 @item Separate_Suffix
14880 This is a simple attribute whose value satisfies the same conditions as
14881 @code{Body_Suffix}.
14883 This attribute is specific to Ada. It denotes the suffix used in file names
14884 that contain separate bodies. If it is not specified, then it defaults to same
14885 value as @code{Body_Suffix ("Ada")}.
14888 This is an associative array attribute, specific to Ada, defined over
14889 compilation unit names. The image is a string that is the name of the file
14890 that contains that library unit. The file name is case sensitive if the
14891 conventions of the host operating system require it.
14894 This is an associative array attribute, specific to Ada, defined over
14895 compilation unit names. The image is a string that is the name of the file
14896 that contains the library unit body for the named unit. The file name is case
14897 sensitive if the conventions of the host operating system require it.
14899 @item Specification_Exceptions
14900 This is an associative array attribute defined on language names,
14901 whose value is a list of strings.
14903 This attribute is not significant for Ada.
14905 For C and C++, each string in the list denotes the name of a file that
14906 contains prototypes, but whose suffix is not necessarily the
14907 @code{Spec_Suffix} for the language.
14909 @item Implementation_Exceptions
14910 This is an associative array attribute defined on language names,
14911 whose value is a list of strings.
14913 This attribute is not significant for Ada.
14915 For C and C++, each string in the list denotes the name of a file that
14916 contains source code, but whose suffix is not necessarily the
14917 @code{Body_Suffix} for the language.
14920 The following attributes of package @code{Naming} are obsolescent. They are
14921 kept as synonyms of other attributes for compatibility with previous versions
14922 of the Project Manager.
14925 @item Specification_Suffix
14926 This is a synonym of @code{Spec_Suffix}.
14928 @item Implementation_Suffix
14929 This is a synonym of @code{Body_Suffix}.
14931 @item Specification
14932 This is a synonym of @code{Spec}.
14934 @item Implementation
14935 This is a synonym of @code{Body}.
14938 @subsection package Compiler
14941 The attributes of the @code{Compiler} package specify the compilation options
14942 to be used by the underlying compiler.
14945 @item Default_Switches
14946 This is an associative array attribute. Its
14947 domain is a set of language names. Its range is a string list that
14948 specifies the compilation options to be used when compiling a component
14949 written in that language, for which no file-specific switches have been
14953 This is an associative array attribute. Its domain is
14954 a set of file names. Its range is a string list that specifies the
14955 compilation options to be used when compiling the named file. If a file
14956 is not specified in the Switches attribute, it is compiled with the
14957 options specified by Default_Switches of its language, if defined.
14959 @item Local_Configuration_Pragmas.
14960 This is a simple attribute, whose
14961 value is a path name that designates a file containing configuration pragmas
14962 to be used for all invocations of the compiler for immediate sources of the
14966 @subsection package Builder
14969 The attributes of package @code{Builder} specify the compilation, binding, and
14970 linking options to be used when building an executable for a project. The
14971 following attributes apply to package @code{Builder}:
14974 @item Default_Switches
14975 This is an associative array attribute. Its
14976 domain is a set of language names. Its range is a string list that
14977 specifies options to be used when building a main
14978 written in that language, for which no file-specific switches have been
14982 This is an associative array attribute. Its domain is
14983 a set of file names. Its range is a string list that specifies
14984 options to be used when building the named main file. If a main file
14985 is not specified in the Switches attribute, it is built with the
14986 options specified by Default_Switches of its language, if defined.
14988 @item Global_Configuration_Pragmas
14989 This is a simple attribute, whose
14990 value is a path name that designates a file that contains configuration pragmas
14991 to be used in every build of an executable. If both local and global
14992 configuration pragmas are specified, a compilation makes use of both sets.
14996 This is an associative array attribute. Its domain is
14997 a set of main source file names. Its range is a simple string that specifies
14998 the executable file name to be used when linking the specified main source.
14999 If a main source is not specified in the Executable attribute, the executable
15000 file name is deducted from the main source file name.
15001 This attribute has no effect if its value is the empty string.
15003 @item Executable_Suffix
15004 This is a simple attribute whose value is the suffix to be added to
15005 the executables that don't have an attribute Executable specified.
15008 @subsection package Gnatls
15011 The attributes of package @code{Gnatls} specify the tool options to be used
15012 when invoking the library browser @command{gnatls}.
15013 The following attributes apply to package @code{Gnatls}:
15017 This is a single attribute with a string list value. Each non empty string
15018 in the list is an option when invoking @code{gnatls}.
15021 @subsection package Binder
15024 The attributes of package @code{Binder} specify the options to be used
15025 when invoking the binder in the construction of an executable.
15026 The following attributes apply to package @code{Binder}:
15029 @item Default_Switches
15030 This is an associative array attribute. Its
15031 domain is a set of language names. Its range is a string list that
15032 specifies options to be used when binding a main
15033 written in that language, for which no file-specific switches have been
15037 This is an associative array attribute. Its domain is
15038 a set of file names. Its range is a string list that specifies
15039 options to be used when binding the named main file. If a main file
15040 is not specified in the Switches attribute, it is boundt with the
15041 options specified by Default_Switches of its language, if defined.
15044 @subsection package Linker
15047 The attributes of package @code{Linker} specify the options to be used when
15048 invoking the linker in the construction of an executable.
15049 The following attributes apply to package @code{Linker}:
15052 @item Default_Switches
15053 This is an associative array attribute. Its
15054 domain is a set of language names. Its range is a string list that
15055 specifies options to be used when linking a main
15056 written in that language, for which no file-specific switches have been
15060 This is an associative array attribute. Its domain is
15061 a set of file names. Its range is a string list that specifies
15062 options to be used when linking the named main file. If a main file
15063 is not specified in the Switches attribute, it is linked with the
15064 options specified by Default_Switches of its language, if defined.
15066 @item Linker_Options
15067 This is a string list attribute. Its value specifies additional options that
15068 be givent to the linker when linking an executable. This attribute is not
15069 used in the main project, only in projects imported directly or indirectly.
15073 @subsection package Cross_Reference
15076 The attributes of package @code{Cross_Reference} specify the tool options
15078 when invoking the library tool @command{gnatxref}.
15079 The following attributes apply to package @code{Cross_Reference}:
15082 @item Default_Switches
15083 This is an associative array attribute. Its
15084 domain is a set of language names. Its range is a string list that
15085 specifies options to be used when calling @command{gnatxref} on a source
15086 written in that language, for which no file-specific switches have been
15090 This is an associative array attribute. Its domain is
15091 a set of file names. Its range is a string list that specifies
15092 options to be used when calling @command{gnatxref} on the named main source.
15093 If a source is not specified in the Switches attribute, @command{gnatxref} will
15094 be called with the options specified by Default_Switches of its language,
15098 @subsection package Finder
15101 The attributes of package @code{Finder} specify the tool options to be used
15102 when invoking the search tool @command{gnatfind}.
15103 The following attributes apply to package @code{Finder}:
15106 @item Default_Switches
15107 This is an associative array attribute. Its
15108 domain is a set of language names. Its range is a string list that
15109 specifies options to be used when calling @command{gnatfind} on a source
15110 written in that language, for which no file-specific switches have been
15114 This is an associative array attribute. Its domain is
15115 a set of file names. Its range is a string list that specifies
15116 options to be used when calling @command{gnatfind} on the named main source.
15117 If a source is not specified in the Switches attribute, @command{gnatfind} will
15118 be called with the options specified by Default_Switches of its language,
15122 @subsection package Pretty_Printer
15125 The attributes of package @code{Pretty_Printer}
15126 specify the tool options to be used
15127 when invoking the formatting tool @command{gnatpp}.
15128 The following attributes apply to package @code{Pretty_Printer}:
15131 @item Default_switches
15132 This is an associative array attribute. Its
15133 domain is a set of language names. Its range is a string list that
15134 specifies options to be used when calling @command{gnatpp} on a source
15135 written in that language, for which no file-specific switches have been
15139 This is an associative array attribute. Its domain is
15140 a set of file names. Its range is a string list that specifies
15141 options to be used when calling @command{gnatpp} on the named main source.
15142 If a source is not specified in the Switches attribute, @command{gnatpp} will
15143 be called with the options specified by Default_Switches of its language,
15147 @subsection package gnatstub
15150 The attributes of package @code{gnatstub}
15151 specify the tool options to be used
15152 when invoking the tool @command{gnatstub}.
15153 The following attributes apply to package @code{gnatstub}:
15156 @item Default_switches
15157 This is an associative array attribute. Its
15158 domain is a set of language names. Its range is a string list that
15159 specifies options to be used when calling @command{gnatstub} on a source
15160 written in that language, for which no file-specific switches have been
15164 This is an associative array attribute. Its domain is
15165 a set of file names. Its range is a string list that specifies
15166 options to be used when calling @command{gnatstub} on the named main source.
15167 If a source is not specified in the Switches attribute, @command{gnatpp} will
15168 be called with the options specified by Default_Switches of its language,
15172 @subsection package Eliminate
15175 The attributes of package @code{Eliminate}
15176 specify the tool options to be used
15177 when invoking the tool @command{gnatelim}.
15178 The following attributes apply to package @code{Eliminate}:
15181 @item Default_switches
15182 This is an associative array attribute. Its
15183 domain is a set of language names. Its range is a string list that
15184 specifies options to be used when calling @command{gnatelim} on a source
15185 written in that language, for which no file-specific switches have been
15189 This is an associative array attribute. Its domain is
15190 a set of file names. Its range is a string list that specifies
15191 options to be used when calling @command{gnatelim} on the named main source.
15192 If a source is not specified in the Switches attribute, @command{gnatelim} will
15193 be called with the options specified by Default_Switches of its language,
15197 @subsection package Metrics
15200 The attributes of package @code{Metrics}
15201 specify the tool options to be used
15202 when invoking the tool @command{gnatmetric}.
15203 The following attributes apply to package @code{Metrics}:
15206 @item Default_switches
15207 This is an associative array attribute. Its
15208 domain is a set of language names. Its range is a string list that
15209 specifies options to be used when calling @command{gnatmetric} on a source
15210 written in that language, for which no file-specific switches have been
15214 This is an associative array attribute. Its domain is
15215 a set of file names. Its range is a string list that specifies
15216 options to be used when calling @command{gnatmetric} on the named main source.
15217 If a source is not specified in the Switches attribute, @command{gnatmetric}
15218 will be called with the options specified by Default_Switches of its language,
15222 @subsection package IDE
15225 The attributes of package @code{IDE} specify the options to be used when using
15226 an Integrated Development Environment such as @command{GPS}.
15230 This is a simple attribute. Its value is a string that designates the remote
15231 host in a cross-compilation environment, to be used for remote compilation and
15232 debugging. This field should not be specified when running on the local
15236 This is a simple attribute. Its value is a string that specifies the
15237 name of IP address of the embedded target in a cross-compilation environment,
15238 on which the program should execute.
15240 @item Communication_Protocol
15241 This is a simple string attribute. Its value is the name of the protocol
15242 to use to communicate with the target in a cross-compilation environment,
15243 e.g. @code{"wtx"} or @code{"vxworks"}.
15245 @item Compiler_Command
15246 This is an associative array attribute, whose domain is a language name. Its
15247 value is string that denotes the command to be used to invoke the compiler.
15248 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
15249 gnatmake, in particular in the handling of switches.
15251 @item Debugger_Command
15252 This is simple attribute, Its value is a string that specifies the name of
15253 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
15255 @item Default_Switches
15256 This is an associative array attribute. Its indexes are the name of the
15257 external tools that the GNAT Programming System (GPS) is supporting. Its
15258 value is a list of switches to use when invoking that tool.
15261 This is a simple attribute. Its value is a string that specifies the name
15262 of the @command{gnatls} utility to be used to retrieve information about the
15263 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
15266 This is a simple attribute. Its value is a string used to specify the
15267 Version Control System (VCS) to be used for this project, e.g CVS, RCS
15268 ClearCase or Perforce.
15270 @item VCS_File_Check
15271 This is a simple attribute. Its value is a string that specifies the
15272 command used by the VCS to check the validity of a file, either
15273 when the user explicitly asks for a check, or as a sanity check before
15274 doing the check-in.
15276 @item VCS_Log_Check
15277 This is a simple attribute. Its value is a string that specifies
15278 the command used by the VCS to check the validity of a log file.
15282 @node Package Renamings
15283 @section Package Renamings
15286 A package can be defined by a renaming declaration. The new package renames
15287 a package declared in a different project file, and has the same attributes
15288 as the package it renames.
15291 package_renaming ::==
15292 @b{package} package_identifier @b{renames}
15293 <project_>simple_name.package_identifier ;
15297 The package_identifier of the renamed package must be the same as the
15298 package_identifier. The project whose name is the prefix of the renamed
15299 package must contain a package declaration with this name. This project
15300 must appear in the context_clause of the enclosing project declaration,
15301 or be the parent project of the enclosing child project.
15307 A project file specifies a set of rules for constructing a software system.
15308 A project file can be self-contained, or depend on other project files.
15309 Dependencies are expressed through a context clause that names other projects.
15315 context_clause project_declaration
15317 project_declaration ::=
15318 simple_project_declaration | project_extension
15320 simple_project_declaration ::=
15321 @b{project} <project_>simple_name @b{is}
15322 @{declarative_item@}
15323 @b{end} <project_>simple_name;
15329 [@b{limited}] @b{with} path_name @{ , path_name @} ;
15336 A path name denotes a project file. A path name can be absolute or relative.
15337 An absolute path name includes a sequence of directories, in the syntax of
15338 the host operating system, that identifies uniquely the project file in the
15339 file system. A relative path name identifies the project file, relative
15340 to the directory that contains the current project, or relative to a
15341 directory listed in the environment variable ADA_PROJECT_PATH.
15342 Path names are case sensitive if file names in the host operating system
15343 are case sensitive.
15345 The syntax of the environment variable ADA_PROJECT_PATH is a list of
15346 directory names separated by colons (semicolons on Windows).
15348 A given project name can appear only once in a context_clause.
15350 It is illegal for a project imported by a context clause to refer, directly
15351 or indirectly, to the project in which this context clause appears (the
15352 dependency graph cannot contain cycles), except when one of the with_clause
15353 in the cycle is a @code{limited with}.
15355 @node Project Extensions
15356 @section Project Extensions
15359 A project extension introduces a new project, which inherits the declarations
15360 of another project.
15364 project_extension ::=
15365 @b{project} <project_>simple_name @b{extends} path_name @b{is}
15366 @{declarative_item@}
15367 @b{end} <project_>simple_name;
15371 The project extension declares a child project. The child project inherits
15372 all the declarations and all the files of the parent project, These inherited
15373 declaration can be overridden in the child project, by means of suitable
15376 @node Project File Elaboration
15377 @section Project File Elaboration
15380 A project file is processed as part of the invocation of a gnat tool that
15381 uses the project option. Elaboration of the process file consists in the
15382 sequential elaboration of all its declarations. The computed values of
15383 attributes and variables in the project are then used to establish the
15384 environment in which the gnat tool will execute.
15386 @node Obsolescent Features
15387 @chapter Obsolescent Features
15390 This chapter describes features that are provided by GNAT, but are
15391 considered obsolescent since there are preferred ways of achieving
15392 the same effect. These features are provided solely for historical
15393 compatibility purposes.
15396 * pragma No_Run_Time::
15397 * pragma Ravenscar::
15398 * pragma Restricted_Run_Time::
15401 @node pragma No_Run_Time
15402 @section pragma No_Run_Time
15404 The pragma @code{No_Run_Time} is used to achieve an affect similar
15405 to the use of the "Zero Foot Print" configurable run time, but without
15406 requiring a specially configured run time. The result of using this
15407 pragma, which must be used for all units in a partition, is to restrict
15408 the use of any language features requiring run-time support code. The
15409 preferred usage is to use an appropriately configured run-time that
15410 includes just those features that are to be made accessible.
15412 @node pragma Ravenscar
15413 @section pragma Ravenscar
15415 The pragma @code{Ravenscar} has exactly the same effect as pragma
15416 @code{Profile (Ravenscar)}. The latter usage is preferred since it
15417 is part of the new Ada 2005 standard.
15419 @node pragma Restricted_Run_Time
15420 @section pragma Restricted_Run_Time
15422 The pragma @code{Restricted_Run_Time} has exactly the same effect as
15423 pragma @code{Profile (Restricted)}. The latter usage is
15424 preferred since the Ada 2005 pragma @code{Profile} is intended for
15425 this kind of implementation dependent addition.
15428 @c GNU Free Documentation License
15430 @node Index,,GNU Free Documentation License, Top