1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c Copyright (C) 1995-2007, 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
21 @set DEFAULTLANGUAGEVERSION Ada 2005
22 @set NONDEFAULTLANGUAGEVERSION Ada 95
24 @settitle GNAT Reference Manual
26 @setchapternewpage odd
29 @include gcc-common.texi
31 @dircategory GNU Ada tools
33 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
37 Copyright @copyright{} 1995-2007, Free Software Foundation
39 Permission is granted to copy, distribute and/or modify this document
40 under the terms of the GNU Free Documentation License, Version 1.2
41 or any later version published by the Free Software Foundation;
42 with the Invariant Sections being ``GNU Free Documentation License'',
43 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
44 no Back-Cover Texts. A copy of the license is included in the section
45 entitled ``GNU Free Documentation License''.
49 @title GNAT Reference Manual
50 @subtitle GNAT, The GNU Ada Compiler
54 @vskip 0pt plus 1filll
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
68 GNAT, The GNU Ada 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::
110 * Pragma C_Pass_By_Copy::
111 * Pragma Check_Name::
113 * Pragma Common_Object::
114 * Pragma Compile_Time_Error::
115 * Pragma Compile_Time_Warning::
116 * Pragma Complete_Representation::
117 * Pragma Complex_Representation::
118 * Pragma Component_Alignment::
119 * Pragma Convention_Identifier::
121 * Pragma CPP_Constructor::
122 * Pragma CPP_Virtual::
123 * Pragma CPP_Vtable::
125 * Pragma Debug_Policy::
126 * Pragma Detect_Blocking::
127 * Pragma Elaboration_Checks::
129 * Pragma Export_Exception::
130 * Pragma Export_Function::
131 * Pragma Export_Object::
132 * Pragma Export_Procedure::
133 * Pragma Export_Value::
134 * Pragma Export_Valued_Procedure::
135 * Pragma Extend_System::
137 * Pragma External_Name_Casing::
138 * Pragma Finalize_Storage_Only::
139 * Pragma Float_Representation::
141 * Pragma Implicit_Packing::
142 * Pragma Import_Exception::
143 * Pragma Import_Function::
144 * Pragma Import_Object::
145 * Pragma Import_Procedure::
146 * Pragma Import_Valued_Procedure::
147 * Pragma Initialize_Scalars::
148 * Pragma Inline_Always::
149 * Pragma Inline_Generic::
151 * Pragma Interface_Name::
152 * Pragma Interrupt_Handler::
153 * Pragma Interrupt_State::
154 * Pragma Keep_Names::
157 * Pragma Linker_Alias::
158 * Pragma Linker_Constructor::
159 * Pragma Linker_Destructor::
160 * Pragma Linker_Section::
161 * Pragma Long_Float::
162 * Pragma Machine_Attribute::
164 * Pragma Main_Storage::
167 * Pragma No_Strict_Aliasing ::
168 * Pragma Normalize_Scalars::
169 * Pragma Obsolescent::
171 * Pragma Persistent_BSS::
173 * Pragma Profile (Ravenscar)::
174 * Pragma Profile (Restricted)::
175 * Pragma Psect_Object::
176 * Pragma Pure_Function::
177 * Pragma Restriction_Warnings::
178 * Pragma Source_File_Name::
179 * Pragma Source_File_Name_Project::
180 * Pragma Source_Reference::
181 * Pragma Stream_Convert::
182 * Pragma Style_Checks::
185 * Pragma Suppress_All::
186 * Pragma Suppress_Exception_Locations::
187 * Pragma Suppress_Initialization::
190 * Pragma Task_Storage::
191 * Pragma Time_Slice::
193 * Pragma Unchecked_Union::
194 * Pragma Unimplemented_Unit::
195 * Pragma Universal_Aliasing ::
196 * Pragma Universal_Data::
197 * Pragma Unreferenced::
198 * Pragma Unreferenced_Objects::
199 * Pragma Unreserve_All_Interrupts::
200 * Pragma Unsuppress::
201 * Pragma Use_VADS_Size::
202 * Pragma Validity_Checks::
205 * Pragma Weak_External::
206 * Pragma Wide_Character_Encoding::
208 Implementation Defined Attributes
218 * Default_Bit_Order::
227 * Has_Access_Values::
228 * Has_Discriminants::
234 * Max_Interrupt_Priority::
236 * Maximum_Alignment::
240 * Passed_By_Reference::
252 * Unconstrained_Array::
253 * Universal_Literal_String::
254 * Unrestricted_Access::
260 The Implementation of Standard I/O
262 * Standard I/O Packages::
268 * Wide_Wide_Text_IO::
271 * Filenames encoding::
273 * Operations on C Streams::
274 * Interfacing to C Streams::
278 * Ada.Characters.Latin_9 (a-chlat9.ads)::
279 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
280 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
281 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
282 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
283 * Ada.Command_Line.Remove (a-colire.ads)::
284 * Ada.Command_Line.Environment (a-colien.ads)::
285 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
286 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
287 * Ada.Exceptions.Traceback (a-exctra.ads)::
288 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
289 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
290 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
291 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
292 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
293 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
294 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
295 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
296 * GNAT.Altivec (g-altive.ads)::
297 * GNAT.Altivec.Conversions (g-altcon.ads)::
298 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
299 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
300 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
301 * GNAT.Array_Split (g-arrspl.ads)::
302 * GNAT.AWK (g-awk.ads)::
303 * GNAT.Bounded_Buffers (g-boubuf.ads)::
304 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
305 * GNAT.Bubble_Sort (g-bubsor.ads)::
306 * GNAT.Bubble_Sort_A (g-busora.ads)::
307 * GNAT.Bubble_Sort_G (g-busorg.ads)::
308 * GNAT.Byte_Swapping (g-bytswa.ads)::
309 * GNAT.Calendar (g-calend.ads)::
310 * GNAT.Calendar.Time_IO (g-catiio.ads)::
311 * GNAT.Case_Util (g-casuti.ads)::
312 * GNAT.CGI (g-cgi.ads)::
313 * GNAT.CGI.Cookie (g-cgicoo.ads)::
314 * GNAT.CGI.Debug (g-cgideb.ads)::
315 * GNAT.Command_Line (g-comlin.ads)::
316 * GNAT.Compiler_Version (g-comver.ads)::
317 * GNAT.Ctrl_C (g-ctrl_c.ads)::
318 * GNAT.CRC32 (g-crc32.ads)::
319 * GNAT.Current_Exception (g-curexc.ads)::
320 * GNAT.Debug_Pools (g-debpoo.ads)::
321 * GNAT.Debug_Utilities (g-debuti.ads)::
322 * GNAT.Directory_Operations (g-dirope.ads)::
323 * GNAT.Dynamic_HTables (g-dynhta.ads)::
324 * GNAT.Dynamic_Tables (g-dyntab.ads)::
325 * GNAT.Exception_Actions (g-excact.ads)::
326 * GNAT.Exception_Traces (g-exctra.ads)::
327 * GNAT.Exceptions (g-except.ads)::
328 * GNAT.Expect (g-expect.ads)::
329 * GNAT.Float_Control (g-flocon.ads)::
330 * GNAT.Heap_Sort (g-heasor.ads)::
331 * GNAT.Heap_Sort_A (g-hesora.ads)::
332 * GNAT.Heap_Sort_G (g-hesorg.ads)::
333 * GNAT.HTable (g-htable.ads)::
334 * GNAT.IO (g-io.ads)::
335 * GNAT.IO_Aux (g-io_aux.ads)::
336 * GNAT.Lock_Files (g-locfil.ads)::
337 * GNAT.MD5 (g-md5.ads)::
338 * GNAT.Memory_Dump (g-memdum.ads)::
339 * GNAT.Most_Recent_Exception (g-moreex.ads)::
340 * GNAT.OS_Lib (g-os_lib.ads)::
341 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
342 * GNAT.Regexp (g-regexp.ads)::
343 * GNAT.Registry (g-regist.ads)::
344 * GNAT.Regpat (g-regpat.ads)::
345 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
346 * GNAT.Semaphores (g-semaph.ads)::
347 * GNAT.SHA1 (g-sha1.ads)::
348 * GNAT.Signals (g-signal.ads)::
349 * GNAT.Sockets (g-socket.ads)::
350 * GNAT.Source_Info (g-souinf.ads)::
351 * GNAT.Spell_Checker (g-speche.ads)::
352 * GNAT.Spitbol.Patterns (g-spipat.ads)::
353 * GNAT.Spitbol (g-spitbo.ads)::
354 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
355 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
356 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
357 * GNAT.Strings (g-string.ads)::
358 * GNAT.String_Split (g-strspl.ads)::
359 * GNAT.Table (g-table.ads)::
360 * GNAT.Task_Lock (g-tasloc.ads)::
361 * GNAT.Threads (g-thread.ads)::
362 * GNAT.Traceback (g-traceb.ads)::
363 * GNAT.Traceback.Symbolic (g-trasym.ads)::
364 * GNAT.Wide_String_Split (g-wistsp.ads)::
365 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
366 * Interfaces.C.Extensions (i-cexten.ads)::
367 * Interfaces.C.Streams (i-cstrea.ads)::
368 * Interfaces.CPP (i-cpp.ads)::
369 * Interfaces.Os2lib (i-os2lib.ads)::
370 * Interfaces.Os2lib.Errors (i-os2err.ads)::
371 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
372 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
373 * Interfaces.Packed_Decimal (i-pacdec.ads)::
374 * Interfaces.VxWorks (i-vxwork.ads)::
375 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
376 * System.Address_Image (s-addima.ads)::
377 * System.Assertions (s-assert.ads)::
378 * System.Memory (s-memory.ads)::
379 * System.Partition_Interface (s-parint.ads)::
380 * System.Restrictions (s-restri.ads)::
381 * System.Rident (s-rident.ads)::
382 * System.Task_Info (s-tasinf.ads)::
383 * System.Wch_Cnv (s-wchcnv.ads)::
384 * System.Wch_Con (s-wchcon.ads)::
388 * Text_IO Stream Pointer Positioning::
389 * Text_IO Reading and Writing Non-Regular Files::
391 * Treating Text_IO Files as Streams::
392 * Text_IO Extensions::
393 * Text_IO Facilities for Unbounded Strings::
397 * Wide_Text_IO Stream Pointer Positioning::
398 * Wide_Text_IO Reading and Writing Non-Regular Files::
402 * Wide_Wide_Text_IO Stream Pointer Positioning::
403 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
405 Interfacing to Other Languages
408 * Interfacing to C++::
409 * Interfacing to COBOL::
410 * Interfacing to Fortran::
411 * Interfacing to non-GNAT Ada code::
413 Specialized Needs Annexes
415 Implementation of Specific Ada Features
416 * Machine Code Insertions::
417 * GNAT Implementation of Tasking::
418 * GNAT Implementation of Shared Passive Packages::
419 * Code Generation for Array Aggregates::
420 * The Size of Discriminated Records with Default Discriminants::
421 * Strict Conformance to the Ada Reference Manual::
423 Project File Reference
427 GNU Free Documentation License
434 @node About This Guide
435 @unnumbered About This Guide
438 This manual contains useful information in writing programs using the
439 @value{EDITION} compiler. It includes information on implementation dependent
440 characteristics of @value{EDITION}, including all the information required by
441 Annex M of the Ada language standard.
443 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
444 Ada 83 compatibility mode.
445 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
446 but you can override with a compiler switch
447 to explicitly specify the language version.
448 (Please refer to the section ``Compiling Different Versions of Ada'', in
449 @cite{@value{EDITION} User's Guide}, for details on these switches.)
450 Throughout this manual, references to ``Ada'' without a year suffix
451 apply to both the Ada 95 and Ada 2005 versions of the language.
453 Ada is designed to be highly portable.
454 In general, a program will have the same effect even when compiled by
455 different compilers on different platforms.
456 However, since Ada is designed to be used in a
457 wide variety of applications, it also contains a number of system
458 dependent features to be used in interfacing to the external world.
459 @cindex Implementation-dependent features
462 Note: Any program that makes use of implementation-dependent features
463 may be non-portable. You should follow good programming practice and
464 isolate and clearly document any sections of your program that make use
465 of these features in a non-portable manner.
468 For ease of exposition, ``GNAT Pro'' will be referred to simply as
469 ``GNAT'' in the remainder of this document.
473 * What This Reference Manual Contains::
475 * Related Information::
478 @node What This Reference Manual Contains
479 @unnumberedsec What This Reference Manual Contains
482 This reference manual contains the following chapters:
486 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
487 pragmas, which can be used to extend and enhance the functionality of the
491 @ref{Implementation Defined Attributes}, lists GNAT
492 implementation-dependent attributes which can be used to extend and
493 enhance the functionality of the compiler.
496 @ref{Implementation Advice}, provides information on generally
497 desirable behavior which are not requirements that all compilers must
498 follow since it cannot be provided on all systems, or which may be
499 undesirable on some systems.
502 @ref{Implementation Defined Characteristics}, provides a guide to
503 minimizing implementation dependent features.
506 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
507 implemented by GNAT, and how they can be imported into user
508 application programs.
511 @ref{Representation Clauses and Pragmas}, describes in detail the
512 way that GNAT represents data, and in particular the exact set
513 of representation clauses and pragmas that is accepted.
516 @ref{Standard Library Routines}, provides a listing of packages and a
517 brief description of the functionality that is provided by Ada's
518 extensive set of standard library routines as implemented by GNAT@.
521 @ref{The Implementation of Standard I/O}, details how the GNAT
522 implementation of the input-output facilities.
525 @ref{The GNAT Library}, is a catalog of packages that complement
526 the Ada predefined library.
529 @ref{Interfacing to Other Languages}, describes how programs
530 written in Ada using GNAT can be interfaced to other programming
533 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
534 of the specialized needs annexes.
537 @ref{Implementation of Specific Ada Features}, discusses issues related
538 to GNAT's implementation of machine code insertions, tasking, and several
542 @ref{Project File Reference}, presents the syntax and semantics
546 @ref{Obsolescent Features} documents implementation dependent features,
547 including pragmas and attributes, which are considered obsolescent, since
548 there are other preferred ways of achieving the same results. These
549 obsolescent forms are retained for backwards compatibility.
553 @cindex Ada 95 Language Reference Manual
554 @cindex Ada 2005 Language Reference Manual
556 This reference manual assumes a basic familiarity with the Ada 95 language, as
557 described in the International Standard ANSI/ISO/IEC-8652:1995,
559 It does not require knowledge of the new features introduced by Ada 2005,
560 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
562 Both reference manuals are included in the GNAT documentation
566 @unnumberedsec Conventions
567 @cindex Conventions, typographical
568 @cindex Typographical conventions
571 Following are examples of the typographical and graphic conventions used
576 @code{Functions}, @code{utility program names}, @code{standard names},
583 @file{File Names}, @samp{button names}, and @samp{field names}.
592 [optional information or parameters]
595 Examples are described by text
597 and then shown this way.
602 Commands that are entered by the user are preceded in this manual by the
603 characters @samp{$ } (dollar sign followed by space). If your system uses this
604 sequence as a prompt, then the commands will appear exactly as you see them
605 in the manual. If your system uses some other prompt, then the command will
606 appear with the @samp{$} replaced by whatever prompt character you are using.
608 @node Related Information
609 @unnumberedsec Related Information
611 See the following documents for further information on GNAT:
615 @cite{GNAT User's Guide}, which provides information on how to use
616 the GNAT compiler system.
619 @cite{Ada 95 Reference Manual}, which contains all reference
620 material for the Ada 95 programming language.
623 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
624 of the Ada 95 standard. The annotations describe
625 detailed aspects of the design decision, and in particular contain useful
626 sections on Ada 83 compatibility.
629 @cite{Ada 2005 Reference Manual}, which contains all reference
630 material for the Ada 2005 programming language.
633 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
634 of the Ada 2005 standard. The annotations describe
635 detailed aspects of the design decision, and in particular contain useful
636 sections on Ada 83 and Ada 95 compatibility.
639 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
640 which contains specific information on compatibility between GNAT and
644 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
645 describes in detail the pragmas and attributes provided by the DEC Ada 83
650 @node Implementation Defined Pragmas
651 @chapter Implementation Defined Pragmas
654 Ada defines a set of pragmas that can be used to supply additional
655 information to the compiler. These language defined pragmas are
656 implemented in GNAT and work as described in the Ada Reference
659 In addition, Ada allows implementations to define additional pragmas
660 whose meaning is defined by the implementation. GNAT provides a number
661 of these implementation-dependent pragmas which can be used to extend
662 and enhance the functionality of the compiler. This section of the GNAT
663 Reference Manual describes these additional pragmas.
665 Note that any program using these pragmas may not be portable to other
666 compilers (although GNAT implements this set of pragmas on all
667 platforms). Therefore if portability to other compilers is an important
668 consideration, the use of these pragmas should be minimized.
671 * Pragma Abort_Defer::
679 * Pragma C_Pass_By_Copy::
680 * Pragma Check_Name::
682 * Pragma Common_Object::
683 * Pragma Compile_Time_Error::
684 * Pragma Compile_Time_Warning::
685 * Pragma Complete_Representation::
686 * Pragma Complex_Representation::
687 * Pragma Component_Alignment::
688 * Pragma Convention_Identifier::
690 * Pragma CPP_Constructor::
691 * Pragma CPP_Virtual::
692 * Pragma CPP_Vtable::
694 * Pragma Debug_Policy::
695 * Pragma Detect_Blocking::
696 * Pragma Elaboration_Checks::
698 * Pragma Export_Exception::
699 * Pragma Export_Function::
700 * Pragma Export_Object::
701 * Pragma Export_Procedure::
702 * Pragma Export_Value::
703 * Pragma Export_Valued_Procedure::
704 * Pragma Extend_System::
706 * Pragma External_Name_Casing::
707 * Pragma Finalize_Storage_Only::
708 * Pragma Float_Representation::
710 * Pragma Implicit_Packing::
711 * Pragma Import_Exception::
712 * Pragma Import_Function::
713 * Pragma Import_Object::
714 * Pragma Import_Procedure::
715 * Pragma Import_Valued_Procedure::
716 * Pragma Initialize_Scalars::
717 * Pragma Inline_Always::
718 * Pragma Inline_Generic::
720 * Pragma Interface_Name::
721 * Pragma Interrupt_Handler::
722 * Pragma Interrupt_State::
723 * Pragma Keep_Names::
726 * Pragma Linker_Alias::
727 * Pragma Linker_Constructor::
728 * Pragma Linker_Destructor::
729 * Pragma Linker_Section::
730 * Pragma Long_Float::
731 * Pragma Machine_Attribute::
733 * Pragma Main_Storage::
736 * Pragma No_Strict_Aliasing::
737 * Pragma Normalize_Scalars::
738 * Pragma Obsolescent::
740 * Pragma Persistent_BSS::
742 * Pragma Profile (Ravenscar)::
743 * Pragma Profile (Restricted)::
744 * Pragma Psect_Object::
745 * Pragma Pure_Function::
746 * Pragma Restriction_Warnings::
747 * Pragma Source_File_Name::
748 * Pragma Source_File_Name_Project::
749 * Pragma Source_Reference::
750 * Pragma Stream_Convert::
751 * Pragma Style_Checks::
754 * Pragma Suppress_All::
755 * Pragma Suppress_Exception_Locations::
756 * Pragma Suppress_Initialization::
759 * Pragma Task_Storage::
760 * Pragma Time_Slice::
762 * Pragma Unchecked_Union::
763 * Pragma Unimplemented_Unit::
764 * Pragma Universal_Aliasing ::
765 * Pragma Universal_Data::
766 * Pragma Unreferenced::
767 * Pragma Unreferenced_Objects::
768 * Pragma Unreserve_All_Interrupts::
769 * Pragma Unsuppress::
770 * Pragma Use_VADS_Size::
771 * Pragma Validity_Checks::
774 * Pragma Weak_External::
775 * Pragma Wide_Character_Encoding::
778 @node Pragma Abort_Defer
779 @unnumberedsec Pragma Abort_Defer
781 @cindex Deferring aborts
789 This pragma must appear at the start of the statement sequence of a
790 handled sequence of statements (right after the @code{begin}). It has
791 the effect of deferring aborts for the sequence of statements (but not
792 for the declarations or handlers, if any, associated with this statement
796 @unnumberedsec Pragma Ada_83
805 A configuration pragma that establishes Ada 83 mode for the unit to
806 which it applies, regardless of the mode set by the command line
807 switches. In Ada 83 mode, GNAT attempts to be as compatible with
808 the syntax and semantics of Ada 83, as defined in the original Ada
809 83 Reference Manual as possible. In particular, the keywords added by Ada 95
810 (and Ada 2005) are not recognized, optional package bodies are allowed,
811 and generics may name types with unknown discriminants without using
812 the @code{(<>)} notation. In addition, some but not all of the additional
813 restrictions of Ada 83 are enforced.
815 Ada 83 mode is intended for two purposes. Firstly, it allows existing
816 Ada 83 code to be compiled and adapted to GNAT with less effort.
817 Secondly, it aids in keeping code backwards compatible with Ada 83.
818 However, there is no guarantee that code that is processed correctly
819 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
820 83 compiler, since GNAT does not enforce all the additional checks
824 @unnumberedsec Pragma Ada_95
833 A configuration pragma that establishes Ada 95 mode for the unit to which
834 it applies, regardless of the mode set by the command line switches.
835 This mode is set automatically for the @code{Ada} and @code{System}
836 packages and their children, so you need not specify it in these
837 contexts. This pragma is useful when writing a reusable component that
838 itself uses Ada 95 features, but which is intended to be usable from
839 either Ada 83 or Ada 95 programs.
842 @unnumberedsec Pragma Ada_05
851 A configuration pragma that establishes Ada 2005 mode for the unit to which
852 it applies, regardless of the mode set by the command line switches.
853 This mode is set automatically for the @code{Ada} and @code{System}
854 packages and their children, so you need not specify it in these
855 contexts. This pragma is useful when writing a reusable component that
856 itself uses Ada 2005 features, but which is intended to be usable from
857 either Ada 83 or Ada 95 programs.
859 @node Pragma Ada_2005
860 @unnumberedsec Pragma Ada_2005
869 This configuration pragma is a synonym for pragma Ada_05 and has the
870 same syntax and effect.
872 @node Pragma Annotate
873 @unnumberedsec Pragma Annotate
878 pragma Annotate (IDENTIFIER @{, ARG@});
880 ARG ::= NAME | EXPRESSION
884 This pragma is used to annotate programs. @var{identifier} identifies
885 the type of annotation. GNAT verifies this is an identifier, but does
886 not otherwise analyze it. The @var{arg} argument
887 can be either a string literal or an
888 expression. String literals are assumed to be of type
889 @code{Standard.String}. Names of entities are simply analyzed as entity
890 names. All other expressions are analyzed as expressions, and must be
893 The analyzed pragma is retained in the tree, but not otherwise processed
894 by any part of the GNAT compiler. This pragma is intended for use by
895 external tools, including ASIS@.
898 @unnumberedsec Pragma Assert
905 [, static_string_EXPRESSION]);
909 The effect of this pragma depends on whether the corresponding command
910 line switch is set to activate assertions. The pragma expands into code
911 equivalent to the following:
914 if assertions-enabled then
915 if not boolean_EXPRESSION then
916 System.Assertions.Raise_Assert_Failure
923 The string argument, if given, is the message that will be associated
924 with the exception occurrence if the exception is raised. If no second
925 argument is given, the default message is @samp{@var{file}:@var{nnn}},
926 where @var{file} is the name of the source file containing the assert,
927 and @var{nnn} is the line number of the assert. A pragma is not a
928 statement, so if a statement sequence contains nothing but a pragma
929 assert, then a null statement is required in addition, as in:
934 pragma Assert (K > 3, "Bad value for K");
940 Note that, as with the @code{if} statement to which it is equivalent, the
941 type of the expression is either @code{Standard.Boolean}, or any type derived
942 from this standard type.
944 If assertions are disabled (switch @code{-gnata} not used), then there
945 is no effect (and in particular, any side effects from the expression
946 are suppressed). More precisely it is not quite true that the pragma
947 has no effect, since the expression is analyzed, and may cause types
948 to be frozen if they are mentioned here for the first time.
950 If assertions are enabled, then the given expression is tested, and if
951 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
952 which results in the raising of @code{Assert_Failure} with the given message.
954 If the boolean expression has side effects, these side effects will turn
955 on and off with the setting of the assertions mode, resulting in
956 assertions that have an effect on the program. You should generally
957 avoid side effects in the expression arguments of this pragma. However,
958 the expressions are analyzed for semantic correctness whether or not
959 assertions are enabled, so turning assertions on and off cannot affect
960 the legality of a program.
962 @node Pragma Ast_Entry
963 @unnumberedsec Pragma Ast_Entry
969 pragma AST_Entry (entry_IDENTIFIER);
973 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
974 argument is the simple name of a single entry; at most one @code{AST_Entry}
975 pragma is allowed for any given entry. This pragma must be used in
976 conjunction with the @code{AST_Entry} attribute, and is only allowed after
977 the entry declaration and in the same task type specification or single task
978 as the entry to which it applies. This pragma specifies that the given entry
979 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
980 resulting from an OpenVMS system service call. The pragma does not affect
981 normal use of the entry. For further details on this pragma, see the
982 DEC Ada Language Reference Manual, section 9.12a.
984 @node Pragma C_Pass_By_Copy
985 @unnumberedsec Pragma C_Pass_By_Copy
986 @cindex Passing by copy
987 @findex C_Pass_By_Copy
991 pragma C_Pass_By_Copy
992 ([Max_Size =>] static_integer_EXPRESSION);
996 Normally the default mechanism for passing C convention records to C
997 convention subprograms is to pass them by reference, as suggested by RM
998 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
999 this default, by requiring that record formal parameters be passed by
1000 copy if all of the following conditions are met:
1004 The size of the record type does not exceed@*@var{static_integer_expression}.
1006 The record type has @code{Convention C}.
1008 The formal parameter has this record type, and the subprogram has a
1009 foreign (non-Ada) convention.
1013 If these conditions are met the argument is passed by copy, i.e.@: in a
1014 manner consistent with what C expects if the corresponding formal in the
1015 C prototype is a struct (rather than a pointer to a struct).
1017 You can also pass records by copy by specifying the convention
1018 @code{C_Pass_By_Copy} for the record type, or by using the extended
1019 @code{Import} and @code{Export} pragmas, which allow specification of
1020 passing mechanisms on a parameter by parameter basis.
1022 @node Pragma Check_Name
1023 @unnumberedsec Pragma Check_Name
1024 @cindex Defining check names
1025 @cindex Check names, defining
1029 @smallexample @c ada
1030 pragma Check_Name (check_name_IDENTIFIER);
1034 This is a configuration pragma which defines a new implementation
1035 defined check name (unless IDENTIFIER matches one of the predefined
1036 check names, in which case the pragma has no effect). Check names
1037 are global to a partition, so if two more more configuration pragmas
1038 are present in a partition mentioning the same name, only one new
1039 check name is introduced.
1041 An implementation defined check name introduced with this pragma may
1042 be used in only three contexts: @code{pragma Suppress},
1043 @code{pragma Unsuppress},
1044 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1045 any of these three cases, the check name must be visible. A check
1046 name is visible if it is in the configuration pragmas applying to
1047 the current unit, or if it appears at the start of any unit that
1048 is part of the dependency set of the current unit (e.g. units that
1049 are mentioned in @code{with} clauses.
1051 Normally the default mechanism for passing C convention records to C
1052 @node Pragma Comment
1053 @unnumberedsec Pragma Comment
1058 @smallexample @c ada
1059 pragma Comment (static_string_EXPRESSION);
1063 This is almost identical in effect to pragma @code{Ident}. It allows the
1064 placement of a comment into the object file and hence into the
1065 executable file if the operating system permits such usage. The
1066 difference is that @code{Comment}, unlike @code{Ident}, has
1067 no limitations on placement of the pragma (it can be placed
1068 anywhere in the main source unit), and if more than one pragma
1069 is used, all comments are retained.
1071 @node Pragma Common_Object
1072 @unnumberedsec Pragma Common_Object
1073 @findex Common_Object
1077 @smallexample @c ada
1078 pragma Common_Object (
1079 [Internal =>] local_NAME,
1080 [, [External =>] EXTERNAL_SYMBOL]
1081 [, [Size =>] EXTERNAL_SYMBOL] );
1085 | static_string_EXPRESSION
1089 This pragma enables the shared use of variables stored in overlaid
1090 linker areas corresponding to the use of @code{COMMON}
1091 in Fortran. The single
1092 object @var{local_NAME} is assigned to the area designated by
1093 the @var{External} argument.
1094 You may define a record to correspond to a series
1095 of fields. The @var{size} argument
1096 is syntax checked in GNAT, but otherwise ignored.
1098 @code{Common_Object} is not supported on all platforms. If no
1099 support is available, then the code generator will issue a message
1100 indicating that the necessary attribute for implementation of this
1101 pragma is not available.
1103 @node Pragma Compile_Time_Error
1104 @unnumberedsec Pragma Compile_Time_Error
1105 @findex Compile_Time_Error
1109 @smallexample @c ada
1110 pragma Compile_Time_Error
1111 (boolean_EXPRESSION, static_string_EXPRESSION);
1115 This pragma can be used to generate additional compile time
1117 is particularly useful in generics, where errors can be issued for
1118 specific problematic instantiations. The first parameter is a boolean
1119 expression. The pragma is effective only if the value of this expression
1120 is known at compile time, and has the value True. The set of expressions
1121 whose values are known at compile time includes all static boolean
1122 expressions, and also other values which the compiler can determine
1123 at compile time (e.g. the size of a record type set by an explicit
1124 size representation clause, or the value of a variable which was
1125 initialized to a constant and is known not to have been modified).
1126 If these conditions are met, an error message is generated using
1127 the value given as the second argument. This string value may contain
1128 embedded ASCII.LF characters to break the message into multiple lines.
1130 @node Pragma Compile_Time_Warning
1131 @unnumberedsec Pragma Compile_Time_Warning
1132 @findex Compile_Time_Warning
1136 @smallexample @c ada
1137 pragma Compile_Time_Warning
1138 (boolean_EXPRESSION, static_string_EXPRESSION);
1142 This pragma can be used to generate additional compile time warnings. It
1143 is particularly useful in generics, where warnings can be issued for
1144 specific problematic instantiations. The first parameter is a boolean
1145 expression. The pragma is effective only if the value of this expression
1146 is known at compile time, and has the value True. The set of expressions
1147 whose values are known at compile time includes all static boolean
1148 expressions, and also other values which the compiler can determine
1149 at compile time (e.g. the size of a record type set by an explicit
1150 size representation clause, or the value of a variable which was
1151 initialized to a constant and is known not to have been modified).
1152 If these conditions are met, a warning message is generated using
1153 the value given as the second argument. This string value may contain
1154 embedded ASCII.LF characters to break the message into multiple lines.
1156 @node Pragma Complete_Representation
1157 @unnumberedsec Pragma Complete_Representation
1158 @findex Complete_Representation
1162 @smallexample @c ada
1163 pragma Complete_Representation;
1167 This pragma must appear immediately within a record representation
1168 clause. Typical placements are before the first component clause
1169 or after the last component clause. The effect is to give an error
1170 message if any component is missing a component clause. This pragma
1171 may be used to ensure that a record representation clause is
1172 complete, and that this invariant is maintained if fields are
1173 added to the record in the future.
1175 @node Pragma Complex_Representation
1176 @unnumberedsec Pragma Complex_Representation
1177 @findex Complex_Representation
1181 @smallexample @c ada
1182 pragma Complex_Representation
1183 ([Entity =>] local_NAME);
1187 The @var{Entity} argument must be the name of a record type which has
1188 two fields of the same floating-point type. The effect of this pragma is
1189 to force gcc to use the special internal complex representation form for
1190 this record, which may be more efficient. Note that this may result in
1191 the code for this type not conforming to standard ABI (application
1192 binary interface) requirements for the handling of record types. For
1193 example, in some environments, there is a requirement for passing
1194 records by pointer, and the use of this pragma may result in passing
1195 this type in floating-point registers.
1197 @node Pragma Component_Alignment
1198 @unnumberedsec Pragma Component_Alignment
1199 @cindex Alignments of components
1200 @findex Component_Alignment
1204 @smallexample @c ada
1205 pragma Component_Alignment (
1206 [Form =>] ALIGNMENT_CHOICE
1207 [, [Name =>] type_local_NAME]);
1209 ALIGNMENT_CHOICE ::=
1217 Specifies the alignment of components in array or record types.
1218 The meaning of the @var{Form} argument is as follows:
1221 @findex Component_Size
1222 @item Component_Size
1223 Aligns scalar components and subcomponents of the array or record type
1224 on boundaries appropriate to their inherent size (naturally
1225 aligned). For example, 1-byte components are aligned on byte boundaries,
1226 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1227 integer components are aligned on 4-byte boundaries and so on. These
1228 alignment rules correspond to the normal rules for C compilers on all
1229 machines except the VAX@.
1231 @findex Component_Size_4
1232 @item Component_Size_4
1233 Naturally aligns components with a size of four or fewer
1234 bytes. Components that are larger than 4 bytes are placed on the next
1237 @findex Storage_Unit
1239 Specifies that array or record components are byte aligned, i.e.@:
1240 aligned on boundaries determined by the value of the constant
1241 @code{System.Storage_Unit}.
1245 Specifies that array or record components are aligned on default
1246 boundaries, appropriate to the underlying hardware or operating system or
1247 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1248 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1249 the @code{Default} choice is the same as @code{Component_Size} (natural
1254 If the @code{Name} parameter is present, @var{type_local_NAME} must
1255 refer to a local record or array type, and the specified alignment
1256 choice applies to the specified type. The use of
1257 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1258 @code{Component_Alignment} pragma to be ignored. The use of
1259 @code{Component_Alignment} together with a record representation clause
1260 is only effective for fields not specified by the representation clause.
1262 If the @code{Name} parameter is absent, the pragma can be used as either
1263 a configuration pragma, in which case it applies to one or more units in
1264 accordance with the normal rules for configuration pragmas, or it can be
1265 used within a declarative part, in which case it applies to types that
1266 are declared within this declarative part, or within any nested scope
1267 within this declarative part. In either case it specifies the alignment
1268 to be applied to any record or array type which has otherwise standard
1271 If the alignment for a record or array type is not specified (using
1272 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1273 clause), the GNAT uses the default alignment as described previously.
1275 @node Pragma Convention_Identifier
1276 @unnumberedsec Pragma Convention_Identifier
1277 @findex Convention_Identifier
1278 @cindex Conventions, synonyms
1282 @smallexample @c ada
1283 pragma Convention_Identifier (
1284 [Name =>] IDENTIFIER,
1285 [Convention =>] convention_IDENTIFIER);
1289 This pragma provides a mechanism for supplying synonyms for existing
1290 convention identifiers. The @code{Name} identifier can subsequently
1291 be used as a synonym for the given convention in other pragmas (including
1292 for example pragma @code{Import} or another @code{Convention_Identifier}
1293 pragma). As an example of the use of this, suppose you had legacy code
1294 which used Fortran77 as the identifier for Fortran. Then the pragma:
1296 @smallexample @c ada
1297 pragma Convention_Identifier (Fortran77, Fortran);
1301 would allow the use of the convention identifier @code{Fortran77} in
1302 subsequent code, avoiding the need to modify the sources. As another
1303 example, you could use this to parametrize convention requirements
1304 according to systems. Suppose you needed to use @code{Stdcall} on
1305 windows systems, and @code{C} on some other system, then you could
1306 define a convention identifier @code{Library} and use a single
1307 @code{Convention_Identifier} pragma to specify which convention
1308 would be used system-wide.
1310 @node Pragma CPP_Class
1311 @unnumberedsec Pragma CPP_Class
1313 @cindex Interfacing with C++
1317 @smallexample @c ada
1318 pragma CPP_Class ([Entity =>] local_NAME);
1322 The argument denotes an entity in the current declarative region that is
1323 declared as a tagged record type. It indicates that the type corresponds
1324 to an externally declared C++ class type, and is to be laid out the same
1325 way that C++ would lay out the type.
1327 Types for which @code{CPP_Class} is specified do not have assignment or
1328 equality operators defined (such operations can be imported or declared
1329 as subprograms as required). Initialization is allowed only by constructor
1330 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1331 limited if not explicitly declared as limited or derived from a limited
1332 type, and a warning is issued in that case.
1334 Pragma @code{CPP_Class} is intended primarily for automatic generation
1335 using an automatic binding generator tool.
1336 See @ref{Interfacing to C++} for related information.
1338 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1339 for backward compatibility but its functionality is available
1340 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1342 @node Pragma CPP_Constructor
1343 @unnumberedsec Pragma CPP_Constructor
1344 @cindex Interfacing with C++
1345 @findex CPP_Constructor
1349 @smallexample @c ada
1350 pragma CPP_Constructor ([Entity =>] local_NAME
1351 [, [External_Name =>] static_string_EXPRESSION ]
1352 [, [Link_Name =>] static_string_EXPRESSION ]);
1356 This pragma identifies an imported function (imported in the usual way
1357 with pragma @code{Import}) as corresponding to a C++ constructor. If
1358 @code{External_Name} and @code{Link_Name} are not specified then the
1359 @code{Entity} argument is a name that must have been previously mentioned
1360 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1361 must be of one of the following forms:
1365 @code{function @var{Fname} return @var{T}'Class}
1368 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1372 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1374 The first form is the default constructor, used when an object of type
1375 @var{T} is created on the Ada side with no explicit constructor. Other
1376 constructors (including the copy constructor, which is simply a special
1377 case of the second form in which the one and only argument is of type
1378 @var{T}), can only appear in two contexts:
1382 On the right side of an initialization of an object of type @var{T}.
1384 In an extension aggregate for an object of a type derived from @var{T}.
1388 Although the constructor is described as a function that returns a value
1389 on the Ada side, it is typically a procedure with an extra implicit
1390 argument (the object being initialized) at the implementation
1391 level. GNAT issues the appropriate call, whatever it is, to get the
1392 object properly initialized.
1394 In the case of derived objects, you may use one of two possible forms
1395 for declaring and creating an object:
1398 @item @code{New_Object : Derived_T}
1399 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1403 In the first case the default constructor is called and extension fields
1404 if any are initialized according to the default initialization
1405 expressions in the Ada declaration. In the second case, the given
1406 constructor is called and the extension aggregate indicates the explicit
1407 values of the extension fields.
1409 If no constructors are imported, it is impossible to create any objects
1410 on the Ada side. If no default constructor is imported, only the
1411 initialization forms using an explicit call to a constructor are
1414 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1415 using an automatic binding generator tool.
1416 See @ref{Interfacing to C++} for more related information.
1418 @node Pragma CPP_Virtual
1419 @unnumberedsec Pragma CPP_Virtual
1420 @cindex Interfacing to C++
1423 This pragma is now obsolete has has no effect because GNAT generates
1424 the same object layout than the G++ compiler.
1426 See @ref{Interfacing to C++} for related information.
1428 @node Pragma CPP_Vtable
1429 @unnumberedsec Pragma CPP_Vtable
1430 @cindex Interfacing with C++
1433 This pragma is now obsolete has has no effect because GNAT generates
1434 the same object layout than the G++ compiler.
1436 See @ref{Interfacing to C++} for related information.
1439 @unnumberedsec Pragma Debug
1444 @smallexample @c ada
1445 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1447 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1449 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1453 The procedure call argument has the syntactic form of an expression, meeting
1454 the syntactic requirements for pragmas.
1456 If debug pragmas are not enabled or if the condition is present and evaluates
1457 to False, this pragma has no effect. If debug pragmas are enabled, the
1458 semantics of the pragma is exactly equivalent to the procedure call statement
1459 corresponding to the argument with a terminating semicolon. Pragmas are
1460 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1461 intersperse calls to debug procedures in the middle of declarations. Debug
1462 pragmas can be enabled either by use of the command line switch @code{-gnata}
1463 or by use of the configuration pragma @code{Debug_Policy}.
1465 @node Pragma Debug_Policy
1466 @unnumberedsec Pragma Debug_Policy
1467 @findex Debug_Policy
1471 @smallexample @c ada
1472 pragma Debug_Policy (CHECK | IGNORE);
1476 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1477 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1478 This pragma overrides the effect of the @code{-gnata} switch on the
1481 @node Pragma Detect_Blocking
1482 @unnumberedsec Pragma Detect_Blocking
1483 @findex Detect_Blocking
1487 @smallexample @c ada
1488 pragma Detect_Blocking;
1492 This is a configuration pragma that forces the detection of potentially
1493 blocking operations within a protected operation, and to raise Program_Error
1496 @node Pragma Elaboration_Checks
1497 @unnumberedsec Pragma Elaboration_Checks
1498 @cindex Elaboration control
1499 @findex Elaboration_Checks
1503 @smallexample @c ada
1504 pragma Elaboration_Checks (Dynamic | Static);
1508 This is a configuration pragma that provides control over the
1509 elaboration model used by the compilation affected by the
1510 pragma. If the parameter is @code{Dynamic},
1511 then the dynamic elaboration
1512 model described in the Ada Reference Manual is used, as though
1513 the @code{-gnatE} switch had been specified on the command
1514 line. If the parameter is @code{Static}, then the default GNAT static
1515 model is used. This configuration pragma overrides the setting
1516 of the command line. For full details on the elaboration models
1517 used by the GNAT compiler, see section ``Elaboration Order
1518 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1520 @node Pragma Eliminate
1521 @unnumberedsec Pragma Eliminate
1522 @cindex Elimination of unused subprograms
1527 @smallexample @c ada
1529 [Unit_Name =>] IDENTIFIER |
1530 SELECTED_COMPONENT);
1533 [Unit_Name =>] IDENTIFIER |
1535 [Entity =>] IDENTIFIER |
1536 SELECTED_COMPONENT |
1538 [,OVERLOADING_RESOLUTION]);
1540 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1543 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1546 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1548 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1549 Result_Type => result_SUBTYPE_NAME]
1551 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1552 SUBTYPE_NAME ::= STRING_VALUE
1554 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1555 SOURCE_TRACE ::= STRING_VALUE
1557 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1561 This pragma indicates that the given entity is not used outside the
1562 compilation unit it is defined in. The entity must be an explicitly declared
1563 subprogram; this includes generic subprogram instances and
1564 subprograms declared in generic package instances.
1566 If the entity to be eliminated is a library level subprogram, then
1567 the first form of pragma @code{Eliminate} is used with only a single argument.
1568 In this form, the @code{Unit_Name} argument specifies the name of the
1569 library level unit to be eliminated.
1571 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1572 are required. If item is an entity of a library package, then the first
1573 argument specifies the unit name, and the second argument specifies
1574 the particular entity. If the second argument is in string form, it must
1575 correspond to the internal manner in which GNAT stores entity names (see
1576 compilation unit Namet in the compiler sources for details).
1578 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1579 to distinguish between overloaded subprograms. If a pragma does not contain
1580 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1581 subprograms denoted by the first two parameters.
1583 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1584 to be eliminated in a manner similar to that used for the extended
1585 @code{Import} and @code{Export} pragmas, except that the subtype names are
1586 always given as strings. At the moment, this form of distinguishing
1587 overloaded subprograms is implemented only partially, so we do not recommend
1588 using it for practical subprogram elimination.
1590 Note that in case of a parameterless procedure its profile is represented
1591 as @code{Parameter_Types => ("")}
1593 Alternatively, the @code{Source_Location} parameter is used to specify
1594 which overloaded alternative is to be eliminated by pointing to the
1595 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1596 source text. The string literal (or concatenation of string literals)
1597 given as SOURCE_TRACE must have the following format:
1599 @smallexample @c ada
1600 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1605 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1606 FILE_NAME ::= STRING_LITERAL
1607 LINE_NUMBER ::= DIGIT @{DIGIT@}
1610 SOURCE_TRACE should be the short name of the source file (with no directory
1611 information), and LINE_NUMBER is supposed to point to the line where the
1612 defining name of the subprogram is located.
1614 For the subprograms that are not a part of generic instantiations, only one
1615 SOURCE_LOCATION is used. If a subprogram is declared in a package
1616 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1617 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1618 second one denotes the declaration of the corresponding subprogram in the
1619 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1620 in case of nested instantiations.
1622 The effect of the pragma is to allow the compiler to eliminate
1623 the code or data associated with the named entity. Any reference to
1624 an eliminated entity outside the compilation unit it is defined in,
1625 causes a compile time or link time error.
1627 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1628 in a system independent manner, with unused entities eliminated, without
1629 the requirement of modifying the source text. Normally the required set
1630 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1631 tool. Elimination of unused entities local to a compilation unit is
1632 automatic, without requiring the use of pragma @code{Eliminate}.
1634 Note that the reason this pragma takes string literals where names might
1635 be expected is that a pragma @code{Eliminate} can appear in a context where the
1636 relevant names are not visible.
1638 Note that any change in the source files that includes removing, splitting of
1639 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1642 It is legal to use pragma Eliminate where the referenced entity is a
1643 dispatching operation, but it is not clear what this would mean, since
1644 in general the call does not know which entity is actually being called.
1645 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1647 @node Pragma Export_Exception
1648 @unnumberedsec Pragma Export_Exception
1650 @findex Export_Exception
1654 @smallexample @c ada
1655 pragma Export_Exception (
1656 [Internal =>] local_NAME,
1657 [, [External =>] EXTERNAL_SYMBOL,]
1658 [, [Form =>] Ada | VMS]
1659 [, [Code =>] static_integer_EXPRESSION]);
1663 | static_string_EXPRESSION
1667 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1668 causes the specified exception to be propagated outside of the Ada program,
1669 so that it can be handled by programs written in other OpenVMS languages.
1670 This pragma establishes an external name for an Ada exception and makes the
1671 name available to the OpenVMS Linker as a global symbol. For further details
1672 on this pragma, see the
1673 DEC Ada Language Reference Manual, section 13.9a3.2.
1675 @node Pragma Export_Function
1676 @unnumberedsec Pragma Export_Function
1677 @cindex Argument passing mechanisms
1678 @findex Export_Function
1683 @smallexample @c ada
1684 pragma Export_Function (
1685 [Internal =>] local_NAME,
1686 [, [External =>] EXTERNAL_SYMBOL]
1687 [, [Parameter_Types =>] PARAMETER_TYPES]
1688 [, [Result_Type =>] result_SUBTYPE_MARK]
1689 [, [Mechanism =>] MECHANISM]
1690 [, [Result_Mechanism =>] MECHANISM_NAME]);
1694 | static_string_EXPRESSION
1699 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1703 | subtype_Name ' Access
1707 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1709 MECHANISM_ASSOCIATION ::=
1710 [formal_parameter_NAME =>] MECHANISM_NAME
1715 | Descriptor [([Class =>] CLASS_NAME)]
1717 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1721 Use this pragma to make a function externally callable and optionally
1722 provide information on mechanisms to be used for passing parameter and
1723 result values. We recommend, for the purposes of improving portability,
1724 this pragma always be used in conjunction with a separate pragma
1725 @code{Export}, which must precede the pragma @code{Export_Function}.
1726 GNAT does not require a separate pragma @code{Export}, but if none is
1727 present, @code{Convention Ada} is assumed, which is usually
1728 not what is wanted, so it is usually appropriate to use this
1729 pragma in conjunction with a @code{Export} or @code{Convention}
1730 pragma that specifies the desired foreign convention.
1731 Pragma @code{Export_Function}
1732 (and @code{Export}, if present) must appear in the same declarative
1733 region as the function to which they apply.
1735 @var{internal_name} must uniquely designate the function to which the
1736 pragma applies. If more than one function name exists of this name in
1737 the declarative part you must use the @code{Parameter_Types} and
1738 @code{Result_Type} parameters is mandatory to achieve the required
1739 unique designation. @var{subtype_ mark}s in these parameters must
1740 exactly match the subtypes in the corresponding function specification,
1741 using positional notation to match parameters with subtype marks.
1742 The form with an @code{'Access} attribute can be used to match an
1743 anonymous access parameter.
1746 @cindex Passing by descriptor
1747 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1749 @cindex Suppressing external name
1750 Special treatment is given if the EXTERNAL is an explicit null
1751 string or a static string expressions that evaluates to the null
1752 string. In this case, no external name is generated. This form
1753 still allows the specification of parameter mechanisms.
1755 @node Pragma Export_Object
1756 @unnumberedsec Pragma Export_Object
1757 @findex Export_Object
1761 @smallexample @c ada
1762 pragma Export_Object
1763 [Internal =>] local_NAME,
1764 [, [External =>] EXTERNAL_SYMBOL]
1765 [, [Size =>] EXTERNAL_SYMBOL]
1769 | static_string_EXPRESSION
1773 This pragma designates an object as exported, and apart from the
1774 extended rules for external symbols, is identical in effect to the use of
1775 the normal @code{Export} pragma applied to an object. You may use a
1776 separate Export pragma (and you probably should from the point of view
1777 of portability), but it is not required. @var{Size} is syntax checked,
1778 but otherwise ignored by GNAT@.
1780 @node Pragma Export_Procedure
1781 @unnumberedsec Pragma Export_Procedure
1782 @findex Export_Procedure
1786 @smallexample @c ada
1787 pragma Export_Procedure (
1788 [Internal =>] local_NAME
1789 [, [External =>] EXTERNAL_SYMBOL]
1790 [, [Parameter_Types =>] PARAMETER_TYPES]
1791 [, [Mechanism =>] MECHANISM]);
1795 | static_string_EXPRESSION
1800 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1804 | subtype_Name ' Access
1808 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1810 MECHANISM_ASSOCIATION ::=
1811 [formal_parameter_NAME =>] MECHANISM_NAME
1816 | Descriptor [([Class =>] CLASS_NAME)]
1818 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1822 This pragma is identical to @code{Export_Function} except that it
1823 applies to a procedure rather than a function and the parameters
1824 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1825 GNAT does not require a separate pragma @code{Export}, but if none is
1826 present, @code{Convention Ada} is assumed, which is usually
1827 not what is wanted, so it is usually appropriate to use this
1828 pragma in conjunction with a @code{Export} or @code{Convention}
1829 pragma that specifies the desired foreign convention.
1832 @cindex Passing by descriptor
1833 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1835 @cindex Suppressing external name
1836 Special treatment is given if the EXTERNAL is an explicit null
1837 string or a static string expressions that evaluates to the null
1838 string. In this case, no external name is generated. This form
1839 still allows the specification of parameter mechanisms.
1841 @node Pragma Export_Value
1842 @unnumberedsec Pragma Export_Value
1843 @findex Export_Value
1847 @smallexample @c ada
1848 pragma Export_Value (
1849 [Value =>] static_integer_EXPRESSION,
1850 [Link_Name =>] static_string_EXPRESSION);
1854 This pragma serves to export a static integer value for external use.
1855 The first argument specifies the value to be exported. The Link_Name
1856 argument specifies the symbolic name to be associated with the integer
1857 value. This pragma is useful for defining a named static value in Ada
1858 that can be referenced in assembly language units to be linked with
1859 the application. This pragma is currently supported only for the
1860 AAMP target and is ignored for other targets.
1862 @node Pragma Export_Valued_Procedure
1863 @unnumberedsec Pragma Export_Valued_Procedure
1864 @findex Export_Valued_Procedure
1868 @smallexample @c ada
1869 pragma Export_Valued_Procedure (
1870 [Internal =>] local_NAME
1871 [, [External =>] EXTERNAL_SYMBOL]
1872 [, [Parameter_Types =>] PARAMETER_TYPES]
1873 [, [Mechanism =>] MECHANISM]);
1877 | static_string_EXPRESSION
1882 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1886 | subtype_Name ' Access
1890 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1892 MECHANISM_ASSOCIATION ::=
1893 [formal_parameter_NAME =>] MECHANISM_NAME
1898 | Descriptor [([Class =>] CLASS_NAME)]
1900 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1904 This pragma is identical to @code{Export_Procedure} except that the
1905 first parameter of @var{local_NAME}, which must be present, must be of
1906 mode @code{OUT}, and externally the subprogram is treated as a function
1907 with this parameter as the result of the function. GNAT provides for
1908 this capability to allow the use of @code{OUT} and @code{IN OUT}
1909 parameters in interfacing to external functions (which are not permitted
1911 GNAT does not require a separate pragma @code{Export}, but if none is
1912 present, @code{Convention Ada} is assumed, which is almost certainly
1913 not what is wanted since the whole point of this pragma is to interface
1914 with foreign language functions, so it is usually appropriate to use this
1915 pragma in conjunction with a @code{Export} or @code{Convention}
1916 pragma that specifies the desired foreign convention.
1919 @cindex Passing by descriptor
1920 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1922 @cindex Suppressing external name
1923 Special treatment is given if the EXTERNAL is an explicit null
1924 string or a static string expressions that evaluates to the null
1925 string. In this case, no external name is generated. This form
1926 still allows the specification of parameter mechanisms.
1928 @node Pragma Extend_System
1929 @unnumberedsec Pragma Extend_System
1930 @cindex @code{system}, extending
1932 @findex Extend_System
1936 @smallexample @c ada
1937 pragma Extend_System ([Name =>] IDENTIFIER);
1941 This pragma is used to provide backwards compatibility with other
1942 implementations that extend the facilities of package @code{System}. In
1943 GNAT, @code{System} contains only the definitions that are present in
1944 the Ada RM@. However, other implementations, notably the DEC Ada 83
1945 implementation, provide many extensions to package @code{System}.
1947 For each such implementation accommodated by this pragma, GNAT provides a
1948 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1949 implementation, which provides the required additional definitions. You
1950 can use this package in two ways. You can @code{with} it in the normal
1951 way and access entities either by selection or using a @code{use}
1952 clause. In this case no special processing is required.
1954 However, if existing code contains references such as
1955 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1956 definitions provided in package @code{System}, you may use this pragma
1957 to extend visibility in @code{System} in a non-standard way that
1958 provides greater compatibility with the existing code. Pragma
1959 @code{Extend_System} is a configuration pragma whose single argument is
1960 the name of the package containing the extended definition
1961 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
1962 control of this pragma will be processed using special visibility
1963 processing that looks in package @code{System.Aux_@var{xxx}} where
1964 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1965 package @code{System}, but not found in package @code{System}.
1967 You can use this pragma either to access a predefined @code{System}
1968 extension supplied with the compiler, for example @code{Aux_DEC} or
1969 you can construct your own extension unit following the above
1970 definition. Note that such a package is a child of @code{System}
1971 and thus is considered part of the implementation. To compile
1972 it you will have to use the appropriate switch for compiling
1973 system units. See the GNAT User's Guide for details.
1975 @node Pragma External
1976 @unnumberedsec Pragma External
1981 @smallexample @c ada
1983 [ Convention =>] convention_IDENTIFIER,
1984 [ Entity =>] local_NAME
1985 [, [External_Name =>] static_string_EXPRESSION ]
1986 [, [Link_Name =>] static_string_EXPRESSION ]);
1990 This pragma is identical in syntax and semantics to pragma
1991 @code{Export} as defined in the Ada Reference Manual. It is
1992 provided for compatibility with some Ada 83 compilers that
1993 used this pragma for exactly the same purposes as pragma
1994 @code{Export} before the latter was standardized.
1996 @node Pragma External_Name_Casing
1997 @unnumberedsec Pragma External_Name_Casing
1998 @cindex Dec Ada 83 casing compatibility
1999 @cindex External Names, casing
2000 @cindex Casing of External names
2001 @findex External_Name_Casing
2005 @smallexample @c ada
2006 pragma External_Name_Casing (
2007 Uppercase | Lowercase
2008 [, Uppercase | Lowercase | As_Is]);
2012 This pragma provides control over the casing of external names associated
2013 with Import and Export pragmas. There are two cases to consider:
2016 @item Implicit external names
2017 Implicit external names are derived from identifiers. The most common case
2018 arises when a standard Ada Import or Export pragma is used with only two
2021 @smallexample @c ada
2022 pragma Import (C, C_Routine);
2026 Since Ada is a case-insensitive language, the spelling of the identifier in
2027 the Ada source program does not provide any information on the desired
2028 casing of the external name, and so a convention is needed. In GNAT the
2029 default treatment is that such names are converted to all lower case
2030 letters. This corresponds to the normal C style in many environments.
2031 The first argument of pragma @code{External_Name_Casing} can be used to
2032 control this treatment. If @code{Uppercase} is specified, then the name
2033 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2034 then the normal default of all lower case letters will be used.
2036 This same implicit treatment is also used in the case of extended DEC Ada 83
2037 compatible Import and Export pragmas where an external name is explicitly
2038 specified using an identifier rather than a string.
2040 @item Explicit external names
2041 Explicit external names are given as string literals. The most common case
2042 arises when a standard Ada Import or Export pragma is used with three
2045 @smallexample @c ada
2046 pragma Import (C, C_Routine, "C_routine");
2050 In this case, the string literal normally provides the exact casing required
2051 for the external name. The second argument of pragma
2052 @code{External_Name_Casing} may be used to modify this behavior.
2053 If @code{Uppercase} is specified, then the name
2054 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2055 then the name will be forced to all lowercase letters. A specification of
2056 @code{As_Is} provides the normal default behavior in which the casing is
2057 taken from the string provided.
2061 This pragma may appear anywhere that a pragma is valid. In particular, it
2062 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2063 case it applies to all subsequent compilations, or it can be used as a program
2064 unit pragma, in which case it only applies to the current unit, or it can
2065 be used more locally to control individual Import/Export pragmas.
2067 It is primarily intended for use with OpenVMS systems, where many
2068 compilers convert all symbols to upper case by default. For interfacing to
2069 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2072 @smallexample @c ada
2073 pragma External_Name_Casing (Uppercase, Uppercase);
2077 to enforce the upper casing of all external symbols.
2079 @node Pragma Finalize_Storage_Only
2080 @unnumberedsec Pragma Finalize_Storage_Only
2081 @findex Finalize_Storage_Only
2085 @smallexample @c ada
2086 pragma Finalize_Storage_Only (first_subtype_local_NAME);
2090 This pragma allows the compiler not to emit a Finalize call for objects
2091 defined at the library level. This is mostly useful for types where
2092 finalization is only used to deal with storage reclamation since in most
2093 environments it is not necessary to reclaim memory just before terminating
2094 execution, hence the name.
2096 @node Pragma Float_Representation
2097 @unnumberedsec Pragma Float_Representation
2099 @findex Float_Representation
2103 @smallexample @c ada
2104 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2106 FLOAT_REP ::= VAX_Float | IEEE_Float
2110 In the one argument form, this pragma is a configuration pragma which
2111 allows control over the internal representation chosen for the predefined
2112 floating point types declared in the packages @code{Standard} and
2113 @code{System}. On all systems other than OpenVMS, the argument must
2114 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2115 argument may be @code{VAX_Float} to specify the use of the VAX float
2116 format for the floating-point types in Standard. This requires that
2117 the standard runtime libraries be recompiled. See the
2118 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2119 of the GNAT Users Guide for details on the use of this command.
2121 The two argument form specifies the representation to be used for
2122 the specified floating-point type. On all systems other than OpenVMS,
2124 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2125 argument may be @code{VAX_Float} to specify the use of the VAX float
2130 For digits values up to 6, F float format will be used.
2132 For digits values from 7 to 9, G float format will be used.
2134 For digits values from 10 to 15, F float format will be used.
2136 Digits values above 15 are not allowed.
2140 @unnumberedsec Pragma Ident
2145 @smallexample @c ada
2146 pragma Ident (static_string_EXPRESSION);
2150 This pragma provides a string identification in the generated object file,
2151 if the system supports the concept of this kind of identification string.
2152 This pragma is allowed only in the outermost declarative part or
2153 declarative items of a compilation unit. If more than one @code{Ident}
2154 pragma is given, only the last one processed is effective.
2156 On OpenVMS systems, the effect of the pragma is identical to the effect of
2157 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2158 maximum allowed length is 31 characters, so if it is important to
2159 maintain compatibility with this compiler, you should obey this length
2162 @node Pragma Implicit_Packing
2163 @unnumberedsec Pragma Implicit_Packing
2164 @findex Implicit_Packing
2168 @smallexample @c ada
2169 pragma Implicit_Packing;
2173 This is a configuration pragma that requests implicit packing for packed
2174 arrays for which a size clause is given but no explicit pragma Pack or
2175 specification of Component_Size is present. Consider this example:
2177 @smallexample @c ada
2178 type R is array (0 .. 7) of Boolean;
2183 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2184 does not change the layout of a composite object. So the Size clause in the
2185 above example is normally rejected, since the default layout of the array uses
2186 8-bit components, and thus the array requires a minimum of 64 bits.
2188 If this declaration is compiled in a region of code covered by an occurrence
2189 of the configuration pragma Implicit_Packing, then the Size clause in this
2190 and similar examples will cause implicit packing and thus be accepted. For
2191 this implicit packing to occur, the type in question must be an array of small
2192 components whose size is known at compile time, and the Size clause must
2193 specify the exact size that corresponds to the length of the array multiplied
2194 by the size in bits of the component type.
2195 @cindex Array packing
2197 @node Pragma Import_Exception
2198 @unnumberedsec Pragma Import_Exception
2200 @findex Import_Exception
2204 @smallexample @c ada
2205 pragma Import_Exception (
2206 [Internal =>] local_NAME,
2207 [, [External =>] EXTERNAL_SYMBOL,]
2208 [, [Form =>] Ada | VMS]
2209 [, [Code =>] static_integer_EXPRESSION]);
2213 | static_string_EXPRESSION
2217 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2218 It allows OpenVMS conditions (for example, from OpenVMS system services or
2219 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2220 The pragma specifies that the exception associated with an exception
2221 declaration in an Ada program be defined externally (in non-Ada code).
2222 For further details on this pragma, see the
2223 DEC Ada Language Reference Manual, section 13.9a.3.1.
2225 @node Pragma Import_Function
2226 @unnumberedsec Pragma Import_Function
2227 @findex Import_Function
2231 @smallexample @c ada
2232 pragma Import_Function (
2233 [Internal =>] local_NAME,
2234 [, [External =>] EXTERNAL_SYMBOL]
2235 [, [Parameter_Types =>] PARAMETER_TYPES]
2236 [, [Result_Type =>] SUBTYPE_MARK]
2237 [, [Mechanism =>] MECHANISM]
2238 [, [Result_Mechanism =>] MECHANISM_NAME]
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 used in conjunction with a pragma @code{Import} to
2270 specify additional information for an imported function. The pragma
2271 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2272 @code{Import_Function} pragma and both must appear in the same
2273 declarative part as the function specification.
2275 The @var{Internal} argument must uniquely designate
2276 the function to which the
2277 pragma applies. If more than one function name exists of this name in
2278 the declarative part you must use the @code{Parameter_Types} and
2279 @var{Result_Type} parameters to achieve the required unique
2280 designation. Subtype marks in these parameters must exactly match the
2281 subtypes in the corresponding function specification, using positional
2282 notation to match parameters with subtype marks.
2283 The form with an @code{'Access} attribute can be used to match an
2284 anonymous access parameter.
2286 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2287 parameters to specify passing mechanisms for the
2288 parameters and result. If you specify a single mechanism name, it
2289 applies to all parameters. Otherwise you may specify a mechanism on a
2290 parameter by parameter basis using either positional or named
2291 notation. If the mechanism is not specified, the default mechanism
2295 @cindex Passing by descriptor
2296 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2298 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2299 It specifies that the designated parameter and all following parameters
2300 are optional, meaning that they are not passed at the generated code
2301 level (this is distinct from the notion of optional parameters in Ada
2302 where the parameters are passed anyway with the designated optional
2303 parameters). All optional parameters must be of mode @code{IN} and have
2304 default parameter values that are either known at compile time
2305 expressions, or uses of the @code{'Null_Parameter} attribute.
2307 @node Pragma Import_Object
2308 @unnumberedsec Pragma Import_Object
2309 @findex Import_Object
2313 @smallexample @c ada
2314 pragma Import_Object
2315 [Internal =>] local_NAME,
2316 [, [External =>] EXTERNAL_SYMBOL],
2317 [, [Size =>] EXTERNAL_SYMBOL]);
2321 | static_string_EXPRESSION
2325 This pragma designates an object as imported, and apart from the
2326 extended rules for external symbols, is identical in effect to the use of
2327 the normal @code{Import} pragma applied to an object. Unlike the
2328 subprogram case, you need not use a separate @code{Import} pragma,
2329 although you may do so (and probably should do so from a portability
2330 point of view). @var{size} is syntax checked, but otherwise ignored by
2333 @node Pragma Import_Procedure
2334 @unnumberedsec Pragma Import_Procedure
2335 @findex Import_Procedure
2339 @smallexample @c ada
2340 pragma Import_Procedure (
2341 [Internal =>] local_NAME,
2342 [, [External =>] EXTERNAL_SYMBOL]
2343 [, [Parameter_Types =>] PARAMETER_TYPES]
2344 [, [Mechanism =>] MECHANISM]
2345 [, [First_Optional_Parameter =>] IDENTIFIER]);
2349 | static_string_EXPRESSION
2353 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2357 | subtype_Name ' Access
2361 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2363 MECHANISM_ASSOCIATION ::=
2364 [formal_parameter_NAME =>] MECHANISM_NAME
2369 | Descriptor [([Class =>] CLASS_NAME)]
2371 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2375 This pragma is identical to @code{Import_Function} except that it
2376 applies to a procedure rather than a function and the parameters
2377 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2379 @node Pragma Import_Valued_Procedure
2380 @unnumberedsec Pragma Import_Valued_Procedure
2381 @findex Import_Valued_Procedure
2385 @smallexample @c ada
2386 pragma Import_Valued_Procedure (
2387 [Internal =>] local_NAME,
2388 [, [External =>] EXTERNAL_SYMBOL]
2389 [, [Parameter_Types =>] PARAMETER_TYPES]
2390 [, [Mechanism =>] MECHANISM]
2391 [, [First_Optional_Parameter =>] IDENTIFIER]);
2395 | static_string_EXPRESSION
2399 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2403 | subtype_Name ' Access
2407 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2409 MECHANISM_ASSOCIATION ::=
2410 [formal_parameter_NAME =>] MECHANISM_NAME
2415 | Descriptor [([Class =>] CLASS_NAME)]
2417 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2421 This pragma is identical to @code{Import_Procedure} except that the
2422 first parameter of @var{local_NAME}, which must be present, must be of
2423 mode @code{OUT}, and externally the subprogram is treated as a function
2424 with this parameter as the result of the function. The purpose of this
2425 capability is to allow the use of @code{OUT} and @code{IN OUT}
2426 parameters in interfacing to external functions (which are not permitted
2427 in Ada functions). You may optionally use the @code{Mechanism}
2428 parameters to specify passing mechanisms for the parameters.
2429 If you specify a single mechanism name, it applies to all parameters.
2430 Otherwise you may specify a mechanism on a parameter by parameter
2431 basis using either positional or named notation. If the mechanism is not
2432 specified, the default mechanism is used.
2434 Note that it is important to use this pragma in conjunction with a separate
2435 pragma Import that specifies the desired convention, since otherwise the
2436 default convention is Ada, which is almost certainly not what is required.
2438 @node Pragma Initialize_Scalars
2439 @unnumberedsec Pragma Initialize_Scalars
2440 @findex Initialize_Scalars
2441 @cindex debugging with Initialize_Scalars
2445 @smallexample @c ada
2446 pragma Initialize_Scalars;
2450 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2451 two important differences. First, there is no requirement for the pragma
2452 to be used uniformly in all units of a partition, in particular, it is fine
2453 to use this just for some or all of the application units of a partition,
2454 without needing to recompile the run-time library.
2456 In the case where some units are compiled with the pragma, and some without,
2457 then a declaration of a variable where the type is defined in package
2458 Standard or is locally declared will always be subject to initialization,
2459 as will any declaration of a scalar variable. For composite variables,
2460 whether the variable is initialized may also depend on whether the package
2461 in which the type of the variable is declared is compiled with the pragma.
2463 The other important difference is that you can control the value used
2464 for initializing scalar objects. At bind time, you can select several
2465 options for initialization. You can
2466 initialize with invalid values (similar to Normalize_Scalars, though for
2467 Initialize_Scalars it is not always possible to determine the invalid
2468 values in complex cases like signed component fields with non-standard
2469 sizes). You can also initialize with high or
2470 low values, or with a specified bit pattern. See the users guide for binder
2471 options for specifying these cases.
2473 This means that you can compile a program, and then without having to
2474 recompile the program, you can run it with different values being used
2475 for initializing otherwise uninitialized values, to test if your program
2476 behavior depends on the choice. Of course the behavior should not change,
2477 and if it does, then most likely you have an erroneous reference to an
2478 uninitialized value.
2480 It is even possible to change the value at execution time eliminating even
2481 the need to rebind with a different switch using an environment variable.
2482 See the GNAT users guide for details.
2484 Note that pragma @code{Initialize_Scalars} is particularly useful in
2485 conjunction with the enhanced validity checking that is now provided
2486 in GNAT, which checks for invalid values under more conditions.
2487 Using this feature (see description of the @code{-gnatV} flag in the
2488 users guide) in conjunction with pragma @code{Initialize_Scalars}
2489 provides a powerful new tool to assist in the detection of problems
2490 caused by uninitialized variables.
2492 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2493 effect on the generated code. This may cause your code to be
2494 substantially larger. It may also cause an increase in the amount
2495 of stack required, so it is probably a good idea to turn on stack
2496 checking (see description of stack checking in the GNAT users guide)
2497 when using this pragma.
2499 @node Pragma Inline_Always
2500 @unnumberedsec Pragma Inline_Always
2501 @findex Inline_Always
2505 @smallexample @c ada
2506 pragma Inline_Always (NAME [, NAME]);
2510 Similar to pragma @code{Inline} except that inlining is not subject to
2511 the use of option @code{-gnatn} and the inlining happens regardless of
2512 whether this option is used.
2514 @node Pragma Inline_Generic
2515 @unnumberedsec Pragma Inline_Generic
2516 @findex Inline_Generic
2520 @smallexample @c ada
2521 pragma Inline_Generic (generic_package_NAME);
2525 This is implemented for compatibility with DEC Ada 83 and is recognized,
2526 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2527 by default when using GNAT@.
2529 @node Pragma Interface
2530 @unnumberedsec Pragma Interface
2535 @smallexample @c ada
2537 [Convention =>] convention_identifier,
2538 [Entity =>] local_NAME
2539 [, [External_Name =>] static_string_expression],
2540 [, [Link_Name =>] static_string_expression]);
2544 This pragma is identical in syntax and semantics to
2545 the standard Ada pragma @code{Import}. It is provided for compatibility
2546 with Ada 83. The definition is upwards compatible both with pragma
2547 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2548 with some extended implementations of this pragma in certain Ada 83
2551 @node Pragma Interface_Name
2552 @unnumberedsec Pragma Interface_Name
2553 @findex Interface_Name
2557 @smallexample @c ada
2558 pragma Interface_Name (
2559 [Entity =>] local_NAME
2560 [, [External_Name =>] static_string_EXPRESSION]
2561 [, [Link_Name =>] static_string_EXPRESSION]);
2565 This pragma provides an alternative way of specifying the interface name
2566 for an interfaced subprogram, and is provided for compatibility with Ada
2567 83 compilers that use the pragma for this purpose. You must provide at
2568 least one of @var{External_Name} or @var{Link_Name}.
2570 @node Pragma Interrupt_Handler
2571 @unnumberedsec Pragma Interrupt_Handler
2572 @findex Interrupt_Handler
2576 @smallexample @c ada
2577 pragma Interrupt_Handler (procedure_local_NAME);
2581 This program unit pragma is supported for parameterless protected procedures
2582 as described in Annex C of the Ada Reference Manual. On the AAMP target
2583 the pragma can also be specified for nonprotected parameterless procedures
2584 that are declared at the library level (which includes procedures
2585 declared at the top level of a library package). In the case of AAMP,
2586 when this pragma is applied to a nonprotected procedure, the instruction
2587 @code{IERET} is generated for returns from the procedure, enabling
2588 maskable interrupts, in place of the normal return instruction.
2590 @node Pragma Interrupt_State
2591 @unnumberedsec Pragma Interrupt_State
2592 @findex Interrupt_State
2596 @smallexample @c ada
2597 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2601 Normally certain interrupts are reserved to the implementation. Any attempt
2602 to attach an interrupt causes Program_Error to be raised, as described in
2603 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2604 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2605 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2606 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2607 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2608 Ada exceptions, or used to implement run-time functions such as the
2609 @code{abort} statement and stack overflow checking.
2611 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2612 such uses of interrupts. It subsumes the functionality of pragma
2613 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2614 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2615 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2616 and may be used to mark interrupts required by the board support package
2619 Interrupts can be in one of three states:
2623 The interrupt is reserved (no Ada handler can be installed), and the
2624 Ada run-time may not install a handler. As a result you are guaranteed
2625 standard system default action if this interrupt is raised.
2629 The interrupt is reserved (no Ada handler can be installed). The run time
2630 is allowed to install a handler for internal control purposes, but is
2631 not required to do so.
2635 The interrupt is unreserved. The user may install a handler to provide
2640 These states are the allowed values of the @code{State} parameter of the
2641 pragma. The @code{Name} parameter is a value of the type
2642 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2643 @code{Ada.Interrupts.Names}.
2645 This is a configuration pragma, and the binder will check that there
2646 are no inconsistencies between different units in a partition in how a
2647 given interrupt is specified. It may appear anywhere a pragma is legal.
2649 The effect is to move the interrupt to the specified state.
2651 By declaring interrupts to be SYSTEM, you guarantee the standard system
2652 action, such as a core dump.
2654 By declaring interrupts to be USER, you guarantee that you can install
2657 Note that certain signals on many operating systems cannot be caught and
2658 handled by applications. In such cases, the pragma is ignored. See the
2659 operating system documentation, or the value of the array @code{Reserved}
2660 declared in the specification of package @code{System.OS_Interface}.
2662 Overriding the default state of signals used by the Ada runtime may interfere
2663 with an application's runtime behavior in the cases of the synchronous signals,
2664 and in the case of the signal used to implement the @code{abort} statement.
2666 @node Pragma Keep_Names
2667 @unnumberedsec Pragma Keep_Names
2672 @smallexample @c ada
2673 pragma Keep_Names ([On =>] enumeration_first_subtype_local_NAME);
2677 The @var{local_NAME} argument
2678 must refer to an enumeration first subtype
2679 in the current declarative part. The effect is to retain the enumeration
2680 literal names for use by @code{Image} and @code{Value} even if a global
2681 @code{Discard_Names} pragma applies. This is useful when you want to
2682 generally suppress enumeration literal names and for example you therefore
2683 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2684 want to retain the names for specific enumeration types.
2686 @node Pragma License
2687 @unnumberedsec Pragma License
2689 @cindex License checking
2693 @smallexample @c ada
2694 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2698 This pragma is provided to allow automated checking for appropriate license
2699 conditions with respect to the standard and modified GPL@. A pragma
2700 @code{License}, which is a configuration pragma that typically appears at
2701 the start of a source file or in a separate @file{gnat.adc} file, specifies
2702 the licensing conditions of a unit as follows:
2706 This is used for a unit that can be freely used with no license restrictions.
2707 Examples of such units are public domain units, and units from the Ada
2711 This is used for a unit that is licensed under the unmodified GPL, and which
2712 therefore cannot be @code{with}'ed by a restricted unit.
2715 This is used for a unit licensed under the GNAT modified GPL that includes
2716 a special exception paragraph that specifically permits the inclusion of
2717 the unit in programs without requiring the entire program to be released
2721 This is used for a unit that is restricted in that it is not permitted to
2722 depend on units that are licensed under the GPL@. Typical examples are
2723 proprietary code that is to be released under more restrictive license
2724 conditions. Note that restricted units are permitted to @code{with} units
2725 which are licensed under the modified GPL (this is the whole point of the
2731 Normally a unit with no @code{License} pragma is considered to have an
2732 unknown license, and no checking is done. However, standard GNAT headers
2733 are recognized, and license information is derived from them as follows.
2737 A GNAT license header starts with a line containing 78 hyphens. The following
2738 comment text is searched for the appearance of any of the following strings.
2740 If the string ``GNU General Public License'' is found, then the unit is assumed
2741 to have GPL license, unless the string ``As a special exception'' follows, in
2742 which case the license is assumed to be modified GPL@.
2744 If one of the strings
2745 ``This specification is adapted from the Ada Semantic Interface'' or
2746 ``This specification is derived from the Ada Reference Manual'' is found
2747 then the unit is assumed to be unrestricted.
2751 These default actions means that a program with a restricted license pragma
2752 will automatically get warnings if a GPL unit is inappropriately
2753 @code{with}'ed. For example, the program:
2755 @smallexample @c ada
2758 procedure Secret_Stuff is
2764 if compiled with pragma @code{License} (@code{Restricted}) in a
2765 @file{gnat.adc} file will generate the warning:
2770 >>> license of withed unit "Sem_Ch3" is incompatible
2772 2. with GNAT.Sockets;
2773 3. procedure Secret_Stuff is
2777 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2778 compiler and is licensed under the
2779 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2780 run time, and is therefore licensed under the modified GPL@.
2782 @node Pragma Link_With
2783 @unnumberedsec Pragma Link_With
2788 @smallexample @c ada
2789 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2793 This pragma is provided for compatibility with certain Ada 83 compilers.
2794 It has exactly the same effect as pragma @code{Linker_Options} except
2795 that spaces occurring within one of the string expressions are treated
2796 as separators. For example, in the following case:
2798 @smallexample @c ada
2799 pragma Link_With ("-labc -ldef");
2803 results in passing the strings @code{-labc} and @code{-ldef} as two
2804 separate arguments to the linker. In addition pragma Link_With allows
2805 multiple arguments, with the same effect as successive pragmas.
2807 @node Pragma Linker_Alias
2808 @unnumberedsec Pragma Linker_Alias
2809 @findex Linker_Alias
2813 @smallexample @c ada
2814 pragma Linker_Alias (
2815 [Entity =>] local_NAME
2816 [Target =>] static_string_EXPRESSION);
2820 @var{local_NAME} must refer to an object that is declared at the library
2821 level. This pragma establishes the given entity as a linker alias for the
2822 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
2823 and causes @var{local_NAME} to be emitted as an alias for the symbol
2824 @var{static_string_EXPRESSION} in the object file, that is to say no space
2825 is reserved for @var{local_NAME} by the assembler and it will be resolved
2826 to the same address as @var{static_string_EXPRESSION} by the linker.
2828 The actual linker name for the target must be used (e.g. the fully
2829 encoded name with qualification in Ada, or the mangled name in C++),
2830 or it must be declared using the C convention with @code{pragma Import}
2831 or @code{pragma Export}.
2833 Not all target machines support this pragma. On some of them it is accepted
2834 only if @code{pragma Weak_External} has been applied to @var{local_NAME}.
2836 @smallexample @c ada
2837 -- Example of the use of pragma Linker_Alias
2841 pragma Export (C, i);
2843 new_name_for_i : Integer;
2844 pragma Linker_Alias (new_name_for_i, "i");
2848 @node Pragma Linker_Constructor
2849 @unnumberedsec Pragma Linker_Constructor
2850 @findex Linker_Constructor
2854 @smallexample @c ada
2855 pragma Linker_Constructor (procedure_LOCAL_NAME);
2859 @var{procedure_local_NAME} must refer to a parameterless procedure that
2860 is declared at the library level. A procedure to which this pragma is
2861 applied will be treated as an initialization routine by the linker.
2862 It is equivalent to @code{__attribute__((constructor))} in GNU C and
2863 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
2864 of the executable is called (or immediately after the shared library is
2865 loaded if the procedure is linked in a shared library), in particular
2866 before the Ada run-time environment is set up.
2868 Because of these specific contexts, the set of operations such a procedure
2869 can perform is very limited and the type of objects it can manipulate is
2870 essentially restricted to the elementary types. In particular, it must only
2871 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
2873 This pragma is used by GNAT to implement auto-initialization of shared Stand
2874 Alone Libraries, which provides a related capability without the restrictions
2875 listed above. Where possible, the use of Stand Alone Libraries is preferable
2876 to the use of this pragma.
2878 @node Pragma Linker_Destructor
2879 @unnumberedsec Pragma Linker_Destructor
2880 @findex Linker_Destructor
2884 @smallexample @c ada
2885 pragma Linker_Destructor (procedure_LOCAL_NAME);
2889 @var{procedure_local_NAME} must refer to a parameterless procedure that
2890 is declared at the library level. A procedure to which this pragma is
2891 applied will be treated as a finalization routine by the linker.
2892 It is equivalent to @code{__attribute__((destructor))} in GNU C and
2893 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
2894 of the executable has exited (or immediately before the shared library
2895 is unloaded if the procedure is linked in a shared library), in particular
2896 after the Ada run-time environment is shut down.
2898 See @code{pragma Linker_Constructor} for the set of restrictions that apply
2899 because of these specific contexts.
2901 @node Pragma Linker_Section
2902 @unnumberedsec Pragma Linker_Section
2903 @findex Linker_Section
2907 @smallexample @c ada
2908 pragma Linker_Section (
2909 [Entity =>] local_NAME
2910 [Section =>] static_string_EXPRESSION);
2914 @var{local_NAME} must refer to an object that is declared at the library
2915 level. This pragma specifies the name of the linker section for the given
2916 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
2917 causes @var{local_NAME} to be placed in the @var{static_string_EXPRESSION}
2918 section of the executable (assuming the linker doesn't rename the section).
2920 The compiler normally places library-level objects in standard sections
2921 depending on their type: procedures and functions generally go in the
2922 @code{.text} section, initialized variables in the @code{.data} section
2923 and uninitialized variables in the @code{.bss} section.
2925 Other, special sections may exist on given target machines to map special
2926 hardware, for example I/O ports or flash memory. This pragma is a means to
2927 defer the final layout of the executable to the linker, thus fully working
2928 at the symbolic level with the compiler.
2930 Some file formats do not support arbitrary sections so not all target
2931 machines support this pragma. The use of this pragma may cause a program
2932 execution to be erroneous if it is used to place an entity into an
2933 inappropriate section (e.g. a modified variable into the @code{.text}
2934 section). See also @code{pragma Persistent_BSS}.
2936 @smallexample @c ada
2937 -- Example of the use of pragma Linker_Section
2941 pragma Volatile (Port_A);
2942 pragma Linker_Section (Port_A, ".bss.port_a");
2945 pragma Volatile (Port_B);
2946 pragma Linker_Section (Port_B, ".bss.port_b");
2950 @node Pragma Long_Float
2951 @unnumberedsec Pragma Long_Float
2957 @smallexample @c ada
2958 pragma Long_Float (FLOAT_FORMAT);
2960 FLOAT_FORMAT ::= D_Float | G_Float
2964 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2965 It allows control over the internal representation chosen for the predefined
2966 type @code{Long_Float} and for floating point type representations with
2967 @code{digits} specified in the range 7 through 15.
2968 For further details on this pragma, see the
2969 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
2970 this pragma, the standard runtime libraries must be recompiled. See the
2971 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2972 of the GNAT User's Guide for details on the use of this command.
2974 @node Pragma Machine_Attribute
2975 @unnumberedsec Pragma Machine_Attribute
2976 @findex Machine_Attribute
2980 @smallexample @c ada
2981 pragma Machine_Attribute (
2982 [Attribute_Name =>] string_EXPRESSION,
2983 [Entity =>] local_NAME);
2987 Machine-dependent attributes can be specified for types and/or
2988 declarations. This pragma is semantically equivalent to
2989 @code{__attribute__((@var{string_expression}))} in GNU C,
2990 where @code{@var{string_expression}} is
2991 recognized by the target macro @code{TARGET_ATTRIBUTE_TABLE} which is
2992 defined for each machine. See the GCC manual for further information.
2993 It is not possible to specify attributes defined by other languages,
2994 only attributes defined by the machine the code is intended to run on.
2997 @unnumberedsec Pragma Main
3003 @smallexample @c ada
3005 (MAIN_OPTION [, MAIN_OPTION]);
3008 [STACK_SIZE =>] static_integer_EXPRESSION
3009 | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
3010 | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
3014 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3015 no effect in GNAT, other than being syntax checked.
3017 @node Pragma Main_Storage
3018 @unnumberedsec Pragma Main_Storage
3020 @findex Main_Storage
3024 @smallexample @c ada
3026 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3028 MAIN_STORAGE_OPTION ::=
3029 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3030 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3034 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3035 no effect in GNAT, other than being syntax checked. Note that the pragma
3036 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3038 @node Pragma No_Body
3039 @unnumberedsec Pragma No_Body
3044 @smallexample @c ada
3049 There are a number of cases in which a package spec does not require a body,
3050 and in fact a body is not permitted. GNAT will not permit the spec to be
3051 compiled if there is a body around. The pragma No_Body allows you to provide
3052 a body file, even in a case where no body is allowed. The body file must
3053 contain only comments and a single No_Body pragma. This is recognized by
3054 the compiler as indicating that no body is logically present.
3056 This is particularly useful during maintenance when a package is modified in
3057 such a way that a body needed before is no longer needed. The provision of a
3058 dummy body with a No_Body pragma ensures that there is no inteference from
3059 earlier versions of the package body.
3061 @node Pragma No_Return
3062 @unnumberedsec Pragma No_Return
3067 @smallexample @c ada
3068 pragma No_Return (procedure_local_NAME @{, procedure_local_NAME@});
3072 Each @var{procedure_local_NAME} argument must refer to one or more procedure
3073 declarations in the current declarative part. A procedure to which this
3074 pragma is applied may not contain any explicit @code{return} statements.
3075 In addition, if the procedure contains any implicit returns from falling
3076 off the end of a statement sequence, then execution of that implicit
3077 return will cause Program_Error to be raised.
3079 One use of this pragma is to identify procedures whose only purpose is to raise
3080 an exception. Another use of this pragma is to suppress incorrect warnings
3081 about missing returns in functions, where the last statement of a function
3082 statement sequence is a call to such a procedure.
3084 Note that in Ada 2005 mode, this pragma is part of the language, and is
3085 identical in effect to the pragma as implemented in Ada 95 mode.
3087 @node Pragma No_Strict_Aliasing
3088 @unnumberedsec Pragma No_Strict_Aliasing
3089 @findex No_Strict_Aliasing
3093 @smallexample @c ada
3094 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3098 @var{type_LOCAL_NAME} must refer to an access type
3099 declaration in the current declarative part. The effect is to inhibit
3100 strict aliasing optimization for the given type. The form with no
3101 arguments is a configuration pragma which applies to all access types
3102 declared in units to which the pragma applies. For a detailed
3103 description of the strict aliasing optimization, and the situations
3104 in which it must be suppressed, see section
3105 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
3107 @node Pragma Normalize_Scalars
3108 @unnumberedsec Pragma Normalize_Scalars
3109 @findex Normalize_Scalars
3113 @smallexample @c ada
3114 pragma Normalize_Scalars;
3118 This is a language defined pragma which is fully implemented in GNAT@. The
3119 effect is to cause all scalar objects that are not otherwise initialized
3120 to be initialized. The initial values are implementation dependent and
3124 @item Standard.Character
3126 Objects whose root type is Standard.Character are initialized to
3127 Character'Last unless the subtype range excludes NUL (in which case
3128 NUL is used). This choice will always generate an invalid value if
3131 @item Standard.Wide_Character
3133 Objects whose root type is Standard.Wide_Character are initialized to
3134 Wide_Character'Last unless the subtype range excludes NUL (in which case
3135 NUL is used). This choice will always generate an invalid value if
3138 @item Standard.Wide_Wide_Character
3140 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3141 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3142 which case NUL is used). This choice will always generate an invalid value if
3147 Objects of an integer type are treated differently depending on whether
3148 negative values are present in the subtype. If no negative values are
3149 present, then all one bits is used as the initial value except in the
3150 special case where zero is excluded from the subtype, in which case
3151 all zero bits are used. This choice will always generate an invalid
3152 value if one exists.
3154 For subtypes with negative values present, the largest negative number
3155 is used, except in the unusual case where this largest negative number
3156 is in the subtype, and the largest positive number is not, in which case
3157 the largest positive value is used. This choice will always generate
3158 an invalid value if one exists.
3160 @item Floating-Point Types
3161 Objects of all floating-point types are initialized to all 1-bits. For
3162 standard IEEE format, this corresponds to a NaN (not a number) which is
3163 indeed an invalid value.
3165 @item Fixed-Point Types
3166 Objects of all fixed-point types are treated as described above for integers,
3167 with the rules applying to the underlying integer value used to represent
3168 the fixed-point value.
3171 Objects of a modular type are initialized to all one bits, except in
3172 the special case where zero is excluded from the subtype, in which
3173 case all zero bits are used. This choice will always generate an
3174 invalid value if one exists.
3176 @item Enumeration types
3177 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3178 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3179 whose Pos value is zero, in which case a code of zero is used. This choice
3180 will always generate an invalid value if one exists.
3184 @node Pragma Obsolescent
3185 @unnumberedsec Pragma Obsolescent
3190 @smallexample @c ada
3192 (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3196 This pragma can occur immediately following a declaration of an entity,
3197 including the case of a record component, and usually the Entity name
3198 must match the name of the entity declared by this declaration.
3199 Alternatively, the pragma can immediately follow an
3200 enumeration type declaration, where the entity argument names one of the
3201 enumeration literals.
3203 This pragma is used to indicate that the named entity
3204 is considered obsolescent and should not be used. Typically this is
3205 used when an API must be modified by eventually removing or modifying
3206 existing subprograms or other entities. The pragma can be used at an
3207 intermediate stage when the entity is still present, but will be
3210 The effect of this pragma is to output a warning message on
3211 a call to a program thus marked that the
3212 subprogram is obsolescent if the appropriate warning option in the
3213 compiler is activated. If the string parameter is present, then a second
3214 warning message is given containing this text.
3215 In addition, a call to such a program is considered a violation of
3216 pragma Restrictions (No_Obsolescent_Features).
3218 This pragma can also be used as a program unit pragma for a package,
3219 in which case the entity name is the name of the package, and the
3220 pragma indicates that the entire package is considered
3221 obsolescent. In this case a client @code{with}'ing such a package
3222 violates the restriction, and the @code{with} statement is
3223 flagged with warnings if the warning option is set.
3225 If the optional third parameter is present (which must be exactly
3226 the identifier Ada_05, no other argument is allowed), then the
3227 indication of obsolescence applies only when compiling in Ada 2005
3228 mode. This is primarily intended for dealing with the situations
3229 in the predefined library where subprograms or packages
3230 have become defined as obsolescent in Ada 2005
3231 (e.g. in Ada.Characters.Handling), but may be used anywhere.
3233 The following examples show typical uses of this pragma:
3235 @smallexample @c ada
3238 (Entity => p, "use pp instead of p");
3244 (Entity => q2, "use q2new instead");
3246 type R is new integer;
3248 (Entity => R, "use RR in Ada 2005", Ada_05);
3253 pragma Obsolescent (Entity => F2);
3257 type E is (a, bc, 'd', quack);
3258 pragma Obsolescent (Entity => bc)
3259 pragma Obsolescent (Entity => 'd')
3262 (a, b : character) return character;
3263 pragma Obsolescent (Entity => "+");
3268 In an earlier version of GNAT, the Entity parameter was not required,
3269 and this form is still accepted for compatibility purposes. If the
3270 Entity parameter is omitted, then the pragma applies to the declaration
3271 immediately preceding the pragma (this form cannot be used for the
3272 enumeration literal case).
3274 @node Pragma Passive
3275 @unnumberedsec Pragma Passive
3280 @smallexample @c ada
3281 pragma Passive [(Semaphore | No)];
3285 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3286 compatibility with DEC Ada 83 implementations, where it is used within a
3287 task definition to request that a task be made passive. If the argument
3288 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3289 treats the pragma as an assertion that the containing task is passive
3290 and that optimization of context switch with this task is permitted and
3291 desired. If the argument @code{No} is present, the task must not be
3292 optimized. GNAT does not attempt to optimize any tasks in this manner
3293 (since protected objects are available in place of passive tasks).
3295 @node Pragma Persistent_BSS
3296 @unnumberedsec Pragma Persistent_BSS
3297 @findex Persistent_BSS
3301 @smallexample @c ada
3302 pragma Persistent_BSS [(local_NAME)]
3306 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3307 section. On some targets the linker and loader provide for special
3308 treatment of this section, allowing a program to be reloaded without
3309 affecting the contents of this data (hence the name persistent).
3311 There are two forms of usage. If an argument is given, it must be the
3312 local name of a library level object, with no explicit initialization
3313 and whose type is potentially persistent. If no argument is given, then
3314 the pragma is a configuration pragma, and applies to all library level
3315 objects with no explicit initialization of potentially persistent types.
3317 A potentially persistent type is a scalar type, or a non-tagged,
3318 non-discriminated record, all of whose components have no explicit
3319 initialization and are themselves of a potentially persistent type,
3320 or an array, all of whose constraints are static, and whose component
3321 type is potentially persistent.
3323 If this pragma is used on a target where this feature is not supported,
3324 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3326 @node Pragma Polling
3327 @unnumberedsec Pragma Polling
3332 @smallexample @c ada
3333 pragma Polling (ON | OFF);
3337 This pragma controls the generation of polling code. This is normally off.
3338 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3339 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3340 runtime library, and can be found in file @file{a-excpol.adb}.
3342 Pragma @code{Polling} can appear as a configuration pragma (for example it
3343 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3344 can be used in the statement or declaration sequence to control polling
3347 A call to the polling routine is generated at the start of every loop and
3348 at the start of every subprogram call. This guarantees that the @code{Poll}
3349 routine is called frequently, and places an upper bound (determined by
3350 the complexity of the code) on the period between two @code{Poll} calls.
3352 The primary purpose of the polling interface is to enable asynchronous
3353 aborts on targets that cannot otherwise support it (for example Windows
3354 NT), but it may be used for any other purpose requiring periodic polling.
3355 The standard version is null, and can be replaced by a user program. This
3356 will require re-compilation of the @code{Ada.Exceptions} package that can
3357 be found in files @file{a-except.ads} and @file{a-except.adb}.
3359 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3360 distribution) is used to enable the asynchronous abort capability on
3361 targets that do not normally support the capability. The version of
3362 @code{Poll} in this file makes a call to the appropriate runtime routine
3363 to test for an abort condition.
3365 Note that polling can also be enabled by use of the @code{-gnatP} switch. See
3366 the @cite{GNAT User's Guide} for details.
3368 @node Pragma Profile (Ravenscar)
3369 @unnumberedsec Pragma Profile (Ravenscar)
3374 @smallexample @c ada
3375 pragma Profile (Ravenscar);
3379 A configuration pragma that establishes the following set of configuration
3383 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3384 [RM D.2.2] Tasks are dispatched following a preemptive
3385 priority-ordered scheduling policy.
3387 @item Locking_Policy (Ceiling_Locking)
3388 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3389 the ceiling priority of the corresponding protected object.
3391 @c @item Detect_Blocking
3392 @c This pragma forces the detection of potentially blocking operations within a
3393 @c protected operation, and to raise Program_Error if that happens.
3397 plus the following set of restrictions:
3400 @item Max_Entry_Queue_Length = 1
3401 Defines the maximum number of calls that are queued on a (protected) entry.
3402 Note that this restrictions is checked at run time. Violation of this
3403 restriction results in the raising of Program_Error exception at the point of
3404 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3405 always 1 and hence no task can be queued on a protected entry.
3407 @item Max_Protected_Entries = 1
3408 [RM D.7] Specifies the maximum number of entries per protected type. The
3409 bounds of every entry family of a protected unit shall be static, or shall be
3410 defined by a discriminant of a subtype whose corresponding bound is static.
3411 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3413 @item Max_Task_Entries = 0
3414 [RM D.7] Specifies the maximum number of entries
3415 per task. The bounds of every entry family
3416 of a task unit shall be static, or shall be
3417 defined by a discriminant of a subtype whose
3418 corresponding bound is static. A value of zero
3419 indicates that no rendezvous are possible. For
3420 the Profile (Ravenscar), the value of Max_Task_Entries is always
3423 @item No_Abort_Statements
3424 [RM D.7] There are no abort_statements, and there are
3425 no calls to Task_Identification.Abort_Task.
3427 @item No_Asynchronous_Control
3428 [RM D.7] There are no semantic dependences on the package
3429 Asynchronous_Task_Control.
3432 There are no semantic dependencies on the package Ada.Calendar.
3434 @item No_Dynamic_Attachment
3435 There is no call to any of the operations defined in package Ada.Interrupts
3436 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3437 Detach_Handler, and Reference).
3439 @item No_Dynamic_Priorities
3440 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3442 @item No_Implicit_Heap_Allocations
3443 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3445 @item No_Local_Protected_Objects
3446 Protected objects and access types that designate
3447 such objects shall be declared only at library level.
3449 @item No_Protected_Type_Allocators
3450 There are no allocators for protected types or
3451 types containing protected subcomponents.
3453 @item No_Relative_Delay
3454 There are no delay_relative statements.
3456 @item No_Requeue_Statements
3457 Requeue statements are not allowed.
3459 @item No_Select_Statements
3460 There are no select_statements.
3462 @item No_Task_Allocators
3463 [RM D.7] There are no allocators for task types
3464 or types containing task subcomponents.
3466 @item No_Task_Attributes_Package
3467 There are no semantic dependencies on the Ada.Task_Attributes package.
3469 @item No_Task_Hierarchy
3470 [RM D.7] All (non-environment) tasks depend
3471 directly on the environment task of the partition.
3473 @item No_Task_Termination
3474 Tasks which terminate are erroneous.
3476 @item Simple_Barriers
3477 Entry barrier condition expressions shall be either static
3478 boolean expressions or boolean objects which are declared in
3479 the protected type which contains the entry.
3483 This set of configuration pragmas and restrictions correspond to the
3484 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3485 published by the @cite{International Real-Time Ada Workshop}, 1997,
3486 and whose most recent description is available at
3487 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
3489 The original definition of the profile was revised at subsequent IRTAW
3490 meetings. It has been included in the ISO
3491 @cite{Guide for the Use of the Ada Programming Language in High
3492 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3493 the next revision of the standard. The formal definition given by
3494 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3495 AI-305) available at
3496 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3497 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3500 The above set is a superset of the restrictions provided by pragma
3501 @code{Profile (Restricted)}, it includes six additional restrictions
3502 (@code{Simple_Barriers}, @code{No_Select_Statements},
3503 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3504 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
3505 that pragma @code{Profile (Ravenscar)}, like the pragma
3506 @code{Profile (Restricted)},
3507 automatically causes the use of a simplified,
3508 more efficient version of the tasking run-time system.
3510 @node Pragma Profile (Restricted)
3511 @unnumberedsec Pragma Profile (Restricted)
3512 @findex Restricted Run Time
3516 @smallexample @c ada
3517 pragma Profile (Restricted);
3521 A configuration pragma that establishes the following set of restrictions:
3524 @item No_Abort_Statements
3525 @item No_Entry_Queue
3526 @item No_Task_Hierarchy
3527 @item No_Task_Allocators
3528 @item No_Dynamic_Priorities
3529 @item No_Terminate_Alternatives
3530 @item No_Dynamic_Attachment
3531 @item No_Protected_Type_Allocators
3532 @item No_Local_Protected_Objects
3533 @item No_Requeue_Statements
3534 @item No_Task_Attributes_Package
3535 @item Max_Asynchronous_Select_Nesting = 0
3536 @item Max_Task_Entries = 0
3537 @item Max_Protected_Entries = 1
3538 @item Max_Select_Alternatives = 0
3542 This set of restrictions causes the automatic selection of a simplified
3543 version of the run time that provides improved performance for the
3544 limited set of tasking functionality permitted by this set of restrictions.
3546 @node Pragma Psect_Object
3547 @unnumberedsec Pragma Psect_Object
3548 @findex Psect_Object
3552 @smallexample @c ada
3553 pragma Psect_Object (
3554 [Internal =>] local_NAME,
3555 [, [External =>] EXTERNAL_SYMBOL]
3556 [, [Size =>] EXTERNAL_SYMBOL]);
3560 | static_string_EXPRESSION
3564 This pragma is identical in effect to pragma @code{Common_Object}.
3566 @node Pragma Pure_Function
3567 @unnumberedsec Pragma Pure_Function
3568 @findex Pure_Function
3572 @smallexample @c ada
3573 pragma Pure_Function ([Entity =>] function_local_NAME);
3577 This pragma appears in the same declarative part as a function
3578 declaration (or a set of function declarations if more than one
3579 overloaded declaration exists, in which case the pragma applies
3580 to all entities). It specifies that the function @code{Entity} is
3581 to be considered pure for the purposes of code generation. This means
3582 that the compiler can assume that there are no side effects, and
3583 in particular that two calls with identical arguments produce the
3584 same result. It also means that the function can be used in an
3587 Note that, quite deliberately, there are no static checks to try
3588 to ensure that this promise is met, so @code{Pure_Function} can be used
3589 with functions that are conceptually pure, even if they do modify
3590 global variables. For example, a square root function that is
3591 instrumented to count the number of times it is called is still
3592 conceptually pure, and can still be optimized, even though it
3593 modifies a global variable (the count). Memo functions are another
3594 example (where a table of previous calls is kept and consulted to
3595 avoid re-computation).
3598 Note: Most functions in a @code{Pure} package are automatically pure, and
3599 there is no need to use pragma @code{Pure_Function} for such functions. One
3600 exception is any function that has at least one formal of type
3601 @code{System.Address} or a type derived from it. Such functions are not
3602 considered pure by default, since the compiler assumes that the
3603 @code{Address} parameter may be functioning as a pointer and that the
3604 referenced data may change even if the address value does not.
3605 Similarly, imported functions are not considered to be pure by default,
3606 since there is no way of checking that they are in fact pure. The use
3607 of pragma @code{Pure_Function} for such a function will override these default
3608 assumption, and cause the compiler to treat a designated subprogram as pure
3611 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3612 applies to the underlying renamed function. This can be used to
3613 disambiguate cases of overloading where some but not all functions
3614 in a set of overloaded functions are to be designated as pure.
3616 If pragma @code{Pure_Function} is applied to a library level function, the
3617 function is also considered pure from an optimization point of view, but the
3618 unit is not a Pure unit in the categorization sense. So for example, a function
3619 thus marked is free to @code{with} non-pure units.
3621 @node Pragma Restriction_Warnings
3622 @unnumberedsec Pragma Restriction_Warnings
3623 @findex Restriction_Warnings
3627 @smallexample @c ada
3628 pragma Restriction_Warnings
3629 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3633 This pragma allows a series of restriction identifiers to be
3634 specified (the list of allowed identifiers is the same as for
3635 pragma @code{Restrictions}). For each of these identifiers
3636 the compiler checks for violations of the restriction, but
3637 generates a warning message rather than an error message
3638 if the restriction is violated.
3640 @node Pragma Source_File_Name
3641 @unnumberedsec Pragma Source_File_Name
3642 @findex Source_File_Name
3646 @smallexample @c ada
3647 pragma Source_File_Name (
3648 [Unit_Name =>] unit_NAME,
3649 Spec_File_Name => STRING_LITERAL);
3651 pragma Source_File_Name (
3652 [Unit_Name =>] unit_NAME,
3653 Body_File_Name => STRING_LITERAL);
3657 Use this to override the normal naming convention. It is a configuration
3658 pragma, and so has the usual applicability of configuration pragmas
3659 (i.e.@: it applies to either an entire partition, or to all units in a
3660 compilation, or to a single unit, depending on how it is used.
3661 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
3662 the second argument is required, and indicates whether this is the file
3663 name for the spec or for the body.
3665 Another form of the @code{Source_File_Name} pragma allows
3666 the specification of patterns defining alternative file naming schemes
3667 to apply to all files.
3669 @smallexample @c ada
3670 pragma Source_File_Name
3671 (Spec_File_Name => STRING_LITERAL
3672 [,Casing => CASING_SPEC]
3673 [,Dot_Replacement => STRING_LITERAL]);
3675 pragma Source_File_Name
3676 (Body_File_Name => STRING_LITERAL
3677 [,Casing => CASING_SPEC]
3678 [,Dot_Replacement => STRING_LITERAL]);
3680 pragma Source_File_Name
3681 (Subunit_File_Name => STRING_LITERAL
3682 [,Casing => CASING_SPEC]
3683 [,Dot_Replacement => STRING_LITERAL]);
3685 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3689 The first argument is a pattern that contains a single asterisk indicating
3690 the point at which the unit name is to be inserted in the pattern string
3691 to form the file name. The second argument is optional. If present it
3692 specifies the casing of the unit name in the resulting file name string.
3693 The default is lower case. Finally the third argument allows for systematic
3694 replacement of any dots in the unit name by the specified string literal.
3696 A pragma Source_File_Name cannot appear after a
3697 @ref{Pragma Source_File_Name_Project}.
3699 For more details on the use of the @code{Source_File_Name} pragma,
3700 see the sections ``Using Other File Names'' and
3701 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3703 @node Pragma Source_File_Name_Project
3704 @unnumberedsec Pragma Source_File_Name_Project
3705 @findex Source_File_Name_Project
3708 This pragma has the same syntax and semantics as pragma Source_File_Name.
3709 It is only allowed as a stand alone configuration pragma.
3710 It cannot appear after a @ref{Pragma Source_File_Name}, and
3711 most importantly, once pragma Source_File_Name_Project appears,
3712 no further Source_File_Name pragmas are allowed.
3714 The intention is that Source_File_Name_Project pragmas are always
3715 generated by the Project Manager in a manner consistent with the naming
3716 specified in a project file, and when naming is controlled in this manner,
3717 it is not permissible to attempt to modify this naming scheme using
3718 Source_File_Name pragmas (which would not be known to the project manager).
3720 @node Pragma Source_Reference
3721 @unnumberedsec Pragma Source_Reference
3722 @findex Source_Reference
3726 @smallexample @c ada
3727 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3731 This pragma must appear as the first line of a source file.
3732 @var{integer_literal} is the logical line number of the line following
3733 the pragma line (for use in error messages and debugging
3734 information). @var{string_literal} is a static string constant that
3735 specifies the file name to be used in error messages and debugging
3736 information. This is most notably used for the output of @code{gnatchop}
3737 with the @code{-r} switch, to make sure that the original unchopped
3738 source file is the one referred to.
3740 The second argument must be a string literal, it cannot be a static
3741 string expression other than a string literal. This is because its value
3742 is needed for error messages issued by all phases of the compiler.
3744 @node Pragma Stream_Convert
3745 @unnumberedsec Pragma Stream_Convert
3746 @findex Stream_Convert
3750 @smallexample @c ada
3751 pragma Stream_Convert (
3752 [Entity =>] type_local_NAME,
3753 [Read =>] function_NAME,
3754 [Write =>] function_NAME);
3758 This pragma provides an efficient way of providing stream functions for
3759 types defined in packages. Not only is it simpler to use than declaring
3760 the necessary functions with attribute representation clauses, but more
3761 significantly, it allows the declaration to made in such a way that the
3762 stream packages are not loaded unless they are needed. The use of
3763 the Stream_Convert pragma adds no overhead at all, unless the stream
3764 attributes are actually used on the designated type.
3766 The first argument specifies the type for which stream functions are
3767 provided. The second parameter provides a function used to read values
3768 of this type. It must name a function whose argument type may be any
3769 subtype, and whose returned type must be the type given as the first
3770 argument to the pragma.
3772 The meaning of the @var{Read}
3773 parameter is that if a stream attribute directly
3774 or indirectly specifies reading of the type given as the first parameter,
3775 then a value of the type given as the argument to the Read function is
3776 read from the stream, and then the Read function is used to convert this
3777 to the required target type.
3779 Similarly the @var{Write} parameter specifies how to treat write attributes
3780 that directly or indirectly apply to the type given as the first parameter.
3781 It must have an input parameter of the type specified by the first parameter,
3782 and the return type must be the same as the input type of the Read function.
3783 The effect is to first call the Write function to convert to the given stream
3784 type, and then write the result type to the stream.
3786 The Read and Write functions must not be overloaded subprograms. If necessary
3787 renamings can be supplied to meet this requirement.
3788 The usage of this attribute is best illustrated by a simple example, taken
3789 from the GNAT implementation of package Ada.Strings.Unbounded:
3791 @smallexample @c ada
3792 function To_Unbounded (S : String)
3793 return Unbounded_String
3794 renames To_Unbounded_String;
3796 pragma Stream_Convert
3797 (Unbounded_String, To_Unbounded, To_String);
3801 The specifications of the referenced functions, as given in the Ada
3802 Reference Manual are:
3804 @smallexample @c ada
3805 function To_Unbounded_String (Source : String)
3806 return Unbounded_String;
3808 function To_String (Source : Unbounded_String)
3813 The effect is that if the value of an unbounded string is written to a
3814 stream, then the representation of the item in the stream is in the same
3815 format used for @code{Standard.String}, and this same representation is
3816 expected when a value of this type is read from the stream.
3818 @node Pragma Style_Checks
3819 @unnumberedsec Pragma Style_Checks
3820 @findex Style_Checks
3824 @smallexample @c ada
3825 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3826 On | Off [, local_NAME]);
3830 This pragma is used in conjunction with compiler switches to control the
3831 built in style checking provided by GNAT@. The compiler switches, if set,
3832 provide an initial setting for the switches, and this pragma may be used
3833 to modify these settings, or the settings may be provided entirely by
3834 the use of the pragma. This pragma can be used anywhere that a pragma
3835 is legal, including use as a configuration pragma (including use in
3836 the @file{gnat.adc} file).
3838 The form with a string literal specifies which style options are to be
3839 activated. These are additive, so they apply in addition to any previously
3840 set style check options. The codes for the options are the same as those
3841 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3842 For example the following two methods can be used to enable
3847 @smallexample @c ada
3848 pragma Style_Checks ("l");
3853 gcc -c -gnatyl @dots{}
3858 The form ALL_CHECKS activates all standard checks (its use is equivalent
3859 to the use of the @code{gnaty} switch with no options. See GNAT User's
3862 The forms with @code{Off} and @code{On}
3863 can be used to temporarily disable style checks
3864 as shown in the following example:
3866 @smallexample @c ada
3870 pragma Style_Checks ("k"); -- requires keywords in lower case
3871 pragma Style_Checks (Off); -- turn off style checks
3872 NULL; -- this will not generate an error message
3873 pragma Style_Checks (On); -- turn style checks back on
3874 NULL; -- this will generate an error message
3878 Finally the two argument form is allowed only if the first argument is
3879 @code{On} or @code{Off}. The effect is to turn of semantic style checks
3880 for the specified entity, as shown in the following example:
3882 @smallexample @c ada
3886 pragma Style_Checks ("r"); -- require consistency of identifier casing
3888 Rf1 : Integer := ARG; -- incorrect, wrong case
3889 pragma Style_Checks (Off, Arg);
3890 Rf2 : Integer := ARG; -- OK, no error
3893 @node Pragma Subtitle
3894 @unnumberedsec Pragma Subtitle
3899 @smallexample @c ada
3900 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3904 This pragma is recognized for compatibility with other Ada compilers
3905 but is ignored by GNAT@.
3907 @node Pragma Suppress
3908 @unnumberedsec Pragma Suppress
3913 @smallexample @c ada
3914 pragma Suppress (Identifier [, [On =>] Name]);
3918 This is a standard pragma, and supports all the check names required in
3919 the RM. It is included here because GNAT recognizes one additional check
3920 name: @code{Alignment_Check} which can be used to suppress alignment checks
3921 on addresses used in address clauses. Such checks can also be suppressed
3922 by suppressing range checks, but the specific use of @code{Alignment_Check}
3923 allows suppression of alignment checks without suppressing other range checks.
3925 @node Pragma Suppress_All
3926 @unnumberedsec Pragma Suppress_All
3927 @findex Suppress_All
3931 @smallexample @c ada
3932 pragma Suppress_All;
3936 This pragma can only appear immediately following a compilation
3937 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
3938 which it follows. This pragma is implemented for compatibility with DEC
3939 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
3940 configuration pragma is the preferred usage in GNAT@.
3942 @node Pragma Suppress_Exception_Locations
3943 @unnumberedsec Pragma Suppress_Exception_Locations
3944 @findex Suppress_Exception_Locations
3948 @smallexample @c ada
3949 pragma Suppress_Exception_Locations;
3953 In normal mode, a raise statement for an exception by default generates
3954 an exception message giving the file name and line number for the location
3955 of the raise. This is useful for debugging and logging purposes, but this
3956 entails extra space for the strings for the messages. The configuration
3957 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3958 generation of these strings, with the result that space is saved, but the
3959 exception message for such raises is null. This configuration pragma may
3960 appear in a global configuration pragma file, or in a specific unit as
3961 usual. It is not required that this pragma be used consistently within
3962 a partition, so it is fine to have some units within a partition compiled
3963 with this pragma and others compiled in normal mode without it.
3965 @node Pragma Suppress_Initialization
3966 @unnumberedsec Pragma Suppress_Initialization
3967 @findex Suppress_Initialization
3968 @cindex Suppressing initialization
3969 @cindex Initialization, suppression of
3973 @smallexample @c ada
3974 pragma Suppress_Initialization ([Entity =>] type_Name);
3978 This pragma suppresses any implicit or explicit initialization
3979 associated with the given type name for all variables of this type.
3981 @node Pragma Task_Info
3982 @unnumberedsec Pragma Task_Info
3987 @smallexample @c ada
3988 pragma Task_Info (EXPRESSION);
3992 This pragma appears within a task definition (like pragma
3993 @code{Priority}) and applies to the task in which it appears. The
3994 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3995 The @code{Task_Info} pragma provides system dependent control over
3996 aspects of tasking implementation, for example, the ability to map
3997 tasks to specific processors. For details on the facilities available
3998 for the version of GNAT that you are using, see the documentation
3999 in the specification of package System.Task_Info in the runtime
4002 @node Pragma Task_Name
4003 @unnumberedsec Pragma Task_Name
4008 @smallexample @c ada
4009 pragma Task_Name (string_EXPRESSION);
4013 This pragma appears within a task definition (like pragma
4014 @code{Priority}) and applies to the task in which it appears. The
4015 argument must be of type String, and provides a name to be used for
4016 the task instance when the task is created. Note that this expression
4017 is not required to be static, and in particular, it can contain
4018 references to task discriminants. This facility can be used to
4019 provide different names for different tasks as they are created,
4020 as illustrated in the example below.
4022 The task name is recorded internally in the run-time structures
4023 and is accessible to tools like the debugger. In addition the
4024 routine @code{Ada.Task_Identification.Image} will return this
4025 string, with a unique task address appended.
4027 @smallexample @c ada
4028 -- Example of the use of pragma Task_Name
4030 with Ada.Task_Identification;
4031 use Ada.Task_Identification;
4032 with Text_IO; use Text_IO;
4035 type Astring is access String;
4037 task type Task_Typ (Name : access String) is
4038 pragma Task_Name (Name.all);
4041 task body Task_Typ is
4042 Nam : constant String := Image (Current_Task);
4044 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4047 type Ptr_Task is access Task_Typ;
4048 Task_Var : Ptr_Task;
4052 new Task_Typ (new String'("This is task 1"));
4054 new Task_Typ (new String'("This is task 2"));
4058 @node Pragma Task_Storage
4059 @unnumberedsec Pragma Task_Storage
4060 @findex Task_Storage
4063 @smallexample @c ada
4064 pragma Task_Storage (
4065 [Task_Type =>] local_NAME,
4066 [Top_Guard =>] static_integer_EXPRESSION);
4070 This pragma specifies the length of the guard area for tasks. The guard
4071 area is an additional storage area allocated to a task. A value of zero
4072 means that either no guard area is created or a minimal guard area is
4073 created, depending on the target. This pragma can appear anywhere a
4074 @code{Storage_Size} attribute definition clause is allowed for a task
4077 @node Pragma Time_Slice
4078 @unnumberedsec Pragma Time_Slice
4083 @smallexample @c ada
4084 pragma Time_Slice (static_duration_EXPRESSION);
4088 For implementations of GNAT on operating systems where it is possible
4089 to supply a time slice value, this pragma may be used for this purpose.
4090 It is ignored if it is used in a system that does not allow this control,
4091 or if it appears in other than the main program unit.
4093 Note that the effect of this pragma is identical to the effect of the
4094 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4097 @unnumberedsec Pragma Title
4102 @smallexample @c ada
4103 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4106 [Title =>] STRING_LITERAL,
4107 | [Subtitle =>] STRING_LITERAL
4111 Syntax checked but otherwise ignored by GNAT@. This is a listing control
4112 pragma used in DEC Ada 83 implementations to provide a title and/or
4113 subtitle for the program listing. The program listing generated by GNAT
4114 does not have titles or subtitles.
4116 Unlike other pragmas, the full flexibility of named notation is allowed
4117 for this pragma, i.e.@: the parameters may be given in any order if named
4118 notation is used, and named and positional notation can be mixed
4119 following the normal rules for procedure calls in Ada.
4121 @node Pragma Unchecked_Union
4122 @unnumberedsec Pragma Unchecked_Union
4124 @findex Unchecked_Union
4128 @smallexample @c ada
4129 pragma Unchecked_Union (first_subtype_local_NAME);
4133 This pragma is used to specify a representation of a record type that is
4134 equivalent to a C union. It was introduced as a GNAT implementation defined
4135 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4136 pragma, making it language defined, and GNAT fully implements this extended
4137 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4138 details, consult the Ada 2005 Reference Manual, section B.3.3.
4140 @node Pragma Unimplemented_Unit
4141 @unnumberedsec Pragma Unimplemented_Unit
4142 @findex Unimplemented_Unit
4146 @smallexample @c ada
4147 pragma Unimplemented_Unit;
4151 If this pragma occurs in a unit that is processed by the compiler, GNAT
4152 aborts with the message @samp{@var{xxx} not implemented}, where
4153 @var{xxx} is the name of the current compilation unit. This pragma is
4154 intended to allow the compiler to handle unimplemented library units in
4157 The abort only happens if code is being generated. Thus you can use
4158 specs of unimplemented packages in syntax or semantic checking mode.
4160 @node Pragma Universal_Aliasing
4161 @unnumberedsec Pragma Universal_Aliasing
4162 @findex Universal_Aliasing
4166 @smallexample @c ada
4167 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4171 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4172 declarative part. The effect is to inhibit strict type-based aliasing
4173 optimization for the given type. In other words, the effect is as though
4174 access types designating this type were subject to pragma No_Strict_Aliasing.
4175 For a detailed description of the strict aliasing optimization, and the
4176 situations in which it must be suppressed, see section
4177 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
4179 @node Pragma Universal_Data
4180 @unnumberedsec Pragma Universal_Data
4181 @findex Universal_Data
4185 @smallexample @c ada
4186 pragma Universal_Data [(library_unit_Name)];
4190 This pragma is supported only for the AAMP target and is ignored for
4191 other targets. The pragma specifies that all library-level objects
4192 (Counter 0 data) associated with the library unit are to be accessed
4193 and updated using universal addressing (24-bit addresses for AAMP5)
4194 rather than the default of 16-bit Data Environment (DENV) addressing.
4195 Use of this pragma will generally result in less efficient code for
4196 references to global data associated with the library unit, but
4197 allows such data to be located anywhere in memory. This pragma is
4198 a library unit pragma, but can also be used as a configuration pragma
4199 (including use in the @file{gnat.adc} file). The functionality
4200 of this pragma is also available by applying the -univ switch on the
4201 compilations of units where universal addressing of the data is desired.
4203 @node Pragma Unreferenced
4204 @unnumberedsec Pragma Unreferenced
4205 @findex Unreferenced
4206 @cindex Warnings, unreferenced
4210 @smallexample @c ada
4211 pragma Unreferenced (local_NAME @{, local_NAME@});
4212 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4216 This pragma signals that the entities whose names are listed are
4217 deliberately not referenced in the current source unit. This
4218 suppresses warnings about the
4219 entities being unreferenced, and in addition a warning will be
4220 generated if one of these entities is in fact referenced in the
4221 same unit as the pragma (or in the corresponding body, or one
4224 This is particularly useful for clearly signaling that a particular
4225 parameter is not referenced in some particular subprogram implementation
4226 and that this is deliberate. It can also be useful in the case of
4227 objects declared only for their initialization or finalization side
4230 If @code{local_NAME} identifies more than one matching homonym in the
4231 current scope, then the entity most recently declared is the one to which
4232 the pragma applies. Note that in the case of accept formals, the pragma
4233 Unreferenced may appear immediately after the keyword @code{do} which
4234 allows the indication of whether or not accept formals are referenced
4235 or not to be given individually for each accept statement.
4237 The left hand side of an assignment does not count as a reference for the
4238 purpose of this pragma. Thus it is fine to assign to an entity for which
4239 pragma Unreferenced is given.
4241 Note that if a warning is desired for all calls to a given subprogram,
4242 regardless of whether they occur in the same unit as the subprogram
4243 declaration, then this pragma should not be used (calls from another
4244 unit would not be flagged); pragma Obsolescent can be used instead
4245 for this purpose, see @xref{Pragma Obsolescent}.
4247 The second form of pragma @code{Unreferenced} is used within a context
4248 clause. In this case the arguments must be unit names of units previously
4249 mentioned in @code{with} clauses (similar to the usage of pragma
4250 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4253 @node Pragma Unreferenced_Objects
4254 @unnumberedsec Pragma Unreferenced_Objects
4255 @findex Unreferenced_Objects
4256 @cindex Warnings, unreferenced
4260 @smallexample @c ada
4261 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4265 This pragma signals that for the types or subtypes whose names are
4266 listed, objects which are declared with one of these types or subtypes may
4267 not be referenced, and if no references appear, no warnings are given.
4269 This is particularly useful for objects which are declared solely for their
4270 initialization and finalization effect. Such variables are sometimes referred
4271 to as RAII variables (Resource Acquisition Is Initialization). Using this
4272 pragma on the relevant type (most typically a limited controlled type), the
4273 compiler will automatically suppress unwanted warnings about these variables
4274 not being referenced.
4276 @node Pragma Unreserve_All_Interrupts
4277 @unnumberedsec Pragma Unreserve_All_Interrupts
4278 @findex Unreserve_All_Interrupts
4282 @smallexample @c ada
4283 pragma Unreserve_All_Interrupts;
4287 Normally certain interrupts are reserved to the implementation. Any attempt
4288 to attach an interrupt causes Program_Error to be raised, as described in
4289 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4290 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
4291 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4292 interrupt execution.
4294 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4295 a program, then all such interrupts are unreserved. This allows the
4296 program to handle these interrupts, but disables their standard
4297 functions. For example, if this pragma is used, then pressing
4298 @kbd{Ctrl-C} will not automatically interrupt execution. However,
4299 a program can then handle the @code{SIGINT} interrupt as it chooses.
4301 For a full list of the interrupts handled in a specific implementation,
4302 see the source code for the specification of @code{Ada.Interrupts.Names} in
4303 file @file{a-intnam.ads}. This is a target dependent file that contains the
4304 list of interrupts recognized for a given target. The documentation in
4305 this file also specifies what interrupts are affected by the use of
4306 the @code{Unreserve_All_Interrupts} pragma.
4308 For a more general facility for controlling what interrupts can be
4309 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4310 of the @code{Unreserve_All_Interrupts} pragma.
4312 @node Pragma Unsuppress
4313 @unnumberedsec Pragma Unsuppress
4318 @smallexample @c ada
4319 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4323 This pragma undoes the effect of a previous pragma @code{Suppress}. If
4324 there is no corresponding pragma @code{Suppress} in effect, it has no
4325 effect. The range of the effect is the same as for pragma
4326 @code{Suppress}. The meaning of the arguments is identical to that used
4327 in pragma @code{Suppress}.
4329 One important application is to ensure that checks are on in cases where
4330 code depends on the checks for its correct functioning, so that the code
4331 will compile correctly even if the compiler switches are set to suppress
4334 @node Pragma Use_VADS_Size
4335 @unnumberedsec Pragma Use_VADS_Size
4336 @cindex @code{Size}, VADS compatibility
4337 @findex Use_VADS_Size
4341 @smallexample @c ada
4342 pragma Use_VADS_Size;
4346 This is a configuration pragma. In a unit to which it applies, any use
4347 of the 'Size attribute is automatically interpreted as a use of the
4348 'VADS_Size attribute. Note that this may result in incorrect semantic
4349 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
4350 the handling of existing code which depends on the interpretation of Size
4351 as implemented in the VADS compiler. See description of the VADS_Size
4352 attribute for further details.
4354 @node Pragma Validity_Checks
4355 @unnumberedsec Pragma Validity_Checks
4356 @findex Validity_Checks
4360 @smallexample @c ada
4361 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4365 This pragma is used in conjunction with compiler switches to control the
4366 built-in validity checking provided by GNAT@. The compiler switches, if set
4367 provide an initial setting for the switches, and this pragma may be used
4368 to modify these settings, or the settings may be provided entirely by
4369 the use of the pragma. This pragma can be used anywhere that a pragma
4370 is legal, including use as a configuration pragma (including use in
4371 the @file{gnat.adc} file).
4373 The form with a string literal specifies which validity options are to be
4374 activated. The validity checks are first set to include only the default
4375 reference manual settings, and then a string of letters in the string
4376 specifies the exact set of options required. The form of this string
4377 is exactly as described for the @code{-gnatVx} compiler switch (see the
4378 GNAT users guide for details). For example the following two methods
4379 can be used to enable validity checking for mode @code{in} and
4380 @code{in out} subprogram parameters:
4384 @smallexample @c ada
4385 pragma Validity_Checks ("im");
4390 gcc -c -gnatVim @dots{}
4395 The form ALL_CHECKS activates all standard checks (its use is equivalent
4396 to the use of the @code{gnatva} switch.
4398 The forms with @code{Off} and @code{On}
4399 can be used to temporarily disable validity checks
4400 as shown in the following example:
4402 @smallexample @c ada
4406 pragma Validity_Checks ("c"); -- validity checks for copies
4407 pragma Validity_Checks (Off); -- turn off validity checks
4408 A := B; -- B will not be validity checked
4409 pragma Validity_Checks (On); -- turn validity checks back on
4410 A := C; -- C will be validity checked
4413 @node Pragma Volatile
4414 @unnumberedsec Pragma Volatile
4419 @smallexample @c ada
4420 pragma Volatile (local_NAME);
4424 This pragma is defined by the Ada Reference Manual, and the GNAT
4425 implementation is fully conformant with this definition. The reason it
4426 is mentioned in this section is that a pragma of the same name was supplied
4427 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
4428 implementation of pragma Volatile is upwards compatible with the
4429 implementation in DEC Ada 83.
4431 @node Pragma Warnings
4432 @unnumberedsec Pragma Warnings
4437 @smallexample @c ada
4438 pragma Warnings (On | Off);
4439 pragma Warnings (On | Off, local_NAME);
4440 pragma Warnings (static_string_EXPRESSION);
4441 pragma Warnings (On | Off, static_string_EXPRESSION);
4445 Normally warnings are enabled, with the output being controlled by
4446 the command line switch. Warnings (@code{Off}) turns off generation of
4447 warnings until a Warnings (@code{On}) is encountered or the end of the
4448 current unit. If generation of warnings is turned off using this
4449 pragma, then no warning messages are output, regardless of the
4450 setting of the command line switches.
4452 The form with a single argument may be used as a configuration pragma.
4454 If the @var{local_NAME} parameter is present, warnings are suppressed for
4455 the specified entity. This suppression is effective from the point where
4456 it occurs till the end of the extended scope of the variable (similar to
4457 the scope of @code{Suppress}).
4459 The form with a single static_string_EXPRESSION argument provides more precise
4460 control over which warnings are active. The string is a list of letters
4461 specifying which warnings are to be activated and which deactivated. The
4462 code for these letters is the same as the string used in the command
4463 line switch controlling warnings. The following is a brief summary. For
4464 full details see the GNAT Users Guide:
4467 a turn on all optional warnings (except d,h,l)
4468 A turn off all optional warnings
4469 b turn on warnings for bad fixed value (not multiple of small)
4470 B turn off warnings for bad fixed value (not multiple of small)
4471 c turn on warnings for constant conditional
4472 C turn off warnings for constant conditional
4473 d turn on warnings for implicit dereference
4474 D turn off warnings for implicit dereference
4475 e treat all warnings as errors
4476 f turn on warnings for unreferenced formal
4477 F turn off warnings for unreferenced formal
4478 g turn on warnings for unrecognized pragma
4479 G turn off warnings for unrecognized pragma
4480 h turn on warnings for hiding variable
4481 H turn off warnings for hiding variable
4482 i turn on warnings for implementation unit
4483 I turn off warnings for implementation unit
4484 j turn on warnings for obsolescent (annex J) feature
4485 J turn off warnings for obsolescent (annex J) feature
4486 k turn on warnings on constant variable
4487 K turn off warnings on constant variable
4488 l turn on warnings for missing elaboration pragma
4489 L turn off warnings for missing elaboration pragma
4490 m turn on warnings for variable assigned but not read
4491 M turn off warnings for variable assigned but not read
4492 n normal warning mode (cancels -gnatws/-gnatwe)
4493 o turn on warnings for address clause overlay
4494 O turn off warnings for address clause overlay
4495 p turn on warnings for ineffective pragma Inline
4496 P turn off warnings for ineffective pragma Inline
4497 q turn on warnings for questionable missing parentheses
4498 Q turn off warnings for questionable missing parentheses
4499 r turn on warnings for redundant construct
4500 R turn off warnings for redundant construct
4501 s suppress all warnings
4502 t turn on warnings for tracking deleted code
4503 T turn off warnings for tracking deleted code
4504 u turn on warnings for unused entity
4505 U turn off warnings for unused entity
4506 v turn on warnings for unassigned variable
4507 V turn off warnings for unassigned variable
4508 w turn on warnings for wrong low bound assumption
4509 W turn off warnings for wrong low bound assumption
4510 x turn on warnings for export/import
4511 X turn off warnings for export/import
4512 y turn on warnings for Ada 2005 incompatibility
4513 Y turn off warnings for Ada 2005 incompatibility
4514 z turn on size/align warnings for unchecked conversion
4515 Z turn off size/align warnings for unchecked conversion
4519 The specified warnings will be in effect until the end of the program
4520 or another pragma Warnings is encountered. The effect of the pragma is
4521 cumulative. Initially the set of warnings is the standard default set
4522 as possibly modified by compiler switches. Then each pragma Warning
4523 modifies this set of warnings as specified. This form of the pragma may
4524 also be used as a configuration pragma.
4526 The fourth form, with an On|Off parameter and a string, is used to
4527 control individual messages, based on their text. The string argument
4528 is a pattern that is used to match against the text of individual
4529 warning messages (not including the initial "warnings: " tag).
4531 The pattern may start with an asterisk, which matches otherwise unmatched
4532 characters at the start of the message, and it may also end with an asterisk
4533 which matches otherwise unmatched characters at the end of the message. For
4534 example, the string "*alignment*" could be used to match any warnings about
4535 alignment problems. Within the string, the sequence "*" can be used to match
4536 any sequence of characters enclosed in quotation marks. No other regular
4537 expression notations are permitted. All characters other than asterisk in
4538 these three specific cases are treated as literal characters in the match.
4540 There are two ways to use this pragma. The OFF form can be used as a
4541 configuration pragma. The effect is to suppress all warnings (if any)
4542 that match the pattern string throughout the compilation.
4544 The second usage is to suppress a warning locally, and in this case, two
4545 pragmas must appear in sequence:
4547 @smallexample @c ada
4548 pragma Warnings (Off, Pattern);
4549 .. code where given warning is to be suppressed
4550 pragma Warnings (On, Pattern);
4554 In this usage, the pattern string must match in the Off and On pragmas,
4555 and at least one matching warning must be suppressed.
4557 @node Pragma Weak_External
4558 @unnumberedsec Pragma Weak_External
4559 @findex Weak_External
4563 @smallexample @c ada
4564 pragma Weak_External ([Entity =>] local_NAME);
4568 @var{local_NAME} must refer to an object that is declared at the library
4569 level. This pragma specifies that the given entity should be marked as a
4570 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
4571 in GNU C and causes @var{local_NAME} to be emitted as a weak symbol instead
4572 of a regular symbol, that is to say a symbol that does not have to be
4573 resolved by the linker if used in conjunction with a pragma Import.
4575 When a weak symbol is not resolved by the linker, its address is set to
4576 zero. This is useful in writing interfaces to external modules that may
4577 or may not be linked in the final executable, for example depending on
4578 configuration settings.
4580 If a program references at run time an entity to which this pragma has been
4581 applied, and the corresponding symbol was not resolved at link time, then
4582 the execution of the program is erroneous. It is not erroneous to take the
4583 Address of such an entity, for example to guard potential references,
4584 as shown in the example below.
4586 Some file formats do not support weak symbols so not all target machines
4587 support this pragma.
4589 @smallexample @c ada
4590 -- Example of the use of pragma Weak_External
4592 package External_Module is
4594 pragma Import (C, key);
4595 pragma Weak_External (key);
4596 function Present return boolean;
4597 end External_Module;
4599 with System; use System;
4600 package body External_Module is
4601 function Present return boolean is
4603 return key'Address /= System.Null_Address;
4605 end External_Module;
4608 @node Pragma Wide_Character_Encoding
4609 @unnumberedsec Pragma Wide_Character_Encoding
4610 @findex Wide_Character_Encoding
4614 @smallexample @c ada
4615 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
4619 This pragma specifies the wide character encoding to be used in program
4620 source text appearing subsequently. It is a configuration pragma, but may
4621 also be used at any point that a pragma is allowed, and it is permissible
4622 to have more than one such pragma in a file, allowing multiple encodings
4623 to appear within the same file.
4625 The argument can be an identifier or a character literal. In the identifier
4626 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
4627 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
4628 case it is correspondingly one of the characters h,u,s,e,8,b.
4630 Note that when the pragma is used within a file, it affects only the
4631 encoding within that file, and does not affect withed units, specs,
4634 @node Implementation Defined Attributes
4635 @chapter Implementation Defined Attributes
4636 Ada defines (throughout the Ada reference manual,
4637 summarized in Annex K),
4638 a set of attributes that provide useful additional functionality in all
4639 areas of the language. These language defined attributes are implemented
4640 in GNAT and work as described in the Ada Reference Manual.
4642 In addition, Ada allows implementations to define additional
4643 attributes whose meaning is defined by the implementation. GNAT provides
4644 a number of these implementation-dependent attributes which can be used
4645 to extend and enhance the functionality of the compiler. This section of
4646 the GNAT reference manual describes these additional attributes.
4648 Note that any program using these attributes may not be portable to
4649 other compilers (although GNAT implements this set of attributes on all
4650 platforms). Therefore if portability to other compilers is an important
4651 consideration, you should minimize the use of these attributes.
4662 * Default_Bit_Order::
4671 * Has_Access_Values::
4672 * Has_Discriminants::
4678 * Max_Interrupt_Priority::
4680 * Maximum_Alignment::
4684 * Passed_By_Reference::
4696 * Unconstrained_Array::
4697 * Universal_Literal_String::
4698 * Unrestricted_Access::
4706 @unnumberedsec Abort_Signal
4707 @findex Abort_Signal
4709 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4710 prefix) provides the entity for the special exception used to signal
4711 task abort or asynchronous transfer of control. Normally this attribute
4712 should only be used in the tasking runtime (it is highly peculiar, and
4713 completely outside the normal semantics of Ada, for a user program to
4714 intercept the abort exception).
4717 @unnumberedsec Address_Size
4718 @cindex Size of @code{Address}
4719 @findex Address_Size
4721 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4722 prefix) is a static constant giving the number of bits in an
4723 @code{Address}. It is the same value as System.Address'Size,
4724 but has the advantage of being static, while a direct
4725 reference to System.Address'Size is non-static because Address
4729 @unnumberedsec Asm_Input
4732 The @code{Asm_Input} attribute denotes a function that takes two
4733 parameters. The first is a string, the second is an expression of the
4734 type designated by the prefix. The first (string) argument is required
4735 to be a static expression, and is the constraint for the parameter,
4736 (e.g.@: what kind of register is required). The second argument is the
4737 value to be used as the input argument. The possible values for the
4738 constant are the same as those used in the RTL, and are dependent on
4739 the configuration file used to built the GCC back end.
4740 @ref{Machine Code Insertions}
4743 @unnumberedsec Asm_Output
4746 The @code{Asm_Output} attribute denotes a function that takes two
4747 parameters. The first is a string, the second is the name of a variable
4748 of the type designated by the attribute prefix. The first (string)
4749 argument is required to be a static expression and designates the
4750 constraint for the parameter (e.g.@: what kind of register is
4751 required). The second argument is the variable to be updated with the
4752 result. The possible values for constraint are the same as those used in
4753 the RTL, and are dependent on the configuration file used to build the
4754 GCC back end. If there are no output operands, then this argument may
4755 either be omitted, or explicitly given as @code{No_Output_Operands}.
4756 @ref{Machine Code Insertions}
4759 @unnumberedsec AST_Entry
4763 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
4764 the name of an entry, it yields a value of the predefined type AST_Handler
4765 (declared in the predefined package System, as extended by the use of
4766 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
4767 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
4768 Language Reference Manual}, section 9.12a.
4773 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4774 offset within the storage unit (byte) that contains the first bit of
4775 storage allocated for the object. The value of this attribute is of the
4776 type @code{Universal_Integer}, and is always a non-negative number not
4777 exceeding the value of @code{System.Storage_Unit}.
4779 For an object that is a variable or a constant allocated in a register,
4780 the value is zero. (The use of this attribute does not force the
4781 allocation of a variable to memory).
4783 For an object that is a formal parameter, this attribute applies
4784 to either the matching actual parameter or to a copy of the
4785 matching actual parameter.
4787 For an access object the value is zero. Note that
4788 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4789 designated object. Similarly for a record component
4790 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4791 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4792 are subject to index checks.
4794 This attribute is designed to be compatible with the DEC Ada 83 definition
4795 and implementation of the @code{Bit} attribute.
4798 @unnumberedsec Bit_Position
4799 @findex Bit_Position
4801 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4802 of the fields of the record type, yields the bit
4803 offset within the record contains the first bit of
4804 storage allocated for the object. The value of this attribute is of the
4805 type @code{Universal_Integer}. The value depends only on the field
4806 @var{C} and is independent of the alignment of
4807 the containing record @var{R}.
4810 @unnumberedsec Code_Address
4811 @findex Code_Address
4812 @cindex Subprogram address
4813 @cindex Address of subprogram code
4816 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
4817 intended effect seems to be to provide
4818 an address value which can be used to call the subprogram by means of
4819 an address clause as in the following example:
4821 @smallexample @c ada
4822 procedure K is @dots{}
4825 for L'Address use K'Address;
4826 pragma Import (Ada, L);
4830 A call to @code{L} is then expected to result in a call to @code{K}@.
4831 In Ada 83, where there were no access-to-subprogram values, this was
4832 a common work-around for getting the effect of an indirect call.
4833 GNAT implements the above use of @code{Address} and the technique
4834 illustrated by the example code works correctly.
4836 However, for some purposes, it is useful to have the address of the start
4837 of the generated code for the subprogram. On some architectures, this is
4838 not necessarily the same as the @code{Address} value described above.
4839 For example, the @code{Address} value may reference a subprogram
4840 descriptor rather than the subprogram itself.
4842 The @code{'Code_Address} attribute, which can only be applied to
4843 subprogram entities, always returns the address of the start of the
4844 generated code of the specified subprogram, which may or may not be
4845 the same value as is returned by the corresponding @code{'Address}
4848 @node Default_Bit_Order
4849 @unnumberedsec Default_Bit_Order
4851 @cindex Little endian
4852 @findex Default_Bit_Order
4854 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4855 permissible prefix), provides the value @code{System.Default_Bit_Order}
4856 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4857 @code{Low_Order_First}). This is used to construct the definition of
4858 @code{Default_Bit_Order} in package @code{System}.
4861 @unnumberedsec Elaborated
4864 The prefix of the @code{'Elaborated} attribute must be a unit name. The
4865 value is a Boolean which indicates whether or not the given unit has been
4866 elaborated. This attribute is primarily intended for internal use by the
4867 generated code for dynamic elaboration checking, but it can also be used
4868 in user programs. The value will always be True once elaboration of all
4869 units has been completed. An exception is for units which need no
4870 elaboration, the value is always False for such units.
4873 @unnumberedsec Elab_Body
4876 This attribute can only be applied to a program unit name. It returns
4877 the entity for the corresponding elaboration procedure for elaborating
4878 the body of the referenced unit. This is used in the main generated
4879 elaboration procedure by the binder and is not normally used in any
4880 other context. However, there may be specialized situations in which it
4881 is useful to be able to call this elaboration procedure from Ada code,
4882 e.g.@: if it is necessary to do selective re-elaboration to fix some
4886 @unnumberedsec Elab_Spec
4889 This attribute can only be applied to a program unit name. It returns
4890 the entity for the corresponding elaboration procedure for elaborating
4891 the specification of the referenced unit. This is used in the main
4892 generated elaboration procedure by the binder and is not normally used
4893 in any other context. However, there may be specialized situations in
4894 which it is useful to be able to call this elaboration procedure from
4895 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4900 @cindex Ada 83 attributes
4903 The @code{Emax} attribute is provided for compatibility with Ada 83. See
4904 the Ada 83 reference manual for an exact description of the semantics of
4908 @unnumberedsec Enabled
4911 The @code{Enabled} attribute allows an application program to check at compile
4912 time to see if the designated check is currently enabled. The prefix is a
4913 simple identifier, referencing any predefined check name (other than
4914 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
4915 no argument is given for the attribute, the check is for the general state
4916 of the check, if an argument is given, then it is an entity name, and the
4917 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
4918 given naming the entity (if not, then the argument is ignored).
4920 Note that instantiations inherit the check status at the point of the
4921 instantiation, so a useful idiom is to have a library package that
4922 introduces a check name with @code{pragma Check_Name}, and then contains
4923 generic packages or subprograms which use the @code{Enabled} attribute
4924 to see if the check is enabled. A user of this package can then issue
4925 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
4926 the package or subprogram, controlling whether the check will be present.
4929 @unnumberedsec Enum_Rep
4930 @cindex Representation of enums
4933 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4934 function with the following spec:
4936 @smallexample @c ada
4937 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4938 return @i{Universal_Integer};
4942 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4943 enumeration type or to a non-overloaded enumeration
4944 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
4945 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4946 enumeration literal or object.
4948 The function returns the representation value for the given enumeration
4949 value. This will be equal to value of the @code{Pos} attribute in the
4950 absence of an enumeration representation clause. This is a static
4951 attribute (i.e.@: the result is static if the argument is static).
4953 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4954 in which case it simply returns the integer value. The reason for this
4955 is to allow it to be used for @code{(<>)} discrete formal arguments in
4956 a generic unit that can be instantiated with either enumeration types
4957 or integer types. Note that if @code{Enum_Rep} is used on a modular
4958 type whose upper bound exceeds the upper bound of the largest signed
4959 integer type, and the argument is a variable, so that the universal
4960 integer calculation is done at run time, then the call to @code{Enum_Rep}
4961 may raise @code{Constraint_Error}.
4964 @unnumberedsec Epsilon
4965 @cindex Ada 83 attributes
4968 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
4969 the Ada 83 reference manual for an exact description of the semantics of
4973 @unnumberedsec Fixed_Value
4976 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4977 function with the following specification:
4979 @smallexample @c ada
4980 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4985 The value returned is the fixed-point value @var{V} such that
4987 @smallexample @c ada
4988 @var{V} = Arg * @var{S}'Small
4992 The effect is thus similar to first converting the argument to the
4993 integer type used to represent @var{S}, and then doing an unchecked
4994 conversion to the fixed-point type. The difference is
4995 that there are full range checks, to ensure that the result is in range.
4996 This attribute is primarily intended for use in implementation of the
4997 input-output functions for fixed-point values.
4999 @node Has_Access_Values
5000 @unnumberedsec Has_Access_Values
5001 @cindex Access values, testing for
5002 @findex Has_Access_Values
5004 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5005 is a Boolean value which is True if the is an access type, or is a composite
5006 type with a component (at any nesting depth) that is an access type, and is
5008 The intended use of this attribute is in conjunction with generic
5009 definitions. If the attribute is applied to a generic private type, it
5010 indicates whether or not the corresponding actual type has access values.
5012 @node Has_Discriminants
5013 @unnumberedsec Has_Discriminants
5014 @cindex Discriminants, testing for
5015 @findex Has_Discriminants
5017 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5018 is a Boolean value which is True if the type has discriminants, and False
5019 otherwise. The intended use of this attribute is in conjunction with generic
5020 definitions. If the attribute is applied to a generic private type, it
5021 indicates whether or not the corresponding actual type has discriminants.
5027 The @code{Img} attribute differs from @code{Image} in that it may be
5028 applied to objects as well as types, in which case it gives the
5029 @code{Image} for the subtype of the object. This is convenient for
5032 @smallexample @c ada
5033 Put_Line ("X = " & X'Img);
5037 has the same meaning as the more verbose:
5039 @smallexample @c ada
5040 Put_Line ("X = " & @var{T}'Image (X));
5044 where @var{T} is the (sub)type of the object @code{X}.
5047 @unnumberedsec Integer_Value
5048 @findex Integer_Value
5050 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5051 function with the following spec:
5053 @smallexample @c ada
5054 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5059 The value returned is the integer value @var{V}, such that
5061 @smallexample @c ada
5062 Arg = @var{V} * @var{T}'Small
5066 where @var{T} is the type of @code{Arg}.
5067 The effect is thus similar to first doing an unchecked conversion from
5068 the fixed-point type to its corresponding implementation type, and then
5069 converting the result to the target integer type. The difference is
5070 that there are full range checks, to ensure that the result is in range.
5071 This attribute is primarily intended for use in implementation of the
5072 standard input-output functions for fixed-point values.
5075 @unnumberedsec Large
5076 @cindex Ada 83 attributes
5079 The @code{Large} attribute is provided for compatibility with Ada 83. See
5080 the Ada 83 reference manual for an exact description of the semantics of
5084 @unnumberedsec Machine_Size
5085 @findex Machine_Size
5087 This attribute is identical to the @code{Object_Size} attribute. It is
5088 provided for compatibility with the DEC Ada 83 attribute of this name.
5091 @unnumberedsec Mantissa
5092 @cindex Ada 83 attributes
5095 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
5096 the Ada 83 reference manual for an exact description of the semantics of
5099 @node Max_Interrupt_Priority
5100 @unnumberedsec Max_Interrupt_Priority
5101 @cindex Interrupt priority, maximum
5102 @findex Max_Interrupt_Priority
5104 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5105 permissible prefix), provides the same value as
5106 @code{System.Max_Interrupt_Priority}.
5109 @unnumberedsec Max_Priority
5110 @cindex Priority, maximum
5111 @findex Max_Priority
5113 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5114 prefix) provides the same value as @code{System.Max_Priority}.
5116 @node Maximum_Alignment
5117 @unnumberedsec Maximum_Alignment
5118 @cindex Alignment, maximum
5119 @findex Maximum_Alignment
5121 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5122 permissible prefix) provides the maximum useful alignment value for the
5123 target. This is a static value that can be used to specify the alignment
5124 for an object, guaranteeing that it is properly aligned in all
5127 @node Mechanism_Code
5128 @unnumberedsec Mechanism_Code
5129 @cindex Return values, passing mechanism
5130 @cindex Parameters, passing mechanism
5131 @findex Mechanism_Code
5133 @code{@var{function}'Mechanism_Code} yields an integer code for the
5134 mechanism used for the result of function, and
5135 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5136 used for formal parameter number @var{n} (a static integer value with 1
5137 meaning the first parameter) of @var{subprogram}. The code returned is:
5145 by descriptor (default descriptor class)
5147 by descriptor (UBS: unaligned bit string)
5149 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5151 by descriptor (UBA: unaligned bit array)
5153 by descriptor (S: string, also scalar access type parameter)
5155 by descriptor (SB: string with arbitrary bounds)
5157 by descriptor (A: contiguous array)
5159 by descriptor (NCA: non-contiguous array)
5163 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5166 @node Null_Parameter
5167 @unnumberedsec Null_Parameter
5168 @cindex Zero address, passing
5169 @findex Null_Parameter
5171 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5172 type or subtype @var{T} allocated at machine address zero. The attribute
5173 is allowed only as the default expression of a formal parameter, or as
5174 an actual expression of a subprogram call. In either case, the
5175 subprogram must be imported.
5177 The identity of the object is represented by the address zero in the
5178 argument list, independent of the passing mechanism (explicit or
5181 This capability is needed to specify that a zero address should be
5182 passed for a record or other composite object passed by reference.
5183 There is no way of indicating this without the @code{Null_Parameter}
5187 @unnumberedsec Object_Size
5188 @cindex Size, used for objects
5191 The size of an object is not necessarily the same as the size of the type
5192 of an object. This is because by default object sizes are increased to be
5193 a multiple of the alignment of the object. For example,
5194 @code{Natural'Size} is
5195 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5196 Similarly, a record containing an integer and a character:
5198 @smallexample @c ada
5206 will have a size of 40 (that is @code{Rec'Size} will be 40. The
5207 alignment will be 4, because of the
5208 integer field, and so the default size of record objects for this type
5209 will be 64 (8 bytes).
5211 The @code{@var{type}'Object_Size} attribute
5212 has been added to GNAT to allow the
5213 default object size of a type to be easily determined. For example,
5214 @code{Natural'Object_Size} is 32, and
5215 @code{Rec'Object_Size} (for the record type in the above example) will be
5216 64. Note also that, unlike the situation with the
5217 @code{Size} attribute as defined in the Ada RM, the
5218 @code{Object_Size} attribute can be specified individually
5219 for different subtypes. For example:
5221 @smallexample @c ada
5222 type R is new Integer;
5223 subtype R1 is R range 1 .. 10;
5224 subtype R2 is R range 1 .. 10;
5225 for R2'Object_Size use 8;
5229 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
5230 32 since the default object size for a subtype is the same as the object size
5231 for the parent subtype. This means that objects of type @code{R}
5233 by default be 32 bits (four bytes). But objects of type
5234 @code{R2} will be only
5235 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
5237 Although @code{Object_Size} does properly reflect the default object size
5238 value, it is not necessarily the case that all objects will be of this size
5239 in a case where it is not specified explicitly. The compiler is free to
5240 increase the size and alignment of stand alone objects to improve efficiency
5241 of the generated code and sometimes does so in the case of large composite
5242 objects. If the size of a stand alone object is critical to the
5243 application, it should be specified explicitly.
5245 @node Passed_By_Reference
5246 @unnumberedsec Passed_By_Reference
5247 @cindex Parameters, when passed by reference
5248 @findex Passed_By_Reference
5250 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5251 a value of type @code{Boolean} value that is @code{True} if the type is
5252 normally passed by reference and @code{False} if the type is normally
5253 passed by copy in calls. For scalar types, the result is always @code{False}
5254 and is static. For non-scalar types, the result is non-static.
5257 @unnumberedsec Range_Length
5258 @findex Range_Length
5260 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5261 the number of values represented by the subtype (zero for a null
5262 range). The result is static for static subtypes. @code{Range_Length}
5263 applied to the index subtype of a one dimensional array always gives the
5264 same result as @code{Range} applied to the array itself.
5267 @unnumberedsec Safe_Emax
5268 @cindex Ada 83 attributes
5271 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
5272 the Ada 83 reference manual for an exact description of the semantics of
5276 @unnumberedsec Safe_Large
5277 @cindex Ada 83 attributes
5280 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
5281 the Ada 83 reference manual for an exact description of the semantics of
5285 @unnumberedsec Small
5286 @cindex Ada 83 attributes
5289 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5291 GNAT also allows this attribute to be applied to floating-point types
5292 for compatibility with Ada 83. See
5293 the Ada 83 reference manual for an exact description of the semantics of
5294 this attribute when applied to floating-point types.
5297 @unnumberedsec Storage_Unit
5298 @findex Storage_Unit
5300 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5301 prefix) provides the same value as @code{System.Storage_Unit}.
5304 @unnumberedsec Stub_Type
5307 The GNAT implementation of remote access-to-classwide types is
5308 organized as described in AARM section E.4 (20.t): a value of an RACW type
5309 (designating a remote object) is represented as a normal access
5310 value, pointing to a "stub" object which in turn contains the
5311 necessary information to contact the designated remote object. A
5312 call on any dispatching operation of such a stub object does the
5313 remote call, if necessary, using the information in the stub object
5314 to locate the target partition, etc.
5316 For a prefix @code{T} that denotes a remote access-to-classwide type,
5317 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5319 By construction, the layout of @code{T'Stub_Type} is identical to that of
5320 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5321 unit @code{System.Partition_Interface}. Use of this attribute will create
5322 an implicit dependency on this unit.
5325 @unnumberedsec Target_Name
5328 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5329 prefix) provides a static string value that identifies the target
5330 for the current compilation. For GCC implementations, this is the
5331 standard gcc target name without the terminating slash (for
5332 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5338 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5339 provides the same value as @code{System.Tick},
5342 @unnumberedsec To_Address
5345 The @code{System'To_Address}
5346 (@code{System} is the only permissible prefix)
5347 denotes a function identical to
5348 @code{System.Storage_Elements.To_Address} except that
5349 it is a static attribute. This means that if its argument is
5350 a static expression, then the result of the attribute is a
5351 static expression. The result is that such an expression can be
5352 used in contexts (e.g.@: preelaborable packages) which require a
5353 static expression and where the function call could not be used
5354 (since the function call is always non-static, even if its
5355 argument is static).
5358 @unnumberedsec Type_Class
5361 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5362 the value of the type class for the full type of @var{type}. If
5363 @var{type} is a generic formal type, the value is the value for the
5364 corresponding actual subtype. The value of this attribute is of type
5365 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5367 @smallexample @c ada
5369 (Type_Class_Enumeration,
5371 Type_Class_Fixed_Point,
5372 Type_Class_Floating_Point,
5377 Type_Class_Address);
5381 Protected types yield the value @code{Type_Class_Task}, which thus
5382 applies to all concurrent types. This attribute is designed to
5383 be compatible with the DEC Ada 83 attribute of the same name.
5386 @unnumberedsec UET_Address
5389 The @code{UET_Address} attribute can only be used for a prefix which
5390 denotes a library package. It yields the address of the unit exception
5391 table when zero cost exception handling is used. This attribute is
5392 intended only for use within the GNAT implementation. See the unit
5393 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5394 for details on how this attribute is used in the implementation.
5396 @node Unconstrained_Array
5397 @unnumberedsec Unconstrained_Array
5398 @findex Unconstrained_Array
5400 The @code{Unconstrained_Array} attribute can be used with a prefix that
5401 denotes any type or subtype. It is a static attribute that yields
5402 @code{True} if the prefix designates an unconstrained array,
5403 and @code{False} otherwise. In a generic instance, the result is
5404 still static, and yields the result of applying this test to the
5407 @node Universal_Literal_String
5408 @unnumberedsec Universal_Literal_String
5409 @cindex Named numbers, representation of
5410 @findex Universal_Literal_String
5412 The prefix of @code{Universal_Literal_String} must be a named
5413 number. The static result is the string consisting of the characters of
5414 the number as defined in the original source. This allows the user
5415 program to access the actual text of named numbers without intermediate
5416 conversions and without the need to enclose the strings in quotes (which
5417 would preclude their use as numbers). This is used internally for the
5418 construction of values of the floating-point attributes from the file
5419 @file{ttypef.ads}, but may also be used by user programs.
5421 For example, the following program prints the first 50 digits of pi:
5423 @smallexample @c ada
5424 with Text_IO; use Text_IO;
5428 Put (Ada.Numerics.Pi'Universal_Literal_String);
5432 @node Unrestricted_Access
5433 @unnumberedsec Unrestricted_Access
5434 @cindex @code{Access}, unrestricted
5435 @findex Unrestricted_Access
5437 The @code{Unrestricted_Access} attribute is similar to @code{Access}
5438 except that all accessibility and aliased view checks are omitted. This
5439 is a user-beware attribute. It is similar to
5440 @code{Address}, for which it is a desirable replacement where the value
5441 desired is an access type. In other words, its effect is identical to
5442 first applying the @code{Address} attribute and then doing an unchecked
5443 conversion to a desired access type. In GNAT, but not necessarily in
5444 other implementations, the use of static chains for inner level
5445 subprograms means that @code{Unrestricted_Access} applied to a
5446 subprogram yields a value that can be called as long as the subprogram
5447 is in scope (normal Ada accessibility rules restrict this usage).
5449 It is possible to use @code{Unrestricted_Access} for any type, but care
5450 must be exercised if it is used to create pointers to unconstrained
5451 objects. In this case, the resulting pointer has the same scope as the
5452 context of the attribute, and may not be returned to some enclosing
5453 scope. For instance, a function cannot use @code{Unrestricted_Access}
5454 to create a unconstrained pointer and then return that value to the
5458 @unnumberedsec VADS_Size
5459 @cindex @code{Size}, VADS compatibility
5462 The @code{'VADS_Size} attribute is intended to make it easier to port
5463 legacy code which relies on the semantics of @code{'Size} as implemented
5464 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
5465 same semantic interpretation. In particular, @code{'VADS_Size} applied
5466 to a predefined or other primitive type with no Size clause yields the
5467 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
5468 typical machines). In addition @code{'VADS_Size} applied to an object
5469 gives the result that would be obtained by applying the attribute to
5470 the corresponding type.
5473 @unnumberedsec Value_Size
5474 @cindex @code{Size}, setting for not-first subtype
5476 @code{@var{type}'Value_Size} is the number of bits required to represent
5477 a value of the given subtype. It is the same as @code{@var{type}'Size},
5478 but, unlike @code{Size}, may be set for non-first subtypes.
5481 @unnumberedsec Wchar_T_Size
5482 @findex Wchar_T_Size
5483 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
5484 prefix) provides the size in bits of the C @code{wchar_t} type
5485 primarily for constructing the definition of this type in
5486 package @code{Interfaces.C}.
5489 @unnumberedsec Word_Size
5491 @code{Standard'Word_Size} (@code{Standard} is the only permissible
5492 prefix) provides the value @code{System.Word_Size}.
5494 @c ------------------------
5495 @node Implementation Advice
5496 @chapter Implementation Advice
5498 The main text of the Ada Reference Manual describes the required
5499 behavior of all Ada compilers, and the GNAT compiler conforms to
5502 In addition, there are sections throughout the Ada Reference Manual headed
5503 by the phrase ``Implementation advice''. These sections are not normative,
5504 i.e., they do not specify requirements that all compilers must
5505 follow. Rather they provide advice on generally desirable behavior. You
5506 may wonder why they are not requirements. The most typical answer is
5507 that they describe behavior that seems generally desirable, but cannot
5508 be provided on all systems, or which may be undesirable on some systems.
5510 As far as practical, GNAT follows the implementation advice sections in
5511 the Ada Reference Manual. This chapter contains a table giving the
5512 reference manual section number, paragraph number and several keywords
5513 for each advice. Each entry consists of the text of the advice followed
5514 by the GNAT interpretation of this advice. Most often, this simply says
5515 ``followed'', which means that GNAT follows the advice. However, in a
5516 number of cases, GNAT deliberately deviates from this advice, in which
5517 case the text describes what GNAT does and why.
5519 @cindex Error detection
5520 @unnumberedsec 1.1.3(20): Error Detection
5523 If an implementation detects the use of an unsupported Specialized Needs
5524 Annex feature at run time, it should raise @code{Program_Error} if
5527 Not relevant. All specialized needs annex features are either supported,
5528 or diagnosed at compile time.
5531 @unnumberedsec 1.1.3(31): Child Units
5534 If an implementation wishes to provide implementation-defined
5535 extensions to the functionality of a language-defined library unit, it
5536 should normally do so by adding children to the library unit.
5540 @cindex Bounded errors
5541 @unnumberedsec 1.1.5(12): Bounded Errors
5544 If an implementation detects a bounded error or erroneous
5545 execution, it should raise @code{Program_Error}.
5547 Followed in all cases in which the implementation detects a bounded
5548 error or erroneous execution. Not all such situations are detected at
5552 @unnumberedsec 2.8(16): Pragmas
5555 Normally, implementation-defined pragmas should have no semantic effect
5556 for error-free programs; that is, if the implementation-defined pragmas
5557 are removed from a working program, the program should still be legal,
5558 and should still have the same semantics.
5560 The following implementation defined pragmas are exceptions to this
5572 @item CPP_Constructor
5576 @item Interface_Name
5578 @item Machine_Attribute
5580 @item Unimplemented_Unit
5582 @item Unchecked_Union
5587 In each of the above cases, it is essential to the purpose of the pragma
5588 that this advice not be followed. For details see the separate section
5589 on implementation defined pragmas.
5591 @unnumberedsec 2.8(17-19): Pragmas
5594 Normally, an implementation should not define pragmas that can
5595 make an illegal program legal, except as follows:
5599 A pragma used to complete a declaration, such as a pragma @code{Import};
5603 A pragma used to configure the environment by adding, removing, or
5604 replacing @code{library_items}.
5606 See response to paragraph 16 of this same section.
5608 @cindex Character Sets
5609 @cindex Alternative Character Sets
5610 @unnumberedsec 3.5.2(5): Alternative Character Sets
5613 If an implementation supports a mode with alternative interpretations
5614 for @code{Character} and @code{Wide_Character}, the set of graphic
5615 characters of @code{Character} should nevertheless remain a proper
5616 subset of the set of graphic characters of @code{Wide_Character}. Any
5617 character set ``localizations'' should be reflected in the results of
5618 the subprograms defined in the language-defined package
5619 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
5620 an alternative interpretation of @code{Character}, the implementation should
5621 also support a corresponding change in what is a legal
5622 @code{identifier_letter}.
5624 Not all wide character modes follow this advice, in particular the JIS
5625 and IEC modes reflect standard usage in Japan, and in these encoding,
5626 the upper half of the Latin-1 set is not part of the wide-character
5627 subset, since the most significant bit is used for wide character
5628 encoding. However, this only applies to the external forms. Internally
5629 there is no such restriction.
5631 @cindex Integer types
5632 @unnumberedsec 3.5.4(28): Integer Types
5636 An implementation should support @code{Long_Integer} in addition to
5637 @code{Integer} if the target machine supports 32-bit (or longer)
5638 arithmetic. No other named integer subtypes are recommended for package
5639 @code{Standard}. Instead, appropriate named integer subtypes should be
5640 provided in the library package @code{Interfaces} (see B.2).
5642 @code{Long_Integer} is supported. Other standard integer types are supported
5643 so this advice is not fully followed. These types
5644 are supported for convenient interface to C, and so that all hardware
5645 types of the machine are easily available.
5646 @unnumberedsec 3.5.4(29): Integer Types
5650 An implementation for a two's complement machine should support
5651 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
5652 implementation should support a non-binary modules up to @code{Integer'Last}.
5656 @cindex Enumeration values
5657 @unnumberedsec 3.5.5(8): Enumeration Values
5660 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5661 subtype, if the value of the operand does not correspond to the internal
5662 code for any enumeration literal of its type (perhaps due to an
5663 un-initialized variable), then the implementation should raise
5664 @code{Program_Error}. This is particularly important for enumeration
5665 types with noncontiguous internal codes specified by an
5666 enumeration_representation_clause.
5671 @unnumberedsec 3.5.7(17): Float Types
5674 An implementation should support @code{Long_Float} in addition to
5675 @code{Float} if the target machine supports 11 or more digits of
5676 precision. No other named floating point subtypes are recommended for
5677 package @code{Standard}. Instead, appropriate named floating point subtypes
5678 should be provided in the library package @code{Interfaces} (see B.2).
5680 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
5681 former provides improved compatibility with other implementations
5682 supporting this type. The latter corresponds to the highest precision
5683 floating-point type supported by the hardware. On most machines, this
5684 will be the same as @code{Long_Float}, but on some machines, it will
5685 correspond to the IEEE extended form. The notable case is all ia32
5686 (x86) implementations, where @code{Long_Long_Float} corresponds to
5687 the 80-bit extended precision format supported in hardware on this
5688 processor. Note that the 128-bit format on SPARC is not supported,
5689 since this is a software rather than a hardware format.
5691 @cindex Multidimensional arrays
5692 @cindex Arrays, multidimensional
5693 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5696 An implementation should normally represent multidimensional arrays in
5697 row-major order, consistent with the notation used for multidimensional
5698 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
5699 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5700 column-major order should be used instead (see B.5, ``Interfacing with
5705 @findex Duration'Small
5706 @unnumberedsec 9.6(30-31): Duration'Small
5709 Whenever possible in an implementation, the value of @code{Duration'Small}
5710 should be no greater than 100 microseconds.
5712 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
5716 The time base for @code{delay_relative_statements} should be monotonic;
5717 it need not be the same time base as used for @code{Calendar.Clock}.
5721 @unnumberedsec 10.2.1(12): Consistent Representation
5724 In an implementation, a type declared in a pre-elaborated package should
5725 have the same representation in every elaboration of a given version of
5726 the package, whether the elaborations occur in distinct executions of
5727 the same program, or in executions of distinct programs or partitions
5728 that include the given version.
5730 Followed, except in the case of tagged types. Tagged types involve
5731 implicit pointers to a local copy of a dispatch table, and these pointers
5732 have representations which thus depend on a particular elaboration of the
5733 package. It is not easy to see how it would be possible to follow this
5734 advice without severely impacting efficiency of execution.
5736 @cindex Exception information
5737 @unnumberedsec 11.4.1(19): Exception Information
5740 @code{Exception_Message} by default and @code{Exception_Information}
5741 should produce information useful for
5742 debugging. @code{Exception_Message} should be short, about one
5743 line. @code{Exception_Information} can be long. @code{Exception_Message}
5744 should not include the
5745 @code{Exception_Name}. @code{Exception_Information} should include both
5746 the @code{Exception_Name} and the @code{Exception_Message}.
5748 Followed. For each exception that doesn't have a specified
5749 @code{Exception_Message}, the compiler generates one containing the location
5750 of the raise statement. This location has the form ``file:line'', where
5751 file is the short file name (without path information) and line is the line
5752 number in the file. Note that in the case of the Zero Cost Exception
5753 mechanism, these messages become redundant with the Exception_Information that
5754 contains a full backtrace of the calling sequence, so they are disabled.
5755 To disable explicitly the generation of the source location message, use the
5756 Pragma @code{Discard_Names}.
5758 @cindex Suppression of checks
5759 @cindex Checks, suppression of
5760 @unnumberedsec 11.5(28): Suppression of Checks
5763 The implementation should minimize the code executed for checks that
5764 have been suppressed.
5768 @cindex Representation clauses
5769 @unnumberedsec 13.1 (21-24): Representation Clauses
5772 The recommended level of support for all representation items is
5773 qualified as follows:
5777 An implementation need not support representation items containing
5778 non-static expressions, except that an implementation should support a
5779 representation item for a given entity if each non-static expression in
5780 the representation item is a name that statically denotes a constant
5781 declared before the entity.
5783 Followed. In fact, GNAT goes beyond the recommended level of support
5784 by allowing nonstatic expressions in some representation clauses even
5785 without the need to declare constants initialized with the values of
5789 @smallexample @c ada
5792 for Y'Address use X'Address;>>
5798 An implementation need not support a specification for the @code{Size}
5799 for a given composite subtype, nor the size or storage place for an
5800 object (including a component) of a given composite subtype, unless the
5801 constraints on the subtype and its composite subcomponents (if any) are
5802 all static constraints.
5804 Followed. Size Clauses are not permitted on non-static components, as
5809 An aliased component, or a component whose type is by-reference, should
5810 always be allocated at an addressable location.
5814 @cindex Packed types
5815 @unnumberedsec 13.2(6-8): Packed Types
5818 If a type is packed, then the implementation should try to minimize
5819 storage allocated to objects of the type, possibly at the expense of
5820 speed of accessing components, subject to reasonable complexity in
5821 addressing calculations.
5825 The recommended level of support pragma @code{Pack} is:
5827 For a packed record type, the components should be packed as tightly as
5828 possible subject to the Sizes of the component subtypes, and subject to
5829 any @code{record_representation_clause} that applies to the type; the
5830 implementation may, but need not, reorder components or cross aligned
5831 word boundaries to improve the packing. A component whose @code{Size} is
5832 greater than the word size may be allocated an integral number of words.
5834 Followed. Tight packing of arrays is supported for all component sizes
5835 up to 64-bits. If the array component size is 1 (that is to say, if
5836 the component is a boolean type or an enumeration type with two values)
5837 then values of the type are implicitly initialized to zero. This
5838 happens both for objects of the packed type, and for objects that have a
5839 subcomponent of the packed type.
5843 An implementation should support Address clauses for imported
5847 @cindex @code{Address} clauses
5848 @unnumberedsec 13.3(14-19): Address Clauses
5852 For an array @var{X}, @code{@var{X}'Address} should point at the first
5853 component of the array, and not at the array bounds.
5859 The recommended level of support for the @code{Address} attribute is:
5861 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5862 object that is aliased or of a by-reference type, or is an entity whose
5863 @code{Address} has been specified.
5865 Followed. A valid address will be produced even if none of those
5866 conditions have been met. If necessary, the object is forced into
5867 memory to ensure the address is valid.
5871 An implementation should support @code{Address} clauses for imported
5878 Objects (including subcomponents) that are aliased or of a by-reference
5879 type should be allocated on storage element boundaries.
5885 If the @code{Address} of an object is specified, or it is imported or exported,
5886 then the implementation should not perform optimizations based on
5887 assumptions of no aliases.
5891 @cindex @code{Alignment} clauses
5892 @unnumberedsec 13.3(29-35): Alignment Clauses
5895 The recommended level of support for the @code{Alignment} attribute for
5898 An implementation should support specified Alignments that are factors
5899 and multiples of the number of storage elements per word, subject to the
5906 An implementation need not support specified @code{Alignment}s for
5907 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5908 loaded and stored by available machine instructions.
5914 An implementation need not support specified @code{Alignment}s that are
5915 greater than the maximum @code{Alignment} the implementation ever returns by
5922 The recommended level of support for the @code{Alignment} attribute for
5925 Same as above, for subtypes, but in addition:
5931 For stand-alone library-level objects of statically constrained
5932 subtypes, the implementation should support all @code{Alignment}s
5933 supported by the target linker. For example, page alignment is likely to
5934 be supported for such objects, but not for subtypes.
5938 @cindex @code{Size} clauses
5939 @unnumberedsec 13.3(42-43): Size Clauses
5942 The recommended level of support for the @code{Size} attribute of
5945 A @code{Size} clause should be supported for an object if the specified
5946 @code{Size} is at least as large as its subtype's @code{Size}, and
5947 corresponds to a size in storage elements that is a multiple of the
5948 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5952 @unnumberedsec 13.3(50-56): Size Clauses
5955 If the @code{Size} of a subtype is specified, and allows for efficient
5956 independent addressability (see 9.10) on the target architecture, then
5957 the @code{Size} of the following objects of the subtype should equal the
5958 @code{Size} of the subtype:
5960 Aliased objects (including components).
5966 @code{Size} clause on a composite subtype should not affect the
5967 internal layout of components.
5969 Followed. But note that this can be overridden by use of the implementation
5970 pragma Implicit_Packing in the case of packed arrays.
5974 The recommended level of support for the @code{Size} attribute of subtypes is:
5978 The @code{Size} (if not specified) of a static discrete or fixed point
5979 subtype should be the number of bits needed to represent each value
5980 belonging to the subtype using an unbiased representation, leaving space
5981 for a sign bit only if the subtype contains negative values. If such a
5982 subtype is a first subtype, then an implementation should support a
5983 specified @code{Size} for it that reflects this representation.
5989 For a subtype implemented with levels of indirection, the @code{Size}
5990 should include the size of the pointers, but not the size of what they
5995 @cindex @code{Component_Size} clauses
5996 @unnumberedsec 13.3(71-73): Component Size Clauses
5999 The recommended level of support for the @code{Component_Size}
6004 An implementation need not support specified @code{Component_Sizes} that are
6005 less than the @code{Size} of the component subtype.
6011 An implementation should support specified @code{Component_Size}s that
6012 are factors and multiples of the word size. For such
6013 @code{Component_Size}s, the array should contain no gaps between
6014 components. For other @code{Component_Size}s (if supported), the array
6015 should contain no gaps between components when packing is also
6016 specified; the implementation should forbid this combination in cases
6017 where it cannot support a no-gaps representation.
6021 @cindex Enumeration representation clauses
6022 @cindex Representation clauses, enumeration
6023 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6026 The recommended level of support for enumeration representation clauses
6029 An implementation need not support enumeration representation clauses
6030 for boolean types, but should at minimum support the internal codes in
6031 the range @code{System.Min_Int.System.Max_Int}.
6035 @cindex Record representation clauses
6036 @cindex Representation clauses, records
6037 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6040 The recommended level of support for
6041 @*@code{record_representation_clauses} is:
6043 An implementation should support storage places that can be extracted
6044 with a load, mask, shift sequence of machine code, and set with a load,
6045 shift, mask, store sequence, given the available machine instructions
6052 A storage place should be supported if its size is equal to the
6053 @code{Size} of the component subtype, and it starts and ends on a
6054 boundary that obeys the @code{Alignment} of the component subtype.
6060 If the default bit ordering applies to the declaration of a given type,
6061 then for a component whose subtype's @code{Size} is less than the word
6062 size, any storage place that does not cross an aligned word boundary
6063 should be supported.
6069 An implementation may reserve a storage place for the tag field of a
6070 tagged type, and disallow other components from overlapping that place.
6072 Followed. The storage place for the tag field is the beginning of the tagged
6073 record, and its size is Address'Size. GNAT will reject an explicit component
6074 clause for the tag field.
6078 An implementation need not support a @code{component_clause} for a
6079 component of an extension part if the storage place is not after the
6080 storage places of all components of the parent type, whether or not
6081 those storage places had been specified.
6083 Followed. The above advice on record representation clauses is followed,
6084 and all mentioned features are implemented.
6086 @cindex Storage place attributes
6087 @unnumberedsec 13.5.2(5): Storage Place Attributes
6090 If a component is represented using some form of pointer (such as an
6091 offset) to the actual data of the component, and this data is contiguous
6092 with the rest of the object, then the storage place attributes should
6093 reflect the place of the actual data, not the pointer. If a component is
6094 allocated discontinuously from the rest of the object, then a warning
6095 should be generated upon reference to one of its storage place
6098 Followed. There are no such components in GNAT@.
6100 @cindex Bit ordering
6101 @unnumberedsec 13.5.3(7-8): Bit Ordering
6104 The recommended level of support for the non-default bit ordering is:
6108 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6109 should support the non-default bit ordering in addition to the default
6112 Followed. Word size does not equal storage size in this implementation.
6113 Thus non-default bit ordering is not supported.
6115 @cindex @code{Address}, as private type
6116 @unnumberedsec 13.7(37): Address as Private
6119 @code{Address} should be of a private type.
6123 @cindex Operations, on @code{Address}
6124 @cindex @code{Address}, operations of
6125 @unnumberedsec 13.7.1(16): Address Operations
6128 Operations in @code{System} and its children should reflect the target
6129 environment semantics as closely as is reasonable. For example, on most
6130 machines, it makes sense for address arithmetic to ``wrap around''.
6131 Operations that do not make sense should raise @code{Program_Error}.
6133 Followed. Address arithmetic is modular arithmetic that wraps around. No
6134 operation raises @code{Program_Error}, since all operations make sense.
6136 @cindex Unchecked conversion
6137 @unnumberedsec 13.9(14-17): Unchecked Conversion
6140 The @code{Size} of an array object should not include its bounds; hence,
6141 the bounds should not be part of the converted data.
6147 The implementation should not generate unnecessary run-time checks to
6148 ensure that the representation of @var{S} is a representation of the
6149 target type. It should take advantage of the permission to return by
6150 reference when possible. Restrictions on unchecked conversions should be
6151 avoided unless required by the target environment.
6153 Followed. There are no restrictions on unchecked conversion. A warning is
6154 generated if the source and target types do not have the same size since
6155 the semantics in this case may be target dependent.
6159 The recommended level of support for unchecked conversions is:
6163 Unchecked conversions should be supported and should be reversible in
6164 the cases where this clause defines the result. To enable meaningful use
6165 of unchecked conversion, a contiguous representation should be used for
6166 elementary subtypes, for statically constrained array subtypes whose
6167 component subtype is one of the subtypes described in this paragraph,
6168 and for record subtypes without discriminants whose component subtypes
6169 are described in this paragraph.
6173 @cindex Heap usage, implicit
6174 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6177 An implementation should document any cases in which it dynamically
6178 allocates heap storage for a purpose other than the evaluation of an
6181 Followed, the only other points at which heap storage is dynamically
6182 allocated are as follows:
6186 At initial elaboration time, to allocate dynamically sized global
6190 To allocate space for a task when a task is created.
6193 To extend the secondary stack dynamically when needed. The secondary
6194 stack is used for returning variable length results.
6199 A default (implementation-provided) storage pool for an
6200 access-to-constant type should not have overhead to support deallocation of
6207 A storage pool for an anonymous access type should be created at the
6208 point of an allocator for the type, and be reclaimed when the designated
6209 object becomes inaccessible.
6213 @cindex Unchecked deallocation
6214 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6217 For a standard storage pool, @code{Free} should actually reclaim the
6222 @cindex Stream oriented attributes
6223 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6226 If a stream element is the same size as a storage element, then the
6227 normal in-memory representation should be used by @code{Read} and
6228 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
6229 should use the smallest number of stream elements needed to represent
6230 all values in the base range of the scalar type.
6233 Followed. By default, GNAT uses the interpretation suggested by AI-195,
6234 which specifies using the size of the first subtype.
6235 However, such an implementation is based on direct binary
6236 representations and is therefore target- and endianness-dependent.
6237 To address this issue, GNAT also supplies an alternate implementation
6238 of the stream attributes @code{Read} and @code{Write},
6239 which uses the target-independent XDR standard representation
6241 @cindex XDR representation
6242 @cindex @code{Read} attribute
6243 @cindex @code{Write} attribute
6244 @cindex Stream oriented attributes
6245 The XDR implementation is provided as an alternative body of the
6246 @code{System.Stream_Attributes} package, in the file
6247 @file{s-strxdr.adb} in the GNAT library.
6248 There is no @file{s-strxdr.ads} file.
6249 In order to install the XDR implementation, do the following:
6251 @item Replace the default implementation of the
6252 @code{System.Stream_Attributes} package with the XDR implementation.
6253 For example on a Unix platform issue the commands:
6255 $ mv s-stratt.adb s-strold.adb
6256 $ mv s-strxdr.adb s-stratt.adb
6260 Rebuild the GNAT run-time library as documented in the
6261 @cite{GNAT User's Guide}
6264 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6267 If an implementation provides additional named predefined integer types,
6268 then the names should end with @samp{Integer} as in
6269 @samp{Long_Integer}. If an implementation provides additional named
6270 predefined floating point types, then the names should end with
6271 @samp{Float} as in @samp{Long_Float}.
6275 @findex Ada.Characters.Handling
6276 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6279 If an implementation provides a localized definition of @code{Character}
6280 or @code{Wide_Character}, then the effects of the subprograms in
6281 @code{Characters.Handling} should reflect the localizations. See also
6284 Followed. GNAT provides no such localized definitions.
6286 @cindex Bounded-length strings
6287 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6290 Bounded string objects should not be implemented by implicit pointers
6291 and dynamic allocation.
6293 Followed. No implicit pointers or dynamic allocation are used.
6295 @cindex Random number generation
6296 @unnumberedsec A.5.2(46-47): Random Number Generation
6299 Any storage associated with an object of type @code{Generator} should be
6300 reclaimed on exit from the scope of the object.
6306 If the generator period is sufficiently long in relation to the number
6307 of distinct initiator values, then each possible value of
6308 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6309 random numbers that does not, in a practical sense, overlap the sequence
6310 initiated by any other value. If this is not possible, then the mapping
6311 between initiator values and generator states should be a rapidly
6312 varying function of the initiator value.
6314 Followed. The generator period is sufficiently long for the first
6315 condition here to hold true.
6317 @findex Get_Immediate
6318 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6321 The @code{Get_Immediate} procedures should be implemented with
6322 unbuffered input. For a device such as a keyboard, input should be
6323 @dfn{available} if a key has already been typed, whereas for a disk
6324 file, input should always be available except at end of file. For a file
6325 associated with a keyboard-like device, any line-editing features of the
6326 underlying operating system should be disabled during the execution of
6327 @code{Get_Immediate}.
6329 Followed on all targets except VxWorks. For VxWorks, there is no way to
6330 provide this functionality that does not result in the input buffer being
6331 flushed before the @code{Get_Immediate} call. A special unit
6332 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6336 @unnumberedsec B.1(39-41): Pragma @code{Export}
6339 If an implementation supports pragma @code{Export} to a given language,
6340 then it should also allow the main subprogram to be written in that
6341 language. It should support some mechanism for invoking the elaboration
6342 of the Ada library units included in the system, and for invoking the
6343 finalization of the environment task. On typical systems, the
6344 recommended mechanism is to provide two subprograms whose link names are
6345 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
6346 elaboration code for library units. @code{adafinal} should contain the
6347 finalization code. These subprograms should have no effect the second
6348 and subsequent time they are called.
6354 Automatic elaboration of pre-elaborated packages should be
6355 provided when pragma @code{Export} is supported.
6357 Followed when the main program is in Ada. If the main program is in a
6358 foreign language, then
6359 @code{adainit} must be called to elaborate pre-elaborated
6364 For each supported convention @var{L} other than @code{Intrinsic}, an
6365 implementation should support @code{Import} and @code{Export} pragmas
6366 for objects of @var{L}-compatible types and for subprograms, and pragma
6367 @code{Convention} for @var{L}-eligible types and for subprograms,
6368 presuming the other language has corresponding features. Pragma
6369 @code{Convention} need not be supported for scalar types.
6373 @cindex Package @code{Interfaces}
6375 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6378 For each implementation-defined convention identifier, there should be a
6379 child package of package Interfaces with the corresponding name. This
6380 package should contain any declarations that would be useful for
6381 interfacing to the language (implementation) represented by the
6382 convention. Any declarations useful for interfacing to any language on
6383 the given hardware architecture should be provided directly in
6386 Followed. An additional package not defined
6387 in the Ada Reference Manual is @code{Interfaces.CPP}, used
6388 for interfacing to C++.
6392 An implementation supporting an interface to C, COBOL, or Fortran should
6393 provide the corresponding package or packages described in the following
6396 Followed. GNAT provides all the packages described in this section.
6398 @cindex C, interfacing with
6399 @unnumberedsec B.3(63-71): Interfacing with C
6402 An implementation should support the following interface correspondences
6409 An Ada procedure corresponds to a void-returning C function.
6415 An Ada function corresponds to a non-void C function.
6421 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
6428 An Ada @code{in} parameter of an access-to-object type with designated
6429 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
6430 where @var{t} is the C type corresponding to the Ada type @var{T}.
6436 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
6437 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
6438 argument to a C function, where @var{t} is the C type corresponding to
6439 the Ada type @var{T}. In the case of an elementary @code{out} or
6440 @code{in out} parameter, a pointer to a temporary copy is used to
6441 preserve by-copy semantics.
6447 An Ada parameter of a record type @var{T}, of any mode, is passed as a
6448 @code{@var{t}*} argument to a C function, where @var{t} is the C
6449 structure corresponding to the Ada type @var{T}.
6451 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
6452 pragma, or Convention, or by explicitly specifying the mechanism for a given
6453 call using an extended import or export pragma.
6457 An Ada parameter of an array type with component type @var{T}, of any
6458 mode, is passed as a @code{@var{t}*} argument to a C function, where
6459 @var{t} is the C type corresponding to the Ada type @var{T}.
6465 An Ada parameter of an access-to-subprogram type is passed as a pointer
6466 to a C function whose prototype corresponds to the designated
6467 subprogram's specification.
6471 @cindex COBOL, interfacing with
6472 @unnumberedsec B.4(95-98): Interfacing with COBOL
6475 An Ada implementation should support the following interface
6476 correspondences between Ada and COBOL@.
6482 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
6483 the COBOL type corresponding to @var{T}.
6489 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
6490 the corresponding COBOL type.
6496 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
6497 COBOL type corresponding to the Ada parameter type; for scalars, a local
6498 copy is used if necessary to ensure by-copy semantics.
6502 @cindex Fortran, interfacing with
6503 @unnumberedsec B.5(22-26): Interfacing with Fortran
6506 An Ada implementation should support the following interface
6507 correspondences between Ada and Fortran:
6513 An Ada procedure corresponds to a Fortran subroutine.
6519 An Ada function corresponds to a Fortran function.
6525 An Ada parameter of an elementary, array, or record type @var{T} is
6526 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
6527 the Fortran type corresponding to the Ada type @var{T}, and where the
6528 INTENT attribute of the corresponding dummy argument matches the Ada
6529 formal parameter mode; the Fortran implementation's parameter passing
6530 conventions are used. For elementary types, a local copy is used if
6531 necessary to ensure by-copy semantics.
6537 An Ada parameter of an access-to-subprogram type is passed as a
6538 reference to a Fortran procedure whose interface corresponds to the
6539 designated subprogram's specification.
6543 @cindex Machine operations
6544 @unnumberedsec C.1(3-5): Access to Machine Operations
6547 The machine code or intrinsic support should allow access to all
6548 operations normally available to assembly language programmers for the
6549 target environment, including privileged instructions, if any.
6555 The interfacing pragmas (see Annex B) should support interface to
6556 assembler; the default assembler should be associated with the
6557 convention identifier @code{Assembler}.
6563 If an entity is exported to assembly language, then the implementation
6564 should allocate it at an addressable location, and should ensure that it
6565 is retained by the linking process, even if not otherwise referenced
6566 from the Ada code. The implementation should assume that any call to a
6567 machine code or assembler subprogram is allowed to read or update every
6568 object that is specified as exported.
6572 @unnumberedsec C.1(10-16): Access to Machine Operations
6575 The implementation should ensure that little or no overhead is
6576 associated with calling intrinsic and machine-code subprograms.
6578 Followed for both intrinsics and machine-code subprograms.
6582 It is recommended that intrinsic subprograms be provided for convenient
6583 access to any machine operations that provide special capabilities or
6584 efficiency and that are not otherwise available through the language
6587 Followed. A full set of machine operation intrinsic subprograms is provided.
6591 Atomic read-modify-write operations---e.g.@:, test and set, compare and
6592 swap, decrement and test, enqueue/dequeue.
6594 Followed on any target supporting such operations.
6598 Standard numeric functions---e.g.@:, sin, log.
6600 Followed on any target supporting such operations.
6604 String manipulation operations---e.g.@:, translate and test.
6606 Followed on any target supporting such operations.
6610 Vector operations---e.g.@:, compare vector against thresholds.
6612 Followed on any target supporting such operations.
6616 Direct operations on I/O ports.
6618 Followed on any target supporting such operations.
6620 @cindex Interrupt support
6621 @unnumberedsec C.3(28): Interrupt Support
6624 If the @code{Ceiling_Locking} policy is not in effect, the
6625 implementation should provide means for the application to specify which
6626 interrupts are to be blocked during protected actions, if the underlying
6627 system allows for a finer-grain control of interrupt blocking.
6629 Followed. The underlying system does not allow for finer-grain control
6630 of interrupt blocking.
6632 @cindex Protected procedure handlers
6633 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6636 Whenever possible, the implementation should allow interrupt handlers to
6637 be called directly by the hardware.
6641 This is never possible under IRIX, so this is followed by default.
6643 Followed on any target where the underlying operating system permits
6648 Whenever practical, violations of any
6649 implementation-defined restrictions should be detected before run time.
6651 Followed. Compile time warnings are given when possible.
6653 @cindex Package @code{Interrupts}
6655 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6659 If implementation-defined forms of interrupt handler procedures are
6660 supported, such as protected procedures with parameters, then for each
6661 such form of a handler, a type analogous to @code{Parameterless_Handler}
6662 should be specified in a child package of @code{Interrupts}, with the
6663 same operations as in the predefined package Interrupts.
6667 @cindex Pre-elaboration requirements
6668 @unnumberedsec C.4(14): Pre-elaboration Requirements
6671 It is recommended that pre-elaborated packages be implemented in such a
6672 way that there should be little or no code executed at run time for the
6673 elaboration of entities not already covered by the Implementation
6676 Followed. Executable code is generated in some cases, e.g.@: loops
6677 to initialize large arrays.
6679 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6683 If the pragma applies to an entity, then the implementation should
6684 reduce the amount of storage used for storing names associated with that
6689 @cindex Package @code{Task_Attributes}
6690 @findex Task_Attributes
6691 @unnumberedsec C.7.2(30): The Package Task_Attributes
6694 Some implementations are targeted to domains in which memory use at run
6695 time must be completely deterministic. For such implementations, it is
6696 recommended that the storage for task attributes will be pre-allocated
6697 statically and not from the heap. This can be accomplished by either
6698 placing restrictions on the number and the size of the task's
6699 attributes, or by using the pre-allocated storage for the first @var{N}
6700 attribute objects, and the heap for the others. In the latter case,
6701 @var{N} should be documented.
6703 Not followed. This implementation is not targeted to such a domain.
6705 @cindex Locking Policies
6706 @unnumberedsec D.3(17): Locking Policies
6710 The implementation should use names that end with @samp{_Locking} for
6711 locking policies defined by the implementation.
6713 Followed. A single implementation-defined locking policy is defined,
6714 whose name (@code{Inheritance_Locking}) follows this suggestion.
6716 @cindex Entry queuing policies
6717 @unnumberedsec D.4(16): Entry Queuing Policies
6720 Names that end with @samp{_Queuing} should be used
6721 for all implementation-defined queuing policies.
6723 Followed. No such implementation-defined queuing policies exist.
6725 @cindex Preemptive abort
6726 @unnumberedsec D.6(9-10): Preemptive Abort
6729 Even though the @code{abort_statement} is included in the list of
6730 potentially blocking operations (see 9.5.1), it is recommended that this
6731 statement be implemented in a way that never requires the task executing
6732 the @code{abort_statement} to block.
6738 On a multi-processor, the delay associated with aborting a task on
6739 another processor should be bounded; the implementation should use
6740 periodic polling, if necessary, to achieve this.
6744 @cindex Tasking restrictions
6745 @unnumberedsec D.7(21): Tasking Restrictions
6748 When feasible, the implementation should take advantage of the specified
6749 restrictions to produce a more efficient implementation.
6751 GNAT currently takes advantage of these restrictions by providing an optimized
6752 run time when the Ravenscar profile and the GNAT restricted run time set
6753 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
6754 pragma @code{Profile (Restricted)} for more details.
6756 @cindex Time, monotonic
6757 @unnumberedsec D.8(47-49): Monotonic Time
6760 When appropriate, implementations should provide configuration
6761 mechanisms to change the value of @code{Tick}.
6763 Such configuration mechanisms are not appropriate to this implementation
6764 and are thus not supported.
6768 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6769 be implemented as transformations of the same time base.
6775 It is recommended that the @dfn{best} time base which exists in
6776 the underlying system be available to the application through
6777 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
6781 @cindex Partition communication subsystem
6783 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6786 Whenever possible, the PCS on the called partition should allow for
6787 multiple tasks to call the RPC-receiver with different messages and
6788 should allow them to block until the corresponding subprogram body
6791 Followed by GLADE, a separately supplied PCS that can be used with
6796 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6797 should raise @code{Storage_Error} if it runs out of space trying to
6798 write the @code{Item} into the stream.
6800 Followed by GLADE, a separately supplied PCS that can be used with
6803 @cindex COBOL support
6804 @unnumberedsec F(7): COBOL Support
6807 If COBOL (respectively, C) is widely supported in the target
6808 environment, implementations supporting the Information Systems Annex
6809 should provide the child package @code{Interfaces.COBOL} (respectively,
6810 @code{Interfaces.C}) specified in Annex B and should support a
6811 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6812 pragmas (see Annex B), thus allowing Ada programs to interface with
6813 programs written in that language.
6817 @cindex Decimal radix support
6818 @unnumberedsec F.1(2): Decimal Radix Support
6821 Packed decimal should be used as the internal representation for objects
6822 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6824 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
6828 @unnumberedsec G: Numerics
6831 If Fortran (respectively, C) is widely supported in the target
6832 environment, implementations supporting the Numerics Annex
6833 should provide the child package @code{Interfaces.Fortran} (respectively,
6834 @code{Interfaces.C}) specified in Annex B and should support a
6835 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6836 pragmas (see Annex B), thus allowing Ada programs to interface with
6837 programs written in that language.
6841 @cindex Complex types
6842 @unnumberedsec G.1.1(56-58): Complex Types
6845 Because the usual mathematical meaning of multiplication of a complex
6846 operand and a real operand is that of the scaling of both components of
6847 the former by the latter, an implementation should not perform this
6848 operation by first promoting the real operand to complex type and then
6849 performing a full complex multiplication. In systems that, in the
6850 future, support an Ada binding to IEC 559:1989, the latter technique
6851 will not generate the required result when one of the components of the
6852 complex operand is infinite. (Explicit multiplication of the infinite
6853 component by the zero component obtained during promotion yields a NaN
6854 that propagates into the final result.) Analogous advice applies in the
6855 case of multiplication of a complex operand and a pure-imaginary
6856 operand, and in the case of division of a complex operand by a real or
6857 pure-imaginary operand.
6863 Similarly, because the usual mathematical meaning of addition of a
6864 complex operand and a real operand is that the imaginary operand remains
6865 unchanged, an implementation should not perform this operation by first
6866 promoting the real operand to complex type and then performing a full
6867 complex addition. In implementations in which the @code{Signed_Zeros}
6868 attribute of the component type is @code{True} (and which therefore
6869 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6870 predefined arithmetic operations), the latter technique will not
6871 generate the required result when the imaginary component of the complex
6872 operand is a negatively signed zero. (Explicit addition of the negative
6873 zero to the zero obtained during promotion yields a positive zero.)
6874 Analogous advice applies in the case of addition of a complex operand
6875 and a pure-imaginary operand, and in the case of subtraction of a
6876 complex operand and a real or pure-imaginary operand.
6882 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6883 attempt to provide a rational treatment of the signs of zero results and
6884 result components. As one example, the result of the @code{Argument}
6885 function should have the sign of the imaginary component of the
6886 parameter @code{X} when the point represented by that parameter lies on
6887 the positive real axis; as another, the sign of the imaginary component
6888 of the @code{Compose_From_Polar} function should be the same as
6889 (respectively, the opposite of) that of the @code{Argument} parameter when that
6890 parameter has a value of zero and the @code{Modulus} parameter has a
6891 nonnegative (respectively, negative) value.
6895 @cindex Complex elementary functions
6896 @unnumberedsec G.1.2(49): Complex Elementary Functions
6899 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6900 @code{True} should attempt to provide a rational treatment of the signs
6901 of zero results and result components. For example, many of the complex
6902 elementary functions have components that are odd functions of one of
6903 the parameter components; in these cases, the result component should
6904 have the sign of the parameter component at the origin. Other complex
6905 elementary functions have zero components whose sign is opposite that of
6906 a parameter component at the origin, or is always positive or always
6911 @cindex Accuracy requirements
6912 @unnumberedsec G.2.4(19): Accuracy Requirements
6915 The versions of the forward trigonometric functions without a
6916 @code{Cycle} parameter should not be implemented by calling the
6917 corresponding version with a @code{Cycle} parameter of
6918 @code{2.0*Numerics.Pi}, since this will not provide the required
6919 accuracy in some portions of the domain. For the same reason, the
6920 version of @code{Log} without a @code{Base} parameter should not be
6921 implemented by calling the corresponding version with a @code{Base}
6922 parameter of @code{Numerics.e}.
6926 @cindex Complex arithmetic accuracy
6927 @cindex Accuracy, complex arithmetic
6928 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6932 The version of the @code{Compose_From_Polar} function without a
6933 @code{Cycle} parameter should not be implemented by calling the
6934 corresponding version with a @code{Cycle} parameter of
6935 @code{2.0*Numerics.Pi}, since this will not provide the required
6936 accuracy in some portions of the domain.
6940 @c -----------------------------------------
6941 @node Implementation Defined Characteristics
6942 @chapter Implementation Defined Characteristics
6945 In addition to the implementation dependent pragmas and attributes, and
6946 the implementation advice, there are a number of other Ada features
6947 that are potentially implementation dependent. These are mentioned
6948 throughout the Ada Reference Manual, and are summarized in annex M@.
6950 A requirement for conforming Ada compilers is that they provide
6951 documentation describing how the implementation deals with each of these
6952 issues. In this chapter, you will find each point in annex M listed
6953 followed by a description in italic font of how GNAT
6957 implementation on IRIX 5.3 operating system or greater
6959 handles the implementation dependence.
6961 You can use this chapter as a guide to minimizing implementation
6962 dependent features in your programs if portability to other compilers
6963 and other operating systems is an important consideration. The numbers
6964 in each section below correspond to the paragraph number in the Ada
6970 @strong{2}. Whether or not each recommendation given in Implementation
6971 Advice is followed. See 1.1.2(37).
6974 @xref{Implementation Advice}.
6979 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
6982 The complexity of programs that can be processed is limited only by the
6983 total amount of available virtual memory, and disk space for the
6984 generated object files.
6989 @strong{4}. Variations from the standard that are impractical to avoid
6990 given the implementation's execution environment. See 1.1.3(6).
6993 There are no variations from the standard.
6998 @strong{5}. Which @code{code_statement}s cause external
6999 interactions. See 1.1.3(10).
7002 Any @code{code_statement} can potentially cause external interactions.
7007 @strong{6}. The coded representation for the text of an Ada
7008 program. See 2.1(4).
7011 See separate section on source representation.
7016 @strong{7}. The control functions allowed in comments. See 2.1(14).
7019 See separate section on source representation.
7024 @strong{8}. The representation for an end of line. See 2.2(2).
7027 See separate section on source representation.
7032 @strong{9}. Maximum supported line length and lexical element
7033 length. See 2.2(15).
7036 The maximum line length is 255 characters an the maximum length of a
7037 lexical element is also 255 characters.
7042 @strong{10}. Implementation defined pragmas. See 2.8(14).
7046 @xref{Implementation Defined Pragmas}.
7051 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
7054 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7055 parameter, checks that the optimization flag is set, and aborts if it is
7061 @strong{12}. The sequence of characters of the value returned by
7062 @code{@var{S}'Image} when some of the graphic characters of
7063 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
7067 The sequence of characters is as defined by the wide character encoding
7068 method used for the source. See section on source representation for
7074 @strong{13}. The predefined integer types declared in
7075 @code{Standard}. See 3.5.4(25).
7079 @item Short_Short_Integer
7082 (Short) 16 bit signed
7086 64 bit signed (Alpha OpenVMS only)
7087 32 bit signed (all other targets)
7088 @item Long_Long_Integer
7095 @strong{14}. Any nonstandard integer types and the operators defined
7096 for them. See 3.5.4(26).
7099 There are no nonstandard integer types.
7104 @strong{15}. Any nonstandard real types and the operators defined for
7108 There are no nonstandard real types.
7113 @strong{16}. What combinations of requested decimal precision and range
7114 are supported for floating point types. See 3.5.7(7).
7117 The precision and range is as defined by the IEEE standard.
7122 @strong{17}. The predefined floating point types declared in
7123 @code{Standard}. See 3.5.7(16).
7130 (Short) 32 bit IEEE short
7133 @item Long_Long_Float
7134 64 bit IEEE long (80 bit IEEE long on x86 processors)
7140 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
7143 @code{Fine_Delta} is 2**(@minus{}63)
7148 @strong{19}. What combinations of small, range, and digits are
7149 supported for fixed point types. See 3.5.9(10).
7152 Any combinations are permitted that do not result in a small less than
7153 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7154 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7155 is 64 bits (true of all architectures except ia32), then the output from
7156 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
7157 is because floating-point conversions are used to convert fixed point.
7162 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
7163 within an unnamed @code{block_statement}. See 3.9(10).
7166 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7167 decimal integer are allocated.
7172 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
7175 @xref{Implementation Defined Attributes}.
7180 @strong{22}. Any implementation-defined time types. See 9.6(6).
7183 There are no implementation-defined time types.
7188 @strong{23}. The time base associated with relative delays.
7191 See 9.6(20). The time base used is that provided by the C library
7192 function @code{gettimeofday}.
7197 @strong{24}. The time base of the type @code{Calendar.Time}. See
7201 The time base used is that provided by the C library function
7202 @code{gettimeofday}.
7207 @strong{25}. The time zone used for package @code{Calendar}
7208 operations. See 9.6(24).
7211 The time zone used by package @code{Calendar} is the current system time zone
7212 setting for local time, as accessed by the C library function
7218 @strong{26}. Any limit on @code{delay_until_statements} of
7219 @code{select_statements}. See 9.6(29).
7222 There are no such limits.
7227 @strong{27}. Whether or not two non overlapping parts of a composite
7228 object are independently addressable, in the case where packing, record
7229 layout, or @code{Component_Size} is specified for the object. See
7233 Separate components are independently addressable if they do not share
7234 overlapping storage units.
7239 @strong{28}. The representation for a compilation. See 10.1(2).
7242 A compilation is represented by a sequence of files presented to the
7243 compiler in a single invocation of the @code{gcc} command.
7248 @strong{29}. Any restrictions on compilations that contain multiple
7249 compilation_units. See 10.1(4).
7252 No single file can contain more than one compilation unit, but any
7253 sequence of files can be presented to the compiler as a single
7259 @strong{30}. The mechanisms for creating an environment and for adding
7260 and replacing compilation units. See 10.1.4(3).
7263 See separate section on compilation model.
7268 @strong{31}. The manner of explicitly assigning library units to a
7269 partition. See 10.2(2).
7272 If a unit contains an Ada main program, then the Ada units for the partition
7273 are determined by recursive application of the rules in the Ada Reference
7274 Manual section 10.2(2-6). In other words, the Ada units will be those that
7275 are needed by the main program, and then this definition of need is applied
7276 recursively to those units, and the partition contains the transitive
7277 closure determined by this relationship. In short, all the necessary units
7278 are included, with no need to explicitly specify the list. If additional
7279 units are required, e.g.@: by foreign language units, then all units must be
7280 mentioned in the context clause of one of the needed Ada units.
7282 If the partition contains no main program, or if the main program is in
7283 a language other than Ada, then GNAT
7284 provides the binder options @code{-z} and @code{-n} respectively, and in
7285 this case a list of units can be explicitly supplied to the binder for
7286 inclusion in the partition (all units needed by these units will also
7287 be included automatically). For full details on the use of these
7288 options, refer to the @cite{GNAT User's Guide} sections on Binding
7294 @strong{32}. The implementation-defined means, if any, of specifying
7295 which compilation units are needed by a given compilation unit. See
7299 The units needed by a given compilation unit are as defined in
7300 the Ada Reference Manual section 10.2(2-6). There are no
7301 implementation-defined pragmas or other implementation-defined
7302 means for specifying needed units.
7307 @strong{33}. The manner of designating the main subprogram of a
7308 partition. See 10.2(7).
7311 The main program is designated by providing the name of the
7312 corresponding @file{ALI} file as the input parameter to the binder.
7317 @strong{34}. The order of elaboration of @code{library_items}. See
7321 The first constraint on ordering is that it meets the requirements of
7322 Chapter 10 of the Ada Reference Manual. This still leaves some
7323 implementation dependent choices, which are resolved by first
7324 elaborating bodies as early as possible (i.e., in preference to specs
7325 where there is a choice), and second by evaluating the immediate with
7326 clauses of a unit to determine the probably best choice, and
7327 third by elaborating in alphabetical order of unit names
7328 where a choice still remains.
7333 @strong{35}. Parameter passing and function return for the main
7334 subprogram. See 10.2(21).
7337 The main program has no parameters. It may be a procedure, or a function
7338 returning an integer type. In the latter case, the returned integer
7339 value is the return code of the program (overriding any value that
7340 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7345 @strong{36}. The mechanisms for building and running partitions. See
7349 GNAT itself supports programs with only a single partition. The GNATDIST
7350 tool provided with the GLADE package (which also includes an implementation
7351 of the PCS) provides a completely flexible method for building and running
7352 programs consisting of multiple partitions. See the separate GLADE manual
7358 @strong{37}. The details of program execution, including program
7359 termination. See 10.2(25).
7362 See separate section on compilation model.
7367 @strong{38}. The semantics of any non-active partitions supported by the
7368 implementation. See 10.2(28).
7371 Passive partitions are supported on targets where shared memory is
7372 provided by the operating system. See the GLADE reference manual for
7378 @strong{39}. The information returned by @code{Exception_Message}. See
7382 Exception message returns the null string unless a specific message has
7383 been passed by the program.
7388 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
7389 declared within an unnamed @code{block_statement}. See 11.4.1(12).
7392 Blocks have implementation defined names of the form @code{B@var{nnn}}
7393 where @var{nnn} is an integer.
7398 @strong{41}. The information returned by
7399 @code{Exception_Information}. See 11.4.1(13).
7402 @code{Exception_Information} returns a string in the following format:
7405 @emph{Exception_Name:} nnnnn
7406 @emph{Message:} mmmmm
7408 @emph{Call stack traceback locations:}
7409 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
7417 @code{nnnn} is the fully qualified name of the exception in all upper
7418 case letters. This line is always present.
7421 @code{mmmm} is the message (this line present only if message is non-null)
7424 @code{ppp} is the Process Id value as a decimal integer (this line is
7425 present only if the Process Id is nonzero). Currently we are
7426 not making use of this field.
7429 The Call stack traceback locations line and the following values
7430 are present only if at least one traceback location was recorded.
7431 The values are given in C style format, with lower case letters
7432 for a-f, and only as many digits present as are necessary.
7436 The line terminator sequence at the end of each line, including
7437 the last line is a single @code{LF} character (@code{16#0A#}).
7442 @strong{42}. Implementation-defined check names. See 11.5(27).
7445 The implementation defined check name Alignment_Check controls checking of
7446 address clause values for proper alignment (that is, the address supplied
7447 must be consistent with the alignment of the type).
7449 In addition, a user program can add implementation-defined check names
7450 by means of the pragma Check_Name.
7455 @strong{43}. The interpretation of each aspect of representation. See
7459 See separate section on data representations.
7464 @strong{44}. Any restrictions placed upon representation items. See
7468 See separate section on data representations.
7473 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
7477 Size for an indefinite subtype is the maximum possible size, except that
7478 for the case of a subprogram parameter, the size of the parameter object
7484 @strong{46}. The default external representation for a type tag. See
7488 The default external representation for a type tag is the fully expanded
7489 name of the type in upper case letters.
7494 @strong{47}. What determines whether a compilation unit is the same in
7495 two different partitions. See 13.3(76).
7498 A compilation unit is the same in two different partitions if and only
7499 if it derives from the same source file.
7504 @strong{48}. Implementation-defined components. See 13.5.1(15).
7507 The only implementation defined component is the tag for a tagged type,
7508 which contains a pointer to the dispatching table.
7513 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
7514 ordering. See 13.5.3(5).
7517 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
7518 implementation, so no non-default bit ordering is supported. The default
7519 bit ordering corresponds to the natural endianness of the target architecture.
7524 @strong{50}. The contents of the visible part of package @code{System}
7525 and its language-defined children. See 13.7(2).
7528 See the definition of these packages in files @file{system.ads} and
7529 @file{s-stoele.ads}.
7534 @strong{51}. The contents of the visible part of package
7535 @code{System.Machine_Code}, and the meaning of
7536 @code{code_statements}. See 13.8(7).
7539 See the definition and documentation in file @file{s-maccod.ads}.
7544 @strong{52}. The effect of unchecked conversion. See 13.9(11).
7547 Unchecked conversion between types of the same size
7548 results in an uninterpreted transmission of the bits from one type
7549 to the other. If the types are of unequal sizes, then in the case of
7550 discrete types, a shorter source is first zero or sign extended as
7551 necessary, and a shorter target is simply truncated on the left.
7552 For all non-discrete types, the source is first copied if necessary
7553 to ensure that the alignment requirements of the target are met, then
7554 a pointer is constructed to the source value, and the result is obtained
7555 by dereferencing this pointer after converting it to be a pointer to the
7556 target type. Unchecked conversions where the target subtype is an
7557 unconstrained array are not permitted. If the target alignment is
7558 greater than the source alignment, then a copy of the result is
7559 made with appropriate alignment
7564 @strong{53}. The manner of choosing a storage pool for an access type
7565 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
7568 There are 3 different standard pools used by the compiler when
7569 @code{Storage_Pool} is not specified depending whether the type is local
7570 to a subprogram or defined at the library level and whether
7571 @code{Storage_Size}is specified or not. See documentation in the runtime
7572 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
7573 @code{System.Pool_Local} in files @file{s-poosiz.ads},
7574 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
7580 @strong{54}. Whether or not the implementation provides user-accessible
7581 names for the standard pool type(s). See 13.11(17).
7585 See documentation in the sources of the run time mentioned in paragraph
7586 @strong{53} . All these pools are accessible by means of @code{with}'ing
7592 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
7595 @code{Storage_Size} is measured in storage units, and refers to the
7596 total space available for an access type collection, or to the primary
7597 stack space for a task.
7602 @strong{56}. Implementation-defined aspects of storage pools. See
7606 See documentation in the sources of the run time mentioned in paragraph
7607 @strong{53} for details on GNAT-defined aspects of storage pools.
7612 @strong{57}. The set of restrictions allowed in a pragma
7613 @code{Restrictions}. See 13.12(7).
7616 All RM defined Restriction identifiers are implemented. The following
7617 additional restriction identifiers are provided. There are two separate
7618 lists of implementation dependent restriction identifiers. The first
7619 set requires consistency throughout a partition (in other words, if the
7620 restriction identifier is used for any compilation unit in the partition,
7621 then all compilation units in the partition must obey the restriction.
7625 @item Simple_Barriers
7626 @findex Simple_Barriers
7627 This restriction ensures at compile time that barriers in entry declarations
7628 for protected types are restricted to either static boolean expressions or
7629 references to simple boolean variables defined in the private part of the
7630 protected type. No other form of entry barriers is permitted. This is one
7631 of the restrictions of the Ravenscar profile for limited tasking (see also
7632 pragma @code{Profile (Ravenscar)}).
7634 @item Max_Entry_Queue_Length => Expr
7635 @findex Max_Entry_Queue_Length
7636 This restriction is a declaration that any protected entry compiled in
7637 the scope of the restriction has at most the specified number of
7638 tasks waiting on the entry
7639 at any one time, and so no queue is required. This restriction is not
7640 checked at compile time. A program execution is erroneous if an attempt
7641 is made to queue more than the specified number of tasks on such an entry.
7645 This restriction ensures at compile time that there is no implicit or
7646 explicit dependence on the package @code{Ada.Calendar}.
7648 @item No_Direct_Boolean_Operators
7649 @findex No_Direct_Boolean_Operators
7650 This restriction ensures that no logical (and/or/xor) or comparison
7651 operators are used on operands of type Boolean (or any type derived
7652 from Boolean). This is intended for use in safety critical programs
7653 where the certification protocol requires the use of short-circuit
7654 (and then, or else) forms for all composite boolean operations.
7656 @item No_Dispatching_Calls
7657 @findex No_Dispatching_Calls
7658 This restriction ensures at compile time that the code generated by the
7659 compiler involves no dispatching calls. The use of this restriction allows the
7660 safe use of record extensions, classwide membership tests and other classwide
7661 features not involving implicit dispatching. This restriction ensures that
7662 the code contains no indirect calls through a dispatching mechanism. Note that
7663 this includes internally-generated calls created by the compiler, for example
7664 in the implementation of class-wide objects assignments. The
7665 membership test is allowed in the presence of this restriction, because its
7666 implementation requires no dispatching.
7667 This restriction is comparable to the official Ada restriction
7668 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7669 all classwide constructs that do not imply dispatching.
7670 The following example indicates constructs that violate this restriction.
7674 type T is tagged record
7677 procedure P (X : T);
7679 type DT is new T with record
7680 More_Data : Natural;
7682 procedure Q (X : DT);
7686 procedure Example is
7687 procedure Test (O : T'Class) is
7688 N : Natural := O'Size;-- Error: Dispatching call
7689 C : T'Class := O; -- Error: implicit Dispatching Call
7691 if O in DT'Class then -- OK : Membership test
7692 Q (DT (O)); -- OK : Type conversion plus direct call
7694 P (O); -- Error: Dispatching call
7700 P (Obj); -- OK : Direct call
7701 P (T (Obj)); -- OK : Type conversion plus direct call
7702 P (T'Class (Obj)); -- Error: Dispatching call
7704 Test (Obj); -- OK : Type conversion
7706 if Obj in T'Class then -- OK : Membership test
7712 @item No_Dynamic_Attachment
7713 @findex No_Dynamic_Attachment
7714 This restriction ensures that there is no call to any of the operations
7715 defined in package Ada.Interrupts.
7717 @item No_Enumeration_Maps
7718 @findex No_Enumeration_Maps
7719 This restriction ensures at compile time that no operations requiring
7720 enumeration maps are used (that is Image and Value attributes applied
7721 to enumeration types).
7723 @item No_Entry_Calls_In_Elaboration_Code
7724 @findex No_Entry_Calls_In_Elaboration_Code
7725 This restriction ensures at compile time that no task or protected entry
7726 calls are made during elaboration code. As a result of the use of this
7727 restriction, the compiler can assume that no code past an accept statement
7728 in a task can be executed at elaboration time.
7730 @item No_Exception_Handlers
7731 @findex No_Exception_Handlers
7732 This restriction ensures at compile time that there are no explicit
7733 exception handlers. It also indicates that no exception propagation will
7734 be provided. In this mode, exceptions may be raised but will result in
7735 an immediate call to the last chance handler, a routine that the user
7736 must define with the following profile:
7738 procedure Last_Chance_Handler
7739 (Source_Location : System.Address; Line : Integer);
7740 pragma Export (C, Last_Chance_Handler,
7741 "__gnat_last_chance_handler");
7743 The parameter is a C null-terminated string representing a message to be
7744 associated with the exception (typically the source location of the raise
7745 statement generated by the compiler). The Line parameter when nonzero
7746 represents the line number in the source program where the raise occurs.
7748 @item No_Exception_Propagation
7749 @findex No_Exception_Propagation
7750 This restriction guarantees that exceptions are never propagated to an outer
7751 subprogram scope). The only case in which an exception may be raised is when
7752 the handler is statically in the same subprogram, so that the effect of a raise
7753 is essentially like a goto statement. Any other raise statement (implicit or
7754 explicit) will be considered unhandled. Exception handlers are allowed, but may
7755 not contain an exception occurrence identifier (exception choice). In addition
7756 use of the package GNAT.Current_Exception is not permitted, and reraise
7757 statements (raise with no operand) are not permitted.
7759 @item No_Exception_Registration
7760 @findex No_Exception_Registration
7761 This restriction ensures at compile time that no stream operations for
7762 types Exception_Id or Exception_Occurrence are used. This also makes it
7763 impossible to pass exceptions to or from a partition with this restriction
7764 in a distributed environment. If this exception is active, then the generated
7765 code is simplified by omitting the otherwise-required global registration
7766 of exceptions when they are declared.
7768 @item No_Implicit_Conditionals
7769 @findex No_Implicit_Conditionals
7770 This restriction ensures that the generated code does not contain any
7771 implicit conditionals, either by modifying the generated code where possible,
7772 or by rejecting any construct that would otherwise generate an implicit
7773 conditional. Note that this check does not include run time constraint
7774 checks, which on some targets may generate implicit conditionals as
7775 well. To control the latter, constraint checks can be suppressed in the
7776 normal manner. Constructs generating implicit conditionals include comparisons
7777 of composite objects and the Max/Min attributes.
7779 @item No_Implicit_Dynamic_Code
7780 @findex No_Implicit_Dynamic_Code
7781 This restriction prevents the compiler from building ``trampolines''.
7782 This is a structure that is built on the stack and contains dynamic
7783 code to be executed at run time. On some targets, a trampoline is
7784 built for the following features: @code{Access},
7785 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
7786 nested task bodies; primitive operations of nested tagged types.
7787 Trampolines do not work on machines that prevent execution of stack
7788 data. For example, on windows systems, enabling DEP (data execution
7789 protection) will cause trampolines to raise an exception.
7791 @item No_Implicit_Loops
7792 @findex No_Implicit_Loops
7793 This restriction ensures that the generated code does not contain any
7794 implicit @code{for} loops, either by modifying
7795 the generated code where possible,
7796 or by rejecting any construct that would otherwise generate an implicit
7797 @code{for} loop. If this restriction is active, it is possible to build
7798 large array aggregates with all static components without generating an
7799 intermediate temporary, and without generating a loop to initialize individual
7800 components..Otherwise, a loop is created for arrays larger than about 5000
7803 @item No_Initialize_Scalars
7804 @findex No_Initialize_Scalars
7805 This restriction ensures that no unit in the partition is compiled with
7806 pragma Initialize_Scalars. This allows the generation of more efficient
7807 code, and in particular eliminates dummy null initialization routines that
7808 are otherwise generated for some record and array types.
7810 @item No_Local_Protected_Objects
7811 @findex No_Local_Protected_Objects
7812 This restriction ensures at compile time that protected objects are
7813 only declared at the library level.
7815 @item No_Protected_Type_Allocators
7816 @findex No_Protected_Type_Allocators
7817 This restriction ensures at compile time that there are no allocator
7818 expressions that attempt to allocate protected objects.
7820 @item No_Secondary_Stack
7821 @findex No_Secondary_Stack
7822 This restriction ensures at compile time that the generated code does not
7823 contain any reference to the secondary stack. The secondary stack is used
7824 to implement functions returning unconstrained objects (arrays or records)
7827 @item No_Select_Statements
7828 @findex No_Select_Statements
7829 This restriction ensures at compile time no select statements of any kind
7830 are permitted, that is the keyword @code{select} may not appear.
7831 This is one of the restrictions of the Ravenscar
7832 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7834 @item No_Standard_Storage_Pools
7835 @findex No_Standard_Storage_Pools
7836 This restriction ensures at compile time that no access types
7837 use the standard default storage pool. Any access type declared must
7838 have an explicit Storage_Pool attribute defined specifying a
7839 user-defined storage pool.
7843 This restriction ensures at compile/bind time that there are no
7844 stream objects created (and therefore no actual stream operations).
7845 This restriction does not forbid dependences on the package
7846 @code{Ada.Streams}. So it is permissible to with
7847 @code{Ada.Streams} (or another package that does so itself)
7848 as long as no actual stream objects are created.
7850 @item No_Task_Attributes_Package
7851 @findex No_Task_Attributes_Package
7852 This restriction ensures at compile time that there are no implicit or
7853 explicit dependencies on the package @code{Ada.Task_Attributes}.
7855 @item No_Task_Termination
7856 @findex No_Task_Termination
7857 This restriction ensures at compile time that no terminate alternatives
7858 appear in any task body.
7862 This restriction prevents the declaration of tasks or task types throughout
7863 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
7864 except that violations are caught at compile time and cause an error message
7865 to be output either by the compiler or binder.
7867 @item Static_Priorities
7868 @findex Static_Priorities
7869 This restriction ensures at compile time that all priority expressions
7870 are static, and that there are no dependencies on the package
7871 @code{Ada.Dynamic_Priorities}.
7873 @item Static_Storage_Size
7874 @findex Static_Storage_Size
7875 This restriction ensures at compile time that any expression appearing
7876 in a Storage_Size pragma or attribute definition clause is static.
7881 The second set of implementation dependent restriction identifiers
7882 does not require partition-wide consistency.
7883 The restriction may be enforced for a single
7884 compilation unit without any effect on any of the
7885 other compilation units in the partition.
7889 @item No_Elaboration_Code
7890 @findex No_Elaboration_Code
7891 This restriction ensures at compile time that no elaboration code is
7892 generated. Note that this is not the same condition as is enforced
7893 by pragma @code{Preelaborate}. There are cases in which pragma
7894 @code{Preelaborate} still permits code to be generated (e.g.@: code
7895 to initialize a large array to all zeroes), and there are cases of units
7896 which do not meet the requirements for pragma @code{Preelaborate},
7897 but for which no elaboration code is generated. Generally, it is
7898 the case that preelaborable units will meet the restrictions, with
7899 the exception of large aggregates initialized with an others_clause,
7900 and exception declarations (which generate calls to a run-time
7901 registry procedure). This restriction is enforced on
7902 a unit by unit basis, it need not be obeyed consistently
7903 throughout a partition.
7905 In the case of aggregates with others, if the aggregate has a dynamic
7906 size, there is no way to eliminate the elaboration code (such dynamic
7907 bounds would be incompatible with @code{Preelaborate} in any case). If
7908 the bounds are static, then use of this restriction actually modifies
7909 the code choice of the compiler to avoid generating a loop, and instead
7910 generate the aggregate statically if possible, no matter how many times
7911 the data for the others clause must be repeatedly generated.
7913 It is not possible to precisely document
7914 the constructs which are compatible with this restriction, since,
7915 unlike most other restrictions, this is not a restriction on the
7916 source code, but a restriction on the generated object code. For
7917 example, if the source contains a declaration:
7920 Val : constant Integer := X;
7924 where X is not a static constant, it may be possible, depending
7925 on complex optimization circuitry, for the compiler to figure
7926 out the value of X at compile time, in which case this initialization
7927 can be done by the loader, and requires no initialization code. It
7928 is not possible to document the precise conditions under which the
7929 optimizer can figure this out.
7931 Note that this the implementation of this restriction requires full
7932 code generation. If it is used in conjunction with "semantics only"
7933 checking, then some cases of violations may be missed.
7935 @item No_Entry_Queue
7936 @findex No_Entry_Queue
7937 This restriction is a declaration that any protected entry compiled in
7938 the scope of the restriction has at most one task waiting on the entry
7939 at any one time, and so no queue is required. This restriction is not
7940 checked at compile time. A program execution is erroneous if an attempt
7941 is made to queue a second task on such an entry.
7943 @item No_Implementation_Attributes
7944 @findex No_Implementation_Attributes
7945 This restriction checks at compile time that no GNAT-defined attributes
7946 are present. With this restriction, the only attributes that can be used
7947 are those defined in the Ada Reference Manual.
7949 @item No_Implementation_Pragmas
7950 @findex No_Implementation_Pragmas
7951 This restriction checks at compile time that no GNAT-defined pragmas
7952 are present. With this restriction, the only pragmas that can be used
7953 are those defined in the Ada Reference Manual.
7955 @item No_Implementation_Restrictions
7956 @findex No_Implementation_Restrictions
7957 This restriction checks at compile time that no GNAT-defined restriction
7958 identifiers (other than @code{No_Implementation_Restrictions} itself)
7959 are present. With this restriction, the only other restriction identifiers
7960 that can be used are those defined in the Ada Reference Manual.
7962 @item No_Wide_Characters
7963 @findex No_Wide_Characters
7964 This restriction ensures at compile time that no uses of the types
7965 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7967 appear, and that no wide or wide wide string or character literals
7968 appear in the program (that is literals representing characters not in
7969 type @code{Character}.
7976 @strong{58}. The consequences of violating limitations on
7977 @code{Restrictions} pragmas. See 13.12(9).
7980 Restrictions that can be checked at compile time result in illegalities
7981 if violated. Currently there are no other consequences of violating
7987 @strong{59}. The representation used by the @code{Read} and
7988 @code{Write} attributes of elementary types in terms of stream
7989 elements. See 13.13.2(9).
7992 The representation is the in-memory representation of the base type of
7993 the type, using the number of bits corresponding to the
7994 @code{@var{type}'Size} value, and the natural ordering of the machine.
7999 @strong{60}. The names and characteristics of the numeric subtypes
8000 declared in the visible part of package @code{Standard}. See A.1(3).
8003 See items describing the integer and floating-point types supported.
8008 @strong{61}. The accuracy actually achieved by the elementary
8009 functions. See A.5.1(1).
8012 The elementary functions correspond to the functions available in the C
8013 library. Only fast math mode is implemented.
8018 @strong{62}. The sign of a zero result from some of the operators or
8019 functions in @code{Numerics.Generic_Elementary_Functions}, when
8020 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
8023 The sign of zeroes follows the requirements of the IEEE 754 standard on
8029 @strong{63}. The value of
8030 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
8033 Maximum image width is 649, see library file @file{a-numran.ads}.
8038 @strong{64}. The value of
8039 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
8042 Maximum image width is 80, see library file @file{a-nudira.ads}.
8047 @strong{65}. The algorithms for random number generation. See
8051 The algorithm is documented in the source files @file{a-numran.ads} and
8052 @file{a-numran.adb}.
8057 @strong{66}. The string representation of a random number generator's
8058 state. See A.5.2(38).
8061 See the documentation contained in the file @file{a-numran.adb}.
8066 @strong{67}. The minimum time interval between calls to the
8067 time-dependent Reset procedure that are guaranteed to initiate different
8068 random number sequences. See A.5.2(45).
8071 The minimum period between reset calls to guarantee distinct series of
8072 random numbers is one microsecond.
8077 @strong{68}. The values of the @code{Model_Mantissa},
8078 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8079 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8080 Annex is not supported. See A.5.3(72).
8083 See the source file @file{ttypef.ads} for the values of all numeric
8089 @strong{69}. Any implementation-defined characteristics of the
8090 input-output packages. See A.7(14).
8093 There are no special implementation defined characteristics for these
8099 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
8103 All type representations are contiguous, and the @code{Buffer_Size} is
8104 the value of @code{@var{type}'Size} rounded up to the next storage unit
8110 @strong{71}. External files for standard input, standard output, and
8111 standard error See A.10(5).
8114 These files are mapped onto the files provided by the C streams
8115 libraries. See source file @file{i-cstrea.ads} for further details.
8120 @strong{72}. The accuracy of the value produced by @code{Put}. See
8124 If more digits are requested in the output than are represented by the
8125 precision of the value, zeroes are output in the corresponding least
8126 significant digit positions.
8131 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
8132 @code{Command_Name}. See A.15(1).
8135 These are mapped onto the @code{argv} and @code{argc} parameters of the
8136 main program in the natural manner.
8141 @strong{74}. Implementation-defined convention names. See B.1(11).
8144 The following convention names are supported
8152 Synonym for Assembler
8154 Synonym for Assembler
8157 @item C_Pass_By_Copy
8158 Allowed only for record types, like C, but also notes that record
8159 is to be passed by copy rather than reference.
8162 @item C_Plus_Plus (or CPP)
8165 Treated the same as C
8167 Treated the same as C
8171 For support of pragma @code{Import} with convention Intrinsic, see
8172 separate section on Intrinsic Subprograms.
8174 Stdcall (used for Windows implementations only). This convention correspond
8175 to the WINAPI (previously called Pascal convention) C/C++ convention under
8176 Windows. A function with this convention cleans the stack before exit.
8182 Stubbed is a special convention used to indicate that the body of the
8183 subprogram will be entirely ignored. Any call to the subprogram
8184 is converted into a raise of the @code{Program_Error} exception. If a
8185 pragma @code{Import} specifies convention @code{stubbed} then no body need
8186 be present at all. This convention is useful during development for the
8187 inclusion of subprograms whose body has not yet been written.
8191 In addition, all otherwise unrecognized convention names are also
8192 treated as being synonymous with convention C@. In all implementations
8193 except for VMS, use of such other names results in a warning. In VMS
8194 implementations, these names are accepted silently.
8199 @strong{75}. The meaning of link names. See B.1(36).
8202 Link names are the actual names used by the linker.
8207 @strong{76}. The manner of choosing link names when neither the link
8208 name nor the address of an imported or exported entity is specified. See
8212 The default linker name is that which would be assigned by the relevant
8213 external language, interpreting the Ada name as being in all lower case
8219 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
8222 The string passed to @code{Linker_Options} is presented uninterpreted as
8223 an argument to the link command, unless it contains Ascii.NUL characters.
8224 NUL characters if they appear act as argument separators, so for example
8226 @smallexample @c ada
8227 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
8231 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8232 linker. The order of linker options is preserved for a given unit. The final
8233 list of options passed to the linker is in reverse order of the elaboration
8234 order. For example, linker options fo a body always appear before the options
8235 from the corresponding package spec.
8240 @strong{78}. The contents of the visible part of package
8241 @code{Interfaces} and its language-defined descendants. See B.2(1).
8244 See files with prefix @file{i-} in the distributed library.
8249 @strong{79}. Implementation-defined children of package
8250 @code{Interfaces}. The contents of the visible part of package
8251 @code{Interfaces}. See B.2(11).
8254 See files with prefix @file{i-} in the distributed library.
8259 @strong{80}. The types @code{Floating}, @code{Long_Floating},
8260 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8261 @code{COBOL_Character}; and the initialization of the variables
8262 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8263 @code{Interfaces.COBOL}. See B.4(50).
8270 (Floating) Long_Float
8275 @item Decimal_Element
8277 @item COBOL_Character
8282 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8287 @strong{81}. Support for access to machine instructions. See C.1(1).
8290 See documentation in file @file{s-maccod.ads} in the distributed library.
8295 @strong{82}. Implementation-defined aspects of access to machine
8296 operations. See C.1(9).
8299 See documentation in file @file{s-maccod.ads} in the distributed library.
8304 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
8307 Interrupts are mapped to signals or conditions as appropriate. See
8309 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8310 on the interrupts supported on a particular target.
8315 @strong{84}. Implementation-defined aspects of pre-elaboration. See
8319 GNAT does not permit a partition to be restarted without reloading,
8320 except under control of the debugger.
8325 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
8328 Pragma @code{Discard_Names} causes names of enumeration literals to
8329 be suppressed. In the presence of this pragma, the Image attribute
8330 provides the image of the Pos of the literal, and Value accepts
8336 @strong{86}. The result of the @code{Task_Identification.Image}
8337 attribute. See C.7.1(7).
8340 The result of this attribute is a string that identifies
8341 the object or component that denotes a given task. If a variable Var has a task
8342 type, the image for this task will have the form Var_XXXXXXXX, where the
8344 is the hexadecimal representation of the virtual address of the corresponding
8345 task control block. If the variable is an array of tasks, the image of each
8346 task will have the form of an indexed component indicating the position of a
8347 given task in the array, eg. Group(5)_XXXXXXX. If the task is a
8348 component of a record, the image of the task will have the form of a selected
8349 component. These rules are fully recursive, so that the image of a task that
8350 is a subcomponent of a composite object corresponds to the expression that
8351 designates this task.
8353 If a task is created by an allocator, its image depends on the context. If the
8354 allocator is part of an object declaration, the rules described above are used
8355 to construct its image, and this image is not affected by subsequent
8356 assignments. If the allocator appears within an expression, the image
8357 includes only the name of the task type.
8359 If the configuration pragma Discard_Names is present, or if the restriction
8360 No_Implicit_Heap_Allocation is in effect, the image reduces to
8361 the numeric suffix, that is to say the hexadecimal representation of the
8362 virtual address of the control block of the task.
8366 @strong{87}. The value of @code{Current_Task} when in a protected entry
8367 or interrupt handler. See C.7.1(17).
8370 Protected entries or interrupt handlers can be executed by any
8371 convenient thread, so the value of @code{Current_Task} is undefined.
8376 @strong{88}. The effect of calling @code{Current_Task} from an entry
8377 body or interrupt handler. See C.7.1(19).
8380 The effect of calling @code{Current_Task} from an entry body or
8381 interrupt handler is to return the identification of the task currently
8387 @strong{89}. Implementation-defined aspects of
8388 @code{Task_Attributes}. See C.7.2(19).
8391 There are no implementation-defined aspects of @code{Task_Attributes}.
8396 @strong{90}. Values of all @code{Metrics}. See D(2).
8399 The metrics information for GNAT depends on the performance of the
8400 underlying operating system. The sources of the run-time for tasking
8401 implementation, together with the output from @code{-gnatG} can be
8402 used to determine the exact sequence of operating systems calls made
8403 to implement various tasking constructs. Together with appropriate
8404 information on the performance of the underlying operating system,
8405 on the exact target in use, this information can be used to determine
8406 the required metrics.
8411 @strong{91}. The declarations of @code{Any_Priority} and
8412 @code{Priority}. See D.1(11).
8415 See declarations in file @file{system.ads}.
8420 @strong{92}. Implementation-defined execution resources. See D.1(15).
8423 There are no implementation-defined execution resources.
8428 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
8429 access to a protected object keeps its processor busy. See D.2.1(3).
8432 On a multi-processor, a task that is waiting for access to a protected
8433 object does not keep its processor busy.
8438 @strong{94}. The affect of implementation defined execution resources
8439 on task dispatching. See D.2.1(9).
8444 Tasks map to IRIX threads, and the dispatching policy is as defined by
8445 the IRIX implementation of threads.
8447 Tasks map to threads in the threads package used by GNAT@. Where possible
8448 and appropriate, these threads correspond to native threads of the
8449 underlying operating system.
8454 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
8455 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
8458 There are no implementation-defined policy-identifiers allowed in this
8464 @strong{96}. Implementation-defined aspects of priority inversion. See
8468 Execution of a task cannot be preempted by the implementation processing
8469 of delay expirations for lower priority tasks.
8474 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
8479 Tasks map to IRIX threads, and the dispatching policy is as defined by
8480 the IRIX implementation of threads.
8482 The policy is the same as that of the underlying threads implementation.
8487 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
8488 in a pragma @code{Locking_Policy}. See D.3(4).
8491 The only implementation defined policy permitted in GNAT is
8492 @code{Inheritance_Locking}. On targets that support this policy, locking
8493 is implemented by inheritance, i.e.@: the task owning the lock operates
8494 at a priority equal to the highest priority of any task currently
8495 requesting the lock.
8500 @strong{99}. Default ceiling priorities. See D.3(10).
8503 The ceiling priority of protected objects of the type
8504 @code{System.Interrupt_Priority'Last} as described in the Ada
8505 Reference Manual D.3(10),
8510 @strong{100}. The ceiling of any protected object used internally by
8511 the implementation. See D.3(16).
8514 The ceiling priority of internal protected objects is
8515 @code{System.Priority'Last}.
8520 @strong{101}. Implementation-defined queuing policies. See D.4(1).
8523 There are no implementation-defined queuing policies.
8528 @strong{102}. On a multiprocessor, any conditions that cause the
8529 completion of an aborted construct to be delayed later than what is
8530 specified for a single processor. See D.6(3).
8533 The semantics for abort on a multi-processor is the same as on a single
8534 processor, there are no further delays.
8539 @strong{103}. Any operations that implicitly require heap storage
8540 allocation. See D.7(8).
8543 The only operation that implicitly requires heap storage allocation is
8549 @strong{104}. Implementation-defined aspects of pragma
8550 @code{Restrictions}. See D.7(20).
8553 There are no such implementation-defined aspects.
8558 @strong{105}. Implementation-defined aspects of package
8559 @code{Real_Time}. See D.8(17).
8562 There are no implementation defined aspects of package @code{Real_Time}.
8567 @strong{106}. Implementation-defined aspects of
8568 @code{delay_statements}. See D.9(8).
8571 Any difference greater than one microsecond will cause the task to be
8572 delayed (see D.9(7)).
8577 @strong{107}. The upper bound on the duration of interrupt blocking
8578 caused by the implementation. See D.12(5).
8581 The upper bound is determined by the underlying operating system. In
8582 no cases is it more than 10 milliseconds.
8587 @strong{108}. The means for creating and executing distributed
8591 The GLADE package provides a utility GNATDIST for creating and executing
8592 distributed programs. See the GLADE reference manual for further details.
8597 @strong{109}. Any events that can result in a partition becoming
8598 inaccessible. See E.1(7).
8601 See the GLADE reference manual for full details on such events.
8606 @strong{110}. The scheduling policies, treatment of priorities, and
8607 management of shared resources between partitions in certain cases. See
8611 See the GLADE reference manual for full details on these aspects of
8612 multi-partition execution.
8617 @strong{111}. Events that cause the version of a compilation unit to
8621 Editing the source file of a compilation unit, or the source files of
8622 any units on which it is dependent in a significant way cause the version
8623 to change. No other actions cause the version number to change. All changes
8624 are significant except those which affect only layout, capitalization or
8630 @strong{112}. Whether the execution of the remote subprogram is
8631 immediately aborted as a result of cancellation. See E.4(13).
8634 See the GLADE reference manual for details on the effect of abort in
8635 a distributed application.
8640 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
8643 See the GLADE reference manual for a full description of all implementation
8644 defined aspects of the PCS@.
8649 @strong{114}. Implementation-defined interfaces in the PCS@. See
8653 See the GLADE reference manual for a full description of all
8654 implementation defined interfaces.
8659 @strong{115}. The values of named numbers in the package
8660 @code{Decimal}. See F.2(7).
8672 @item Max_Decimal_Digits
8679 @strong{116}. The value of @code{Max_Picture_Length} in the package
8680 @code{Text_IO.Editing}. See F.3.3(16).
8688 @strong{117}. The value of @code{Max_Picture_Length} in the package
8689 @code{Wide_Text_IO.Editing}. See F.3.4(5).
8697 @strong{118}. The accuracy actually achieved by the complex elementary
8698 functions and by other complex arithmetic operations. See G.1(1).
8701 Standard library functions are used for the complex arithmetic
8702 operations. Only fast math mode is currently supported.
8707 @strong{119}. The sign of a zero result (or a component thereof) from
8708 any operator or function in @code{Numerics.Generic_Complex_Types}, when
8709 @code{Real'Signed_Zeros} is True. See G.1.1(53).
8712 The signs of zero values are as recommended by the relevant
8713 implementation advice.
8718 @strong{120}. The sign of a zero result (or a component thereof) from
8719 any operator or function in
8720 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8721 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
8724 The signs of zero values are as recommended by the relevant
8725 implementation advice.
8730 @strong{121}. Whether the strict mode or the relaxed mode is the
8731 default. See G.2(2).
8734 The strict mode is the default. There is no separate relaxed mode. GNAT
8735 provides a highly efficient implementation of strict mode.
8740 @strong{122}. The result interval in certain cases of fixed-to-float
8741 conversion. See G.2.1(10).
8744 For cases where the result interval is implementation dependent, the
8745 accuracy is that provided by performing all operations in 64-bit IEEE
8746 floating-point format.
8751 @strong{123}. The result of a floating point arithmetic operation in
8752 overflow situations, when the @code{Machine_Overflows} attribute of the
8753 result type is @code{False}. See G.2.1(13).
8756 Infinite and NaN values are produced as dictated by the IEEE
8757 floating-point standard.
8759 Note that on machines that are not fully compliant with the IEEE
8760 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
8761 must be used for achieving IEEE confirming behavior (although at the cost
8762 of a significant performance penalty), so infinite and NaN values are
8768 @strong{124}. The result interval for division (or exponentiation by a
8769 negative exponent), when the floating point hardware implements division
8770 as multiplication by a reciprocal. See G.2.1(16).
8773 Not relevant, division is IEEE exact.
8778 @strong{125}. The definition of close result set, which determines the
8779 accuracy of certain fixed point multiplications and divisions. See
8783 Operations in the close result set are performed using IEEE long format
8784 floating-point arithmetic. The input operands are converted to
8785 floating-point, the operation is done in floating-point, and the result
8786 is converted to the target type.
8791 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
8792 point multiplication or division for which the result shall be in the
8793 perfect result set. See G.2.3(22).
8796 The result is only defined to be in the perfect result set if the result
8797 can be computed by a single scaling operation involving a scale factor
8798 representable in 64-bits.
8803 @strong{127}. The result of a fixed point arithmetic operation in
8804 overflow situations, when the @code{Machine_Overflows} attribute of the
8805 result type is @code{False}. See G.2.3(27).
8808 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8814 @strong{128}. The result of an elementary function reference in
8815 overflow situations, when the @code{Machine_Overflows} attribute of the
8816 result type is @code{False}. See G.2.4(4).
8819 IEEE infinite and Nan values are produced as appropriate.
8824 @strong{129}. The value of the angle threshold, within which certain
8825 elementary functions, complex arithmetic operations, and complex
8826 elementary functions yield results conforming to a maximum relative
8827 error bound. See G.2.4(10).
8830 Information on this subject is not yet available.
8835 @strong{130}. The accuracy of certain elementary functions for
8836 parameters beyond the angle threshold. See G.2.4(10).
8839 Information on this subject is not yet available.
8844 @strong{131}. The result of a complex arithmetic operation or complex
8845 elementary function reference in overflow situations, when the
8846 @code{Machine_Overflows} attribute of the corresponding real type is
8847 @code{False}. See G.2.6(5).
8850 IEEE infinite and Nan values are produced as appropriate.
8855 @strong{132}. The accuracy of certain complex arithmetic operations and
8856 certain complex elementary functions for parameters (or components
8857 thereof) beyond the angle threshold. See G.2.6(8).
8860 Information on those subjects is not yet available.
8865 @strong{133}. Information regarding bounded errors and erroneous
8866 execution. See H.2(1).
8869 Information on this subject is not yet available.
8874 @strong{134}. Implementation-defined aspects of pragma
8875 @code{Inspection_Point}. See H.3.2(8).
8878 Pragma @code{Inspection_Point} ensures that the variable is live and can
8879 be examined by the debugger at the inspection point.
8884 @strong{135}. Implementation-defined aspects of pragma
8885 @code{Restrictions}. See H.4(25).
8888 There are no implementation-defined aspects of pragma @code{Restrictions}. The
8889 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8890 generated code. Checks must suppressed by use of pragma @code{Suppress}.
8895 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
8899 There are no restrictions on pragma @code{Restrictions}.
8901 @node Intrinsic Subprograms
8902 @chapter Intrinsic Subprograms
8903 @cindex Intrinsic Subprograms
8906 * Intrinsic Operators::
8907 * Enclosing_Entity::
8908 * Exception_Information::
8909 * Exception_Message::
8917 * Shift_Right_Arithmetic::
8922 GNAT allows a user application program to write the declaration:
8924 @smallexample @c ada
8925 pragma Import (Intrinsic, name);
8929 providing that the name corresponds to one of the implemented intrinsic
8930 subprograms in GNAT, and that the parameter profile of the referenced
8931 subprogram meets the requirements. This chapter describes the set of
8932 implemented intrinsic subprograms, and the requirements on parameter profiles.
8933 Note that no body is supplied; as with other uses of pragma Import, the
8934 body is supplied elsewhere (in this case by the compiler itself). Note
8935 that any use of this feature is potentially non-portable, since the
8936 Ada standard does not require Ada compilers to implement this feature.
8938 @node Intrinsic Operators
8939 @section Intrinsic Operators
8940 @cindex Intrinsic operator
8943 All the predefined numeric operators in package Standard
8944 in @code{pragma Import (Intrinsic,..)}
8945 declarations. In the binary operator case, the operands must have the same
8946 size. The operand or operands must also be appropriate for
8947 the operator. For example, for addition, the operands must
8948 both be floating-point or both be fixed-point, and the
8949 right operand for @code{"**"} must have a root type of
8950 @code{Standard.Integer'Base}.
8951 You can use an intrinsic operator declaration as in the following example:
8953 @smallexample @c ada
8954 type Int1 is new Integer;
8955 type Int2 is new Integer;
8957 function "+" (X1 : Int1; X2 : Int2) return Int1;
8958 function "+" (X1 : Int1; X2 : Int2) return Int2;
8959 pragma Import (Intrinsic, "+");
8963 This declaration would permit ``mixed mode'' arithmetic on items
8964 of the differing types @code{Int1} and @code{Int2}.
8965 It is also possible to specify such operators for private types, if the
8966 full views are appropriate arithmetic types.
8968 @node Enclosing_Entity
8969 @section Enclosing_Entity
8970 @cindex Enclosing_Entity
8972 This intrinsic subprogram is used in the implementation of the
8973 library routine @code{GNAT.Source_Info}. The only useful use of the
8974 intrinsic import in this case is the one in this unit, so an
8975 application program should simply call the function
8976 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8977 the current subprogram, package, task, entry, or protected subprogram.
8979 @node Exception_Information
8980 @section Exception_Information
8981 @cindex Exception_Information'
8983 This intrinsic subprogram is used in the implementation of the
8984 library routine @code{GNAT.Current_Exception}. The only useful
8985 use of the intrinsic import in this case is the one in this unit,
8986 so an application program should simply call the function
8987 @code{GNAT.Current_Exception.Exception_Information} to obtain
8988 the exception information associated with the current exception.
8990 @node Exception_Message
8991 @section Exception_Message
8992 @cindex Exception_Message
8994 This intrinsic subprogram is used in the implementation of the
8995 library routine @code{GNAT.Current_Exception}. The only useful
8996 use of the intrinsic import in this case is the one in this unit,
8997 so an application program should simply call the function
8998 @code{GNAT.Current_Exception.Exception_Message} to obtain
8999 the message associated with the current exception.
9001 @node Exception_Name
9002 @section Exception_Name
9003 @cindex Exception_Name
9005 This intrinsic subprogram is used in the implementation of the
9006 library routine @code{GNAT.Current_Exception}. The only useful
9007 use of the intrinsic import in this case is the one in this unit,
9008 so an application program should simply call the function
9009 @code{GNAT.Current_Exception.Exception_Name} to obtain
9010 the name of the current exception.
9016 This intrinsic subprogram is used in the implementation of the
9017 library routine @code{GNAT.Source_Info}. The only useful use of the
9018 intrinsic import in this case is the one in this unit, so an
9019 application program should simply call the function
9020 @code{GNAT.Source_Info.File} to obtain the name of the current
9027 This intrinsic subprogram is used in the implementation of the
9028 library routine @code{GNAT.Source_Info}. The only useful use of the
9029 intrinsic import in this case is the one in this unit, so an
9030 application program should simply call the function
9031 @code{GNAT.Source_Info.Line} to obtain the number of the current
9035 @section Rotate_Left
9038 In standard Ada, the @code{Rotate_Left} function is available only
9039 for the predefined modular types in package @code{Interfaces}. However, in
9040 GNAT it is possible to define a Rotate_Left function for a user
9041 defined modular type or any signed integer type as in this example:
9043 @smallexample @c ada
9045 (Value : My_Modular_Type;
9047 return My_Modular_Type;
9051 The requirements are that the profile be exactly as in the example
9052 above. The only modifications allowed are in the formal parameter
9053 names, and in the type of @code{Value} and the return type, which
9054 must be the same, and must be either a signed integer type, or
9055 a modular integer type with a binary modulus, and the size must
9056 be 8. 16, 32 or 64 bits.
9059 @section Rotate_Right
9060 @cindex Rotate_Right
9062 A @code{Rotate_Right} function can be defined for any user defined
9063 binary modular integer type, or signed integer type, as described
9064 above for @code{Rotate_Left}.
9070 A @code{Shift_Left} function can be defined for any user defined
9071 binary modular integer type, or signed integer type, as described
9072 above for @code{Rotate_Left}.
9075 @section Shift_Right
9078 A @code{Shift_Right} function can be defined for any user defined
9079 binary modular integer type, or signed integer type, as described
9080 above for @code{Rotate_Left}.
9082 @node Shift_Right_Arithmetic
9083 @section Shift_Right_Arithmetic
9084 @cindex Shift_Right_Arithmetic
9086 A @code{Shift_Right_Arithmetic} function can be defined for any user
9087 defined binary modular integer type, or signed integer type, as described
9088 above for @code{Rotate_Left}.
9090 @node Source_Location
9091 @section Source_Location
9092 @cindex Source_Location
9094 This intrinsic subprogram is used in the implementation of the
9095 library routine @code{GNAT.Source_Info}. The only useful use of the
9096 intrinsic import in this case is the one in this unit, so an
9097 application program should simply call the function
9098 @code{GNAT.Source_Info.Source_Location} to obtain the current
9099 source file location.
9101 @node Representation Clauses and Pragmas
9102 @chapter Representation Clauses and Pragmas
9103 @cindex Representation Clauses
9106 * Alignment Clauses::
9108 * Storage_Size Clauses::
9109 * Size of Variant Record Objects::
9110 * Biased Representation ::
9111 * Value_Size and Object_Size Clauses::
9112 * Component_Size Clauses::
9113 * Bit_Order Clauses::
9114 * Effect of Bit_Order on Byte Ordering::
9115 * Pragma Pack for Arrays::
9116 * Pragma Pack for Records::
9117 * Record Representation Clauses::
9118 * Enumeration Clauses::
9120 * Effect of Convention on Representation::
9121 * Determining the Representations chosen by GNAT::
9125 @cindex Representation Clause
9126 @cindex Representation Pragma
9127 @cindex Pragma, representation
9128 This section describes the representation clauses accepted by GNAT, and
9129 their effect on the representation of corresponding data objects.
9131 GNAT fully implements Annex C (Systems Programming). This means that all
9132 the implementation advice sections in chapter 13 are fully implemented.
9133 However, these sections only require a minimal level of support for
9134 representation clauses. GNAT provides much more extensive capabilities,
9135 and this section describes the additional capabilities provided.
9137 @node Alignment Clauses
9138 @section Alignment Clauses
9139 @cindex Alignment Clause
9142 GNAT requires that all alignment clauses specify a power of 2, and all
9143 default alignments are always a power of 2. The default alignment
9144 values are as follows:
9147 @item @emph{Primitive Types}.
9148 For primitive types, the alignment is the minimum of the actual size of
9149 objects of the type divided by @code{Storage_Unit},
9150 and the maximum alignment supported by the target.
9151 (This maximum alignment is given by the GNAT-specific attribute
9152 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9153 @cindex @code{Maximum_Alignment} attribute
9154 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9155 default alignment will be 8 on any target that supports alignments
9156 this large, but on some targets, the maximum alignment may be smaller
9157 than 8, in which case objects of type @code{Long_Float} will be maximally
9160 @item @emph{Arrays}.
9161 For arrays, the alignment is equal to the alignment of the component type
9162 for the normal case where no packing or component size is given. If the
9163 array is packed, and the packing is effective (see separate section on
9164 packed arrays), then the alignment will be one for long packed arrays,
9165 or arrays whose length is not known at compile time. For short packed
9166 arrays, which are handled internally as modular types, the alignment
9167 will be as described for primitive types, e.g.@: a packed array of length
9168 31 bits will have an object size of four bytes, and an alignment of 4.
9170 @item @emph{Records}.
9171 For the normal non-packed case, the alignment of a record is equal to
9172 the maximum alignment of any of its components. For tagged records, this
9173 includes the implicit access type used for the tag. If a pragma @code{Pack} is
9174 used and all fields are packable (see separate section on pragma @code{Pack}),
9175 then the resulting alignment is 1.
9177 A special case is when:
9180 the size of the record is given explicitly, or a
9181 full record representation clause is given, and
9183 the size of the record is 2, 4, or 8 bytes.
9186 In this case, an alignment is chosen to match the
9187 size of the record. For example, if we have:
9189 @smallexample @c ada
9190 type Small is record
9193 for Small'Size use 16;
9197 then the default alignment of the record type @code{Small} is 2, not 1. This
9198 leads to more efficient code when the record is treated as a unit, and also
9199 allows the type to specified as @code{Atomic} on architectures requiring
9205 An alignment clause may specify a larger alignment than the default value
9206 up to some maximum value dependent on the target (obtainable by using the
9207 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9208 a smaller alignment than the default value, for example
9210 @smallexample @c ada
9215 for V'alignment use 1;
9219 @cindex Alignment, default
9220 The default alignment for the type @code{V} is 4, as a result of the
9221 Integer field in the record, but it is permissible, as shown, to
9222 override the default alignment of the record with a smaller value.
9225 @section Size Clauses
9229 The default size for a type @code{T} is obtainable through the
9230 language-defined attribute @code{T'Size} and also through the
9231 equivalent GNAT-defined attribute @code{T'Value_Size}.
9232 For objects of type @code{T}, GNAT will generally increase the type size
9233 so that the object size (obtainable through the GNAT-defined attribute
9234 @code{T'Object_Size})
9235 is a multiple of @code{T'Alignment * Storage_Unit}.
9238 @smallexample @c ada
9239 type Smallint is range 1 .. 6;
9248 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9249 as specified by the RM rules,
9250 but objects of this type will have a size of 8
9251 (@code{Smallint'Object_Size} = 8),
9252 since objects by default occupy an integral number
9253 of storage units. On some targets, notably older
9254 versions of the Digital Alpha, the size of stand
9255 alone objects of this type may be 32, reflecting
9256 the inability of the hardware to do byte load/stores.
9258 Similarly, the size of type @code{Rec} is 40 bits
9259 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9260 the alignment is 4, so objects of this type will have
9261 their size increased to 64 bits so that it is a multiple
9262 of the alignment (in bits). This decision is
9263 in accordance with the specific Implementation Advice in RM 13.3(43):
9266 A @code{Size} clause should be supported for an object if the specified
9267 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9268 to a size in storage elements that is a multiple of the object's
9269 @code{Alignment} (if the @code{Alignment} is nonzero).
9273 An explicit size clause may be used to override the default size by
9274 increasing it. For example, if we have:
9276 @smallexample @c ada
9277 type My_Boolean is new Boolean;
9278 for My_Boolean'Size use 32;
9282 then values of this type will always be 32 bits long. In the case of
9283 discrete types, the size can be increased up to 64 bits, with the effect
9284 that the entire specified field is used to hold the value, sign- or
9285 zero-extended as appropriate. If more than 64 bits is specified, then
9286 padding space is allocated after the value, and a warning is issued that
9287 there are unused bits.
9289 Similarly the size of records and arrays may be increased, and the effect
9290 is to add padding bits after the value. This also causes a warning message
9293 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
9294 Size in bits, this corresponds to an object of size 256 megabytes (minus
9295 one). This limitation is true on all targets. The reason for this
9296 limitation is that it improves the quality of the code in many cases
9297 if it is known that a Size value can be accommodated in an object of
9300 @node Storage_Size Clauses
9301 @section Storage_Size Clauses
9302 @cindex Storage_Size Clause
9305 For tasks, the @code{Storage_Size} clause specifies the amount of space
9306 to be allocated for the task stack. This cannot be extended, and if the
9307 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9308 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
9309 or a @code{Storage_Size} pragma in the task definition to set the
9310 appropriate required size. A useful technique is to include in every
9311 task definition a pragma of the form:
9313 @smallexample @c ada
9314 pragma Storage_Size (Default_Stack_Size);
9318 Then @code{Default_Stack_Size} can be defined in a global package, and
9319 modified as required. Any tasks requiring stack sizes different from the
9320 default can have an appropriate alternative reference in the pragma.
9322 You can also use the @code{-d} binder switch to modify the default stack
9325 For access types, the @code{Storage_Size} clause specifies the maximum
9326 space available for allocation of objects of the type. If this space is
9327 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9328 In the case where the access type is declared local to a subprogram, the
9329 use of a @code{Storage_Size} clause triggers automatic use of a special
9330 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9331 space for the pool is automatically reclaimed on exit from the scope in
9332 which the type is declared.
9334 A special case recognized by the compiler is the specification of a
9335 @code{Storage_Size} of zero for an access type. This means that no
9336 items can be allocated from the pool, and this is recognized at compile
9337 time, and all the overhead normally associated with maintaining a fixed
9338 size storage pool is eliminated. Consider the following example:
9340 @smallexample @c ada
9342 type R is array (Natural) of Character;
9343 type P is access all R;
9344 for P'Storage_Size use 0;
9345 -- Above access type intended only for interfacing purposes
9349 procedure g (m : P);
9350 pragma Import (C, g);
9361 As indicated in this example, these dummy storage pools are often useful in
9362 connection with interfacing where no object will ever be allocated. If you
9363 compile the above example, you get the warning:
9366 p.adb:16:09: warning: allocation from empty storage pool
9367 p.adb:16:09: warning: Storage_Error will be raised at run time
9371 Of course in practice, there will not be any explicit allocators in the
9372 case of such an access declaration.
9374 @node Size of Variant Record Objects
9375 @section Size of Variant Record Objects
9376 @cindex Size, variant record objects
9377 @cindex Variant record objects, size
9380 In the case of variant record objects, there is a question whether Size gives
9381 information about a particular variant, or the maximum size required
9382 for any variant. Consider the following program
9384 @smallexample @c ada
9385 with Text_IO; use Text_IO;
9387 type R1 (A : Boolean := False) is record
9389 when True => X : Character;
9398 Put_Line (Integer'Image (V1'Size));
9399 Put_Line (Integer'Image (V2'Size));
9404 Here we are dealing with a variant record, where the True variant
9405 requires 16 bits, and the False variant requires 8 bits.
9406 In the above example, both V1 and V2 contain the False variant,
9407 which is only 8 bits long. However, the result of running the
9416 The reason for the difference here is that the discriminant value of
9417 V1 is fixed, and will always be False. It is not possible to assign
9418 a True variant value to V1, therefore 8 bits is sufficient. On the
9419 other hand, in the case of V2, the initial discriminant value is
9420 False (from the default), but it is possible to assign a True
9421 variant value to V2, therefore 16 bits must be allocated for V2
9422 in the general case, even fewer bits may be needed at any particular
9423 point during the program execution.
9425 As can be seen from the output of this program, the @code{'Size}
9426 attribute applied to such an object in GNAT gives the actual allocated
9427 size of the variable, which is the largest size of any of the variants.
9428 The Ada Reference Manual is not completely clear on what choice should
9429 be made here, but the GNAT behavior seems most consistent with the
9430 language in the RM@.
9432 In some cases, it may be desirable to obtain the size of the current
9433 variant, rather than the size of the largest variant. This can be
9434 achieved in GNAT by making use of the fact that in the case of a
9435 subprogram parameter, GNAT does indeed return the size of the current
9436 variant (because a subprogram has no way of knowing how much space
9437 is actually allocated for the actual).
9439 Consider the following modified version of the above program:
9441 @smallexample @c ada
9442 with Text_IO; use Text_IO;
9444 type R1 (A : Boolean := False) is record
9446 when True => X : Character;
9453 function Size (V : R1) return Integer is
9459 Put_Line (Integer'Image (V2'Size));
9460 Put_Line (Integer'IMage (Size (V2)));
9462 Put_Line (Integer'Image (V2'Size));
9463 Put_Line (Integer'IMage (Size (V2)));
9468 The output from this program is
9478 Here we see that while the @code{'Size} attribute always returns
9479 the maximum size, regardless of the current variant value, the
9480 @code{Size} function does indeed return the size of the current
9483 @node Biased Representation
9484 @section Biased Representation
9485 @cindex Size for biased representation
9486 @cindex Biased representation
9489 In the case of scalars with a range starting at other than zero, it is
9490 possible in some cases to specify a size smaller than the default minimum
9491 value, and in such cases, GNAT uses an unsigned biased representation,
9492 in which zero is used to represent the lower bound, and successive values
9493 represent successive values of the type.
9495 For example, suppose we have the declaration:
9497 @smallexample @c ada
9498 type Small is range -7 .. -4;
9499 for Small'Size use 2;
9503 Although the default size of type @code{Small} is 4, the @code{Size}
9504 clause is accepted by GNAT and results in the following representation
9508 -7 is represented as 2#00#
9509 -6 is represented as 2#01#
9510 -5 is represented as 2#10#
9511 -4 is represented as 2#11#
9515 Biased representation is only used if the specified @code{Size} clause
9516 cannot be accepted in any other manner. These reduced sizes that force
9517 biased representation can be used for all discrete types except for
9518 enumeration types for which a representation clause is given.
9520 @node Value_Size and Object_Size Clauses
9521 @section Value_Size and Object_Size Clauses
9524 @cindex Size, of objects
9527 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
9528 number of bits required to hold values of type @code{T}.
9529 Although this interpretation was allowed in Ada 83, it was not required,
9530 and this requirement in practice can cause some significant difficulties.
9531 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
9532 However, in Ada 95 and Ada 2005,
9533 @code{Natural'Size} is
9534 typically 31. This means that code may change in behavior when moving
9535 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
9537 @smallexample @c ada
9544 at 0 range 0 .. Natural'Size - 1;
9545 at 0 range Natural'Size .. 2 * Natural'Size - 1;
9550 In the above code, since the typical size of @code{Natural} objects
9551 is 32 bits and @code{Natural'Size} is 31, the above code can cause
9552 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
9553 there are cases where the fact that the object size can exceed the
9554 size of the type causes surprises.
9556 To help get around this problem GNAT provides two implementation
9557 defined attributes, @code{Value_Size} and @code{Object_Size}. When
9558 applied to a type, these attributes yield the size of the type
9559 (corresponding to the RM defined size attribute), and the size of
9560 objects of the type respectively.
9562 The @code{Object_Size} is used for determining the default size of
9563 objects and components. This size value can be referred to using the
9564 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
9565 the basis of the determination of the size. The backend is free to
9566 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
9567 character might be stored in 32 bits on a machine with no efficient
9568 byte access instructions such as the Alpha.
9570 The default rules for the value of @code{Object_Size} for
9571 discrete types are as follows:
9575 The @code{Object_Size} for base subtypes reflect the natural hardware
9576 size in bits (run the compiler with @option{-gnatS} to find those values
9577 for numeric types). Enumeration types and fixed-point base subtypes have
9578 8, 16, 32 or 64 bits for this size, depending on the range of values
9582 The @code{Object_Size} of a subtype is the same as the
9583 @code{Object_Size} of
9584 the type from which it is obtained.
9587 The @code{Object_Size} of a derived base type is copied from the parent
9588 base type, and the @code{Object_Size} of a derived first subtype is copied
9589 from the parent first subtype.
9593 The @code{Value_Size} attribute
9594 is the (minimum) number of bits required to store a value
9596 This value is used to determine how tightly to pack
9597 records or arrays with components of this type, and also affects
9598 the semantics of unchecked conversion (unchecked conversions where
9599 the @code{Value_Size} values differ generate a warning, and are potentially
9602 The default rules for the value of @code{Value_Size} are as follows:
9606 The @code{Value_Size} for a base subtype is the minimum number of bits
9607 required to store all values of the type (including the sign bit
9608 only if negative values are possible).
9611 If a subtype statically matches the first subtype of a given type, then it has
9612 by default the same @code{Value_Size} as the first subtype. This is a
9613 consequence of RM 13.1(14) (``if two subtypes statically match,
9614 then their subtype-specific aspects are the same''.)
9617 All other subtypes have a @code{Value_Size} corresponding to the minimum
9618 number of bits required to store all values of the subtype. For
9619 dynamic bounds, it is assumed that the value can range down or up
9620 to the corresponding bound of the ancestor
9624 The RM defined attribute @code{Size} corresponds to the
9625 @code{Value_Size} attribute.
9627 The @code{Size} attribute may be defined for a first-named subtype. This sets
9628 the @code{Value_Size} of
9629 the first-named subtype to the given value, and the
9630 @code{Object_Size} of this first-named subtype to the given value padded up
9631 to an appropriate boundary. It is a consequence of the default rules
9632 above that this @code{Object_Size} will apply to all further subtypes. On the
9633 other hand, @code{Value_Size} is affected only for the first subtype, any
9634 dynamic subtypes obtained from it directly, and any statically matching
9635 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
9637 @code{Value_Size} and
9638 @code{Object_Size} may be explicitly set for any subtype using
9639 an attribute definition clause. Note that the use of these attributes
9640 can cause the RM 13.1(14) rule to be violated. If two access types
9641 reference aliased objects whose subtypes have differing @code{Object_Size}
9642 values as a result of explicit attribute definition clauses, then it
9643 is erroneous to convert from one access subtype to the other.
9645 At the implementation level, Esize stores the Object_Size and the
9646 RM_Size field stores the @code{Value_Size} (and hence the value of the
9647 @code{Size} attribute,
9648 which, as noted above, is equivalent to @code{Value_Size}).
9650 To get a feel for the difference, consider the following examples (note
9651 that in each case the base is @code{Short_Short_Integer} with a size of 8):
9654 Object_Size Value_Size
9656 type x1 is range 0 .. 5; 8 3
9658 type x2 is range 0 .. 5;
9659 for x2'size use 12; 16 12
9661 subtype x3 is x2 range 0 .. 3; 16 2
9663 subtype x4 is x2'base range 0 .. 10; 8 4
9665 subtype x5 is x2 range 0 .. dynamic; 16 3*
9667 subtype x6 is x2'base range 0 .. dynamic; 8 3*
9672 Note: the entries marked ``3*'' are not actually specified by the Ada
9673 Reference Manual, but it seems in the spirit of the RM rules to allocate
9674 the minimum number of bits (here 3, given the range for @code{x2})
9675 known to be large enough to hold the given range of values.
9677 So far, so good, but GNAT has to obey the RM rules, so the question is
9678 under what conditions must the RM @code{Size} be used.
9679 The following is a list
9680 of the occasions on which the RM @code{Size} must be used:
9684 Component size for packed arrays or records
9687 Value of the attribute @code{Size} for a type
9690 Warning about sizes not matching for unchecked conversion
9694 For record types, the @code{Object_Size} is always a multiple of the
9695 alignment of the type (this is true for all types). In some cases the
9696 @code{Value_Size} can be smaller. Consider:
9706 On a typical 32-bit architecture, the X component will be four bytes, and
9707 require four-byte alignment, and the Y component will be one byte. In this
9708 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
9709 required to store a value of this type, and for example, it is permissible
9710 to have a component of type R in an outer record whose component size is
9711 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9712 since it must be rounded up so that this value is a multiple of the
9713 alignment (4 bytes = 32 bits).
9716 For all other types, the @code{Object_Size}
9717 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9718 Only @code{Size} may be specified for such types.
9720 @node Component_Size Clauses
9721 @section Component_Size Clauses
9722 @cindex Component_Size Clause
9725 Normally, the value specified in a component size clause must be consistent
9726 with the subtype of the array component with regard to size and alignment.
9727 In other words, the value specified must be at least equal to the size
9728 of this subtype, and must be a multiple of the alignment value.
9730 In addition, component size clauses are allowed which cause the array
9731 to be packed, by specifying a smaller value. The cases in which this
9732 is allowed are for component size values in the range 1 through 63. The value
9733 specified must not be smaller than the Size of the subtype. GNAT will
9734 accurately honor all packing requests in this range. For example, if
9737 @smallexample @c ada
9738 type r is array (1 .. 8) of Natural;
9739 for r'Component_Size use 31;
9743 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9744 Of course access to the components of such an array is considerably
9745 less efficient than if the natural component size of 32 is used.
9747 Note that there is no point in giving both a component size clause
9748 and a pragma Pack for the same array type. if such duplicate
9749 clauses are given, the pragma Pack will be ignored.
9751 @node Bit_Order Clauses
9752 @section Bit_Order Clauses
9753 @cindex Bit_Order Clause
9754 @cindex bit ordering
9755 @cindex ordering, of bits
9758 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9759 attribute. The specification may either correspond to the default bit
9760 order for the target, in which case the specification has no effect and
9761 places no additional restrictions, or it may be for the non-standard
9762 setting (that is the opposite of the default).
9764 In the case where the non-standard value is specified, the effect is
9765 to renumber bits within each byte, but the ordering of bytes is not
9766 affected. There are certain
9767 restrictions placed on component clauses as follows:
9771 @item Components fitting within a single storage unit.
9773 These are unrestricted, and the effect is merely to renumber bits. For
9774 example if we are on a little-endian machine with @code{Low_Order_First}
9775 being the default, then the following two declarations have exactly
9778 @smallexample @c ada
9781 B : Integer range 1 .. 120;
9785 A at 0 range 0 .. 0;
9786 B at 0 range 1 .. 7;
9791 B : Integer range 1 .. 120;
9794 for R2'Bit_Order use High_Order_First;
9797 A at 0 range 7 .. 7;
9798 B at 0 range 0 .. 6;
9803 The useful application here is to write the second declaration with the
9804 @code{Bit_Order} attribute definition clause, and know that it will be treated
9805 the same, regardless of whether the target is little-endian or big-endian.
9807 @item Components occupying an integral number of bytes.
9809 These are components that exactly fit in two or more bytes. Such component
9810 declarations are allowed, but have no effect, since it is important to realize
9811 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9812 In particular, the following attempt at getting an endian-independent integer
9815 @smallexample @c ada
9820 for R2'Bit_Order use High_Order_First;
9823 A at 0 range 0 .. 31;
9828 This declaration will result in a little-endian integer on a
9829 little-endian machine, and a big-endian integer on a big-endian machine.
9830 If byte flipping is required for interoperability between big- and
9831 little-endian machines, this must be explicitly programmed. This capability
9832 is not provided by @code{Bit_Order}.
9834 @item Components that are positioned across byte boundaries
9836 but do not occupy an integral number of bytes. Given that bytes are not
9837 reordered, such fields would occupy a non-contiguous sequence of bits
9838 in memory, requiring non-trivial code to reassemble. They are for this
9839 reason not permitted, and any component clause specifying such a layout
9840 will be flagged as illegal by GNAT@.
9845 Since the misconception that Bit_Order automatically deals with all
9846 endian-related incompatibilities is a common one, the specification of
9847 a component field that is an integral number of bytes will always
9848 generate a warning. This warning may be suppressed using
9849 @code{pragma Suppress} if desired. The following section contains additional
9850 details regarding the issue of byte ordering.
9852 @node Effect of Bit_Order on Byte Ordering
9853 @section Effect of Bit_Order on Byte Ordering
9854 @cindex byte ordering
9855 @cindex ordering, of bytes
9858 In this section we will review the effect of the @code{Bit_Order} attribute
9859 definition clause on byte ordering. Briefly, it has no effect at all, but
9860 a detailed example will be helpful. Before giving this
9861 example, let us review the precise
9862 definition of the effect of defining @code{Bit_Order}. The effect of a
9863 non-standard bit order is described in section 15.5.3 of the Ada
9867 2 A bit ordering is a method of interpreting the meaning of
9868 the storage place attributes.
9872 To understand the precise definition of storage place attributes in
9873 this context, we visit section 13.5.1 of the manual:
9876 13 A record_representation_clause (without the mod_clause)
9877 specifies the layout. The storage place attributes (see 13.5.2)
9878 are taken from the values of the position, first_bit, and last_bit
9879 expressions after normalizing those values so that first_bit is
9880 less than Storage_Unit.
9884 The critical point here is that storage places are taken from
9885 the values after normalization, not before. So the @code{Bit_Order}
9886 interpretation applies to normalized values. The interpretation
9887 is described in the later part of the 15.5.3 paragraph:
9890 2 A bit ordering is a method of interpreting the meaning of
9891 the storage place attributes. High_Order_First (known in the
9892 vernacular as ``big endian'') means that the first bit of a
9893 storage element (bit 0) is the most significant bit (interpreting
9894 the sequence of bits that represent a component as an unsigned
9895 integer value). Low_Order_First (known in the vernacular as
9896 ``little endian'') means the opposite: the first bit is the
9901 Note that the numbering is with respect to the bits of a storage
9902 unit. In other words, the specification affects only the numbering
9903 of bits within a single storage unit.
9905 We can make the effect clearer by giving an example.
9907 Suppose that we have an external device which presents two bytes, the first
9908 byte presented, which is the first (low addressed byte) of the two byte
9909 record is called Master, and the second byte is called Slave.
9911 The left most (most significant bit is called Control for each byte, and
9912 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9913 (least significant) bit.
9915 On a big-endian machine, we can write the following representation clause
9917 @smallexample @c ada
9919 Master_Control : Bit;
9927 Slave_Control : Bit;
9938 Master_Control at 0 range 0 .. 0;
9939 Master_V1 at 0 range 1 .. 1;
9940 Master_V2 at 0 range 2 .. 2;
9941 Master_V3 at 0 range 3 .. 3;
9942 Master_V4 at 0 range 4 .. 4;
9943 Master_V5 at 0 range 5 .. 5;
9944 Master_V6 at 0 range 6 .. 6;
9945 Master_V7 at 0 range 7 .. 7;
9946 Slave_Control at 1 range 0 .. 0;
9947 Slave_V1 at 1 range 1 .. 1;
9948 Slave_V2 at 1 range 2 .. 2;
9949 Slave_V3 at 1 range 3 .. 3;
9950 Slave_V4 at 1 range 4 .. 4;
9951 Slave_V5 at 1 range 5 .. 5;
9952 Slave_V6 at 1 range 6 .. 6;
9953 Slave_V7 at 1 range 7 .. 7;
9958 Now if we move this to a little endian machine, then the bit ordering within
9959 the byte is backwards, so we have to rewrite the record rep clause as:
9961 @smallexample @c ada
9963 Master_Control at 0 range 7 .. 7;
9964 Master_V1 at 0 range 6 .. 6;
9965 Master_V2 at 0 range 5 .. 5;
9966 Master_V3 at 0 range 4 .. 4;
9967 Master_V4 at 0 range 3 .. 3;
9968 Master_V5 at 0 range 2 .. 2;
9969 Master_V6 at 0 range 1 .. 1;
9970 Master_V7 at 0 range 0 .. 0;
9971 Slave_Control at 1 range 7 .. 7;
9972 Slave_V1 at 1 range 6 .. 6;
9973 Slave_V2 at 1 range 5 .. 5;
9974 Slave_V3 at 1 range 4 .. 4;
9975 Slave_V4 at 1 range 3 .. 3;
9976 Slave_V5 at 1 range 2 .. 2;
9977 Slave_V6 at 1 range 1 .. 1;
9978 Slave_V7 at 1 range 0 .. 0;
9983 It is a nuisance to have to rewrite the clause, especially if
9984 the code has to be maintained on both machines. However,
9985 this is a case that we can handle with the
9986 @code{Bit_Order} attribute if it is implemented.
9987 Note that the implementation is not required on byte addressed
9988 machines, but it is indeed implemented in GNAT.
9989 This means that we can simply use the
9990 first record clause, together with the declaration
9992 @smallexample @c ada
9993 for Data'Bit_Order use High_Order_First;
9997 and the effect is what is desired, namely the layout is exactly the same,
9998 independent of whether the code is compiled on a big-endian or little-endian
10001 The important point to understand is that byte ordering is not affected.
10002 A @code{Bit_Order} attribute definition never affects which byte a field
10003 ends up in, only where it ends up in that byte.
10004 To make this clear, let us rewrite the record rep clause of the previous
10007 @smallexample @c ada
10008 for Data'Bit_Order use High_Order_First;
10009 for Data use record
10010 Master_Control at 0 range 0 .. 0;
10011 Master_V1 at 0 range 1 .. 1;
10012 Master_V2 at 0 range 2 .. 2;
10013 Master_V3 at 0 range 3 .. 3;
10014 Master_V4 at 0 range 4 .. 4;
10015 Master_V5 at 0 range 5 .. 5;
10016 Master_V6 at 0 range 6 .. 6;
10017 Master_V7 at 0 range 7 .. 7;
10018 Slave_Control at 0 range 8 .. 8;
10019 Slave_V1 at 0 range 9 .. 9;
10020 Slave_V2 at 0 range 10 .. 10;
10021 Slave_V3 at 0 range 11 .. 11;
10022 Slave_V4 at 0 range 12 .. 12;
10023 Slave_V5 at 0 range 13 .. 13;
10024 Slave_V6 at 0 range 14 .. 14;
10025 Slave_V7 at 0 range 15 .. 15;
10030 This is exactly equivalent to saying (a repeat of the first example):
10032 @smallexample @c ada
10033 for Data'Bit_Order use High_Order_First;
10034 for Data use record
10035 Master_Control at 0 range 0 .. 0;
10036 Master_V1 at 0 range 1 .. 1;
10037 Master_V2 at 0 range 2 .. 2;
10038 Master_V3 at 0 range 3 .. 3;
10039 Master_V4 at 0 range 4 .. 4;
10040 Master_V5 at 0 range 5 .. 5;
10041 Master_V6 at 0 range 6 .. 6;
10042 Master_V7 at 0 range 7 .. 7;
10043 Slave_Control at 1 range 0 .. 0;
10044 Slave_V1 at 1 range 1 .. 1;
10045 Slave_V2 at 1 range 2 .. 2;
10046 Slave_V3 at 1 range 3 .. 3;
10047 Slave_V4 at 1 range 4 .. 4;
10048 Slave_V5 at 1 range 5 .. 5;
10049 Slave_V6 at 1 range 6 .. 6;
10050 Slave_V7 at 1 range 7 .. 7;
10055 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10056 field. The storage place attributes are obtained by normalizing the
10057 values given so that the @code{First_Bit} value is less than 8. After
10058 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10059 we specified in the other case.
10061 Now one might expect that the @code{Bit_Order} attribute might affect
10062 bit numbering within the entire record component (two bytes in this
10063 case, thus affecting which byte fields end up in), but that is not
10064 the way this feature is defined, it only affects numbering of bits,
10065 not which byte they end up in.
10067 Consequently it never makes sense to specify a starting bit number
10068 greater than 7 (for a byte addressable field) if an attribute
10069 definition for @code{Bit_Order} has been given, and indeed it
10070 may be actively confusing to specify such a value, so the compiler
10071 generates a warning for such usage.
10073 If you do need to control byte ordering then appropriate conditional
10074 values must be used. If in our example, the slave byte came first on
10075 some machines we might write:
10077 @smallexample @c ada
10078 Master_Byte_First constant Boolean := @dots{};
10080 Master_Byte : constant Natural :=
10081 1 - Boolean'Pos (Master_Byte_First);
10082 Slave_Byte : constant Natural :=
10083 Boolean'Pos (Master_Byte_First);
10085 for Data'Bit_Order use High_Order_First;
10086 for Data use record
10087 Master_Control at Master_Byte range 0 .. 0;
10088 Master_V1 at Master_Byte range 1 .. 1;
10089 Master_V2 at Master_Byte range 2 .. 2;
10090 Master_V3 at Master_Byte range 3 .. 3;
10091 Master_V4 at Master_Byte range 4 .. 4;
10092 Master_V5 at Master_Byte range 5 .. 5;
10093 Master_V6 at Master_Byte range 6 .. 6;
10094 Master_V7 at Master_Byte range 7 .. 7;
10095 Slave_Control at Slave_Byte range 0 .. 0;
10096 Slave_V1 at Slave_Byte range 1 .. 1;
10097 Slave_V2 at Slave_Byte range 2 .. 2;
10098 Slave_V3 at Slave_Byte range 3 .. 3;
10099 Slave_V4 at Slave_Byte range 4 .. 4;
10100 Slave_V5 at Slave_Byte range 5 .. 5;
10101 Slave_V6 at Slave_Byte range 6 .. 6;
10102 Slave_V7 at Slave_Byte range 7 .. 7;
10107 Now to switch between machines, all that is necessary is
10108 to set the boolean constant @code{Master_Byte_First} in
10109 an appropriate manner.
10111 @node Pragma Pack for Arrays
10112 @section Pragma Pack for Arrays
10113 @cindex Pragma Pack (for arrays)
10116 Pragma @code{Pack} applied to an array has no effect unless the component type
10117 is packable. For a component type to be packable, it must be one of the
10124 Any type whose size is specified with a size clause
10126 Any packed array type with a static size
10130 For all these cases, if the component subtype size is in the range
10131 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10132 component size were specified giving the component subtype size.
10133 For example if we have:
10135 @smallexample @c ada
10136 type r is range 0 .. 17;
10138 type ar is array (1 .. 8) of r;
10143 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10144 and the size of the array @code{ar} will be exactly 40 bits.
10146 Note that in some cases this rather fierce approach to packing can produce
10147 unexpected effects. For example, in Ada 95 and Ada 2005,
10148 subtype @code{Natural} typically has a size of 31, meaning that if you
10149 pack an array of @code{Natural}, you get 31-bit
10150 close packing, which saves a few bits, but results in far less efficient
10151 access. Since many other Ada compilers will ignore such a packing request,
10152 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10153 might not be what is intended. You can easily remove this warning by
10154 using an explicit @code{Component_Size} setting instead, which never generates
10155 a warning, since the intention of the programmer is clear in this case.
10157 GNAT treats packed arrays in one of two ways. If the size of the array is
10158 known at compile time and is less than 64 bits, then internally the array
10159 is represented as a single modular type, of exactly the appropriate number
10160 of bits. If the length is greater than 63 bits, or is not known at compile
10161 time, then the packed array is represented as an array of bytes, and the
10162 length is always a multiple of 8 bits.
10164 Note that to represent a packed array as a modular type, the alignment must
10165 be suitable for the modular type involved. For example, on typical machines
10166 a 32-bit packed array will be represented by a 32-bit modular integer with
10167 an alignment of four bytes. If you explicitly override the default alignment
10168 with an alignment clause that is too small, the modular representation
10169 cannot be used. For example, consider the following set of declarations:
10171 @smallexample @c ada
10172 type R is range 1 .. 3;
10173 type S is array (1 .. 31) of R;
10174 for S'Component_Size use 2;
10176 for S'Alignment use 1;
10180 If the alignment clause were not present, then a 62-bit modular
10181 representation would be chosen (typically with an alignment of 4 or 8
10182 bytes depending on the target). But the default alignment is overridden
10183 with the explicit alignment clause. This means that the modular
10184 representation cannot be used, and instead the array of bytes
10185 representation must be used, meaning that the length must be a multiple
10186 of 8. Thus the above set of declarations will result in a diagnostic
10187 rejecting the size clause and noting that the minimum size allowed is 64.
10189 @cindex Pragma Pack (for type Natural)
10190 @cindex Pragma Pack warning
10192 One special case that is worth noting occurs when the base type of the
10193 component size is 8/16/32 and the subtype is one bit less. Notably this
10194 occurs with subtype @code{Natural}. Consider:
10196 @smallexample @c ada
10197 type Arr is array (1 .. 32) of Natural;
10202 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10203 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10204 Ada 83 compilers did not attempt 31 bit packing.
10206 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10207 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10208 substantial unintended performance penalty when porting legacy Ada 83 code.
10209 To help prevent this, GNAT generates a warning in such cases. If you really
10210 want 31 bit packing in a case like this, you can set the component size
10213 @smallexample @c ada
10214 type Arr is array (1 .. 32) of Natural;
10215 for Arr'Component_Size use 31;
10219 Here 31-bit packing is achieved as required, and no warning is generated,
10220 since in this case the programmer intention is clear.
10222 @node Pragma Pack for Records
10223 @section Pragma Pack for Records
10224 @cindex Pragma Pack (for records)
10227 Pragma @code{Pack} applied to a record will pack the components to reduce
10228 wasted space from alignment gaps and by reducing the amount of space
10229 taken by components. We distinguish between @emph{packable} components and
10230 @emph{non-packable} components.
10231 Components of the following types are considered packable:
10234 All primitive types are packable.
10237 Small packed arrays, whose size does not exceed 64 bits, and where the
10238 size is statically known at compile time, are represented internally
10239 as modular integers, and so they are also packable.
10244 All packable components occupy the exact number of bits corresponding to
10245 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10246 can start on an arbitrary bit boundary.
10248 All other types are non-packable, they occupy an integral number of
10250 are placed at a boundary corresponding to their alignment requirements.
10252 For example, consider the record
10254 @smallexample @c ada
10255 type Rb1 is array (1 .. 13) of Boolean;
10258 type Rb2 is array (1 .. 65) of Boolean;
10273 The representation for the record x2 is as follows:
10275 @smallexample @c ada
10276 for x2'Size use 224;
10278 l1 at 0 range 0 .. 0;
10279 l2 at 0 range 1 .. 64;
10280 l3 at 12 range 0 .. 31;
10281 l4 at 16 range 0 .. 0;
10282 l5 at 16 range 1 .. 13;
10283 l6 at 18 range 0 .. 71;
10288 Studying this example, we see that the packable fields @code{l1}
10290 of length equal to their sizes, and placed at specific bit boundaries (and
10291 not byte boundaries) to
10292 eliminate padding. But @code{l3} is of a non-packable float type, so
10293 it is on the next appropriate alignment boundary.
10295 The next two fields are fully packable, so @code{l4} and @code{l5} are
10296 minimally packed with no gaps. However, type @code{Rb2} is a packed
10297 array that is longer than 64 bits, so it is itself non-packable. Thus
10298 the @code{l6} field is aligned to the next byte boundary, and takes an
10299 integral number of bytes, i.e.@: 72 bits.
10301 @node Record Representation Clauses
10302 @section Record Representation Clauses
10303 @cindex Record Representation Clause
10306 Record representation clauses may be given for all record types, including
10307 types obtained by record extension. Component clauses are allowed for any
10308 static component. The restrictions on component clauses depend on the type
10311 @cindex Component Clause
10312 For all components of an elementary type, the only restriction on component
10313 clauses is that the size must be at least the 'Size value of the type
10314 (actually the Value_Size). There are no restrictions due to alignment,
10315 and such components may freely cross storage boundaries.
10317 Packed arrays with a size up to and including 64 bits are represented
10318 internally using a modular type with the appropriate number of bits, and
10319 thus the same lack of restriction applies. For example, if you declare:
10321 @smallexample @c ada
10322 type R is array (1 .. 49) of Boolean;
10328 then a component clause for a component of type R may start on any
10329 specified bit boundary, and may specify a value of 49 bits or greater.
10331 For packed bit arrays that are longer than 64 bits, there are two
10332 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10333 including the important case of single bits or boolean values, then
10334 there are no limitations on placement of such components, and they
10335 may start and end at arbitrary bit boundaries.
10337 If the component size is not a power of 2 (e.g. 3 or 5), then
10338 an array of this type longer than 64 bits must always be placed on
10339 on a storage unit (byte) boundary and occupy an integral number
10340 of storage units (bytes). Any component clause that does not
10341 meet this requirement will be rejected.
10343 Any aliased component, or component of an aliased type, must
10344 have its normal alignment and size. A component clause that
10345 does not meet this requirement will be rejected.
10347 The tag field of a tagged type always occupies an address sized field at
10348 the start of the record. No component clause may attempt to overlay this
10349 tag. When a tagged type appears as a component, the tag field must have
10352 In the case of a record extension T1, of a type T, no component clause applied
10353 to the type T1 can specify a storage location that would overlap the first
10354 T'Size bytes of the record.
10356 For all other component types, including non-bit-packed arrays,
10357 the component can be placed at an arbitrary bit boundary,
10358 so for example, the following is permitted:
10360 @smallexample @c ada
10361 type R is array (1 .. 10) of Boolean;
10370 G at 0 range 0 .. 0;
10371 H at 0 range 1 .. 1;
10372 L at 0 range 2 .. 81;
10373 R at 0 range 82 .. 161;
10378 Note: the above rules apply to recent releases of GNAT 5.
10379 In GNAT 3, there are more severe restrictions on larger components.
10380 For non-primitive types, including packed arrays with a size greater than
10381 64 bits, component clauses must respect the alignment requirement of the
10382 type, in particular, always starting on a byte boundary, and the length
10383 must be a multiple of the storage unit.
10385 @node Enumeration Clauses
10386 @section Enumeration Clauses
10388 The only restriction on enumeration clauses is that the range of values
10389 must be representable. For the signed case, if one or more of the
10390 representation values are negative, all values must be in the range:
10392 @smallexample @c ada
10393 System.Min_Int .. System.Max_Int
10397 For the unsigned case, where all values are non negative, the values must
10400 @smallexample @c ada
10401 0 .. System.Max_Binary_Modulus;
10405 A @emph{confirming} representation clause is one in which the values range
10406 from 0 in sequence, i.e.@: a clause that confirms the default representation
10407 for an enumeration type.
10408 Such a confirming representation
10409 is permitted by these rules, and is specially recognized by the compiler so
10410 that no extra overhead results from the use of such a clause.
10412 If an array has an index type which is an enumeration type to which an
10413 enumeration clause has been applied, then the array is stored in a compact
10414 manner. Consider the declarations:
10416 @smallexample @c ada
10417 type r is (A, B, C);
10418 for r use (A => 1, B => 5, C => 10);
10419 type t is array (r) of Character;
10423 The array type t corresponds to a vector with exactly three elements and
10424 has a default size equal to @code{3*Character'Size}. This ensures efficient
10425 use of space, but means that accesses to elements of the array will incur
10426 the overhead of converting representation values to the corresponding
10427 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
10429 @node Address Clauses
10430 @section Address Clauses
10431 @cindex Address Clause
10433 The reference manual allows a general restriction on representation clauses,
10434 as found in RM 13.1(22):
10437 An implementation need not support representation
10438 items containing nonstatic expressions, except that
10439 an implementation should support a representation item
10440 for a given entity if each nonstatic expression in the
10441 representation item is a name that statically denotes
10442 a constant declared before the entity.
10446 In practice this is applicable only to address clauses, since this is the
10447 only case in which a non-static expression is permitted by the syntax. As
10448 the AARM notes in sections 13.1 (22.a-22.h):
10451 22.a Reason: This is to avoid the following sort of thing:
10453 22.b X : Integer := F(@dots{});
10454 Y : Address := G(@dots{});
10455 for X'Address use Y;
10457 22.c In the above, we have to evaluate the
10458 initialization expression for X before we
10459 know where to put the result. This seems
10460 like an unreasonable implementation burden.
10462 22.d The above code should instead be written
10465 22.e Y : constant Address := G(@dots{});
10466 X : Integer := F(@dots{});
10467 for X'Address use Y;
10469 22.f This allows the expression ``Y'' to be safely
10470 evaluated before X is created.
10472 22.g The constant could be a formal parameter of mode in.
10474 22.h An implementation can support other nonstatic
10475 expressions if it wants to. Expressions of type
10476 Address are hardly ever static, but their value
10477 might be known at compile time anyway in many
10482 GNAT does indeed permit many additional cases of non-static expressions. In
10483 particular, if the type involved is elementary there are no restrictions
10484 (since in this case, holding a temporary copy of the initialization value,
10485 if one is present, is inexpensive). In addition, if there is no implicit or
10486 explicit initialization, then there are no restrictions. GNAT will reject
10487 only the case where all three of these conditions hold:
10492 The type of the item is non-elementary (e.g.@: a record or array).
10495 There is explicit or implicit initialization required for the object.
10496 Note that access values are always implicitly initialized, and also
10497 in GNAT, certain bit-packed arrays (those having a dynamic length or
10498 a length greater than 64) will also be implicitly initialized to zero.
10501 The address value is non-static. Here GNAT is more permissive than the
10502 RM, and allows the address value to be the address of a previously declared
10503 stand-alone variable, as long as it does not itself have an address clause.
10505 @smallexample @c ada
10506 Anchor : Some_Initialized_Type;
10507 Overlay : Some_Initialized_Type;
10508 for Overlay'Address use Anchor'Address;
10512 However, the prefix of the address clause cannot be an array component, or
10513 a component of a discriminated record.
10518 As noted above in section 22.h, address values are typically non-static. In
10519 particular the To_Address function, even if applied to a literal value, is
10520 a non-static function call. To avoid this minor annoyance, GNAT provides
10521 the implementation defined attribute 'To_Address. The following two
10522 expressions have identical values:
10526 @smallexample @c ada
10527 To_Address (16#1234_0000#)
10528 System'To_Address (16#1234_0000#);
10532 except that the second form is considered to be a static expression, and
10533 thus when used as an address clause value is always permitted.
10536 Additionally, GNAT treats as static an address clause that is an
10537 unchecked_conversion of a static integer value. This simplifies the porting
10538 of legacy code, and provides a portable equivalent to the GNAT attribute
10541 Another issue with address clauses is the interaction with alignment
10542 requirements. When an address clause is given for an object, the address
10543 value must be consistent with the alignment of the object (which is usually
10544 the same as the alignment of the type of the object). If an address clause
10545 is given that specifies an inappropriately aligned address value, then the
10546 program execution is erroneous.
10548 Since this source of erroneous behavior can have unfortunate effects, GNAT
10549 checks (at compile time if possible, generating a warning, or at execution
10550 time with a run-time check) that the alignment is appropriate. If the
10551 run-time check fails, then @code{Program_Error} is raised. This run-time
10552 check is suppressed if range checks are suppressed, or if the special GNAT
10553 check Alignment_Check is suppressed, or if
10554 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
10556 Finally, GNAT does not permit overlaying of objects of controlled types or
10557 composite types containing a controlled component. In most cases, the compiler
10558 can detect an attempt at such overlays and will generate a warning at compile
10559 time and a Program_Error exception at run time.
10562 An address clause cannot be given for an exported object. More
10563 understandably the real restriction is that objects with an address
10564 clause cannot be exported. This is because such variables are not
10565 defined by the Ada program, so there is no external object to export.
10568 It is permissible to give an address clause and a pragma Import for the
10569 same object. In this case, the variable is not really defined by the
10570 Ada program, so there is no external symbol to be linked. The link name
10571 and the external name are ignored in this case. The reason that we allow this
10572 combination is that it provides a useful idiom to avoid unwanted
10573 initializations on objects with address clauses.
10575 When an address clause is given for an object that has implicit or
10576 explicit initialization, then by default initialization takes place. This
10577 means that the effect of the object declaration is to overwrite the
10578 memory at the specified address. This is almost always not what the
10579 programmer wants, so GNAT will output a warning:
10589 for Ext'Address use System'To_Address (16#1234_1234#);
10591 >>> warning: implicit initialization of "Ext" may
10592 modify overlaid storage
10593 >>> warning: use pragma Import for "Ext" to suppress
10594 initialization (RM B(24))
10600 As indicated by the warning message, the solution is to use a (dummy) pragma
10601 Import to suppress this initialization. The pragma tell the compiler that the
10602 object is declared and initialized elsewhere. The following package compiles
10603 without warnings (and the initialization is suppressed):
10605 @smallexample @c ada
10613 for Ext'Address use System'To_Address (16#1234_1234#);
10614 pragma Import (Ada, Ext);
10619 A final issue with address clauses involves their use for overlaying
10620 variables, as in the following example:
10621 @cindex Overlaying of objects
10623 @smallexample @c ada
10626 for B'Address use A'Address;
10630 or alternatively, using the form recommended by the RM:
10632 @smallexample @c ada
10634 Addr : constant Address := A'Address;
10636 for B'Address use Addr;
10640 In both of these cases, @code{A}
10641 and @code{B} become aliased to one another via the
10642 address clause. This use of address clauses to overlay
10643 variables, achieving an effect similar to unchecked
10644 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
10645 the effect is implementation defined. Furthermore, the
10646 Ada RM specifically recommends that in a situation
10647 like this, @code{B} should be subject to the following
10648 implementation advice (RM 13.3(19)):
10651 19 If the Address of an object is specified, or it is imported
10652 or exported, then the implementation should not perform
10653 optimizations based on assumptions of no aliases.
10657 GNAT follows this recommendation, and goes further by also applying
10658 this recommendation to the overlaid variable (@code{A}
10659 in the above example) in this case. This means that the overlay
10660 works "as expected", in that a modification to one of the variables
10661 will affect the value of the other.
10663 @node Effect of Convention on Representation
10664 @section Effect of Convention on Representation
10665 @cindex Convention, effect on representation
10668 Normally the specification of a foreign language convention for a type or
10669 an object has no effect on the chosen representation. In particular, the
10670 representation chosen for data in GNAT generally meets the standard system
10671 conventions, and for example records are laid out in a manner that is
10672 consistent with C@. This means that specifying convention C (for example)
10675 There are four exceptions to this general rule:
10679 @item Convention Fortran and array subtypes
10680 If pragma Convention Fortran is specified for an array subtype, then in
10681 accordance with the implementation advice in section 3.6.2(11) of the
10682 Ada Reference Manual, the array will be stored in a Fortran-compatible
10683 column-major manner, instead of the normal default row-major order.
10685 @item Convention C and enumeration types
10686 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
10687 to accommodate all values of the type. For example, for the enumeration
10690 @smallexample @c ada
10691 type Color is (Red, Green, Blue);
10695 8 bits is sufficient to store all values of the type, so by default, objects
10696 of type @code{Color} will be represented using 8 bits. However, normal C
10697 convention is to use 32 bits for all enum values in C, since enum values
10698 are essentially of type int. If pragma @code{Convention C} is specified for an
10699 Ada enumeration type, then the size is modified as necessary (usually to
10700 32 bits) to be consistent with the C convention for enum values.
10702 Note that this treatment applies only to types. If Convention C is given for
10703 an enumeration object, where the enumeration type is not Convention C, then
10704 Object_Size bits are allocated. For example, for a normal enumeration type,
10705 with less than 256 elements, only 8 bits will be allocated for the object.
10706 Since this may be a surprise in terms of what C expects, GNAT will issue a
10707 warning in this situation. The warning can be suppressed by giving an explicit
10708 size clause specifying the desired size.
10710 @item Convention C/Fortran and Boolean types
10711 In C, the usual convention for boolean values, that is values used for
10712 conditions, is that zero represents false, and nonzero values represent
10713 true. In Ada, the normal convention is that two specific values, typically
10714 0/1, are used to represent false/true respectively.
10716 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
10717 value represents true).
10719 To accommodate the Fortran and C conventions, if a pragma Convention specifies
10720 C or Fortran convention for a derived Boolean, as in the following example:
10722 @smallexample @c ada
10723 type C_Switch is new Boolean;
10724 pragma Convention (C, C_Switch);
10728 then the GNAT generated code will treat any nonzero value as true. For truth
10729 values generated by GNAT, the conventional value 1 will be used for True, but
10730 when one of these values is read, any nonzero value is treated as True.
10732 @item Access types on OpenVMS
10733 For 64-bit OpenVMS systems, access types (other than those for unconstrained
10734 arrays) are 64-bits long. An exception to this rule is for the case of
10735 C-convention access types where there is no explicit size clause present (or
10736 inherited for derived types). In this case, GNAT chooses to make these
10737 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
10738 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
10742 @node Determining the Representations chosen by GNAT
10743 @section Determining the Representations chosen by GNAT
10744 @cindex Representation, determination of
10745 @cindex @code{-gnatR} switch
10748 Although the descriptions in this section are intended to be complete, it is
10749 often easier to simply experiment to see what GNAT accepts and what the
10750 effect is on the layout of types and objects.
10752 As required by the Ada RM, if a representation clause is not accepted, then
10753 it must be rejected as illegal by the compiler. However, when a
10754 representation clause or pragma is accepted, there can still be questions
10755 of what the compiler actually does. For example, if a partial record
10756 representation clause specifies the location of some components and not
10757 others, then where are the non-specified components placed? Or if pragma
10758 @code{Pack} is used on a record, then exactly where are the resulting
10759 fields placed? The section on pragma @code{Pack} in this chapter can be
10760 used to answer the second question, but it is often easier to just see
10761 what the compiler does.
10763 For this purpose, GNAT provides the option @code{-gnatR}. If you compile
10764 with this option, then the compiler will output information on the actual
10765 representations chosen, in a format similar to source representation
10766 clauses. For example, if we compile the package:
10768 @smallexample @c ada
10770 type r (x : boolean) is tagged record
10772 when True => S : String (1 .. 100);
10773 when False => null;
10777 type r2 is new r (false) with record
10782 y2 at 16 range 0 .. 31;
10789 type x1 is array (1 .. 10) of x;
10790 for x1'component_size use 11;
10792 type ia is access integer;
10794 type Rb1 is array (1 .. 13) of Boolean;
10797 type Rb2 is array (1 .. 65) of Boolean;
10813 using the switch @code{-gnatR} we obtain the following output:
10816 Representation information for unit q
10817 -------------------------------------
10820 for r'Alignment use 4;
10822 x at 4 range 0 .. 7;
10823 _tag at 0 range 0 .. 31;
10824 s at 5 range 0 .. 799;
10827 for r2'Size use 160;
10828 for r2'Alignment use 4;
10830 x at 4 range 0 .. 7;
10831 _tag at 0 range 0 .. 31;
10832 _parent at 0 range 0 .. 63;
10833 y2 at 16 range 0 .. 31;
10837 for x'Alignment use 1;
10839 y at 0 range 0 .. 7;
10842 for x1'Size use 112;
10843 for x1'Alignment use 1;
10844 for x1'Component_Size use 11;
10846 for rb1'Size use 13;
10847 for rb1'Alignment use 2;
10848 for rb1'Component_Size use 1;
10850 for rb2'Size use 72;
10851 for rb2'Alignment use 1;
10852 for rb2'Component_Size use 1;
10854 for x2'Size use 224;
10855 for x2'Alignment use 4;
10857 l1 at 0 range 0 .. 0;
10858 l2 at 0 range 1 .. 64;
10859 l3 at 12 range 0 .. 31;
10860 l4 at 16 range 0 .. 0;
10861 l5 at 16 range 1 .. 13;
10862 l6 at 18 range 0 .. 71;
10867 The Size values are actually the Object_Size, i.e.@: the default size that
10868 will be allocated for objects of the type.
10869 The ?? size for type r indicates that we have a variant record, and the
10870 actual size of objects will depend on the discriminant value.
10872 The Alignment values show the actual alignment chosen by the compiler
10873 for each record or array type.
10875 The record representation clause for type r shows where all fields
10876 are placed, including the compiler generated tag field (whose location
10877 cannot be controlled by the programmer).
10879 The record representation clause for the type extension r2 shows all the
10880 fields present, including the parent field, which is a copy of the fields
10881 of the parent type of r2, i.e.@: r1.
10883 The component size and size clauses for types rb1 and rb2 show
10884 the exact effect of pragma @code{Pack} on these arrays, and the record
10885 representation clause for type x2 shows how pragma @code{Pack} affects
10888 In some cases, it may be useful to cut and paste the representation clauses
10889 generated by the compiler into the original source to fix and guarantee
10890 the actual representation to be used.
10892 @node Standard Library Routines
10893 @chapter Standard Library Routines
10896 The Ada Reference Manual contains in Annex A a full description of an
10897 extensive set of standard library routines that can be used in any Ada
10898 program, and which must be provided by all Ada compilers. They are
10899 analogous to the standard C library used by C programs.
10901 GNAT implements all of the facilities described in annex A, and for most
10902 purposes the description in the Ada Reference Manual, or appropriate Ada
10903 text book, will be sufficient for making use of these facilities.
10905 In the case of the input-output facilities,
10906 @xref{The Implementation of Standard I/O},
10907 gives details on exactly how GNAT interfaces to the
10908 file system. For the remaining packages, the Ada Reference Manual
10909 should be sufficient. The following is a list of the packages included,
10910 together with a brief description of the functionality that is provided.
10912 For completeness, references are included to other predefined library
10913 routines defined in other sections of the Ada Reference Manual (these are
10914 cross-indexed from Annex A).
10918 This is a parent package for all the standard library packages. It is
10919 usually included implicitly in your program, and itself contains no
10920 useful data or routines.
10922 @item Ada.Calendar (9.6)
10923 @code{Calendar} provides time of day access, and routines for
10924 manipulating times and durations.
10926 @item Ada.Characters (A.3.1)
10927 This is a dummy parent package that contains no useful entities
10929 @item Ada.Characters.Handling (A.3.2)
10930 This package provides some basic character handling capabilities,
10931 including classification functions for classes of characters (e.g.@: test
10932 for letters, or digits).
10934 @item Ada.Characters.Latin_1 (A.3.3)
10935 This package includes a complete set of definitions of the characters
10936 that appear in type CHARACTER@. It is useful for writing programs that
10937 will run in international environments. For example, if you want an
10938 upper case E with an acute accent in a string, it is often better to use
10939 the definition of @code{UC_E_Acute} in this package. Then your program
10940 will print in an understandable manner even if your environment does not
10941 support these extended characters.
10943 @item Ada.Command_Line (A.15)
10944 This package provides access to the command line parameters and the name
10945 of the current program (analogous to the use of @code{argc} and @code{argv}
10946 in C), and also allows the exit status for the program to be set in a
10947 system-independent manner.
10949 @item Ada.Decimal (F.2)
10950 This package provides constants describing the range of decimal numbers
10951 implemented, and also a decimal divide routine (analogous to the COBOL
10952 verb DIVIDE .. GIVING .. REMAINDER ..)
10954 @item Ada.Direct_IO (A.8.4)
10955 This package provides input-output using a model of a set of records of
10956 fixed-length, containing an arbitrary definite Ada type, indexed by an
10957 integer record number.
10959 @item Ada.Dynamic_Priorities (D.5)
10960 This package allows the priorities of a task to be adjusted dynamically
10961 as the task is running.
10963 @item Ada.Exceptions (11.4.1)
10964 This package provides additional information on exceptions, and also
10965 contains facilities for treating exceptions as data objects, and raising
10966 exceptions with associated messages.
10968 @item Ada.Finalization (7.6)
10969 This package contains the declarations and subprograms to support the
10970 use of controlled types, providing for automatic initialization and
10971 finalization (analogous to the constructors and destructors of C++)
10973 @item Ada.Interrupts (C.3.2)
10974 This package provides facilities for interfacing to interrupts, which
10975 includes the set of signals or conditions that can be raised and
10976 recognized as interrupts.
10978 @item Ada.Interrupts.Names (C.3.2)
10979 This package provides the set of interrupt names (actually signal
10980 or condition names) that can be handled by GNAT@.
10982 @item Ada.IO_Exceptions (A.13)
10983 This package defines the set of exceptions that can be raised by use of
10984 the standard IO packages.
10987 This package contains some standard constants and exceptions used
10988 throughout the numerics packages. Note that the constants pi and e are
10989 defined here, and it is better to use these definitions than rolling
10992 @item Ada.Numerics.Complex_Elementary_Functions
10993 Provides the implementation of standard elementary functions (such as
10994 log and trigonometric functions) operating on complex numbers using the
10995 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10996 created by the package @code{Numerics.Complex_Types}.
10998 @item Ada.Numerics.Complex_Types
10999 This is a predefined instantiation of
11000 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11001 build the type @code{Complex} and @code{Imaginary}.
11003 @item Ada.Numerics.Discrete_Random
11004 This package provides a random number generator suitable for generating
11005 random integer values from a specified range.
11007 @item Ada.Numerics.Float_Random
11008 This package provides a random number generator suitable for generating
11009 uniformly distributed floating point values.
11011 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11012 This is a generic version of the package that provides the
11013 implementation of standard elementary functions (such as log and
11014 trigonometric functions) for an arbitrary complex type.
11016 The following predefined instantiations of this package are provided:
11020 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11022 @code{Ada.Numerics.Complex_Elementary_Functions}
11024 @code{Ada.Numerics.
11025 Long_Complex_Elementary_Functions}
11028 @item Ada.Numerics.Generic_Complex_Types
11029 This is a generic package that allows the creation of complex types,
11030 with associated complex arithmetic operations.
11032 The following predefined instantiations of this package exist
11035 @code{Ada.Numerics.Short_Complex_Complex_Types}
11037 @code{Ada.Numerics.Complex_Complex_Types}
11039 @code{Ada.Numerics.Long_Complex_Complex_Types}
11042 @item Ada.Numerics.Generic_Elementary_Functions
11043 This is a generic package that provides the implementation of standard
11044 elementary functions (such as log an trigonometric functions) for an
11045 arbitrary float type.
11047 The following predefined instantiations of this package exist
11051 @code{Ada.Numerics.Short_Elementary_Functions}
11053 @code{Ada.Numerics.Elementary_Functions}
11055 @code{Ada.Numerics.Long_Elementary_Functions}
11058 @item Ada.Real_Time (D.8)
11059 This package provides facilities similar to those of @code{Calendar}, but
11060 operating with a finer clock suitable for real time control. Note that
11061 annex D requires that there be no backward clock jumps, and GNAT generally
11062 guarantees this behavior, but of course if the external clock on which
11063 the GNAT runtime depends is deliberately reset by some external event,
11064 then such a backward jump may occur.
11066 @item Ada.Sequential_IO (A.8.1)
11067 This package provides input-output facilities for sequential files,
11068 which can contain a sequence of values of a single type, which can be
11069 any Ada type, including indefinite (unconstrained) types.
11071 @item Ada.Storage_IO (A.9)
11072 This package provides a facility for mapping arbitrary Ada types to and
11073 from a storage buffer. It is primarily intended for the creation of new
11076 @item Ada.Streams (13.13.1)
11077 This is a generic package that provides the basic support for the
11078 concept of streams as used by the stream attributes (@code{Input},
11079 @code{Output}, @code{Read} and @code{Write}).
11081 @item Ada.Streams.Stream_IO (A.12.1)
11082 This package is a specialization of the type @code{Streams} defined in
11083 package @code{Streams} together with a set of operations providing
11084 Stream_IO capability. The Stream_IO model permits both random and
11085 sequential access to a file which can contain an arbitrary set of values
11086 of one or more Ada types.
11088 @item Ada.Strings (A.4.1)
11089 This package provides some basic constants used by the string handling
11092 @item Ada.Strings.Bounded (A.4.4)
11093 This package provides facilities for handling variable length
11094 strings. The bounded model requires a maximum length. It is thus
11095 somewhat more limited than the unbounded model, but avoids the use of
11096 dynamic allocation or finalization.
11098 @item Ada.Strings.Fixed (A.4.3)
11099 This package provides facilities for handling fixed length strings.
11101 @item Ada.Strings.Maps (A.4.2)
11102 This package provides facilities for handling character mappings and
11103 arbitrarily defined subsets of characters. For instance it is useful in
11104 defining specialized translation tables.
11106 @item Ada.Strings.Maps.Constants (A.4.6)
11107 This package provides a standard set of predefined mappings and
11108 predefined character sets. For example, the standard upper to lower case
11109 conversion table is found in this package. Note that upper to lower case
11110 conversion is non-trivial if you want to take the entire set of
11111 characters, including extended characters like E with an acute accent,
11112 into account. You should use the mappings in this package (rather than
11113 adding 32 yourself) to do case mappings.
11115 @item Ada.Strings.Unbounded (A.4.5)
11116 This package provides facilities for handling variable length
11117 strings. The unbounded model allows arbitrary length strings, but
11118 requires the use of dynamic allocation and finalization.
11120 @item Ada.Strings.Wide_Bounded (A.4.7)
11121 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11122 @itemx Ada.Strings.Wide_Maps (A.4.7)
11123 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11124 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11125 These packages provide analogous capabilities to the corresponding
11126 packages without @samp{Wide_} in the name, but operate with the types
11127 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11128 and @code{Character}.
11130 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11131 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11132 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11133 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11134 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11135 These packages provide analogous capabilities to the corresponding
11136 packages without @samp{Wide_} in the name, but operate with the types
11137 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11138 of @code{String} and @code{Character}.
11140 @item Ada.Synchronous_Task_Control (D.10)
11141 This package provides some standard facilities for controlling task
11142 communication in a synchronous manner.
11145 This package contains definitions for manipulation of the tags of tagged
11148 @item Ada.Task_Attributes
11149 This package provides the capability of associating arbitrary
11150 task-specific data with separate tasks.
11153 This package provides basic text input-output capabilities for
11154 character, string and numeric data. The subpackages of this
11155 package are listed next.
11157 @item Ada.Text_IO.Decimal_IO
11158 Provides input-output facilities for decimal fixed-point types
11160 @item Ada.Text_IO.Enumeration_IO
11161 Provides input-output facilities for enumeration types.
11163 @item Ada.Text_IO.Fixed_IO
11164 Provides input-output facilities for ordinary fixed-point types.
11166 @item Ada.Text_IO.Float_IO
11167 Provides input-output facilities for float types. The following
11168 predefined instantiations of this generic package are available:
11172 @code{Short_Float_Text_IO}
11174 @code{Float_Text_IO}
11176 @code{Long_Float_Text_IO}
11179 @item Ada.Text_IO.Integer_IO
11180 Provides input-output facilities for integer types. The following
11181 predefined instantiations of this generic package are available:
11184 @item Short_Short_Integer
11185 @code{Ada.Short_Short_Integer_Text_IO}
11186 @item Short_Integer
11187 @code{Ada.Short_Integer_Text_IO}
11189 @code{Ada.Integer_Text_IO}
11191 @code{Ada.Long_Integer_Text_IO}
11192 @item Long_Long_Integer
11193 @code{Ada.Long_Long_Integer_Text_IO}
11196 @item Ada.Text_IO.Modular_IO
11197 Provides input-output facilities for modular (unsigned) types
11199 @item Ada.Text_IO.Complex_IO (G.1.3)
11200 This package provides basic text input-output capabilities for complex
11203 @item Ada.Text_IO.Editing (F.3.3)
11204 This package contains routines for edited output, analogous to the use
11205 of pictures in COBOL@. The picture formats used by this package are a
11206 close copy of the facility in COBOL@.
11208 @item Ada.Text_IO.Text_Streams (A.12.2)
11209 This package provides a facility that allows Text_IO files to be treated
11210 as streams, so that the stream attributes can be used for writing
11211 arbitrary data, including binary data, to Text_IO files.
11213 @item Ada.Unchecked_Conversion (13.9)
11214 This generic package allows arbitrary conversion from one type to
11215 another of the same size, providing for breaking the type safety in
11216 special circumstances.
11218 If the types have the same Size (more accurately the same Value_Size),
11219 then the effect is simply to transfer the bits from the source to the
11220 target type without any modification. This usage is well defined, and
11221 for simple types whose representation is typically the same across
11222 all implementations, gives a portable method of performing such
11225 If the types do not have the same size, then the result is implementation
11226 defined, and thus may be non-portable. The following describes how GNAT
11227 handles such unchecked conversion cases.
11229 If the types are of different sizes, and are both discrete types, then
11230 the effect is of a normal type conversion without any constraint checking.
11231 In particular if the result type has a larger size, the result will be
11232 zero or sign extended. If the result type has a smaller size, the result
11233 will be truncated by ignoring high order bits.
11235 If the types are of different sizes, and are not both discrete types,
11236 then the conversion works as though pointers were created to the source
11237 and target, and the pointer value is converted. The effect is that bits
11238 are copied from successive low order storage units and bits of the source
11239 up to the length of the target type.
11241 A warning is issued if the lengths differ, since the effect in this
11242 case is implementation dependent, and the above behavior may not match
11243 that of some other compiler.
11245 A pointer to one type may be converted to a pointer to another type using
11246 unchecked conversion. The only case in which the effect is undefined is
11247 when one or both pointers are pointers to unconstrained array types. In
11248 this case, the bounds information may get incorrectly transferred, and in
11249 particular, GNAT uses double size pointers for such types, and it is
11250 meaningless to convert between such pointer types. GNAT will issue a
11251 warning if the alignment of the target designated type is more strict
11252 than the alignment of the source designated type (since the result may
11253 be unaligned in this case).
11255 A pointer other than a pointer to an unconstrained array type may be
11256 converted to and from System.Address. Such usage is common in Ada 83
11257 programs, but note that Ada.Address_To_Access_Conversions is the
11258 preferred method of performing such conversions in Ada 95 and Ada 2005.
11260 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11261 used in conjunction with pointers to unconstrained objects, since
11262 the bounds information cannot be handled correctly in this case.
11264 @item Ada.Unchecked_Deallocation (13.11.2)
11265 This generic package allows explicit freeing of storage previously
11266 allocated by use of an allocator.
11268 @item Ada.Wide_Text_IO (A.11)
11269 This package is similar to @code{Ada.Text_IO}, except that the external
11270 file supports wide character representations, and the internal types are
11271 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11272 and @code{String}. It contains generic subpackages listed next.
11274 @item Ada.Wide_Text_IO.Decimal_IO
11275 Provides input-output facilities for decimal fixed-point types
11277 @item Ada.Wide_Text_IO.Enumeration_IO
11278 Provides input-output facilities for enumeration types.
11280 @item Ada.Wide_Text_IO.Fixed_IO
11281 Provides input-output facilities for ordinary fixed-point types.
11283 @item Ada.Wide_Text_IO.Float_IO
11284 Provides input-output facilities for float types. The following
11285 predefined instantiations of this generic package are available:
11289 @code{Short_Float_Wide_Text_IO}
11291 @code{Float_Wide_Text_IO}
11293 @code{Long_Float_Wide_Text_IO}
11296 @item Ada.Wide_Text_IO.Integer_IO
11297 Provides input-output facilities for integer types. The following
11298 predefined instantiations of this generic package are available:
11301 @item Short_Short_Integer
11302 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11303 @item Short_Integer
11304 @code{Ada.Short_Integer_Wide_Text_IO}
11306 @code{Ada.Integer_Wide_Text_IO}
11308 @code{Ada.Long_Integer_Wide_Text_IO}
11309 @item Long_Long_Integer
11310 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11313 @item Ada.Wide_Text_IO.Modular_IO
11314 Provides input-output facilities for modular (unsigned) types
11316 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11317 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11318 external file supports wide character representations.
11320 @item Ada.Wide_Text_IO.Editing (F.3.4)
11321 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11322 types are @code{Wide_Character} and @code{Wide_String} instead of
11323 @code{Character} and @code{String}.
11325 @item Ada.Wide_Text_IO.Streams (A.12.3)
11326 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11327 types are @code{Wide_Character} and @code{Wide_String} instead of
11328 @code{Character} and @code{String}.
11330 @item Ada.Wide_Wide_Text_IO (A.11)
11331 This package is similar to @code{Ada.Text_IO}, except that the external
11332 file supports wide character representations, and the internal types are
11333 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11334 and @code{String}. It contains generic subpackages listed next.
11336 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11337 Provides input-output facilities for decimal fixed-point types
11339 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11340 Provides input-output facilities for enumeration types.
11342 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11343 Provides input-output facilities for ordinary fixed-point types.
11345 @item Ada.Wide_Wide_Text_IO.Float_IO
11346 Provides input-output facilities for float types. The following
11347 predefined instantiations of this generic package are available:
11351 @code{Short_Float_Wide_Wide_Text_IO}
11353 @code{Float_Wide_Wide_Text_IO}
11355 @code{Long_Float_Wide_Wide_Text_IO}
11358 @item Ada.Wide_Wide_Text_IO.Integer_IO
11359 Provides input-output facilities for integer types. The following
11360 predefined instantiations of this generic package are available:
11363 @item Short_Short_Integer
11364 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
11365 @item Short_Integer
11366 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
11368 @code{Ada.Integer_Wide_Wide_Text_IO}
11370 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
11371 @item Long_Long_Integer
11372 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
11375 @item Ada.Wide_Wide_Text_IO.Modular_IO
11376 Provides input-output facilities for modular (unsigned) types
11378 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
11379 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11380 external file supports wide character representations.
11382 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
11383 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11384 types are @code{Wide_Character} and @code{Wide_String} instead of
11385 @code{Character} and @code{String}.
11387 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
11388 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11389 types are @code{Wide_Character} and @code{Wide_String} instead of
11390 @code{Character} and @code{String}.
11395 @node The Implementation of Standard I/O
11396 @chapter The Implementation of Standard I/O
11399 GNAT implements all the required input-output facilities described in
11400 A.6 through A.14. These sections of the Ada Reference Manual describe the
11401 required behavior of these packages from the Ada point of view, and if
11402 you are writing a portable Ada program that does not need to know the
11403 exact manner in which Ada maps to the outside world when it comes to
11404 reading or writing external files, then you do not need to read this
11405 chapter. As long as your files are all regular files (not pipes or
11406 devices), and as long as you write and read the files only from Ada, the
11407 description in the Ada Reference Manual is sufficient.
11409 However, if you want to do input-output to pipes or other devices, such
11410 as the keyboard or screen, or if the files you are dealing with are
11411 either generated by some other language, or to be read by some other
11412 language, then you need to know more about the details of how the GNAT
11413 implementation of these input-output facilities behaves.
11415 In this chapter we give a detailed description of exactly how GNAT
11416 interfaces to the file system. As always, the sources of the system are
11417 available to you for answering questions at an even more detailed level,
11418 but for most purposes the information in this chapter will suffice.
11420 Another reason that you may need to know more about how input-output is
11421 implemented arises when you have a program written in mixed languages
11422 where, for example, files are shared between the C and Ada sections of
11423 the same program. GNAT provides some additional facilities, in the form
11424 of additional child library packages, that facilitate this sharing, and
11425 these additional facilities are also described in this chapter.
11428 * Standard I/O Packages::
11434 * Wide_Wide_Text_IO::
11437 * Filenames encoding::
11439 * Operations on C Streams::
11440 * Interfacing to C Streams::
11443 @node Standard I/O Packages
11444 @section Standard I/O Packages
11447 The Standard I/O packages described in Annex A for
11453 Ada.Text_IO.Complex_IO
11455 Ada.Text_IO.Text_Streams
11459 Ada.Wide_Text_IO.Complex_IO
11461 Ada.Wide_Text_IO.Text_Streams
11463 Ada.Wide_Wide_Text_IO
11465 Ada.Wide_Wide_Text_IO.Complex_IO
11467 Ada.Wide_Wide_Text_IO.Text_Streams
11477 are implemented using the C
11478 library streams facility; where
11482 All files are opened using @code{fopen}.
11484 All input/output operations use @code{fread}/@code{fwrite}.
11488 There is no internal buffering of any kind at the Ada library level. The only
11489 buffering is that provided at the system level in the implementation of the
11490 library routines that support streams. This facilitates shared use of these
11491 streams by mixed language programs. Note though that system level buffering is
11492 explicitly enabled at elaboration of the standard I/O packages and that can
11493 have an impact on mixed language programs, in particular those using I/O before
11494 calling the Ada elaboration routine (e.g. adainit). It is recommended to call
11495 the Ada elaboration routine before performing any I/O or when impractical,
11496 flush the common I/O streams and in particular Standard_Output before
11497 elaborating the Ada code.
11500 @section FORM Strings
11503 The format of a FORM string in GNAT is:
11506 "keyword=value,keyword=value,@dots{},keyword=value"
11510 where letters may be in upper or lower case, and there are no spaces
11511 between values. The order of the entries is not important. Currently
11512 there are two keywords defined.
11516 WCEM=[n|h|u|s|e|8|b]
11520 The use of these parameters is described later in this section.
11526 Direct_IO can only be instantiated for definite types. This is a
11527 restriction of the Ada language, which means that the records are fixed
11528 length (the length being determined by @code{@var{type}'Size}, rounded
11529 up to the next storage unit boundary if necessary).
11531 The records of a Direct_IO file are simply written to the file in index
11532 sequence, with the first record starting at offset zero, and subsequent
11533 records following. There is no control information of any kind. For
11534 example, if 32-bit integers are being written, each record takes
11535 4-bytes, so the record at index @var{K} starts at offset
11536 (@var{K}@minus{}1)*4.
11538 There is no limit on the size of Direct_IO files, they are expanded as
11539 necessary to accommodate whatever records are written to the file.
11541 @node Sequential_IO
11542 @section Sequential_IO
11545 Sequential_IO may be instantiated with either a definite (constrained)
11546 or indefinite (unconstrained) type.
11548 For the definite type case, the elements written to the file are simply
11549 the memory images of the data values with no control information of any
11550 kind. The resulting file should be read using the same type, no validity
11551 checking is performed on input.
11553 For the indefinite type case, the elements written consist of two
11554 parts. First is the size of the data item, written as the memory image
11555 of a @code{Interfaces.C.size_t} value, followed by the memory image of
11556 the data value. The resulting file can only be read using the same
11557 (unconstrained) type. Normal assignment checks are performed on these
11558 read operations, and if these checks fail, @code{Data_Error} is
11559 raised. In particular, in the array case, the lengths must match, and in
11560 the variant record case, if the variable for a particular read operation
11561 is constrained, the discriminants must match.
11563 Note that it is not possible to use Sequential_IO to write variable
11564 length array items, and then read the data back into different length
11565 arrays. For example, the following will raise @code{Data_Error}:
11567 @smallexample @c ada
11568 package IO is new Sequential_IO (String);
11573 IO.Write (F, "hello!")
11574 IO.Reset (F, Mode=>In_File);
11581 On some Ada implementations, this will print @code{hell}, but the program is
11582 clearly incorrect, since there is only one element in the file, and that
11583 element is the string @code{hello!}.
11585 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
11586 using Stream_IO, and this is the preferred mechanism. In particular, the
11587 above program fragment rewritten to use Stream_IO will work correctly.
11593 Text_IO files consist of a stream of characters containing the following
11594 special control characters:
11597 LF (line feed, 16#0A#) Line Mark
11598 FF (form feed, 16#0C#) Page Mark
11602 A canonical Text_IO file is defined as one in which the following
11603 conditions are met:
11607 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
11611 The character @code{FF} is used only as a page mark, i.e.@: to mark the
11612 end of a page and consequently can appear only immediately following a
11613 @code{LF} (line mark) character.
11616 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
11617 (line mark, page mark). In the former case, the page mark is implicitly
11618 assumed to be present.
11622 A file written using Text_IO will be in canonical form provided that no
11623 explicit @code{LF} or @code{FF} characters are written using @code{Put}
11624 or @code{Put_Line}. There will be no @code{FF} character at the end of
11625 the file unless an explicit @code{New_Page} operation was performed
11626 before closing the file.
11628 A canonical Text_IO file that is a regular file (i.e., not a device or a
11629 pipe) can be read using any of the routines in Text_IO@. The
11630 semantics in this case will be exactly as defined in the Ada Reference
11631 Manual, and all the routines in Text_IO are fully implemented.
11633 A text file that does not meet the requirements for a canonical Text_IO
11634 file has one of the following:
11638 The file contains @code{FF} characters not immediately following a
11639 @code{LF} character.
11642 The file contains @code{LF} or @code{FF} characters written by
11643 @code{Put} or @code{Put_Line}, which are not logically considered to be
11644 line marks or page marks.
11647 The file ends in a character other than @code{LF} or @code{FF},
11648 i.e.@: there is no explicit line mark or page mark at the end of the file.
11652 Text_IO can be used to read such non-standard text files but subprograms
11653 to do with line or page numbers do not have defined meanings. In
11654 particular, a @code{FF} character that does not follow a @code{LF}
11655 character may or may not be treated as a page mark from the point of
11656 view of page and line numbering. Every @code{LF} character is considered
11657 to end a line, and there is an implied @code{LF} character at the end of
11661 * Text_IO Stream Pointer Positioning::
11662 * Text_IO Reading and Writing Non-Regular Files::
11664 * Treating Text_IO Files as Streams::
11665 * Text_IO Extensions::
11666 * Text_IO Facilities for Unbounded Strings::
11669 @node Text_IO Stream Pointer Positioning
11670 @subsection Stream Pointer Positioning
11673 @code{Ada.Text_IO} has a definition of current position for a file that
11674 is being read. No internal buffering occurs in Text_IO, and usually the
11675 physical position in the stream used to implement the file corresponds
11676 to this logical position defined by Text_IO@. There are two exceptions:
11680 After a call to @code{End_Of_Page} that returns @code{True}, the stream
11681 is positioned past the @code{LF} (line mark) that precedes the page
11682 mark. Text_IO maintains an internal flag so that subsequent read
11683 operations properly handle the logical position which is unchanged by
11684 the @code{End_Of_Page} call.
11687 After a call to @code{End_Of_File} that returns @code{True}, if the
11688 Text_IO file was positioned before the line mark at the end of file
11689 before the call, then the logical position is unchanged, but the stream
11690 is physically positioned right at the end of file (past the line mark,
11691 and past a possible page mark following the line mark. Again Text_IO
11692 maintains internal flags so that subsequent read operations properly
11693 handle the logical position.
11697 These discrepancies have no effect on the observable behavior of
11698 Text_IO, but if a single Ada stream is shared between a C program and
11699 Ada program, or shared (using @samp{shared=yes} in the form string)
11700 between two Ada files, then the difference may be observable in some
11703 @node Text_IO Reading and Writing Non-Regular Files
11704 @subsection Reading and Writing Non-Regular Files
11707 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
11708 can be used for reading and writing. Writing is not affected and the
11709 sequence of characters output is identical to the normal file case, but
11710 for reading, the behavior of Text_IO is modified to avoid undesirable
11711 look-ahead as follows:
11713 An input file that is not a regular file is considered to have no page
11714 marks. Any @code{Ascii.FF} characters (the character normally used for a
11715 page mark) appearing in the file are considered to be data
11716 characters. In particular:
11720 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
11721 following a line mark. If a page mark appears, it will be treated as a
11725 This avoids the need to wait for an extra character to be typed or
11726 entered from the pipe to complete one of these operations.
11729 @code{End_Of_Page} always returns @code{False}
11732 @code{End_Of_File} will return @code{False} if there is a page mark at
11733 the end of the file.
11737 Output to non-regular files is the same as for regular files. Page marks
11738 may be written to non-regular files using @code{New_Page}, but as noted
11739 above they will not be treated as page marks on input if the output is
11740 piped to another Ada program.
11742 Another important discrepancy when reading non-regular files is that the end
11743 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
11744 pressing the @key{EOT} key,
11746 is signaled once (i.e.@: the test @code{End_Of_File}
11747 will yield @code{True}, or a read will
11748 raise @code{End_Error}), but then reading can resume
11749 to read data past that end of
11750 file indication, until another end of file indication is entered.
11752 @node Get_Immediate
11753 @subsection Get_Immediate
11754 @cindex Get_Immediate
11757 Get_Immediate returns the next character (including control characters)
11758 from the input file. In particular, Get_Immediate will return LF or FF
11759 characters used as line marks or page marks. Such operations leave the
11760 file positioned past the control character, and it is thus not treated
11761 as having its normal function. This means that page, line and column
11762 counts after this kind of Get_Immediate call are set as though the mark
11763 did not occur. In the case where a Get_Immediate leaves the file
11764 positioned between the line mark and page mark (which is not normally
11765 possible), it is undefined whether the FF character will be treated as a
11768 @node Treating Text_IO Files as Streams
11769 @subsection Treating Text_IO Files as Streams
11770 @cindex Stream files
11773 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11774 as a stream. Data written to a Text_IO file in this stream mode is
11775 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
11776 16#0C# (@code{FF}), the resulting file may have non-standard
11777 format. Similarly if read operations are used to read from a Text_IO
11778 file treated as a stream, then @code{LF} and @code{FF} characters may be
11779 skipped and the effect is similar to that described above for
11780 @code{Get_Immediate}.
11782 @node Text_IO Extensions
11783 @subsection Text_IO Extensions
11784 @cindex Text_IO extensions
11787 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11788 to the standard @code{Text_IO} package:
11791 @item function File_Exists (Name : String) return Boolean;
11792 Determines if a file of the given name exists.
11794 @item function Get_Line return String;
11795 Reads a string from the standard input file. The value returned is exactly
11796 the length of the line that was read.
11798 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11799 Similar, except that the parameter File specifies the file from which
11800 the string is to be read.
11804 @node Text_IO Facilities for Unbounded Strings
11805 @subsection Text_IO Facilities for Unbounded Strings
11806 @cindex Text_IO for unbounded strings
11807 @cindex Unbounded_String, Text_IO operations
11810 The package @code{Ada.Strings.Unbounded.Text_IO}
11811 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11812 subprograms useful for Text_IO operations on unbounded strings:
11816 @item function Get_Line (File : File_Type) return Unbounded_String;
11817 Reads a line from the specified file
11818 and returns the result as an unbounded string.
11820 @item procedure Put (File : File_Type; U : Unbounded_String);
11821 Writes the value of the given unbounded string to the specified file
11822 Similar to the effect of
11823 @code{Put (To_String (U))} except that an extra copy is avoided.
11825 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11826 Writes the value of the given unbounded string to the specified file,
11827 followed by a @code{New_Line}.
11828 Similar to the effect of @code{Put_Line (To_String (U))} except
11829 that an extra copy is avoided.
11833 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11834 and is optional. If the parameter is omitted, then the standard input or
11835 output file is referenced as appropriate.
11837 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11838 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11839 @code{Wide_Text_IO} functionality for unbounded wide strings.
11841 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11842 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11843 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11846 @section Wide_Text_IO
11849 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11850 both input and output files may contain special sequences that represent
11851 wide character values. The encoding scheme for a given file may be
11852 specified using a FORM parameter:
11859 as part of the FORM string (WCEM = wide character encoding method),
11860 where @var{x} is one of the following characters
11866 Upper half encoding
11878 The encoding methods match those that
11879 can be used in a source
11880 program, but there is no requirement that the encoding method used for
11881 the source program be the same as the encoding method used for files,
11882 and different files may use different encoding methods.
11884 The default encoding method for the standard files, and for opened files
11885 for which no WCEM parameter is given in the FORM string matches the
11886 wide character encoding specified for the main program (the default
11887 being brackets encoding if no coding method was specified with -gnatW).
11891 In this encoding, a wide character is represented by a five character
11899 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
11900 characters (using upper case letters) of the wide character code. For
11901 example, ESC A345 is used to represent the wide character with code
11902 16#A345#. This scheme is compatible with use of the full
11903 @code{Wide_Character} set.
11905 @item Upper Half Coding
11906 The wide character with encoding 16#abcd#, where the upper bit is on
11907 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
11908 16#cd#. The second byte may never be a format control character, but is
11909 not required to be in the upper half. This method can be also used for
11910 shift-JIS or EUC where the internal coding matches the external coding.
11912 @item Shift JIS Coding
11913 A wide character is represented by a two character sequence 16#ab# and
11914 16#cd#, with the restrictions described for upper half encoding as
11915 described above. The internal character code is the corresponding JIS
11916 character according to the standard algorithm for Shift-JIS
11917 conversion. Only characters defined in the JIS code set table can be
11918 used with this encoding method.
11921 A wide character is represented by a two character sequence 16#ab# and
11922 16#cd#, with both characters being in the upper half. The internal
11923 character code is the corresponding JIS character according to the EUC
11924 encoding algorithm. Only characters defined in the JIS code set table
11925 can be used with this encoding method.
11928 A wide character is represented using
11929 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11930 10646-1/Am.2. Depending on the character value, the representation
11931 is a one, two, or three byte sequence:
11934 16#0000#-16#007f#: 2#0xxxxxxx#
11935 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
11936 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11940 where the xxx bits correspond to the left-padded bits of the
11941 16-bit character value. Note that all lower half ASCII characters
11942 are represented as ASCII bytes and all upper half characters and
11943 other wide characters are represented as sequences of upper-half
11944 (The full UTF-8 scheme allows for encoding 31-bit characters as
11945 6-byte sequences, but in this implementation, all UTF-8 sequences
11946 of four or more bytes length will raise a Constraint_Error, as
11947 will all invalid UTF-8 sequences.)
11949 @item Brackets Coding
11950 In this encoding, a wide character is represented by the following eight
11951 character sequence:
11958 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11959 characters (using uppercase letters) of the wide character code. For
11960 example, @code{["A345"]} is used to represent the wide character with code
11962 This scheme is compatible with use of the full Wide_Character set.
11963 On input, brackets coding can also be used for upper half characters,
11964 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
11965 is only used for wide characters with a code greater than @code{16#FF#}.
11967 Note that brackets coding is not normally used in the context of
11968 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
11969 a portable way of encoding source files. In the context of Wide_Text_IO
11970 or Wide_Wide_Text_IO, it can only be used if the file does not contain
11971 any instance of the left bracket character other than to encode wide
11972 character values using the brackets encoding method. In practice it is
11973 expected that some standard wide character encoding method such
11974 as UTF-8 will be used for text input output.
11976 If brackets notation is used, then any occurrence of a left bracket
11977 in the input file which is not the start of a valid wide character
11978 sequence will cause Constraint_Error to be raised. It is possible to
11979 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
11980 input will interpret this as a left bracket.
11982 However, when a left bracket is output, it will be output as a left bracket
11983 and not as ["5B"]. We make this decision because for normal use of
11984 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
11985 brackets. For example, if we write:
11988 Put_Line ("Start of output [first run]");
11992 we really do not want to have the left bracket in this message clobbered so
11993 that the output reads:
11996 Start of output ["5B"]first run]
12000 In practice brackets encoding is reasonably useful for normal Put_Line use
12001 since we won't get confused between left brackets and wide character
12002 sequences in the output. But for input, or when files are written out
12003 and read back in, it really makes better sense to use one of the standard
12004 encoding methods such as UTF-8.
12009 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12010 not all wide character
12011 values can be represented. An attempt to output a character that cannot
12012 be represented using the encoding scheme for the file causes
12013 Constraint_Error to be raised. An invalid wide character sequence on
12014 input also causes Constraint_Error to be raised.
12017 * Wide_Text_IO Stream Pointer Positioning::
12018 * Wide_Text_IO Reading and Writing Non-Regular Files::
12021 @node Wide_Text_IO Stream Pointer Positioning
12022 @subsection Stream Pointer Positioning
12025 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12026 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12029 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12030 normal lower ASCII set (i.e.@: a character in the range:
12032 @smallexample @c ada
12033 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12037 then although the logical position of the file pointer is unchanged by
12038 the @code{Look_Ahead} call, the stream is physically positioned past the
12039 wide character sequence. Again this is to avoid the need for buffering
12040 or backup, and all @code{Wide_Text_IO} routines check the internal
12041 indication that this situation has occurred so that this is not visible
12042 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
12043 can be observed if the wide text file shares a stream with another file.
12045 @node Wide_Text_IO Reading and Writing Non-Regular Files
12046 @subsection Reading and Writing Non-Regular Files
12049 As in the case of Text_IO, when a non-regular file is read, it is
12050 assumed that the file contains no page marks (any form characters are
12051 treated as data characters), and @code{End_Of_Page} always returns
12052 @code{False}. Similarly, the end of file indication is not sticky, so
12053 it is possible to read beyond an end of file.
12055 @node Wide_Wide_Text_IO
12056 @section Wide_Wide_Text_IO
12059 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12060 both input and output files may contain special sequences that represent
12061 wide wide character values. The encoding scheme for a given file may be
12062 specified using a FORM parameter:
12069 as part of the FORM string (WCEM = wide character encoding method),
12070 where @var{x} is one of the following characters
12076 Upper half encoding
12088 The encoding methods match those that
12089 can be used in a source
12090 program, but there is no requirement that the encoding method used for
12091 the source program be the same as the encoding method used for files,
12092 and different files may use different encoding methods.
12094 The default encoding method for the standard files, and for opened files
12095 for which no WCEM parameter is given in the FORM string matches the
12096 wide character encoding specified for the main program (the default
12097 being brackets encoding if no coding method was specified with -gnatW).
12102 A wide character is represented using
12103 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12104 10646-1/Am.2. Depending on the character value, the representation
12105 is a one, two, three, or four byte sequence:
12108 16#000000#-16#00007f#: 2#0xxxxxxx#
12109 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12110 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12111 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12115 where the xxx bits correspond to the left-padded bits of the
12116 21-bit character value. Note that all lower half ASCII characters
12117 are represented as ASCII bytes and all upper half characters and
12118 other wide characters are represented as sequences of upper-half
12121 @item Brackets Coding
12122 In this encoding, a wide wide character is represented by the following eight
12123 character sequence if is in wide character range
12129 and by the following ten character sequence if not
12132 [ " a b c d e f " ]
12136 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12137 are the four or six hexadecimal
12138 characters (using uppercase letters) of the wide wide character code. For
12139 example, @code{["01A345"]} is used to represent the wide wide character
12140 with code @code{16#01A345#}.
12142 This scheme is compatible with use of the full Wide_Wide_Character set.
12143 On input, brackets coding can also be used for upper half characters,
12144 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12145 is only used for wide characters with a code greater than @code{16#FF#}.
12150 If is also possible to use the other Wide_Character encoding methods,
12151 such as Shift-JIS, but the other schemes cannot support the full range
12152 of wide wide characters.
12153 An attempt to output a character that cannot
12154 be represented using the encoding scheme for the file causes
12155 Constraint_Error to be raised. An invalid wide character sequence on
12156 input also causes Constraint_Error to be raised.
12159 * Wide_Wide_Text_IO Stream Pointer Positioning::
12160 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12163 @node Wide_Wide_Text_IO Stream Pointer Positioning
12164 @subsection Stream Pointer Positioning
12167 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12168 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12171 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12172 normal lower ASCII set (i.e.@: a character in the range:
12174 @smallexample @c ada
12175 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12179 then although the logical position of the file pointer is unchanged by
12180 the @code{Look_Ahead} call, the stream is physically positioned past the
12181 wide character sequence. Again this is to avoid the need for buffering
12182 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12183 indication that this situation has occurred so that this is not visible
12184 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
12185 can be observed if the wide text file shares a stream with another file.
12187 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12188 @subsection Reading and Writing Non-Regular Files
12191 As in the case of Text_IO, when a non-regular file is read, it is
12192 assumed that the file contains no page marks (any form characters are
12193 treated as data characters), and @code{End_Of_Page} always returns
12194 @code{False}. Similarly, the end of file indication is not sticky, so
12195 it is possible to read beyond an end of file.
12201 A stream file is a sequence of bytes, where individual elements are
12202 written to the file as described in the Ada Reference Manual. The type
12203 @code{Stream_Element} is simply a byte. There are two ways to read or
12204 write a stream file.
12208 The operations @code{Read} and @code{Write} directly read or write a
12209 sequence of stream elements with no control information.
12212 The stream attributes applied to a stream file transfer data in the
12213 manner described for stream attributes.
12217 @section Shared Files
12220 Section A.14 of the Ada Reference Manual allows implementations to
12221 provide a wide variety of behavior if an attempt is made to access the
12222 same external file with two or more internal files.
12224 To provide a full range of functionality, while at the same time
12225 minimizing the problems of portability caused by this implementation
12226 dependence, GNAT handles file sharing as follows:
12230 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12231 to open two or more files with the same full name is considered an error
12232 and is not supported. The exception @code{Use_Error} will be
12233 raised. Note that a file that is not explicitly closed by the program
12234 remains open until the program terminates.
12237 If the form parameter @samp{shared=no} appears in the form string, the
12238 file can be opened or created with its own separate stream identifier,
12239 regardless of whether other files sharing the same external file are
12240 opened. The exact effect depends on how the C stream routines handle
12241 multiple accesses to the same external files using separate streams.
12244 If the form parameter @samp{shared=yes} appears in the form string for
12245 each of two or more files opened using the same full name, the same
12246 stream is shared between these files, and the semantics are as described
12247 in Ada Reference Manual, Section A.14.
12251 When a program that opens multiple files with the same name is ported
12252 from another Ada compiler to GNAT, the effect will be that
12253 @code{Use_Error} is raised.
12255 The documentation of the original compiler and the documentation of the
12256 program should then be examined to determine if file sharing was
12257 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12258 and @code{Create} calls as required.
12260 When a program is ported from GNAT to some other Ada compiler, no
12261 special attention is required unless the @samp{shared=@var{xxx}} form
12262 parameter is used in the program. In this case, you must examine the
12263 documentation of the new compiler to see if it supports the required
12264 file sharing semantics, and form strings modified appropriately. Of
12265 course it may be the case that the program cannot be ported if the
12266 target compiler does not support the required functionality. The best
12267 approach in writing portable code is to avoid file sharing (and hence
12268 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12271 One common use of file sharing in Ada 83 is the use of instantiations of
12272 Sequential_IO on the same file with different types, to achieve
12273 heterogeneous input-output. Although this approach will work in GNAT if
12274 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12275 for this purpose (using the stream attributes)
12277 @node Filenames encoding
12278 @section Filenames encoding
12281 An encoding form parameter can be used to specify the filename
12282 encoding @samp{encoding=@var{xxx}}.
12286 If the form parameter @samp{encoding=utf8} appears in the form string, the
12287 filename must be encoded in UTF-8.
12290 If the form parameter @samp{encoding=8bits} appears in the form
12291 string, the filename must be a standard 8bits string.
12294 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12295 value UTF-8 is used. This encoding form parameter is only supported on
12296 the Windows platform. On the other Operating Systems the runtime is
12297 supporting UTF-8 natively.
12300 @section Open Modes
12303 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12304 using the mode shown in the following table:
12307 @center @code{Open} and @code{Create} Call Modes
12309 @b{OPEN } @b{CREATE}
12310 Append_File "r+" "w+"
12312 Out_File (Direct_IO) "r+" "w"
12313 Out_File (all other cases) "w" "w"
12314 Inout_File "r+" "w+"
12318 If text file translation is required, then either @samp{b} or @samp{t}
12319 is added to the mode, depending on the setting of Text. Text file
12320 translation refers to the mapping of CR/LF sequences in an external file
12321 to LF characters internally. This mapping only occurs in DOS and
12322 DOS-like systems, and is not relevant to other systems.
12324 A special case occurs with Stream_IO@. As shown in the above table, the
12325 file is initially opened in @samp{r} or @samp{w} mode for the
12326 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
12327 subsequently requires switching from reading to writing or vice-versa,
12328 then the file is reopened in @samp{r+} mode to permit the required operation.
12330 @node Operations on C Streams
12331 @section Operations on C Streams
12332 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12333 access to the C library functions for operations on C streams:
12335 @smallexample @c adanocomment
12336 package Interfaces.C_Streams is
12337 -- Note: the reason we do not use the types that are in
12338 -- Interfaces.C is that we want to avoid dragging in the
12339 -- code in this unit if possible.
12340 subtype chars is System.Address;
12341 -- Pointer to null-terminated array of characters
12342 subtype FILEs is System.Address;
12343 -- Corresponds to the C type FILE*
12344 subtype voids is System.Address;
12345 -- Corresponds to the C type void*
12346 subtype int is Integer;
12347 subtype long is Long_Integer;
12348 -- Note: the above types are subtypes deliberately, and it
12349 -- is part of this spec that the above correspondences are
12350 -- guaranteed. This means that it is legitimate to, for
12351 -- example, use Integer instead of int. We provide these
12352 -- synonyms for clarity, but in some cases it may be
12353 -- convenient to use the underlying types (for example to
12354 -- avoid an unnecessary dependency of a spec on the spec
12356 type size_t is mod 2 ** Standard'Address_Size;
12357 NULL_Stream : constant FILEs;
12358 -- Value returned (NULL in C) to indicate an
12359 -- fdopen/fopen/tmpfile error
12360 ----------------------------------
12361 -- Constants Defined in stdio.h --
12362 ----------------------------------
12363 EOF : constant int;
12364 -- Used by a number of routines to indicate error or
12366 IOFBF : constant int;
12367 IOLBF : constant int;
12368 IONBF : constant int;
12369 -- Used to indicate buffering mode for setvbuf call
12370 SEEK_CUR : constant int;
12371 SEEK_END : constant int;
12372 SEEK_SET : constant int;
12373 -- Used to indicate origin for fseek call
12374 function stdin return FILEs;
12375 function stdout return FILEs;
12376 function stderr return FILEs;
12377 -- Streams associated with standard files
12378 --------------------------
12379 -- Standard C functions --
12380 --------------------------
12381 -- The functions selected below are ones that are
12382 -- available in DOS, OS/2, UNIX and Xenix (but not
12383 -- necessarily in ANSI C). These are very thin interfaces
12384 -- which copy exactly the C headers. For more
12385 -- documentation on these functions, see the Microsoft C
12386 -- "Run-Time Library Reference" (Microsoft Press, 1990,
12387 -- ISBN 1-55615-225-6), which includes useful information
12388 -- on system compatibility.
12389 procedure clearerr (stream : FILEs);
12390 function fclose (stream : FILEs) return int;
12391 function fdopen (handle : int; mode : chars) return FILEs;
12392 function feof (stream : FILEs) return int;
12393 function ferror (stream : FILEs) return int;
12394 function fflush (stream : FILEs) return int;
12395 function fgetc (stream : FILEs) return int;
12396 function fgets (strng : chars; n : int; stream : FILEs)
12398 function fileno (stream : FILEs) return int;
12399 function fopen (filename : chars; Mode : chars)
12401 -- Note: to maintain target independence, use
12402 -- text_translation_required, a boolean variable defined in
12403 -- a-sysdep.c to deal with the target dependent text
12404 -- translation requirement. If this variable is set,
12405 -- then b/t should be appended to the standard mode
12406 -- argument to set the text translation mode off or on
12408 function fputc (C : int; stream : FILEs) return int;
12409 function fputs (Strng : chars; Stream : FILEs) return int;
12426 function ftell (stream : FILEs) return long;
12433 function isatty (handle : int) return int;
12434 procedure mktemp (template : chars);
12435 -- The return value (which is just a pointer to template)
12437 procedure rewind (stream : FILEs);
12438 function rmtmp return int;
12446 function tmpfile return FILEs;
12447 function ungetc (c : int; stream : FILEs) return int;
12448 function unlink (filename : chars) return int;
12449 ---------------------
12450 -- Extra functions --
12451 ---------------------
12452 -- These functions supply slightly thicker bindings than
12453 -- those above. They are derived from functions in the
12454 -- C Run-Time Library, but may do a bit more work than
12455 -- just directly calling one of the Library functions.
12456 function is_regular_file (handle : int) return int;
12457 -- Tests if given handle is for a regular file (result 1)
12458 -- or for a non-regular file (pipe or device, result 0).
12459 ---------------------------------
12460 -- Control of Text/Binary Mode --
12461 ---------------------------------
12462 -- If text_translation_required is true, then the following
12463 -- functions may be used to dynamically switch a file from
12464 -- binary to text mode or vice versa. These functions have
12465 -- no effect if text_translation_required is false (i.e. in
12466 -- normal UNIX mode). Use fileno to get a stream handle.
12467 procedure set_binary_mode (handle : int);
12468 procedure set_text_mode (handle : int);
12469 ----------------------------
12470 -- Full Path Name support --
12471 ----------------------------
12472 procedure full_name (nam : chars; buffer : chars);
12473 -- Given a NUL terminated string representing a file
12474 -- name, returns in buffer a NUL terminated string
12475 -- representing the full path name for the file name.
12476 -- On systems where it is relevant the drive is also
12477 -- part of the full path name. It is the responsibility
12478 -- of the caller to pass an actual parameter for buffer
12479 -- that is big enough for any full path name. Use
12480 -- max_path_len given below as the size of buffer.
12481 max_path_len : integer;
12482 -- Maximum length of an allowable full path name on the
12483 -- system, including a terminating NUL character.
12484 end Interfaces.C_Streams;
12487 @node Interfacing to C Streams
12488 @section Interfacing to C Streams
12491 The packages in this section permit interfacing Ada files to C Stream
12494 @smallexample @c ada
12495 with Interfaces.C_Streams;
12496 package Ada.Sequential_IO.C_Streams is
12497 function C_Stream (F : File_Type)
12498 return Interfaces.C_Streams.FILEs;
12500 (File : in out File_Type;
12501 Mode : in File_Mode;
12502 C_Stream : in Interfaces.C_Streams.FILEs;
12503 Form : in String := "");
12504 end Ada.Sequential_IO.C_Streams;
12506 with Interfaces.C_Streams;
12507 package Ada.Direct_IO.C_Streams is
12508 function C_Stream (F : File_Type)
12509 return Interfaces.C_Streams.FILEs;
12511 (File : in out File_Type;
12512 Mode : in File_Mode;
12513 C_Stream : in Interfaces.C_Streams.FILEs;
12514 Form : in String := "");
12515 end Ada.Direct_IO.C_Streams;
12517 with Interfaces.C_Streams;
12518 package Ada.Text_IO.C_Streams is
12519 function C_Stream (F : File_Type)
12520 return Interfaces.C_Streams.FILEs;
12522 (File : in out File_Type;
12523 Mode : in File_Mode;
12524 C_Stream : in Interfaces.C_Streams.FILEs;
12525 Form : in String := "");
12526 end Ada.Text_IO.C_Streams;
12528 with Interfaces.C_Streams;
12529 package Ada.Wide_Text_IO.C_Streams is
12530 function C_Stream (F : File_Type)
12531 return Interfaces.C_Streams.FILEs;
12533 (File : in out File_Type;
12534 Mode : in File_Mode;
12535 C_Stream : in Interfaces.C_Streams.FILEs;
12536 Form : in String := "");
12537 end Ada.Wide_Text_IO.C_Streams;
12539 with Interfaces.C_Streams;
12540 package Ada.Wide_Wide_Text_IO.C_Streams is
12541 function C_Stream (F : File_Type)
12542 return Interfaces.C_Streams.FILEs;
12544 (File : in out File_Type;
12545 Mode : in File_Mode;
12546 C_Stream : in Interfaces.C_Streams.FILEs;
12547 Form : in String := "");
12548 end Ada.Wide_Wide_Text_IO.C_Streams;
12550 with Interfaces.C_Streams;
12551 package Ada.Stream_IO.C_Streams is
12552 function C_Stream (F : File_Type)
12553 return Interfaces.C_Streams.FILEs;
12555 (File : in out File_Type;
12556 Mode : in File_Mode;
12557 C_Stream : in Interfaces.C_Streams.FILEs;
12558 Form : in String := "");
12559 end Ada.Stream_IO.C_Streams;
12563 In each of these six packages, the @code{C_Stream} function obtains the
12564 @code{FILE} pointer from a currently opened Ada file. It is then
12565 possible to use the @code{Interfaces.C_Streams} package to operate on
12566 this stream, or the stream can be passed to a C program which can
12567 operate on it directly. Of course the program is responsible for
12568 ensuring that only appropriate sequences of operations are executed.
12570 One particular use of relevance to an Ada program is that the
12571 @code{setvbuf} function can be used to control the buffering of the
12572 stream used by an Ada file. In the absence of such a call the standard
12573 default buffering is used.
12575 The @code{Open} procedures in these packages open a file giving an
12576 existing C Stream instead of a file name. Typically this stream is
12577 imported from a C program, allowing an Ada file to operate on an
12580 @node The GNAT Library
12581 @chapter The GNAT Library
12584 The GNAT library contains a number of general and special purpose packages.
12585 It represents functionality that the GNAT developers have found useful, and
12586 which is made available to GNAT users. The packages described here are fully
12587 supported, and upwards compatibility will be maintained in future releases,
12588 so you can use these facilities with the confidence that the same functionality
12589 will be available in future releases.
12591 The chapter here simply gives a brief summary of the facilities available.
12592 The full documentation is found in the spec file for the package. The full
12593 sources of these library packages, including both spec and body, are provided
12594 with all GNAT releases. For example, to find out the full specifications of
12595 the SPITBOL pattern matching capability, including a full tutorial and
12596 extensive examples, look in the @file{g-spipat.ads} file in the library.
12598 For each entry here, the package name (as it would appear in a @code{with}
12599 clause) is given, followed by the name of the corresponding spec file in
12600 parentheses. The packages are children in four hierarchies, @code{Ada},
12601 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
12602 GNAT-specific hierarchy.
12604 Note that an application program should only use packages in one of these
12605 four hierarchies if the package is defined in the Ada Reference Manual,
12606 or is listed in this section of the GNAT Programmers Reference Manual.
12607 All other units should be considered internal implementation units and
12608 should not be directly @code{with}'ed by application code. The use of
12609 a @code{with} statement that references one of these internal implementation
12610 units makes an application potentially dependent on changes in versions
12611 of GNAT, and will generate a warning message.
12614 * Ada.Characters.Latin_9 (a-chlat9.ads)::
12615 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
12616 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
12617 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
12618 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
12619 * Ada.Command_Line.Remove (a-colire.ads)::
12620 * Ada.Command_Line.Environment (a-colien.ads)::
12621 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
12622 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
12623 * Ada.Exceptions.Traceback (a-exctra.ads)::
12624 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
12625 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
12626 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
12627 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
12628 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
12629 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
12630 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
12631 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
12632 * GNAT.Altivec (g-altive.ads)::
12633 * GNAT.Altivec.Conversions (g-altcon.ads)::
12634 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
12635 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
12636 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
12637 * GNAT.Array_Split (g-arrspl.ads)::
12638 * GNAT.AWK (g-awk.ads)::
12639 * GNAT.Bounded_Buffers (g-boubuf.ads)::
12640 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
12641 * GNAT.Bubble_Sort (g-bubsor.ads)::
12642 * GNAT.Bubble_Sort_A (g-busora.ads)::
12643 * GNAT.Bubble_Sort_G (g-busorg.ads)::
12644 * GNAT.Byte_Swapping (g-bytswa.ads)::
12645 * GNAT.Calendar (g-calend.ads)::
12646 * GNAT.Calendar.Time_IO (g-catiio.ads)::
12647 * GNAT.CRC32 (g-crc32.ads)::
12648 * GNAT.Case_Util (g-casuti.ads)::
12649 * GNAT.CGI (g-cgi.ads)::
12650 * GNAT.CGI.Cookie (g-cgicoo.ads)::
12651 * GNAT.CGI.Debug (g-cgideb.ads)::
12652 * GNAT.Command_Line (g-comlin.ads)::
12653 * GNAT.Compiler_Version (g-comver.ads)::
12654 * GNAT.Ctrl_C (g-ctrl_c.ads)::
12655 * GNAT.Current_Exception (g-curexc.ads)::
12656 * GNAT.Debug_Pools (g-debpoo.ads)::
12657 * GNAT.Debug_Utilities (g-debuti.ads)::
12658 * GNAT.Directory_Operations (g-dirope.ads)::
12659 * GNAT.Dynamic_HTables (g-dynhta.ads)::
12660 * GNAT.Dynamic_Tables (g-dyntab.ads)::
12661 * GNAT.Exception_Actions (g-excact.ads)::
12662 * GNAT.Exception_Traces (g-exctra.ads)::
12663 * GNAT.Exceptions (g-except.ads)::
12664 * GNAT.Expect (g-expect.ads)::
12665 * GNAT.Float_Control (g-flocon.ads)::
12666 * GNAT.Heap_Sort (g-heasor.ads)::
12667 * GNAT.Heap_Sort_A (g-hesora.ads)::
12668 * GNAT.Heap_Sort_G (g-hesorg.ads)::
12669 * GNAT.HTable (g-htable.ads)::
12670 * GNAT.IO (g-io.ads)::
12671 * GNAT.IO_Aux (g-io_aux.ads)::
12672 * GNAT.Lock_Files (g-locfil.ads)::
12673 * GNAT.MD5 (g-md5.ads)::
12674 * GNAT.Memory_Dump (g-memdum.ads)::
12675 * GNAT.Most_Recent_Exception (g-moreex.ads)::
12676 * GNAT.OS_Lib (g-os_lib.ads)::
12677 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
12678 * GNAT.Regexp (g-regexp.ads)::
12679 * GNAT.Registry (g-regist.ads)::
12680 * GNAT.Regpat (g-regpat.ads)::
12681 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
12682 * GNAT.Semaphores (g-semaph.ads)::
12683 * GNAT.SHA1 (g-sha1.ads)::
12684 * GNAT.Signals (g-signal.ads)::
12685 * GNAT.Sockets (g-socket.ads)::
12686 * GNAT.Source_Info (g-souinf.ads)::
12687 * GNAT.Spell_Checker (g-speche.ads)::
12688 * GNAT.Spitbol.Patterns (g-spipat.ads)::
12689 * GNAT.Spitbol (g-spitbo.ads)::
12690 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
12691 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
12692 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
12693 * GNAT.Strings (g-string.ads)::
12694 * GNAT.String_Split (g-strspl.ads)::
12695 * GNAT.UTF_32 (g-utf_32.ads)::
12696 * GNAT.Table (g-table.ads)::
12697 * GNAT.Task_Lock (g-tasloc.ads)::
12698 * GNAT.Threads (g-thread.ads)::
12699 * GNAT.Traceback (g-traceb.ads)::
12700 * GNAT.Traceback.Symbolic (g-trasym.ads)::
12701 * GNAT.Wide_String_Split (g-wistsp.ads)::
12702 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
12703 * Interfaces.C.Extensions (i-cexten.ads)::
12704 * Interfaces.C.Streams (i-cstrea.ads)::
12705 * Interfaces.CPP (i-cpp.ads)::
12706 * Interfaces.Os2lib (i-os2lib.ads)::
12707 * Interfaces.Os2lib.Errors (i-os2err.ads)::
12708 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
12709 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
12710 * Interfaces.Packed_Decimal (i-pacdec.ads)::
12711 * Interfaces.VxWorks (i-vxwork.ads)::
12712 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
12713 * System.Address_Image (s-addima.ads)::
12714 * System.Assertions (s-assert.ads)::
12715 * System.Memory (s-memory.ads)::
12716 * System.Partition_Interface (s-parint.ads)::
12717 * System.Restrictions (s-restri.ads)::
12718 * System.Rident (s-rident.ads)::
12719 * System.Task_Info (s-tasinf.ads)::
12720 * System.Wch_Cnv (s-wchcnv.ads)::
12721 * System.Wch_Con (s-wchcon.ads)::
12724 @node Ada.Characters.Latin_9 (a-chlat9.ads)
12725 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12726 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12727 @cindex Latin_9 constants for Character
12730 This child of @code{Ada.Characters}
12731 provides a set of definitions corresponding to those in the
12732 RM-defined package @code{Ada.Characters.Latin_1} but with the
12733 few modifications required for @code{Latin-9}
12734 The provision of such a package
12735 is specifically authorized by the Ada Reference Manual
12738 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
12739 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12740 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12741 @cindex Latin_1 constants for Wide_Character
12744 This child of @code{Ada.Characters}
12745 provides a set of definitions corresponding to those in the
12746 RM-defined package @code{Ada.Characters.Latin_1} but with the
12747 types of the constants being @code{Wide_Character}
12748 instead of @code{Character}. The provision of such a package
12749 is specifically authorized by the Ada Reference Manual
12752 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
12753 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12754 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12755 @cindex Latin_9 constants for Wide_Character
12758 This child of @code{Ada.Characters}
12759 provides a set of definitions corresponding to those in the
12760 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12761 types of the constants being @code{Wide_Character}
12762 instead of @code{Character}. The provision of such a package
12763 is specifically authorized by the Ada Reference Manual
12766 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
12767 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12768 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12769 @cindex Latin_1 constants for Wide_Wide_Character
12772 This child of @code{Ada.Characters}
12773 provides a set of definitions corresponding to those in the
12774 RM-defined package @code{Ada.Characters.Latin_1} but with the
12775 types of the constants being @code{Wide_Wide_Character}
12776 instead of @code{Character}. The provision of such a package
12777 is specifically authorized by the Ada Reference Manual
12780 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
12781 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12782 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12783 @cindex Latin_9 constants for Wide_Wide_Character
12786 This child of @code{Ada.Characters}
12787 provides a set of definitions corresponding to those in the
12788 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12789 types of the constants being @code{Wide_Wide_Character}
12790 instead of @code{Character}. The provision of such a package
12791 is specifically authorized by the Ada Reference Manual
12794 @node Ada.Command_Line.Remove (a-colire.ads)
12795 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12796 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12797 @cindex Removing command line arguments
12798 @cindex Command line, argument removal
12801 This child of @code{Ada.Command_Line}
12802 provides a mechanism for logically removing
12803 arguments from the argument list. Once removed, an argument is not visible
12804 to further calls on the subprograms in @code{Ada.Command_Line} will not
12805 see the removed argument.
12807 @node Ada.Command_Line.Environment (a-colien.ads)
12808 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12809 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12810 @cindex Environment entries
12813 This child of @code{Ada.Command_Line}
12814 provides a mechanism for obtaining environment values on systems
12815 where this concept makes sense.
12817 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12818 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12819 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12820 @cindex C Streams, Interfacing with Direct_IO
12823 This package provides subprograms that allow interfacing between
12824 C streams and @code{Direct_IO}. The stream identifier can be
12825 extracted from a file opened on the Ada side, and an Ada file
12826 can be constructed from a stream opened on the C side.
12828 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12829 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12830 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12831 @cindex Null_Occurrence, testing for
12834 This child subprogram provides a way of testing for the null
12835 exception occurrence (@code{Null_Occurrence}) without raising
12838 @node Ada.Exceptions.Traceback (a-exctra.ads)
12839 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12840 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12841 @cindex Traceback for Exception Occurrence
12844 This child package provides the subprogram (@code{Tracebacks}) to
12845 give a traceback array of addresses based on an exception
12848 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12849 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12850 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12851 @cindex C Streams, Interfacing with Sequential_IO
12854 This package provides subprograms that allow interfacing between
12855 C streams and @code{Sequential_IO}. The stream identifier can be
12856 extracted from a file opened on the Ada side, and an Ada file
12857 can be constructed from a stream opened on the C side.
12859 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12860 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12861 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12862 @cindex C Streams, Interfacing with Stream_IO
12865 This package provides subprograms that allow interfacing between
12866 C streams and @code{Stream_IO}. The stream identifier can be
12867 extracted from a file opened on the Ada side, and an Ada file
12868 can be constructed from a stream opened on the C side.
12870 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
12871 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12872 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12873 @cindex @code{Unbounded_String}, IO support
12874 @cindex @code{Text_IO}, extensions for unbounded strings
12877 This package provides subprograms for Text_IO for unbounded
12878 strings, avoiding the necessity for an intermediate operation
12879 with ordinary strings.
12881 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
12882 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12883 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12884 @cindex @code{Unbounded_Wide_String}, IO support
12885 @cindex @code{Text_IO}, extensions for unbounded wide strings
12888 This package provides subprograms for Text_IO for unbounded
12889 wide strings, avoiding the necessity for an intermediate operation
12890 with ordinary wide strings.
12892 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
12893 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12894 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12895 @cindex @code{Unbounded_Wide_Wide_String}, IO support
12896 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
12899 This package provides subprograms for Text_IO for unbounded
12900 wide wide strings, avoiding the necessity for an intermediate operation
12901 with ordinary wide wide strings.
12903 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
12904 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12905 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12906 @cindex C Streams, Interfacing with @code{Text_IO}
12909 This package provides subprograms that allow interfacing between
12910 C streams and @code{Text_IO}. The stream identifier can be
12911 extracted from a file opened on the Ada side, and an Ada file
12912 can be constructed from a stream opened on the C side.
12914 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
12915 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12916 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12917 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
12920 This package provides subprograms that allow interfacing between
12921 C streams and @code{Wide_Text_IO}. The stream identifier can be
12922 extracted from a file opened on the Ada side, and an Ada file
12923 can be constructed from a stream opened on the C side.
12925 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
12926 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12927 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12928 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
12931 This package provides subprograms that allow interfacing between
12932 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
12933 extracted from a file opened on the Ada side, and an Ada file
12934 can be constructed from a stream opened on the C side.
12936 @node GNAT.Altivec (g-altive.ads)
12937 @section @code{GNAT.Altivec} (@file{g-altive.ads})
12938 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
12942 This is the root package of the GNAT AltiVec binding. It provides
12943 definitions of constants and types common to all the versions of the
12946 @node GNAT.Altivec.Conversions (g-altcon.ads)
12947 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12948 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12952 This package provides the Vector/View conversion routines.
12954 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
12955 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12956 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12960 This package exposes the Ada interface to the AltiVec operations on
12961 vector objects. A soft emulation is included by default in the GNAT
12962 library. The hard binding is provided as a separate package. This unit
12963 is common to both bindings.
12965 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
12966 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12967 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12971 This package exposes the various vector types part of the Ada binding
12972 to AltiVec facilities.
12974 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
12975 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12976 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12980 This package provides public 'View' data types from/to which private
12981 vector representations can be converted via
12982 GNAT.Altivec.Conversions. This allows convenient access to individual
12983 vector elements and provides a simple way to initialize vector
12986 @node GNAT.Array_Split (g-arrspl.ads)
12987 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12988 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12989 @cindex Array splitter
12992 Useful array-manipulation routines: given a set of separators, split
12993 an array wherever the separators appear, and provide direct access
12994 to the resulting slices.
12996 @node GNAT.AWK (g-awk.ads)
12997 @section @code{GNAT.AWK} (@file{g-awk.ads})
12998 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13003 Provides AWK-like parsing functions, with an easy interface for parsing one
13004 or more files containing formatted data. The file is viewed as a database
13005 where each record is a line and a field is a data element in this line.
13007 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13008 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13009 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13011 @cindex Bounded Buffers
13014 Provides a concurrent generic bounded buffer abstraction. Instances are
13015 useful directly or as parts of the implementations of other abstractions,
13018 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13019 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13020 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13025 Provides a thread-safe asynchronous intertask mailbox communication facility.
13027 @node GNAT.Bubble_Sort (g-bubsor.ads)
13028 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13029 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13031 @cindex Bubble sort
13034 Provides a general implementation of bubble sort usable for sorting arbitrary
13035 data items. Exchange and comparison procedures are provided by passing
13036 access-to-procedure values.
13038 @node GNAT.Bubble_Sort_A (g-busora.ads)
13039 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13040 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13042 @cindex Bubble sort
13045 Provides a general implementation of bubble sort usable for sorting arbitrary
13046 data items. Move and comparison procedures are provided by passing
13047 access-to-procedure values. This is an older version, retained for
13048 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13050 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13051 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13052 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13054 @cindex Bubble sort
13057 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13058 are provided as generic parameters, this improves efficiency, especially
13059 if the procedures can be inlined, at the expense of duplicating code for
13060 multiple instantiations.
13062 @node GNAT.Byte_Swapping (g-bytswa.ads)
13063 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13064 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13065 @cindex Byte swapping
13069 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13070 Machine-specific implementations are available in some cases.
13072 @node GNAT.Calendar (g-calend.ads)
13073 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13074 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13075 @cindex @code{Calendar}
13078 Extends the facilities provided by @code{Ada.Calendar} to include handling
13079 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13080 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13081 C @code{timeval} format.
13083 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13084 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13085 @cindex @code{Calendar}
13087 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13089 @node GNAT.CRC32 (g-crc32.ads)
13090 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13091 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13093 @cindex Cyclic Redundancy Check
13096 This package implements the CRC-32 algorithm. For a full description
13097 of this algorithm see
13098 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13099 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13100 Aug.@: 1988. Sarwate, D.V@.
13102 @node GNAT.Case_Util (g-casuti.ads)
13103 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13104 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13105 @cindex Casing utilities
13106 @cindex Character handling (@code{GNAT.Case_Util})
13109 A set of simple routines for handling upper and lower casing of strings
13110 without the overhead of the full casing tables
13111 in @code{Ada.Characters.Handling}.
13113 @node GNAT.CGI (g-cgi.ads)
13114 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13115 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13116 @cindex CGI (Common Gateway Interface)
13119 This is a package for interfacing a GNAT program with a Web server via the
13120 Common Gateway Interface (CGI)@. Basically this package parses the CGI
13121 parameters, which are a set of key/value pairs sent by the Web server. It
13122 builds a table whose index is the key and provides some services to deal
13125 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13126 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13127 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13128 @cindex CGI (Common Gateway Interface) cookie support
13129 @cindex Cookie support in CGI
13132 This is a package to interface a GNAT program with a Web server via the
13133 Common Gateway Interface (CGI). It exports services to deal with Web
13134 cookies (piece of information kept in the Web client software).
13136 @node GNAT.CGI.Debug (g-cgideb.ads)
13137 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13138 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13139 @cindex CGI (Common Gateway Interface) debugging
13142 This is a package to help debugging CGI (Common Gateway Interface)
13143 programs written in Ada.
13145 @node GNAT.Command_Line (g-comlin.ads)
13146 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13147 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13148 @cindex Command line
13151 Provides a high level interface to @code{Ada.Command_Line} facilities,
13152 including the ability to scan for named switches with optional parameters
13153 and expand file names using wild card notations.
13155 @node GNAT.Compiler_Version (g-comver.ads)
13156 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13157 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13158 @cindex Compiler Version
13159 @cindex Version, of compiler
13162 Provides a routine for obtaining the version of the compiler used to
13163 compile the program. More accurately this is the version of the binder
13164 used to bind the program (this will normally be the same as the version
13165 of the compiler if a consistent tool set is used to compile all units
13168 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13169 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13170 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13174 Provides a simple interface to handle Ctrl-C keyboard events.
13176 @node GNAT.Current_Exception (g-curexc.ads)
13177 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13178 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13179 @cindex Current exception
13180 @cindex Exception retrieval
13183 Provides access to information on the current exception that has been raised
13184 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13185 specification syntax.
13186 This is particularly useful in simulating typical facilities for
13187 obtaining information about exceptions provided by Ada 83 compilers.
13189 @node GNAT.Debug_Pools (g-debpoo.ads)
13190 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13191 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13193 @cindex Debug pools
13194 @cindex Memory corruption debugging
13197 Provide a debugging storage pools that helps tracking memory corruption
13198 problems. See section ``Finding memory problems with GNAT Debug Pool'' in
13199 the @cite{GNAT User's Guide}.
13201 @node GNAT.Debug_Utilities (g-debuti.ads)
13202 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13203 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13207 Provides a few useful utilities for debugging purposes, including conversion
13208 to and from string images of address values. Supports both C and Ada formats
13209 for hexadecimal literals.
13211 @node GNAT.Directory_Operations (g-dirope.ads)
13212 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13213 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13214 @cindex Directory operations
13217 Provides a set of routines for manipulating directories, including changing
13218 the current directory, making new directories, and scanning the files in a
13221 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13222 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13223 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13224 @cindex Hash tables
13227 A generic implementation of hash tables that can be used to hash arbitrary
13228 data. Provided in two forms, a simple form with built in hash functions,
13229 and a more complex form in which the hash function is supplied.
13232 This package provides a facility similar to that of @code{GNAT.HTable},
13233 except that this package declares a type that can be used to define
13234 dynamic instances of the hash table, while an instantiation of
13235 @code{GNAT.HTable} creates a single instance of the hash table.
13237 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13238 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13239 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13240 @cindex Table implementation
13241 @cindex Arrays, extendable
13244 A generic package providing a single dimension array abstraction where the
13245 length of the array can be dynamically modified.
13248 This package provides a facility similar to that of @code{GNAT.Table},
13249 except that this package declares a type that can be used to define
13250 dynamic instances of the table, while an instantiation of
13251 @code{GNAT.Table} creates a single instance of the table type.
13253 @node GNAT.Exception_Actions (g-excact.ads)
13254 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13255 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13256 @cindex Exception actions
13259 Provides callbacks when an exception is raised. Callbacks can be registered
13260 for specific exceptions, or when any exception is raised. This
13261 can be used for instance to force a core dump to ease debugging.
13263 @node GNAT.Exception_Traces (g-exctra.ads)
13264 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13265 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13266 @cindex Exception traces
13270 Provides an interface allowing to control automatic output upon exception
13273 @node GNAT.Exceptions (g-except.ads)
13274 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
13275 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
13276 @cindex Exceptions, Pure
13277 @cindex Pure packages, exceptions
13280 Normally it is not possible to raise an exception with
13281 a message from a subprogram in a pure package, since the
13282 necessary types and subprograms are in @code{Ada.Exceptions}
13283 which is not a pure unit. @code{GNAT.Exceptions} provides a
13284 facility for getting around this limitation for a few
13285 predefined exceptions, and for example allow raising
13286 @code{Constraint_Error} with a message from a pure subprogram.
13288 @node GNAT.Expect (g-expect.ads)
13289 @section @code{GNAT.Expect} (@file{g-expect.ads})
13290 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
13293 Provides a set of subprograms similar to what is available
13294 with the standard Tcl Expect tool.
13295 It allows you to easily spawn and communicate with an external process.
13296 You can send commands or inputs to the process, and compare the output
13297 with some expected regular expression. Currently @code{GNAT.Expect}
13298 is implemented on all native GNAT ports except for OpenVMS@.
13299 It is not implemented for cross ports, and in particular is not
13300 implemented for VxWorks or LynxOS@.
13302 @node GNAT.Float_Control (g-flocon.ads)
13303 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
13304 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
13305 @cindex Floating-Point Processor
13308 Provides an interface for resetting the floating-point processor into the
13309 mode required for correct semantic operation in Ada. Some third party
13310 library calls may cause this mode to be modified, and the Reset procedure
13311 in this package can be used to reestablish the required mode.
13313 @node GNAT.Heap_Sort (g-heasor.ads)
13314 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13315 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13319 Provides a general implementation of heap sort usable for sorting arbitrary
13320 data items. Exchange and comparison procedures are provided by passing
13321 access-to-procedure values. The algorithm used is a modified heap sort
13322 that performs approximately N*log(N) comparisons in the worst case.
13324 @node GNAT.Heap_Sort_A (g-hesora.ads)
13325 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13326 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13330 Provides a general implementation of heap sort usable for sorting arbitrary
13331 data items. Move and comparison procedures are provided by passing
13332 access-to-procedure values. The algorithm used is a modified heap sort
13333 that performs approximately N*log(N) comparisons in the worst case.
13334 This differs from @code{GNAT.Heap_Sort} in having a less convenient
13335 interface, but may be slightly more efficient.
13337 @node GNAT.Heap_Sort_G (g-hesorg.ads)
13338 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13339 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13343 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
13344 are provided as generic parameters, this improves efficiency, especially
13345 if the procedures can be inlined, at the expense of duplicating code for
13346 multiple instantiations.
13348 @node GNAT.HTable (g-htable.ads)
13349 @section @code{GNAT.HTable} (@file{g-htable.ads})
13350 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
13351 @cindex Hash tables
13354 A generic implementation of hash tables that can be used to hash arbitrary
13355 data. Provides two approaches, one a simple static approach, and the other
13356 allowing arbitrary dynamic hash tables.
13358 @node GNAT.IO (g-io.ads)
13359 @section @code{GNAT.IO} (@file{g-io.ads})
13360 @cindex @code{GNAT.IO} (@file{g-io.ads})
13362 @cindex Input/Output facilities
13365 A simple preelaborable input-output package that provides a subset of
13366 simple Text_IO functions for reading characters and strings from
13367 Standard_Input, and writing characters, strings and integers to either
13368 Standard_Output or Standard_Error.
13370 @node GNAT.IO_Aux (g-io_aux.ads)
13371 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13372 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13374 @cindex Input/Output facilities
13376 Provides some auxiliary functions for use with Text_IO, including a test
13377 for whether a file exists, and functions for reading a line of text.
13379 @node GNAT.Lock_Files (g-locfil.ads)
13380 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13381 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13382 @cindex File locking
13383 @cindex Locking using files
13386 Provides a general interface for using files as locks. Can be used for
13387 providing program level synchronization.
13389 @node GNAT.MD5 (g-md5.ads)
13390 @section @code{GNAT.MD5} (@file{g-md5.ads})
13391 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
13392 @cindex Message Digest MD5
13395 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
13397 @node GNAT.Memory_Dump (g-memdum.ads)
13398 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13399 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13400 @cindex Dump Memory
13403 Provides a convenient routine for dumping raw memory to either the
13404 standard output or standard error files. Uses GNAT.IO for actual
13407 @node GNAT.Most_Recent_Exception (g-moreex.ads)
13408 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13409 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13410 @cindex Exception, obtaining most recent
13413 Provides access to the most recently raised exception. Can be used for
13414 various logging purposes, including duplicating functionality of some
13415 Ada 83 implementation dependent extensions.
13417 @node GNAT.OS_Lib (g-os_lib.ads)
13418 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13419 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13420 @cindex Operating System interface
13421 @cindex Spawn capability
13424 Provides a range of target independent operating system interface functions,
13425 including time/date management, file operations, subprocess management,
13426 including a portable spawn procedure, and access to environment variables
13427 and error return codes.
13429 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
13430 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13431 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13432 @cindex Hash functions
13435 Provides a generator of static minimal perfect hash functions. No
13436 collisions occur and each item can be retrieved from the table in one
13437 probe (perfect property). The hash table size corresponds to the exact
13438 size of the key set and no larger (minimal property). The key set has to
13439 be know in advance (static property). The hash functions are also order
13440 preserving. If w2 is inserted after w1 in the generator, their
13441 hashcode are in the same order. These hashing functions are very
13442 convenient for use with realtime applications.
13444 @node GNAT.Regexp (g-regexp.ads)
13445 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
13446 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
13447 @cindex Regular expressions
13448 @cindex Pattern matching
13451 A simple implementation of regular expressions, using a subset of regular
13452 expression syntax copied from familiar Unix style utilities. This is the
13453 simples of the three pattern matching packages provided, and is particularly
13454 suitable for ``file globbing'' applications.
13456 @node GNAT.Registry (g-regist.ads)
13457 @section @code{GNAT.Registry} (@file{g-regist.ads})
13458 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
13459 @cindex Windows Registry
13462 This is a high level binding to the Windows registry. It is possible to
13463 do simple things like reading a key value, creating a new key. For full
13464 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
13465 package provided with the Win32Ada binding
13467 @node GNAT.Regpat (g-regpat.ads)
13468 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
13469 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
13470 @cindex Regular expressions
13471 @cindex Pattern matching
13474 A complete implementation of Unix-style regular expression matching, copied
13475 from the original V7 style regular expression library written in C by
13476 Henry Spencer (and binary compatible with this C library).
13478 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
13479 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13480 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13481 @cindex Secondary Stack Info
13484 Provide the capability to query the high water mark of the current task's
13487 @node GNAT.Semaphores (g-semaph.ads)
13488 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
13489 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
13493 Provides classic counting and binary semaphores using protected types.
13495 @node GNAT.SHA1 (g-sha1.ads)
13496 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
13497 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
13498 @cindex Secure Hash Algorithm SHA-1
13501 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
13503 @node GNAT.Signals (g-signal.ads)
13504 @section @code{GNAT.Signals} (@file{g-signal.ads})
13505 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
13509 Provides the ability to manipulate the blocked status of signals on supported
13512 @node GNAT.Sockets (g-socket.ads)
13513 @section @code{GNAT.Sockets} (@file{g-socket.ads})
13514 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
13518 A high level and portable interface to develop sockets based applications.
13519 This package is based on the sockets thin binding found in
13520 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
13521 on all native GNAT ports except for OpenVMS@. It is not implemented
13522 for the LynxOS@ cross port.
13524 @node GNAT.Source_Info (g-souinf.ads)
13525 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
13526 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
13527 @cindex Source Information
13530 Provides subprograms that give access to source code information known at
13531 compile time, such as the current file name and line number.
13533 @node GNAT.Spell_Checker (g-speche.ads)
13534 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13535 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13536 @cindex Spell checking
13539 Provides a function for determining whether one string is a plausible
13540 near misspelling of another string.
13542 @node GNAT.Spitbol.Patterns (g-spipat.ads)
13543 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13544 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13545 @cindex SPITBOL pattern matching
13546 @cindex Pattern matching
13549 A complete implementation of SNOBOL4 style pattern matching. This is the
13550 most elaborate of the pattern matching packages provided. It fully duplicates
13551 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
13552 efficient algorithm developed by Robert Dewar for the SPITBOL system.
13554 @node GNAT.Spitbol (g-spitbo.ads)
13555 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13556 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13557 @cindex SPITBOL interface
13560 The top level package of the collection of SPITBOL-style functionality, this
13561 package provides basic SNOBOL4 string manipulation functions, such as
13562 Pad, Reverse, Trim, Substr capability, as well as a generic table function
13563 useful for constructing arbitrary mappings from strings in the style of
13564 the SNOBOL4 TABLE function.
13566 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
13567 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13568 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13569 @cindex Sets of strings
13570 @cindex SPITBOL Tables
13573 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13574 for type @code{Standard.Boolean}, giving an implementation of sets of
13577 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
13578 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13579 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13580 @cindex Integer maps
13582 @cindex SPITBOL Tables
13585 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13586 for type @code{Standard.Integer}, giving an implementation of maps
13587 from string to integer values.
13589 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
13590 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13591 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13592 @cindex String maps
13594 @cindex SPITBOL Tables
13597 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
13598 a variable length string type, giving an implementation of general
13599 maps from strings to strings.
13601 @node GNAT.Strings (g-string.ads)
13602 @section @code{GNAT.Strings} (@file{g-string.ads})
13603 @cindex @code{GNAT.Strings} (@file{g-string.ads})
13606 Common String access types and related subprograms. Basically it
13607 defines a string access and an array of string access types.
13609 @node GNAT.String_Split (g-strspl.ads)
13610 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
13611 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
13612 @cindex String splitter
13615 Useful string manipulation routines: given a set of separators, split
13616 a string wherever the separators appear, and provide direct access
13617 to the resulting slices. This package is instantiated from
13618 @code{GNAT.Array_Split}.
13620 @node GNAT.UTF_32 (g-utf_32.ads)
13621 @section @code{GNAT.UTF_32} (@file{g-table.ads})
13622 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
13623 @cindex Wide character codes
13626 This is a package intended to be used in conjunction with the
13627 @code{Wide_Character} type in Ada 95 and the
13628 @code{Wide_Wide_Character} type in Ada 2005 (available
13629 in @code{GNAT} in Ada 2005 mode). This package contains
13630 Unicode categorization routines, as well as lexical
13631 categorization routines corresponding to the Ada 2005
13632 lexical rules for identifiers and strings, and also a
13633 lower case to upper case fold routine corresponding to
13634 the Ada 2005 rules for identifier equivalence.
13636 @node GNAT.Table (g-table.ads)
13637 @section @code{GNAT.Table} (@file{g-table.ads})
13638 @cindex @code{GNAT.Table} (@file{g-table.ads})
13639 @cindex Table implementation
13640 @cindex Arrays, extendable
13643 A generic package providing a single dimension array abstraction where the
13644 length of the array can be dynamically modified.
13647 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
13648 except that this package declares a single instance of the table type,
13649 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
13650 used to define dynamic instances of the table.
13652 @node GNAT.Task_Lock (g-tasloc.ads)
13653 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13654 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13655 @cindex Task synchronization
13656 @cindex Task locking
13660 A very simple facility for locking and unlocking sections of code using a
13661 single global task lock. Appropriate for use in situations where contention
13662 between tasks is very rarely expected.
13664 @node GNAT.Threads (g-thread.ads)
13665 @section @code{GNAT.Threads} (@file{g-thread.ads})
13666 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
13667 @cindex Foreign threads
13668 @cindex Threads, foreign
13671 Provides facilities for dealing with foreign threads which need to be known
13672 by the GNAT run-time system. Consult the documentation of this package for
13673 further details if your program has threads that are created by a non-Ada
13674 environment which then accesses Ada code.
13676 @node GNAT.Traceback (g-traceb.ads)
13677 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
13678 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
13679 @cindex Trace back facilities
13682 Provides a facility for obtaining non-symbolic traceback information, useful
13683 in various debugging situations.
13685 @node GNAT.Traceback.Symbolic (g-trasym.ads)
13686 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13687 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13688 @cindex Trace back facilities
13691 Provides symbolic traceback information that includes the subprogram
13692 name and line number information. Note that this capability is not available
13693 on all targets, see g-trasym.ads for list of supported targets.
13695 @node GNAT.Wide_String_Split (g-wistsp.ads)
13696 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13697 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13698 @cindex Wide_String splitter
13701 Useful wide string manipulation routines: given a set of separators, split
13702 a wide string wherever the separators appear, and provide direct access
13703 to the resulting slices. This package is instantiated from
13704 @code{GNAT.Array_Split}.
13706 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
13707 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13708 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13709 @cindex Wide_Wide_String splitter
13712 Useful wide wide string manipulation routines: given a set of separators, split
13713 a wide wide string wherever the separators appear, and provide direct access
13714 to the resulting slices. This package is instantiated from
13715 @code{GNAT.Array_Split}.
13717 @node Interfaces.C.Extensions (i-cexten.ads)
13718 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13719 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13722 This package contains additional C-related definitions, intended
13723 for use with either manually or automatically generated bindings
13726 @node Interfaces.C.Streams (i-cstrea.ads)
13727 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13728 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13729 @cindex C streams, interfacing
13732 This package is a binding for the most commonly used operations
13735 @node Interfaces.CPP (i-cpp.ads)
13736 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
13737 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
13738 @cindex C++ interfacing
13739 @cindex Interfacing, to C++
13742 This package provides facilities for use in interfacing to C++. It
13743 is primarily intended to be used in connection with automated tools
13744 for the generation of C++ interfaces.
13746 @node Interfaces.Os2lib (i-os2lib.ads)
13747 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13748 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13749 @cindex Interfacing, to OS/2
13750 @cindex OS/2 interfacing
13753 This package provides interface definitions to the OS/2 library.
13754 It is a thin binding which is a direct translation of the
13755 various @file{<bse@.h>} files.
13757 @node Interfaces.Os2lib.Errors (i-os2err.ads)
13758 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13759 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13760 @cindex OS/2 Error codes
13761 @cindex Interfacing, to OS/2
13762 @cindex OS/2 interfacing
13765 This package provides definitions of the OS/2 error codes.
13767 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
13768 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13769 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13770 @cindex Interfacing, to OS/2
13771 @cindex Synchronization, OS/2
13772 @cindex OS/2 synchronization primitives
13775 This is a child package that provides definitions for interfacing
13776 to the @code{OS/2} synchronization primitives.
13778 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
13779 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13780 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13781 @cindex Interfacing, to OS/2
13782 @cindex Thread control, OS/2
13783 @cindex OS/2 thread interfacing
13786 This is a child package that provides definitions for interfacing
13787 to the @code{OS/2} thread primitives.
13789 @node Interfaces.Packed_Decimal (i-pacdec.ads)
13790 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13791 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13792 @cindex IBM Packed Format
13793 @cindex Packed Decimal
13796 This package provides a set of routines for conversions to and
13797 from a packed decimal format compatible with that used on IBM
13800 @node Interfaces.VxWorks (i-vxwork.ads)
13801 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13802 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13803 @cindex Interfacing to VxWorks
13804 @cindex VxWorks, interfacing
13807 This package provides a limited binding to the VxWorks API.
13808 In particular, it interfaces with the
13809 VxWorks hardware interrupt facilities.
13811 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
13812 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13813 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13814 @cindex Interfacing to VxWorks' I/O
13815 @cindex VxWorks, I/O interfacing
13816 @cindex VxWorks, Get_Immediate
13817 @cindex Get_Immediate, VxWorks
13820 This package provides a binding to the ioctl (IO/Control)
13821 function of VxWorks, defining a set of option values and
13822 function codes. A particular use of this package is
13823 to enable the use of Get_Immediate under VxWorks.
13825 @node System.Address_Image (s-addima.ads)
13826 @section @code{System.Address_Image} (@file{s-addima.ads})
13827 @cindex @code{System.Address_Image} (@file{s-addima.ads})
13828 @cindex Address image
13829 @cindex Image, of an address
13832 This function provides a useful debugging
13833 function that gives an (implementation dependent)
13834 string which identifies an address.
13836 @node System.Assertions (s-assert.ads)
13837 @section @code{System.Assertions} (@file{s-assert.ads})
13838 @cindex @code{System.Assertions} (@file{s-assert.ads})
13840 @cindex Assert_Failure, exception
13843 This package provides the declaration of the exception raised
13844 by an run-time assertion failure, as well as the routine that
13845 is used internally to raise this assertion.
13847 @node System.Memory (s-memory.ads)
13848 @section @code{System.Memory} (@file{s-memory.ads})
13849 @cindex @code{System.Memory} (@file{s-memory.ads})
13850 @cindex Memory allocation
13853 This package provides the interface to the low level routines used
13854 by the generated code for allocation and freeing storage for the
13855 default storage pool (analogous to the C routines malloc and free.
13856 It also provides a reallocation interface analogous to the C routine
13857 realloc. The body of this unit may be modified to provide alternative
13858 allocation mechanisms for the default pool, and in addition, direct
13859 calls to this unit may be made for low level allocation uses (for
13860 example see the body of @code{GNAT.Tables}).
13862 @node System.Partition_Interface (s-parint.ads)
13863 @section @code{System.Partition_Interface} (@file{s-parint.ads})
13864 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
13865 @cindex Partition interfacing functions
13868 This package provides facilities for partition interfacing. It
13869 is used primarily in a distribution context when using Annex E
13872 @node System.Restrictions (s-restri.ads)
13873 @section @code{System.Restrictions} (@file{s-restri.ads})
13874 @cindex @code{System.Restrictions} (@file{s-restri.ads})
13875 @cindex Run-time restrictions access
13878 This package provides facilities for accessing at run time
13879 the status of restrictions specified at compile time for
13880 the partition. Information is available both with regard
13881 to actual restrictions specified, and with regard to
13882 compiler determined information on which restrictions
13883 are violated by one or more packages in the partition.
13885 @node System.Rident (s-rident.ads)
13886 @section @code{System.Rident} (@file{s-rident.ads})
13887 @cindex @code{System.Rident} (@file{s-rident.ads})
13888 @cindex Restrictions definitions
13891 This package provides definitions of the restrictions
13892 identifiers supported by GNAT, and also the format of
13893 the restrictions provided in package System.Restrictions.
13894 It is not normally necessary to @code{with} this generic package
13895 since the necessary instantiation is included in
13896 package System.Restrictions.
13898 @node System.Task_Info (s-tasinf.ads)
13899 @section @code{System.Task_Info} (@file{s-tasinf.ads})
13900 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
13901 @cindex Task_Info pragma
13904 This package provides target dependent functionality that is used
13905 to support the @code{Task_Info} pragma
13907 @node System.Wch_Cnv (s-wchcnv.ads)
13908 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13909 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13910 @cindex Wide Character, Representation
13911 @cindex Wide String, Conversion
13912 @cindex Representation of wide characters
13915 This package provides routines for converting between
13916 wide and wide wide characters and a representation as a value of type
13917 @code{Standard.String}, using a specified wide character
13918 encoding method. It uses definitions in
13919 package @code{System.Wch_Con}.
13921 @node System.Wch_Con (s-wchcon.ads)
13922 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
13923 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
13926 This package provides definitions and descriptions of
13927 the various methods used for encoding wide characters
13928 in ordinary strings. These definitions are used by
13929 the package @code{System.Wch_Cnv}.
13931 @node Interfacing to Other Languages
13932 @chapter Interfacing to Other Languages
13934 The facilities in annex B of the Ada Reference Manual are fully
13935 implemented in GNAT, and in addition, a full interface to C++ is
13939 * Interfacing to C::
13940 * Interfacing to C++::
13941 * Interfacing to COBOL::
13942 * Interfacing to Fortran::
13943 * Interfacing to non-GNAT Ada code::
13946 @node Interfacing to C
13947 @section Interfacing to C
13950 Interfacing to C with GNAT can use one of two approaches:
13954 The types in the package @code{Interfaces.C} may be used.
13956 Standard Ada types may be used directly. This may be less portable to
13957 other compilers, but will work on all GNAT compilers, which guarantee
13958 correspondence between the C and Ada types.
13962 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
13963 effect, since this is the default. The following table shows the
13964 correspondence between Ada scalar types and the corresponding C types.
13969 @item Short_Integer
13971 @item Short_Short_Integer
13975 @item Long_Long_Integer
13983 @item Long_Long_Float
13984 This is the longest floating-point type supported by the hardware.
13988 Additionally, there are the following general correspondences between Ada
13992 Ada enumeration types map to C enumeration types directly if pragma
13993 @code{Convention C} is specified, which causes them to have int
13994 length. Without pragma @code{Convention C}, Ada enumeration types map to
13995 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
13996 @code{int}, respectively) depending on the number of values passed.
13997 This is the only case in which pragma @code{Convention C} affects the
13998 representation of an Ada type.
14001 Ada access types map to C pointers, except for the case of pointers to
14002 unconstrained types in Ada, which have no direct C equivalent.
14005 Ada arrays map directly to C arrays.
14008 Ada records map directly to C structures.
14011 Packed Ada records map to C structures where all members are bit fields
14012 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14015 @node Interfacing to C++
14016 @section Interfacing to C++
14019 The interface to C++ makes use of the following pragmas, which are
14020 primarily intended to be constructed automatically using a binding generator
14021 tool, although it is possible to construct them by hand. No suitable binding
14022 generator tool is supplied with GNAT though.
14024 Using these pragmas it is possible to achieve complete
14025 inter-operability between Ada tagged types and C++ class definitions.
14026 See @ref{Implementation Defined Pragmas}, for more details.
14029 @item pragma CPP_Class ([Entity =>] @var{local_NAME})
14030 The argument denotes an entity in the current declarative region that is
14031 declared as a tagged or untagged record type. It indicates that the type
14032 corresponds to an externally declared C++ class type, and is to be laid
14033 out the same way that C++ would lay out the type.
14035 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14036 for backward compatibility but its functionality is available
14037 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14039 @item pragma CPP_Constructor ([Entity =>] @var{local_NAME})
14040 This pragma identifies an imported function (imported in the usual way
14041 with pragma @code{Import}) as corresponding to a C++ constructor.
14044 @node Interfacing to COBOL
14045 @section Interfacing to COBOL
14048 Interfacing to COBOL is achieved as described in section B.4 of
14049 the Ada Reference Manual.
14051 @node Interfacing to Fortran
14052 @section Interfacing to Fortran
14055 Interfacing to Fortran is achieved as described in section B.5 of the
14056 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
14057 multi-dimensional array causes the array to be stored in column-major
14058 order as required for convenient interface to Fortran.
14060 @node Interfacing to non-GNAT Ada code
14061 @section Interfacing to non-GNAT Ada code
14063 It is possible to specify the convention @code{Ada} in a pragma
14064 @code{Import} or pragma @code{Export}. However this refers to
14065 the calling conventions used by GNAT, which may or may not be
14066 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14067 compiler to allow interoperation.
14069 If arguments types are kept simple, and if the foreign compiler generally
14070 follows system calling conventions, then it may be possible to integrate
14071 files compiled by other Ada compilers, provided that the elaboration
14072 issues are adequately addressed (for example by eliminating the
14073 need for any load time elaboration).
14075 In particular, GNAT running on VMS is designed to
14076 be highly compatible with the DEC Ada 83 compiler, so this is one
14077 case in which it is possible to import foreign units of this type,
14078 provided that the data items passed are restricted to simple scalar
14079 values or simple record types without variants, or simple array
14080 types with fixed bounds.
14082 @node Specialized Needs Annexes
14083 @chapter Specialized Needs Annexes
14086 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14087 required in all implementations. However, as described in this chapter,
14088 GNAT implements all of these annexes:
14091 @item Systems Programming (Annex C)
14092 The Systems Programming Annex is fully implemented.
14094 @item Real-Time Systems (Annex D)
14095 The Real-Time Systems Annex is fully implemented.
14097 @item Distributed Systems (Annex E)
14098 Stub generation is fully implemented in the GNAT compiler. In addition,
14099 a complete compatible PCS is available as part of the GLADE system,
14100 a separate product. When the two
14101 products are used in conjunction, this annex is fully implemented.
14103 @item Information Systems (Annex F)
14104 The Information Systems annex is fully implemented.
14106 @item Numerics (Annex G)
14107 The Numerics Annex is fully implemented.
14109 @item Safety and Security / High-Integrity Systems (Annex H)
14110 The Safety and Security Annex (termed the High-Integrity Systems Annex
14111 in Ada 2005) is fully implemented.
14114 @node Implementation of Specific Ada Features
14115 @chapter Implementation of Specific Ada Features
14118 This chapter describes the GNAT implementation of several Ada language
14122 * Machine Code Insertions::
14123 * GNAT Implementation of Tasking::
14124 * GNAT Implementation of Shared Passive Packages::
14125 * Code Generation for Array Aggregates::
14126 * The Size of Discriminated Records with Default Discriminants::
14127 * Strict Conformance to the Ada Reference Manual::
14130 @node Machine Code Insertions
14131 @section Machine Code Insertions
14132 @cindex Machine Code insertions
14135 Package @code{Machine_Code} provides machine code support as described
14136 in the Ada Reference Manual in two separate forms:
14139 Machine code statements, consisting of qualified expressions that
14140 fit the requirements of RM section 13.8.
14142 An intrinsic callable procedure, providing an alternative mechanism of
14143 including machine instructions in a subprogram.
14147 The two features are similar, and both are closely related to the mechanism
14148 provided by the asm instruction in the GNU C compiler. Full understanding
14149 and use of the facilities in this package requires understanding the asm
14150 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
14151 by Richard Stallman. The relevant section is titled ``Extensions to the C
14152 Language Family'' @result{} ``Assembler Instructions with C Expression
14155 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14156 semantic restrictions and effects as described below. Both are provided so
14157 that the procedure call can be used as a statement, and the function call
14158 can be used to form a code_statement.
14160 The first example given in the GCC documentation is the C @code{asm}
14163 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14167 The equivalent can be written for GNAT as:
14169 @smallexample @c ada
14170 Asm ("fsinx %1 %0",
14171 My_Float'Asm_Output ("=f", result),
14172 My_Float'Asm_Input ("f", angle));
14176 The first argument to @code{Asm} is the assembler template, and is
14177 identical to what is used in GNU C@. This string must be a static
14178 expression. The second argument is the output operand list. It is
14179 either a single @code{Asm_Output} attribute reference, or a list of such
14180 references enclosed in parentheses (technically an array aggregate of
14183 The @code{Asm_Output} attribute denotes a function that takes two
14184 parameters. The first is a string, the second is the name of a variable
14185 of the type designated by the attribute prefix. The first (string)
14186 argument is required to be a static expression and designates the
14187 constraint for the parameter (e.g.@: what kind of register is
14188 required). The second argument is the variable to be updated with the
14189 result. The possible values for constraint are the same as those used in
14190 the RTL, and are dependent on the configuration file used to build the
14191 GCC back end. If there are no output operands, then this argument may
14192 either be omitted, or explicitly given as @code{No_Output_Operands}.
14194 The second argument of @code{@var{my_float}'Asm_Output} functions as
14195 though it were an @code{out} parameter, which is a little curious, but
14196 all names have the form of expressions, so there is no syntactic
14197 irregularity, even though normally functions would not be permitted
14198 @code{out} parameters. The third argument is the list of input
14199 operands. It is either a single @code{Asm_Input} attribute reference, or
14200 a list of such references enclosed in parentheses (technically an array
14201 aggregate of such references).
14203 The @code{Asm_Input} attribute denotes a function that takes two
14204 parameters. The first is a string, the second is an expression of the
14205 type designated by the prefix. The first (string) argument is required
14206 to be a static expression, and is the constraint for the parameter,
14207 (e.g.@: what kind of register is required). The second argument is the
14208 value to be used as the input argument. The possible values for the
14209 constant are the same as those used in the RTL, and are dependent on
14210 the configuration file used to built the GCC back end.
14212 If there are no input operands, this argument may either be omitted, or
14213 explicitly given as @code{No_Input_Operands}. The fourth argument, not
14214 present in the above example, is a list of register names, called the
14215 @dfn{clobber} argument. This argument, if given, must be a static string
14216 expression, and is a space or comma separated list of names of registers
14217 that must be considered destroyed as a result of the @code{Asm} call. If
14218 this argument is the null string (the default value), then the code
14219 generator assumes that no additional registers are destroyed.
14221 The fifth argument, not present in the above example, called the
14222 @dfn{volatile} argument, is by default @code{False}. It can be set to
14223 the literal value @code{True} to indicate to the code generator that all
14224 optimizations with respect to the instruction specified should be
14225 suppressed, and that in particular, for an instruction that has outputs,
14226 the instruction will still be generated, even if none of the outputs are
14227 used. See the full description in the GCC manual for further details.
14228 Generally it is strongly advisable to use Volatile for any ASM statement
14229 that is missing either input or output operands, or when two or more ASM
14230 statements appear in sequence, to avoid unwanted optimizations. A warning
14231 is generated if this advice is not followed.
14233 The @code{Asm} subprograms may be used in two ways. First the procedure
14234 forms can be used anywhere a procedure call would be valid, and
14235 correspond to what the RM calls ``intrinsic'' routines. Such calls can
14236 be used to intersperse machine instructions with other Ada statements.
14237 Second, the function forms, which return a dummy value of the limited
14238 private type @code{Asm_Insn}, can be used in code statements, and indeed
14239 this is the only context where such calls are allowed. Code statements
14240 appear as aggregates of the form:
14242 @smallexample @c ada
14243 Asm_Insn'(Asm (@dots{}));
14244 Asm_Insn'(Asm_Volatile (@dots{}));
14248 In accordance with RM rules, such code statements are allowed only
14249 within subprograms whose entire body consists of such statements. It is
14250 not permissible to intermix such statements with other Ada statements.
14252 Typically the form using intrinsic procedure calls is more convenient
14253 and more flexible. The code statement form is provided to meet the RM
14254 suggestion that such a facility should be made available. The following
14255 is the exact syntax of the call to @code{Asm}. As usual, if named notation
14256 is used, the arguments may be given in arbitrary order, following the
14257 normal rules for use of positional and named arguments)
14261 [Template =>] static_string_EXPRESSION
14262 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
14263 [,[Inputs =>] INPUT_OPERAND_LIST ]
14264 [,[Clobber =>] static_string_EXPRESSION ]
14265 [,[Volatile =>] static_boolean_EXPRESSION] )
14267 OUTPUT_OPERAND_LIST ::=
14268 [PREFIX.]No_Output_Operands
14269 | OUTPUT_OPERAND_ATTRIBUTE
14270 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
14272 OUTPUT_OPERAND_ATTRIBUTE ::=
14273 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
14275 INPUT_OPERAND_LIST ::=
14276 [PREFIX.]No_Input_Operands
14277 | INPUT_OPERAND_ATTRIBUTE
14278 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
14280 INPUT_OPERAND_ATTRIBUTE ::=
14281 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
14285 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
14286 are declared in the package @code{Machine_Code} and must be referenced
14287 according to normal visibility rules. In particular if there is no
14288 @code{use} clause for this package, then appropriate package name
14289 qualification is required.
14291 @node GNAT Implementation of Tasking
14292 @section GNAT Implementation of Tasking
14295 This chapter outlines the basic GNAT approach to tasking (in particular,
14296 a multi-layered library for portability) and discusses issues related
14297 to compliance with the Real-Time Systems Annex.
14300 * Mapping Ada Tasks onto the Underlying Kernel Threads::
14301 * Ensuring Compliance with the Real-Time Annex::
14304 @node Mapping Ada Tasks onto the Underlying Kernel Threads
14305 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
14308 GNAT's run-time support comprises two layers:
14311 @item GNARL (GNAT Run-time Layer)
14312 @item GNULL (GNAT Low-level Library)
14316 In GNAT, Ada's tasking services rely on a platform and OS independent
14317 layer known as GNARL@. This code is responsible for implementing the
14318 correct semantics of Ada's task creation, rendezvous, protected
14321 GNARL decomposes Ada's tasking semantics into simpler lower level
14322 operations such as create a thread, set the priority of a thread,
14323 yield, create a lock, lock/unlock, etc. The spec for these low-level
14324 operations constitutes GNULLI, the GNULL Interface. This interface is
14325 directly inspired from the POSIX real-time API@.
14327 If the underlying executive or OS implements the POSIX standard
14328 faithfully, the GNULL Interface maps as is to the services offered by
14329 the underlying kernel. Otherwise, some target dependent glue code maps
14330 the services offered by the underlying kernel to the semantics expected
14333 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
14334 key point is that each Ada task is mapped on a thread in the underlying
14335 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
14337 In addition Ada task priorities map onto the underlying thread priorities.
14338 Mapping Ada tasks onto the underlying kernel threads has several advantages:
14342 The underlying scheduler is used to schedule the Ada tasks. This
14343 makes Ada tasks as efficient as kernel threads from a scheduling
14347 Interaction with code written in C containing threads is eased
14348 since at the lowest level Ada tasks and C threads map onto the same
14349 underlying kernel concept.
14352 When an Ada task is blocked during I/O the remaining Ada tasks are
14356 On multiprocessor systems Ada tasks can execute in parallel.
14360 Some threads libraries offer a mechanism to fork a new process, with the
14361 child process duplicating the threads from the parent.
14363 support this functionality when the parent contains more than one task.
14364 @cindex Forking a new process
14366 @node Ensuring Compliance with the Real-Time Annex
14367 @subsection Ensuring Compliance with the Real-Time Annex
14368 @cindex Real-Time Systems Annex compliance
14371 Although mapping Ada tasks onto
14372 the underlying threads has significant advantages, it does create some
14373 complications when it comes to respecting the scheduling semantics
14374 specified in the real-time annex (Annex D).
14376 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
14377 scheduling policy states:
14380 @emph{When the active priority of a ready task that is not running
14381 changes, or the setting of its base priority takes effect, the
14382 task is removed from the ready queue for its old active priority
14383 and is added at the tail of the ready queue for its new active
14384 priority, except in the case where the active priority is lowered
14385 due to the loss of inherited priority, in which case the task is
14386 added at the head of the ready queue for its new active priority.}
14390 While most kernels do put tasks at the end of the priority queue when
14391 a task changes its priority, (which respects the main
14392 FIFO_Within_Priorities requirement), almost none keep a thread at the
14393 beginning of its priority queue when its priority drops from the loss
14394 of inherited priority.
14396 As a result most vendors have provided incomplete Annex D implementations.
14398 The GNAT run-time, has a nice cooperative solution to this problem
14399 which ensures that accurate FIFO_Within_Priorities semantics are
14402 The principle is as follows. When an Ada task T is about to start
14403 running, it checks whether some other Ada task R with the same
14404 priority as T has been suspended due to the loss of priority
14405 inheritance. If this is the case, T yields and is placed at the end of
14406 its priority queue. When R arrives at the front of the queue it
14409 Note that this simple scheme preserves the relative order of the tasks
14410 that were ready to execute in the priority queue where R has been
14413 @node GNAT Implementation of Shared Passive Packages
14414 @section GNAT Implementation of Shared Passive Packages
14415 @cindex Shared passive packages
14418 GNAT fully implements the pragma @code{Shared_Passive} for
14419 @cindex pragma @code{Shared_Passive}
14420 the purpose of designating shared passive packages.
14421 This allows the use of passive partitions in the
14422 context described in the Ada Reference Manual; i.e. for communication
14423 between separate partitions of a distributed application using the
14424 features in Annex E.
14426 @cindex Distribution Systems Annex
14428 However, the implementation approach used by GNAT provides for more
14429 extensive usage as follows:
14432 @item Communication between separate programs
14434 This allows separate programs to access the data in passive
14435 partitions, using protected objects for synchronization where
14436 needed. The only requirement is that the two programs have a
14437 common shared file system. It is even possible for programs
14438 running on different machines with different architectures
14439 (e.g. different endianness) to communicate via the data in
14440 a passive partition.
14442 @item Persistence between program runs
14444 The data in a passive package can persist from one run of a
14445 program to another, so that a later program sees the final
14446 values stored by a previous run of the same program.
14451 The implementation approach used is to store the data in files. A
14452 separate stream file is created for each object in the package, and
14453 an access to an object causes the corresponding file to be read or
14456 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
14457 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
14458 set to the directory to be used for these files.
14459 The files in this directory
14460 have names that correspond to their fully qualified names. For
14461 example, if we have the package
14463 @smallexample @c ada
14465 pragma Shared_Passive (X);
14472 and the environment variable is set to @code{/stemp/}, then the files created
14473 will have the names:
14481 These files are created when a value is initially written to the object, and
14482 the files are retained until manually deleted. This provides the persistence
14483 semantics. If no file exists, it means that no partition has assigned a value
14484 to the variable; in this case the initial value declared in the package
14485 will be used. This model ensures that there are no issues in synchronizing
14486 the elaboration process, since elaboration of passive packages elaborates the
14487 initial values, but does not create the files.
14489 The files are written using normal @code{Stream_IO} access.
14490 If you want to be able
14491 to communicate between programs or partitions running on different
14492 architectures, then you should use the XDR versions of the stream attribute
14493 routines, since these are architecture independent.
14495 If active synchronization is required for access to the variables in the
14496 shared passive package, then as described in the Ada Reference Manual, the
14497 package may contain protected objects used for this purpose. In this case
14498 a lock file (whose name is @file{___lock} (three underscores)
14499 is created in the shared memory directory.
14500 @cindex @file{___lock} file (for shared passive packages)
14501 This is used to provide the required locking
14502 semantics for proper protected object synchronization.
14504 As of January 2003, GNAT supports shared passive packages on all platforms
14505 except for OpenVMS.
14507 @node Code Generation for Array Aggregates
14508 @section Code Generation for Array Aggregates
14511 * Static constant aggregates with static bounds::
14512 * Constant aggregates with unconstrained nominal types::
14513 * Aggregates with static bounds::
14514 * Aggregates with non-static bounds::
14515 * Aggregates in assignment statements::
14519 Aggregates have a rich syntax and allow the user to specify the values of
14520 complex data structures by means of a single construct. As a result, the
14521 code generated for aggregates can be quite complex and involve loops, case
14522 statements and multiple assignments. In the simplest cases, however, the
14523 compiler will recognize aggregates whose components and constraints are
14524 fully static, and in those cases the compiler will generate little or no
14525 executable code. The following is an outline of the code that GNAT generates
14526 for various aggregate constructs. For further details, you will find it
14527 useful to examine the output produced by the -gnatG flag to see the expanded
14528 source that is input to the code generator. You may also want to examine
14529 the assembly code generated at various levels of optimization.
14531 The code generated for aggregates depends on the context, the component values,
14532 and the type. In the context of an object declaration the code generated is
14533 generally simpler than in the case of an assignment. As a general rule, static
14534 component values and static subtypes also lead to simpler code.
14536 @node Static constant aggregates with static bounds
14537 @subsection Static constant aggregates with static bounds
14540 For the declarations:
14541 @smallexample @c ada
14542 type One_Dim is array (1..10) of integer;
14543 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
14547 GNAT generates no executable code: the constant ar0 is placed in static memory.
14548 The same is true for constant aggregates with named associations:
14550 @smallexample @c ada
14551 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
14552 Cr3 : constant One_Dim := (others => 7777);
14556 The same is true for multidimensional constant arrays such as:
14558 @smallexample @c ada
14559 type two_dim is array (1..3, 1..3) of integer;
14560 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
14564 The same is true for arrays of one-dimensional arrays: the following are
14567 @smallexample @c ada
14568 type ar1b is array (1..3) of boolean;
14569 type ar_ar is array (1..3) of ar1b;
14570 None : constant ar1b := (others => false); -- fully static
14571 None2 : constant ar_ar := (1..3 => None); -- fully static
14575 However, for multidimensional aggregates with named associations, GNAT will
14576 generate assignments and loops, even if all associations are static. The
14577 following two declarations generate a loop for the first dimension, and
14578 individual component assignments for the second dimension:
14580 @smallexample @c ada
14581 Zero1: constant two_dim := (1..3 => (1..3 => 0));
14582 Zero2: constant two_dim := (others => (others => 0));
14585 @node Constant aggregates with unconstrained nominal types
14586 @subsection Constant aggregates with unconstrained nominal types
14589 In such cases the aggregate itself establishes the subtype, so that
14590 associations with @code{others} cannot be used. GNAT determines the
14591 bounds for the actual subtype of the aggregate, and allocates the
14592 aggregate statically as well. No code is generated for the following:
14594 @smallexample @c ada
14595 type One_Unc is array (natural range <>) of integer;
14596 Cr_Unc : constant One_Unc := (12,24,36);
14599 @node Aggregates with static bounds
14600 @subsection Aggregates with static bounds
14603 In all previous examples the aggregate was the initial (and immutable) value
14604 of a constant. If the aggregate initializes a variable, then code is generated
14605 for it as a combination of individual assignments and loops over the target
14606 object. The declarations
14608 @smallexample @c ada
14609 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
14610 Cr_Var2 : One_Dim := (others > -1);
14614 generate the equivalent of
14616 @smallexample @c ada
14622 for I in Cr_Var2'range loop
14623 Cr_Var2 (I) := =-1;
14627 @node Aggregates with non-static bounds
14628 @subsection Aggregates with non-static bounds
14631 If the bounds of the aggregate are not statically compatible with the bounds
14632 of the nominal subtype of the target, then constraint checks have to be
14633 generated on the bounds. For a multidimensional array, constraint checks may
14634 have to be applied to sub-arrays individually, if they do not have statically
14635 compatible subtypes.
14637 @node Aggregates in assignment statements
14638 @subsection Aggregates in assignment statements
14641 In general, aggregate assignment requires the construction of a temporary,
14642 and a copy from the temporary to the target of the assignment. This is because
14643 it is not always possible to convert the assignment into a series of individual
14644 component assignments. For example, consider the simple case:
14646 @smallexample @c ada
14651 This cannot be converted into:
14653 @smallexample @c ada
14659 So the aggregate has to be built first in a separate location, and then
14660 copied into the target. GNAT recognizes simple cases where this intermediate
14661 step is not required, and the assignments can be performed in place, directly
14662 into the target. The following sufficient criteria are applied:
14666 The bounds of the aggregate are static, and the associations are static.
14668 The components of the aggregate are static constants, names of
14669 simple variables that are not renamings, or expressions not involving
14670 indexed components whose operands obey these rules.
14674 If any of these conditions are violated, the aggregate will be built in
14675 a temporary (created either by the front-end or the code generator) and then
14676 that temporary will be copied onto the target.
14679 @node The Size of Discriminated Records with Default Discriminants
14680 @section The Size of Discriminated Records with Default Discriminants
14683 If a discriminated type @code{T} has discriminants with default values, it is
14684 possible to declare an object of this type without providing an explicit
14687 @smallexample @c ada
14689 type Size is range 1..100;
14691 type Rec (D : Size := 15) is record
14692 Name : String (1..D);
14700 Such an object is said to be @emph{unconstrained}.
14701 The discriminant of the object
14702 can be modified by a full assignment to the object, as long as it preserves the
14703 relation between the value of the discriminant, and the value of the components
14706 @smallexample @c ada
14708 Word := (3, "yes");
14710 Word := (5, "maybe");
14712 Word := (5, "no"); -- raises Constraint_Error
14717 In order to support this behavior efficiently, an unconstrained object is
14718 given the maximum size that any value of the type requires. In the case
14719 above, @code{Word} has storage for the discriminant and for
14720 a @code{String} of length 100.
14721 It is important to note that unconstrained objects do not require dynamic
14722 allocation. It would be an improper implementation to place on the heap those
14723 components whose size depends on discriminants. (This improper implementation
14724 was used by some Ada83 compilers, where the @code{Name} component above
14726 been stored as a pointer to a dynamic string). Following the principle that
14727 dynamic storage management should never be introduced implicitly,
14728 an Ada compiler should reserve the full size for an unconstrained declared
14729 object, and place it on the stack.
14731 This maximum size approach
14732 has been a source of surprise to some users, who expect the default
14733 values of the discriminants to determine the size reserved for an
14734 unconstrained object: ``If the default is 15, why should the object occupy
14736 The answer, of course, is that the discriminant may be later modified,
14737 and its full range of values must be taken into account. This is why the
14742 type Rec (D : Positive := 15) is record
14743 Name : String (1..D);
14751 is flagged by the compiler with a warning:
14752 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
14753 because the required size includes @code{Positive'Last}
14754 bytes. As the first example indicates, the proper approach is to declare an
14755 index type of ``reasonable'' range so that unconstrained objects are not too
14758 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
14759 created in the heap by means of an allocator, then it is @emph{not}
14761 it is constrained by the default values of the discriminants, and those values
14762 cannot be modified by full assignment. This is because in the presence of
14763 aliasing all views of the object (which may be manipulated by different tasks,
14764 say) must be consistent, so it is imperative that the object, once created,
14767 @node Strict Conformance to the Ada Reference Manual
14768 @section Strict Conformance to the Ada Reference Manual
14771 The dynamic semantics defined by the Ada Reference Manual impose a set of
14772 run-time checks to be generated. By default, the GNAT compiler will insert many
14773 run-time checks into the compiled code, including most of those required by the
14774 Ada Reference Manual. However, there are three checks that are not enabled
14775 in the default mode for efficiency reasons: arithmetic overflow checking for
14776 integer operations (including division by zero), checks for access before
14777 elaboration on subprogram calls, and stack overflow checking (most operating
14778 systems do not perform this check by default).
14780 Strict conformance to the Ada Reference Manual can be achieved by adding
14781 three compiler options for overflow checking for integer operations
14782 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
14783 calls and generic instantiations (@option{-gnatE}), and stack overflow
14784 checking (@option{-fstack-check}).
14786 Note that the result of a floating point arithmetic operation in overflow and
14787 invalid situations, when the @code{Machine_Overflows} attribute of the result
14788 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
14789 case for machines compliant with the IEEE floating-point standard, but on
14790 machines that are not fully compliant with this standard, such as Alpha, the
14791 @option{-mieee} compiler flag must be used for achieving IEEE confirming
14792 behavior (although at the cost of a significant performance penalty), so
14793 infinite and and NaN values are properly generated.
14796 @node Project File Reference
14797 @chapter Project File Reference
14800 This chapter describes the syntax and semantics of project files.
14801 Project files specify the options to be used when building a system.
14802 Project files can specify global settings for all tools,
14803 as well as tool-specific settings.
14804 See the chapter on project files in the GNAT Users guide for examples of use.
14808 * Lexical Elements::
14810 * Empty declarations::
14811 * Typed string declarations::
14815 * Project Attributes::
14816 * Attribute References::
14817 * External Values::
14818 * Case Construction::
14820 * Package Renamings::
14822 * Project Extensions::
14823 * Project File Elaboration::
14826 @node Reserved Words
14827 @section Reserved Words
14830 All Ada reserved words are reserved in project files, and cannot be used
14831 as variable names or project names. In addition, the following are
14832 also reserved in project files:
14835 @item @code{extends}
14837 @item @code{external}
14839 @item @code{project}
14843 @node Lexical Elements
14844 @section Lexical Elements
14847 Rules for identifiers are the same as in Ada. Identifiers
14848 are case-insensitive. Strings are case sensitive, except where noted.
14849 Comments have the same form as in Ada.
14859 simple_name @{. simple_name@}
14863 @section Declarations
14866 Declarations introduce new entities that denote types, variables, attributes,
14867 and packages. Some declarations can only appear immediately within a project
14868 declaration. Others can appear within a project or within a package.
14872 declarative_item ::=
14873 simple_declarative_item |
14874 typed_string_declaration |
14875 package_declaration
14877 simple_declarative_item ::=
14878 variable_declaration |
14879 typed_variable_declaration |
14880 attribute_declaration |
14881 case_construction |
14885 @node Empty declarations
14886 @section Empty declarations
14889 empty_declaration ::=
14893 An empty declaration is allowed anywhere a declaration is allowed.
14896 @node Typed string declarations
14897 @section Typed string declarations
14900 Typed strings are sequences of string literals. Typed strings are the only
14901 named types in project files. They are used in case constructions, where they
14902 provide support for conditional attribute definitions.
14906 typed_string_declaration ::=
14907 @b{type} <typed_string_>_simple_name @b{is}
14908 ( string_literal @{, string_literal@} );
14912 A typed string declaration can only appear immediately within a project
14915 All the string literals in a typed string declaration must be distinct.
14921 Variables denote values, and appear as constituents of expressions.
14924 typed_variable_declaration ::=
14925 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
14927 variable_declaration ::=
14928 <variable_>simple_name := expression;
14932 The elaboration of a variable declaration introduces the variable and
14933 assigns to it the value of the expression. The name of the variable is
14934 available after the assignment symbol.
14937 A typed_variable can only be declare once.
14940 a non typed variable can be declared multiple times.
14943 Before the completion of its first declaration, the value of variable
14944 is the null string.
14947 @section Expressions
14950 An expression is a formula that defines a computation or retrieval of a value.
14951 In a project file the value of an expression is either a string or a list
14952 of strings. A string value in an expression is either a literal, the current
14953 value of a variable, an external value, an attribute reference, or a
14954 concatenation operation.
14967 attribute_reference
14973 ( <string_>expression @{ , <string_>expression @} )
14976 @subsection Concatenation
14978 The following concatenation functions are defined:
14980 @smallexample @c ada
14981 function "&" (X : String; Y : String) return String;
14982 function "&" (X : String_List; Y : String) return String_List;
14983 function "&" (X : String_List; Y : String_List) return String_List;
14987 @section Attributes
14990 An attribute declaration defines a property of a project or package. This
14991 property can later be queried by means of an attribute reference.
14992 Attribute values are strings or string lists.
14994 Some attributes are associative arrays. These attributes are mappings whose
14995 domain is a set of strings. These attributes are declared one association
14996 at a time, by specifying a point in the domain and the corresponding image
14997 of the attribute. They may also be declared as a full associative array,
14998 getting the same associations as the corresponding attribute in an imported
14999 or extended project.
15001 Attributes that are not associative arrays are called simple attributes.
15005 attribute_declaration ::=
15006 full_associative_array_declaration |
15007 @b{for} attribute_designator @b{use} expression ;
15009 full_associative_array_declaration ::=
15010 @b{for} <associative_array_attribute_>simple_name @b{use}
15011 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15013 attribute_designator ::=
15014 <simple_attribute_>simple_name |
15015 <associative_array_attribute_>simple_name ( string_literal )
15019 Some attributes are project-specific, and can only appear immediately within
15020 a project declaration. Others are package-specific, and can only appear within
15021 the proper package.
15023 The expression in an attribute definition must be a string or a string_list.
15024 The string literal appearing in the attribute_designator of an associative
15025 array attribute is case-insensitive.
15027 @node Project Attributes
15028 @section Project Attributes
15031 The following attributes apply to a project. All of them are simple
15036 Expression must be a path name. The attribute defines the
15037 directory in which the object files created by the build are to be placed. If
15038 not specified, object files are placed in the project directory.
15041 Expression must be a path name. The attribute defines the
15042 directory in which the executables created by the build are to be placed.
15043 If not specified, executables are placed in the object directory.
15046 Expression must be a list of path names. The attribute
15047 defines the directories in which the source files for the project are to be
15048 found. If not specified, source files are found in the project directory.
15049 If a string in the list ends with "/**", then the directory that precedes
15050 "/**" and all of its subdirectories (recursively) are included in the list
15051 of source directories.
15053 @item Excluded_Source_Dirs
15054 Expression must be a list of strings. Each entry designates a directory that
15055 is not to be included in the list of source directories of the project.
15056 This is normally used when there are strings ending with "/**" in the value
15057 of attribute Source_Dirs.
15060 Expression must be a list of file names. The attribute
15061 defines the individual files, in the project directory, which are to be used
15062 as sources for the project. File names are path_names that contain no directory
15063 information. If the project has no sources the attribute must be declared
15064 explicitly with an empty list.
15066 @item Excluded_Source_Files (Locally_Removed_Files)
15067 Expression must be a list of strings that are legal file names.
15068 Each file name must designate a source that would normally be a source file
15069 in the source directories of the project or, if the project file is an
15070 extending project file, inherited by the current project file. It cannot
15071 designate an immediate source that is not inherited. Each of the source files
15072 in the list are not considered to be sources of the project file: they are not
15073 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15074 Excluded_Source_Files is preferred.
15076 @item Source_List_File
15077 Expression must a single path name. The attribute
15078 defines a text file that contains a list of source file names to be used
15079 as sources for the project
15082 Expression must be a path name. The attribute defines the
15083 directory in which a library is to be built. The directory must exist, must
15084 be distinct from the project's object directory, and must be writable.
15087 Expression must be a string that is a legal file name,
15088 without extension. The attribute defines a string that is used to generate
15089 the name of the library to be built by the project.
15092 Argument must be a string value that must be one of the
15093 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15094 string is case-insensitive. If this attribute is not specified, the library is
15095 a static library. Otherwise, the library may be dynamic or relocatable. This
15096 distinction is operating-system dependent.
15098 @item Library_Version
15099 Expression must be a string value whose interpretation
15100 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15101 libraries as the internal name of the library (the @code{"soname"}). If the
15102 library file name (built from the @code{Library_Name}) is different from the
15103 @code{Library_Version}, then the library file will be a symbolic link to the
15104 actual file whose name will be @code{Library_Version}.
15106 @item Library_Interface
15107 Expression must be a string list. Each element of the string list
15108 must designate a unit of the project.
15109 If this attribute is present in a Library Project File, then the project
15110 file is a Stand-alone Library_Project_File.
15112 @item Library_Auto_Init
15113 Expression must be a single string "true" or "false", case-insensitive.
15114 If this attribute is present in a Stand-alone Library Project File,
15115 it indicates if initialization is automatic when the dynamic library
15118 @item Library_Options
15119 Expression must be a string list. Indicates additional switches that
15120 are to be used when building a shared library.
15123 Expression must be a single string. Designates an alternative to "gcc"
15124 for building shared libraries.
15126 @item Library_Src_Dir
15127 Expression must be a path name. The attribute defines the
15128 directory in which the sources of the interfaces of a Stand-alone Library will
15129 be copied. The directory must exist, must be distinct from the project's
15130 object directory and source directories of all projects in the project tree,
15131 and must be writable.
15133 @item Library_Src_Dir
15134 Expression must be a path name. The attribute defines the
15135 directory in which the ALI files of a Library will
15136 be copied. The directory must exist, must be distinct from the project's
15137 object directory and source directories of all projects in the project tree,
15138 and must be writable.
15140 @item Library_Symbol_File
15141 Expression must be a single string. Its value is the single file name of a
15142 symbol file to be created when building a stand-alone library when the
15143 symbol policy is either "compliant", "controlled" or "restricted",
15144 on platforms that support symbol control, such as VMS. When symbol policy
15145 is "direct", then a file with this name must exist in the object directory.
15147 @item Library_Reference_Symbol_File
15148 Expression must be a single string. Its value is the path name of a
15149 reference symbol file that is read when the symbol policy is either
15150 "compliant" or "controlled", on platforms that support symbol control,
15151 such as VMS, when building a stand-alone library. The path may be an absolute
15152 path or a path relative to the project directory.
15154 @item Library_Symbol_Policy
15155 Expression must be a single string. Its case-insensitive value can only be
15156 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15158 This attribute is not taken into account on all platforms. It controls the
15159 policy for exported symbols and, on some platforms (like VMS) that have the
15160 notions of major and minor IDs built in the library files, it controls
15161 the setting of these IDs.
15163 "autonomous" or "default": exported symbols are not controlled.
15165 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15166 it is equivalent to policy "autonomous". If there are exported symbols in
15167 the reference symbol file that are not in the object files of the interfaces,
15168 the major ID of the library is increased. If there are symbols in the
15169 object files of the interfaces that are not in the reference symbol file,
15170 these symbols are put at the end of the list in the newly created symbol file
15171 and the minor ID is increased.
15173 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15174 The library will fail to build if the exported symbols in the object files of
15175 the interfaces do not match exactly the symbol in the symbol file.
15177 "restricted": The attribute Library_Symbol_File must be defined. The library
15178 will fail to build if there are symbols in the symbol file that are not in
15179 the exported symbols of the object files of the interfaces. Additional symbols
15180 in the object files are not added to the symbol file.
15182 "direct": The attribute Library_Symbol_File must be defined and must designate
15183 an existing file in the object directory. This symbol file is passed directly
15184 to the underlying linker without any symbol processing.
15187 Expression must be a list of strings that are legal file names.
15188 These file names designate existing compilation units in the source directory
15189 that are legal main subprograms.
15191 When a project file is elaborated, as part of the execution of a gnatmake
15192 command, one or several executables are built and placed in the Exec_Dir.
15193 If the gnatmake command does not include explicit file names, the executables
15194 that are built correspond to the files specified by this attribute.
15196 @item Externally_Built
15197 Expression must be a single string. Its value must be either "true" of "false",
15198 case-insensitive. The default is "false". When the value of this attribute is
15199 "true", no attempt is made to compile the sources or to build the library,
15200 when the project is a library project.
15202 @item Main_Language
15203 This is a simple attribute. Its value is a string that specifies the
15204 language of the main program.
15207 Expression must be a string list. Each string designates
15208 a programming language that is known to GNAT. The strings are case-insensitive.
15212 @node Attribute References
15213 @section Attribute References
15216 Attribute references are used to retrieve the value of previously defined
15217 attribute for a package or project.
15220 attribute_reference ::=
15221 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
15223 attribute_prefix ::=
15225 <project_simple_name | package_identifier |
15226 <project_>simple_name . package_identifier
15230 If an attribute has not been specified for a given package or project, its
15231 value is the null string or the empty list.
15233 @node External Values
15234 @section External Values
15237 An external value is an expression whose value is obtained from the command
15238 that invoked the processing of the current project file (typically a
15244 @b{external} ( string_literal [, string_literal] )
15248 The first string_literal is the string to be used on the command line or
15249 in the environment to specify the external value. The second string_literal,
15250 if present, is the default to use if there is no specification for this
15251 external value either on the command line or in the environment.
15253 @node Case Construction
15254 @section Case Construction
15257 A case construction supports attribute and variable declarations that depend
15258 on the value of a previously declared variable.
15262 case_construction ::=
15263 @b{case} <typed_variable_>name @b{is}
15268 @b{when} discrete_choice_list =>
15269 @{case_construction |
15270 attribute_declaration |
15271 variable_declaration |
15272 empty_declaration@}
15274 discrete_choice_list ::=
15275 string_literal @{| string_literal@} |
15280 Inside a case construction, variable declarations must be for variables that
15281 have already been declared before the case construction.
15283 All choices in a choice list must be distinct. The choice lists of two
15284 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
15285 alternatives do not need to include all values of the type. An @code{others}
15286 choice must appear last in the list of alternatives.
15292 A package provides a grouping of variable declarations and attribute
15293 declarations to be used when invoking various GNAT tools. The name of
15294 the package indicates the tool(s) to which it applies.
15298 package_declaration ::=
15299 package_specification | package_renaming
15301 package_specification ::=
15302 @b{package} package_identifier @b{is}
15303 @{simple_declarative_item@}
15304 @b{end} package_identifier ;
15306 package_identifier ::=
15307 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
15308 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
15309 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
15312 @subsection Package Naming
15315 The attributes of a @code{Naming} package specifies the naming conventions
15316 that apply to the source files in a project. When invoking other GNAT tools,
15317 they will use the sources in the source directories that satisfy these
15318 naming conventions.
15320 The following attributes apply to a @code{Naming} package:
15324 This is a simple attribute whose value is a string. Legal values of this
15325 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
15326 These strings are themselves case insensitive.
15329 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
15331 @item Dot_Replacement
15332 This is a simple attribute whose string value satisfies the following
15336 @item It must not be empty
15337 @item It cannot start or end with an alphanumeric character
15338 @item It cannot be a single underscore
15339 @item It cannot start with an underscore followed by an alphanumeric
15340 @item It cannot contain a dot @code{'.'} if longer than one character
15344 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
15347 This is an associative array attribute, defined on language names,
15348 whose image is a string that must satisfy the following
15352 @item It must not be empty
15353 @item It cannot start with an alphanumeric character
15354 @item It cannot start with an underscore followed by an alphanumeric character
15358 For Ada, the attribute denotes the suffix used in file names that contain
15359 library unit declarations, that is to say units that are package and
15360 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
15361 specified, then the default is @code{".ads"}.
15363 For C and C++, the attribute denotes the suffix used in file names that
15364 contain prototypes.
15367 This is an associative array attribute defined on language names,
15368 whose image is a string that must satisfy the following
15372 @item It must not be empty
15373 @item It cannot start with an alphanumeric character
15374 @item It cannot start with an underscore followed by an alphanumeric character
15375 @item It cannot be a suffix of @code{Spec_Suffix}
15379 For Ada, the attribute denotes the suffix used in file names that contain
15380 library bodies, that is to say units that are package and subprogram bodies.
15381 If @code{Body_Suffix ("Ada")} is not specified, then the default is
15384 For C and C++, the attribute denotes the suffix used in file names that contain
15387 @item Separate_Suffix
15388 This is a simple attribute whose value satisfies the same conditions as
15389 @code{Body_Suffix}.
15391 This attribute is specific to Ada. It denotes the suffix used in file names
15392 that contain separate bodies. If it is not specified, then it defaults to same
15393 value as @code{Body_Suffix ("Ada")}.
15396 This is an associative array attribute, specific to Ada, defined over
15397 compilation unit names. The image is a string that is the name of the file
15398 that contains that library unit. The file name is case sensitive if the
15399 conventions of the host operating system require it.
15402 This is an associative array attribute, specific to Ada, defined over
15403 compilation unit names. The image is a string that is the name of the file
15404 that contains the library unit body for the named unit. The file name is case
15405 sensitive if the conventions of the host operating system require it.
15407 @item Specification_Exceptions
15408 This is an associative array attribute defined on language names,
15409 whose value is a list of strings.
15411 This attribute is not significant for Ada.
15413 For C and C++, each string in the list denotes the name of a file that
15414 contains prototypes, but whose suffix is not necessarily the
15415 @code{Spec_Suffix} for the language.
15417 @item Implementation_Exceptions
15418 This is an associative array attribute defined on language names,
15419 whose value is a list of strings.
15421 This attribute is not significant for Ada.
15423 For C and C++, each string in the list denotes the name of a file that
15424 contains source code, but whose suffix is not necessarily the
15425 @code{Body_Suffix} for the language.
15428 The following attributes of package @code{Naming} are obsolescent. They are
15429 kept as synonyms of other attributes for compatibility with previous versions
15430 of the Project Manager.
15433 @item Specification_Suffix
15434 This is a synonym of @code{Spec_Suffix}.
15436 @item Implementation_Suffix
15437 This is a synonym of @code{Body_Suffix}.
15439 @item Specification
15440 This is a synonym of @code{Spec}.
15442 @item Implementation
15443 This is a synonym of @code{Body}.
15446 @subsection package Compiler
15449 The attributes of the @code{Compiler} package specify the compilation options
15450 to be used by the underlying compiler.
15453 @item Default_Switches
15454 This is an associative array attribute. Its
15455 domain is a set of language names. Its range is a string list that
15456 specifies the compilation options to be used when compiling a component
15457 written in that language, for which no file-specific switches have been
15461 This is an associative array attribute. Its domain is
15462 a set of file names. Its range is a string list that specifies the
15463 compilation options to be used when compiling the named file. If a file
15464 is not specified in the Switches attribute, it is compiled with the
15465 options specified by Default_Switches of its language, if defined.
15467 @item Local_Configuration_Pragmas.
15468 This is a simple attribute, whose
15469 value is a path name that designates a file containing configuration pragmas
15470 to be used for all invocations of the compiler for immediate sources of the
15474 @subsection package Builder
15477 The attributes of package @code{Builder} specify the compilation, binding, and
15478 linking options to be used when building an executable for a project. The
15479 following attributes apply to package @code{Builder}:
15482 @item Default_Switches
15483 This is an associative array attribute. Its
15484 domain is a set of language names. Its range is a string list that
15485 specifies options to be used when building a main
15486 written in that language, for which no file-specific switches have been
15490 This is an associative array attribute. Its domain is
15491 a set of file names. Its range is a string list that specifies
15492 options to be used when building the named main file. If a main file
15493 is not specified in the Switches attribute, it is built with the
15494 options specified by Default_Switches of its language, if defined.
15496 @item Global_Configuration_Pragmas
15497 This is a simple attribute, whose
15498 value is a path name that designates a file that contains configuration pragmas
15499 to be used in every build of an executable. If both local and global
15500 configuration pragmas are specified, a compilation makes use of both sets.
15504 This is an associative array attribute. Its domain is
15505 a set of main source file names. Its range is a simple string that specifies
15506 the executable file name to be used when linking the specified main source.
15507 If a main source is not specified in the Executable attribute, the executable
15508 file name is deducted from the main source file name.
15509 This attribute has no effect if its value is the empty string.
15511 @item Executable_Suffix
15512 This is a simple attribute whose value is the suffix to be added to
15513 the executables that don't have an attribute Executable specified.
15516 @subsection package Gnatls
15519 The attributes of package @code{Gnatls} specify the tool options to be used
15520 when invoking the library browser @command{gnatls}.
15521 The following attributes apply to package @code{Gnatls}:
15525 This is a single attribute with a string list value. Each non empty string
15526 in the list is an option when invoking @code{gnatls}.
15529 @subsection package Binder
15532 The attributes of package @code{Binder} specify the options to be used
15533 when invoking the binder in the construction of an executable.
15534 The following attributes apply to package @code{Binder}:
15537 @item Default_Switches
15538 This is an associative array attribute. Its
15539 domain is a set of language names. Its range is a string list that
15540 specifies options to be used when binding a main
15541 written in that language, for which no file-specific switches have been
15545 This is an associative array attribute. Its domain is
15546 a set of file names. Its range is a string list that specifies
15547 options to be used when binding the named main file. If a main file
15548 is not specified in the Switches attribute, it is bound with the
15549 options specified by Default_Switches of its language, if defined.
15552 @subsection package Linker
15555 The attributes of package @code{Linker} specify the options to be used when
15556 invoking the linker in the construction of an executable.
15557 The following attributes apply to package @code{Linker}:
15560 @item Default_Switches
15561 This is an associative array attribute. Its
15562 domain is a set of language names. Its range is a string list that
15563 specifies options to be used when linking a main
15564 written in that language, for which no file-specific switches have been
15568 This is an associative array attribute. Its domain is
15569 a set of file names. Its range is a string list that specifies
15570 options to be used when linking the named main file. If a main file
15571 is not specified in the Switches attribute, it is linked with the
15572 options specified by Default_Switches of its language, if defined.
15574 @item Linker_Options
15575 This is a string list attribute. Its value specifies additional options that
15576 be given to the linker when linking an executable. This attribute is not
15577 used in the main project, only in projects imported directly or indirectly.
15581 @subsection package Cross_Reference
15584 The attributes of package @code{Cross_Reference} specify the tool options
15586 when invoking the library tool @command{gnatxref}.
15587 The following attributes apply to package @code{Cross_Reference}:
15590 @item Default_Switches
15591 This is an associative array attribute. Its
15592 domain is a set of language names. Its range is a string list that
15593 specifies options to be used when calling @command{gnatxref} on a source
15594 written in that language, for which no file-specific switches have been
15598 This is an associative array attribute. Its domain is
15599 a set of file names. Its range is a string list that specifies
15600 options to be used when calling @command{gnatxref} on the named main source.
15601 If a source is not specified in the Switches attribute, @command{gnatxref} will
15602 be called with the options specified by Default_Switches of its language,
15606 @subsection package Finder
15609 The attributes of package @code{Finder} specify the tool options to be used
15610 when invoking the search tool @command{gnatfind}.
15611 The following attributes apply to package @code{Finder}:
15614 @item Default_Switches
15615 This is an associative array attribute. Its
15616 domain is a set of language names. Its range is a string list that
15617 specifies options to be used when calling @command{gnatfind} on a source
15618 written in that language, for which no file-specific switches have been
15622 This is an associative array attribute. Its domain is
15623 a set of file names. Its range is a string list that specifies
15624 options to be used when calling @command{gnatfind} on the named main source.
15625 If a source is not specified in the Switches attribute, @command{gnatfind} will
15626 be called with the options specified by Default_Switches of its language,
15630 @subsection package Pretty_Printer
15633 The attributes of package @code{Pretty_Printer}
15634 specify the tool options to be used
15635 when invoking the formatting tool @command{gnatpp}.
15636 The following attributes apply to package @code{Pretty_Printer}:
15639 @item Default_switches
15640 This is an associative array attribute. Its
15641 domain is a set of language names. Its range is a string list that
15642 specifies options to be used when calling @command{gnatpp} on a source
15643 written in that language, for which no file-specific switches have been
15647 This is an associative array attribute. Its domain is
15648 a set of file names. Its range is a string list that specifies
15649 options to be used when calling @command{gnatpp} on the named main source.
15650 If a source is not specified in the Switches attribute, @command{gnatpp} will
15651 be called with the options specified by Default_Switches of its language,
15655 @subsection package gnatstub
15658 The attributes of package @code{gnatstub}
15659 specify the tool options to be used
15660 when invoking the tool @command{gnatstub}.
15661 The following attributes apply to package @code{gnatstub}:
15664 @item Default_switches
15665 This is an associative array attribute. Its
15666 domain is a set of language names. Its range is a string list that
15667 specifies options to be used when calling @command{gnatstub} on a source
15668 written in that language, for which no file-specific switches have been
15672 This is an associative array attribute. Its domain is
15673 a set of file names. Its range is a string list that specifies
15674 options to be used when calling @command{gnatstub} on the named main source.
15675 If a source is not specified in the Switches attribute, @command{gnatpp} will
15676 be called with the options specified by Default_Switches of its language,
15680 @subsection package Eliminate
15683 The attributes of package @code{Eliminate}
15684 specify the tool options to be used
15685 when invoking the tool @command{gnatelim}.
15686 The following attributes apply to package @code{Eliminate}:
15689 @item Default_switches
15690 This is an associative array attribute. Its
15691 domain is a set of language names. Its range is a string list that
15692 specifies options to be used when calling @command{gnatelim} on a source
15693 written in that language, for which no file-specific switches have been
15697 This is an associative array attribute. Its domain is
15698 a set of file names. Its range is a string list that specifies
15699 options to be used when calling @command{gnatelim} on the named main source.
15700 If a source is not specified in the Switches attribute, @command{gnatelim} will
15701 be called with the options specified by Default_Switches of its language,
15705 @subsection package Metrics
15708 The attributes of package @code{Metrics}
15709 specify the tool options to be used
15710 when invoking the tool @command{gnatmetric}.
15711 The following attributes apply to package @code{Metrics}:
15714 @item Default_switches
15715 This is an associative array attribute. Its
15716 domain is a set of language names. Its range is a string list that
15717 specifies options to be used when calling @command{gnatmetric} on a source
15718 written in that language, for which no file-specific switches have been
15722 This is an associative array attribute. Its domain is
15723 a set of file names. Its range is a string list that specifies
15724 options to be used when calling @command{gnatmetric} on the named main source.
15725 If a source is not specified in the Switches attribute, @command{gnatmetric}
15726 will be called with the options specified by Default_Switches of its language,
15730 @subsection package IDE
15733 The attributes of package @code{IDE} specify the options to be used when using
15734 an Integrated Development Environment such as @command{GPS}.
15738 This is a simple attribute. Its value is a string that designates the remote
15739 host in a cross-compilation environment, to be used for remote compilation and
15740 debugging. This field should not be specified when running on the local
15744 This is a simple attribute. Its value is a string that specifies the
15745 name of IP address of the embedded target in a cross-compilation environment,
15746 on which the program should execute.
15748 @item Communication_Protocol
15749 This is a simple string attribute. Its value is the name of the protocol
15750 to use to communicate with the target in a cross-compilation environment,
15751 e.g. @code{"wtx"} or @code{"vxworks"}.
15753 @item Compiler_Command
15754 This is an associative array attribute, whose domain is a language name. Its
15755 value is string that denotes the command to be used to invoke the compiler.
15756 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
15757 gnatmake, in particular in the handling of switches.
15759 @item Debugger_Command
15760 This is simple attribute, Its value is a string that specifies the name of
15761 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
15763 @item Default_Switches
15764 This is an associative array attribute. Its indexes are the name of the
15765 external tools that the GNAT Programming System (GPS) is supporting. Its
15766 value is a list of switches to use when invoking that tool.
15769 This is a simple attribute. Its value is a string that specifies the name
15770 of the @command{gnatls} utility to be used to retrieve information about the
15771 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
15774 This is a simple attribute. Its value is a string used to specify the
15775 Version Control System (VCS) to be used for this project, e.g CVS, RCS
15776 ClearCase or Perforce.
15778 @item VCS_File_Check
15779 This is a simple attribute. Its value is a string that specifies the
15780 command used by the VCS to check the validity of a file, either
15781 when the user explicitly asks for a check, or as a sanity check before
15782 doing the check-in.
15784 @item VCS_Log_Check
15785 This is a simple attribute. Its value is a string that specifies
15786 the command used by the VCS to check the validity of a log file.
15788 @item VCS_Repository_Root
15789 The VCS repository root path. This is used to create tags or branches
15790 of the repository. For subversion the value should be the @code{URL}
15791 as specified to check-out the working copy of the repository.
15793 @item VCS_Patch_Root
15794 The local root directory to use for building patch file. All patch chunks
15795 will be relative to this path. The root project directory is used if
15796 this value is not defined.
15800 @node Package Renamings
15801 @section Package Renamings
15804 A package can be defined by a renaming declaration. The new package renames
15805 a package declared in a different project file, and has the same attributes
15806 as the package it renames.
15809 package_renaming ::==
15810 @b{package} package_identifier @b{renames}
15811 <project_>simple_name.package_identifier ;
15815 The package_identifier of the renamed package must be the same as the
15816 package_identifier. The project whose name is the prefix of the renamed
15817 package must contain a package declaration with this name. This project
15818 must appear in the context_clause of the enclosing project declaration,
15819 or be the parent project of the enclosing child project.
15825 A project file specifies a set of rules for constructing a software system.
15826 A project file can be self-contained, or depend on other project files.
15827 Dependencies are expressed through a context clause that names other projects.
15833 context_clause project_declaration
15835 project_declaration ::=
15836 simple_project_declaration | project_extension
15838 simple_project_declaration ::=
15839 @b{project} <project_>simple_name @b{is}
15840 @{declarative_item@}
15841 @b{end} <project_>simple_name;
15847 [@b{limited}] @b{with} path_name @{ , path_name @} ;
15854 A path name denotes a project file. A path name can be absolute or relative.
15855 An absolute path name includes a sequence of directories, in the syntax of
15856 the host operating system, that identifies uniquely the project file in the
15857 file system. A relative path name identifies the project file, relative
15858 to the directory that contains the current project, or relative to a
15859 directory listed in the environment variable ADA_PROJECT_PATH.
15860 Path names are case sensitive if file names in the host operating system
15861 are case sensitive.
15863 The syntax of the environment variable ADA_PROJECT_PATH is a list of
15864 directory names separated by colons (semicolons on Windows).
15866 A given project name can appear only once in a context_clause.
15868 It is illegal for a project imported by a context clause to refer, directly
15869 or indirectly, to the project in which this context clause appears (the
15870 dependency graph cannot contain cycles), except when one of the with_clause
15871 in the cycle is a @code{limited with}.
15873 @node Project Extensions
15874 @section Project Extensions
15877 A project extension introduces a new project, which inherits the declarations
15878 of another project.
15882 project_extension ::=
15883 @b{project} <project_>simple_name @b{extends} path_name @b{is}
15884 @{declarative_item@}
15885 @b{end} <project_>simple_name;
15889 The project extension declares a child project. The child project inherits
15890 all the declarations and all the files of the parent project, These inherited
15891 declaration can be overridden in the child project, by means of suitable
15894 @node Project File Elaboration
15895 @section Project File Elaboration
15898 A project file is processed as part of the invocation of a gnat tool that
15899 uses the project option. Elaboration of the process file consists in the
15900 sequential elaboration of all its declarations. The computed values of
15901 attributes and variables in the project are then used to establish the
15902 environment in which the gnat tool will execute.
15904 @node Obsolescent Features
15905 @chapter Obsolescent Features
15908 This chapter describes features that are provided by GNAT, but are
15909 considered obsolescent since there are preferred ways of achieving
15910 the same effect. These features are provided solely for historical
15911 compatibility purposes.
15914 * pragma No_Run_Time::
15915 * pragma Ravenscar::
15916 * pragma Restricted_Run_Time::
15919 @node pragma No_Run_Time
15920 @section pragma No_Run_Time
15922 The pragma @code{No_Run_Time} is used to achieve an affect similar
15923 to the use of the "Zero Foot Print" configurable run time, but without
15924 requiring a specially configured run time. The result of using this
15925 pragma, which must be used for all units in a partition, is to restrict
15926 the use of any language features requiring run-time support code. The
15927 preferred usage is to use an appropriately configured run-time that
15928 includes just those features that are to be made accessible.
15930 @node pragma Ravenscar
15931 @section pragma Ravenscar
15933 The pragma @code{Ravenscar} has exactly the same effect as pragma
15934 @code{Profile (Ravenscar)}. The latter usage is preferred since it
15935 is part of the new Ada 2005 standard.
15937 @node pragma Restricted_Run_Time
15938 @section pragma Restricted_Run_Time
15940 The pragma @code{Restricted_Run_Time} has exactly the same effect as
15941 pragma @code{Profile (Restricted)}. The latter usage is
15942 preferred since the Ada 2005 pragma @code{Profile} is intended for
15943 this kind of implementation dependent addition.
15946 @c GNU Free Documentation License
15948 @node Index,,GNU Free Documentation License, Top