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::
112 * Pragma Common_Object::
113 * Pragma Compile_Time_Error::
114 * Pragma Compile_Time_Warning::
115 * Pragma Complete_Representation::
116 * Pragma Complex_Representation::
117 * Pragma Component_Alignment::
118 * Pragma Convention_Identifier::
120 * Pragma CPP_Constructor::
121 * Pragma CPP_Virtual::
122 * Pragma CPP_Vtable::
124 * Pragma Debug_Policy::
125 * Pragma Detect_Blocking::
126 * Pragma Elaboration_Checks::
128 * Pragma Export_Exception::
129 * Pragma Export_Function::
130 * Pragma Export_Object::
131 * Pragma Export_Procedure::
132 * Pragma Export_Value::
133 * Pragma Export_Valued_Procedure::
134 * Pragma Extend_System::
136 * Pragma External_Name_Casing::
137 * Pragma Finalize_Storage_Only::
138 * Pragma Float_Representation::
140 * Pragma Import_Exception::
141 * Pragma Import_Function::
142 * Pragma Import_Object::
143 * Pragma Import_Procedure::
144 * Pragma Import_Valued_Procedure::
145 * Pragma Initialize_Scalars::
146 * Pragma Inline_Always::
147 * Pragma Inline_Generic::
149 * Pragma Interface_Name::
150 * Pragma Interrupt_Handler::
151 * Pragma Interrupt_State::
152 * Pragma Keep_Names::
155 * Pragma Linker_Alias::
156 * Pragma Linker_Constructor::
157 * Pragma Linker_Destructor::
158 * Pragma Linker_Section::
159 * Pragma Long_Float::
160 * Pragma Machine_Attribute::
161 * Pragma Main_Storage::
164 * Pragma No_Strict_Aliasing ::
165 * Pragma Normalize_Scalars::
166 * Pragma Obsolescent::
168 * Pragma Persistent_BSS::
170 * Pragma Profile (Ravenscar)::
171 * Pragma Profile (Restricted)::
172 * Pragma Psect_Object::
173 * Pragma Pure_Function::
174 * Pragma Restriction_Warnings::
175 * Pragma Source_File_Name::
176 * Pragma Source_File_Name_Project::
177 * Pragma Source_Reference::
178 * Pragma Stream_Convert::
179 * Pragma Style_Checks::
182 * Pragma Suppress_All::
183 * Pragma Suppress_Exception_Locations::
184 * Pragma Suppress_Initialization::
187 * Pragma Task_Storage::
188 * Pragma Time_Slice::
190 * Pragma Unchecked_Union::
191 * Pragma Unimplemented_Unit::
192 * Pragma Universal_Aliasing ::
193 * Pragma Universal_Data::
194 * Pragma Unreferenced::
195 * Pragma Unreferenced_Objects::
196 * Pragma Unreserve_All_Interrupts::
197 * Pragma Unsuppress::
198 * Pragma Use_VADS_Size::
199 * Pragma Validity_Checks::
202 * Pragma Weak_External::
203 * Pragma Wide_Character_Encoding::
205 Implementation Defined Attributes
215 * Default_Bit_Order::
223 * Has_Access_Values::
224 * Has_Discriminants::
230 * Max_Interrupt_Priority::
232 * Maximum_Alignment::
236 * Passed_By_Reference::
248 * Unconstrained_Array::
249 * Universal_Literal_String::
250 * Unrestricted_Access::
256 The Implementation of Standard I/O
258 * Standard I/O Packages::
264 * Wide_Wide_Text_IO::
267 * Filenames encoding::
269 * Operations on C Streams::
270 * Interfacing to C Streams::
274 * Ada.Characters.Latin_9 (a-chlat9.ads)::
275 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
276 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
277 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
278 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
279 * Ada.Command_Line.Remove (a-colire.ads)::
280 * Ada.Command_Line.Environment (a-colien.ads)::
281 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
282 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
283 * Ada.Exceptions.Traceback (a-exctra.ads)::
284 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
285 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
286 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
287 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
288 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
289 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
290 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
291 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
292 * GNAT.Altivec (g-altive.ads)::
293 * GNAT.Altivec.Conversions (g-altcon.ads)::
294 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
295 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
296 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
297 * GNAT.Array_Split (g-arrspl.ads)::
298 * GNAT.AWK (g-awk.ads)::
299 * GNAT.Bounded_Buffers (g-boubuf.ads)::
300 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
301 * GNAT.Bubble_Sort (g-bubsor.ads)::
302 * GNAT.Bubble_Sort_A (g-busora.ads)::
303 * GNAT.Bubble_Sort_G (g-busorg.ads)::
304 * GNAT.Byte_Swapping (g-bytswa.ads)::
305 * GNAT.Calendar (g-calend.ads)::
306 * GNAT.Calendar.Time_IO (g-catiio.ads)::
307 * GNAT.Case_Util (g-casuti.ads)::
308 * GNAT.CGI (g-cgi.ads)::
309 * GNAT.CGI.Cookie (g-cgicoo.ads)::
310 * GNAT.CGI.Debug (g-cgideb.ads)::
311 * GNAT.Command_Line (g-comlin.ads)::
312 * GNAT.Compiler_Version (g-comver.ads)::
313 * GNAT.Ctrl_C (g-ctrl_c.ads)::
314 * GNAT.CRC32 (g-crc32.ads)::
315 * GNAT.Current_Exception (g-curexc.ads)::
316 * GNAT.Debug_Pools (g-debpoo.ads)::
317 * GNAT.Debug_Utilities (g-debuti.ads)::
318 * GNAT.Directory_Operations (g-dirope.ads)::
319 * GNAT.Dynamic_HTables (g-dynhta.ads)::
320 * GNAT.Dynamic_Tables (g-dyntab.ads)::
321 * GNAT.Exception_Actions (g-excact.ads)::
322 * GNAT.Exception_Traces (g-exctra.ads)::
323 * GNAT.Exceptions (g-except.ads)::
324 * GNAT.Expect (g-expect.ads)::
325 * GNAT.Float_Control (g-flocon.ads)::
326 * GNAT.Heap_Sort (g-heasor.ads)::
327 * GNAT.Heap_Sort_A (g-hesora.ads)::
328 * GNAT.Heap_Sort_G (g-hesorg.ads)::
329 * GNAT.HTable (g-htable.ads)::
330 * GNAT.IO (g-io.ads)::
331 * GNAT.IO_Aux (g-io_aux.ads)::
332 * GNAT.Lock_Files (g-locfil.ads)::
333 * GNAT.MD5 (g-md5.ads)::
334 * GNAT.Memory_Dump (g-memdum.ads)::
335 * GNAT.Most_Recent_Exception (g-moreex.ads)::
336 * GNAT.OS_Lib (g-os_lib.ads)::
337 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
338 * GNAT.Regexp (g-regexp.ads)::
339 * GNAT.Registry (g-regist.ads)::
340 * GNAT.Regpat (g-regpat.ads)::
341 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
342 * GNAT.Semaphores (g-semaph.ads)::
343 * GNAT.SHA1 (g-sha1.ads)::
344 * GNAT.Signals (g-signal.ads)::
345 * GNAT.Sockets (g-socket.ads)::
346 * GNAT.Source_Info (g-souinf.ads)::
347 * GNAT.Spell_Checker (g-speche.ads)::
348 * GNAT.Spitbol.Patterns (g-spipat.ads)::
349 * GNAT.Spitbol (g-spitbo.ads)::
350 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
351 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
352 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
353 * GNAT.Strings (g-string.ads)::
354 * GNAT.String_Split (g-strspl.ads)::
355 * GNAT.Table (g-table.ads)::
356 * GNAT.Task_Lock (g-tasloc.ads)::
357 * GNAT.Threads (g-thread.ads)::
358 * GNAT.Traceback (g-traceb.ads)::
359 * GNAT.Traceback.Symbolic (g-trasym.ads)::
360 * GNAT.Wide_String_Split (g-wistsp.ads)::
361 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
362 * Interfaces.C.Extensions (i-cexten.ads)::
363 * Interfaces.C.Streams (i-cstrea.ads)::
364 * Interfaces.CPP (i-cpp.ads)::
365 * Interfaces.Os2lib (i-os2lib.ads)::
366 * Interfaces.Os2lib.Errors (i-os2err.ads)::
367 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
368 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
369 * Interfaces.Packed_Decimal (i-pacdec.ads)::
370 * Interfaces.VxWorks (i-vxwork.ads)::
371 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
372 * System.Address_Image (s-addima.ads)::
373 * System.Assertions (s-assert.ads)::
374 * System.Memory (s-memory.ads)::
375 * System.Partition_Interface (s-parint.ads)::
376 * System.Restrictions (s-restri.ads)::
377 * System.Rident (s-rident.ads)::
378 * System.Task_Info (s-tasinf.ads)::
379 * System.Wch_Cnv (s-wchcnv.ads)::
380 * System.Wch_Con (s-wchcon.ads)::
384 * Text_IO Stream Pointer Positioning::
385 * Text_IO Reading and Writing Non-Regular Files::
387 * Treating Text_IO Files as Streams::
388 * Text_IO Extensions::
389 * Text_IO Facilities for Unbounded Strings::
393 * Wide_Text_IO Stream Pointer Positioning::
394 * Wide_Text_IO Reading and Writing Non-Regular Files::
398 * Wide_Wide_Text_IO Stream Pointer Positioning::
399 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
401 Interfacing to Other Languages
404 * Interfacing to C++::
405 * Interfacing to COBOL::
406 * Interfacing to Fortran::
407 * Interfacing to non-GNAT Ada code::
409 Specialized Needs Annexes
411 Implementation of Specific Ada Features
412 * Machine Code Insertions::
413 * GNAT Implementation of Tasking::
414 * GNAT Implementation of Shared Passive Packages::
415 * Code Generation for Array Aggregates::
416 * The Size of Discriminated Records with Default Discriminants::
417 * Strict Conformance to the Ada Reference Manual::
419 Project File Reference
423 GNU Free Documentation License
430 @node About This Guide
431 @unnumbered About This Guide
434 This manual contains useful information in writing programs using the
435 @value{EDITION} compiler. It includes information on implementation dependent
436 characteristics of @value{EDITION}, including all the information required by
437 Annex M of the Ada language standard.
439 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
440 Ada 83 compatibility mode.
441 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
442 but you can override with a compiler switch
443 to explicitly specify the language version.
444 (Please refer to the section ``Compiling Different Versions of Ada'', in
445 @cite{@value{EDITION} User's Guide}, for details on these switches.)
446 Throughout this manual, references to ``Ada'' without a year suffix
447 apply to both the Ada 95 and Ada 2005 versions of the language.
449 Ada is designed to be highly portable.
450 In general, a program will have the same effect even when compiled by
451 different compilers on different platforms.
452 However, since Ada is designed to be used in a
453 wide variety of applications, it also contains a number of system
454 dependent features to be used in interfacing to the external world.
455 @cindex Implementation-dependent features
458 Note: Any program that makes use of implementation-dependent features
459 may be non-portable. You should follow good programming practice and
460 isolate and clearly document any sections of your program that make use
461 of these features in a non-portable manner.
464 For ease of exposition, ``GNAT Pro'' will be referred to simply as
465 ``GNAT'' in the remainder of this document.
469 * What This Reference Manual Contains::
471 * Related Information::
474 @node What This Reference Manual Contains
475 @unnumberedsec What This Reference Manual Contains
478 This reference manual contains the following chapters:
482 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
483 pragmas, which can be used to extend and enhance the functionality of the
487 @ref{Implementation Defined Attributes}, lists GNAT
488 implementation-dependent attributes which can be used to extend and
489 enhance the functionality of the compiler.
492 @ref{Implementation Advice}, provides information on generally
493 desirable behavior which are not requirements that all compilers must
494 follow since it cannot be provided on all systems, or which may be
495 undesirable on some systems.
498 @ref{Implementation Defined Characteristics}, provides a guide to
499 minimizing implementation dependent features.
502 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
503 implemented by GNAT, and how they can be imported into user
504 application programs.
507 @ref{Representation Clauses and Pragmas}, describes in detail the
508 way that GNAT represents data, and in particular the exact set
509 of representation clauses and pragmas that is accepted.
512 @ref{Standard Library Routines}, provides a listing of packages and a
513 brief description of the functionality that is provided by Ada's
514 extensive set of standard library routines as implemented by GNAT@.
517 @ref{The Implementation of Standard I/O}, details how the GNAT
518 implementation of the input-output facilities.
521 @ref{The GNAT Library}, is a catalog of packages that complement
522 the Ada predefined library.
525 @ref{Interfacing to Other Languages}, describes how programs
526 written in Ada using GNAT can be interfaced to other programming
529 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
530 of the specialized needs annexes.
533 @ref{Implementation of Specific Ada Features}, discusses issues related
534 to GNAT's implementation of machine code insertions, tasking, and several
538 @ref{Project File Reference}, presents the syntax and semantics
542 @ref{Obsolescent Features} documents implementation dependent features,
543 including pragmas and attributes, which are considered obsolescent, since
544 there are other preferred ways of achieving the same results. These
545 obsolescent forms are retained for backwards compatibility.
549 @cindex Ada 95 Language Reference Manual
550 @cindex Ada 2005 Language Reference Manual
552 This reference manual assumes a basic familiarity with the Ada 95 language, as
553 described in the International Standard ANSI/ISO/IEC-8652:1995,
555 It does not require knowledge of the new features introduced by Ada 2005,
556 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
558 Both reference manuals are included in the GNAT documentation
562 @unnumberedsec Conventions
563 @cindex Conventions, typographical
564 @cindex Typographical conventions
567 Following are examples of the typographical and graphic conventions used
572 @code{Functions}, @code{utility program names}, @code{standard names},
579 @file{File Names}, @samp{button names}, and @samp{field names}.
588 [optional information or parameters]
591 Examples are described by text
593 and then shown this way.
598 Commands that are entered by the user are preceded in this manual by the
599 characters @samp{$ } (dollar sign followed by space). If your system uses this
600 sequence as a prompt, then the commands will appear exactly as you see them
601 in the manual. If your system uses some other prompt, then the command will
602 appear with the @samp{$} replaced by whatever prompt character you are using.
604 @node Related Information
605 @unnumberedsec Related Information
607 See the following documents for further information on GNAT:
611 @cite{GNAT User's Guide}, which provides information on how to use
612 the GNAT compiler system.
615 @cite{Ada 95 Reference Manual}, which contains all reference
616 material for the Ada 95 programming language.
619 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
620 of the Ada 95 standard. The annotations describe
621 detailed aspects of the design decision, and in particular contain useful
622 sections on Ada 83 compatibility.
625 @cite{Ada 2005 Reference Manual}, which contains all reference
626 material for the Ada 2005 programming language.
629 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
630 of the Ada 2005 standard. The annotations describe
631 detailed aspects of the design decision, and in particular contain useful
632 sections on Ada 83 and Ada 95 compatibility.
635 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
636 which contains specific information on compatibility between GNAT and
640 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
641 describes in detail the pragmas and attributes provided by the DEC Ada 83
646 @node Implementation Defined Pragmas
647 @chapter Implementation Defined Pragmas
650 Ada defines a set of pragmas that can be used to supply additional
651 information to the compiler. These language defined pragmas are
652 implemented in GNAT and work as described in the Ada Reference
655 In addition, Ada allows implementations to define additional pragmas
656 whose meaning is defined by the implementation. GNAT provides a number
657 of these implementation-dependent pragmas which can be used to extend
658 and enhance the functionality of the compiler. This section of the GNAT
659 Reference Manual describes these additional pragmas.
661 Note that any program using these pragmas may not be portable to other
662 compilers (although GNAT implements this set of pragmas on all
663 platforms). Therefore if portability to other compilers is an important
664 consideration, the use of these pragmas should be minimized.
667 * Pragma Abort_Defer::
675 * Pragma C_Pass_By_Copy::
677 * Pragma Common_Object::
678 * Pragma Compile_Time_Error::
679 * Pragma Compile_Time_Warning::
680 * Pragma Complete_Representation::
681 * Pragma Complex_Representation::
682 * Pragma Component_Alignment::
683 * Pragma Convention_Identifier::
685 * Pragma CPP_Constructor::
686 * Pragma CPP_Virtual::
687 * Pragma CPP_Vtable::
689 * Pragma Debug_Policy::
690 * Pragma Detect_Blocking::
691 * Pragma Elaboration_Checks::
693 * Pragma Export_Exception::
694 * Pragma Export_Function::
695 * Pragma Export_Object::
696 * Pragma Export_Procedure::
697 * Pragma Export_Value::
698 * Pragma Export_Valued_Procedure::
699 * Pragma Extend_System::
701 * Pragma External_Name_Casing::
702 * Pragma Finalize_Storage_Only::
703 * Pragma Float_Representation::
705 * Pragma Import_Exception::
706 * Pragma Import_Function::
707 * Pragma Import_Object::
708 * Pragma Import_Procedure::
709 * Pragma Import_Valued_Procedure::
710 * Pragma Initialize_Scalars::
711 * Pragma Inline_Always::
712 * Pragma Inline_Generic::
714 * Pragma Interface_Name::
715 * Pragma Interrupt_Handler::
716 * Pragma Interrupt_State::
717 * Pragma Keep_Names::
720 * Pragma Linker_Alias::
721 * Pragma Linker_Constructor::
722 * Pragma Linker_Destructor::
723 * Pragma Linker_Section::
724 * Pragma Long_Float::
725 * Pragma Machine_Attribute::
726 * Pragma Main_Storage::
729 * Pragma No_Strict_Aliasing::
730 * Pragma Normalize_Scalars::
731 * Pragma Obsolescent::
733 * Pragma Persistent_BSS::
735 * Pragma Profile (Ravenscar)::
736 * Pragma Profile (Restricted)::
737 * Pragma Psect_Object::
738 * Pragma Pure_Function::
739 * Pragma Restriction_Warnings::
740 * Pragma Source_File_Name::
741 * Pragma Source_File_Name_Project::
742 * Pragma Source_Reference::
743 * Pragma Stream_Convert::
744 * Pragma Style_Checks::
747 * Pragma Suppress_All::
748 * Pragma Suppress_Exception_Locations::
749 * Pragma Suppress_Initialization::
752 * Pragma Task_Storage::
753 * Pragma Time_Slice::
755 * Pragma Unchecked_Union::
756 * Pragma Unimplemented_Unit::
757 * Pragma Universal_Aliasing ::
758 * Pragma Universal_Data::
759 * Pragma Unreferenced::
760 * Pragma Unreferenced_Objects::
761 * Pragma Unreserve_All_Interrupts::
762 * Pragma Unsuppress::
763 * Pragma Use_VADS_Size::
764 * Pragma Validity_Checks::
767 * Pragma Weak_External::
768 * Pragma Wide_Character_Encoding::
771 @node Pragma Abort_Defer
772 @unnumberedsec Pragma Abort_Defer
774 @cindex Deferring aborts
782 This pragma must appear at the start of the statement sequence of a
783 handled sequence of statements (right after the @code{begin}). It has
784 the effect of deferring aborts for the sequence of statements (but not
785 for the declarations or handlers, if any, associated with this statement
789 @unnumberedsec Pragma Ada_83
798 A configuration pragma that establishes Ada 83 mode for the unit to
799 which it applies, regardless of the mode set by the command line
800 switches. In Ada 83 mode, GNAT attempts to be as compatible with
801 the syntax and semantics of Ada 83, as defined in the original Ada
802 83 Reference Manual as possible. In particular, the keywords added by Ada 95
803 (and Ada 2005) are not recognized, optional package bodies are allowed,
804 and generics may name types with unknown discriminants without using
805 the @code{(<>)} notation. In addition, some but not all of the additional
806 restrictions of Ada 83 are enforced.
808 Ada 83 mode is intended for two purposes. Firstly, it allows existing
809 Ada 83 code to be compiled and adapted to GNAT with less effort.
810 Secondly, it aids in keeping code backwards compatible with Ada 83.
811 However, there is no guarantee that code that is processed correctly
812 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
813 83 compiler, since GNAT does not enforce all the additional checks
817 @unnumberedsec Pragma Ada_95
826 A configuration pragma that establishes Ada 95 mode for the unit to which
827 it applies, regardless of the mode set by the command line switches.
828 This mode is set automatically for the @code{Ada} and @code{System}
829 packages and their children, so you need not specify it in these
830 contexts. This pragma is useful when writing a reusable component that
831 itself uses Ada 95 features, but which is intended to be usable from
832 either Ada 83 or Ada 95 programs.
835 @unnumberedsec Pragma Ada_05
844 A configuration pragma that establishes Ada 2005 mode for the unit to which
845 it applies, regardless of the mode set by the command line switches.
846 This mode is set automatically for the @code{Ada} and @code{System}
847 packages and their children, so you need not specify it in these
848 contexts. This pragma is useful when writing a reusable component that
849 itself uses Ada 2005 features, but which is intended to be usable from
850 either Ada 83 or Ada 95 programs.
852 @node Pragma Ada_2005
853 @unnumberedsec Pragma Ada_2005
862 This configuration pragma is a synonym for pragma Ada_05 and has the
863 same syntax and effect.
865 @node Pragma Annotate
866 @unnumberedsec Pragma Annotate
871 pragma Annotate (IDENTIFIER @{, ARG@});
873 ARG ::= NAME | EXPRESSION
877 This pragma is used to annotate programs. @var{identifier} identifies
878 the type of annotation. GNAT verifies this is an identifier, but does
879 not otherwise analyze it. The @var{arg} argument
880 can be either a string literal or an
881 expression. String literals are assumed to be of type
882 @code{Standard.String}. Names of entities are simply analyzed as entity
883 names. All other expressions are analyzed as expressions, and must be
886 The analyzed pragma is retained in the tree, but not otherwise processed
887 by any part of the GNAT compiler. This pragma is intended for use by
888 external tools, including ASIS@.
891 @unnumberedsec Pragma Assert
898 [, static_string_EXPRESSION]);
902 The effect of this pragma depends on whether the corresponding command
903 line switch is set to activate assertions. The pragma expands into code
904 equivalent to the following:
907 if assertions-enabled then
908 if not boolean_EXPRESSION then
909 System.Assertions.Raise_Assert_Failure
916 The string argument, if given, is the message that will be associated
917 with the exception occurrence if the exception is raised. If no second
918 argument is given, the default message is @samp{@var{file}:@var{nnn}},
919 where @var{file} is the name of the source file containing the assert,
920 and @var{nnn} is the line number of the assert. A pragma is not a
921 statement, so if a statement sequence contains nothing but a pragma
922 assert, then a null statement is required in addition, as in:
927 pragma Assert (K > 3, "Bad value for K");
933 Note that, as with the @code{if} statement to which it is equivalent, the
934 type of the expression is either @code{Standard.Boolean}, or any type derived
935 from this standard type.
937 If assertions are disabled (switch @code{-gnata} not used), then there
938 is no effect (and in particular, any side effects from the expression
939 are suppressed). More precisely it is not quite true that the pragma
940 has no effect, since the expression is analyzed, and may cause types
941 to be frozen if they are mentioned here for the first time.
943 If assertions are enabled, then the given expression is tested, and if
944 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
945 which results in the raising of @code{Assert_Failure} with the given message.
947 If the boolean expression has side effects, these side effects will turn
948 on and off with the setting of the assertions mode, resulting in
949 assertions that have an effect on the program. You should generally
950 avoid side effects in the expression arguments of this pragma. However,
951 the expressions are analyzed for semantic correctness whether or not
952 assertions are enabled, so turning assertions on and off cannot affect
953 the legality of a program.
955 @node Pragma Ast_Entry
956 @unnumberedsec Pragma Ast_Entry
962 pragma AST_Entry (entry_IDENTIFIER);
966 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
967 argument is the simple name of a single entry; at most one @code{AST_Entry}
968 pragma is allowed for any given entry. This pragma must be used in
969 conjunction with the @code{AST_Entry} attribute, and is only allowed after
970 the entry declaration and in the same task type specification or single task
971 as the entry to which it applies. This pragma specifies that the given entry
972 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
973 resulting from an OpenVMS system service call. The pragma does not affect
974 normal use of the entry. For further details on this pragma, see the
975 DEC Ada Language Reference Manual, section 9.12a.
977 @node Pragma C_Pass_By_Copy
978 @unnumberedsec Pragma C_Pass_By_Copy
979 @cindex Passing by copy
980 @findex C_Pass_By_Copy
984 pragma C_Pass_By_Copy
985 ([Max_Size =>] static_integer_EXPRESSION);
989 Normally the default mechanism for passing C convention records to C
990 convention subprograms is to pass them by reference, as suggested by RM
991 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
992 this default, by requiring that record formal parameters be passed by
993 copy if all of the following conditions are met:
997 The size of the record type does not exceed@*@var{static_integer_expression}.
999 The record type has @code{Convention C}.
1001 The formal parameter has this record type, and the subprogram has a
1002 foreign (non-Ada) convention.
1006 If these conditions are met the argument is passed by copy, i.e.@: in a
1007 manner consistent with what C expects if the corresponding formal in the
1008 C prototype is a struct (rather than a pointer to a struct).
1010 You can also pass records by copy by specifying the convention
1011 @code{C_Pass_By_Copy} for the record type, or by using the extended
1012 @code{Import} and @code{Export} pragmas, which allow specification of
1013 passing mechanisms on a parameter by parameter basis.
1015 @node Pragma Comment
1016 @unnumberedsec Pragma Comment
1021 @smallexample @c ada
1022 pragma Comment (static_string_EXPRESSION);
1026 This is almost identical in effect to pragma @code{Ident}. It allows the
1027 placement of a comment into the object file and hence into the
1028 executable file if the operating system permits such usage. The
1029 difference is that @code{Comment}, unlike @code{Ident}, has
1030 no limitations on placement of the pragma (it can be placed
1031 anywhere in the main source unit), and if more than one pragma
1032 is used, all comments are retained.
1034 @node Pragma Common_Object
1035 @unnumberedsec Pragma Common_Object
1036 @findex Common_Object
1040 @smallexample @c ada
1041 pragma Common_Object (
1042 [Internal =>] local_NAME,
1043 [, [External =>] EXTERNAL_SYMBOL]
1044 [, [Size =>] EXTERNAL_SYMBOL] );
1048 | static_string_EXPRESSION
1052 This pragma enables the shared use of variables stored in overlaid
1053 linker areas corresponding to the use of @code{COMMON}
1054 in Fortran. The single
1055 object @var{local_NAME} is assigned to the area designated by
1056 the @var{External} argument.
1057 You may define a record to correspond to a series
1058 of fields. The @var{size} argument
1059 is syntax checked in GNAT, but otherwise ignored.
1061 @code{Common_Object} is not supported on all platforms. If no
1062 support is available, then the code generator will issue a message
1063 indicating that the necessary attribute for implementation of this
1064 pragma is not available.
1066 @node Pragma Compile_Time_Error
1067 @unnumberedsec Pragma Compile_Time_Error
1068 @findex Compile_Time_Error
1072 @smallexample @c ada
1073 pragma Compile_Time_Error
1074 (boolean_EXPRESSION, static_string_EXPRESSION);
1078 This pragma can be used to generate additional compile time
1080 is particularly useful in generics, where errors can be issued for
1081 specific problematic instantiations. The first parameter is a boolean
1082 expression. The pragma is effective only if the value of this expression
1083 is known at compile time, and has the value True. The set of expressions
1084 whose values are known at compile time includes all static boolean
1085 expressions, and also other values which the compiler can determine
1086 at compile time (e.g. the size of a record type set by an explicit
1087 size representation clause, or the value of a variable which was
1088 initialized to a constant and is known not to have been modified).
1089 If these conditions are met, an error message is generated using
1090 the value given as the second argument. This string value may contain
1091 embedded ASCII.LF characters to break the message into multiple lines.
1093 @node Pragma Compile_Time_Warning
1094 @unnumberedsec Pragma Compile_Time_Warning
1095 @findex Compile_Time_Warning
1099 @smallexample @c ada
1100 pragma Compile_Time_Warning
1101 (boolean_EXPRESSION, static_string_EXPRESSION);
1105 This pragma can be used to generate additional compile time warnings. It
1106 is particularly useful in generics, where warnings can be issued for
1107 specific problematic instantiations. The first parameter is a boolean
1108 expression. The pragma is effective only if the value of this expression
1109 is known at compile time, and has the value True. The set of expressions
1110 whose values are known at compile time includes all static boolean
1111 expressions, and also other values which the compiler can determine
1112 at compile time (e.g. the size of a record type set by an explicit
1113 size representation clause, or the value of a variable which was
1114 initialized to a constant and is known not to have been modified).
1115 If these conditions are met, a warning message is generated using
1116 the value given as the second argument. This string value may contain
1117 embedded ASCII.LF characters to break the message into multiple lines.
1119 @node Pragma Complete_Representation
1120 @unnumberedsec Pragma Complete_Representation
1121 @findex Complete_Representation
1125 @smallexample @c ada
1126 pragma Complete_Representation;
1130 This pragma must appear immediately within a record representation
1131 clause. Typical placements are before the first component clause
1132 or after the last component clause. The effect is to give an error
1133 message if any component is missing a component clause. This pragma
1134 may be used to ensure that a record representation clause is
1135 complete, and that this invariant is maintained if fields are
1136 added to the record in the future.
1138 @node Pragma Complex_Representation
1139 @unnumberedsec Pragma Complex_Representation
1140 @findex Complex_Representation
1144 @smallexample @c ada
1145 pragma Complex_Representation
1146 ([Entity =>] local_NAME);
1150 The @var{Entity} argument must be the name of a record type which has
1151 two fields of the same floating-point type. The effect of this pragma is
1152 to force gcc to use the special internal complex representation form for
1153 this record, which may be more efficient. Note that this may result in
1154 the code for this type not conforming to standard ABI (application
1155 binary interface) requirements for the handling of record types. For
1156 example, in some environments, there is a requirement for passing
1157 records by pointer, and the use of this pragma may result in passing
1158 this type in floating-point registers.
1160 @node Pragma Component_Alignment
1161 @unnumberedsec Pragma Component_Alignment
1162 @cindex Alignments of components
1163 @findex Component_Alignment
1167 @smallexample @c ada
1168 pragma Component_Alignment (
1169 [Form =>] ALIGNMENT_CHOICE
1170 [, [Name =>] type_local_NAME]);
1172 ALIGNMENT_CHOICE ::=
1180 Specifies the alignment of components in array or record types.
1181 The meaning of the @var{Form} argument is as follows:
1184 @findex Component_Size
1185 @item Component_Size
1186 Aligns scalar components and subcomponents of the array or record type
1187 on boundaries appropriate to their inherent size (naturally
1188 aligned). For example, 1-byte components are aligned on byte boundaries,
1189 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1190 integer components are aligned on 4-byte boundaries and so on. These
1191 alignment rules correspond to the normal rules for C compilers on all
1192 machines except the VAX@.
1194 @findex Component_Size_4
1195 @item Component_Size_4
1196 Naturally aligns components with a size of four or fewer
1197 bytes. Components that are larger than 4 bytes are placed on the next
1200 @findex Storage_Unit
1202 Specifies that array or record components are byte aligned, i.e.@:
1203 aligned on boundaries determined by the value of the constant
1204 @code{System.Storage_Unit}.
1208 Specifies that array or record components are aligned on default
1209 boundaries, appropriate to the underlying hardware or operating system or
1210 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1211 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1212 the @code{Default} choice is the same as @code{Component_Size} (natural
1217 If the @code{Name} parameter is present, @var{type_local_NAME} must
1218 refer to a local record or array type, and the specified alignment
1219 choice applies to the specified type. The use of
1220 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1221 @code{Component_Alignment} pragma to be ignored. The use of
1222 @code{Component_Alignment} together with a record representation clause
1223 is only effective for fields not specified by the representation clause.
1225 If the @code{Name} parameter is absent, the pragma can be used as either
1226 a configuration pragma, in which case it applies to one or more units in
1227 accordance with the normal rules for configuration pragmas, or it can be
1228 used within a declarative part, in which case it applies to types that
1229 are declared within this declarative part, or within any nested scope
1230 within this declarative part. In either case it specifies the alignment
1231 to be applied to any record or array type which has otherwise standard
1234 If the alignment for a record or array type is not specified (using
1235 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1236 clause), the GNAT uses the default alignment as described previously.
1238 @node Pragma Convention_Identifier
1239 @unnumberedsec Pragma Convention_Identifier
1240 @findex Convention_Identifier
1241 @cindex Conventions, synonyms
1245 @smallexample @c ada
1246 pragma Convention_Identifier (
1247 [Name =>] IDENTIFIER,
1248 [Convention =>] convention_IDENTIFIER);
1252 This pragma provides a mechanism for supplying synonyms for existing
1253 convention identifiers. The @code{Name} identifier can subsequently
1254 be used as a synonym for the given convention in other pragmas (including
1255 for example pragma @code{Import} or another @code{Convention_Identifier}
1256 pragma). As an example of the use of this, suppose you had legacy code
1257 which used Fortran77 as the identifier for Fortran. Then the pragma:
1259 @smallexample @c ada
1260 pragma Convention_Identifier (Fortran77, Fortran);
1264 would allow the use of the convention identifier @code{Fortran77} in
1265 subsequent code, avoiding the need to modify the sources. As another
1266 example, you could use this to parametrize convention requirements
1267 according to systems. Suppose you needed to use @code{Stdcall} on
1268 windows systems, and @code{C} on some other system, then you could
1269 define a convention identifier @code{Library} and use a single
1270 @code{Convention_Identifier} pragma to specify which convention
1271 would be used system-wide.
1273 @node Pragma CPP_Class
1274 @unnumberedsec Pragma CPP_Class
1276 @cindex Interfacing with C++
1280 @smallexample @c ada
1281 pragma CPP_Class ([Entity =>] local_NAME);
1285 The argument denotes an entity in the current declarative region that is
1286 declared as a tagged record type. It indicates that the type corresponds
1287 to an externally declared C++ class type, and is to be laid out the same
1288 way that C++ would lay out the type.
1290 Types for which @code{CPP_Class} is specified do not have assignment or
1291 equality operators defined (such operations can be imported or declared
1292 as subprograms as required). Initialization is allowed only by constructor
1293 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1294 limited if not explicitly declared as limited or derived from a limited
1295 type, and a warning is issued in that case.
1297 Pragma @code{CPP_Class} is intended primarily for automatic generation
1298 using an automatic binding generator tool.
1299 See @ref{Interfacing to C++} for related information.
1301 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1302 for backward compatibility but its functionality is available
1303 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1305 @node Pragma CPP_Constructor
1306 @unnumberedsec Pragma CPP_Constructor
1307 @cindex Interfacing with C++
1308 @findex CPP_Constructor
1312 @smallexample @c ada
1313 pragma CPP_Constructor ([Entity =>] local_NAME
1314 [, [External_Name =>] static_string_EXPRESSION ]
1315 [, [Link_Name =>] static_string_EXPRESSION ]);
1319 This pragma identifies an imported function (imported in the usual way
1320 with pragma @code{Import}) as corresponding to a C++ constructor. If
1321 @code{External_Name} and @code{Link_Name} are not specified then the
1322 @code{Entity} argument is a name that must have been previously mentioned
1323 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1324 must be of one of the following forms:
1328 @code{function @var{Fname} return @var{T}'Class}
1331 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1335 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1337 The first form is the default constructor, used when an object of type
1338 @var{T} is created on the Ada side with no explicit constructor. Other
1339 constructors (including the copy constructor, which is simply a special
1340 case of the second form in which the one and only argument is of type
1341 @var{T}), can only appear in two contexts:
1345 On the right side of an initialization of an object of type @var{T}.
1347 In an extension aggregate for an object of a type derived from @var{T}.
1351 Although the constructor is described as a function that returns a value
1352 on the Ada side, it is typically a procedure with an extra implicit
1353 argument (the object being initialized) at the implementation
1354 level. GNAT issues the appropriate call, whatever it is, to get the
1355 object properly initialized.
1357 In the case of derived objects, you may use one of two possible forms
1358 for declaring and creating an object:
1361 @item @code{New_Object : Derived_T}
1362 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1366 In the first case the default constructor is called and extension fields
1367 if any are initialized according to the default initialization
1368 expressions in the Ada declaration. In the second case, the given
1369 constructor is called and the extension aggregate indicates the explicit
1370 values of the extension fields.
1372 If no constructors are imported, it is impossible to create any objects
1373 on the Ada side. If no default constructor is imported, only the
1374 initialization forms using an explicit call to a constructor are
1377 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1378 using an automatic binding generator tool.
1379 See @ref{Interfacing to C++} for more related information.
1381 @node Pragma CPP_Virtual
1382 @unnumberedsec Pragma CPP_Virtual
1383 @cindex Interfacing to C++
1386 This pragma is now obsolete has has no effect because GNAT generates
1387 the same object layout than the G++ compiler.
1389 See @ref{Interfacing to C++} for related information.
1391 @node Pragma CPP_Vtable
1392 @unnumberedsec Pragma CPP_Vtable
1393 @cindex Interfacing with C++
1396 This pragma is now obsolete has has no effect because GNAT generates
1397 the same object layout than the G++ compiler.
1399 See @ref{Interfacing to C++} for related information.
1402 @unnumberedsec Pragma Debug
1407 @smallexample @c ada
1408 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1410 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1412 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1416 The procedure call argument has the syntactic form of an expression, meeting
1417 the syntactic requirements for pragmas.
1419 If debug pragmas are not enabled or if the condition is present and evaluates
1420 to False, this pragma has no effect. If debug pragmas are enabled, the
1421 semantics of the pragma is exactly equivalent to the procedure call statement
1422 corresponding to the argument with a terminating semicolon. Pragmas are
1423 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1424 intersperse calls to debug procedures in the middle of declarations. Debug
1425 pragmas can be enabled either by use of the command line switch @code{-gnata}
1426 or by use of the configuration pragma @code{Debug_Policy}.
1428 @node Pragma Debug_Policy
1429 @unnumberedsec Pragma Debug_Policy
1430 @findex Debug_Policy
1434 @smallexample @c ada
1435 pragma Debug_Policy (CHECK | IGNORE);
1439 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1440 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1441 This pragma overrides the effect of the @code{-gnata} switch on the
1444 @node Pragma Detect_Blocking
1445 @unnumberedsec Pragma Detect_Blocking
1446 @findex Detect_Blocking
1450 @smallexample @c ada
1451 pragma Detect_Blocking;
1455 This is a configuration pragma that forces the detection of potentially
1456 blocking operations within a protected operation, and to raise Program_Error
1459 @node Pragma Elaboration_Checks
1460 @unnumberedsec Pragma Elaboration_Checks
1461 @cindex Elaboration control
1462 @findex Elaboration_Checks
1466 @smallexample @c ada
1467 pragma Elaboration_Checks (Dynamic | Static);
1471 This is a configuration pragma that provides control over the
1472 elaboration model used by the compilation affected by the
1473 pragma. If the parameter is @code{Dynamic},
1474 then the dynamic elaboration
1475 model described in the Ada Reference Manual is used, as though
1476 the @code{-gnatE} switch had been specified on the command
1477 line. If the parameter is @code{Static}, then the default GNAT static
1478 model is used. This configuration pragma overrides the setting
1479 of the command line. For full details on the elaboration models
1480 used by the GNAT compiler, see section ``Elaboration Order
1481 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1483 @node Pragma Eliminate
1484 @unnumberedsec Pragma Eliminate
1485 @cindex Elimination of unused subprograms
1490 @smallexample @c ada
1492 [Unit_Name =>] IDENTIFIER |
1493 SELECTED_COMPONENT);
1496 [Unit_Name =>] IDENTIFIER |
1498 [Entity =>] IDENTIFIER |
1499 SELECTED_COMPONENT |
1501 [,OVERLOADING_RESOLUTION]);
1503 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1506 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1509 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1511 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1512 Result_Type => result_SUBTYPE_NAME]
1514 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1515 SUBTYPE_NAME ::= STRING_VALUE
1517 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1518 SOURCE_TRACE ::= STRING_VALUE
1520 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1524 This pragma indicates that the given entity is not used outside the
1525 compilation unit it is defined in. The entity must be an explicitly declared
1526 subprogram; this includes generic subprogram instances and
1527 subprograms declared in generic package instances.
1529 If the entity to be eliminated is a library level subprogram, then
1530 the first form of pragma @code{Eliminate} is used with only a single argument.
1531 In this form, the @code{Unit_Name} argument specifies the name of the
1532 library level unit to be eliminated.
1534 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1535 are required. If item is an entity of a library package, then the first
1536 argument specifies the unit name, and the second argument specifies
1537 the particular entity. If the second argument is in string form, it must
1538 correspond to the internal manner in which GNAT stores entity names (see
1539 compilation unit Namet in the compiler sources for details).
1541 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1542 to distinguish between overloaded subprograms. If a pragma does not contain
1543 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1544 subprograms denoted by the first two parameters.
1546 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1547 to be eliminated in a manner similar to that used for the extended
1548 @code{Import} and @code{Export} pragmas, except that the subtype names are
1549 always given as strings. At the moment, this form of distinguishing
1550 overloaded subprograms is implemented only partially, so we do not recommend
1551 using it for practical subprogram elimination.
1553 Note, that in case of a parameterless procedure its profile is represented
1554 as @code{Parameter_Types => ("")}
1556 Alternatively, the @code{Source_Location} parameter is used to specify
1557 which overloaded alternative is to be eliminated by pointing to the
1558 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1559 source text. The string literal (or concatenation of string literals)
1560 given as SOURCE_TRACE must have the following format:
1562 @smallexample @c ada
1563 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1568 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1569 FILE_NAME ::= STRING_LITERAL
1570 LINE_NUMBER ::= DIGIT @{DIGIT@}
1573 SOURCE_TRACE should be the short name of the source file (with no directory
1574 information), and LINE_NUMBER is supposed to point to the line where the
1575 defining name of the subprogram is located.
1577 For the subprograms that are not a part of generic instantiations, only one
1578 SOURCE_LOCATION is used. If a subprogram is declared in a package
1579 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1580 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1581 second one denotes the declaration of the corresponding subprogram in the
1582 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1583 in case of nested instantiations.
1585 The effect of the pragma is to allow the compiler to eliminate
1586 the code or data associated with the named entity. Any reference to
1587 an eliminated entity outside the compilation unit it is defined in,
1588 causes a compile time or link time error.
1590 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1591 in a system independent manner, with unused entities eliminated, without
1592 the requirement of modifying the source text. Normally the required set
1593 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1594 tool. Elimination of unused entities local to a compilation unit is
1595 automatic, without requiring the use of pragma @code{Eliminate}.
1597 Note that the reason this pragma takes string literals where names might
1598 be expected is that a pragma @code{Eliminate} can appear in a context where the
1599 relevant names are not visible.
1601 Note that any change in the source files that includes removing, splitting of
1602 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1605 @node Pragma Export_Exception
1606 @unnumberedsec Pragma Export_Exception
1608 @findex Export_Exception
1612 @smallexample @c ada
1613 pragma Export_Exception (
1614 [Internal =>] local_NAME,
1615 [, [External =>] EXTERNAL_SYMBOL,]
1616 [, [Form =>] Ada | VMS]
1617 [, [Code =>] static_integer_EXPRESSION]);
1621 | static_string_EXPRESSION
1625 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1626 causes the specified exception to be propagated outside of the Ada program,
1627 so that it can be handled by programs written in other OpenVMS languages.
1628 This pragma establishes an external name for an Ada exception and makes the
1629 name available to the OpenVMS Linker as a global symbol. For further details
1630 on this pragma, see the
1631 DEC Ada Language Reference Manual, section 13.9a3.2.
1633 @node Pragma Export_Function
1634 @unnumberedsec Pragma Export_Function
1635 @cindex Argument passing mechanisms
1636 @findex Export_Function
1641 @smallexample @c ada
1642 pragma Export_Function (
1643 [Internal =>] local_NAME,
1644 [, [External =>] EXTERNAL_SYMBOL]
1645 [, [Parameter_Types =>] PARAMETER_TYPES]
1646 [, [Result_Type =>] result_SUBTYPE_MARK]
1647 [, [Mechanism =>] MECHANISM]
1648 [, [Result_Mechanism =>] MECHANISM_NAME]);
1652 | static_string_EXPRESSION
1657 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1661 | subtype_Name ' Access
1665 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1667 MECHANISM_ASSOCIATION ::=
1668 [formal_parameter_NAME =>] MECHANISM_NAME
1673 | Descriptor [([Class =>] CLASS_NAME)]
1675 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1679 Use this pragma to make a function externally callable and optionally
1680 provide information on mechanisms to be used for passing parameter and
1681 result values. We recommend, for the purposes of improving portability,
1682 this pragma always be used in conjunction with a separate pragma
1683 @code{Export}, which must precede the pragma @code{Export_Function}.
1684 GNAT does not require a separate pragma @code{Export}, but if none is
1685 present, @code{Convention Ada} is assumed, which is usually
1686 not what is wanted, so it is usually appropriate to use this
1687 pragma in conjunction with a @code{Export} or @code{Convention}
1688 pragma that specifies the desired foreign convention.
1689 Pragma @code{Export_Function}
1690 (and @code{Export}, if present) must appear in the same declarative
1691 region as the function to which they apply.
1693 @var{internal_name} must uniquely designate the function to which the
1694 pragma applies. If more than one function name exists of this name in
1695 the declarative part you must use the @code{Parameter_Types} and
1696 @code{Result_Type} parameters is mandatory to achieve the required
1697 unique designation. @var{subtype_ mark}s in these parameters must
1698 exactly match the subtypes in the corresponding function specification,
1699 using positional notation to match parameters with subtype marks.
1700 The form with an @code{'Access} attribute can be used to match an
1701 anonymous access parameter.
1704 @cindex Passing by descriptor
1705 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1707 @cindex Suppressing external name
1708 Special treatment is given if the EXTERNAL is an explicit null
1709 string or a static string expressions that evaluates to the null
1710 string. In this case, no external name is generated. This form
1711 still allows the specification of parameter mechanisms.
1713 @node Pragma Export_Object
1714 @unnumberedsec Pragma Export_Object
1715 @findex Export_Object
1719 @smallexample @c ada
1720 pragma Export_Object
1721 [Internal =>] local_NAME,
1722 [, [External =>] EXTERNAL_SYMBOL]
1723 [, [Size =>] EXTERNAL_SYMBOL]
1727 | static_string_EXPRESSION
1731 This pragma designates an object as exported, and apart from the
1732 extended rules for external symbols, is identical in effect to the use of
1733 the normal @code{Export} pragma applied to an object. You may use a
1734 separate Export pragma (and you probably should from the point of view
1735 of portability), but it is not required. @var{Size} is syntax checked,
1736 but otherwise ignored by GNAT@.
1738 @node Pragma Export_Procedure
1739 @unnumberedsec Pragma Export_Procedure
1740 @findex Export_Procedure
1744 @smallexample @c ada
1745 pragma Export_Procedure (
1746 [Internal =>] local_NAME
1747 [, [External =>] EXTERNAL_SYMBOL]
1748 [, [Parameter_Types =>] PARAMETER_TYPES]
1749 [, [Mechanism =>] MECHANISM]);
1753 | static_string_EXPRESSION
1758 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1762 | subtype_Name ' Access
1766 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1768 MECHANISM_ASSOCIATION ::=
1769 [formal_parameter_NAME =>] MECHANISM_NAME
1774 | Descriptor [([Class =>] CLASS_NAME)]
1776 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1780 This pragma is identical to @code{Export_Function} except that it
1781 applies to a procedure rather than a function and the parameters
1782 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1783 GNAT does not require a separate pragma @code{Export}, but if none is
1784 present, @code{Convention Ada} is assumed, which is usually
1785 not what is wanted, so it is usually appropriate to use this
1786 pragma in conjunction with a @code{Export} or @code{Convention}
1787 pragma that specifies the desired foreign convention.
1790 @cindex Passing by descriptor
1791 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1793 @cindex Suppressing external name
1794 Special treatment is given if the EXTERNAL is an explicit null
1795 string or a static string expressions that evaluates to the null
1796 string. In this case, no external name is generated. This form
1797 still allows the specification of parameter mechanisms.
1799 @node Pragma Export_Value
1800 @unnumberedsec Pragma Export_Value
1801 @findex Export_Value
1805 @smallexample @c ada
1806 pragma Export_Value (
1807 [Value =>] static_integer_EXPRESSION,
1808 [Link_Name =>] static_string_EXPRESSION);
1812 This pragma serves to export a static integer value for external use.
1813 The first argument specifies the value to be exported. The Link_Name
1814 argument specifies the symbolic name to be associated with the integer
1815 value. This pragma is useful for defining a named static value in Ada
1816 that can be referenced in assembly language units to be linked with
1817 the application. This pragma is currently supported only for the
1818 AAMP target and is ignored for other targets.
1820 @node Pragma Export_Valued_Procedure
1821 @unnumberedsec Pragma Export_Valued_Procedure
1822 @findex Export_Valued_Procedure
1826 @smallexample @c ada
1827 pragma Export_Valued_Procedure (
1828 [Internal =>] local_NAME
1829 [, [External =>] EXTERNAL_SYMBOL]
1830 [, [Parameter_Types =>] PARAMETER_TYPES]
1831 [, [Mechanism =>] MECHANISM]);
1835 | static_string_EXPRESSION
1840 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1844 | subtype_Name ' Access
1848 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1850 MECHANISM_ASSOCIATION ::=
1851 [formal_parameter_NAME =>] MECHANISM_NAME
1856 | Descriptor [([Class =>] CLASS_NAME)]
1858 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1862 This pragma is identical to @code{Export_Procedure} except that the
1863 first parameter of @var{local_NAME}, which must be present, must be of
1864 mode @code{OUT}, and externally the subprogram is treated as a function
1865 with this parameter as the result of the function. GNAT provides for
1866 this capability to allow the use of @code{OUT} and @code{IN OUT}
1867 parameters in interfacing to external functions (which are not permitted
1869 GNAT does not require a separate pragma @code{Export}, but if none is
1870 present, @code{Convention Ada} is assumed, which is almost certainly
1871 not what is wanted since the whole point of this pragma is to interface
1872 with foreign language functions, so it is usually appropriate to use this
1873 pragma in conjunction with a @code{Export} or @code{Convention}
1874 pragma that specifies the desired foreign convention.
1877 @cindex Passing by descriptor
1878 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1880 @cindex Suppressing external name
1881 Special treatment is given if the EXTERNAL is an explicit null
1882 string or a static string expressions that evaluates to the null
1883 string. In this case, no external name is generated. This form
1884 still allows the specification of parameter mechanisms.
1886 @node Pragma Extend_System
1887 @unnumberedsec Pragma Extend_System
1888 @cindex @code{system}, extending
1890 @findex Extend_System
1894 @smallexample @c ada
1895 pragma Extend_System ([Name =>] IDENTIFIER);
1899 This pragma is used to provide backwards compatibility with other
1900 implementations that extend the facilities of package @code{System}. In
1901 GNAT, @code{System} contains only the definitions that are present in
1902 the Ada RM@. However, other implementations, notably the DEC Ada 83
1903 implementation, provide many extensions to package @code{System}.
1905 For each such implementation accommodated by this pragma, GNAT provides a
1906 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1907 implementation, which provides the required additional definitions. You
1908 can use this package in two ways. You can @code{with} it in the normal
1909 way and access entities either by selection or using a @code{use}
1910 clause. In this case no special processing is required.
1912 However, if existing code contains references such as
1913 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1914 definitions provided in package @code{System}, you may use this pragma
1915 to extend visibility in @code{System} in a non-standard way that
1916 provides greater compatibility with the existing code. Pragma
1917 @code{Extend_System} is a configuration pragma whose single argument is
1918 the name of the package containing the extended definition
1919 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
1920 control of this pragma will be processed using special visibility
1921 processing that looks in package @code{System.Aux_@var{xxx}} where
1922 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1923 package @code{System}, but not found in package @code{System}.
1925 You can use this pragma either to access a predefined @code{System}
1926 extension supplied with the compiler, for example @code{Aux_DEC} or
1927 you can construct your own extension unit following the above
1928 definition. Note that such a package is a child of @code{System}
1929 and thus is considered part of the implementation. To compile
1930 it you will have to use the appropriate switch for compiling
1931 system units. See the GNAT User's Guide for details.
1933 @node Pragma External
1934 @unnumberedsec Pragma External
1939 @smallexample @c ada
1941 [ Convention =>] convention_IDENTIFIER,
1942 [ Entity =>] local_NAME
1943 [, [External_Name =>] static_string_EXPRESSION ]
1944 [, [Link_Name =>] static_string_EXPRESSION ]);
1948 This pragma is identical in syntax and semantics to pragma
1949 @code{Export} as defined in the Ada Reference Manual. It is
1950 provided for compatibility with some Ada 83 compilers that
1951 used this pragma for exactly the same purposes as pragma
1952 @code{Export} before the latter was standardized.
1954 @node Pragma External_Name_Casing
1955 @unnumberedsec Pragma External_Name_Casing
1956 @cindex Dec Ada 83 casing compatibility
1957 @cindex External Names, casing
1958 @cindex Casing of External names
1959 @findex External_Name_Casing
1963 @smallexample @c ada
1964 pragma External_Name_Casing (
1965 Uppercase | Lowercase
1966 [, Uppercase | Lowercase | As_Is]);
1970 This pragma provides control over the casing of external names associated
1971 with Import and Export pragmas. There are two cases to consider:
1974 @item Implicit external names
1975 Implicit external names are derived from identifiers. The most common case
1976 arises when a standard Ada Import or Export pragma is used with only two
1979 @smallexample @c ada
1980 pragma Import (C, C_Routine);
1984 Since Ada is a case-insensitive language, the spelling of the identifier in
1985 the Ada source program does not provide any information on the desired
1986 casing of the external name, and so a convention is needed. In GNAT the
1987 default treatment is that such names are converted to all lower case
1988 letters. This corresponds to the normal C style in many environments.
1989 The first argument of pragma @code{External_Name_Casing} can be used to
1990 control this treatment. If @code{Uppercase} is specified, then the name
1991 will be forced to all uppercase letters. If @code{Lowercase} is specified,
1992 then the normal default of all lower case letters will be used.
1994 This same implicit treatment is also used in the case of extended DEC Ada 83
1995 compatible Import and Export pragmas where an external name is explicitly
1996 specified using an identifier rather than a string.
1998 @item Explicit external names
1999 Explicit external names are given as string literals. The most common case
2000 arises when a standard Ada Import or Export pragma is used with three
2003 @smallexample @c ada
2004 pragma Import (C, C_Routine, "C_routine");
2008 In this case, the string literal normally provides the exact casing required
2009 for the external name. The second argument of pragma
2010 @code{External_Name_Casing} may be used to modify this behavior.
2011 If @code{Uppercase} is specified, then the name
2012 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2013 then the name will be forced to all lowercase letters. A specification of
2014 @code{As_Is} provides the normal default behavior in which the casing is
2015 taken from the string provided.
2019 This pragma may appear anywhere that a pragma is valid. In particular, it
2020 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2021 case it applies to all subsequent compilations, or it can be used as a program
2022 unit pragma, in which case it only applies to the current unit, or it can
2023 be used more locally to control individual Import/Export pragmas.
2025 It is primarily intended for use with OpenVMS systems, where many
2026 compilers convert all symbols to upper case by default. For interfacing to
2027 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2030 @smallexample @c ada
2031 pragma External_Name_Casing (Uppercase, Uppercase);
2035 to enforce the upper casing of all external symbols.
2037 @node Pragma Finalize_Storage_Only
2038 @unnumberedsec Pragma Finalize_Storage_Only
2039 @findex Finalize_Storage_Only
2043 @smallexample @c ada
2044 pragma Finalize_Storage_Only (first_subtype_local_NAME);
2048 This pragma allows the compiler not to emit a Finalize call for objects
2049 defined at the library level. This is mostly useful for types where
2050 finalization is only used to deal with storage reclamation since in most
2051 environments it is not necessary to reclaim memory just before terminating
2052 execution, hence the name.
2054 @node Pragma Float_Representation
2055 @unnumberedsec Pragma Float_Representation
2057 @findex Float_Representation
2061 @smallexample @c ada
2062 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2064 FLOAT_REP ::= VAX_Float | IEEE_Float
2068 In the one argument form, this pragma is a configuration pragma which
2069 allows control over the internal representation chosen for the predefined
2070 floating point types declared in the packages @code{Standard} and
2071 @code{System}. On all systems other than OpenVMS, the argument must
2072 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2073 argument may be @code{VAX_Float} to specify the use of the VAX float
2074 format for the floating-point types in Standard. This requires that
2075 the standard runtime libraries be recompiled. See the
2076 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2077 of the GNAT Users Guide for details on the use of this command.
2079 The two argument form specifies the representation to be used for
2080 the specified floating-point type. On all systems other than OpenVMS,
2082 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2083 argument may be @code{VAX_Float} to specify the use of the VAX float
2088 For digits values up to 6, F float format will be used.
2090 For digits values from 7 to 9, G float format will be used.
2092 For digits values from 10 to 15, F float format will be used.
2094 Digits values above 15 are not allowed.
2098 @unnumberedsec Pragma Ident
2103 @smallexample @c ada
2104 pragma Ident (static_string_EXPRESSION);
2108 This pragma provides a string identification in the generated object file,
2109 if the system supports the concept of this kind of identification string.
2110 This pragma is allowed only in the outermost declarative part or
2111 declarative items of a compilation unit. If more than one @code{Ident}
2112 pragma is given, only the last one processed is effective.
2114 On OpenVMS systems, the effect of the pragma is identical to the effect of
2115 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2116 maximum allowed length is 31 characters, so if it is important to
2117 maintain compatibility with this compiler, you should obey this length
2120 @node Pragma Import_Exception
2121 @unnumberedsec Pragma Import_Exception
2123 @findex Import_Exception
2127 @smallexample @c ada
2128 pragma Import_Exception (
2129 [Internal =>] local_NAME,
2130 [, [External =>] EXTERNAL_SYMBOL,]
2131 [, [Form =>] Ada | VMS]
2132 [, [Code =>] static_integer_EXPRESSION]);
2136 | static_string_EXPRESSION
2140 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2141 It allows OpenVMS conditions (for example, from OpenVMS system services or
2142 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2143 The pragma specifies that the exception associated with an exception
2144 declaration in an Ada program be defined externally (in non-Ada code).
2145 For further details on this pragma, see the
2146 DEC Ada Language Reference Manual, section 13.9a.3.1.
2148 @node Pragma Import_Function
2149 @unnumberedsec Pragma Import_Function
2150 @findex Import_Function
2154 @smallexample @c ada
2155 pragma Import_Function (
2156 [Internal =>] local_NAME,
2157 [, [External =>] EXTERNAL_SYMBOL]
2158 [, [Parameter_Types =>] PARAMETER_TYPES]
2159 [, [Result_Type =>] SUBTYPE_MARK]
2160 [, [Mechanism =>] MECHANISM]
2161 [, [Result_Mechanism =>] MECHANISM_NAME]
2162 [, [First_Optional_Parameter =>] IDENTIFIER]);
2166 | static_string_EXPRESSION
2170 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2174 | subtype_Name ' Access
2178 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2180 MECHANISM_ASSOCIATION ::=
2181 [formal_parameter_NAME =>] MECHANISM_NAME
2186 | Descriptor [([Class =>] CLASS_NAME)]
2188 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2192 This pragma is used in conjunction with a pragma @code{Import} to
2193 specify additional information for an imported function. The pragma
2194 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2195 @code{Import_Function} pragma and both must appear in the same
2196 declarative part as the function specification.
2198 The @var{Internal} argument must uniquely designate
2199 the function to which the
2200 pragma applies. If more than one function name exists of this name in
2201 the declarative part you must use the @code{Parameter_Types} and
2202 @var{Result_Type} parameters to achieve the required unique
2203 designation. Subtype marks in these parameters must exactly match the
2204 subtypes in the corresponding function specification, using positional
2205 notation to match parameters with subtype marks.
2206 The form with an @code{'Access} attribute can be used to match an
2207 anonymous access parameter.
2209 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2210 parameters to specify passing mechanisms for the
2211 parameters and result. If you specify a single mechanism name, it
2212 applies to all parameters. Otherwise you may specify a mechanism on a
2213 parameter by parameter basis using either positional or named
2214 notation. If the mechanism is not specified, the default mechanism
2218 @cindex Passing by descriptor
2219 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2221 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2222 It specifies that the designated parameter and all following parameters
2223 are optional, meaning that they are not passed at the generated code
2224 level (this is distinct from the notion of optional parameters in Ada
2225 where the parameters are passed anyway with the designated optional
2226 parameters). All optional parameters must be of mode @code{IN} and have
2227 default parameter values that are either known at compile time
2228 expressions, or uses of the @code{'Null_Parameter} attribute.
2230 @node Pragma Import_Object
2231 @unnumberedsec Pragma Import_Object
2232 @findex Import_Object
2236 @smallexample @c ada
2237 pragma Import_Object
2238 [Internal =>] local_NAME,
2239 [, [External =>] EXTERNAL_SYMBOL],
2240 [, [Size =>] EXTERNAL_SYMBOL]);
2244 | static_string_EXPRESSION
2248 This pragma designates an object as imported, and apart from the
2249 extended rules for external symbols, is identical in effect to the use of
2250 the normal @code{Import} pragma applied to an object. Unlike the
2251 subprogram case, you need not use a separate @code{Import} pragma,
2252 although you may do so (and probably should do so from a portability
2253 point of view). @var{size} is syntax checked, but otherwise ignored by
2256 @node Pragma Import_Procedure
2257 @unnumberedsec Pragma Import_Procedure
2258 @findex Import_Procedure
2262 @smallexample @c ada
2263 pragma Import_Procedure (
2264 [Internal =>] local_NAME,
2265 [, [External =>] EXTERNAL_SYMBOL]
2266 [, [Parameter_Types =>] PARAMETER_TYPES]
2267 [, [Mechanism =>] MECHANISM]
2268 [, [First_Optional_Parameter =>] IDENTIFIER]);
2272 | static_string_EXPRESSION
2276 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2280 | subtype_Name ' Access
2284 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2286 MECHANISM_ASSOCIATION ::=
2287 [formal_parameter_NAME =>] MECHANISM_NAME
2292 | Descriptor [([Class =>] CLASS_NAME)]
2294 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2298 This pragma is identical to @code{Import_Function} except that it
2299 applies to a procedure rather than a function and the parameters
2300 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2302 @node Pragma Import_Valued_Procedure
2303 @unnumberedsec Pragma Import_Valued_Procedure
2304 @findex Import_Valued_Procedure
2308 @smallexample @c ada
2309 pragma Import_Valued_Procedure (
2310 [Internal =>] local_NAME,
2311 [, [External =>] EXTERNAL_SYMBOL]
2312 [, [Parameter_Types =>] PARAMETER_TYPES]
2313 [, [Mechanism =>] MECHANISM]
2314 [, [First_Optional_Parameter =>] IDENTIFIER]);
2318 | static_string_EXPRESSION
2322 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2326 | subtype_Name ' Access
2330 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2332 MECHANISM_ASSOCIATION ::=
2333 [formal_parameter_NAME =>] MECHANISM_NAME
2338 | Descriptor [([Class =>] CLASS_NAME)]
2340 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2344 This pragma is identical to @code{Import_Procedure} except that the
2345 first parameter of @var{local_NAME}, which must be present, must be of
2346 mode @code{OUT}, and externally the subprogram is treated as a function
2347 with this parameter as the result of the function. The purpose of this
2348 capability is to allow the use of @code{OUT} and @code{IN OUT}
2349 parameters in interfacing to external functions (which are not permitted
2350 in Ada functions). You may optionally use the @code{Mechanism}
2351 parameters to specify passing mechanisms for the parameters.
2352 If you specify a single mechanism name, it applies to all parameters.
2353 Otherwise you may specify a mechanism on a parameter by parameter
2354 basis using either positional or named notation. If the mechanism is not
2355 specified, the default mechanism is used.
2357 Note that it is important to use this pragma in conjunction with a separate
2358 pragma Import that specifies the desired convention, since otherwise the
2359 default convention is Ada, which is almost certainly not what is required.
2361 @node Pragma Initialize_Scalars
2362 @unnumberedsec Pragma Initialize_Scalars
2363 @findex Initialize_Scalars
2364 @cindex debugging with Initialize_Scalars
2368 @smallexample @c ada
2369 pragma Initialize_Scalars;
2373 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2374 two important differences. First, there is no requirement for the pragma
2375 to be used uniformly in all units of a partition, in particular, it is fine
2376 to use this just for some or all of the application units of a partition,
2377 without needing to recompile the run-time library.
2379 In the case where some units are compiled with the pragma, and some without,
2380 then a declaration of a variable where the type is defined in package
2381 Standard or is locally declared will always be subject to initialization,
2382 as will any declaration of a scalar variable. For composite variables,
2383 whether the variable is initialized may also depend on whether the package
2384 in which the type of the variable is declared is compiled with the pragma.
2386 The other important difference is that you can control the value used
2387 for initializing scalar objects. At bind time, you can select several
2388 options for initialization. You can
2389 initialize with invalid values (similar to Normalize_Scalars, though for
2390 Initialize_Scalars it is not always possible to determine the invalid
2391 values in complex cases like signed component fields with non-standard
2392 sizes). You can also initialize with high or
2393 low values, or with a specified bit pattern. See the users guide for binder
2394 options for specifying these cases.
2396 This means that you can compile a program, and then without having to
2397 recompile the program, you can run it with different values being used
2398 for initializing otherwise uninitialized values, to test if your program
2399 behavior depends on the choice. Of course the behavior should not change,
2400 and if it does, then most likely you have an erroneous reference to an
2401 uninitialized value.
2403 It is even possible to change the value at execution time eliminating even
2404 the need to rebind with a different switch using an environment variable.
2405 See the GNAT users guide for details.
2407 Note that pragma @code{Initialize_Scalars} is particularly useful in
2408 conjunction with the enhanced validity checking that is now provided
2409 in GNAT, which checks for invalid values under more conditions.
2410 Using this feature (see description of the @code{-gnatV} flag in the
2411 users guide) in conjunction with pragma @code{Initialize_Scalars}
2412 provides a powerful new tool to assist in the detection of problems
2413 caused by uninitialized variables.
2415 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2416 effect on the generated code. This may cause your code to be
2417 substantially larger. It may also cause an increase in the amount
2418 of stack required, so it is probably a good idea to turn on stack
2419 checking (see description of stack checking in the GNAT users guide)
2420 when using this pragma.
2422 @node Pragma Inline_Always
2423 @unnumberedsec Pragma Inline_Always
2424 @findex Inline_Always
2428 @smallexample @c ada
2429 pragma Inline_Always (NAME [, NAME]);
2433 Similar to pragma @code{Inline} except that inlining is not subject to
2434 the use of option @code{-gnatn} and the inlining happens regardless of
2435 whether this option is used.
2437 @node Pragma Inline_Generic
2438 @unnumberedsec Pragma Inline_Generic
2439 @findex Inline_Generic
2443 @smallexample @c ada
2444 pragma Inline_Generic (generic_package_NAME);
2448 This is implemented for compatibility with DEC Ada 83 and is recognized,
2449 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2450 by default when using GNAT@.
2452 @node Pragma Interface
2453 @unnumberedsec Pragma Interface
2458 @smallexample @c ada
2460 [Convention =>] convention_identifier,
2461 [Entity =>] local_NAME
2462 [, [External_Name =>] static_string_expression],
2463 [, [Link_Name =>] static_string_expression]);
2467 This pragma is identical in syntax and semantics to
2468 the standard Ada pragma @code{Import}. It is provided for compatibility
2469 with Ada 83. The definition is upwards compatible both with pragma
2470 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2471 with some extended implementations of this pragma in certain Ada 83
2474 @node Pragma Interface_Name
2475 @unnumberedsec Pragma Interface_Name
2476 @findex Interface_Name
2480 @smallexample @c ada
2481 pragma Interface_Name (
2482 [Entity =>] local_NAME
2483 [, [External_Name =>] static_string_EXPRESSION]
2484 [, [Link_Name =>] static_string_EXPRESSION]);
2488 This pragma provides an alternative way of specifying the interface name
2489 for an interfaced subprogram, and is provided for compatibility with Ada
2490 83 compilers that use the pragma for this purpose. You must provide at
2491 least one of @var{External_Name} or @var{Link_Name}.
2493 @node Pragma Interrupt_Handler
2494 @unnumberedsec Pragma Interrupt_Handler
2495 @findex Interrupt_Handler
2499 @smallexample @c ada
2500 pragma Interrupt_Handler (procedure_local_NAME);
2504 This program unit pragma is supported for parameterless protected procedures
2505 as described in Annex C of the Ada Reference Manual. On the AAMP target
2506 the pragma can also be specified for nonprotected parameterless procedures
2507 that are declared at the library level (which includes procedures
2508 declared at the top level of a library package). In the case of AAMP,
2509 when this pragma is applied to a nonprotected procedure, the instruction
2510 @code{IERET} is generated for returns from the procedure, enabling
2511 maskable interrupts, in place of the normal return instruction.
2513 @node Pragma Interrupt_State
2514 @unnumberedsec Pragma Interrupt_State
2515 @findex Interrupt_State
2519 @smallexample @c ada
2520 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2524 Normally certain interrupts are reserved to the implementation. Any attempt
2525 to attach an interrupt causes Program_Error to be raised, as described in
2526 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2527 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2528 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2529 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2530 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2531 Ada exceptions, or used to implement run-time functions such as the
2532 @code{abort} statement and stack overflow checking.
2534 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2535 such uses of interrupts. It subsumes the functionality of pragma
2536 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2537 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2538 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2539 and may be used to mark interrupts required by the board support package
2542 Interrupts can be in one of three states:
2546 The interrupt is reserved (no Ada handler can be installed), and the
2547 Ada run-time may not install a handler. As a result you are guaranteed
2548 standard system default action if this interrupt is raised.
2552 The interrupt is reserved (no Ada handler can be installed). The run time
2553 is allowed to install a handler for internal control purposes, but is
2554 not required to do so.
2558 The interrupt is unreserved. The user may install a handler to provide
2563 These states are the allowed values of the @code{State} parameter of the
2564 pragma. The @code{Name} parameter is a value of the type
2565 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2566 @code{Ada.Interrupts.Names}.
2568 This is a configuration pragma, and the binder will check that there
2569 are no inconsistencies between different units in a partition in how a
2570 given interrupt is specified. It may appear anywhere a pragma is legal.
2572 The effect is to move the interrupt to the specified state.
2574 By declaring interrupts to be SYSTEM, you guarantee the standard system
2575 action, such as a core dump.
2577 By declaring interrupts to be USER, you guarantee that you can install
2580 Note that certain signals on many operating systems cannot be caught and
2581 handled by applications. In such cases, the pragma is ignored. See the
2582 operating system documentation, or the value of the array @code{Reserved}
2583 declared in the specification of package @code{System.OS_Interface}.
2585 Overriding the default state of signals used by the Ada runtime may interfere
2586 with an application's runtime behavior in the cases of the synchronous signals,
2587 and in the case of the signal used to implement the @code{abort} statement.
2589 @node Pragma Keep_Names
2590 @unnumberedsec Pragma Keep_Names
2595 @smallexample @c ada
2596 pragma Keep_Names ([On =>] enumeration_first_subtype_local_NAME);
2600 The @var{local_NAME} argument
2601 must refer to an enumeration first subtype
2602 in the current declarative part. The effect is to retain the enumeration
2603 literal names for use by @code{Image} and @code{Value} even if a global
2604 @code{Discard_Names} pragma applies. This is useful when you want to
2605 generally suppress enumeration literal names and for example you therefore
2606 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2607 want to retain the names for specific enumeration types.
2609 @node Pragma License
2610 @unnumberedsec Pragma License
2612 @cindex License checking
2616 @smallexample @c ada
2617 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2621 This pragma is provided to allow automated checking for appropriate license
2622 conditions with respect to the standard and modified GPL@. A pragma
2623 @code{License}, which is a configuration pragma that typically appears at
2624 the start of a source file or in a separate @file{gnat.adc} file, specifies
2625 the licensing conditions of a unit as follows:
2629 This is used for a unit that can be freely used with no license restrictions.
2630 Examples of such units are public domain units, and units from the Ada
2634 This is used for a unit that is licensed under the unmodified GPL, and which
2635 therefore cannot be @code{with}'ed by a restricted unit.
2638 This is used for a unit licensed under the GNAT modified GPL that includes
2639 a special exception paragraph that specifically permits the inclusion of
2640 the unit in programs without requiring the entire program to be released
2644 This is used for a unit that is restricted in that it is not permitted to
2645 depend on units that are licensed under the GPL@. Typical examples are
2646 proprietary code that is to be released under more restrictive license
2647 conditions. Note that restricted units are permitted to @code{with} units
2648 which are licensed under the modified GPL (this is the whole point of the
2654 Normally a unit with no @code{License} pragma is considered to have an
2655 unknown license, and no checking is done. However, standard GNAT headers
2656 are recognized, and license information is derived from them as follows.
2660 A GNAT license header starts with a line containing 78 hyphens. The following
2661 comment text is searched for the appearance of any of the following strings.
2663 If the string ``GNU General Public License'' is found, then the unit is assumed
2664 to have GPL license, unless the string ``As a special exception'' follows, in
2665 which case the license is assumed to be modified GPL@.
2667 If one of the strings
2668 ``This specification is adapted from the Ada Semantic Interface'' or
2669 ``This specification is derived from the Ada Reference Manual'' is found
2670 then the unit is assumed to be unrestricted.
2674 These default actions means that a program with a restricted license pragma
2675 will automatically get warnings if a GPL unit is inappropriately
2676 @code{with}'ed. For example, the program:
2678 @smallexample @c ada
2681 procedure Secret_Stuff is
2687 if compiled with pragma @code{License} (@code{Restricted}) in a
2688 @file{gnat.adc} file will generate the warning:
2693 >>> license of withed unit "Sem_Ch3" is incompatible
2695 2. with GNAT.Sockets;
2696 3. procedure Secret_Stuff is
2700 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2701 compiler and is licensed under the
2702 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2703 run time, and is therefore licensed under the modified GPL@.
2705 @node Pragma Link_With
2706 @unnumberedsec Pragma Link_With
2711 @smallexample @c ada
2712 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2716 This pragma is provided for compatibility with certain Ada 83 compilers.
2717 It has exactly the same effect as pragma @code{Linker_Options} except
2718 that spaces occurring within one of the string expressions are treated
2719 as separators. For example, in the following case:
2721 @smallexample @c ada
2722 pragma Link_With ("-labc -ldef");
2726 results in passing the strings @code{-labc} and @code{-ldef} as two
2727 separate arguments to the linker. In addition pragma Link_With allows
2728 multiple arguments, with the same effect as successive pragmas.
2730 @node Pragma Linker_Alias
2731 @unnumberedsec Pragma Linker_Alias
2732 @findex Linker_Alias
2736 @smallexample @c ada
2737 pragma Linker_Alias (
2738 [Entity =>] local_NAME
2739 [Target =>] static_string_EXPRESSION);
2743 @var{local_NAME} must refer to an object that is declared at the library
2744 level. This pragma establishes the given entity as a linker alias for the
2745 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
2746 and causes @var{local_NAME} to be emitted as an alias for the symbol
2747 @var{static_string_EXPRESSION} in the object file, that is to say no space
2748 is reserved for @var{local_NAME} by the assembler and it will be resolved
2749 to the same address as @var{static_string_EXPRESSION} by the linker.
2751 The actual linker name for the target must be used (e.g. the fully
2752 encoded name with qualification in Ada, or the mangled name in C++),
2753 or it must be declared using the C convention with @code{pragma Import}
2754 or @code{pragma Export}.
2756 Not all target machines support this pragma. On some of them it is accepted
2757 only if @code{pragma Weak_External} has been applied to @var{local_NAME}.
2759 @smallexample @c ada
2760 -- Example of the use of pragma Linker_Alias
2764 pragma Export (C, i);
2766 new_name_for_i : Integer;
2767 pragma Linker_Alias (new_name_for_i, "i");
2771 @node Pragma Linker_Constructor
2772 @unnumberedsec Pragma Linker_Constructor
2773 @findex Linker_Constructor
2777 @smallexample @c ada
2778 pragma Linker_Constructor (procedure_LOCAL_NAME);
2782 @var{procedure_local_NAME} must refer to a parameterless procedure that
2783 is declared at the library level. A procedure to which this pragma is
2784 applied will be treated as an initialization routine by the linker.
2785 It is equivalent to @code{__attribute__((constructor))} in GNU C and
2786 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
2787 of the executable is called (or immediately after the shared library is
2788 loaded if the procedure is linked in a shared library), in particular
2789 before the Ada run-time environment is set up.
2791 Because of these specific contexts, the set of operations such a procedure
2792 can perform is very limited and the type of objects it can manipulate is
2793 essentially restricted to the elementary types. In particular, it must only
2794 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
2796 This pragma is used by GNAT to implement auto-initialization of shared Stand
2797 Alone Libraries, which provides a related capability without the restrictions
2798 listed above. Where possible, the use of Stand Alone Libraries is preferable
2799 to the use of this pragma.
2801 @node Pragma Linker_Destructor
2802 @unnumberedsec Pragma Linker_Destructor
2803 @findex Linker_Destructor
2807 @smallexample @c ada
2808 pragma Linker_Destructor (procedure_LOCAL_NAME);
2812 @var{procedure_local_NAME} must refer to a parameterless procedure that
2813 is declared at the library level. A procedure to which this pragma is
2814 applied will be treated as a finalization routine by the linker.
2815 It is equivalent to @code{__attribute__((destructor))} in GNU C and
2816 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
2817 of the executable has exited (or immediately before the shared library
2818 is unloaded if the procedure is linked in a shared library), in particular
2819 after the Ada run-time environment is shut down.
2821 See @code{pragma Linker_Constructor} for the set of restrictions that apply
2822 because of these specific contexts.
2824 @node Pragma Linker_Section
2825 @unnumberedsec Pragma Linker_Section
2826 @findex Linker_Section
2830 @smallexample @c ada
2831 pragma Linker_Section (
2832 [Entity =>] local_NAME
2833 [Section =>] static_string_EXPRESSION);
2837 @var{local_NAME} must refer to an object that is declared at the library
2838 level. This pragma specifies the name of the linker section for the given
2839 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
2840 causes @var{local_NAME} to be placed in the @var{static_string_EXPRESSION}
2841 section of the executable (assuming the linker doesn't rename the section).
2843 The compiler normally places library-level objects in standard sections
2844 depending on their type: procedures and functions generally go in the
2845 @code{.text} section, initialized variables in the @code{.data} section
2846 and uninitialized variables in the @code{.bss} section.
2848 Other, special sections may exist on given target machines to map special
2849 hardware, for example I/O ports or flash memory. This pragma is a means to
2850 defer the final layout of the executable to the linker, thus fully working
2851 at the symbolic level with the compiler.
2853 Some file formats do not support arbitrary sections so not all target
2854 machines support this pragma. The use of this pragma may cause a program
2855 execution to be erroneous if it is used to place an entity into an
2856 inappropriate section (e.g. a modified variable into the @code{.text}
2857 section). See also @code{pragma Persistent_BSS}.
2859 @smallexample @c ada
2860 -- Example of the use of pragma Linker_Section
2864 pragma Volatile (Port_A);
2865 pragma Linker_Section (Port_A, ".bss.port_a");
2868 pragma Volatile (Port_B);
2869 pragma Linker_Section (Port_B, ".bss.port_b");
2873 @node Pragma Long_Float
2874 @unnumberedsec Pragma Long_Float
2880 @smallexample @c ada
2881 pragma Long_Float (FLOAT_FORMAT);
2883 FLOAT_FORMAT ::= D_Float | G_Float
2887 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2888 It allows control over the internal representation chosen for the predefined
2889 type @code{Long_Float} and for floating point type representations with
2890 @code{digits} specified in the range 7 through 15.
2891 For further details on this pragma, see the
2892 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
2893 this pragma, the standard runtime libraries must be recompiled. See the
2894 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2895 of the GNAT User's Guide for details on the use of this command.
2897 @node Pragma Machine_Attribute
2898 @unnumberedsec Pragma Machine_Attribute
2899 @findex Machine_Attribute
2903 @smallexample @c ada
2904 pragma Machine_Attribute (
2905 [Attribute_Name =>] string_EXPRESSION,
2906 [Entity =>] local_NAME);
2910 Machine-dependent attributes can be specified for types and/or
2911 declarations. This pragma is semantically equivalent to
2912 @code{__attribute__((@var{string_expression}))} in GNU C,
2913 where @code{@var{string_expression}} is
2914 recognized by the target macro @code{TARGET_ATTRIBUTE_TABLE} which is
2915 defined for each machine. See the GCC manual for further information.
2916 It is not possible to specify attributes defined by other languages,
2917 only attributes defined by the machine the code is intended to run on.
2919 @node Pragma Main_Storage
2920 @unnumberedsec Pragma Main_Storage
2922 @findex Main_Storage
2926 @smallexample @c ada
2928 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2930 MAIN_STORAGE_OPTION ::=
2931 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2932 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
2937 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
2938 no effect in GNAT, other than being syntax checked. Note that the pragma
2939 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2941 @node Pragma No_Body
2942 @unnumberedsec Pragma No_Body
2947 @smallexample @c ada
2952 There are a number of cases in which a package spec does not require a body,
2953 and in fact a body is not permitted. GNAT will not permit the spec to be
2954 compiled if there is a body around. The pragma No_Body allows you to provide
2955 a body file, even in a case where no body is allowed. The body file must
2956 contain only comments and a single No_Body pragma. This is recognized by
2957 the compiler as indicating that no body is logically present.
2959 This is particularly useful during maintenance when a package is modified in
2960 such a way that a body needed before is no longer needed. The provision of a
2961 dummy body with a No_Body pragma ensures that there is no inteference from
2962 earlier versions of the package body.
2964 @node Pragma No_Return
2965 @unnumberedsec Pragma No_Return
2970 @smallexample @c ada
2971 pragma No_Return (procedure_local_NAME @{, procedure_local_NAME@});
2975 Each @var{procedure_local_NAME} argument must refer to one or more procedure
2976 declarations in the current declarative part. A procedure to which this
2977 pragma is applied may not contain any explicit @code{return} statements.
2978 In addition, if the procedure contains any implicit returns from falling
2979 off the end of a statement sequence, then execution of that implicit
2980 return will cause Program_Error to be raised.
2982 One use of this pragma is to identify procedures whose only purpose is to raise
2983 an exception. Another use of this pragma is to suppress incorrect warnings
2984 about missing returns in functions, where the last statement of a function
2985 statement sequence is a call to such a procedure.
2987 Note that in Ada 2005 mode, this pragma is part of the language, and is
2988 identical in effect to the pragma as implemented in Ada 95 mode.
2990 @node Pragma No_Strict_Aliasing
2991 @unnumberedsec Pragma No_Strict_Aliasing
2992 @findex No_Strict_Aliasing
2996 @smallexample @c ada
2997 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3001 @var{type_LOCAL_NAME} must refer to an access type
3002 declaration in the current declarative part. The effect is to inhibit
3003 strict aliasing optimization for the given type. The form with no
3004 arguments is a configuration pragma which applies to all access types
3005 declared in units to which the pragma applies. For a detailed
3006 description of the strict aliasing optimization, and the situations
3007 in which it must be suppressed, see section
3008 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
3010 @node Pragma Normalize_Scalars
3011 @unnumberedsec Pragma Normalize_Scalars
3012 @findex Normalize_Scalars
3016 @smallexample @c ada
3017 pragma Normalize_Scalars;
3021 This is a language defined pragma which is fully implemented in GNAT@. The
3022 effect is to cause all scalar objects that are not otherwise initialized
3023 to be initialized. The initial values are implementation dependent and
3027 @item Standard.Character
3029 Objects whose root type is Standard.Character are initialized to
3030 Character'Last unless the subtype range excludes NUL (in which case
3031 NUL is used). This choice will always generate an invalid value if
3034 @item Standard.Wide_Character
3036 Objects whose root type is Standard.Wide_Character are initialized to
3037 Wide_Character'Last unless the subtype range excludes NUL (in which case
3038 NUL is used). This choice will always generate an invalid value if
3041 @item Standard.Wide_Wide_Character
3043 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3044 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3045 which case NUL is used). This choice will always generate an invalid value if
3050 Objects of an integer type are treated differently depending on whether
3051 negative values are present in the subtype. If no negative values are
3052 present, then all one bits is used as the initial value except in the
3053 special case where zero is excluded from the subtype, in which case
3054 all zero bits are used. This choice will always generate an invalid
3055 value if one exists.
3057 For subtypes with negative values present, the largest negative number
3058 is used, except in the unusual case where this largest negative number
3059 is in the subtype, and the largest positive number is not, in which case
3060 the largest positive value is used. This choice will always generate
3061 an invalid value if one exists.
3063 @item Floating-Point Types
3064 Objects of all floating-point types are initialized to all 1-bits. For
3065 standard IEEE format, this corresponds to a NaN (not a number) which is
3066 indeed an invalid value.
3068 @item Fixed-Point Types
3069 Objects of all fixed-point types are treated as described above for integers,
3070 with the rules applying to the underlying integer value used to represent
3071 the fixed-point value.
3074 Objects of a modular type are initialized to all one bits, except in
3075 the special case where zero is excluded from the subtype, in which
3076 case all zero bits are used. This choice will always generate an
3077 invalid value if one exists.
3079 @item Enumeration types
3080 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3081 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3082 whose Pos value is zero, in which case a code of zero is used. This choice
3083 will always generate an invalid value if one exists.
3087 @node Pragma Obsolescent
3088 @unnumberedsec Pragma Obsolescent
3093 @smallexample @c ada
3095 (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3099 This pragma can occur immediately following a declaration of an entity,
3100 including the case of a record component, and usually the Entity name
3101 must match the name of the entity declared by this declaration.
3102 Alternatively, the pragma can immediately follow an
3103 enumeration type declaration, where the entity argument names one of the
3104 enumeration literals.
3106 This pragma is used to indicate that the named entity
3107 is considered obsolescent and should not be used. Typically this is
3108 used when an API must be modified by eventually removing or modifying
3109 existing subprograms or other entities. The pragma can be used at an
3110 intermediate stage when the entity is still present, but will be
3113 The effect of this pragma is to output a warning message on
3114 a call to a program thus marked that the
3115 subprogram is obsolescent if the appropriate warning option in the
3116 compiler is activated. If the string parameter is present, then a second
3117 warning message is given containing this text.
3118 In addition, a call to such a program is considered a violation of
3119 pragma Restrictions (No_Obsolescent_Features).
3121 This pragma can also be used as a program unit pragma for a package,
3122 in which case the entity name is the name of the package, and the
3123 pragma indicates that the entire package is considered
3124 obsolescent. In this case a client @code{with}'ing such a package
3125 violates the restriction, and the @code{with} statement is
3126 flagged with warnings if the warning option is set.
3128 If the optional third parameter is present (which must be exactly
3129 the identifier Ada_05, no other argument is allowed), then the
3130 indication of obsolescence applies only when compiling in Ada 2005
3131 mode. This is primarily intended for dealing with the situations
3132 in the predefined library where subprograms or packages
3133 have become defined as obsolescent in Ada 2005
3134 (e.g. in Ada.Characters.Handling), but may be used anywhere.
3136 The following examples show typical uses of this pragma:
3138 @smallexample @c ada
3141 (Entity => p, "use pp instead of p");
3147 (Entity => q2, "use q2new instead");
3149 type R is new integer;
3151 (Entity => R, "use RR in Ada 2005", Ada_05);
3156 pragma Obsolescent (Entity => F2);
3160 type E is (a, bc, 'd', quack);
3161 pragma Obsolescent (Entity => bc)
3162 pragma Obsolescent (Entity => 'd')
3165 (a, b : character) return character;
3166 pragma Obsolescent (Entity => "+");
3171 In an earlier version of GNAT, the Entity parameter was not required,
3172 and this form is still accepted for compatibility purposes. If the
3173 Entity parameter is omitted, then the pragma applies to the declaration
3174 immediately preceding the pragma (this form cannot be used for the
3175 enumeration literal case).
3177 @node Pragma Passive
3178 @unnumberedsec Pragma Passive
3183 @smallexample @c ada
3184 pragma Passive ([Semaphore | No]);
3188 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3189 compatibility with DEC Ada 83 implementations, where it is used within a
3190 task definition to request that a task be made passive. If the argument
3191 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3192 treats the pragma as an assertion that the containing task is passive
3193 and that optimization of context switch with this task is permitted and
3194 desired. If the argument @code{No} is present, the task must not be
3195 optimized. GNAT does not attempt to optimize any tasks in this manner
3196 (since protected objects are available in place of passive tasks).
3198 @node Pragma Persistent_BSS
3199 @unnumberedsec Pragma Persistent_BSS
3200 @findex Persistent_BSS
3204 @smallexample @c ada
3205 pragma Persistent_BSS [local_NAME]
3209 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3210 section. On some targets the linker and loader provide for special
3211 treatment of this section, allowing a program to be reloaded without
3212 affecting the contents of this data (hence the name persistent).
3214 There are two forms of usage. If an argument is given, it must be the
3215 local name of a library level object, with no explicit initialization
3216 and whose type is potentially persistent. If no argument is given, then
3217 the pragma is a configuration pragma, and applies to all library level
3218 objects with no explicit initialization of potentially persistent types.
3220 A potentially persistent type is a scalar type, or a non-tagged,
3221 non-discriminated record, all of whose components have no explicit
3222 initialization and are themselves of a potentially persistent type,
3223 or an array, all of whose constraints are static, and whose component
3224 type is potentially persistent.
3226 If this pragma is used on a target where this feature is not supported,
3227 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3229 @node Pragma Polling
3230 @unnumberedsec Pragma Polling
3235 @smallexample @c ada
3236 pragma Polling (ON | OFF);
3240 This pragma controls the generation of polling code. This is normally off.
3241 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3242 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3243 runtime library, and can be found in file @file{a-excpol.adb}.
3245 Pragma @code{Polling} can appear as a configuration pragma (for example it
3246 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3247 can be used in the statement or declaration sequence to control polling
3250 A call to the polling routine is generated at the start of every loop and
3251 at the start of every subprogram call. This guarantees that the @code{Poll}
3252 routine is called frequently, and places an upper bound (determined by
3253 the complexity of the code) on the period between two @code{Poll} calls.
3255 The primary purpose of the polling interface is to enable asynchronous
3256 aborts on targets that cannot otherwise support it (for example Windows
3257 NT), but it may be used for any other purpose requiring periodic polling.
3258 The standard version is null, and can be replaced by a user program. This
3259 will require re-compilation of the @code{Ada.Exceptions} package that can
3260 be found in files @file{a-except.ads} and @file{a-except.adb}.
3262 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3263 distribution) is used to enable the asynchronous abort capability on
3264 targets that do not normally support the capability. The version of
3265 @code{Poll} in this file makes a call to the appropriate runtime routine
3266 to test for an abort condition.
3268 Note that polling can also be enabled by use of the @code{-gnatP} switch. See
3269 the @cite{GNAT User's Guide} for details.
3271 @node Pragma Profile (Ravenscar)
3272 @unnumberedsec Pragma Profile (Ravenscar)
3277 @smallexample @c ada
3278 pragma Profile (Ravenscar);
3282 A configuration pragma that establishes the following set of configuration
3286 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3287 [RM D.2.2] Tasks are dispatched following a preemptive
3288 priority-ordered scheduling policy.
3290 @item Locking_Policy (Ceiling_Locking)
3291 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3292 the ceiling priority of the corresponding protected object.
3294 @c @item Detect_Blocking
3295 @c This pragma forces the detection of potentially blocking operations within a
3296 @c protected operation, and to raise Program_Error if that happens.
3300 plus the following set of restrictions:
3303 @item Max_Entry_Queue_Length = 1
3304 Defines the maximum number of calls that are queued on a (protected) entry.
3305 Note that this restrictions is checked at run time. Violation of this
3306 restriction results in the raising of Program_Error exception at the point of
3307 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3308 always 1 and hence no task can be queued on a protected entry.
3310 @item Max_Protected_Entries = 1
3311 [RM D.7] Specifies the maximum number of entries per protected type. The
3312 bounds of every entry family of a protected unit shall be static, or shall be
3313 defined by a discriminant of a subtype whose corresponding bound is static.
3314 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3316 @item Max_Task_Entries = 0
3317 [RM D.7] Specifies the maximum number of entries
3318 per task. The bounds of every entry family
3319 of a task unit shall be static, or shall be
3320 defined by a discriminant of a subtype whose
3321 corresponding bound is static. A value of zero
3322 indicates that no rendezvous are possible. For
3323 the Profile (Ravenscar), the value of Max_Task_Entries is always
3326 @item No_Abort_Statements
3327 [RM D.7] There are no abort_statements, and there are
3328 no calls to Task_Identification.Abort_Task.
3330 @item No_Asynchronous_Control
3331 [RM D.7] There are no semantic dependences on the package
3332 Asynchronous_Task_Control.
3335 There are no semantic dependencies on the package Ada.Calendar.
3337 @item No_Dynamic_Attachment
3338 There is no call to any of the operations defined in package Ada.Interrupts
3339 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3340 Detach_Handler, and Reference).
3342 @item No_Dynamic_Priorities
3343 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3345 @item No_Implicit_Heap_Allocations
3346 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3348 @item No_Local_Protected_Objects
3349 Protected objects and access types that designate
3350 such objects shall be declared only at library level.
3352 @item No_Protected_Type_Allocators
3353 There are no allocators for protected types or
3354 types containing protected subcomponents.
3356 @item No_Relative_Delay
3357 There are no delay_relative statements.
3359 @item No_Requeue_Statements
3360 Requeue statements are not allowed.
3362 @item No_Select_Statements
3363 There are no select_statements.
3365 @item No_Task_Allocators
3366 [RM D.7] There are no allocators for task types
3367 or types containing task subcomponents.
3369 @item No_Task_Attributes_Package
3370 There are no semantic dependencies on the Ada.Task_Attributes package.
3372 @item No_Task_Hierarchy
3373 [RM D.7] All (non-environment) tasks depend
3374 directly on the environment task of the partition.
3376 @item No_Task_Termination
3377 Tasks which terminate are erroneous.
3379 @item Simple_Barriers
3380 Entry barrier condition expressions shall be either static
3381 boolean expressions or boolean objects which are declared in
3382 the protected type which contains the entry.
3386 This set of configuration pragmas and restrictions correspond to the
3387 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3388 published by the @cite{International Real-Time Ada Workshop}, 1997,
3389 and whose most recent description is available at
3390 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
3392 The original definition of the profile was revised at subsequent IRTAW
3393 meetings. It has been included in the ISO
3394 @cite{Guide for the Use of the Ada Programming Language in High
3395 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3396 the next revision of the standard. The formal definition given by
3397 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3398 AI-305) available at
3399 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3400 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3403 The above set is a superset of the restrictions provided by pragma
3404 @code{Profile (Restricted)}, it includes six additional restrictions
3405 (@code{Simple_Barriers}, @code{No_Select_Statements},
3406 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3407 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
3408 that pragma @code{Profile (Ravenscar)}, like the pragma
3409 @code{Profile (Restricted)},
3410 automatically causes the use of a simplified,
3411 more efficient version of the tasking run-time system.
3413 @node Pragma Profile (Restricted)
3414 @unnumberedsec Pragma Profile (Restricted)
3415 @findex Restricted Run Time
3419 @smallexample @c ada
3420 pragma Profile (Restricted);
3424 A configuration pragma that establishes the following set of restrictions:
3427 @item No_Abort_Statements
3428 @item No_Entry_Queue
3429 @item No_Task_Hierarchy
3430 @item No_Task_Allocators
3431 @item No_Dynamic_Priorities
3432 @item No_Terminate_Alternatives
3433 @item No_Dynamic_Attachment
3434 @item No_Protected_Type_Allocators
3435 @item No_Local_Protected_Objects
3436 @item No_Requeue_Statements
3437 @item No_Task_Attributes_Package
3438 @item Max_Asynchronous_Select_Nesting = 0
3439 @item Max_Task_Entries = 0
3440 @item Max_Protected_Entries = 1
3441 @item Max_Select_Alternatives = 0
3445 This set of restrictions causes the automatic selection of a simplified
3446 version of the run time that provides improved performance for the
3447 limited set of tasking functionality permitted by this set of restrictions.
3449 @node Pragma Psect_Object
3450 @unnumberedsec Pragma Psect_Object
3451 @findex Psect_Object
3455 @smallexample @c ada
3456 pragma Psect_Object (
3457 [Internal =>] local_NAME,
3458 [, [External =>] EXTERNAL_SYMBOL]
3459 [, [Size =>] EXTERNAL_SYMBOL]);
3463 | static_string_EXPRESSION
3467 This pragma is identical in effect to pragma @code{Common_Object}.
3469 @node Pragma Pure_Function
3470 @unnumberedsec Pragma Pure_Function
3471 @findex Pure_Function
3475 @smallexample @c ada
3476 pragma Pure_Function ([Entity =>] function_local_NAME);
3480 This pragma appears in the same declarative part as a function
3481 declaration (or a set of function declarations if more than one
3482 overloaded declaration exists, in which case the pragma applies
3483 to all entities). It specifies that the function @code{Entity} is
3484 to be considered pure for the purposes of code generation. This means
3485 that the compiler can assume that there are no side effects, and
3486 in particular that two calls with identical arguments produce the
3487 same result. It also means that the function can be used in an
3490 Note that, quite deliberately, there are no static checks to try
3491 to ensure that this promise is met, so @code{Pure_Function} can be used
3492 with functions that are conceptually pure, even if they do modify
3493 global variables. For example, a square root function that is
3494 instrumented to count the number of times it is called is still
3495 conceptually pure, and can still be optimized, even though it
3496 modifies a global variable (the count). Memo functions are another
3497 example (where a table of previous calls is kept and consulted to
3498 avoid re-computation).
3501 Note: Most functions in a @code{Pure} package are automatically pure, and
3502 there is no need to use pragma @code{Pure_Function} for such functions. One
3503 exception is any function that has at least one formal of type
3504 @code{System.Address} or a type derived from it. Such functions are not
3505 considered pure by default, since the compiler assumes that the
3506 @code{Address} parameter may be functioning as a pointer and that the
3507 referenced data may change even if the address value does not.
3508 Similarly, imported functions are not considered to be pure by default,
3509 since there is no way of checking that they are in fact pure. The use
3510 of pragma @code{Pure_Function} for such a function will override these default
3511 assumption, and cause the compiler to treat a designated subprogram as pure
3514 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3515 applies to the underlying renamed function. This can be used to
3516 disambiguate cases of overloading where some but not all functions
3517 in a set of overloaded functions are to be designated as pure.
3519 If pragma @code{Pure_Function} is applied to a library level function, the
3520 function is also considered pure from an optimization point of view, but the
3521 unit is not a Pure unit in the categorization sense. So for example, a function
3522 thus marked is free to @code{with} non-pure units.
3524 @node Pragma Restriction_Warnings
3525 @unnumberedsec Pragma Restriction_Warnings
3526 @findex Restriction_Warnings
3530 @smallexample @c ada
3531 pragma Restriction_Warnings
3532 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3536 This pragma allows a series of restriction identifiers to be
3537 specified (the list of allowed identifiers is the same as for
3538 pragma @code{Restrictions}). For each of these identifiers
3539 the compiler checks for violations of the restriction, but
3540 generates a warning message rather than an error message
3541 if the restriction is violated.
3543 @node Pragma Source_File_Name
3544 @unnumberedsec Pragma Source_File_Name
3545 @findex Source_File_Name
3549 @smallexample @c ada
3550 pragma Source_File_Name (
3551 [Unit_Name =>] unit_NAME,
3552 Spec_File_Name => STRING_LITERAL);
3554 pragma Source_File_Name (
3555 [Unit_Name =>] unit_NAME,
3556 Body_File_Name => STRING_LITERAL);
3560 Use this to override the normal naming convention. It is a configuration
3561 pragma, and so has the usual applicability of configuration pragmas
3562 (i.e.@: it applies to either an entire partition, or to all units in a
3563 compilation, or to a single unit, depending on how it is used.
3564 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
3565 the second argument is required, and indicates whether this is the file
3566 name for the spec or for the body.
3568 Another form of the @code{Source_File_Name} pragma allows
3569 the specification of patterns defining alternative file naming schemes
3570 to apply to all files.
3572 @smallexample @c ada
3573 pragma Source_File_Name
3574 (Spec_File_Name => STRING_LITERAL
3575 [,Casing => CASING_SPEC]
3576 [,Dot_Replacement => STRING_LITERAL]);
3578 pragma Source_File_Name
3579 (Body_File_Name => STRING_LITERAL
3580 [,Casing => CASING_SPEC]
3581 [,Dot_Replacement => STRING_LITERAL]);
3583 pragma Source_File_Name
3584 (Subunit_File_Name => STRING_LITERAL
3585 [,Casing => CASING_SPEC]
3586 [,Dot_Replacement => STRING_LITERAL]);
3588 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3592 The first argument is a pattern that contains a single asterisk indicating
3593 the point at which the unit name is to be inserted in the pattern string
3594 to form the file name. The second argument is optional. If present it
3595 specifies the casing of the unit name in the resulting file name string.
3596 The default is lower case. Finally the third argument allows for systematic
3597 replacement of any dots in the unit name by the specified string literal.
3599 A pragma Source_File_Name cannot appear after a
3600 @ref{Pragma Source_File_Name_Project}.
3602 For more details on the use of the @code{Source_File_Name} pragma,
3603 see the sections ``Using Other File Names'' and
3604 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3606 @node Pragma Source_File_Name_Project
3607 @unnumberedsec Pragma Source_File_Name_Project
3608 @findex Source_File_Name_Project
3611 This pragma has the same syntax and semantics as pragma Source_File_Name.
3612 It is only allowed as a stand alone configuration pragma.
3613 It cannot appear after a @ref{Pragma Source_File_Name}, and
3614 most importantly, once pragma Source_File_Name_Project appears,
3615 no further Source_File_Name pragmas are allowed.
3617 The intention is that Source_File_Name_Project pragmas are always
3618 generated by the Project Manager in a manner consistent with the naming
3619 specified in a project file, and when naming is controlled in this manner,
3620 it is not permissible to attempt to modify this naming scheme using
3621 Source_File_Name pragmas (which would not be known to the project manager).
3623 @node Pragma Source_Reference
3624 @unnumberedsec Pragma Source_Reference
3625 @findex Source_Reference
3629 @smallexample @c ada
3630 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3634 This pragma must appear as the first line of a source file.
3635 @var{integer_literal} is the logical line number of the line following
3636 the pragma line (for use in error messages and debugging
3637 information). @var{string_literal} is a static string constant that
3638 specifies the file name to be used in error messages and debugging
3639 information. This is most notably used for the output of @code{gnatchop}
3640 with the @code{-r} switch, to make sure that the original unchopped
3641 source file is the one referred to.
3643 The second argument must be a string literal, it cannot be a static
3644 string expression other than a string literal. This is because its value
3645 is needed for error messages issued by all phases of the compiler.
3647 @node Pragma Stream_Convert
3648 @unnumberedsec Pragma Stream_Convert
3649 @findex Stream_Convert
3653 @smallexample @c ada
3654 pragma Stream_Convert (
3655 [Entity =>] type_local_NAME,
3656 [Read =>] function_NAME,
3657 [Write =>] function_NAME);
3661 This pragma provides an efficient way of providing stream functions for
3662 types defined in packages. Not only is it simpler to use than declaring
3663 the necessary functions with attribute representation clauses, but more
3664 significantly, it allows the declaration to made in such a way that the
3665 stream packages are not loaded unless they are needed. The use of
3666 the Stream_Convert pragma adds no overhead at all, unless the stream
3667 attributes are actually used on the designated type.
3669 The first argument specifies the type for which stream functions are
3670 provided. The second parameter provides a function used to read values
3671 of this type. It must name a function whose argument type may be any
3672 subtype, and whose returned type must be the type given as the first
3673 argument to the pragma.
3675 The meaning of the @var{Read}
3676 parameter is that if a stream attribute directly
3677 or indirectly specifies reading of the type given as the first parameter,
3678 then a value of the type given as the argument to the Read function is
3679 read from the stream, and then the Read function is used to convert this
3680 to the required target type.
3682 Similarly the @var{Write} parameter specifies how to treat write attributes
3683 that directly or indirectly apply to the type given as the first parameter.
3684 It must have an input parameter of the type specified by the first parameter,
3685 and the return type must be the same as the input type of the Read function.
3686 The effect is to first call the Write function to convert to the given stream
3687 type, and then write the result type to the stream.
3689 The Read and Write functions must not be overloaded subprograms. If necessary
3690 renamings can be supplied to meet this requirement.
3691 The usage of this attribute is best illustrated by a simple example, taken
3692 from the GNAT implementation of package Ada.Strings.Unbounded:
3694 @smallexample @c ada
3695 function To_Unbounded (S : String)
3696 return Unbounded_String
3697 renames To_Unbounded_String;
3699 pragma Stream_Convert
3700 (Unbounded_String, To_Unbounded, To_String);
3704 The specifications of the referenced functions, as given in the Ada
3705 Reference Manual are:
3707 @smallexample @c ada
3708 function To_Unbounded_String (Source : String)
3709 return Unbounded_String;
3711 function To_String (Source : Unbounded_String)
3716 The effect is that if the value of an unbounded string is written to a
3717 stream, then the representation of the item in the stream is in the same
3718 format used for @code{Standard.String}, and this same representation is
3719 expected when a value of this type is read from the stream.
3721 @node Pragma Style_Checks
3722 @unnumberedsec Pragma Style_Checks
3723 @findex Style_Checks
3727 @smallexample @c ada
3728 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3729 On | Off [, local_NAME]);
3733 This pragma is used in conjunction with compiler switches to control the
3734 built in style checking provided by GNAT@. The compiler switches, if set,
3735 provide an initial setting for the switches, and this pragma may be used
3736 to modify these settings, or the settings may be provided entirely by
3737 the use of the pragma. This pragma can be used anywhere that a pragma
3738 is legal, including use as a configuration pragma (including use in
3739 the @file{gnat.adc} file).
3741 The form with a string literal specifies which style options are to be
3742 activated. These are additive, so they apply in addition to any previously
3743 set style check options. The codes for the options are the same as those
3744 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3745 For example the following two methods can be used to enable
3750 @smallexample @c ada
3751 pragma Style_Checks ("l");
3756 gcc -c -gnatyl @dots{}
3761 The form ALL_CHECKS activates all standard checks (its use is equivalent
3762 to the use of the @code{gnaty} switch with no options. See GNAT User's
3765 The forms with @code{Off} and @code{On}
3766 can be used to temporarily disable style checks
3767 as shown in the following example:
3769 @smallexample @c ada
3773 pragma Style_Checks ("k"); -- requires keywords in lower case
3774 pragma Style_Checks (Off); -- turn off style checks
3775 NULL; -- this will not generate an error message
3776 pragma Style_Checks (On); -- turn style checks back on
3777 NULL; -- this will generate an error message
3781 Finally the two argument form is allowed only if the first argument is
3782 @code{On} or @code{Off}. The effect is to turn of semantic style checks
3783 for the specified entity, as shown in the following example:
3785 @smallexample @c ada
3789 pragma Style_Checks ("r"); -- require consistency of identifier casing
3791 Rf1 : Integer := ARG; -- incorrect, wrong case
3792 pragma Style_Checks (Off, Arg);
3793 Rf2 : Integer := ARG; -- OK, no error
3796 @node Pragma Subtitle
3797 @unnumberedsec Pragma Subtitle
3802 @smallexample @c ada
3803 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3807 This pragma is recognized for compatibility with other Ada compilers
3808 but is ignored by GNAT@.
3810 @node Pragma Suppress
3811 @unnumberedsec Pragma Suppress
3816 @smallexample @c ada
3817 pragma Suppress (Identifier [, [On =>] Name]);
3821 This is a standard pragma, and supports all the check names required in
3822 the RM. It is included here because GNAT recognizes one additional check
3823 name: @code{Alignment_Check} which can be used to suppress alignment checks
3824 on addresses used in address clauses. Such checks can also be suppressed
3825 by suppressing range checks, but the specific use of @code{Alignment_Check}
3826 allows suppression of alignment checks without suppressing other range checks.
3828 @node Pragma Suppress_All
3829 @unnumberedsec Pragma Suppress_All
3830 @findex Suppress_All
3834 @smallexample @c ada
3835 pragma Suppress_All;
3839 This pragma can only appear immediately following a compilation
3840 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
3841 which it follows. This pragma is implemented for compatibility with DEC
3842 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
3843 configuration pragma is the preferred usage in GNAT@.
3845 @node Pragma Suppress_Exception_Locations
3846 @unnumberedsec Pragma Suppress_Exception_Locations
3847 @findex Suppress_Exception_Locations
3851 @smallexample @c ada
3852 pragma Suppress_Exception_Locations;
3856 In normal mode, a raise statement for an exception by default generates
3857 an exception message giving the file name and line number for the location
3858 of the raise. This is useful for debugging and logging purposes, but this
3859 entails extra space for the strings for the messages. The configuration
3860 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3861 generation of these strings, with the result that space is saved, but the
3862 exception message for such raises is null. This configuration pragma may
3863 appear in a global configuration pragma file, or in a specific unit as
3864 usual. It is not required that this pragma be used consistently within
3865 a partition, so it is fine to have some units within a partition compiled
3866 with this pragma and others compiled in normal mode without it.
3868 @node Pragma Suppress_Initialization
3869 @unnumberedsec Pragma Suppress_Initialization
3870 @findex Suppress_Initialization
3871 @cindex Suppressing initialization
3872 @cindex Initialization, suppression of
3876 @smallexample @c ada
3877 pragma Suppress_Initialization ([Entity =>] type_Name);
3881 This pragma suppresses any implicit or explicit initialization
3882 associated with the given type name for all variables of this type.
3884 @node Pragma Task_Info
3885 @unnumberedsec Pragma Task_Info
3890 @smallexample @c ada
3891 pragma Task_Info (EXPRESSION);
3895 This pragma appears within a task definition (like pragma
3896 @code{Priority}) and applies to the task in which it appears. The
3897 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3898 The @code{Task_Info} pragma provides system dependent control over
3899 aspects of tasking implementation, for example, the ability to map
3900 tasks to specific processors. For details on the facilities available
3901 for the version of GNAT that you are using, see the documentation
3902 in the specification of package System.Task_Info in the runtime
3905 @node Pragma Task_Name
3906 @unnumberedsec Pragma Task_Name
3911 @smallexample @c ada
3912 pragma Task_Name (string_EXPRESSION);
3916 This pragma appears within a task definition (like pragma
3917 @code{Priority}) and applies to the task in which it appears. The
3918 argument must be of type String, and provides a name to be used for
3919 the task instance when the task is created. Note that this expression
3920 is not required to be static, and in particular, it can contain
3921 references to task discriminants. This facility can be used to
3922 provide different names for different tasks as they are created,
3923 as illustrated in the example below.
3925 The task name is recorded internally in the run-time structures
3926 and is accessible to tools like the debugger. In addition the
3927 routine @code{Ada.Task_Identification.Image} will return this
3928 string, with a unique task address appended.
3930 @smallexample @c ada
3931 -- Example of the use of pragma Task_Name
3933 with Ada.Task_Identification;
3934 use Ada.Task_Identification;
3935 with Text_IO; use Text_IO;
3938 type Astring is access String;
3940 task type Task_Typ (Name : access String) is
3941 pragma Task_Name (Name.all);
3944 task body Task_Typ is
3945 Nam : constant String := Image (Current_Task);
3947 Put_Line ("-->" & Nam (1 .. 14) & "<--");
3950 type Ptr_Task is access Task_Typ;
3951 Task_Var : Ptr_Task;
3955 new Task_Typ (new String'("This is task 1"));
3957 new Task_Typ (new String'("This is task 2"));
3961 @node Pragma Task_Storage
3962 @unnumberedsec Pragma Task_Storage
3963 @findex Task_Storage
3966 @smallexample @c ada
3967 pragma Task_Storage (
3968 [Task_Type =>] local_NAME,
3969 [Top_Guard =>] static_integer_EXPRESSION);
3973 This pragma specifies the length of the guard area for tasks. The guard
3974 area is an additional storage area allocated to a task. A value of zero
3975 means that either no guard area is created or a minimal guard area is
3976 created, depending on the target. This pragma can appear anywhere a
3977 @code{Storage_Size} attribute definition clause is allowed for a task
3980 @node Pragma Time_Slice
3981 @unnumberedsec Pragma Time_Slice
3986 @smallexample @c ada
3987 pragma Time_Slice (static_duration_EXPRESSION);
3991 For implementations of GNAT on operating systems where it is possible
3992 to supply a time slice value, this pragma may be used for this purpose.
3993 It is ignored if it is used in a system that does not allow this control,
3994 or if it appears in other than the main program unit.
3996 Note that the effect of this pragma is identical to the effect of the
3997 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4000 @unnumberedsec Pragma Title
4005 @smallexample @c ada
4006 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4009 [Title =>] STRING_LITERAL,
4010 | [Subtitle =>] STRING_LITERAL
4014 Syntax checked but otherwise ignored by GNAT@. This is a listing control
4015 pragma used in DEC Ada 83 implementations to provide a title and/or
4016 subtitle for the program listing. The program listing generated by GNAT
4017 does not have titles or subtitles.
4019 Unlike other pragmas, the full flexibility of named notation is allowed
4020 for this pragma, i.e.@: the parameters may be given in any order if named
4021 notation is used, and named and positional notation can be mixed
4022 following the normal rules for procedure calls in Ada.
4024 @node Pragma Unchecked_Union
4025 @unnumberedsec Pragma Unchecked_Union
4027 @findex Unchecked_Union
4031 @smallexample @c ada
4032 pragma Unchecked_Union (first_subtype_local_NAME);
4036 This pragma is used to specify a representation of a record type that is
4037 equivalent to a C union. It was introduced as a GNAT implementation defined
4038 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4039 pragma, making it language defined, and GNAT fully implements this extended
4040 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4041 details, consult the Ada 2005 Reference Manual, section B.3.3.
4043 @node Pragma Unimplemented_Unit
4044 @unnumberedsec Pragma Unimplemented_Unit
4045 @findex Unimplemented_Unit
4049 @smallexample @c ada
4050 pragma Unimplemented_Unit;
4054 If this pragma occurs in a unit that is processed by the compiler, GNAT
4055 aborts with the message @samp{@var{xxx} not implemented}, where
4056 @var{xxx} is the name of the current compilation unit. This pragma is
4057 intended to allow the compiler to handle unimplemented library units in
4060 The abort only happens if code is being generated. Thus you can use
4061 specs of unimplemented packages in syntax or semantic checking mode.
4063 @node Pragma Universal_Aliasing
4064 @unnumberedsec Pragma Universal_Aliasing
4065 @findex Universal_Aliasing
4069 @smallexample @c ada
4070 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4074 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4075 declarative part. The effect is to inhibit strict type-based aliasing
4076 optimization for the given type. In other words, the effect is as though
4077 access types designating this type were subject to pragma No_Strict_Aliasing.
4078 For a detailed description of the strict aliasing optimization, and the
4079 situations in which it must be suppressed, see section
4080 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
4082 @node Pragma Universal_Data
4083 @unnumberedsec Pragma Universal_Data
4084 @findex Universal_Data
4088 @smallexample @c ada
4089 pragma Universal_Data [(library_unit_Name)];
4093 This pragma is supported only for the AAMP target and is ignored for
4094 other targets. The pragma specifies that all library-level objects
4095 (Counter 0 data) associated with the library unit are to be accessed
4096 and updated using universal addressing (24-bit addresses for AAMP5)
4097 rather than the default of 16-bit Data Environment (DENV) addressing.
4098 Use of this pragma will generally result in less efficient code for
4099 references to global data associated with the library unit, but
4100 allows such data to be located anywhere in memory. This pragma is
4101 a library unit pragma, but can also be used as a configuration pragma
4102 (including use in the @file{gnat.adc} file). The functionality
4103 of this pragma is also available by applying the -univ switch on the
4104 compilations of units where universal addressing of the data is desired.
4106 @node Pragma Unreferenced
4107 @unnumberedsec Pragma Unreferenced
4108 @findex Unreferenced
4109 @cindex Warnings, unreferenced
4113 @smallexample @c ada
4114 pragma Unreferenced (local_NAME @{, local_NAME@});
4115 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4119 This pragma signals that the entities whose names are listed are
4120 deliberately not referenced in the current source unit. This
4121 suppresses warnings about the
4122 entities being unreferenced, and in addition a warning will be
4123 generated if one of these entities is in fact referenced in the
4124 same unit as the pragma (or in the corresponding body, or one
4127 This is particularly useful for clearly signaling that a particular
4128 parameter is not referenced in some particular subprogram implementation
4129 and that this is deliberate. It can also be useful in the case of
4130 objects declared only for their initialization or finalization side
4133 If @code{local_NAME} identifies more than one matching homonym in the
4134 current scope, then the entity most recently declared is the one to which
4135 the pragma applies. Note that in the case of accept formals, the pragma
4136 Unreferenced may appear immediately after the keyword @code{do} which
4137 allows the indication of whether or not accept formals are referenced
4138 or not to be given individually for each accept statement.
4140 The left hand side of an assignment does not count as a reference for the
4141 purpose of this pragma. Thus it is fine to assign to an entity for which
4142 pragma Unreferenced is given.
4144 Note that if a warning is desired for all calls to a given subprogram,
4145 regardless of whether they occur in the same unit as the subprogram
4146 declaration, then this pragma should not be used (calls from another
4147 unit would not be flagged); pragma Obsolescent can be used instead
4148 for this purpose, see @xref{Pragma Obsolescent}.
4150 The second form of pragma @code{Unreferenced} is used within a context
4151 clause. In this case the arguments must be unit names of units previously
4152 mentioned in @code{with} clauses (similar to the usage of pragma
4153 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4156 @node Pragma Unreferenced_Objects
4157 @unnumberedsec Pragma Unreferenced_Objects
4158 @findex Unreferenced_Objects
4159 @cindex Warnings, unreferenced
4163 @smallexample @c ada
4164 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4168 This pragma signals that for the types or subtypes whose names are
4169 listed, objects which are declared with one of these types or subtypes may
4170 not be referenced, and if no references appear, no warnings are given.
4172 This is particularly useful for objects which are declared solely for their
4173 initialization and finalization effect. Such variables are sometimes referred
4174 to as RAII variables (Resource Acquisition Is Initialization). Using this
4175 pragma on the relevant type (most typically a limited controlled type), the
4176 compiler will automatically suppress unwanted warnings about these variables
4177 not being referenced.
4179 @node Pragma Unreserve_All_Interrupts
4180 @unnumberedsec Pragma Unreserve_All_Interrupts
4181 @findex Unreserve_All_Interrupts
4185 @smallexample @c ada
4186 pragma Unreserve_All_Interrupts;
4190 Normally certain interrupts are reserved to the implementation. Any attempt
4191 to attach an interrupt causes Program_Error to be raised, as described in
4192 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4193 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
4194 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4195 interrupt execution.
4197 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4198 a program, then all such interrupts are unreserved. This allows the
4199 program to handle these interrupts, but disables their standard
4200 functions. For example, if this pragma is used, then pressing
4201 @kbd{Ctrl-C} will not automatically interrupt execution. However,
4202 a program can then handle the @code{SIGINT} interrupt as it chooses.
4204 For a full list of the interrupts handled in a specific implementation,
4205 see the source code for the specification of @code{Ada.Interrupts.Names} in
4206 file @file{a-intnam.ads}. This is a target dependent file that contains the
4207 list of interrupts recognized for a given target. The documentation in
4208 this file also specifies what interrupts are affected by the use of
4209 the @code{Unreserve_All_Interrupts} pragma.
4211 For a more general facility for controlling what interrupts can be
4212 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4213 of the @code{Unreserve_All_Interrupts} pragma.
4215 @node Pragma Unsuppress
4216 @unnumberedsec Pragma Unsuppress
4221 @smallexample @c ada
4222 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4226 This pragma undoes the effect of a previous pragma @code{Suppress}. If
4227 there is no corresponding pragma @code{Suppress} in effect, it has no
4228 effect. The range of the effect is the same as for pragma
4229 @code{Suppress}. The meaning of the arguments is identical to that used
4230 in pragma @code{Suppress}.
4232 One important application is to ensure that checks are on in cases where
4233 code depends on the checks for its correct functioning, so that the code
4234 will compile correctly even if the compiler switches are set to suppress
4237 @node Pragma Use_VADS_Size
4238 @unnumberedsec Pragma Use_VADS_Size
4239 @cindex @code{Size}, VADS compatibility
4240 @findex Use_VADS_Size
4244 @smallexample @c ada
4245 pragma Use_VADS_Size;
4249 This is a configuration pragma. In a unit to which it applies, any use
4250 of the 'Size attribute is automatically interpreted as a use of the
4251 'VADS_Size attribute. Note that this may result in incorrect semantic
4252 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
4253 the handling of existing code which depends on the interpretation of Size
4254 as implemented in the VADS compiler. See description of the VADS_Size
4255 attribute for further details.
4257 @node Pragma Validity_Checks
4258 @unnumberedsec Pragma Validity_Checks
4259 @findex Validity_Checks
4263 @smallexample @c ada
4264 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4268 This pragma is used in conjunction with compiler switches to control the
4269 built-in validity checking provided by GNAT@. The compiler switches, if set
4270 provide an initial setting for the switches, and this pragma may be used
4271 to modify these settings, or the settings may be provided entirely by
4272 the use of the pragma. This pragma can be used anywhere that a pragma
4273 is legal, including use as a configuration pragma (including use in
4274 the @file{gnat.adc} file).
4276 The form with a string literal specifies which validity options are to be
4277 activated. The validity checks are first set to include only the default
4278 reference manual settings, and then a string of letters in the string
4279 specifies the exact set of options required. The form of this string
4280 is exactly as described for the @code{-gnatVx} compiler switch (see the
4281 GNAT users guide for details). For example the following two methods
4282 can be used to enable validity checking for mode @code{in} and
4283 @code{in out} subprogram parameters:
4287 @smallexample @c ada
4288 pragma Validity_Checks ("im");
4293 gcc -c -gnatVim @dots{}
4298 The form ALL_CHECKS activates all standard checks (its use is equivalent
4299 to the use of the @code{gnatva} switch.
4301 The forms with @code{Off} and @code{On}
4302 can be used to temporarily disable validity checks
4303 as shown in the following example:
4305 @smallexample @c ada
4309 pragma Validity_Checks ("c"); -- validity checks for copies
4310 pragma Validity_Checks (Off); -- turn off validity checks
4311 A := B; -- B will not be validity checked
4312 pragma Validity_Checks (On); -- turn validity checks back on
4313 A := C; -- C will be validity checked
4316 @node Pragma Volatile
4317 @unnumberedsec Pragma Volatile
4322 @smallexample @c ada
4323 pragma Volatile (local_NAME);
4327 This pragma is defined by the Ada Reference Manual, and the GNAT
4328 implementation is fully conformant with this definition. The reason it
4329 is mentioned in this section is that a pragma of the same name was supplied
4330 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
4331 implementation of pragma Volatile is upwards compatible with the
4332 implementation in DEC Ada 83.
4334 @node Pragma Warnings
4335 @unnumberedsec Pragma Warnings
4340 @smallexample @c ada
4341 pragma Warnings (On | Off);
4342 pragma Warnings (On | Off, local_NAME);
4343 pragma Warnings (static_string_EXPRESSION);
4344 pragma Warnings (On | Off, static_string_EXPRESSION);
4348 Normally warnings are enabled, with the output being controlled by
4349 the command line switch. Warnings (@code{Off}) turns off generation of
4350 warnings until a Warnings (@code{On}) is encountered or the end of the
4351 current unit. If generation of warnings is turned off using this
4352 pragma, then no warning messages are output, regardless of the
4353 setting of the command line switches.
4355 The form with a single argument may be used as a configuration pragma.
4357 If the @var{local_NAME} parameter is present, warnings are suppressed for
4358 the specified entity. This suppression is effective from the point where
4359 it occurs till the end of the extended scope of the variable (similar to
4360 the scope of @code{Suppress}).
4362 The form with a single static_string_EXPRESSION argument provides more precise
4363 control over which warnings are active. The string is a list of letters
4364 specifying which warnings are to be activated and which deactivated. The
4365 code for these letters is the same as the string used in the command
4366 line switch controlling warnings. The following is a brief summary. For
4367 full details see the GNAT Users Guide:
4370 a turn on all optional warnings (except d,h,l)
4371 A turn off all optional warnings
4372 b turn on warnings for bad fixed value (not multiple of small)
4373 B turn off warnings for bad fixed value (not multiple of small)
4374 c turn on warnings for constant conditional
4375 C turn off warnings for constant conditional
4376 d turn on warnings for implicit dereference
4377 D turn off warnings for implicit dereference
4378 e treat all warnings as errors
4379 f turn on warnings for unreferenced formal
4380 F turn off warnings for unreferenced formal
4381 g turn on warnings for unrecognized pragma
4382 G turn off warnings for unrecognized pragma
4383 h turn on warnings for hiding variable
4384 H turn off warnings for hiding variable
4385 i turn on warnings for implementation unit
4386 I turn off warnings for implementation unit
4387 j turn on warnings for obsolescent (annex J) feature
4388 J turn off warnings for obsolescent (annex J) feature
4389 k turn on warnings on constant variable
4390 K turn off warnings on constant variable
4391 l turn on warnings for missing elaboration pragma
4392 L turn off warnings for missing elaboration pragma
4393 m turn on warnings for variable assigned but not read
4394 M turn off warnings for variable assigned but not read
4395 n normal warning mode (cancels -gnatws/-gnatwe)
4396 o turn on warnings for address clause overlay
4397 O turn off warnings for address clause overlay
4398 p turn on warnings for ineffective pragma Inline
4399 P turn off warnings for ineffective pragma Inline
4400 q turn on warnings for questionable missing parentheses
4401 Q turn off warnings for questionable missing parentheses
4402 r turn on warnings for redundant construct
4403 R turn off warnings for redundant construct
4404 s suppress all warnings
4405 t turn on warnings for tracking deleted code
4406 T turn off warnings for tracking deleted code
4407 u turn on warnings for unused entity
4408 U turn off warnings for unused entity
4409 v turn on warnings for unassigned variable
4410 V turn off warnings for unassigned variable
4411 w turn on warnings for wrong low bound assumption
4412 W turn off warnings for wrong low bound assumption
4413 x turn on warnings for export/import
4414 X turn off warnings for export/import
4415 y turn on warnings for Ada 2005 incompatibility
4416 Y turn off warnings for Ada 2005 incompatibility
4417 z turn on size/align warnings for unchecked conversion
4418 Z turn off size/align warnings for unchecked conversion
4422 The specified warnings will be in effect until the end of the program
4423 or another pragma Warnings is encountered. The effect of the pragma is
4424 cumulative. Initially the set of warnings is the standard default set
4425 as possibly modified by compiler switches. Then each pragma Warning
4426 modifies this set of warnings as specified. This form of the pragma may
4427 also be used as a configuration pragma.
4429 The fourth form, with an On|Off parameter and a string, is used to
4430 control individual messages, based on their text. The string argument
4431 is a pattern that is used to match against the text of individual
4432 warning messages (not including the initial "warnings: " tag).
4434 The pattern may start with an asterisk, which matches otherwise unmatched
4435 characters at the start of the message, and it may also end with an asterisk
4436 which matches otherwise unmatched characters at the end of the message. For
4437 example, the string "*alignment*" could be used to match any warnings about
4438 alignment problems. Within the string, the sequence "*" can be used to match
4439 any sequence of characters enclosed in quotation marks. No other regular
4440 expression notations are permitted. All characters other than asterisk in
4441 these three specific cases are treated as literal characters in the match.
4443 There are two ways to use this pragma. The OFF form can be used as a
4444 configuration pragma. The effect is to suppress all warnings (if any)
4445 that match the pattern string throughout the compilation.
4447 The second usage is to suppress a warning locally, and in this case, two
4448 pragmas must appear in sequence:
4450 @smallexample @c ada
4451 pragma Warnings (Off, Pattern);
4452 .. code where given warning is to be suppressed
4453 pragma Warnings (On, Pattern);
4457 In this usage, the pattern string must match in the Off and On pragmas,
4458 and at least one matching warning must be suppressed.
4460 @node Pragma Weak_External
4461 @unnumberedsec Pragma Weak_External
4462 @findex Weak_External
4466 @smallexample @c ada
4467 pragma Weak_External ([Entity =>] local_NAME);
4471 @var{local_NAME} must refer to an object that is declared at the library
4472 level. This pragma specifies that the given entity should be marked as a
4473 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
4474 in GNU C and causes @var{local_NAME} to be emitted as a weak symbol instead
4475 of a regular symbol, that is to say a symbol that does not have to be
4476 resolved by the linker if used in conjunction with a pragma Import.
4478 When a weak symbol is not resolved by the linker, its address is set to
4479 zero. This is useful in writing interfaces to external modules that may
4480 or may not be linked in the final executable, for example depending on
4481 configuration settings.
4483 If a program references at run time an entity to which this pragma has been
4484 applied, and the corresponding symbol was not resolved at link time, then
4485 the execution of the program is erroneous. It is not erroneous to take the
4486 Address of such an entity, for example to guard potential references,
4487 as shown in the example below.
4489 Some file formats do not support weak symbols so not all target machines
4490 support this pragma.
4492 @smallexample @c ada
4493 -- Example of the use of pragma Weak_External
4495 package External_Module is
4497 pragma Import (C, key);
4498 pragma Weak_External (key);
4499 function Present return boolean;
4500 end External_Module;
4502 with System; use System;
4503 package body External_Module is
4504 function Present return boolean is
4506 return key'Address /= System.Null_Address;
4508 end External_Module;
4511 @node Pragma Wide_Character_Encoding
4512 @unnumberedsec Pragma Wide_Character_Encoding
4513 @findex Wide_Character_Encoding
4517 @smallexample @c ada
4518 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
4522 This pragma specifies the wide character encoding to be used in program
4523 source text appearing subsequently. It is a configuration pragma, but may
4524 also be used at any point that a pragma is allowed, and it is permissible
4525 to have more than one such pragma in a file, allowing multiple encodings
4526 to appear within the same file.
4528 The argument can be an identifier or a character literal. In the identifier
4529 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
4530 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
4531 case it is correspondingly one of the characters h,u,s,e,8,b.
4533 Note that when the pragma is used within a file, it affects only the
4534 encoding within that file, and does not affect withed units, specs,
4537 @node Implementation Defined Attributes
4538 @chapter Implementation Defined Attributes
4539 Ada defines (throughout the Ada reference manual,
4540 summarized in Annex K),
4541 a set of attributes that provide useful additional functionality in all
4542 areas of the language. These language defined attributes are implemented
4543 in GNAT and work as described in the Ada Reference Manual.
4545 In addition, Ada allows implementations to define additional
4546 attributes whose meaning is defined by the implementation. GNAT provides
4547 a number of these implementation-dependent attributes which can be used
4548 to extend and enhance the functionality of the compiler. This section of
4549 the GNAT reference manual describes these additional attributes.
4551 Note that any program using these attributes may not be portable to
4552 other compilers (although GNAT implements this set of attributes on all
4553 platforms). Therefore if portability to other compilers is an important
4554 consideration, you should minimize the use of these attributes.
4565 * Default_Bit_Order::
4573 * Has_Access_Values::
4574 * Has_Discriminants::
4580 * Max_Interrupt_Priority::
4582 * Maximum_Alignment::
4586 * Passed_By_Reference::
4598 * Unconstrained_Array::
4599 * Universal_Literal_String::
4600 * Unrestricted_Access::
4608 @unnumberedsec Abort_Signal
4609 @findex Abort_Signal
4611 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4612 prefix) provides the entity for the special exception used to signal
4613 task abort or asynchronous transfer of control. Normally this attribute
4614 should only be used in the tasking runtime (it is highly peculiar, and
4615 completely outside the normal semantics of Ada, for a user program to
4616 intercept the abort exception).
4619 @unnumberedsec Address_Size
4620 @cindex Size of @code{Address}
4621 @findex Address_Size
4623 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4624 prefix) is a static constant giving the number of bits in an
4625 @code{Address}. It is the same value as System.Address'Size,
4626 but has the advantage of being static, while a direct
4627 reference to System.Address'Size is non-static because Address
4631 @unnumberedsec Asm_Input
4634 The @code{Asm_Input} attribute denotes a function that takes two
4635 parameters. The first is a string, the second is an expression of the
4636 type designated by the prefix. The first (string) argument is required
4637 to be a static expression, and is the constraint for the parameter,
4638 (e.g.@: what kind of register is required). The second argument is the
4639 value to be used as the input argument. The possible values for the
4640 constant are the same as those used in the RTL, and are dependent on
4641 the configuration file used to built the GCC back end.
4642 @ref{Machine Code Insertions}
4645 @unnumberedsec Asm_Output
4648 The @code{Asm_Output} attribute denotes a function that takes two
4649 parameters. The first is a string, the second is the name of a variable
4650 of the type designated by the attribute prefix. The first (string)
4651 argument is required to be a static expression and designates the
4652 constraint for the parameter (e.g.@: what kind of register is
4653 required). The second argument is the variable to be updated with the
4654 result. The possible values for constraint are the same as those used in
4655 the RTL, and are dependent on the configuration file used to build the
4656 GCC back end. If there are no output operands, then this argument may
4657 either be omitted, or explicitly given as @code{No_Output_Operands}.
4658 @ref{Machine Code Insertions}
4661 @unnumberedsec AST_Entry
4665 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
4666 the name of an entry, it yields a value of the predefined type AST_Handler
4667 (declared in the predefined package System, as extended by the use of
4668 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
4669 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
4670 Language Reference Manual}, section 9.12a.
4675 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4676 offset within the storage unit (byte) that contains the first bit of
4677 storage allocated for the object. The value of this attribute is of the
4678 type @code{Universal_Integer}, and is always a non-negative number not
4679 exceeding the value of @code{System.Storage_Unit}.
4681 For an object that is a variable or a constant allocated in a register,
4682 the value is zero. (The use of this attribute does not force the
4683 allocation of a variable to memory).
4685 For an object that is a formal parameter, this attribute applies
4686 to either the matching actual parameter or to a copy of the
4687 matching actual parameter.
4689 For an access object the value is zero. Note that
4690 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4691 designated object. Similarly for a record component
4692 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4693 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4694 are subject to index checks.
4696 This attribute is designed to be compatible with the DEC Ada 83 definition
4697 and implementation of the @code{Bit} attribute.
4700 @unnumberedsec Bit_Position
4701 @findex Bit_Position
4703 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4704 of the fields of the record type, yields the bit
4705 offset within the record contains the first bit of
4706 storage allocated for the object. The value of this attribute is of the
4707 type @code{Universal_Integer}. The value depends only on the field
4708 @var{C} and is independent of the alignment of
4709 the containing record @var{R}.
4712 @unnumberedsec Code_Address
4713 @findex Code_Address
4714 @cindex Subprogram address
4715 @cindex Address of subprogram code
4718 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
4719 intended effect seems to be to provide
4720 an address value which can be used to call the subprogram by means of
4721 an address clause as in the following example:
4723 @smallexample @c ada
4724 procedure K is @dots{}
4727 for L'Address use K'Address;
4728 pragma Import (Ada, L);
4732 A call to @code{L} is then expected to result in a call to @code{K}@.
4733 In Ada 83, where there were no access-to-subprogram values, this was
4734 a common work-around for getting the effect of an indirect call.
4735 GNAT implements the above use of @code{Address} and the technique
4736 illustrated by the example code works correctly.
4738 However, for some purposes, it is useful to have the address of the start
4739 of the generated code for the subprogram. On some architectures, this is
4740 not necessarily the same as the @code{Address} value described above.
4741 For example, the @code{Address} value may reference a subprogram
4742 descriptor rather than the subprogram itself.
4744 The @code{'Code_Address} attribute, which can only be applied to
4745 subprogram entities, always returns the address of the start of the
4746 generated code of the specified subprogram, which may or may not be
4747 the same value as is returned by the corresponding @code{'Address}
4750 @node Default_Bit_Order
4751 @unnumberedsec Default_Bit_Order
4753 @cindex Little endian
4754 @findex Default_Bit_Order
4756 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4757 permissible prefix), provides the value @code{System.Default_Bit_Order}
4758 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4759 @code{Low_Order_First}). This is used to construct the definition of
4760 @code{Default_Bit_Order} in package @code{System}.
4763 @unnumberedsec Elaborated
4766 The prefix of the @code{'Elaborated} attribute must be a unit name. The
4767 value is a Boolean which indicates whether or not the given unit has been
4768 elaborated. This attribute is primarily intended for internal use by the
4769 generated code for dynamic elaboration checking, but it can also be used
4770 in user programs. The value will always be True once elaboration of all
4771 units has been completed. An exception is for units which need no
4772 elaboration, the value is always False for such units.
4775 @unnumberedsec Elab_Body
4778 This attribute can only be applied to a program unit name. It returns
4779 the entity for the corresponding elaboration procedure for elaborating
4780 the body of the referenced unit. This is used in the main generated
4781 elaboration procedure by the binder and is not normally used in any
4782 other context. However, there may be specialized situations in which it
4783 is useful to be able to call this elaboration procedure from Ada code,
4784 e.g.@: if it is necessary to do selective re-elaboration to fix some
4788 @unnumberedsec Elab_Spec
4791 This attribute can only be applied to a program unit name. It returns
4792 the entity for the corresponding elaboration procedure for elaborating
4793 the specification of the referenced unit. This is used in the main
4794 generated elaboration procedure by the binder and is not normally used
4795 in any other context. However, there may be specialized situations in
4796 which it is useful to be able to call this elaboration procedure from
4797 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4802 @cindex Ada 83 attributes
4805 The @code{Emax} attribute is provided for compatibility with Ada 83. See
4806 the Ada 83 reference manual for an exact description of the semantics of
4810 @unnumberedsec Enum_Rep
4811 @cindex Representation of enums
4814 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4815 function with the following spec:
4817 @smallexample @c ada
4818 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4819 return @i{Universal_Integer};
4823 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4824 enumeration type or to a non-overloaded enumeration
4825 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
4826 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4827 enumeration literal or object.
4829 The function returns the representation value for the given enumeration
4830 value. This will be equal to value of the @code{Pos} attribute in the
4831 absence of an enumeration representation clause. This is a static
4832 attribute (i.e.@: the result is static if the argument is static).
4834 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4835 in which case it simply returns the integer value. The reason for this
4836 is to allow it to be used for @code{(<>)} discrete formal arguments in
4837 a generic unit that can be instantiated with either enumeration types
4838 or integer types. Note that if @code{Enum_Rep} is used on a modular
4839 type whose upper bound exceeds the upper bound of the largest signed
4840 integer type, and the argument is a variable, so that the universal
4841 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4842 may raise @code{Constraint_Error}.
4845 @unnumberedsec Epsilon
4846 @cindex Ada 83 attributes
4849 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
4850 the Ada 83 reference manual for an exact description of the semantics of
4854 @unnumberedsec Fixed_Value
4857 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4858 function with the following specification:
4860 @smallexample @c ada
4861 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4866 The value returned is the fixed-point value @var{V} such that
4868 @smallexample @c ada
4869 @var{V} = Arg * @var{S}'Small
4873 The effect is thus similar to first converting the argument to the
4874 integer type used to represent @var{S}, and then doing an unchecked
4875 conversion to the fixed-point type. The difference is
4876 that there are full range checks, to ensure that the result is in range.
4877 This attribute is primarily intended for use in implementation of the
4878 input-output functions for fixed-point values.
4880 @node Has_Access_Values
4881 @unnumberedsec Has_Access_Values
4882 @cindex Access values, testing for
4883 @findex Has_Access_Values
4885 The prefix of the @code{Has_Access_Values} attribute is a type. The result
4886 is a Boolean value which is True if the is an access type, or is a composite
4887 type with a component (at any nesting depth) that is an access type, and is
4889 The intended use of this attribute is in conjunction with generic
4890 definitions. If the attribute is applied to a generic private type, it
4891 indicates whether or not the corresponding actual type has access values.
4893 @node Has_Discriminants
4894 @unnumberedsec Has_Discriminants
4895 @cindex Discriminants, testing for
4896 @findex Has_Discriminants
4898 The prefix of the @code{Has_Discriminants} attribute is a type. The result
4899 is a Boolean value which is True if the type has discriminants, and False
4900 otherwise. The intended use of this attribute is in conjunction with generic
4901 definitions. If the attribute is applied to a generic private type, it
4902 indicates whether or not the corresponding actual type has discriminants.
4908 The @code{Img} attribute differs from @code{Image} in that it may be
4909 applied to objects as well as types, in which case it gives the
4910 @code{Image} for the subtype of the object. This is convenient for
4913 @smallexample @c ada
4914 Put_Line ("X = " & X'Img);
4918 has the same meaning as the more verbose:
4920 @smallexample @c ada
4921 Put_Line ("X = " & @var{T}'Image (X));
4925 where @var{T} is the (sub)type of the object @code{X}.
4928 @unnumberedsec Integer_Value
4929 @findex Integer_Value
4931 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4932 function with the following spec:
4934 @smallexample @c ada
4935 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4940 The value returned is the integer value @var{V}, such that
4942 @smallexample @c ada
4943 Arg = @var{V} * @var{T}'Small
4947 where @var{T} is the type of @code{Arg}.
4948 The effect is thus similar to first doing an unchecked conversion from
4949 the fixed-point type to its corresponding implementation type, and then
4950 converting the result to the target integer type. The difference is
4951 that there are full range checks, to ensure that the result is in range.
4952 This attribute is primarily intended for use in implementation of the
4953 standard input-output functions for fixed-point values.
4956 @unnumberedsec Large
4957 @cindex Ada 83 attributes
4960 The @code{Large} attribute is provided for compatibility with Ada 83. See
4961 the Ada 83 reference manual for an exact description of the semantics of
4965 @unnumberedsec Machine_Size
4966 @findex Machine_Size
4968 This attribute is identical to the @code{Object_Size} attribute. It is
4969 provided for compatibility with the DEC Ada 83 attribute of this name.
4972 @unnumberedsec Mantissa
4973 @cindex Ada 83 attributes
4976 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
4977 the Ada 83 reference manual for an exact description of the semantics of
4980 @node Max_Interrupt_Priority
4981 @unnumberedsec Max_Interrupt_Priority
4982 @cindex Interrupt priority, maximum
4983 @findex Max_Interrupt_Priority
4985 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4986 permissible prefix), provides the same value as
4987 @code{System.Max_Interrupt_Priority}.
4990 @unnumberedsec Max_Priority
4991 @cindex Priority, maximum
4992 @findex Max_Priority
4994 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4995 prefix) provides the same value as @code{System.Max_Priority}.
4997 @node Maximum_Alignment
4998 @unnumberedsec Maximum_Alignment
4999 @cindex Alignment, maximum
5000 @findex Maximum_Alignment
5002 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5003 permissible prefix) provides the maximum useful alignment value for the
5004 target. This is a static value that can be used to specify the alignment
5005 for an object, guaranteeing that it is properly aligned in all
5008 @node Mechanism_Code
5009 @unnumberedsec Mechanism_Code
5010 @cindex Return values, passing mechanism
5011 @cindex Parameters, passing mechanism
5012 @findex Mechanism_Code
5014 @code{@var{function}'Mechanism_Code} yields an integer code for the
5015 mechanism used for the result of function, and
5016 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5017 used for formal parameter number @var{n} (a static integer value with 1
5018 meaning the first parameter) of @var{subprogram}. The code returned is:
5026 by descriptor (default descriptor class)
5028 by descriptor (UBS: unaligned bit string)
5030 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5032 by descriptor (UBA: unaligned bit array)
5034 by descriptor (S: string, also scalar access type parameter)
5036 by descriptor (SB: string with arbitrary bounds)
5038 by descriptor (A: contiguous array)
5040 by descriptor (NCA: non-contiguous array)
5044 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5047 @node Null_Parameter
5048 @unnumberedsec Null_Parameter
5049 @cindex Zero address, passing
5050 @findex Null_Parameter
5052 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5053 type or subtype @var{T} allocated at machine address zero. The attribute
5054 is allowed only as the default expression of a formal parameter, or as
5055 an actual expression of a subprogram call. In either case, the
5056 subprogram must be imported.
5058 The identity of the object is represented by the address zero in the
5059 argument list, independent of the passing mechanism (explicit or
5062 This capability is needed to specify that a zero address should be
5063 passed for a record or other composite object passed by reference.
5064 There is no way of indicating this without the @code{Null_Parameter}
5068 @unnumberedsec Object_Size
5069 @cindex Size, used for objects
5072 The size of an object is not necessarily the same as the size of the type
5073 of an object. This is because by default object sizes are increased to be
5074 a multiple of the alignment of the object. For example,
5075 @code{Natural'Size} is
5076 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5077 Similarly, a record containing an integer and a character:
5079 @smallexample @c ada
5087 will have a size of 40 (that is @code{Rec'Size} will be 40. The
5088 alignment will be 4, because of the
5089 integer field, and so the default size of record objects for this type
5090 will be 64 (8 bytes).
5092 The @code{@var{type}'Object_Size} attribute
5093 has been added to GNAT to allow the
5094 default object size of a type to be easily determined. For example,
5095 @code{Natural'Object_Size} is 32, and
5096 @code{Rec'Object_Size} (for the record type in the above example) will be
5097 64. Note also that, unlike the situation with the
5098 @code{Size} attribute as defined in the Ada RM, the
5099 @code{Object_Size} attribute can be specified individually
5100 for different subtypes. For example:
5102 @smallexample @c ada
5103 type R is new Integer;
5104 subtype R1 is R range 1 .. 10;
5105 subtype R2 is R range 1 .. 10;
5106 for R2'Object_Size use 8;
5110 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
5111 32 since the default object size for a subtype is the same as the object size
5112 for the parent subtype. This means that objects of type @code{R}
5114 by default be 32 bits (four bytes). But objects of type
5115 @code{R2} will be only
5116 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
5118 Although @code{Object_Size} does properly reflect the default object size
5119 value, it is not necessarily the case that all objects will be of this size
5120 in a case where it is not specified explicitly. The compiler is free to
5121 increase the size and alignment of stand alone objects to improve efficiency
5122 of the generated code and sometimes does so in the case of large composite
5123 objects. If the size of a stand alone object is critical to the
5124 application, it should be specified explicitly.
5126 @node Passed_By_Reference
5127 @unnumberedsec Passed_By_Reference
5128 @cindex Parameters, when passed by reference
5129 @findex Passed_By_Reference
5131 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5132 a value of type @code{Boolean} value that is @code{True} if the type is
5133 normally passed by reference and @code{False} if the type is normally
5134 passed by copy in calls. For scalar types, the result is always @code{False}
5135 and is static. For non-scalar types, the result is non-static.
5138 @unnumberedsec Range_Length
5139 @findex Range_Length
5141 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5142 the number of values represented by the subtype (zero for a null
5143 range). The result is static for static subtypes. @code{Range_Length}
5144 applied to the index subtype of a one dimensional array always gives the
5145 same result as @code{Range} applied to the array itself.
5148 @unnumberedsec Safe_Emax
5149 @cindex Ada 83 attributes
5152 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
5153 the Ada 83 reference manual for an exact description of the semantics of
5157 @unnumberedsec Safe_Large
5158 @cindex Ada 83 attributes
5161 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
5162 the Ada 83 reference manual for an exact description of the semantics of
5166 @unnumberedsec Small
5167 @cindex Ada 83 attributes
5170 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5172 GNAT also allows this attribute to be applied to floating-point types
5173 for compatibility with Ada 83. See
5174 the Ada 83 reference manual for an exact description of the semantics of
5175 this attribute when applied to floating-point types.
5178 @unnumberedsec Storage_Unit
5179 @findex Storage_Unit
5181 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5182 prefix) provides the same value as @code{System.Storage_Unit}.
5185 @unnumberedsec Stub_Type
5188 The GNAT implementation of remote access-to-classwide types is
5189 organized as described in AARM section E.4 (20.t): a value of an RACW type
5190 (designating a remote object) is represented as a normal access
5191 value, pointing to a "stub" object which in turn contains the
5192 necessary information to contact the designated remote object. A
5193 call on any dispatching operation of such a stub object does the
5194 remote call, if necessary, using the information in the stub object
5195 to locate the target partition, etc.
5197 For a prefix @code{T} that denotes a remote access-to-classwide type,
5198 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5200 By construction, the layout of @code{T'Stub_Type} is identical to that of
5201 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5202 unit @code{System.Partition_Interface}. Use of this attribute will create
5203 an implicit dependency on this unit.
5206 @unnumberedsec Target_Name
5209 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5210 prefix) provides a static string value that identifies the target
5211 for the current compilation. For GCC implementations, this is the
5212 standard gcc target name without the terminating slash (for
5213 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5219 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5220 provides the same value as @code{System.Tick},
5223 @unnumberedsec To_Address
5226 The @code{System'To_Address}
5227 (@code{System} is the only permissible prefix)
5228 denotes a function identical to
5229 @code{System.Storage_Elements.To_Address} except that
5230 it is a static attribute. This means that if its argument is
5231 a static expression, then the result of the attribute is a
5232 static expression. The result is that such an expression can be
5233 used in contexts (e.g.@: preelaborable packages) which require a
5234 static expression and where the function call could not be used
5235 (since the function call is always non-static, even if its
5236 argument is static).
5239 @unnumberedsec Type_Class
5242 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5243 the value of the type class for the full type of @var{type}. If
5244 @var{type} is a generic formal type, the value is the value for the
5245 corresponding actual subtype. The value of this attribute is of type
5246 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5248 @smallexample @c ada
5250 (Type_Class_Enumeration,
5252 Type_Class_Fixed_Point,
5253 Type_Class_Floating_Point,
5258 Type_Class_Address);
5262 Protected types yield the value @code{Type_Class_Task}, which thus
5263 applies to all concurrent types. This attribute is designed to
5264 be compatible with the DEC Ada 83 attribute of the same name.
5267 @unnumberedsec UET_Address
5270 The @code{UET_Address} attribute can only be used for a prefix which
5271 denotes a library package. It yields the address of the unit exception
5272 table when zero cost exception handling is used. This attribute is
5273 intended only for use within the GNAT implementation. See the unit
5274 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5275 for details on how this attribute is used in the implementation.
5277 @node Unconstrained_Array
5278 @unnumberedsec Unconstrained_Array
5279 @findex Unconstrained_Array
5281 The @code{Unconstrained_Array} attribute can be used with a prefix that
5282 denotes any type or subtype. It is a static attribute that yields
5283 @code{True} if the prefix designates an unconstrained array,
5284 and @code{False} otherwise. In a generic instance, the result is
5285 still static, and yields the result of applying this test to the
5288 @node Universal_Literal_String
5289 @unnumberedsec Universal_Literal_String
5290 @cindex Named numbers, representation of
5291 @findex Universal_Literal_String
5293 The prefix of @code{Universal_Literal_String} must be a named
5294 number. The static result is the string consisting of the characters of
5295 the number as defined in the original source. This allows the user
5296 program to access the actual text of named numbers without intermediate
5297 conversions and without the need to enclose the strings in quotes (which
5298 would preclude their use as numbers). This is used internally for the
5299 construction of values of the floating-point attributes from the file
5300 @file{ttypef.ads}, but may also be used by user programs.
5302 For example, the following program prints the first 50 digits of pi:
5304 @smallexample @c ada
5305 with Text_IO; use Text_IO;
5309 Put (Ada.Numerics.Pi'Universal_Literal_String);
5313 @node Unrestricted_Access
5314 @unnumberedsec Unrestricted_Access
5315 @cindex @code{Access}, unrestricted
5316 @findex Unrestricted_Access
5318 The @code{Unrestricted_Access} attribute is similar to @code{Access}
5319 except that all accessibility and aliased view checks are omitted. This
5320 is a user-beware attribute. It is similar to
5321 @code{Address}, for which it is a desirable replacement where the value
5322 desired is an access type. In other words, its effect is identical to
5323 first applying the @code{Address} attribute and then doing an unchecked
5324 conversion to a desired access type. In GNAT, but not necessarily in
5325 other implementations, the use of static chains for inner level
5326 subprograms means that @code{Unrestricted_Access} applied to a
5327 subprogram yields a value that can be called as long as the subprogram
5328 is in scope (normal Ada accessibility rules restrict this usage).
5330 It is possible to use @code{Unrestricted_Access} for any type, but care
5331 must be exercised if it is used to create pointers to unconstrained
5332 objects. In this case, the resulting pointer has the same scope as the
5333 context of the attribute, and may not be returned to some enclosing
5334 scope. For instance, a function cannot use @code{Unrestricted_Access}
5335 to create a unconstrained pointer and then return that value to the
5339 @unnumberedsec VADS_Size
5340 @cindex @code{Size}, VADS compatibility
5343 The @code{'VADS_Size} attribute is intended to make it easier to port
5344 legacy code which relies on the semantics of @code{'Size} as implemented
5345 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
5346 same semantic interpretation. In particular, @code{'VADS_Size} applied
5347 to a predefined or other primitive type with no Size clause yields the
5348 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
5349 typical machines). In addition @code{'VADS_Size} applied to an object
5350 gives the result that would be obtained by applying the attribute to
5351 the corresponding type.
5354 @unnumberedsec Value_Size
5355 @cindex @code{Size}, setting for not-first subtype
5357 @code{@var{type}'Value_Size} is the number of bits required to represent
5358 a value of the given subtype. It is the same as @code{@var{type}'Size},
5359 but, unlike @code{Size}, may be set for non-first subtypes.
5362 @unnumberedsec Wchar_T_Size
5363 @findex Wchar_T_Size
5364 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
5365 prefix) provides the size in bits of the C @code{wchar_t} type
5366 primarily for constructing the definition of this type in
5367 package @code{Interfaces.C}.
5370 @unnumberedsec Word_Size
5372 @code{Standard'Word_Size} (@code{Standard} is the only permissible
5373 prefix) provides the value @code{System.Word_Size}.
5375 @c ------------------------
5376 @node Implementation Advice
5377 @chapter Implementation Advice
5379 The main text of the Ada Reference Manual describes the required
5380 behavior of all Ada compilers, and the GNAT compiler conforms to
5383 In addition, there are sections throughout the Ada Reference Manual headed
5384 by the phrase ``Implementation advice''. These sections are not normative,
5385 i.e., they do not specify requirements that all compilers must
5386 follow. Rather they provide advice on generally desirable behavior. You
5387 may wonder why they are not requirements. The most typical answer is
5388 that they describe behavior that seems generally desirable, but cannot
5389 be provided on all systems, or which may be undesirable on some systems.
5391 As far as practical, GNAT follows the implementation advice sections in
5392 the Ada Reference Manual. This chapter contains a table giving the
5393 reference manual section number, paragraph number and several keywords
5394 for each advice. Each entry consists of the text of the advice followed
5395 by the GNAT interpretation of this advice. Most often, this simply says
5396 ``followed'', which means that GNAT follows the advice. However, in a
5397 number of cases, GNAT deliberately deviates from this advice, in which
5398 case the text describes what GNAT does and why.
5400 @cindex Error detection
5401 @unnumberedsec 1.1.3(20): Error Detection
5404 If an implementation detects the use of an unsupported Specialized Needs
5405 Annex feature at run time, it should raise @code{Program_Error} if
5408 Not relevant. All specialized needs annex features are either supported,
5409 or diagnosed at compile time.
5412 @unnumberedsec 1.1.3(31): Child Units
5415 If an implementation wishes to provide implementation-defined
5416 extensions to the functionality of a language-defined library unit, it
5417 should normally do so by adding children to the library unit.
5421 @cindex Bounded errors
5422 @unnumberedsec 1.1.5(12): Bounded Errors
5425 If an implementation detects a bounded error or erroneous
5426 execution, it should raise @code{Program_Error}.
5428 Followed in all cases in which the implementation detects a bounded
5429 error or erroneous execution. Not all such situations are detected at
5433 @unnumberedsec 2.8(16): Pragmas
5436 Normally, implementation-defined pragmas should have no semantic effect
5437 for error-free programs; that is, if the implementation-defined pragmas
5438 are removed from a working program, the program should still be legal,
5439 and should still have the same semantics.
5441 The following implementation defined pragmas are exceptions to this
5453 @item CPP_Constructor
5457 @item Interface_Name
5459 @item Machine_Attribute
5461 @item Unimplemented_Unit
5463 @item Unchecked_Union
5468 In each of the above cases, it is essential to the purpose of the pragma
5469 that this advice not be followed. For details see the separate section
5470 on implementation defined pragmas.
5472 @unnumberedsec 2.8(17-19): Pragmas
5475 Normally, an implementation should not define pragmas that can
5476 make an illegal program legal, except as follows:
5480 A pragma used to complete a declaration, such as a pragma @code{Import};
5484 A pragma used to configure the environment by adding, removing, or
5485 replacing @code{library_items}.
5487 See response to paragraph 16 of this same section.
5489 @cindex Character Sets
5490 @cindex Alternative Character Sets
5491 @unnumberedsec 3.5.2(5): Alternative Character Sets
5494 If an implementation supports a mode with alternative interpretations
5495 for @code{Character} and @code{Wide_Character}, the set of graphic
5496 characters of @code{Character} should nevertheless remain a proper
5497 subset of the set of graphic characters of @code{Wide_Character}. Any
5498 character set ``localizations'' should be reflected in the results of
5499 the subprograms defined in the language-defined package
5500 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
5501 an alternative interpretation of @code{Character}, the implementation should
5502 also support a corresponding change in what is a legal
5503 @code{identifier_letter}.
5505 Not all wide character modes follow this advice, in particular the JIS
5506 and IEC modes reflect standard usage in Japan, and in these encoding,
5507 the upper half of the Latin-1 set is not part of the wide-character
5508 subset, since the most significant bit is used for wide character
5509 encoding. However, this only applies to the external forms. Internally
5510 there is no such restriction.
5512 @cindex Integer types
5513 @unnumberedsec 3.5.4(28): Integer Types
5517 An implementation should support @code{Long_Integer} in addition to
5518 @code{Integer} if the target machine supports 32-bit (or longer)
5519 arithmetic. No other named integer subtypes are recommended for package
5520 @code{Standard}. Instead, appropriate named integer subtypes should be
5521 provided in the library package @code{Interfaces} (see B.2).
5523 @code{Long_Integer} is supported. Other standard integer types are supported
5524 so this advice is not fully followed. These types
5525 are supported for convenient interface to C, and so that all hardware
5526 types of the machine are easily available.
5527 @unnumberedsec 3.5.4(29): Integer Types
5531 An implementation for a two's complement machine should support
5532 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
5533 implementation should support a non-binary modules up to @code{Integer'Last}.
5537 @cindex Enumeration values
5538 @unnumberedsec 3.5.5(8): Enumeration Values
5541 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5542 subtype, if the value of the operand does not correspond to the internal
5543 code for any enumeration literal of its type (perhaps due to an
5544 un-initialized variable), then the implementation should raise
5545 @code{Program_Error}. This is particularly important for enumeration
5546 types with noncontiguous internal codes specified by an
5547 enumeration_representation_clause.
5552 @unnumberedsec 3.5.7(17): Float Types
5555 An implementation should support @code{Long_Float} in addition to
5556 @code{Float} if the target machine supports 11 or more digits of
5557 precision. No other named floating point subtypes are recommended for
5558 package @code{Standard}. Instead, appropriate named floating point subtypes
5559 should be provided in the library package @code{Interfaces} (see B.2).
5561 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
5562 former provides improved compatibility with other implementations
5563 supporting this type. The latter corresponds to the highest precision
5564 floating-point type supported by the hardware. On most machines, this
5565 will be the same as @code{Long_Float}, but on some machines, it will
5566 correspond to the IEEE extended form. The notable case is all ia32
5567 (x86) implementations, where @code{Long_Long_Float} corresponds to
5568 the 80-bit extended precision format supported in hardware on this
5569 processor. Note that the 128-bit format on SPARC is not supported,
5570 since this is a software rather than a hardware format.
5572 @cindex Multidimensional arrays
5573 @cindex Arrays, multidimensional
5574 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5577 An implementation should normally represent multidimensional arrays in
5578 row-major order, consistent with the notation used for multidimensional
5579 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
5580 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5581 column-major order should be used instead (see B.5, ``Interfacing with
5586 @findex Duration'Small
5587 @unnumberedsec 9.6(30-31): Duration'Small
5590 Whenever possible in an implementation, the value of @code{Duration'Small}
5591 should be no greater than 100 microseconds.
5593 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
5597 The time base for @code{delay_relative_statements} should be monotonic;
5598 it need not be the same time base as used for @code{Calendar.Clock}.
5602 @unnumberedsec 10.2.1(12): Consistent Representation
5605 In an implementation, a type declared in a pre-elaborated package should
5606 have the same representation in every elaboration of a given version of
5607 the package, whether the elaborations occur in distinct executions of
5608 the same program, or in executions of distinct programs or partitions
5609 that include the given version.
5611 Followed, except in the case of tagged types. Tagged types involve
5612 implicit pointers to a local copy of a dispatch table, and these pointers
5613 have representations which thus depend on a particular elaboration of the
5614 package. It is not easy to see how it would be possible to follow this
5615 advice without severely impacting efficiency of execution.
5617 @cindex Exception information
5618 @unnumberedsec 11.4.1(19): Exception Information
5621 @code{Exception_Message} by default and @code{Exception_Information}
5622 should produce information useful for
5623 debugging. @code{Exception_Message} should be short, about one
5624 line. @code{Exception_Information} can be long. @code{Exception_Message}
5625 should not include the
5626 @code{Exception_Name}. @code{Exception_Information} should include both
5627 the @code{Exception_Name} and the @code{Exception_Message}.
5629 Followed. For each exception that doesn't have a specified
5630 @code{Exception_Message}, the compiler generates one containing the location
5631 of the raise statement. This location has the form ``file:line'', where
5632 file is the short file name (without path information) and line is the line
5633 number in the file. Note that in the case of the Zero Cost Exception
5634 mechanism, these messages become redundant with the Exception_Information that
5635 contains a full backtrace of the calling sequence, so they are disabled.
5636 To disable explicitly the generation of the source location message, use the
5637 Pragma @code{Discard_Names}.
5639 @cindex Suppression of checks
5640 @cindex Checks, suppression of
5641 @unnumberedsec 11.5(28): Suppression of Checks
5644 The implementation should minimize the code executed for checks that
5645 have been suppressed.
5649 @cindex Representation clauses
5650 @unnumberedsec 13.1 (21-24): Representation Clauses
5653 The recommended level of support for all representation items is
5654 qualified as follows:
5658 An implementation need not support representation items containing
5659 non-static expressions, except that an implementation should support a
5660 representation item for a given entity if each non-static expression in
5661 the representation item is a name that statically denotes a constant
5662 declared before the entity.
5664 Followed. In fact, GNAT goes beyond the recommended level of support
5665 by allowing nonstatic expressions in some representation clauses even
5666 without the need to declare constants initialized with the values of
5670 @smallexample @c ada
5673 for Y'Address use X'Address;>>
5679 An implementation need not support a specification for the @code{Size}
5680 for a given composite subtype, nor the size or storage place for an
5681 object (including a component) of a given composite subtype, unless the
5682 constraints on the subtype and its composite subcomponents (if any) are
5683 all static constraints.
5685 Followed. Size Clauses are not permitted on non-static components, as
5690 An aliased component, or a component whose type is by-reference, should
5691 always be allocated at an addressable location.
5695 @cindex Packed types
5696 @unnumberedsec 13.2(6-8): Packed Types
5699 If a type is packed, then the implementation should try to minimize
5700 storage allocated to objects of the type, possibly at the expense of
5701 speed of accessing components, subject to reasonable complexity in
5702 addressing calculations.
5706 The recommended level of support pragma @code{Pack} is:
5708 For a packed record type, the components should be packed as tightly as
5709 possible subject to the Sizes of the component subtypes, and subject to
5710 any @code{record_representation_clause} that applies to the type; the
5711 implementation may, but need not, reorder components or cross aligned
5712 word boundaries to improve the packing. A component whose @code{Size} is
5713 greater than the word size may be allocated an integral number of words.
5715 Followed. Tight packing of arrays is supported for all component sizes
5716 up to 64-bits. If the array component size is 1 (that is to say, if
5717 the component is a boolean type or an enumeration type with two values)
5718 then values of the type are implicitly initialized to zero. This
5719 happens both for objects of the packed type, and for objects that have a
5720 subcomponent of the packed type.
5724 An implementation should support Address clauses for imported
5728 @cindex @code{Address} clauses
5729 @unnumberedsec 13.3(14-19): Address Clauses
5733 For an array @var{X}, @code{@var{X}'Address} should point at the first
5734 component of the array, and not at the array bounds.
5740 The recommended level of support for the @code{Address} attribute is:
5742 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5743 object that is aliased or of a by-reference type, or is an entity whose
5744 @code{Address} has been specified.
5746 Followed. A valid address will be produced even if none of those
5747 conditions have been met. If necessary, the object is forced into
5748 memory to ensure the address is valid.
5752 An implementation should support @code{Address} clauses for imported
5759 Objects (including subcomponents) that are aliased or of a by-reference
5760 type should be allocated on storage element boundaries.
5766 If the @code{Address} of an object is specified, or it is imported or exported,
5767 then the implementation should not perform optimizations based on
5768 assumptions of no aliases.
5772 @cindex @code{Alignment} clauses
5773 @unnumberedsec 13.3(29-35): Alignment Clauses
5776 The recommended level of support for the @code{Alignment} attribute for
5779 An implementation should support specified Alignments that are factors
5780 and multiples of the number of storage elements per word, subject to the
5787 An implementation need not support specified @code{Alignment}s for
5788 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5789 loaded and stored by available machine instructions.
5795 An implementation need not support specified @code{Alignment}s that are
5796 greater than the maximum @code{Alignment} the implementation ever returns by
5803 The recommended level of support for the @code{Alignment} attribute for
5806 Same as above, for subtypes, but in addition:
5812 For stand-alone library-level objects of statically constrained
5813 subtypes, the implementation should support all @code{Alignment}s
5814 supported by the target linker. For example, page alignment is likely to
5815 be supported for such objects, but not for subtypes.
5819 @cindex @code{Size} clauses
5820 @unnumberedsec 13.3(42-43): Size Clauses
5823 The recommended level of support for the @code{Size} attribute of
5826 A @code{Size} clause should be supported for an object if the specified
5827 @code{Size} is at least as large as its subtype's @code{Size}, and
5828 corresponds to a size in storage elements that is a multiple of the
5829 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5833 @unnumberedsec 13.3(50-56): Size Clauses
5836 If the @code{Size} of a subtype is specified, and allows for efficient
5837 independent addressability (see 9.10) on the target architecture, then
5838 the @code{Size} of the following objects of the subtype should equal the
5839 @code{Size} of the subtype:
5841 Aliased objects (including components).
5847 @code{Size} clause on a composite subtype should not affect the
5848 internal layout of components.
5854 The recommended level of support for the @code{Size} attribute of subtypes is:
5858 The @code{Size} (if not specified) of a static discrete or fixed point
5859 subtype should be the number of bits needed to represent each value
5860 belonging to the subtype using an unbiased representation, leaving space
5861 for a sign bit only if the subtype contains negative values. If such a
5862 subtype is a first subtype, then an implementation should support a
5863 specified @code{Size} for it that reflects this representation.
5869 For a subtype implemented with levels of indirection, the @code{Size}
5870 should include the size of the pointers, but not the size of what they
5875 @cindex @code{Component_Size} clauses
5876 @unnumberedsec 13.3(71-73): Component Size Clauses
5879 The recommended level of support for the @code{Component_Size}
5884 An implementation need not support specified @code{Component_Sizes} that are
5885 less than the @code{Size} of the component subtype.
5891 An implementation should support specified @code{Component_Size}s that
5892 are factors and multiples of the word size. For such
5893 @code{Component_Size}s, the array should contain no gaps between
5894 components. For other @code{Component_Size}s (if supported), the array
5895 should contain no gaps between components when packing is also
5896 specified; the implementation should forbid this combination in cases
5897 where it cannot support a no-gaps representation.
5901 @cindex Enumeration representation clauses
5902 @cindex Representation clauses, enumeration
5903 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5906 The recommended level of support for enumeration representation clauses
5909 An implementation need not support enumeration representation clauses
5910 for boolean types, but should at minimum support the internal codes in
5911 the range @code{System.Min_Int.System.Max_Int}.
5915 @cindex Record representation clauses
5916 @cindex Representation clauses, records
5917 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5920 The recommended level of support for
5921 @*@code{record_representation_clauses} is:
5923 An implementation should support storage places that can be extracted
5924 with a load, mask, shift sequence of machine code, and set with a load,
5925 shift, mask, store sequence, given the available machine instructions
5932 A storage place should be supported if its size is equal to the
5933 @code{Size} of the component subtype, and it starts and ends on a
5934 boundary that obeys the @code{Alignment} of the component subtype.
5940 If the default bit ordering applies to the declaration of a given type,
5941 then for a component whose subtype's @code{Size} is less than the word
5942 size, any storage place that does not cross an aligned word boundary
5943 should be supported.
5949 An implementation may reserve a storage place for the tag field of a
5950 tagged type, and disallow other components from overlapping that place.
5952 Followed. The storage place for the tag field is the beginning of the tagged
5953 record, and its size is Address'Size. GNAT will reject an explicit component
5954 clause for the tag field.
5958 An implementation need not support a @code{component_clause} for a
5959 component of an extension part if the storage place is not after the
5960 storage places of all components of the parent type, whether or not
5961 those storage places had been specified.
5963 Followed. The above advice on record representation clauses is followed,
5964 and all mentioned features are implemented.
5966 @cindex Storage place attributes
5967 @unnumberedsec 13.5.2(5): Storage Place Attributes
5970 If a component is represented using some form of pointer (such as an
5971 offset) to the actual data of the component, and this data is contiguous
5972 with the rest of the object, then the storage place attributes should
5973 reflect the place of the actual data, not the pointer. If a component is
5974 allocated discontinuously from the rest of the object, then a warning
5975 should be generated upon reference to one of its storage place
5978 Followed. There are no such components in GNAT@.
5980 @cindex Bit ordering
5981 @unnumberedsec 13.5.3(7-8): Bit Ordering
5984 The recommended level of support for the non-default bit ordering is:
5988 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5989 should support the non-default bit ordering in addition to the default
5992 Followed. Word size does not equal storage size in this implementation.
5993 Thus non-default bit ordering is not supported.
5995 @cindex @code{Address}, as private type
5996 @unnumberedsec 13.7(37): Address as Private
5999 @code{Address} should be of a private type.
6003 @cindex Operations, on @code{Address}
6004 @cindex @code{Address}, operations of
6005 @unnumberedsec 13.7.1(16): Address Operations
6008 Operations in @code{System} and its children should reflect the target
6009 environment semantics as closely as is reasonable. For example, on most
6010 machines, it makes sense for address arithmetic to ``wrap around''.
6011 Operations that do not make sense should raise @code{Program_Error}.
6013 Followed. Address arithmetic is modular arithmetic that wraps around. No
6014 operation raises @code{Program_Error}, since all operations make sense.
6016 @cindex Unchecked conversion
6017 @unnumberedsec 13.9(14-17): Unchecked Conversion
6020 The @code{Size} of an array object should not include its bounds; hence,
6021 the bounds should not be part of the converted data.
6027 The implementation should not generate unnecessary run-time checks to
6028 ensure that the representation of @var{S} is a representation of the
6029 target type. It should take advantage of the permission to return by
6030 reference when possible. Restrictions on unchecked conversions should be
6031 avoided unless required by the target environment.
6033 Followed. There are no restrictions on unchecked conversion. A warning is
6034 generated if the source and target types do not have the same size since
6035 the semantics in this case may be target dependent.
6039 The recommended level of support for unchecked conversions is:
6043 Unchecked conversions should be supported and should be reversible in
6044 the cases where this clause defines the result. To enable meaningful use
6045 of unchecked conversion, a contiguous representation should be used for
6046 elementary subtypes, for statically constrained array subtypes whose
6047 component subtype is one of the subtypes described in this paragraph,
6048 and for record subtypes without discriminants whose component subtypes
6049 are described in this paragraph.
6053 @cindex Heap usage, implicit
6054 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6057 An implementation should document any cases in which it dynamically
6058 allocates heap storage for a purpose other than the evaluation of an
6061 Followed, the only other points at which heap storage is dynamically
6062 allocated are as follows:
6066 At initial elaboration time, to allocate dynamically sized global
6070 To allocate space for a task when a task is created.
6073 To extend the secondary stack dynamically when needed. The secondary
6074 stack is used for returning variable length results.
6079 A default (implementation-provided) storage pool for an
6080 access-to-constant type should not have overhead to support deallocation of
6087 A storage pool for an anonymous access type should be created at the
6088 point of an allocator for the type, and be reclaimed when the designated
6089 object becomes inaccessible.
6093 @cindex Unchecked deallocation
6094 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6097 For a standard storage pool, @code{Free} should actually reclaim the
6102 @cindex Stream oriented attributes
6103 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6106 If a stream element is the same size as a storage element, then the
6107 normal in-memory representation should be used by @code{Read} and
6108 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
6109 should use the smallest number of stream elements needed to represent
6110 all values in the base range of the scalar type.
6113 Followed. By default, GNAT uses the interpretation suggested by AI-195,
6114 which specifies using the size of the first subtype.
6115 However, such an implementation is based on direct binary
6116 representations and is therefore target- and endianness-dependent.
6117 To address this issue, GNAT also supplies an alternate implementation
6118 of the stream attributes @code{Read} and @code{Write},
6119 which uses the target-independent XDR standard representation
6121 @cindex XDR representation
6122 @cindex @code{Read} attribute
6123 @cindex @code{Write} attribute
6124 @cindex Stream oriented attributes
6125 The XDR implementation is provided as an alternative body of the
6126 @code{System.Stream_Attributes} package, in the file
6127 @file{s-strxdr.adb} in the GNAT library.
6128 There is no @file{s-strxdr.ads} file.
6129 In order to install the XDR implementation, do the following:
6131 @item Replace the default implementation of the
6132 @code{System.Stream_Attributes} package with the XDR implementation.
6133 For example on a Unix platform issue the commands:
6135 $ mv s-stratt.adb s-strold.adb
6136 $ mv s-strxdr.adb s-stratt.adb
6140 Rebuild the GNAT run-time library as documented in the
6141 @cite{GNAT User's Guide}
6144 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6147 If an implementation provides additional named predefined integer types,
6148 then the names should end with @samp{Integer} as in
6149 @samp{Long_Integer}. If an implementation provides additional named
6150 predefined floating point types, then the names should end with
6151 @samp{Float} as in @samp{Long_Float}.
6155 @findex Ada.Characters.Handling
6156 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6159 If an implementation provides a localized definition of @code{Character}
6160 or @code{Wide_Character}, then the effects of the subprograms in
6161 @code{Characters.Handling} should reflect the localizations. See also
6164 Followed. GNAT provides no such localized definitions.
6166 @cindex Bounded-length strings
6167 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6170 Bounded string objects should not be implemented by implicit pointers
6171 and dynamic allocation.
6173 Followed. No implicit pointers or dynamic allocation are used.
6175 @cindex Random number generation
6176 @unnumberedsec A.5.2(46-47): Random Number Generation
6179 Any storage associated with an object of type @code{Generator} should be
6180 reclaimed on exit from the scope of the object.
6186 If the generator period is sufficiently long in relation to the number
6187 of distinct initiator values, then each possible value of
6188 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6189 random numbers that does not, in a practical sense, overlap the sequence
6190 initiated by any other value. If this is not possible, then the mapping
6191 between initiator values and generator states should be a rapidly
6192 varying function of the initiator value.
6194 Followed. The generator period is sufficiently long for the first
6195 condition here to hold true.
6197 @findex Get_Immediate
6198 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6201 The @code{Get_Immediate} procedures should be implemented with
6202 unbuffered input. For a device such as a keyboard, input should be
6203 @dfn{available} if a key has already been typed, whereas for a disk
6204 file, input should always be available except at end of file. For a file
6205 associated with a keyboard-like device, any line-editing features of the
6206 underlying operating system should be disabled during the execution of
6207 @code{Get_Immediate}.
6209 Followed on all targets except VxWorks. For VxWorks, there is no way to
6210 provide this functionality that does not result in the input buffer being
6211 flushed before the @code{Get_Immediate} call. A special unit
6212 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6216 @unnumberedsec B.1(39-41): Pragma @code{Export}
6219 If an implementation supports pragma @code{Export} to a given language,
6220 then it should also allow the main subprogram to be written in that
6221 language. It should support some mechanism for invoking the elaboration
6222 of the Ada library units included in the system, and for invoking the
6223 finalization of the environment task. On typical systems, the
6224 recommended mechanism is to provide two subprograms whose link names are
6225 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
6226 elaboration code for library units. @code{adafinal} should contain the
6227 finalization code. These subprograms should have no effect the second
6228 and subsequent time they are called.
6234 Automatic elaboration of pre-elaborated packages should be
6235 provided when pragma @code{Export} is supported.
6237 Followed when the main program is in Ada. If the main program is in a
6238 foreign language, then
6239 @code{adainit} must be called to elaborate pre-elaborated
6244 For each supported convention @var{L} other than @code{Intrinsic}, an
6245 implementation should support @code{Import} and @code{Export} pragmas
6246 for objects of @var{L}-compatible types and for subprograms, and pragma
6247 @code{Convention} for @var{L}-eligible types and for subprograms,
6248 presuming the other language has corresponding features. Pragma
6249 @code{Convention} need not be supported for scalar types.
6253 @cindex Package @code{Interfaces}
6255 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6258 For each implementation-defined convention identifier, there should be a
6259 child package of package Interfaces with the corresponding name. This
6260 package should contain any declarations that would be useful for
6261 interfacing to the language (implementation) represented by the
6262 convention. Any declarations useful for interfacing to any language on
6263 the given hardware architecture should be provided directly in
6266 Followed. An additional package not defined
6267 in the Ada Reference Manual is @code{Interfaces.CPP}, used
6268 for interfacing to C++.
6272 An implementation supporting an interface to C, COBOL, or Fortran should
6273 provide the corresponding package or packages described in the following
6276 Followed. GNAT provides all the packages described in this section.
6278 @cindex C, interfacing with
6279 @unnumberedsec B.3(63-71): Interfacing with C
6282 An implementation should support the following interface correspondences
6289 An Ada procedure corresponds to a void-returning C function.
6295 An Ada function corresponds to a non-void C function.
6301 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
6308 An Ada @code{in} parameter of an access-to-object type with designated
6309 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
6310 where @var{t} is the C type corresponding to the Ada type @var{T}.
6316 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
6317 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
6318 argument to a C function, where @var{t} is the C type corresponding to
6319 the Ada type @var{T}. In the case of an elementary @code{out} or
6320 @code{in out} parameter, a pointer to a temporary copy is used to
6321 preserve by-copy semantics.
6327 An Ada parameter of a record type @var{T}, of any mode, is passed as a
6328 @code{@var{t}*} argument to a C function, where @var{t} is the C
6329 structure corresponding to the Ada type @var{T}.
6331 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
6332 pragma, or Convention, or by explicitly specifying the mechanism for a given
6333 call using an extended import or export pragma.
6337 An Ada parameter of an array type with component type @var{T}, of any
6338 mode, is passed as a @code{@var{t}*} argument to a C function, where
6339 @var{t} is the C type corresponding to the Ada type @var{T}.
6345 An Ada parameter of an access-to-subprogram type is passed as a pointer
6346 to a C function whose prototype corresponds to the designated
6347 subprogram's specification.
6351 @cindex COBOL, interfacing with
6352 @unnumberedsec B.4(95-98): Interfacing with COBOL
6355 An Ada implementation should support the following interface
6356 correspondences between Ada and COBOL@.
6362 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
6363 the COBOL type corresponding to @var{T}.
6369 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
6370 the corresponding COBOL type.
6376 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
6377 COBOL type corresponding to the Ada parameter type; for scalars, a local
6378 copy is used if necessary to ensure by-copy semantics.
6382 @cindex Fortran, interfacing with
6383 @unnumberedsec B.5(22-26): Interfacing with Fortran
6386 An Ada implementation should support the following interface
6387 correspondences between Ada and Fortran:
6393 An Ada procedure corresponds to a Fortran subroutine.
6399 An Ada function corresponds to a Fortran function.
6405 An Ada parameter of an elementary, array, or record type @var{T} is
6406 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
6407 the Fortran type corresponding to the Ada type @var{T}, and where the
6408 INTENT attribute of the corresponding dummy argument matches the Ada
6409 formal parameter mode; the Fortran implementation's parameter passing
6410 conventions are used. For elementary types, a local copy is used if
6411 necessary to ensure by-copy semantics.
6417 An Ada parameter of an access-to-subprogram type is passed as a
6418 reference to a Fortran procedure whose interface corresponds to the
6419 designated subprogram's specification.
6423 @cindex Machine operations
6424 @unnumberedsec C.1(3-5): Access to Machine Operations
6427 The machine code or intrinsic support should allow access to all
6428 operations normally available to assembly language programmers for the
6429 target environment, including privileged instructions, if any.
6435 The interfacing pragmas (see Annex B) should support interface to
6436 assembler; the default assembler should be associated with the
6437 convention identifier @code{Assembler}.
6443 If an entity is exported to assembly language, then the implementation
6444 should allocate it at an addressable location, and should ensure that it
6445 is retained by the linking process, even if not otherwise referenced
6446 from the Ada code. The implementation should assume that any call to a
6447 machine code or assembler subprogram is allowed to read or update every
6448 object that is specified as exported.
6452 @unnumberedsec C.1(10-16): Access to Machine Operations
6455 The implementation should ensure that little or no overhead is
6456 associated with calling intrinsic and machine-code subprograms.
6458 Followed for both intrinsics and machine-code subprograms.
6462 It is recommended that intrinsic subprograms be provided for convenient
6463 access to any machine operations that provide special capabilities or
6464 efficiency and that are not otherwise available through the language
6467 Followed. A full set of machine operation intrinsic subprograms is provided.
6471 Atomic read-modify-write operations---e.g.@:, test and set, compare and
6472 swap, decrement and test, enqueue/dequeue.
6474 Followed on any target supporting such operations.
6478 Standard numeric functions---e.g.@:, sin, log.
6480 Followed on any target supporting such operations.
6484 String manipulation operations---e.g.@:, translate and test.
6486 Followed on any target supporting such operations.
6490 Vector operations---e.g.@:, compare vector against thresholds.
6492 Followed on any target supporting such operations.
6496 Direct operations on I/O ports.
6498 Followed on any target supporting such operations.
6500 @cindex Interrupt support
6501 @unnumberedsec C.3(28): Interrupt Support
6504 If the @code{Ceiling_Locking} policy is not in effect, the
6505 implementation should provide means for the application to specify which
6506 interrupts are to be blocked during protected actions, if the underlying
6507 system allows for a finer-grain control of interrupt blocking.
6509 Followed. The underlying system does not allow for finer-grain control
6510 of interrupt blocking.
6512 @cindex Protected procedure handlers
6513 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6516 Whenever possible, the implementation should allow interrupt handlers to
6517 be called directly by the hardware.
6521 This is never possible under IRIX, so this is followed by default.
6523 Followed on any target where the underlying operating system permits
6528 Whenever practical, violations of any
6529 implementation-defined restrictions should be detected before run time.
6531 Followed. Compile time warnings are given when possible.
6533 @cindex Package @code{Interrupts}
6535 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6539 If implementation-defined forms of interrupt handler procedures are
6540 supported, such as protected procedures with parameters, then for each
6541 such form of a handler, a type analogous to @code{Parameterless_Handler}
6542 should be specified in a child package of @code{Interrupts}, with the
6543 same operations as in the predefined package Interrupts.
6547 @cindex Pre-elaboration requirements
6548 @unnumberedsec C.4(14): Pre-elaboration Requirements
6551 It is recommended that pre-elaborated packages be implemented in such a
6552 way that there should be little or no code executed at run time for the
6553 elaboration of entities not already covered by the Implementation
6556 Followed. Executable code is generated in some cases, e.g.@: loops
6557 to initialize large arrays.
6559 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6563 If the pragma applies to an entity, then the implementation should
6564 reduce the amount of storage used for storing names associated with that
6569 @cindex Package @code{Task_Attributes}
6570 @findex Task_Attributes
6571 @unnumberedsec C.7.2(30): The Package Task_Attributes
6574 Some implementations are targeted to domains in which memory use at run
6575 time must be completely deterministic. For such implementations, it is
6576 recommended that the storage for task attributes will be pre-allocated
6577 statically and not from the heap. This can be accomplished by either
6578 placing restrictions on the number and the size of the task's
6579 attributes, or by using the pre-allocated storage for the first @var{N}
6580 attribute objects, and the heap for the others. In the latter case,
6581 @var{N} should be documented.
6583 Not followed. This implementation is not targeted to such a domain.
6585 @cindex Locking Policies
6586 @unnumberedsec D.3(17): Locking Policies
6590 The implementation should use names that end with @samp{_Locking} for
6591 locking policies defined by the implementation.
6593 Followed. A single implementation-defined locking policy is defined,
6594 whose name (@code{Inheritance_Locking}) follows this suggestion.
6596 @cindex Entry queuing policies
6597 @unnumberedsec D.4(16): Entry Queuing Policies
6600 Names that end with @samp{_Queuing} should be used
6601 for all implementation-defined queuing policies.
6603 Followed. No such implementation-defined queuing policies exist.
6605 @cindex Preemptive abort
6606 @unnumberedsec D.6(9-10): Preemptive Abort
6609 Even though the @code{abort_statement} is included in the list of
6610 potentially blocking operations (see 9.5.1), it is recommended that this
6611 statement be implemented in a way that never requires the task executing
6612 the @code{abort_statement} to block.
6618 On a multi-processor, the delay associated with aborting a task on
6619 another processor should be bounded; the implementation should use
6620 periodic polling, if necessary, to achieve this.
6624 @cindex Tasking restrictions
6625 @unnumberedsec D.7(21): Tasking Restrictions
6628 When feasible, the implementation should take advantage of the specified
6629 restrictions to produce a more efficient implementation.
6631 GNAT currently takes advantage of these restrictions by providing an optimized
6632 run time when the Ravenscar profile and the GNAT restricted run time set
6633 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
6634 pragma @code{Profile (Restricted)} for more details.
6636 @cindex Time, monotonic
6637 @unnumberedsec D.8(47-49): Monotonic Time
6640 When appropriate, implementations should provide configuration
6641 mechanisms to change the value of @code{Tick}.
6643 Such configuration mechanisms are not appropriate to this implementation
6644 and are thus not supported.
6648 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6649 be implemented as transformations of the same time base.
6655 It is recommended that the @dfn{best} time base which exists in
6656 the underlying system be available to the application through
6657 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
6661 @cindex Partition communication subsystem
6663 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6666 Whenever possible, the PCS on the called partition should allow for
6667 multiple tasks to call the RPC-receiver with different messages and
6668 should allow them to block until the corresponding subprogram body
6671 Followed by GLADE, a separately supplied PCS that can be used with
6676 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6677 should raise @code{Storage_Error} if it runs out of space trying to
6678 write the @code{Item} into the stream.
6680 Followed by GLADE, a separately supplied PCS that can be used with
6683 @cindex COBOL support
6684 @unnumberedsec F(7): COBOL Support
6687 If COBOL (respectively, C) is widely supported in the target
6688 environment, implementations supporting the Information Systems Annex
6689 should provide the child package @code{Interfaces.COBOL} (respectively,
6690 @code{Interfaces.C}) specified in Annex B and should support a
6691 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6692 pragmas (see Annex B), thus allowing Ada programs to interface with
6693 programs written in that language.
6697 @cindex Decimal radix support
6698 @unnumberedsec F.1(2): Decimal Radix Support
6701 Packed decimal should be used as the internal representation for objects
6702 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6704 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
6708 @unnumberedsec G: Numerics
6711 If Fortran (respectively, C) is widely supported in the target
6712 environment, implementations supporting the Numerics Annex
6713 should provide the child package @code{Interfaces.Fortran} (respectively,
6714 @code{Interfaces.C}) specified in Annex B and should support a
6715 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6716 pragmas (see Annex B), thus allowing Ada programs to interface with
6717 programs written in that language.
6721 @cindex Complex types
6722 @unnumberedsec G.1.1(56-58): Complex Types
6725 Because the usual mathematical meaning of multiplication of a complex
6726 operand and a real operand is that of the scaling of both components of
6727 the former by the latter, an implementation should not perform this
6728 operation by first promoting the real operand to complex type and then
6729 performing a full complex multiplication. In systems that, in the
6730 future, support an Ada binding to IEC 559:1989, the latter technique
6731 will not generate the required result when one of the components of the
6732 complex operand is infinite. (Explicit multiplication of the infinite
6733 component by the zero component obtained during promotion yields a NaN
6734 that propagates into the final result.) Analogous advice applies in the
6735 case of multiplication of a complex operand and a pure-imaginary
6736 operand, and in the case of division of a complex operand by a real or
6737 pure-imaginary operand.
6743 Similarly, because the usual mathematical meaning of addition of a
6744 complex operand and a real operand is that the imaginary operand remains
6745 unchanged, an implementation should not perform this operation by first
6746 promoting the real operand to complex type and then performing a full
6747 complex addition. In implementations in which the @code{Signed_Zeros}
6748 attribute of the component type is @code{True} (and which therefore
6749 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6750 predefined arithmetic operations), the latter technique will not
6751 generate the required result when the imaginary component of the complex
6752 operand is a negatively signed zero. (Explicit addition of the negative
6753 zero to the zero obtained during promotion yields a positive zero.)
6754 Analogous advice applies in the case of addition of a complex operand
6755 and a pure-imaginary operand, and in the case of subtraction of a
6756 complex operand and a real or pure-imaginary operand.
6762 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6763 attempt to provide a rational treatment of the signs of zero results and
6764 result components. As one example, the result of the @code{Argument}
6765 function should have the sign of the imaginary component of the
6766 parameter @code{X} when the point represented by that parameter lies on
6767 the positive real axis; as another, the sign of the imaginary component
6768 of the @code{Compose_From_Polar} function should be the same as
6769 (respectively, the opposite of) that of the @code{Argument} parameter when that
6770 parameter has a value of zero and the @code{Modulus} parameter has a
6771 nonnegative (respectively, negative) value.
6775 @cindex Complex elementary functions
6776 @unnumberedsec G.1.2(49): Complex Elementary Functions
6779 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6780 @code{True} should attempt to provide a rational treatment of the signs
6781 of zero results and result components. For example, many of the complex
6782 elementary functions have components that are odd functions of one of
6783 the parameter components; in these cases, the result component should
6784 have the sign of the parameter component at the origin. Other complex
6785 elementary functions have zero components whose sign is opposite that of
6786 a parameter component at the origin, or is always positive or always
6791 @cindex Accuracy requirements
6792 @unnumberedsec G.2.4(19): Accuracy Requirements
6795 The versions of the forward trigonometric functions without a
6796 @code{Cycle} parameter should not be implemented by calling the
6797 corresponding version with a @code{Cycle} parameter of
6798 @code{2.0*Numerics.Pi}, since this will not provide the required
6799 accuracy in some portions of the domain. For the same reason, the
6800 version of @code{Log} without a @code{Base} parameter should not be
6801 implemented by calling the corresponding version with a @code{Base}
6802 parameter of @code{Numerics.e}.
6806 @cindex Complex arithmetic accuracy
6807 @cindex Accuracy, complex arithmetic
6808 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6812 The version of the @code{Compose_From_Polar} function without a
6813 @code{Cycle} parameter should not be implemented by calling the
6814 corresponding version with a @code{Cycle} parameter of
6815 @code{2.0*Numerics.Pi}, since this will not provide the required
6816 accuracy in some portions of the domain.
6820 @c -----------------------------------------
6821 @node Implementation Defined Characteristics
6822 @chapter Implementation Defined Characteristics
6825 In addition to the implementation dependent pragmas and attributes, and
6826 the implementation advice, there are a number of other Ada features
6827 that are potentially implementation dependent. These are mentioned
6828 throughout the Ada Reference Manual, and are summarized in annex M@.
6830 A requirement for conforming Ada compilers is that they provide
6831 documentation describing how the implementation deals with each of these
6832 issues. In this chapter, you will find each point in annex M listed
6833 followed by a description in italic font of how GNAT
6837 implementation on IRIX 5.3 operating system or greater
6839 handles the implementation dependence.
6841 You can use this chapter as a guide to minimizing implementation
6842 dependent features in your programs if portability to other compilers
6843 and other operating systems is an important consideration. The numbers
6844 in each section below correspond to the paragraph number in the Ada
6850 @strong{2}. Whether or not each recommendation given in Implementation
6851 Advice is followed. See 1.1.2(37).
6854 @xref{Implementation Advice}.
6859 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
6862 The complexity of programs that can be processed is limited only by the
6863 total amount of available virtual memory, and disk space for the
6864 generated object files.
6869 @strong{4}. Variations from the standard that are impractical to avoid
6870 given the implementation's execution environment. See 1.1.3(6).
6873 There are no variations from the standard.
6878 @strong{5}. Which @code{code_statement}s cause external
6879 interactions. See 1.1.3(10).
6882 Any @code{code_statement} can potentially cause external interactions.
6887 @strong{6}. The coded representation for the text of an Ada
6888 program. See 2.1(4).
6891 See separate section on source representation.
6896 @strong{7}. The control functions allowed in comments. See 2.1(14).
6899 See separate section on source representation.
6904 @strong{8}. The representation for an end of line. See 2.2(2).
6907 See separate section on source representation.
6912 @strong{9}. Maximum supported line length and lexical element
6913 length. See 2.2(15).
6916 The maximum line length is 255 characters an the maximum length of a
6917 lexical element is also 255 characters.
6922 @strong{10}. Implementation defined pragmas. See 2.8(14).
6926 @xref{Implementation Defined Pragmas}.
6931 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
6934 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6935 parameter, checks that the optimization flag is set, and aborts if it is
6941 @strong{12}. The sequence of characters of the value returned by
6942 @code{@var{S}'Image} when some of the graphic characters of
6943 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
6947 The sequence of characters is as defined by the wide character encoding
6948 method used for the source. See section on source representation for
6954 @strong{13}. The predefined integer types declared in
6955 @code{Standard}. See 3.5.4(25).
6959 @item Short_Short_Integer
6962 (Short) 16 bit signed
6966 64 bit signed (Alpha OpenVMS only)
6967 32 bit signed (all other targets)
6968 @item Long_Long_Integer
6975 @strong{14}. Any nonstandard integer types and the operators defined
6976 for them. See 3.5.4(26).
6979 There are no nonstandard integer types.
6984 @strong{15}. Any nonstandard real types and the operators defined for
6988 There are no nonstandard real types.
6993 @strong{16}. What combinations of requested decimal precision and range
6994 are supported for floating point types. See 3.5.7(7).
6997 The precision and range is as defined by the IEEE standard.
7002 @strong{17}. The predefined floating point types declared in
7003 @code{Standard}. See 3.5.7(16).
7010 (Short) 32 bit IEEE short
7013 @item Long_Long_Float
7014 64 bit IEEE long (80 bit IEEE long on x86 processors)
7020 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
7023 @code{Fine_Delta} is 2**(@minus{}63)
7028 @strong{19}. What combinations of small, range, and digits are
7029 supported for fixed point types. See 3.5.9(10).
7032 Any combinations are permitted that do not result in a small less than
7033 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7034 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7035 is 64 bits (true of all architectures except ia32), then the output from
7036 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
7037 is because floating-point conversions are used to convert fixed point.
7042 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
7043 within an unnamed @code{block_statement}. See 3.9(10).
7046 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7047 decimal integer are allocated.
7052 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
7055 @xref{Implementation Defined Attributes}.
7060 @strong{22}. Any implementation-defined time types. See 9.6(6).
7063 There are no implementation-defined time types.
7068 @strong{23}. The time base associated with relative delays.
7071 See 9.6(20). The time base used is that provided by the C library
7072 function @code{gettimeofday}.
7077 @strong{24}. The time base of the type @code{Calendar.Time}. See
7081 The time base used is that provided by the C library function
7082 @code{gettimeofday}.
7087 @strong{25}. The time zone used for package @code{Calendar}
7088 operations. See 9.6(24).
7091 The time zone used by package @code{Calendar} is the current system time zone
7092 setting for local time, as accessed by the C library function
7098 @strong{26}. Any limit on @code{delay_until_statements} of
7099 @code{select_statements}. See 9.6(29).
7102 There are no such limits.
7107 @strong{27}. Whether or not two non overlapping parts of a composite
7108 object are independently addressable, in the case where packing, record
7109 layout, or @code{Component_Size} is specified for the object. See
7113 Separate components are independently addressable if they do not share
7114 overlapping storage units.
7119 @strong{28}. The representation for a compilation. See 10.1(2).
7122 A compilation is represented by a sequence of files presented to the
7123 compiler in a single invocation of the @code{gcc} command.
7128 @strong{29}. Any restrictions on compilations that contain multiple
7129 compilation_units. See 10.1(4).
7132 No single file can contain more than one compilation unit, but any
7133 sequence of files can be presented to the compiler as a single
7139 @strong{30}. The mechanisms for creating an environment and for adding
7140 and replacing compilation units. See 10.1.4(3).
7143 See separate section on compilation model.
7148 @strong{31}. The manner of explicitly assigning library units to a
7149 partition. See 10.2(2).
7152 If a unit contains an Ada main program, then the Ada units for the partition
7153 are determined by recursive application of the rules in the Ada Reference
7154 Manual section 10.2(2-6). In other words, the Ada units will be those that
7155 are needed by the main program, and then this definition of need is applied
7156 recursively to those units, and the partition contains the transitive
7157 closure determined by this relationship. In short, all the necessary units
7158 are included, with no need to explicitly specify the list. If additional
7159 units are required, e.g.@: by foreign language units, then all units must be
7160 mentioned in the context clause of one of the needed Ada units.
7162 If the partition contains no main program, or if the main program is in
7163 a language other than Ada, then GNAT
7164 provides the binder options @code{-z} and @code{-n} respectively, and in
7165 this case a list of units can be explicitly supplied to the binder for
7166 inclusion in the partition (all units needed by these units will also
7167 be included automatically). For full details on the use of these
7168 options, refer to the @cite{GNAT User's Guide} sections on Binding
7174 @strong{32}. The implementation-defined means, if any, of specifying
7175 which compilation units are needed by a given compilation unit. See
7179 The units needed by a given compilation unit are as defined in
7180 the Ada Reference Manual section 10.2(2-6). There are no
7181 implementation-defined pragmas or other implementation-defined
7182 means for specifying needed units.
7187 @strong{33}. The manner of designating the main subprogram of a
7188 partition. See 10.2(7).
7191 The main program is designated by providing the name of the
7192 corresponding @file{ALI} file as the input parameter to the binder.
7197 @strong{34}. The order of elaboration of @code{library_items}. See
7201 The first constraint on ordering is that it meets the requirements of
7202 Chapter 10 of the Ada Reference Manual. This still leaves some
7203 implementation dependent choices, which are resolved by first
7204 elaborating bodies as early as possible (i.e., in preference to specs
7205 where there is a choice), and second by evaluating the immediate with
7206 clauses of a unit to determine the probably best choice, and
7207 third by elaborating in alphabetical order of unit names
7208 where a choice still remains.
7213 @strong{35}. Parameter passing and function return for the main
7214 subprogram. See 10.2(21).
7217 The main program has no parameters. It may be a procedure, or a function
7218 returning an integer type. In the latter case, the returned integer
7219 value is the return code of the program (overriding any value that
7220 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7225 @strong{36}. The mechanisms for building and running partitions. See
7229 GNAT itself supports programs with only a single partition. The GNATDIST
7230 tool provided with the GLADE package (which also includes an implementation
7231 of the PCS) provides a completely flexible method for building and running
7232 programs consisting of multiple partitions. See the separate GLADE manual
7238 @strong{37}. The details of program execution, including program
7239 termination. See 10.2(25).
7242 See separate section on compilation model.
7247 @strong{38}. The semantics of any non-active partitions supported by the
7248 implementation. See 10.2(28).
7251 Passive partitions are supported on targets where shared memory is
7252 provided by the operating system. See the GLADE reference manual for
7258 @strong{39}. The information returned by @code{Exception_Message}. See
7262 Exception message returns the null string unless a specific message has
7263 been passed by the program.
7268 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
7269 declared within an unnamed @code{block_statement}. See 11.4.1(12).
7272 Blocks have implementation defined names of the form @code{B@var{nnn}}
7273 where @var{nnn} is an integer.
7278 @strong{41}. The information returned by
7279 @code{Exception_Information}. See 11.4.1(13).
7282 @code{Exception_Information} returns a string in the following format:
7285 @emph{Exception_Name:} nnnnn
7286 @emph{Message:} mmmmm
7288 @emph{Call stack traceback locations:}
7289 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
7297 @code{nnnn} is the fully qualified name of the exception in all upper
7298 case letters. This line is always present.
7301 @code{mmmm} is the message (this line present only if message is non-null)
7304 @code{ppp} is the Process Id value as a decimal integer (this line is
7305 present only if the Process Id is nonzero). Currently we are
7306 not making use of this field.
7309 The Call stack traceback locations line and the following values
7310 are present only if at least one traceback location was recorded.
7311 The values are given in C style format, with lower case letters
7312 for a-f, and only as many digits present as are necessary.
7316 The line terminator sequence at the end of each line, including
7317 the last line is a single @code{LF} character (@code{16#0A#}).
7322 @strong{42}. Implementation-defined check names. See 11.5(27).
7325 No implementation-defined check names are supported.
7330 @strong{43}. The interpretation of each aspect of representation. See
7334 See separate section on data representations.
7339 @strong{44}. Any restrictions placed upon representation items. See
7343 See separate section on data representations.
7348 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
7352 Size for an indefinite subtype is the maximum possible size, except that
7353 for the case of a subprogram parameter, the size of the parameter object
7359 @strong{46}. The default external representation for a type tag. See
7363 The default external representation for a type tag is the fully expanded
7364 name of the type in upper case letters.
7369 @strong{47}. What determines whether a compilation unit is the same in
7370 two different partitions. See 13.3(76).
7373 A compilation unit is the same in two different partitions if and only
7374 if it derives from the same source file.
7379 @strong{48}. Implementation-defined components. See 13.5.1(15).
7382 The only implementation defined component is the tag for a tagged type,
7383 which contains a pointer to the dispatching table.
7388 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
7389 ordering. See 13.5.3(5).
7392 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
7393 implementation, so no non-default bit ordering is supported. The default
7394 bit ordering corresponds to the natural endianness of the target architecture.
7399 @strong{50}. The contents of the visible part of package @code{System}
7400 and its language-defined children. See 13.7(2).
7403 See the definition of these packages in files @file{system.ads} and
7404 @file{s-stoele.ads}.
7409 @strong{51}. The contents of the visible part of package
7410 @code{System.Machine_Code}, and the meaning of
7411 @code{code_statements}. See 13.8(7).
7414 See the definition and documentation in file @file{s-maccod.ads}.
7419 @strong{52}. The effect of unchecked conversion. See 13.9(11).
7422 Unchecked conversion between types of the same size
7423 results in an uninterpreted transmission of the bits from one type
7424 to the other. If the types are of unequal sizes, then in the case of
7425 discrete types, a shorter source is first zero or sign extended as
7426 necessary, and a shorter target is simply truncated on the left.
7427 For all non-discrete types, the source is first copied if necessary
7428 to ensure that the alignment requirements of the target are met, then
7429 a pointer is constructed to the source value, and the result is obtained
7430 by dereferencing this pointer after converting it to be a pointer to the
7431 target type. Unchecked conversions where the target subtype is an
7432 unconstrained array are not permitted. If the target alignment is
7433 greater than the source alignment, then a copy of the result is
7434 made with appropriate alignment
7439 @strong{53}. The manner of choosing a storage pool for an access type
7440 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
7443 There are 3 different standard pools used by the compiler when
7444 @code{Storage_Pool} is not specified depending whether the type is local
7445 to a subprogram or defined at the library level and whether
7446 @code{Storage_Size}is specified or not. See documentation in the runtime
7447 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
7448 @code{System.Pool_Local} in files @file{s-poosiz.ads},
7449 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
7455 @strong{54}. Whether or not the implementation provides user-accessible
7456 names for the standard pool type(s). See 13.11(17).
7460 See documentation in the sources of the run time mentioned in paragraph
7461 @strong{53} . All these pools are accessible by means of @code{with}'ing
7467 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
7470 @code{Storage_Size} is measured in storage units, and refers to the
7471 total space available for an access type collection, or to the primary
7472 stack space for a task.
7477 @strong{56}. Implementation-defined aspects of storage pools. See
7481 See documentation in the sources of the run time mentioned in paragraph
7482 @strong{53} for details on GNAT-defined aspects of storage pools.
7487 @strong{57}. The set of restrictions allowed in a pragma
7488 @code{Restrictions}. See 13.12(7).
7491 All RM defined Restriction identifiers are implemented. The following
7492 additional restriction identifiers are provided. There are two separate
7493 lists of implementation dependent restriction identifiers. The first
7494 set requires consistency throughout a partition (in other words, if the
7495 restriction identifier is used for any compilation unit in the partition,
7496 then all compilation units in the partition must obey the restriction.
7500 @item Simple_Barriers
7501 @findex Simple_Barriers
7502 This restriction ensures at compile time that barriers in entry declarations
7503 for protected types are restricted to either static boolean expressions or
7504 references to simple boolean variables defined in the private part of the
7505 protected type. No other form of entry barriers is permitted. This is one
7506 of the restrictions of the Ravenscar profile for limited tasking (see also
7507 pragma @code{Profile (Ravenscar)}).
7509 @item Max_Entry_Queue_Length => Expr
7510 @findex Max_Entry_Queue_Length
7511 This restriction is a declaration that any protected entry compiled in
7512 the scope of the restriction has at most the specified number of
7513 tasks waiting on the entry
7514 at any one time, and so no queue is required. This restriction is not
7515 checked at compile time. A program execution is erroneous if an attempt
7516 is made to queue more than the specified number of tasks on such an entry.
7520 This restriction ensures at compile time that there is no implicit or
7521 explicit dependence on the package @code{Ada.Calendar}.
7523 @item No_Direct_Boolean_Operators
7524 @findex No_Direct_Boolean_Operators
7525 This restriction ensures that no logical (and/or/xor) or comparison
7526 operators are used on operands of type Boolean (or any type derived
7527 from Boolean). This is intended for use in safety critical programs
7528 where the certification protocol requires the use of short-circuit
7529 (and then, or else) forms for all composite boolean operations.
7531 @item No_Dispatching_Calls
7532 @findex No_Dispatching_Calls
7533 This restriction ensures at compile time that the code generated by the
7534 compiler involves no dispatching calls. The use of this restriction allows the
7535 safe use of record extensions, classwide membership tests and other classwide
7536 features not involving implicit dispatching. This restriction ensures that
7537 the code contains no indirect calls through a dispatching mechanism. Note that
7538 this includes internally-generated calls created by the compiler, for example
7539 in the implementation of class-wide objects assignments. The
7540 membership test is allowed in the presence of this restriction, because its
7541 implementation requires no dispatching.
7542 This restriction is comparable to the official Ada restriction
7543 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7544 all classwide constructs that do not imply dispatching.
7545 The following example indicates constructs that violate this restriction.
7549 type T is tagged record
7552 procedure P (X : T);
7554 type DT is new T with record
7555 More_Data : Natural;
7557 procedure Q (X : DT);
7561 procedure Example is
7562 procedure Test (O : T'Class) is
7563 N : Natural := O'Size;-- Error: Dispatching call
7564 C : T'Class := O; -- Error: implicit Dispatching Call
7566 if O in DT'Class then -- OK : Membership test
7567 Q (DT (O)); -- OK : Type conversion plus direct call
7569 P (O); -- Error: Dispatching call
7575 P (Obj); -- OK : Direct call
7576 P (T (Obj)); -- OK : Type conversion plus direct call
7577 P (T'Class (Obj)); -- Error: Dispatching call
7579 Test (Obj); -- OK : Type conversion
7581 if Obj in T'Class then -- OK : Membership test
7587 @item No_Dynamic_Attachment
7588 @findex No_Dynamic_Attachment
7589 This restriction ensures that there is no call to any of the operations
7590 defined in package Ada.Interrupts.
7592 @item No_Enumeration_Maps
7593 @findex No_Enumeration_Maps
7594 This restriction ensures at compile time that no operations requiring
7595 enumeration maps are used (that is Image and Value attributes applied
7596 to enumeration types).
7598 @item No_Entry_Calls_In_Elaboration_Code
7599 @findex No_Entry_Calls_In_Elaboration_Code
7600 This restriction ensures at compile time that no task or protected entry
7601 calls are made during elaboration code. As a result of the use of this
7602 restriction, the compiler can assume that no code past an accept statement
7603 in a task can be executed at elaboration time.
7605 @item No_Exception_Handlers
7606 @findex No_Exception_Handlers
7607 This restriction ensures at compile time that there are no explicit
7608 exception handlers. It also indicates that no exception propagation will
7609 be provided. In this mode, exceptions may be raised but will result in
7610 an immediate call to the last chance handler, a routine that the user
7611 must define with the following profile:
7613 procedure Last_Chance_Handler
7614 (Source_Location : System.Address; Line : Integer);
7615 pragma Export (C, Last_Chance_Handler,
7616 "__gnat_last_chance_handler");
7618 The parameter is a C null-terminated string representing a message to be
7619 associated with the exception (typically the source location of the raise
7620 statement generated by the compiler). The Line parameter when nonzero
7621 represents the line number in the source program where the raise occurs.
7623 @item No_Exception_Propagation
7624 @findex No_Exception_Propagation
7625 This restriction guarantees that exceptions are never propagated to an outer
7626 subprogram scope). The only case in which an exception may be raised is when
7627 the handler is statically in the same subprogram, so that the effect of a raise
7628 is essentially like a goto statement. Any other raise statement (implicit or
7629 explicit) will be considered unhandled. Exception handlers are allowed, but may
7630 not contain an exception occurrence identifier (exception choice). In addition
7631 use of the package GNAT.Current_Exception is not permitted, and reraise
7632 statements (raise with no operand) are not permitted.
7634 @item No_Exception_Registration
7635 @findex No_Exception_Registration
7636 This restriction ensures at compile time that no stream operations for
7637 types Exception_Id or Exception_Occurrence are used. This also makes it
7638 impossible to pass exceptions to or from a partition with this restriction
7639 in a distributed environment. If this exception is active, then the generated
7640 code is simplified by omitting the otherwise-required global registration
7641 of exceptions when they are declared.
7643 @item No_Implicit_Conditionals
7644 @findex No_Implicit_Conditionals
7645 This restriction ensures that the generated code does not contain any
7646 implicit conditionals, either by modifying the generated code where possible,
7647 or by rejecting any construct that would otherwise generate an implicit
7648 conditional. Note that this check does not include run time constraint
7649 checks, which on some targets may generate implicit conditionals as
7650 well. To control the latter, constraint checks can be suppressed in the
7651 normal manner. Constructs generating implicit conditionals include comparisons
7652 of composite objects and the Max/Min attributes.
7654 @item No_Implicit_Dynamic_Code
7655 @findex No_Implicit_Dynamic_Code
7656 This restriction prevents the compiler from building ``trampolines''.
7657 This is a structure that is built on the stack and contains dynamic
7658 code to be executed at run time. A trampoline is needed to indirectly
7659 address a nested subprogram (that is a subprogram that is not at the
7660 library level). The restriction prevents the use of any of the
7661 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
7662 being applied to a subprogram that is not at the library level.
7664 @item No_Implicit_Loops
7665 @findex No_Implicit_Loops
7666 This restriction ensures that the generated code does not contain any
7667 implicit @code{for} loops, either by modifying
7668 the generated code where possible,
7669 or by rejecting any construct that would otherwise generate an implicit
7672 @item No_Initialize_Scalars
7673 @findex No_Initialize_Scalars
7674 This restriction ensures that no unit in the partition is compiled with
7675 pragma Initialize_Scalars. This allows the generation of more efficient
7676 code, and in particular eliminates dummy null initialization routines that
7677 are otherwise generated for some record and array types.
7679 @item No_Local_Protected_Objects
7680 @findex No_Local_Protected_Objects
7681 This restriction ensures at compile time that protected objects are
7682 only declared at the library level.
7684 @item No_Protected_Type_Allocators
7685 @findex No_Protected_Type_Allocators
7686 This restriction ensures at compile time that there are no allocator
7687 expressions that attempt to allocate protected objects.
7689 @item No_Secondary_Stack
7690 @findex No_Secondary_Stack
7691 This restriction ensures at compile time that the generated code does not
7692 contain any reference to the secondary stack. The secondary stack is used
7693 to implement functions returning unconstrained objects (arrays or records)
7696 @item No_Select_Statements
7697 @findex No_Select_Statements
7698 This restriction ensures at compile time no select statements of any kind
7699 are permitted, that is the keyword @code{select} may not appear.
7700 This is one of the restrictions of the Ravenscar
7701 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7703 @item No_Standard_Storage_Pools
7704 @findex No_Standard_Storage_Pools
7705 This restriction ensures at compile time that no access types
7706 use the standard default storage pool. Any access type declared must
7707 have an explicit Storage_Pool attribute defined specifying a
7708 user-defined storage pool.
7712 This restriction ensures at compile/bind time that there are no
7713 stream objects created (and therefore no actual stream operations).
7714 This restriction does not forbid dependences on the package
7715 @code{Ada.Streams}. So it is permissible to with
7716 @code{Ada.Streams} (or another package that does so itself)
7717 as long as no actual stream objects are created.
7719 @item No_Task_Attributes_Package
7720 @findex No_Task_Attributes_Package
7721 This restriction ensures at compile time that there are no implicit or
7722 explicit dependencies on the package @code{Ada.Task_Attributes}.
7724 @item No_Task_Termination
7725 @findex No_Task_Termination
7726 This restriction ensures at compile time that no terminate alternatives
7727 appear in any task body.
7731 This restriction prevents the declaration of tasks or task types throughout
7732 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
7733 except that violations are caught at compile time and cause an error message
7734 to be output either by the compiler or binder.
7736 @item Static_Priorities
7737 @findex Static_Priorities
7738 This restriction ensures at compile time that all priority expressions
7739 are static, and that there are no dependencies on the package
7740 @code{Ada.Dynamic_Priorities}.
7742 @item Static_Storage_Size
7743 @findex Static_Storage_Size
7744 This restriction ensures at compile time that any expression appearing
7745 in a Storage_Size pragma or attribute definition clause is static.
7750 The second set of implementation dependent restriction identifiers
7751 does not require partition-wide consistency.
7752 The restriction may be enforced for a single
7753 compilation unit without any effect on any of the
7754 other compilation units in the partition.
7758 @item No_Elaboration_Code
7759 @findex No_Elaboration_Code
7760 This restriction ensures at compile time that no elaboration code is
7761 generated. Note that this is not the same condition as is enforced
7762 by pragma @code{Preelaborate}. There are cases in which pragma
7763 @code{Preelaborate} still permits code to be generated (e.g.@: code
7764 to initialize a large array to all zeroes), and there are cases of units
7765 which do not meet the requirements for pragma @code{Preelaborate},
7766 but for which no elaboration code is generated. Generally, it is
7767 the case that preelaborable units will meet the restrictions, with
7768 the exception of large aggregates initialized with an others_clause,
7769 and exception declarations (which generate calls to a run-time
7770 registry procedure). This restriction is enforced on
7771 a unit by unit basis, it need not be obeyed consistently
7772 throughout a partition.
7774 In the case of aggregates with others, if the aggregate has a dynamic
7775 size, there is no way to eliminate the elaboration code (such dynamic
7776 bounds would be incompatible with @code{Preelaborate} in any case. If
7777 the bounds are static, then use of this restriction actually modifies
7778 the code choice of the compiler to avoid generating a loop, and instead
7779 generate the aggregate statically if possible, no matter how many times
7780 the data for the others clause must be repeatedly generated.
7782 It is not possible to precisely document
7783 the constructs which are compatible with this restriction, since,
7784 unlike most other restrictions, this is not a restriction on the
7785 source code, but a restriction on the generated object code. For
7786 example, if the source contains a declaration:
7789 Val : constant Integer := X;
7793 where X is not a static constant, it may be possible, depending
7794 on complex optimization circuitry, for the compiler to figure
7795 out the value of X at compile time, in which case this initialization
7796 can be done by the loader, and requires no initialization code. It
7797 is not possible to document the precise conditions under which the
7798 optimizer can figure this out.
7800 Note that this the implementation of this restriction requires full
7801 code generation. If it is used in conjunction with "semantics only"
7802 checking, then some cases of violations may be missed.
7804 @item No_Entry_Queue
7805 @findex No_Entry_Queue
7806 This restriction is a declaration that any protected entry compiled in
7807 the scope of the restriction has at most one task waiting on the entry
7808 at any one time, and so no queue is required. This restriction is not
7809 checked at compile time. A program execution is erroneous if an attempt
7810 is made to queue a second task on such an entry.
7812 @item No_Implementation_Attributes
7813 @findex No_Implementation_Attributes
7814 This restriction checks at compile time that no GNAT-defined attributes
7815 are present. With this restriction, the only attributes that can be used
7816 are those defined in the Ada Reference Manual.
7818 @item No_Implementation_Pragmas
7819 @findex No_Implementation_Pragmas
7820 This restriction checks at compile time that no GNAT-defined pragmas
7821 are present. With this restriction, the only pragmas that can be used
7822 are those defined in the Ada Reference Manual.
7824 @item No_Implementation_Restrictions
7825 @findex No_Implementation_Restrictions
7826 This restriction checks at compile time that no GNAT-defined restriction
7827 identifiers (other than @code{No_Implementation_Restrictions} itself)
7828 are present. With this restriction, the only other restriction identifiers
7829 that can be used are those defined in the Ada Reference Manual.
7831 @item No_Wide_Characters
7832 @findex No_Wide_Characters
7833 This restriction ensures at compile time that no uses of the types
7834 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7836 appear, and that no wide or wide wide string or character literals
7837 appear in the program (that is literals representing characters not in
7838 type @code{Character}.
7845 @strong{58}. The consequences of violating limitations on
7846 @code{Restrictions} pragmas. See 13.12(9).
7849 Restrictions that can be checked at compile time result in illegalities
7850 if violated. Currently there are no other consequences of violating
7856 @strong{59}. The representation used by the @code{Read} and
7857 @code{Write} attributes of elementary types in terms of stream
7858 elements. See 13.13.2(9).
7861 The representation is the in-memory representation of the base type of
7862 the type, using the number of bits corresponding to the
7863 @code{@var{type}'Size} value, and the natural ordering of the machine.
7868 @strong{60}. The names and characteristics of the numeric subtypes
7869 declared in the visible part of package @code{Standard}. See A.1(3).
7872 See items describing the integer and floating-point types supported.
7877 @strong{61}. The accuracy actually achieved by the elementary
7878 functions. See A.5.1(1).
7881 The elementary functions correspond to the functions available in the C
7882 library. Only fast math mode is implemented.
7887 @strong{62}. The sign of a zero result from some of the operators or
7888 functions in @code{Numerics.Generic_Elementary_Functions}, when
7889 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
7892 The sign of zeroes follows the requirements of the IEEE 754 standard on
7898 @strong{63}. The value of
7899 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
7902 Maximum image width is 649, see library file @file{a-numran.ads}.
7907 @strong{64}. The value of
7908 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
7911 Maximum image width is 80, see library file @file{a-nudira.ads}.
7916 @strong{65}. The algorithms for random number generation. See
7920 The algorithm is documented in the source files @file{a-numran.ads} and
7921 @file{a-numran.adb}.
7926 @strong{66}. The string representation of a random number generator's
7927 state. See A.5.2(38).
7930 See the documentation contained in the file @file{a-numran.adb}.
7935 @strong{67}. The minimum time interval between calls to the
7936 time-dependent Reset procedure that are guaranteed to initiate different
7937 random number sequences. See A.5.2(45).
7940 The minimum period between reset calls to guarantee distinct series of
7941 random numbers is one microsecond.
7946 @strong{68}. The values of the @code{Model_Mantissa},
7947 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7948 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7949 Annex is not supported. See A.5.3(72).
7952 See the source file @file{ttypef.ads} for the values of all numeric
7958 @strong{69}. Any implementation-defined characteristics of the
7959 input-output packages. See A.7(14).
7962 There are no special implementation defined characteristics for these
7968 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
7972 All type representations are contiguous, and the @code{Buffer_Size} is
7973 the value of @code{@var{type}'Size} rounded up to the next storage unit
7979 @strong{71}. External files for standard input, standard output, and
7980 standard error See A.10(5).
7983 These files are mapped onto the files provided by the C streams
7984 libraries. See source file @file{i-cstrea.ads} for further details.
7989 @strong{72}. The accuracy of the value produced by @code{Put}. See
7993 If more digits are requested in the output than are represented by the
7994 precision of the value, zeroes are output in the corresponding least
7995 significant digit positions.
8000 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
8001 @code{Command_Name}. See A.15(1).
8004 These are mapped onto the @code{argv} and @code{argc} parameters of the
8005 main program in the natural manner.
8010 @strong{74}. Implementation-defined convention names. See B.1(11).
8013 The following convention names are supported
8021 Synonym for Assembler
8023 Synonym for Assembler
8026 @item C_Pass_By_Copy
8027 Allowed only for record types, like C, but also notes that record
8028 is to be passed by copy rather than reference.
8031 @item C_Plus_Plus (or CPP)
8034 Treated the same as C
8036 Treated the same as C
8040 For support of pragma @code{Import} with convention Intrinsic, see
8041 separate section on Intrinsic Subprograms.
8043 Stdcall (used for Windows implementations only). This convention correspond
8044 to the WINAPI (previously called Pascal convention) C/C++ convention under
8045 Windows. A function with this convention cleans the stack before exit.
8051 Stubbed is a special convention used to indicate that the body of the
8052 subprogram will be entirely ignored. Any call to the subprogram
8053 is converted into a raise of the @code{Program_Error} exception. If a
8054 pragma @code{Import} specifies convention @code{stubbed} then no body need
8055 be present at all. This convention is useful during development for the
8056 inclusion of subprograms whose body has not yet been written.
8060 In addition, all otherwise unrecognized convention names are also
8061 treated as being synonymous with convention C@. In all implementations
8062 except for VMS, use of such other names results in a warning. In VMS
8063 implementations, these names are accepted silently.
8068 @strong{75}. The meaning of link names. See B.1(36).
8071 Link names are the actual names used by the linker.
8076 @strong{76}. The manner of choosing link names when neither the link
8077 name nor the address of an imported or exported entity is specified. See
8081 The default linker name is that which would be assigned by the relevant
8082 external language, interpreting the Ada name as being in all lower case
8088 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
8091 The string passed to @code{Linker_Options} is presented uninterpreted as
8092 an argument to the link command, unless it contains Ascii.NUL characters.
8093 NUL characters if they appear act as argument separators, so for example
8095 @smallexample @c ada
8096 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
8100 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8101 linker. The order of linker options is preserved for a given unit. The final
8102 list of options passed to the linker is in reverse order of the elaboration
8103 order. For example, linker options fo a body always appear before the options
8104 from the corresponding package spec.
8109 @strong{78}. The contents of the visible part of package
8110 @code{Interfaces} and its language-defined descendants. See B.2(1).
8113 See files with prefix @file{i-} in the distributed library.
8118 @strong{79}. Implementation-defined children of package
8119 @code{Interfaces}. The contents of the visible part of package
8120 @code{Interfaces}. See B.2(11).
8123 See files with prefix @file{i-} in the distributed library.
8128 @strong{80}. The types @code{Floating}, @code{Long_Floating},
8129 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8130 @code{COBOL_Character}; and the initialization of the variables
8131 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8132 @code{Interfaces.COBOL}. See B.4(50).
8139 (Floating) Long_Float
8144 @item Decimal_Element
8146 @item COBOL_Character
8151 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8156 @strong{81}. Support for access to machine instructions. See C.1(1).
8159 See documentation in file @file{s-maccod.ads} in the distributed library.
8164 @strong{82}. Implementation-defined aspects of access to machine
8165 operations. See C.1(9).
8168 See documentation in file @file{s-maccod.ads} in the distributed library.
8173 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
8176 Interrupts are mapped to signals or conditions as appropriate. See
8178 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8179 on the interrupts supported on a particular target.
8184 @strong{84}. Implementation-defined aspects of pre-elaboration. See
8188 GNAT does not permit a partition to be restarted without reloading,
8189 except under control of the debugger.
8194 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
8197 Pragma @code{Discard_Names} causes names of enumeration literals to
8198 be suppressed. In the presence of this pragma, the Image attribute
8199 provides the image of the Pos of the literal, and Value accepts
8205 @strong{86}. The result of the @code{Task_Identification.Image}
8206 attribute. See C.7.1(7).
8209 The result of this attribute is a string that identifies
8210 the object or component that denotes a given task. If a variable Var has a task
8211 type, the image for this task will have the form Var_XXXXXXXX, where the
8213 is the hexadecimal representation of the virtual address of the corresponding
8214 task control block. If the variable is an array of tasks, the image of each
8215 task will have the form of an indexed component indicating the position of a
8216 given task in the array, eg. Group(5)_XXXXXXX. If the task is a
8217 component of a record, the image of the task will have the form of a selected
8218 component. These rules are fully recursive, so that the image of a task that
8219 is a subcomponent of a composite object corresponds to the expression that
8220 designates this task.
8222 If a task is created by an allocator, its image depends on the context. If the
8223 allocator is part of an object declaration, the rules described above are used
8224 to construct its image, and this image is not affected by subsequent
8225 assignments. If the allocator appears within an expression, the image
8226 includes only the name of the task type.
8228 If the configuration pragma Discard_Names is present, or if the restriction
8229 No_Implicit_Heap_Allocation is in effect, the image reduces to
8230 the numeric suffix, that is to say the hexadecimal representation of the
8231 virtual address of the control block of the task.
8235 @strong{87}. The value of @code{Current_Task} when in a protected entry
8236 or interrupt handler. See C.7.1(17).
8239 Protected entries or interrupt handlers can be executed by any
8240 convenient thread, so the value of @code{Current_Task} is undefined.
8245 @strong{88}. The effect of calling @code{Current_Task} from an entry
8246 body or interrupt handler. See C.7.1(19).
8249 The effect of calling @code{Current_Task} from an entry body or
8250 interrupt handler is to return the identification of the task currently
8256 @strong{89}. Implementation-defined aspects of
8257 @code{Task_Attributes}. See C.7.2(19).
8260 There are no implementation-defined aspects of @code{Task_Attributes}.
8265 @strong{90}. Values of all @code{Metrics}. See D(2).
8268 The metrics information for GNAT depends on the performance of the
8269 underlying operating system. The sources of the run-time for tasking
8270 implementation, together with the output from @code{-gnatG} can be
8271 used to determine the exact sequence of operating systems calls made
8272 to implement various tasking constructs. Together with appropriate
8273 information on the performance of the underlying operating system,
8274 on the exact target in use, this information can be used to determine
8275 the required metrics.
8280 @strong{91}. The declarations of @code{Any_Priority} and
8281 @code{Priority}. See D.1(11).
8284 See declarations in file @file{system.ads}.
8289 @strong{92}. Implementation-defined execution resources. See D.1(15).
8292 There are no implementation-defined execution resources.
8297 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
8298 access to a protected object keeps its processor busy. See D.2.1(3).
8301 On a multi-processor, a task that is waiting for access to a protected
8302 object does not keep its processor busy.
8307 @strong{94}. The affect of implementation defined execution resources
8308 on task dispatching. See D.2.1(9).
8313 Tasks map to IRIX threads, and the dispatching policy is as defined by
8314 the IRIX implementation of threads.
8316 Tasks map to threads in the threads package used by GNAT@. Where possible
8317 and appropriate, these threads correspond to native threads of the
8318 underlying operating system.
8323 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
8324 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
8327 There are no implementation-defined policy-identifiers allowed in this
8333 @strong{96}. Implementation-defined aspects of priority inversion. See
8337 Execution of a task cannot be preempted by the implementation processing
8338 of delay expirations for lower priority tasks.
8343 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
8348 Tasks map to IRIX threads, and the dispatching policy is as defined by
8349 the IRIX implementation of threads.
8351 The policy is the same as that of the underlying threads implementation.
8356 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
8357 in a pragma @code{Locking_Policy}. See D.3(4).
8360 The only implementation defined policy permitted in GNAT is
8361 @code{Inheritance_Locking}. On targets that support this policy, locking
8362 is implemented by inheritance, i.e.@: the task owning the lock operates
8363 at a priority equal to the highest priority of any task currently
8364 requesting the lock.
8369 @strong{99}. Default ceiling priorities. See D.3(10).
8372 The ceiling priority of protected objects of the type
8373 @code{System.Interrupt_Priority'Last} as described in the Ada
8374 Reference Manual D.3(10),
8379 @strong{100}. The ceiling of any protected object used internally by
8380 the implementation. See D.3(16).
8383 The ceiling priority of internal protected objects is
8384 @code{System.Priority'Last}.
8389 @strong{101}. Implementation-defined queuing policies. See D.4(1).
8392 There are no implementation-defined queuing policies.
8397 @strong{102}. On a multiprocessor, any conditions that cause the
8398 completion of an aborted construct to be delayed later than what is
8399 specified for a single processor. See D.6(3).
8402 The semantics for abort on a multi-processor is the same as on a single
8403 processor, there are no further delays.
8408 @strong{103}. Any operations that implicitly require heap storage
8409 allocation. See D.7(8).
8412 The only operation that implicitly requires heap storage allocation is
8418 @strong{104}. Implementation-defined aspects of pragma
8419 @code{Restrictions}. See D.7(20).
8422 There are no such implementation-defined aspects.
8427 @strong{105}. Implementation-defined aspects of package
8428 @code{Real_Time}. See D.8(17).
8431 There are no implementation defined aspects of package @code{Real_Time}.
8436 @strong{106}. Implementation-defined aspects of
8437 @code{delay_statements}. See D.9(8).
8440 Any difference greater than one microsecond will cause the task to be
8441 delayed (see D.9(7)).
8446 @strong{107}. The upper bound on the duration of interrupt blocking
8447 caused by the implementation. See D.12(5).
8450 The upper bound is determined by the underlying operating system. In
8451 no cases is it more than 10 milliseconds.
8456 @strong{108}. The means for creating and executing distributed
8460 The GLADE package provides a utility GNATDIST for creating and executing
8461 distributed programs. See the GLADE reference manual for further details.
8466 @strong{109}. Any events that can result in a partition becoming
8467 inaccessible. See E.1(7).
8470 See the GLADE reference manual for full details on such events.
8475 @strong{110}. The scheduling policies, treatment of priorities, and
8476 management of shared resources between partitions in certain cases. See
8480 See the GLADE reference manual for full details on these aspects of
8481 multi-partition execution.
8486 @strong{111}. Events that cause the version of a compilation unit to
8490 Editing the source file of a compilation unit, or the source files of
8491 any units on which it is dependent in a significant way cause the version
8492 to change. No other actions cause the version number to change. All changes
8493 are significant except those which affect only layout, capitalization or
8499 @strong{112}. Whether the execution of the remote subprogram is
8500 immediately aborted as a result of cancellation. See E.4(13).
8503 See the GLADE reference manual for details on the effect of abort in
8504 a distributed application.
8509 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
8512 See the GLADE reference manual for a full description of all implementation
8513 defined aspects of the PCS@.
8518 @strong{114}. Implementation-defined interfaces in the PCS@. See
8522 See the GLADE reference manual for a full description of all
8523 implementation defined interfaces.
8528 @strong{115}. The values of named numbers in the package
8529 @code{Decimal}. See F.2(7).
8541 @item Max_Decimal_Digits
8548 @strong{116}. The value of @code{Max_Picture_Length} in the package
8549 @code{Text_IO.Editing}. See F.3.3(16).
8557 @strong{117}. The value of @code{Max_Picture_Length} in the package
8558 @code{Wide_Text_IO.Editing}. See F.3.4(5).
8566 @strong{118}. The accuracy actually achieved by the complex elementary
8567 functions and by other complex arithmetic operations. See G.1(1).
8570 Standard library functions are used for the complex arithmetic
8571 operations. Only fast math mode is currently supported.
8576 @strong{119}. The sign of a zero result (or a component thereof) from
8577 any operator or function in @code{Numerics.Generic_Complex_Types}, when
8578 @code{Real'Signed_Zeros} is True. See G.1.1(53).
8581 The signs of zero values are as recommended by the relevant
8582 implementation advice.
8587 @strong{120}. The sign of a zero result (or a component thereof) from
8588 any operator or function in
8589 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8590 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
8593 The signs of zero values are as recommended by the relevant
8594 implementation advice.
8599 @strong{121}. Whether the strict mode or the relaxed mode is the
8600 default. See G.2(2).
8603 The strict mode is the default. There is no separate relaxed mode. GNAT
8604 provides a highly efficient implementation of strict mode.
8609 @strong{122}. The result interval in certain cases of fixed-to-float
8610 conversion. See G.2.1(10).
8613 For cases where the result interval is implementation dependent, the
8614 accuracy is that provided by performing all operations in 64-bit IEEE
8615 floating-point format.
8620 @strong{123}. The result of a floating point arithmetic operation in
8621 overflow situations, when the @code{Machine_Overflows} attribute of the
8622 result type is @code{False}. See G.2.1(13).
8625 Infinite and NaN values are produced as dictated by the IEEE
8626 floating-point standard.
8628 Note that on machines that are not fully compliant with the IEEE
8629 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
8630 must be used for achieving IEEE confirming behavior (although at the cost
8631 of a significant performance penalty), so infinite and NaN values are
8637 @strong{124}. The result interval for division (or exponentiation by a
8638 negative exponent), when the floating point hardware implements division
8639 as multiplication by a reciprocal. See G.2.1(16).
8642 Not relevant, division is IEEE exact.
8647 @strong{125}. The definition of close result set, which determines the
8648 accuracy of certain fixed point multiplications and divisions. See
8652 Operations in the close result set are performed using IEEE long format
8653 floating-point arithmetic. The input operands are converted to
8654 floating-point, the operation is done in floating-point, and the result
8655 is converted to the target type.
8660 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
8661 point multiplication or division for which the result shall be in the
8662 perfect result set. See G.2.3(22).
8665 The result is only defined to be in the perfect result set if the result
8666 can be computed by a single scaling operation involving a scale factor
8667 representable in 64-bits.
8672 @strong{127}. The result of a fixed point arithmetic operation in
8673 overflow situations, when the @code{Machine_Overflows} attribute of the
8674 result type is @code{False}. See G.2.3(27).
8677 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8683 @strong{128}. The result of an elementary function reference in
8684 overflow situations, when the @code{Machine_Overflows} attribute of the
8685 result type is @code{False}. See G.2.4(4).
8688 IEEE infinite and Nan values are produced as appropriate.
8693 @strong{129}. The value of the angle threshold, within which certain
8694 elementary functions, complex arithmetic operations, and complex
8695 elementary functions yield results conforming to a maximum relative
8696 error bound. See G.2.4(10).
8699 Information on this subject is not yet available.
8704 @strong{130}. The accuracy of certain elementary functions for
8705 parameters beyond the angle threshold. See G.2.4(10).
8708 Information on this subject is not yet available.
8713 @strong{131}. The result of a complex arithmetic operation or complex
8714 elementary function reference in overflow situations, when the
8715 @code{Machine_Overflows} attribute of the corresponding real type is
8716 @code{False}. See G.2.6(5).
8719 IEEE infinite and Nan values are produced as appropriate.
8724 @strong{132}. The accuracy of certain complex arithmetic operations and
8725 certain complex elementary functions for parameters (or components
8726 thereof) beyond the angle threshold. See G.2.6(8).
8729 Information on those subjects is not yet available.
8734 @strong{133}. Information regarding bounded errors and erroneous
8735 execution. See H.2(1).
8738 Information on this subject is not yet available.
8743 @strong{134}. Implementation-defined aspects of pragma
8744 @code{Inspection_Point}. See H.3.2(8).
8747 Pragma @code{Inspection_Point} ensures that the variable is live and can
8748 be examined by the debugger at the inspection point.
8753 @strong{135}. Implementation-defined aspects of pragma
8754 @code{Restrictions}. See H.4(25).
8757 There are no implementation-defined aspects of pragma @code{Restrictions}. The
8758 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8759 generated code. Checks must suppressed by use of pragma @code{Suppress}.
8764 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
8768 There are no restrictions on pragma @code{Restrictions}.
8770 @node Intrinsic Subprograms
8771 @chapter Intrinsic Subprograms
8772 @cindex Intrinsic Subprograms
8775 * Intrinsic Operators::
8776 * Enclosing_Entity::
8777 * Exception_Information::
8778 * Exception_Message::
8786 * Shift_Right_Arithmetic::
8791 GNAT allows a user application program to write the declaration:
8793 @smallexample @c ada
8794 pragma Import (Intrinsic, name);
8798 providing that the name corresponds to one of the implemented intrinsic
8799 subprograms in GNAT, and that the parameter profile of the referenced
8800 subprogram meets the requirements. This chapter describes the set of
8801 implemented intrinsic subprograms, and the requirements on parameter profiles.
8802 Note that no body is supplied; as with other uses of pragma Import, the
8803 body is supplied elsewhere (in this case by the compiler itself). Note
8804 that any use of this feature is potentially non-portable, since the
8805 Ada standard does not require Ada compilers to implement this feature.
8807 @node Intrinsic Operators
8808 @section Intrinsic Operators
8809 @cindex Intrinsic operator
8812 All the predefined numeric operators in package Standard
8813 in @code{pragma Import (Intrinsic,..)}
8814 declarations. In the binary operator case, the operands must have the same
8815 size. The operand or operands must also be appropriate for
8816 the operator. For example, for addition, the operands must
8817 both be floating-point or both be fixed-point, and the
8818 right operand for @code{"**"} must have a root type of
8819 @code{Standard.Integer'Base}.
8820 You can use an intrinsic operator declaration as in the following example:
8822 @smallexample @c ada
8823 type Int1 is new Integer;
8824 type Int2 is new Integer;
8826 function "+" (X1 : Int1; X2 : Int2) return Int1;
8827 function "+" (X1 : Int1; X2 : Int2) return Int2;
8828 pragma Import (Intrinsic, "+");
8832 This declaration would permit ``mixed mode'' arithmetic on items
8833 of the differing types @code{Int1} and @code{Int2}.
8834 It is also possible to specify such operators for private types, if the
8835 full views are appropriate arithmetic types.
8837 @node Enclosing_Entity
8838 @section Enclosing_Entity
8839 @cindex Enclosing_Entity
8841 This intrinsic subprogram is used in the implementation of the
8842 library routine @code{GNAT.Source_Info}. The only useful use of the
8843 intrinsic import in this case is the one in this unit, so an
8844 application program should simply call the function
8845 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8846 the current subprogram, package, task, entry, or protected subprogram.
8848 @node Exception_Information
8849 @section Exception_Information
8850 @cindex Exception_Information'
8852 This intrinsic subprogram is used in the implementation of the
8853 library routine @code{GNAT.Current_Exception}. The only useful
8854 use of the intrinsic import in this case is the one in this unit,
8855 so an application program should simply call the function
8856 @code{GNAT.Current_Exception.Exception_Information} to obtain
8857 the exception information associated with the current exception.
8859 @node Exception_Message
8860 @section Exception_Message
8861 @cindex Exception_Message
8863 This intrinsic subprogram is used in the implementation of the
8864 library routine @code{GNAT.Current_Exception}. The only useful
8865 use of the intrinsic import in this case is the one in this unit,
8866 so an application program should simply call the function
8867 @code{GNAT.Current_Exception.Exception_Message} to obtain
8868 the message associated with the current exception.
8870 @node Exception_Name
8871 @section Exception_Name
8872 @cindex Exception_Name
8874 This intrinsic subprogram is used in the implementation of the
8875 library routine @code{GNAT.Current_Exception}. The only useful
8876 use of the intrinsic import in this case is the one in this unit,
8877 so an application program should simply call the function
8878 @code{GNAT.Current_Exception.Exception_Name} to obtain
8879 the name of the current exception.
8885 This intrinsic subprogram is used in the implementation of the
8886 library routine @code{GNAT.Source_Info}. The only useful use of the
8887 intrinsic import in this case is the one in this unit, so an
8888 application program should simply call the function
8889 @code{GNAT.Source_Info.File} to obtain the name of the current
8896 This intrinsic subprogram is used in the implementation of the
8897 library routine @code{GNAT.Source_Info}. The only useful use of the
8898 intrinsic import in this case is the one in this unit, so an
8899 application program should simply call the function
8900 @code{GNAT.Source_Info.Line} to obtain the number of the current
8904 @section Rotate_Left
8907 In standard Ada, the @code{Rotate_Left} function is available only
8908 for the predefined modular types in package @code{Interfaces}. However, in
8909 GNAT it is possible to define a Rotate_Left function for a user
8910 defined modular type or any signed integer type as in this example:
8912 @smallexample @c ada
8914 (Value : My_Modular_Type;
8916 return My_Modular_Type;
8920 The requirements are that the profile be exactly as in the example
8921 above. The only modifications allowed are in the formal parameter
8922 names, and in the type of @code{Value} and the return type, which
8923 must be the same, and must be either a signed integer type, or
8924 a modular integer type with a binary modulus, and the size must
8925 be 8. 16, 32 or 64 bits.
8928 @section Rotate_Right
8929 @cindex Rotate_Right
8931 A @code{Rotate_Right} function can be defined for any user defined
8932 binary modular integer type, or signed integer type, as described
8933 above for @code{Rotate_Left}.
8939 A @code{Shift_Left} function can be defined for any user defined
8940 binary modular integer type, or signed integer type, as described
8941 above for @code{Rotate_Left}.
8944 @section Shift_Right
8947 A @code{Shift_Right} function can be defined for any user defined
8948 binary modular integer type, or signed integer type, as described
8949 above for @code{Rotate_Left}.
8951 @node Shift_Right_Arithmetic
8952 @section Shift_Right_Arithmetic
8953 @cindex Shift_Right_Arithmetic
8955 A @code{Shift_Right_Arithmetic} function can be defined for any user
8956 defined binary modular integer type, or signed integer type, as described
8957 above for @code{Rotate_Left}.
8959 @node Source_Location
8960 @section Source_Location
8961 @cindex Source_Location
8963 This intrinsic subprogram is used in the implementation of the
8964 library routine @code{GNAT.Source_Info}. The only useful use of the
8965 intrinsic import in this case is the one in this unit, so an
8966 application program should simply call the function
8967 @code{GNAT.Source_Info.Source_Location} to obtain the current
8968 source file location.
8970 @node Representation Clauses and Pragmas
8971 @chapter Representation Clauses and Pragmas
8972 @cindex Representation Clauses
8975 * Alignment Clauses::
8977 * Storage_Size Clauses::
8978 * Size of Variant Record Objects::
8979 * Biased Representation ::
8980 * Value_Size and Object_Size Clauses::
8981 * Component_Size Clauses::
8982 * Bit_Order Clauses::
8983 * Effect of Bit_Order on Byte Ordering::
8984 * Pragma Pack for Arrays::
8985 * Pragma Pack for Records::
8986 * Record Representation Clauses::
8987 * Enumeration Clauses::
8989 * Effect of Convention on Representation::
8990 * Determining the Representations chosen by GNAT::
8994 @cindex Representation Clause
8995 @cindex Representation Pragma
8996 @cindex Pragma, representation
8997 This section describes the representation clauses accepted by GNAT, and
8998 their effect on the representation of corresponding data objects.
9000 GNAT fully implements Annex C (Systems Programming). This means that all
9001 the implementation advice sections in chapter 13 are fully implemented.
9002 However, these sections only require a minimal level of support for
9003 representation clauses. GNAT provides much more extensive capabilities,
9004 and this section describes the additional capabilities provided.
9006 @node Alignment Clauses
9007 @section Alignment Clauses
9008 @cindex Alignment Clause
9011 GNAT requires that all alignment clauses specify a power of 2, and all
9012 default alignments are always a power of 2. The default alignment
9013 values are as follows:
9016 @item @emph{Primitive Types}.
9017 For primitive types, the alignment is the minimum of the actual size of
9018 objects of the type divided by @code{Storage_Unit},
9019 and the maximum alignment supported by the target.
9020 (This maximum alignment is given by the GNAT-specific attribute
9021 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9022 @cindex @code{Maximum_Alignment} attribute
9023 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9024 default alignment will be 8 on any target that supports alignments
9025 this large, but on some targets, the maximum alignment may be smaller
9026 than 8, in which case objects of type @code{Long_Float} will be maximally
9029 @item @emph{Arrays}.
9030 For arrays, the alignment is equal to the alignment of the component type
9031 for the normal case where no packing or component size is given. If the
9032 array is packed, and the packing is effective (see separate section on
9033 packed arrays), then the alignment will be one for long packed arrays,
9034 or arrays whose length is not known at compile time. For short packed
9035 arrays, which are handled internally as modular types, the alignment
9036 will be as described for primitive types, e.g.@: a packed array of length
9037 31 bits will have an object size of four bytes, and an alignment of 4.
9039 @item @emph{Records}.
9040 For the normal non-packed case, the alignment of a record is equal to
9041 the maximum alignment of any of its components. For tagged records, this
9042 includes the implicit access type used for the tag. If a pragma @code{Pack} is
9043 used and all fields are packable (see separate section on pragma @code{Pack}),
9044 then the resulting alignment is 1.
9046 A special case is when:
9049 the size of the record is given explicitly, or a
9050 full record representation clause is given, and
9052 the size of the record is 2, 4, or 8 bytes.
9055 In this case, an alignment is chosen to match the
9056 size of the record. For example, if we have:
9058 @smallexample @c ada
9059 type Small is record
9062 for Small'Size use 16;
9066 then the default alignment of the record type @code{Small} is 2, not 1. This
9067 leads to more efficient code when the record is treated as a unit, and also
9068 allows the type to specified as @code{Atomic} on architectures requiring
9074 An alignment clause may specify a larger alignment than the default value
9075 up to some maximum value dependent on the target (obtainable by using the
9076 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9077 a smaller alignment than the default value, for example
9079 @smallexample @c ada
9084 for V'alignment use 1;
9088 @cindex Alignment, default
9089 The default alignment for the type @code{V} is 4, as a result of the
9090 Integer field in the record, but it is permissible, as shown, to
9091 override the default alignment of the record with a smaller value.
9094 @section Size Clauses
9098 The default size for a type @code{T} is obtainable through the
9099 language-defined attribute @code{T'Size} and also through the
9100 equivalent GNAT-defined attribute @code{T'Value_Size}.
9101 For objects of type @code{T}, GNAT will generally increase the type size
9102 so that the object size (obtainable through the GNAT-defined attribute
9103 @code{T'Object_Size})
9104 is a multiple of @code{T'Alignment * Storage_Unit}.
9107 @smallexample @c ada
9108 type Smallint is range 1 .. 6;
9117 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9118 as specified by the RM rules,
9119 but objects of this type will have a size of 8
9120 (@code{Smallint'Object_Size} = 8),
9121 since objects by default occupy an integral number
9122 of storage units. On some targets, notably older
9123 versions of the Digital Alpha, the size of stand
9124 alone objects of this type may be 32, reflecting
9125 the inability of the hardware to do byte load/stores.
9127 Similarly, the size of type @code{Rec} is 40 bits
9128 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9129 the alignment is 4, so objects of this type will have
9130 their size increased to 64 bits so that it is a multiple
9131 of the alignment (in bits). This decision is
9132 in accordance with the specific Implementation Advice in RM 13.3(43):
9135 A @code{Size} clause should be supported for an object if the specified
9136 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9137 to a size in storage elements that is a multiple of the object's
9138 @code{Alignment} (if the @code{Alignment} is nonzero).
9142 An explicit size clause may be used to override the default size by
9143 increasing it. For example, if we have:
9145 @smallexample @c ada
9146 type My_Boolean is new Boolean;
9147 for My_Boolean'Size use 32;
9151 then values of this type will always be 32 bits long. In the case of
9152 discrete types, the size can be increased up to 64 bits, with the effect
9153 that the entire specified field is used to hold the value, sign- or
9154 zero-extended as appropriate. If more than 64 bits is specified, then
9155 padding space is allocated after the value, and a warning is issued that
9156 there are unused bits.
9158 Similarly the size of records and arrays may be increased, and the effect
9159 is to add padding bits after the value. This also causes a warning message
9162 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
9163 Size in bits, this corresponds to an object of size 256 megabytes (minus
9164 one). This limitation is true on all targets. The reason for this
9165 limitation is that it improves the quality of the code in many cases
9166 if it is known that a Size value can be accommodated in an object of
9169 @node Storage_Size Clauses
9170 @section Storage_Size Clauses
9171 @cindex Storage_Size Clause
9174 For tasks, the @code{Storage_Size} clause specifies the amount of space
9175 to be allocated for the task stack. This cannot be extended, and if the
9176 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9177 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
9178 or a @code{Storage_Size} pragma in the task definition to set the
9179 appropriate required size. A useful technique is to include in every
9180 task definition a pragma of the form:
9182 @smallexample @c ada
9183 pragma Storage_Size (Default_Stack_Size);
9187 Then @code{Default_Stack_Size} can be defined in a global package, and
9188 modified as required. Any tasks requiring stack sizes different from the
9189 default can have an appropriate alternative reference in the pragma.
9191 You can also use the @code{-d} binder switch to modify the default stack
9194 For access types, the @code{Storage_Size} clause specifies the maximum
9195 space available for allocation of objects of the type. If this space is
9196 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9197 In the case where the access type is declared local to a subprogram, the
9198 use of a @code{Storage_Size} clause triggers automatic use of a special
9199 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9200 space for the pool is automatically reclaimed on exit from the scope in
9201 which the type is declared.
9203 A special case recognized by the compiler is the specification of a
9204 @code{Storage_Size} of zero for an access type. This means that no
9205 items can be allocated from the pool, and this is recognized at compile
9206 time, and all the overhead normally associated with maintaining a fixed
9207 size storage pool is eliminated. Consider the following example:
9209 @smallexample @c ada
9211 type R is array (Natural) of Character;
9212 type P is access all R;
9213 for P'Storage_Size use 0;
9214 -- Above access type intended only for interfacing purposes
9218 procedure g (m : P);
9219 pragma Import (C, g);
9230 As indicated in this example, these dummy storage pools are often useful in
9231 connection with interfacing where no object will ever be allocated. If you
9232 compile the above example, you get the warning:
9235 p.adb:16:09: warning: allocation from empty storage pool
9236 p.adb:16:09: warning: Storage_Error will be raised at run time
9240 Of course in practice, there will not be any explicit allocators in the
9241 case of such an access declaration.
9243 @node Size of Variant Record Objects
9244 @section Size of Variant Record Objects
9245 @cindex Size, variant record objects
9246 @cindex Variant record objects, size
9249 In the case of variant record objects, there is a question whether Size gives
9250 information about a particular variant, or the maximum size required
9251 for any variant. Consider the following program
9253 @smallexample @c ada
9254 with Text_IO; use Text_IO;
9256 type R1 (A : Boolean := False) is record
9258 when True => X : Character;
9267 Put_Line (Integer'Image (V1'Size));
9268 Put_Line (Integer'Image (V2'Size));
9273 Here we are dealing with a variant record, where the True variant
9274 requires 16 bits, and the False variant requires 8 bits.
9275 In the above example, both V1 and V2 contain the False variant,
9276 which is only 8 bits long. However, the result of running the
9285 The reason for the difference here is that the discriminant value of
9286 V1 is fixed, and will always be False. It is not possible to assign
9287 a True variant value to V1, therefore 8 bits is sufficient. On the
9288 other hand, in the case of V2, the initial discriminant value is
9289 False (from the default), but it is possible to assign a True
9290 variant value to V2, therefore 16 bits must be allocated for V2
9291 in the general case, even fewer bits may be needed at any particular
9292 point during the program execution.
9294 As can be seen from the output of this program, the @code{'Size}
9295 attribute applied to such an object in GNAT gives the actual allocated
9296 size of the variable, which is the largest size of any of the variants.
9297 The Ada Reference Manual is not completely clear on what choice should
9298 be made here, but the GNAT behavior seems most consistent with the
9299 language in the RM@.
9301 In some cases, it may be desirable to obtain the size of the current
9302 variant, rather than the size of the largest variant. This can be
9303 achieved in GNAT by making use of the fact that in the case of a
9304 subprogram parameter, GNAT does indeed return the size of the current
9305 variant (because a subprogram has no way of knowing how much space
9306 is actually allocated for the actual).
9308 Consider the following modified version of the above program:
9310 @smallexample @c ada
9311 with Text_IO; use Text_IO;
9313 type R1 (A : Boolean := False) is record
9315 when True => X : Character;
9322 function Size (V : R1) return Integer is
9328 Put_Line (Integer'Image (V2'Size));
9329 Put_Line (Integer'IMage (Size (V2)));
9331 Put_Line (Integer'Image (V2'Size));
9332 Put_Line (Integer'IMage (Size (V2)));
9337 The output from this program is
9347 Here we see that while the @code{'Size} attribute always returns
9348 the maximum size, regardless of the current variant value, the
9349 @code{Size} function does indeed return the size of the current
9352 @node Biased Representation
9353 @section Biased Representation
9354 @cindex Size for biased representation
9355 @cindex Biased representation
9358 In the case of scalars with a range starting at other than zero, it is
9359 possible in some cases to specify a size smaller than the default minimum
9360 value, and in such cases, GNAT uses an unsigned biased representation,
9361 in which zero is used to represent the lower bound, and successive values
9362 represent successive values of the type.
9364 For example, suppose we have the declaration:
9366 @smallexample @c ada
9367 type Small is range -7 .. -4;
9368 for Small'Size use 2;
9372 Although the default size of type @code{Small} is 4, the @code{Size}
9373 clause is accepted by GNAT and results in the following representation
9377 -7 is represented as 2#00#
9378 -6 is represented as 2#01#
9379 -5 is represented as 2#10#
9380 -4 is represented as 2#11#
9384 Biased representation is only used if the specified @code{Size} clause
9385 cannot be accepted in any other manner. These reduced sizes that force
9386 biased representation can be used for all discrete types except for
9387 enumeration types for which a representation clause is given.
9389 @node Value_Size and Object_Size Clauses
9390 @section Value_Size and Object_Size Clauses
9393 @cindex Size, of objects
9396 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
9397 number of bits required to hold values of type @code{T}.
9398 Although this interpretation was allowed in Ada 83, it was not required,
9399 and this requirement in practice can cause some significant difficulties.
9400 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
9401 However, in Ada 95 and Ada 2005,
9402 @code{Natural'Size} is
9403 typically 31. This means that code may change in behavior when moving
9404 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
9406 @smallexample @c ada
9413 at 0 range 0 .. Natural'Size - 1;
9414 at 0 range Natural'Size .. 2 * Natural'Size - 1;
9419 In the above code, since the typical size of @code{Natural} objects
9420 is 32 bits and @code{Natural'Size} is 31, the above code can cause
9421 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
9422 there are cases where the fact that the object size can exceed the
9423 size of the type causes surprises.
9425 To help get around this problem GNAT provides two implementation
9426 defined attributes, @code{Value_Size} and @code{Object_Size}. When
9427 applied to a type, these attributes yield the size of the type
9428 (corresponding to the RM defined size attribute), and the size of
9429 objects of the type respectively.
9431 The @code{Object_Size} is used for determining the default size of
9432 objects and components. This size value can be referred to using the
9433 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
9434 the basis of the determination of the size. The backend is free to
9435 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
9436 character might be stored in 32 bits on a machine with no efficient
9437 byte access instructions such as the Alpha.
9439 The default rules for the value of @code{Object_Size} for
9440 discrete types are as follows:
9444 The @code{Object_Size} for base subtypes reflect the natural hardware
9445 size in bits (run the compiler with @option{-gnatS} to find those values
9446 for numeric types). Enumeration types and fixed-point base subtypes have
9447 8, 16, 32 or 64 bits for this size, depending on the range of values
9451 The @code{Object_Size} of a subtype is the same as the
9452 @code{Object_Size} of
9453 the type from which it is obtained.
9456 The @code{Object_Size} of a derived base type is copied from the parent
9457 base type, and the @code{Object_Size} of a derived first subtype is copied
9458 from the parent first subtype.
9462 The @code{Value_Size} attribute
9463 is the (minimum) number of bits required to store a value
9465 This value is used to determine how tightly to pack
9466 records or arrays with components of this type, and also affects
9467 the semantics of unchecked conversion (unchecked conversions where
9468 the @code{Value_Size} values differ generate a warning, and are potentially
9471 The default rules for the value of @code{Value_Size} are as follows:
9475 The @code{Value_Size} for a base subtype is the minimum number of bits
9476 required to store all values of the type (including the sign bit
9477 only if negative values are possible).
9480 If a subtype statically matches the first subtype of a given type, then it has
9481 by default the same @code{Value_Size} as the first subtype. This is a
9482 consequence of RM 13.1(14) (``if two subtypes statically match,
9483 then their subtype-specific aspects are the same''.)
9486 All other subtypes have a @code{Value_Size} corresponding to the minimum
9487 number of bits required to store all values of the subtype. For
9488 dynamic bounds, it is assumed that the value can range down or up
9489 to the corresponding bound of the ancestor
9493 The RM defined attribute @code{Size} corresponds to the
9494 @code{Value_Size} attribute.
9496 The @code{Size} attribute may be defined for a first-named subtype. This sets
9497 the @code{Value_Size} of
9498 the first-named subtype to the given value, and the
9499 @code{Object_Size} of this first-named subtype to the given value padded up
9500 to an appropriate boundary. It is a consequence of the default rules
9501 above that this @code{Object_Size} will apply to all further subtypes. On the
9502 other hand, @code{Value_Size} is affected only for the first subtype, any
9503 dynamic subtypes obtained from it directly, and any statically matching
9504 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
9506 @code{Value_Size} and
9507 @code{Object_Size} may be explicitly set for any subtype using
9508 an attribute definition clause. Note that the use of these attributes
9509 can cause the RM 13.1(14) rule to be violated. If two access types
9510 reference aliased objects whose subtypes have differing @code{Object_Size}
9511 values as a result of explicit attribute definition clauses, then it
9512 is erroneous to convert from one access subtype to the other.
9514 At the implementation level, Esize stores the Object_Size and the
9515 RM_Size field stores the @code{Value_Size} (and hence the value of the
9516 @code{Size} attribute,
9517 which, as noted above, is equivalent to @code{Value_Size}).
9519 To get a feel for the difference, consider the following examples (note
9520 that in each case the base is @code{Short_Short_Integer} with a size of 8):
9523 Object_Size Value_Size
9525 type x1 is range 0 .. 5; 8 3
9527 type x2 is range 0 .. 5;
9528 for x2'size use 12; 16 12
9530 subtype x3 is x2 range 0 .. 3; 16 2
9532 subtype x4 is x2'base range 0 .. 10; 8 4
9534 subtype x5 is x2 range 0 .. dynamic; 16 3*
9536 subtype x6 is x2'base range 0 .. dynamic; 8 3*
9541 Note: the entries marked ``3*'' are not actually specified by the Ada
9542 Reference Manual, but it seems in the spirit of the RM rules to allocate
9543 the minimum number of bits (here 3, given the range for @code{x2})
9544 known to be large enough to hold the given range of values.
9546 So far, so good, but GNAT has to obey the RM rules, so the question is
9547 under what conditions must the RM @code{Size} be used.
9548 The following is a list
9549 of the occasions on which the RM @code{Size} must be used:
9553 Component size for packed arrays or records
9556 Value of the attribute @code{Size} for a type
9559 Warning about sizes not matching for unchecked conversion
9563 For record types, the @code{Object_Size} is always a multiple of the
9564 alignment of the type (this is true for all types). In some cases the
9565 @code{Value_Size} can be smaller. Consider:
9575 On a typical 32-bit architecture, the X component will be four bytes, and
9576 require four-byte alignment, and the Y component will be one byte. In this
9577 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
9578 required to store a value of this type, and for example, it is permissible
9579 to have a component of type R in an outer record whose component size is
9580 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9581 since it must be rounded up so that this value is a multiple of the
9582 alignment (4 bytes = 32 bits).
9585 For all other types, the @code{Object_Size}
9586 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9587 Only @code{Size} may be specified for such types.
9589 @node Component_Size Clauses
9590 @section Component_Size Clauses
9591 @cindex Component_Size Clause
9594 Normally, the value specified in a component size clause must be consistent
9595 with the subtype of the array component with regard to size and alignment.
9596 In other words, the value specified must be at least equal to the size
9597 of this subtype, and must be a multiple of the alignment value.
9599 In addition, component size clauses are allowed which cause the array
9600 to be packed, by specifying a smaller value. The cases in which this
9601 is allowed are for component size values in the range 1 through 63. The value
9602 specified must not be smaller than the Size of the subtype. GNAT will
9603 accurately honor all packing requests in this range. For example, if
9606 @smallexample @c ada
9607 type r is array (1 .. 8) of Natural;
9608 for r'Component_Size use 31;
9612 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9613 Of course access to the components of such an array is considerably
9614 less efficient than if the natural component size of 32 is used.
9616 Note that there is no point in giving both a component size clause
9617 and a pragma Pack for the same array type. if such duplicate
9618 clauses are given, the pragma Pack will be ignored.
9620 @node Bit_Order Clauses
9621 @section Bit_Order Clauses
9622 @cindex Bit_Order Clause
9623 @cindex bit ordering
9624 @cindex ordering, of bits
9627 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9628 attribute. The specification may either correspond to the default bit
9629 order for the target, in which case the specification has no effect and
9630 places no additional restrictions, or it may be for the non-standard
9631 setting (that is the opposite of the default).
9633 In the case where the non-standard value is specified, the effect is
9634 to renumber bits within each byte, but the ordering of bytes is not
9635 affected. There are certain
9636 restrictions placed on component clauses as follows:
9640 @item Components fitting within a single storage unit.
9642 These are unrestricted, and the effect is merely to renumber bits. For
9643 example if we are on a little-endian machine with @code{Low_Order_First}
9644 being the default, then the following two declarations have exactly
9647 @smallexample @c ada
9650 B : Integer range 1 .. 120;
9654 A at 0 range 0 .. 0;
9655 B at 0 range 1 .. 7;
9660 B : Integer range 1 .. 120;
9663 for R2'Bit_Order use High_Order_First;
9666 A at 0 range 7 .. 7;
9667 B at 0 range 0 .. 6;
9672 The useful application here is to write the second declaration with the
9673 @code{Bit_Order} attribute definition clause, and know that it will be treated
9674 the same, regardless of whether the target is little-endian or big-endian.
9676 @item Components occupying an integral number of bytes.
9678 These are components that exactly fit in two or more bytes. Such component
9679 declarations are allowed, but have no effect, since it is important to realize
9680 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9681 In particular, the following attempt at getting an endian-independent integer
9684 @smallexample @c ada
9689 for R2'Bit_Order use High_Order_First;
9692 A at 0 range 0 .. 31;
9697 This declaration will result in a little-endian integer on a
9698 little-endian machine, and a big-endian integer on a big-endian machine.
9699 If byte flipping is required for interoperability between big- and
9700 little-endian machines, this must be explicitly programmed. This capability
9701 is not provided by @code{Bit_Order}.
9703 @item Components that are positioned across byte boundaries
9705 but do not occupy an integral number of bytes. Given that bytes are not
9706 reordered, such fields would occupy a non-contiguous sequence of bits
9707 in memory, requiring non-trivial code to reassemble. They are for this
9708 reason not permitted, and any component clause specifying such a layout
9709 will be flagged as illegal by GNAT@.
9714 Since the misconception that Bit_Order automatically deals with all
9715 endian-related incompatibilities is a common one, the specification of
9716 a component field that is an integral number of bytes will always
9717 generate a warning. This warning may be suppressed using
9718 @code{pragma Suppress} if desired. The following section contains additional
9719 details regarding the issue of byte ordering.
9721 @node Effect of Bit_Order on Byte Ordering
9722 @section Effect of Bit_Order on Byte Ordering
9723 @cindex byte ordering
9724 @cindex ordering, of bytes
9727 In this section we will review the effect of the @code{Bit_Order} attribute
9728 definition clause on byte ordering. Briefly, it has no effect at all, but
9729 a detailed example will be helpful. Before giving this
9730 example, let us review the precise
9731 definition of the effect of defining @code{Bit_Order}. The effect of a
9732 non-standard bit order is described in section 15.5.3 of the Ada
9736 2 A bit ordering is a method of interpreting the meaning of
9737 the storage place attributes.
9741 To understand the precise definition of storage place attributes in
9742 this context, we visit section 13.5.1 of the manual:
9745 13 A record_representation_clause (without the mod_clause)
9746 specifies the layout. The storage place attributes (see 13.5.2)
9747 are taken from the values of the position, first_bit, and last_bit
9748 expressions after normalizing those values so that first_bit is
9749 less than Storage_Unit.
9753 The critical point here is that storage places are taken from
9754 the values after normalization, not before. So the @code{Bit_Order}
9755 interpretation applies to normalized values. The interpretation
9756 is described in the later part of the 15.5.3 paragraph:
9759 2 A bit ordering is a method of interpreting the meaning of
9760 the storage place attributes. High_Order_First (known in the
9761 vernacular as ``big endian'') means that the first bit of a
9762 storage element (bit 0) is the most significant bit (interpreting
9763 the sequence of bits that represent a component as an unsigned
9764 integer value). Low_Order_First (known in the vernacular as
9765 ``little endian'') means the opposite: the first bit is the
9770 Note that the numbering is with respect to the bits of a storage
9771 unit. In other words, the specification affects only the numbering
9772 of bits within a single storage unit.
9774 We can make the effect clearer by giving an example.
9776 Suppose that we have an external device which presents two bytes, the first
9777 byte presented, which is the first (low addressed byte) of the two byte
9778 record is called Master, and the second byte is called Slave.
9780 The left most (most significant bit is called Control for each byte, and
9781 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9782 (least significant) bit.
9784 On a big-endian machine, we can write the following representation clause
9786 @smallexample @c ada
9788 Master_Control : Bit;
9796 Slave_Control : Bit;
9807 Master_Control at 0 range 0 .. 0;
9808 Master_V1 at 0 range 1 .. 1;
9809 Master_V2 at 0 range 2 .. 2;
9810 Master_V3 at 0 range 3 .. 3;
9811 Master_V4 at 0 range 4 .. 4;
9812 Master_V5 at 0 range 5 .. 5;
9813 Master_V6 at 0 range 6 .. 6;
9814 Master_V7 at 0 range 7 .. 7;
9815 Slave_Control at 1 range 0 .. 0;
9816 Slave_V1 at 1 range 1 .. 1;
9817 Slave_V2 at 1 range 2 .. 2;
9818 Slave_V3 at 1 range 3 .. 3;
9819 Slave_V4 at 1 range 4 .. 4;
9820 Slave_V5 at 1 range 5 .. 5;
9821 Slave_V6 at 1 range 6 .. 6;
9822 Slave_V7 at 1 range 7 .. 7;
9827 Now if we move this to a little endian machine, then the bit ordering within
9828 the byte is backwards, so we have to rewrite the record rep clause as:
9830 @smallexample @c ada
9832 Master_Control at 0 range 7 .. 7;
9833 Master_V1 at 0 range 6 .. 6;
9834 Master_V2 at 0 range 5 .. 5;
9835 Master_V3 at 0 range 4 .. 4;
9836 Master_V4 at 0 range 3 .. 3;
9837 Master_V5 at 0 range 2 .. 2;
9838 Master_V6 at 0 range 1 .. 1;
9839 Master_V7 at 0 range 0 .. 0;
9840 Slave_Control at 1 range 7 .. 7;
9841 Slave_V1 at 1 range 6 .. 6;
9842 Slave_V2 at 1 range 5 .. 5;
9843 Slave_V3 at 1 range 4 .. 4;
9844 Slave_V4 at 1 range 3 .. 3;
9845 Slave_V5 at 1 range 2 .. 2;
9846 Slave_V6 at 1 range 1 .. 1;
9847 Slave_V7 at 1 range 0 .. 0;
9852 It is a nuisance to have to rewrite the clause, especially if
9853 the code has to be maintained on both machines. However,
9854 this is a case that we can handle with the
9855 @code{Bit_Order} attribute if it is implemented.
9856 Note that the implementation is not required on byte addressed
9857 machines, but it is indeed implemented in GNAT.
9858 This means that we can simply use the
9859 first record clause, together with the declaration
9861 @smallexample @c ada
9862 for Data'Bit_Order use High_Order_First;
9866 and the effect is what is desired, namely the layout is exactly the same,
9867 independent of whether the code is compiled on a big-endian or little-endian
9870 The important point to understand is that byte ordering is not affected.
9871 A @code{Bit_Order} attribute definition never affects which byte a field
9872 ends up in, only where it ends up in that byte.
9873 To make this clear, let us rewrite the record rep clause of the previous
9876 @smallexample @c ada
9877 for Data'Bit_Order use High_Order_First;
9879 Master_Control at 0 range 0 .. 0;
9880 Master_V1 at 0 range 1 .. 1;
9881 Master_V2 at 0 range 2 .. 2;
9882 Master_V3 at 0 range 3 .. 3;
9883 Master_V4 at 0 range 4 .. 4;
9884 Master_V5 at 0 range 5 .. 5;
9885 Master_V6 at 0 range 6 .. 6;
9886 Master_V7 at 0 range 7 .. 7;
9887 Slave_Control at 0 range 8 .. 8;
9888 Slave_V1 at 0 range 9 .. 9;
9889 Slave_V2 at 0 range 10 .. 10;
9890 Slave_V3 at 0 range 11 .. 11;
9891 Slave_V4 at 0 range 12 .. 12;
9892 Slave_V5 at 0 range 13 .. 13;
9893 Slave_V6 at 0 range 14 .. 14;
9894 Slave_V7 at 0 range 15 .. 15;
9899 This is exactly equivalent to saying (a repeat of the first example):
9901 @smallexample @c ada
9902 for Data'Bit_Order use High_Order_First;
9904 Master_Control at 0 range 0 .. 0;
9905 Master_V1 at 0 range 1 .. 1;
9906 Master_V2 at 0 range 2 .. 2;
9907 Master_V3 at 0 range 3 .. 3;
9908 Master_V4 at 0 range 4 .. 4;
9909 Master_V5 at 0 range 5 .. 5;
9910 Master_V6 at 0 range 6 .. 6;
9911 Master_V7 at 0 range 7 .. 7;
9912 Slave_Control at 1 range 0 .. 0;
9913 Slave_V1 at 1 range 1 .. 1;
9914 Slave_V2 at 1 range 2 .. 2;
9915 Slave_V3 at 1 range 3 .. 3;
9916 Slave_V4 at 1 range 4 .. 4;
9917 Slave_V5 at 1 range 5 .. 5;
9918 Slave_V6 at 1 range 6 .. 6;
9919 Slave_V7 at 1 range 7 .. 7;
9924 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9925 field. The storage place attributes are obtained by normalizing the
9926 values given so that the @code{First_Bit} value is less than 8. After
9927 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9928 we specified in the other case.
9930 Now one might expect that the @code{Bit_Order} attribute might affect
9931 bit numbering within the entire record component (two bytes in this
9932 case, thus affecting which byte fields end up in), but that is not
9933 the way this feature is defined, it only affects numbering of bits,
9934 not which byte they end up in.
9936 Consequently it never makes sense to specify a starting bit number
9937 greater than 7 (for a byte addressable field) if an attribute
9938 definition for @code{Bit_Order} has been given, and indeed it
9939 may be actively confusing to specify such a value, so the compiler
9940 generates a warning for such usage.
9942 If you do need to control byte ordering then appropriate conditional
9943 values must be used. If in our example, the slave byte came first on
9944 some machines we might write:
9946 @smallexample @c ada
9947 Master_Byte_First constant Boolean := @dots{};
9949 Master_Byte : constant Natural :=
9950 1 - Boolean'Pos (Master_Byte_First);
9951 Slave_Byte : constant Natural :=
9952 Boolean'Pos (Master_Byte_First);
9954 for Data'Bit_Order use High_Order_First;
9956 Master_Control at Master_Byte range 0 .. 0;
9957 Master_V1 at Master_Byte range 1 .. 1;
9958 Master_V2 at Master_Byte range 2 .. 2;
9959 Master_V3 at Master_Byte range 3 .. 3;
9960 Master_V4 at Master_Byte range 4 .. 4;
9961 Master_V5 at Master_Byte range 5 .. 5;
9962 Master_V6 at Master_Byte range 6 .. 6;
9963 Master_V7 at Master_Byte range 7 .. 7;
9964 Slave_Control at Slave_Byte range 0 .. 0;
9965 Slave_V1 at Slave_Byte range 1 .. 1;
9966 Slave_V2 at Slave_Byte range 2 .. 2;
9967 Slave_V3 at Slave_Byte range 3 .. 3;
9968 Slave_V4 at Slave_Byte range 4 .. 4;
9969 Slave_V5 at Slave_Byte range 5 .. 5;
9970 Slave_V6 at Slave_Byte range 6 .. 6;
9971 Slave_V7 at Slave_Byte range 7 .. 7;
9976 Now to switch between machines, all that is necessary is
9977 to set the boolean constant @code{Master_Byte_First} in
9978 an appropriate manner.
9980 @node Pragma Pack for Arrays
9981 @section Pragma Pack for Arrays
9982 @cindex Pragma Pack (for arrays)
9985 Pragma @code{Pack} applied to an array has no effect unless the component type
9986 is packable. For a component type to be packable, it must be one of the
9993 Any type whose size is specified with a size clause
9995 Any packed array type with a static size
9999 For all these cases, if the component subtype size is in the range
10000 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10001 component size were specified giving the component subtype size.
10002 For example if we have:
10004 @smallexample @c ada
10005 type r is range 0 .. 17;
10007 type ar is array (1 .. 8) of r;
10012 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10013 and the size of the array @code{ar} will be exactly 40 bits.
10015 Note that in some cases this rather fierce approach to packing can produce
10016 unexpected effects. For example, in Ada 95 and Ada 2005,
10017 subtype @code{Natural} typically has a size of 31, meaning that if you
10018 pack an array of @code{Natural}, you get 31-bit
10019 close packing, which saves a few bits, but results in far less efficient
10020 access. Since many other Ada compilers will ignore such a packing request,
10021 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10022 might not be what is intended. You can easily remove this warning by
10023 using an explicit @code{Component_Size} setting instead, which never generates
10024 a warning, since the intention of the programmer is clear in this case.
10026 GNAT treats packed arrays in one of two ways. If the size of the array is
10027 known at compile time and is less than 64 bits, then internally the array
10028 is represented as a single modular type, of exactly the appropriate number
10029 of bits. If the length is greater than 63 bits, or is not known at compile
10030 time, then the packed array is represented as an array of bytes, and the
10031 length is always a multiple of 8 bits.
10033 Note that to represent a packed array as a modular type, the alignment must
10034 be suitable for the modular type involved. For example, on typical machines
10035 a 32-bit packed array will be represented by a 32-bit modular integer with
10036 an alignment of four bytes. If you explicitly override the default alignment
10037 with an alignment clause that is too small, the modular representation
10038 cannot be used. For example, consider the following set of declarations:
10040 @smallexample @c ada
10041 type R is range 1 .. 3;
10042 type S is array (1 .. 31) of R;
10043 for S'Component_Size use 2;
10045 for S'Alignment use 1;
10049 If the alignment clause were not present, then a 62-bit modular
10050 representation would be chosen (typically with an alignment of 4 or 8
10051 bytes depending on the target). But the default alignment is overridden
10052 with the explicit alignment clause. This means that the modular
10053 representation cannot be used, and instead the array of bytes
10054 representation must be used, meaning that the length must be a multiple
10055 of 8. Thus the above set of declarations will result in a diagnostic
10056 rejecting the size clause and noting that the minimum size allowed is 64.
10058 @cindex Pragma Pack (for type Natural)
10059 @cindex Pragma Pack warning
10061 One special case that is worth noting occurs when the base type of the
10062 component size is 8/16/32 and the subtype is one bit less. Notably this
10063 occurs with subtype @code{Natural}. Consider:
10065 @smallexample @c ada
10066 type Arr is array (1 .. 32) of Natural;
10071 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10072 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10073 Ada 83 compilers did not attempt 31 bit packing.
10075 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10076 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10077 substantial unintended performance penalty when porting legacy Ada 83 code.
10078 To help prevent this, GNAT generates a warning in such cases. If you really
10079 want 31 bit packing in a case like this, you can set the component size
10082 @smallexample @c ada
10083 type Arr is array (1 .. 32) of Natural;
10084 for Arr'Component_Size use 31;
10088 Here 31-bit packing is achieved as required, and no warning is generated,
10089 since in this case the programmer intention is clear.
10091 @node Pragma Pack for Records
10092 @section Pragma Pack for Records
10093 @cindex Pragma Pack (for records)
10096 Pragma @code{Pack} applied to a record will pack the components to reduce
10097 wasted space from alignment gaps and by reducing the amount of space
10098 taken by components. We distinguish between @emph{packable} components and
10099 @emph{non-packable} components.
10100 Components of the following types are considered packable:
10103 All primitive types are packable.
10106 Small packed arrays, whose size does not exceed 64 bits, and where the
10107 size is statically known at compile time, are represented internally
10108 as modular integers, and so they are also packable.
10113 All packable components occupy the exact number of bits corresponding to
10114 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10115 can start on an arbitrary bit boundary.
10117 All other types are non-packable, they occupy an integral number of
10119 are placed at a boundary corresponding to their alignment requirements.
10121 For example, consider the record
10123 @smallexample @c ada
10124 type Rb1 is array (1 .. 13) of Boolean;
10127 type Rb2 is array (1 .. 65) of Boolean;
10142 The representation for the record x2 is as follows:
10144 @smallexample @c ada
10145 for x2'Size use 224;
10147 l1 at 0 range 0 .. 0;
10148 l2 at 0 range 1 .. 64;
10149 l3 at 12 range 0 .. 31;
10150 l4 at 16 range 0 .. 0;
10151 l5 at 16 range 1 .. 13;
10152 l6 at 18 range 0 .. 71;
10157 Studying this example, we see that the packable fields @code{l1}
10159 of length equal to their sizes, and placed at specific bit boundaries (and
10160 not byte boundaries) to
10161 eliminate padding. But @code{l3} is of a non-packable float type, so
10162 it is on the next appropriate alignment boundary.
10164 The next two fields are fully packable, so @code{l4} and @code{l5} are
10165 minimally packed with no gaps. However, type @code{Rb2} is a packed
10166 array that is longer than 64 bits, so it is itself non-packable. Thus
10167 the @code{l6} field is aligned to the next byte boundary, and takes an
10168 integral number of bytes, i.e.@: 72 bits.
10170 @node Record Representation Clauses
10171 @section Record Representation Clauses
10172 @cindex Record Representation Clause
10175 Record representation clauses may be given for all record types, including
10176 types obtained by record extension. Component clauses are allowed for any
10177 static component. The restrictions on component clauses depend on the type
10180 @cindex Component Clause
10181 For all components of an elementary type, the only restriction on component
10182 clauses is that the size must be at least the 'Size value of the type
10183 (actually the Value_Size). There are no restrictions due to alignment,
10184 and such components may freely cross storage boundaries.
10186 Packed arrays with a size up to and including 64 bits are represented
10187 internally using a modular type with the appropriate number of bits, and
10188 thus the same lack of restriction applies. For example, if you declare:
10190 @smallexample @c ada
10191 type R is array (1 .. 49) of Boolean;
10197 then a component clause for a component of type R may start on any
10198 specified bit boundary, and may specify a value of 49 bits or greater.
10200 For packed bit arrays that are longer than 64 bits, there are two
10201 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10202 including the important case of single bits or boolean values, then
10203 there are no limitations on placement of such components, and they
10204 may start and end at arbitrary bit boundaries.
10206 If the component size is not a power of 2 (e.g. 3 or 5), then
10207 an array of this type longer than 64 bits must always be placed on
10208 on a storage unit (byte) boundary and occupy an integral number
10209 of storage units (bytes). Any component clause that does not
10210 meet this requirement will be rejected.
10212 Any aliased component, or component of an aliased type, must
10213 have its normal alignment and size. A component clause that
10214 does not meet this requirement will be rejected.
10216 The tag field of a tagged type always occupies an address sized field at
10217 the start of the record. No component clause may attempt to overlay this
10218 tag. When a tagged type appears as a component, the tag field must have
10221 In the case of a record extension T1, of a type T, no component clause applied
10222 to the type T1 can specify a storage location that would overlap the first
10223 T'Size bytes of the record.
10225 For all other component types, including non-bit-packed arrays,
10226 the component can be placed at an arbitrary bit boundary,
10227 so for example, the following is permitted:
10229 @smallexample @c ada
10230 type R is array (1 .. 10) of Boolean;
10239 G at 0 range 0 .. 0;
10240 H at 0 range 1 .. 1;
10241 L at 0 range 2 .. 81;
10242 R at 0 range 82 .. 161;
10247 Note: the above rules apply to recent releases of GNAT 5.
10248 In GNAT 3, there are more severe restrictions on larger components.
10249 For non-primitive types, including packed arrays with a size greater than
10250 64 bits, component clauses must respect the alignment requirement of the
10251 type, in particular, always starting on a byte boundary, and the length
10252 must be a multiple of the storage unit.
10254 @node Enumeration Clauses
10255 @section Enumeration Clauses
10257 The only restriction on enumeration clauses is that the range of values
10258 must be representable. For the signed case, if one or more of the
10259 representation values are negative, all values must be in the range:
10261 @smallexample @c ada
10262 System.Min_Int .. System.Max_Int
10266 For the unsigned case, where all values are non negative, the values must
10269 @smallexample @c ada
10270 0 .. System.Max_Binary_Modulus;
10274 A @emph{confirming} representation clause is one in which the values range
10275 from 0 in sequence, i.e.@: a clause that confirms the default representation
10276 for an enumeration type.
10277 Such a confirming representation
10278 is permitted by these rules, and is specially recognized by the compiler so
10279 that no extra overhead results from the use of such a clause.
10281 If an array has an index type which is an enumeration type to which an
10282 enumeration clause has been applied, then the array is stored in a compact
10283 manner. Consider the declarations:
10285 @smallexample @c ada
10286 type r is (A, B, C);
10287 for r use (A => 1, B => 5, C => 10);
10288 type t is array (r) of Character;
10292 The array type t corresponds to a vector with exactly three elements and
10293 has a default size equal to @code{3*Character'Size}. This ensures efficient
10294 use of space, but means that accesses to elements of the array will incur
10295 the overhead of converting representation values to the corresponding
10296 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
10298 @node Address Clauses
10299 @section Address Clauses
10300 @cindex Address Clause
10302 The reference manual allows a general restriction on representation clauses,
10303 as found in RM 13.1(22):
10306 An implementation need not support representation
10307 items containing nonstatic expressions, except that
10308 an implementation should support a representation item
10309 for a given entity if each nonstatic expression in the
10310 representation item is a name that statically denotes
10311 a constant declared before the entity.
10315 In practice this is applicable only to address clauses, since this is the
10316 only case in which a non-static expression is permitted by the syntax. As
10317 the AARM notes in sections 13.1 (22.a-22.h):
10320 22.a Reason: This is to avoid the following sort of thing:
10322 22.b X : Integer := F(@dots{});
10323 Y : Address := G(@dots{});
10324 for X'Address use Y;
10326 22.c In the above, we have to evaluate the
10327 initialization expression for X before we
10328 know where to put the result. This seems
10329 like an unreasonable implementation burden.
10331 22.d The above code should instead be written
10334 22.e Y : constant Address := G(@dots{});
10335 X : Integer := F(@dots{});
10336 for X'Address use Y;
10338 22.f This allows the expression ``Y'' to be safely
10339 evaluated before X is created.
10341 22.g The constant could be a formal parameter of mode in.
10343 22.h An implementation can support other nonstatic
10344 expressions if it wants to. Expressions of type
10345 Address are hardly ever static, but their value
10346 might be known at compile time anyway in many
10351 GNAT does indeed permit many additional cases of non-static expressions. In
10352 particular, if the type involved is elementary there are no restrictions
10353 (since in this case, holding a temporary copy of the initialization value,
10354 if one is present, is inexpensive). In addition, if there is no implicit or
10355 explicit initialization, then there are no restrictions. GNAT will reject
10356 only the case where all three of these conditions hold:
10361 The type of the item is non-elementary (e.g.@: a record or array).
10364 There is explicit or implicit initialization required for the object.
10365 Note that access values are always implicitly initialized, and also
10366 in GNAT, certain bit-packed arrays (those having a dynamic length or
10367 a length greater than 64) will also be implicitly initialized to zero.
10370 The address value is non-static. Here GNAT is more permissive than the
10371 RM, and allows the address value to be the address of a previously declared
10372 stand-alone variable, as long as it does not itself have an address clause.
10374 @smallexample @c ada
10375 Anchor : Some_Initialized_Type;
10376 Overlay : Some_Initialized_Type;
10377 for Overlay'Address use Anchor'Address;
10381 However, the prefix of the address clause cannot be an array component, or
10382 a component of a discriminated record.
10387 As noted above in section 22.h, address values are typically non-static. In
10388 particular the To_Address function, even if applied to a literal value, is
10389 a non-static function call. To avoid this minor annoyance, GNAT provides
10390 the implementation defined attribute 'To_Address. The following two
10391 expressions have identical values:
10395 @smallexample @c ada
10396 To_Address (16#1234_0000#)
10397 System'To_Address (16#1234_0000#);
10401 except that the second form is considered to be a static expression, and
10402 thus when used as an address clause value is always permitted.
10405 Additionally, GNAT treats as static an address clause that is an
10406 unchecked_conversion of a static integer value. This simplifies the porting
10407 of legacy code, and provides a portable equivalent to the GNAT attribute
10410 Another issue with address clauses is the interaction with alignment
10411 requirements. When an address clause is given for an object, the address
10412 value must be consistent with the alignment of the object (which is usually
10413 the same as the alignment of the type of the object). If an address clause
10414 is given that specifies an inappropriately aligned address value, then the
10415 program execution is erroneous.
10417 Since this source of erroneous behavior can have unfortunate effects, GNAT
10418 checks (at compile time if possible, generating a warning, or at execution
10419 time with a run-time check) that the alignment is appropriate. If the
10420 run-time check fails, then @code{Program_Error} is raised. This run-time
10421 check is suppressed if range checks are suppressed, or if the special GNAT
10422 check Alignment_Check is suppressed, or if
10423 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
10426 An address clause cannot be given for an exported object. More
10427 understandably the real restriction is that objects with an address
10428 clause cannot be exported. This is because such variables are not
10429 defined by the Ada program, so there is no external object to export.
10432 It is permissible to give an address clause and a pragma Import for the
10433 same object. In this case, the variable is not really defined by the
10434 Ada program, so there is no external symbol to be linked. The link name
10435 and the external name are ignored in this case. The reason that we allow this
10436 combination is that it provides a useful idiom to avoid unwanted
10437 initializations on objects with address clauses.
10439 When an address clause is given for an object that has implicit or
10440 explicit initialization, then by default initialization takes place. This
10441 means that the effect of the object declaration is to overwrite the
10442 memory at the specified address. This is almost always not what the
10443 programmer wants, so GNAT will output a warning:
10453 for Ext'Address use System'To_Address (16#1234_1234#);
10455 >>> warning: implicit initialization of "Ext" may
10456 modify overlaid storage
10457 >>> warning: use pragma Import for "Ext" to suppress
10458 initialization (RM B(24))
10464 As indicated by the warning message, the solution is to use a (dummy) pragma
10465 Import to suppress this initialization. The pragma tell the compiler that the
10466 object is declared and initialized elsewhere. The following package compiles
10467 without warnings (and the initialization is suppressed):
10469 @smallexample @c ada
10477 for Ext'Address use System'To_Address (16#1234_1234#);
10478 pragma Import (Ada, Ext);
10483 A final issue with address clauses involves their use for overlaying
10484 variables, as in the following example:
10485 @cindex Overlaying of objects
10487 @smallexample @c ada
10490 for B'Address use A'Address;
10494 or alternatively, using the form recommended by the RM:
10496 @smallexample @c ada
10498 Addr : constant Address := A'Address;
10500 for B'Address use Addr;
10504 In both of these cases, @code{A}
10505 and @code{B} become aliased to one another via the
10506 address clause. This use of address clauses to overlay
10507 variables, achieving an effect similar to unchecked
10508 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
10509 the effect is implementation defined. Furthermore, the
10510 Ada RM specifically recommends that in a situation
10511 like this, @code{B} should be subject to the following
10512 implementation advice (RM 13.3(19)):
10515 19 If the Address of an object is specified, or it is imported
10516 or exported, then the implementation should not perform
10517 optimizations based on assumptions of no aliases.
10521 GNAT follows this recommendation, and goes further by also applying
10522 this recommendation to the overlaid variable (@code{A}
10523 in the above example) in this case. This means that the overlay
10524 works "as expected", in that a modification to one of the variables
10525 will affect the value of the other.
10527 @node Effect of Convention on Representation
10528 @section Effect of Convention on Representation
10529 @cindex Convention, effect on representation
10532 Normally the specification of a foreign language convention for a type or
10533 an object has no effect on the chosen representation. In particular, the
10534 representation chosen for data in GNAT generally meets the standard system
10535 conventions, and for example records are laid out in a manner that is
10536 consistent with C@. This means that specifying convention C (for example)
10539 There are four exceptions to this general rule:
10543 @item Convention Fortran and array subtypes
10544 If pragma Convention Fortran is specified for an array subtype, then in
10545 accordance with the implementation advice in section 3.6.2(11) of the
10546 Ada Reference Manual, the array will be stored in a Fortran-compatible
10547 column-major manner, instead of the normal default row-major order.
10549 @item Convention C and enumeration types
10550 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
10551 to accommodate all values of the type. For example, for the enumeration
10554 @smallexample @c ada
10555 type Color is (Red, Green, Blue);
10559 8 bits is sufficient to store all values of the type, so by default, objects
10560 of type @code{Color} will be represented using 8 bits. However, normal C
10561 convention is to use 32 bits for all enum values in C, since enum values
10562 are essentially of type int. If pragma @code{Convention C} is specified for an
10563 Ada enumeration type, then the size is modified as necessary (usually to
10564 32 bits) to be consistent with the C convention for enum values.
10566 Note that this treatment applies only to types. If Convention C is given for
10567 an enumeration object, where the enumeration type is not Convention C, then
10568 Object_Size bits are allocated. For example, for a normal enumeration type,
10569 with less than 256 elements, only 8 bits will be allocated for the object.
10570 Since this may be a surprise in terms of what C expects, GNAT will issue a
10571 warning in this situation. The warning can be suppressed by giving an explicit
10572 size clause specifying the desired size.
10574 @item Convention C/Fortran and Boolean types
10575 In C, the usual convention for boolean values, that is values used for
10576 conditions, is that zero represents false, and nonzero values represent
10577 true. In Ada, the normal convention is that two specific values, typically
10578 0/1, are used to represent false/true respectively.
10580 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
10581 value represents true).
10583 To accommodate the Fortran and C conventions, if a pragma Convention specifies
10584 C or Fortran convention for a derived Boolean, as in the following example:
10586 @smallexample @c ada
10587 type C_Switch is new Boolean;
10588 pragma Convention (C, C_Switch);
10592 then the GNAT generated code will treat any nonzero value as true. For truth
10593 values generated by GNAT, the conventional value 1 will be used for True, but
10594 when one of these values is read, any nonzero value is treated as True.
10596 @item Access types on OpenVMS
10597 For 64-bit OpenVMS systems, access types (other than those for unconstrained
10598 arrays) are 64-bits long. An exception to this rule is for the case of
10599 C-convention access types where there is no explicit size clause present (or
10600 inherited for derived types). In this case, GNAT chooses to make these
10601 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
10602 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
10606 @node Determining the Representations chosen by GNAT
10607 @section Determining the Representations chosen by GNAT
10608 @cindex Representation, determination of
10609 @cindex @code{-gnatR} switch
10612 Although the descriptions in this section are intended to be complete, it is
10613 often easier to simply experiment to see what GNAT accepts and what the
10614 effect is on the layout of types and objects.
10616 As required by the Ada RM, if a representation clause is not accepted, then
10617 it must be rejected as illegal by the compiler. However, when a
10618 representation clause or pragma is accepted, there can still be questions
10619 of what the compiler actually does. For example, if a partial record
10620 representation clause specifies the location of some components and not
10621 others, then where are the non-specified components placed? Or if pragma
10622 @code{Pack} is used on a record, then exactly where are the resulting
10623 fields placed? The section on pragma @code{Pack} in this chapter can be
10624 used to answer the second question, but it is often easier to just see
10625 what the compiler does.
10627 For this purpose, GNAT provides the option @code{-gnatR}. If you compile
10628 with this option, then the compiler will output information on the actual
10629 representations chosen, in a format similar to source representation
10630 clauses. For example, if we compile the package:
10632 @smallexample @c ada
10634 type r (x : boolean) is tagged record
10636 when True => S : String (1 .. 100);
10637 when False => null;
10641 type r2 is new r (false) with record
10646 y2 at 16 range 0 .. 31;
10653 type x1 is array (1 .. 10) of x;
10654 for x1'component_size use 11;
10656 type ia is access integer;
10658 type Rb1 is array (1 .. 13) of Boolean;
10661 type Rb2 is array (1 .. 65) of Boolean;
10677 using the switch @code{-gnatR} we obtain the following output:
10680 Representation information for unit q
10681 -------------------------------------
10684 for r'Alignment use 4;
10686 x at 4 range 0 .. 7;
10687 _tag at 0 range 0 .. 31;
10688 s at 5 range 0 .. 799;
10691 for r2'Size use 160;
10692 for r2'Alignment use 4;
10694 x at 4 range 0 .. 7;
10695 _tag at 0 range 0 .. 31;
10696 _parent at 0 range 0 .. 63;
10697 y2 at 16 range 0 .. 31;
10701 for x'Alignment use 1;
10703 y at 0 range 0 .. 7;
10706 for x1'Size use 112;
10707 for x1'Alignment use 1;
10708 for x1'Component_Size use 11;
10710 for rb1'Size use 13;
10711 for rb1'Alignment use 2;
10712 for rb1'Component_Size use 1;
10714 for rb2'Size use 72;
10715 for rb2'Alignment use 1;
10716 for rb2'Component_Size use 1;
10718 for x2'Size use 224;
10719 for x2'Alignment use 4;
10721 l1 at 0 range 0 .. 0;
10722 l2 at 0 range 1 .. 64;
10723 l3 at 12 range 0 .. 31;
10724 l4 at 16 range 0 .. 0;
10725 l5 at 16 range 1 .. 13;
10726 l6 at 18 range 0 .. 71;
10731 The Size values are actually the Object_Size, i.e.@: the default size that
10732 will be allocated for objects of the type.
10733 The ?? size for type r indicates that we have a variant record, and the
10734 actual size of objects will depend on the discriminant value.
10736 The Alignment values show the actual alignment chosen by the compiler
10737 for each record or array type.
10739 The record representation clause for type r shows where all fields
10740 are placed, including the compiler generated tag field (whose location
10741 cannot be controlled by the programmer).
10743 The record representation clause for the type extension r2 shows all the
10744 fields present, including the parent field, which is a copy of the fields
10745 of the parent type of r2, i.e.@: r1.
10747 The component size and size clauses for types rb1 and rb2 show
10748 the exact effect of pragma @code{Pack} on these arrays, and the record
10749 representation clause for type x2 shows how pragma @code{Pack} affects
10752 In some cases, it may be useful to cut and paste the representation clauses
10753 generated by the compiler into the original source to fix and guarantee
10754 the actual representation to be used.
10756 @node Standard Library Routines
10757 @chapter Standard Library Routines
10760 The Ada Reference Manual contains in Annex A a full description of an
10761 extensive set of standard library routines that can be used in any Ada
10762 program, and which must be provided by all Ada compilers. They are
10763 analogous to the standard C library used by C programs.
10765 GNAT implements all of the facilities described in annex A, and for most
10766 purposes the description in the Ada Reference Manual, or appropriate Ada
10767 text book, will be sufficient for making use of these facilities.
10769 In the case of the input-output facilities,
10770 @xref{The Implementation of Standard I/O},
10771 gives details on exactly how GNAT interfaces to the
10772 file system. For the remaining packages, the Ada Reference Manual
10773 should be sufficient. The following is a list of the packages included,
10774 together with a brief description of the functionality that is provided.
10776 For completeness, references are included to other predefined library
10777 routines defined in other sections of the Ada Reference Manual (these are
10778 cross-indexed from Annex A).
10782 This is a parent package for all the standard library packages. It is
10783 usually included implicitly in your program, and itself contains no
10784 useful data or routines.
10786 @item Ada.Calendar (9.6)
10787 @code{Calendar} provides time of day access, and routines for
10788 manipulating times and durations.
10790 @item Ada.Characters (A.3.1)
10791 This is a dummy parent package that contains no useful entities
10793 @item Ada.Characters.Handling (A.3.2)
10794 This package provides some basic character handling capabilities,
10795 including classification functions for classes of characters (e.g.@: test
10796 for letters, or digits).
10798 @item Ada.Characters.Latin_1 (A.3.3)
10799 This package includes a complete set of definitions of the characters
10800 that appear in type CHARACTER@. It is useful for writing programs that
10801 will run in international environments. For example, if you want an
10802 upper case E with an acute accent in a string, it is often better to use
10803 the definition of @code{UC_E_Acute} in this package. Then your program
10804 will print in an understandable manner even if your environment does not
10805 support these extended characters.
10807 @item Ada.Command_Line (A.15)
10808 This package provides access to the command line parameters and the name
10809 of the current program (analogous to the use of @code{argc} and @code{argv}
10810 in C), and also allows the exit status for the program to be set in a
10811 system-independent manner.
10813 @item Ada.Decimal (F.2)
10814 This package provides constants describing the range of decimal numbers
10815 implemented, and also a decimal divide routine (analogous to the COBOL
10816 verb DIVIDE .. GIVING .. REMAINDER ..)
10818 @item Ada.Direct_IO (A.8.4)
10819 This package provides input-output using a model of a set of records of
10820 fixed-length, containing an arbitrary definite Ada type, indexed by an
10821 integer record number.
10823 @item Ada.Dynamic_Priorities (D.5)
10824 This package allows the priorities of a task to be adjusted dynamically
10825 as the task is running.
10827 @item Ada.Exceptions (11.4.1)
10828 This package provides additional information on exceptions, and also
10829 contains facilities for treating exceptions as data objects, and raising
10830 exceptions with associated messages.
10832 @item Ada.Finalization (7.6)
10833 This package contains the declarations and subprograms to support the
10834 use of controlled types, providing for automatic initialization and
10835 finalization (analogous to the constructors and destructors of C++)
10837 @item Ada.Interrupts (C.3.2)
10838 This package provides facilities for interfacing to interrupts, which
10839 includes the set of signals or conditions that can be raised and
10840 recognized as interrupts.
10842 @item Ada.Interrupts.Names (C.3.2)
10843 This package provides the set of interrupt names (actually signal
10844 or condition names) that can be handled by GNAT@.
10846 @item Ada.IO_Exceptions (A.13)
10847 This package defines the set of exceptions that can be raised by use of
10848 the standard IO packages.
10851 This package contains some standard constants and exceptions used
10852 throughout the numerics packages. Note that the constants pi and e are
10853 defined here, and it is better to use these definitions than rolling
10856 @item Ada.Numerics.Complex_Elementary_Functions
10857 Provides the implementation of standard elementary functions (such as
10858 log and trigonometric functions) operating on complex numbers using the
10859 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10860 created by the package @code{Numerics.Complex_Types}.
10862 @item Ada.Numerics.Complex_Types
10863 This is a predefined instantiation of
10864 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10865 build the type @code{Complex} and @code{Imaginary}.
10867 @item Ada.Numerics.Discrete_Random
10868 This package provides a random number generator suitable for generating
10869 random integer values from a specified range.
10871 @item Ada.Numerics.Float_Random
10872 This package provides a random number generator suitable for generating
10873 uniformly distributed floating point values.
10875 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10876 This is a generic version of the package that provides the
10877 implementation of standard elementary functions (such as log and
10878 trigonometric functions) for an arbitrary complex type.
10880 The following predefined instantiations of this package are provided:
10884 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10886 @code{Ada.Numerics.Complex_Elementary_Functions}
10888 @code{Ada.Numerics.
10889 Long_Complex_Elementary_Functions}
10892 @item Ada.Numerics.Generic_Complex_Types
10893 This is a generic package that allows the creation of complex types,
10894 with associated complex arithmetic operations.
10896 The following predefined instantiations of this package exist
10899 @code{Ada.Numerics.Short_Complex_Complex_Types}
10901 @code{Ada.Numerics.Complex_Complex_Types}
10903 @code{Ada.Numerics.Long_Complex_Complex_Types}
10906 @item Ada.Numerics.Generic_Elementary_Functions
10907 This is a generic package that provides the implementation of standard
10908 elementary functions (such as log an trigonometric functions) for an
10909 arbitrary float type.
10911 The following predefined instantiations of this package exist
10915 @code{Ada.Numerics.Short_Elementary_Functions}
10917 @code{Ada.Numerics.Elementary_Functions}
10919 @code{Ada.Numerics.Long_Elementary_Functions}
10922 @item Ada.Real_Time (D.8)
10923 This package provides facilities similar to those of @code{Calendar}, but
10924 operating with a finer clock suitable for real time control. Note that
10925 annex D requires that there be no backward clock jumps, and GNAT generally
10926 guarantees this behavior, but of course if the external clock on which
10927 the GNAT runtime depends is deliberately reset by some external event,
10928 then such a backward jump may occur.
10930 @item Ada.Sequential_IO (A.8.1)
10931 This package provides input-output facilities for sequential files,
10932 which can contain a sequence of values of a single type, which can be
10933 any Ada type, including indefinite (unconstrained) types.
10935 @item Ada.Storage_IO (A.9)
10936 This package provides a facility for mapping arbitrary Ada types to and
10937 from a storage buffer. It is primarily intended for the creation of new
10940 @item Ada.Streams (13.13.1)
10941 This is a generic package that provides the basic support for the
10942 concept of streams as used by the stream attributes (@code{Input},
10943 @code{Output}, @code{Read} and @code{Write}).
10945 @item Ada.Streams.Stream_IO (A.12.1)
10946 This package is a specialization of the type @code{Streams} defined in
10947 package @code{Streams} together with a set of operations providing
10948 Stream_IO capability. The Stream_IO model permits both random and
10949 sequential access to a file which can contain an arbitrary set of values
10950 of one or more Ada types.
10952 @item Ada.Strings (A.4.1)
10953 This package provides some basic constants used by the string handling
10956 @item Ada.Strings.Bounded (A.4.4)
10957 This package provides facilities for handling variable length
10958 strings. The bounded model requires a maximum length. It is thus
10959 somewhat more limited than the unbounded model, but avoids the use of
10960 dynamic allocation or finalization.
10962 @item Ada.Strings.Fixed (A.4.3)
10963 This package provides facilities for handling fixed length strings.
10965 @item Ada.Strings.Maps (A.4.2)
10966 This package provides facilities for handling character mappings and
10967 arbitrarily defined subsets of characters. For instance it is useful in
10968 defining specialized translation tables.
10970 @item Ada.Strings.Maps.Constants (A.4.6)
10971 This package provides a standard set of predefined mappings and
10972 predefined character sets. For example, the standard upper to lower case
10973 conversion table is found in this package. Note that upper to lower case
10974 conversion is non-trivial if you want to take the entire set of
10975 characters, including extended characters like E with an acute accent,
10976 into account. You should use the mappings in this package (rather than
10977 adding 32 yourself) to do case mappings.
10979 @item Ada.Strings.Unbounded (A.4.5)
10980 This package provides facilities for handling variable length
10981 strings. The unbounded model allows arbitrary length strings, but
10982 requires the use of dynamic allocation and finalization.
10984 @item Ada.Strings.Wide_Bounded (A.4.7)
10985 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10986 @itemx Ada.Strings.Wide_Maps (A.4.7)
10987 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10988 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10989 These packages provide analogous capabilities to the corresponding
10990 packages without @samp{Wide_} in the name, but operate with the types
10991 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10992 and @code{Character}.
10994 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
10995 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
10996 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
10997 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
10998 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
10999 These packages provide analogous capabilities to the corresponding
11000 packages without @samp{Wide_} in the name, but operate with the types
11001 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11002 of @code{String} and @code{Character}.
11004 @item Ada.Synchronous_Task_Control (D.10)
11005 This package provides some standard facilities for controlling task
11006 communication in a synchronous manner.
11009 This package contains definitions for manipulation of the tags of tagged
11012 @item Ada.Task_Attributes
11013 This package provides the capability of associating arbitrary
11014 task-specific data with separate tasks.
11017 This package provides basic text input-output capabilities for
11018 character, string and numeric data. The subpackages of this
11019 package are listed next.
11021 @item Ada.Text_IO.Decimal_IO
11022 Provides input-output facilities for decimal fixed-point types
11024 @item Ada.Text_IO.Enumeration_IO
11025 Provides input-output facilities for enumeration types.
11027 @item Ada.Text_IO.Fixed_IO
11028 Provides input-output facilities for ordinary fixed-point types.
11030 @item Ada.Text_IO.Float_IO
11031 Provides input-output facilities for float types. The following
11032 predefined instantiations of this generic package are available:
11036 @code{Short_Float_Text_IO}
11038 @code{Float_Text_IO}
11040 @code{Long_Float_Text_IO}
11043 @item Ada.Text_IO.Integer_IO
11044 Provides input-output facilities for integer types. The following
11045 predefined instantiations of this generic package are available:
11048 @item Short_Short_Integer
11049 @code{Ada.Short_Short_Integer_Text_IO}
11050 @item Short_Integer
11051 @code{Ada.Short_Integer_Text_IO}
11053 @code{Ada.Integer_Text_IO}
11055 @code{Ada.Long_Integer_Text_IO}
11056 @item Long_Long_Integer
11057 @code{Ada.Long_Long_Integer_Text_IO}
11060 @item Ada.Text_IO.Modular_IO
11061 Provides input-output facilities for modular (unsigned) types
11063 @item Ada.Text_IO.Complex_IO (G.1.3)
11064 This package provides basic text input-output capabilities for complex
11067 @item Ada.Text_IO.Editing (F.3.3)
11068 This package contains routines for edited output, analogous to the use
11069 of pictures in COBOL@. The picture formats used by this package are a
11070 close copy of the facility in COBOL@.
11072 @item Ada.Text_IO.Text_Streams (A.12.2)
11073 This package provides a facility that allows Text_IO files to be treated
11074 as streams, so that the stream attributes can be used for writing
11075 arbitrary data, including binary data, to Text_IO files.
11077 @item Ada.Unchecked_Conversion (13.9)
11078 This generic package allows arbitrary conversion from one type to
11079 another of the same size, providing for breaking the type safety in
11080 special circumstances.
11082 If the types have the same Size (more accurately the same Value_Size),
11083 then the effect is simply to transfer the bits from the source to the
11084 target type without any modification. This usage is well defined, and
11085 for simple types whose representation is typically the same across
11086 all implementations, gives a portable method of performing such
11089 If the types do not have the same size, then the result is implementation
11090 defined, and thus may be non-portable. The following describes how GNAT
11091 handles such unchecked conversion cases.
11093 If the types are of different sizes, and are both discrete types, then
11094 the effect is of a normal type conversion without any constraint checking.
11095 In particular if the result type has a larger size, the result will be
11096 zero or sign extended. If the result type has a smaller size, the result
11097 will be truncated by ignoring high order bits.
11099 If the types are of different sizes, and are not both discrete types,
11100 then the conversion works as though pointers were created to the source
11101 and target, and the pointer value is converted. The effect is that bits
11102 are copied from successive low order storage units and bits of the source
11103 up to the length of the target type.
11105 A warning is issued if the lengths differ, since the effect in this
11106 case is implementation dependent, and the above behavior may not match
11107 that of some other compiler.
11109 A pointer to one type may be converted to a pointer to another type using
11110 unchecked conversion. The only case in which the effect is undefined is
11111 when one or both pointers are pointers to unconstrained array types. In
11112 this case, the bounds information may get incorrectly transferred, and in
11113 particular, GNAT uses double size pointers for such types, and it is
11114 meaningless to convert between such pointer types. GNAT will issue a
11115 warning if the alignment of the target designated type is more strict
11116 than the alignment of the source designated type (since the result may
11117 be unaligned in this case).
11119 A pointer other than a pointer to an unconstrained array type may be
11120 converted to and from System.Address. Such usage is common in Ada 83
11121 programs, but note that Ada.Address_To_Access_Conversions is the
11122 preferred method of performing such conversions in Ada 95 and Ada 2005.
11124 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11125 used in conjunction with pointers to unconstrained objects, since
11126 the bounds information cannot be handled correctly in this case.
11128 @item Ada.Unchecked_Deallocation (13.11.2)
11129 This generic package allows explicit freeing of storage previously
11130 allocated by use of an allocator.
11132 @item Ada.Wide_Text_IO (A.11)
11133 This package is similar to @code{Ada.Text_IO}, except that the external
11134 file supports wide character representations, and the internal types are
11135 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11136 and @code{String}. It contains generic subpackages listed next.
11138 @item Ada.Wide_Text_IO.Decimal_IO
11139 Provides input-output facilities for decimal fixed-point types
11141 @item Ada.Wide_Text_IO.Enumeration_IO
11142 Provides input-output facilities for enumeration types.
11144 @item Ada.Wide_Text_IO.Fixed_IO
11145 Provides input-output facilities for ordinary fixed-point types.
11147 @item Ada.Wide_Text_IO.Float_IO
11148 Provides input-output facilities for float types. The following
11149 predefined instantiations of this generic package are available:
11153 @code{Short_Float_Wide_Text_IO}
11155 @code{Float_Wide_Text_IO}
11157 @code{Long_Float_Wide_Text_IO}
11160 @item Ada.Wide_Text_IO.Integer_IO
11161 Provides input-output facilities for integer types. The following
11162 predefined instantiations of this generic package are available:
11165 @item Short_Short_Integer
11166 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11167 @item Short_Integer
11168 @code{Ada.Short_Integer_Wide_Text_IO}
11170 @code{Ada.Integer_Wide_Text_IO}
11172 @code{Ada.Long_Integer_Wide_Text_IO}
11173 @item Long_Long_Integer
11174 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11177 @item Ada.Wide_Text_IO.Modular_IO
11178 Provides input-output facilities for modular (unsigned) types
11180 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11181 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11182 external file supports wide character representations.
11184 @item Ada.Wide_Text_IO.Editing (F.3.4)
11185 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11186 types are @code{Wide_Character} and @code{Wide_String} instead of
11187 @code{Character} and @code{String}.
11189 @item Ada.Wide_Text_IO.Streams (A.12.3)
11190 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11191 types are @code{Wide_Character} and @code{Wide_String} instead of
11192 @code{Character} and @code{String}.
11194 @item Ada.Wide_Wide_Text_IO (A.11)
11195 This package is similar to @code{Ada.Text_IO}, except that the external
11196 file supports wide character representations, and the internal types are
11197 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11198 and @code{String}. It contains generic subpackages listed next.
11200 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11201 Provides input-output facilities for decimal fixed-point types
11203 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11204 Provides input-output facilities for enumeration types.
11206 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11207 Provides input-output facilities for ordinary fixed-point types.
11209 @item Ada.Wide_Wide_Text_IO.Float_IO
11210 Provides input-output facilities for float types. The following
11211 predefined instantiations of this generic package are available:
11215 @code{Short_Float_Wide_Wide_Text_IO}
11217 @code{Float_Wide_Wide_Text_IO}
11219 @code{Long_Float_Wide_Wide_Text_IO}
11222 @item Ada.Wide_Wide_Text_IO.Integer_IO
11223 Provides input-output facilities for integer types. The following
11224 predefined instantiations of this generic package are available:
11227 @item Short_Short_Integer
11228 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
11229 @item Short_Integer
11230 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
11232 @code{Ada.Integer_Wide_Wide_Text_IO}
11234 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
11235 @item Long_Long_Integer
11236 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
11239 @item Ada.Wide_Wide_Text_IO.Modular_IO
11240 Provides input-output facilities for modular (unsigned) types
11242 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
11243 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11244 external file supports wide character representations.
11246 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
11247 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11248 types are @code{Wide_Character} and @code{Wide_String} instead of
11249 @code{Character} and @code{String}.
11251 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
11252 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11253 types are @code{Wide_Character} and @code{Wide_String} instead of
11254 @code{Character} and @code{String}.
11259 @node The Implementation of Standard I/O
11260 @chapter The Implementation of Standard I/O
11263 GNAT implements all the required input-output facilities described in
11264 A.6 through A.14. These sections of the Ada Reference Manual describe the
11265 required behavior of these packages from the Ada point of view, and if
11266 you are writing a portable Ada program that does not need to know the
11267 exact manner in which Ada maps to the outside world when it comes to
11268 reading or writing external files, then you do not need to read this
11269 chapter. As long as your files are all regular files (not pipes or
11270 devices), and as long as you write and read the files only from Ada, the
11271 description in the Ada Reference Manual is sufficient.
11273 However, if you want to do input-output to pipes or other devices, such
11274 as the keyboard or screen, or if the files you are dealing with are
11275 either generated by some other language, or to be read by some other
11276 language, then you need to know more about the details of how the GNAT
11277 implementation of these input-output facilities behaves.
11279 In this chapter we give a detailed description of exactly how GNAT
11280 interfaces to the file system. As always, the sources of the system are
11281 available to you for answering questions at an even more detailed level,
11282 but for most purposes the information in this chapter will suffice.
11284 Another reason that you may need to know more about how input-output is
11285 implemented arises when you have a program written in mixed languages
11286 where, for example, files are shared between the C and Ada sections of
11287 the same program. GNAT provides some additional facilities, in the form
11288 of additional child library packages, that facilitate this sharing, and
11289 these additional facilities are also described in this chapter.
11292 * Standard I/O Packages::
11298 * Wide_Wide_Text_IO::
11301 * Filenames encoding::
11303 * Operations on C Streams::
11304 * Interfacing to C Streams::
11307 @node Standard I/O Packages
11308 @section Standard I/O Packages
11311 The Standard I/O packages described in Annex A for
11317 Ada.Text_IO.Complex_IO
11319 Ada.Text_IO.Text_Streams
11323 Ada.Wide_Text_IO.Complex_IO
11325 Ada.Wide_Text_IO.Text_Streams
11327 Ada.Wide_Wide_Text_IO
11329 Ada.Wide_Wide_Text_IO.Complex_IO
11331 Ada.Wide_Wide_Text_IO.Text_Streams
11341 are implemented using the C
11342 library streams facility; where
11346 All files are opened using @code{fopen}.
11348 All input/output operations use @code{fread}/@code{fwrite}.
11352 There is no internal buffering of any kind at the Ada library level. The only
11353 buffering is that provided at the system level in the implementation of the
11354 library routines that support streams. This facilitates shared use of these
11355 streams by mixed language programs. Note though that system level buffering is
11356 explicitly enabled at elaboration of the standard I/O packages and that can
11357 have an impact on mixed language programs, in particular those using I/O before
11358 calling the Ada elaboration routine (e.g. adainit). It is recommended to call
11359 the Ada elaboration routine before performing any I/O or when impractical,
11360 flush the common I/O streams and in particular Standard_Output before
11361 elaborating the Ada code.
11364 @section FORM Strings
11367 The format of a FORM string in GNAT is:
11370 "keyword=value,keyword=value,@dots{},keyword=value"
11374 where letters may be in upper or lower case, and there are no spaces
11375 between values. The order of the entries is not important. Currently
11376 there are two keywords defined.
11380 WCEM=[n|h|u|s|e|8|b]
11384 The use of these parameters is described later in this section.
11390 Direct_IO can only be instantiated for definite types. This is a
11391 restriction of the Ada language, which means that the records are fixed
11392 length (the length being determined by @code{@var{type}'Size}, rounded
11393 up to the next storage unit boundary if necessary).
11395 The records of a Direct_IO file are simply written to the file in index
11396 sequence, with the first record starting at offset zero, and subsequent
11397 records following. There is no control information of any kind. For
11398 example, if 32-bit integers are being written, each record takes
11399 4-bytes, so the record at index @var{K} starts at offset
11400 (@var{K}@minus{}1)*4.
11402 There is no limit on the size of Direct_IO files, they are expanded as
11403 necessary to accommodate whatever records are written to the file.
11405 @node Sequential_IO
11406 @section Sequential_IO
11409 Sequential_IO may be instantiated with either a definite (constrained)
11410 or indefinite (unconstrained) type.
11412 For the definite type case, the elements written to the file are simply
11413 the memory images of the data values with no control information of any
11414 kind. The resulting file should be read using the same type, no validity
11415 checking is performed on input.
11417 For the indefinite type case, the elements written consist of two
11418 parts. First is the size of the data item, written as the memory image
11419 of a @code{Interfaces.C.size_t} value, followed by the memory image of
11420 the data value. The resulting file can only be read using the same
11421 (unconstrained) type. Normal assignment checks are performed on these
11422 read operations, and if these checks fail, @code{Data_Error} is
11423 raised. In particular, in the array case, the lengths must match, and in
11424 the variant record case, if the variable for a particular read operation
11425 is constrained, the discriminants must match.
11427 Note that it is not possible to use Sequential_IO to write variable
11428 length array items, and then read the data back into different length
11429 arrays. For example, the following will raise @code{Data_Error}:
11431 @smallexample @c ada
11432 package IO is new Sequential_IO (String);
11437 IO.Write (F, "hello!")
11438 IO.Reset (F, Mode=>In_File);
11445 On some Ada implementations, this will print @code{hell}, but the program is
11446 clearly incorrect, since there is only one element in the file, and that
11447 element is the string @code{hello!}.
11449 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
11450 using Stream_IO, and this is the preferred mechanism. In particular, the
11451 above program fragment rewritten to use Stream_IO will work correctly.
11457 Text_IO files consist of a stream of characters containing the following
11458 special control characters:
11461 LF (line feed, 16#0A#) Line Mark
11462 FF (form feed, 16#0C#) Page Mark
11466 A canonical Text_IO file is defined as one in which the following
11467 conditions are met:
11471 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
11475 The character @code{FF} is used only as a page mark, i.e.@: to mark the
11476 end of a page and consequently can appear only immediately following a
11477 @code{LF} (line mark) character.
11480 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
11481 (line mark, page mark). In the former case, the page mark is implicitly
11482 assumed to be present.
11486 A file written using Text_IO will be in canonical form provided that no
11487 explicit @code{LF} or @code{FF} characters are written using @code{Put}
11488 or @code{Put_Line}. There will be no @code{FF} character at the end of
11489 the file unless an explicit @code{New_Page} operation was performed
11490 before closing the file.
11492 A canonical Text_IO file that is a regular file (i.e., not a device or a
11493 pipe) can be read using any of the routines in Text_IO@. The
11494 semantics in this case will be exactly as defined in the Ada Reference
11495 Manual, and all the routines in Text_IO are fully implemented.
11497 A text file that does not meet the requirements for a canonical Text_IO
11498 file has one of the following:
11502 The file contains @code{FF} characters not immediately following a
11503 @code{LF} character.
11506 The file contains @code{LF} or @code{FF} characters written by
11507 @code{Put} or @code{Put_Line}, which are not logically considered to be
11508 line marks or page marks.
11511 The file ends in a character other than @code{LF} or @code{FF},
11512 i.e.@: there is no explicit line mark or page mark at the end of the file.
11516 Text_IO can be used to read such non-standard text files but subprograms
11517 to do with line or page numbers do not have defined meanings. In
11518 particular, a @code{FF} character that does not follow a @code{LF}
11519 character may or may not be treated as a page mark from the point of
11520 view of page and line numbering. Every @code{LF} character is considered
11521 to end a line, and there is an implied @code{LF} character at the end of
11525 * Text_IO Stream Pointer Positioning::
11526 * Text_IO Reading and Writing Non-Regular Files::
11528 * Treating Text_IO Files as Streams::
11529 * Text_IO Extensions::
11530 * Text_IO Facilities for Unbounded Strings::
11533 @node Text_IO Stream Pointer Positioning
11534 @subsection Stream Pointer Positioning
11537 @code{Ada.Text_IO} has a definition of current position for a file that
11538 is being read. No internal buffering occurs in Text_IO, and usually the
11539 physical position in the stream used to implement the file corresponds
11540 to this logical position defined by Text_IO@. There are two exceptions:
11544 After a call to @code{End_Of_Page} that returns @code{True}, the stream
11545 is positioned past the @code{LF} (line mark) that precedes the page
11546 mark. Text_IO maintains an internal flag so that subsequent read
11547 operations properly handle the logical position which is unchanged by
11548 the @code{End_Of_Page} call.
11551 After a call to @code{End_Of_File} that returns @code{True}, if the
11552 Text_IO file was positioned before the line mark at the end of file
11553 before the call, then the logical position is unchanged, but the stream
11554 is physically positioned right at the end of file (past the line mark,
11555 and past a possible page mark following the line mark. Again Text_IO
11556 maintains internal flags so that subsequent read operations properly
11557 handle the logical position.
11561 These discrepancies have no effect on the observable behavior of
11562 Text_IO, but if a single Ada stream is shared between a C program and
11563 Ada program, or shared (using @samp{shared=yes} in the form string)
11564 between two Ada files, then the difference may be observable in some
11567 @node Text_IO Reading and Writing Non-Regular Files
11568 @subsection Reading and Writing Non-Regular Files
11571 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
11572 can be used for reading and writing. Writing is not affected and the
11573 sequence of characters output is identical to the normal file case, but
11574 for reading, the behavior of Text_IO is modified to avoid undesirable
11575 look-ahead as follows:
11577 An input file that is not a regular file is considered to have no page
11578 marks. Any @code{Ascii.FF} characters (the character normally used for a
11579 page mark) appearing in the file are considered to be data
11580 characters. In particular:
11584 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
11585 following a line mark. If a page mark appears, it will be treated as a
11589 This avoids the need to wait for an extra character to be typed or
11590 entered from the pipe to complete one of these operations.
11593 @code{End_Of_Page} always returns @code{False}
11596 @code{End_Of_File} will return @code{False} if there is a page mark at
11597 the end of the file.
11601 Output to non-regular files is the same as for regular files. Page marks
11602 may be written to non-regular files using @code{New_Page}, but as noted
11603 above they will not be treated as page marks on input if the output is
11604 piped to another Ada program.
11606 Another important discrepancy when reading non-regular files is that the end
11607 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
11608 pressing the @key{EOT} key,
11610 is signaled once (i.e.@: the test @code{End_Of_File}
11611 will yield @code{True}, or a read will
11612 raise @code{End_Error}), but then reading can resume
11613 to read data past that end of
11614 file indication, until another end of file indication is entered.
11616 @node Get_Immediate
11617 @subsection Get_Immediate
11618 @cindex Get_Immediate
11621 Get_Immediate returns the next character (including control characters)
11622 from the input file. In particular, Get_Immediate will return LF or FF
11623 characters used as line marks or page marks. Such operations leave the
11624 file positioned past the control character, and it is thus not treated
11625 as having its normal function. This means that page, line and column
11626 counts after this kind of Get_Immediate call are set as though the mark
11627 did not occur. In the case where a Get_Immediate leaves the file
11628 positioned between the line mark and page mark (which is not normally
11629 possible), it is undefined whether the FF character will be treated as a
11632 @node Treating Text_IO Files as Streams
11633 @subsection Treating Text_IO Files as Streams
11634 @cindex Stream files
11637 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11638 as a stream. Data written to a Text_IO file in this stream mode is
11639 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
11640 16#0C# (@code{FF}), the resulting file may have non-standard
11641 format. Similarly if read operations are used to read from a Text_IO
11642 file treated as a stream, then @code{LF} and @code{FF} characters may be
11643 skipped and the effect is similar to that described above for
11644 @code{Get_Immediate}.
11646 @node Text_IO Extensions
11647 @subsection Text_IO Extensions
11648 @cindex Text_IO extensions
11651 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11652 to the standard @code{Text_IO} package:
11655 @item function File_Exists (Name : String) return Boolean;
11656 Determines if a file of the given name exists.
11658 @item function Get_Line return String;
11659 Reads a string from the standard input file. The value returned is exactly
11660 the length of the line that was read.
11662 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11663 Similar, except that the parameter File specifies the file from which
11664 the string is to be read.
11668 @node Text_IO Facilities for Unbounded Strings
11669 @subsection Text_IO Facilities for Unbounded Strings
11670 @cindex Text_IO for unbounded strings
11671 @cindex Unbounded_String, Text_IO operations
11674 The package @code{Ada.Strings.Unbounded.Text_IO}
11675 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11676 subprograms useful for Text_IO operations on unbounded strings:
11680 @item function Get_Line (File : File_Type) return Unbounded_String;
11681 Reads a line from the specified file
11682 and returns the result as an unbounded string.
11684 @item procedure Put (File : File_Type; U : Unbounded_String);
11685 Writes the value of the given unbounded string to the specified file
11686 Similar to the effect of
11687 @code{Put (To_String (U))} except that an extra copy is avoided.
11689 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11690 Writes the value of the given unbounded string to the specified file,
11691 followed by a @code{New_Line}.
11692 Similar to the effect of @code{Put_Line (To_String (U))} except
11693 that an extra copy is avoided.
11697 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11698 and is optional. If the parameter is omitted, then the standard input or
11699 output file is referenced as appropriate.
11701 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11702 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11703 @code{Wide_Text_IO} functionality for unbounded wide strings.
11705 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11706 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11707 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11710 @section Wide_Text_IO
11713 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11714 both input and output files may contain special sequences that represent
11715 wide character values. The encoding scheme for a given file may be
11716 specified using a FORM parameter:
11723 as part of the FORM string (WCEM = wide character encoding method),
11724 where @var{x} is one of the following characters
11730 Upper half encoding
11742 The encoding methods match those that
11743 can be used in a source
11744 program, but there is no requirement that the encoding method used for
11745 the source program be the same as the encoding method used for files,
11746 and different files may use different encoding methods.
11748 The default encoding method for the standard files, and for opened files
11749 for which no WCEM parameter is given in the FORM string matches the
11750 wide character encoding specified for the main program (the default
11751 being brackets encoding if no coding method was specified with -gnatW).
11755 In this encoding, a wide character is represented by a five character
11763 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
11764 characters (using upper case letters) of the wide character code. For
11765 example, ESC A345 is used to represent the wide character with code
11766 16#A345#. This scheme is compatible with use of the full
11767 @code{Wide_Character} set.
11769 @item Upper Half Coding
11770 The wide character with encoding 16#abcd#, where the upper bit is on
11771 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
11772 16#cd#. The second byte may never be a format control character, but is
11773 not required to be in the upper half. This method can be also used for
11774 shift-JIS or EUC where the internal coding matches the external coding.
11776 @item Shift JIS Coding
11777 A wide character is represented by a two character sequence 16#ab# and
11778 16#cd#, with the restrictions described for upper half encoding as
11779 described above. The internal character code is the corresponding JIS
11780 character according to the standard algorithm for Shift-JIS
11781 conversion. Only characters defined in the JIS code set table can be
11782 used with this encoding method.
11785 A wide character is represented by a two character sequence 16#ab# and
11786 16#cd#, with both characters being in the upper half. The internal
11787 character code is the corresponding JIS character according to the EUC
11788 encoding algorithm. Only characters defined in the JIS code set table
11789 can be used with this encoding method.
11792 A wide character is represented using
11793 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11794 10646-1/Am.2. Depending on the character value, the representation
11795 is a one, two, or three byte sequence:
11798 16#0000#-16#007f#: 2#0xxxxxxx#
11799 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
11800 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11804 where the xxx bits correspond to the left-padded bits of the
11805 16-bit character value. Note that all lower half ASCII characters
11806 are represented as ASCII bytes and all upper half characters and
11807 other wide characters are represented as sequences of upper-half
11808 (The full UTF-8 scheme allows for encoding 31-bit characters as
11809 6-byte sequences, but in this implementation, all UTF-8 sequences
11810 of four or more bytes length will raise a Constraint_Error, as
11811 will all invalid UTF-8 sequences.)
11813 @item Brackets Coding
11814 In this encoding, a wide character is represented by the following eight
11815 character sequence:
11822 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11823 characters (using uppercase letters) of the wide character code. For
11824 example, @code{["A345"]} is used to represent the wide character with code
11826 This scheme is compatible with use of the full Wide_Character set.
11827 On input, brackets coding can also be used for upper half characters,
11828 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
11829 is only used for wide characters with a code greater than @code{16#FF#}.
11831 Note that brackets coding is not normally used in the context of
11832 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
11833 a portable way of encoding source files. In the context of Wide_Text_IO
11834 or Wide_Wide_Text_IO, it can only be used if the file does not contain
11835 any instance of the left bracket character other than to encode wide
11836 character values using the brackets encoding method. In practice it is
11837 expected that some standard wide character encoding method such
11838 as UTF-8 will be used for text input output.
11840 If brackets notation is used, then any occurrence of a left bracket
11841 in the input file which is not the start of a valid wide character
11842 sequence will cause Constraint_Error to be raised. It is possible to
11843 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
11844 input will interpret this as a left bracket.
11846 However, when a left bracket is output, it will be output as a left bracket
11847 and not as ["5B"]. We make this decision because for normal use of
11848 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
11849 brackets. For example, if we write:
11852 Put_Line ("Start of output [first run]");
11856 we really do not want to have the left bracket in this message clobbered so
11857 that the output reads:
11860 Start of output ["5B"]first run]
11864 In practice brackets encoding is reasonably useful for normal Put_Line use
11865 since we won't get confused between left brackets and wide character
11866 sequences in the output. But for input, or when files are written out
11867 and read back in, it really makes better sense to use one of the standard
11868 encoding methods such as UTF-8.
11873 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
11874 not all wide character
11875 values can be represented. An attempt to output a character that cannot
11876 be represented using the encoding scheme for the file causes
11877 Constraint_Error to be raised. An invalid wide character sequence on
11878 input also causes Constraint_Error to be raised.
11881 * Wide_Text_IO Stream Pointer Positioning::
11882 * Wide_Text_IO Reading and Writing Non-Regular Files::
11885 @node Wide_Text_IO Stream Pointer Positioning
11886 @subsection Stream Pointer Positioning
11889 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11890 of stream pointer positioning (@pxref{Text_IO}). There is one additional
11893 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
11894 normal lower ASCII set (i.e.@: a character in the range:
11896 @smallexample @c ada
11897 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
11901 then although the logical position of the file pointer is unchanged by
11902 the @code{Look_Ahead} call, the stream is physically positioned past the
11903 wide character sequence. Again this is to avoid the need for buffering
11904 or backup, and all @code{Wide_Text_IO} routines check the internal
11905 indication that this situation has occurred so that this is not visible
11906 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
11907 can be observed if the wide text file shares a stream with another file.
11909 @node Wide_Text_IO Reading and Writing Non-Regular Files
11910 @subsection Reading and Writing Non-Regular Files
11913 As in the case of Text_IO, when a non-regular file is read, it is
11914 assumed that the file contains no page marks (any form characters are
11915 treated as data characters), and @code{End_Of_Page} always returns
11916 @code{False}. Similarly, the end of file indication is not sticky, so
11917 it is possible to read beyond an end of file.
11919 @node Wide_Wide_Text_IO
11920 @section Wide_Wide_Text_IO
11923 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
11924 both input and output files may contain special sequences that represent
11925 wide wide character values. The encoding scheme for a given file may be
11926 specified using a FORM parameter:
11933 as part of the FORM string (WCEM = wide character encoding method),
11934 where @var{x} is one of the following characters
11940 Upper half encoding
11952 The encoding methods match those that
11953 can be used in a source
11954 program, but there is no requirement that the encoding method used for
11955 the source program be the same as the encoding method used for files,
11956 and different files may use different encoding methods.
11958 The default encoding method for the standard files, and for opened files
11959 for which no WCEM parameter is given in the FORM string matches the
11960 wide character encoding specified for the main program (the default
11961 being brackets encoding if no coding method was specified with -gnatW).
11966 A wide character is represented using
11967 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11968 10646-1/Am.2. Depending on the character value, the representation
11969 is a one, two, three, or four byte sequence:
11972 16#000000#-16#00007f#: 2#0xxxxxxx#
11973 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
11974 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11975 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
11979 where the xxx bits correspond to the left-padded bits of the
11980 21-bit character value. Note that all lower half ASCII characters
11981 are represented as ASCII bytes and all upper half characters and
11982 other wide characters are represented as sequences of upper-half
11985 @item Brackets Coding
11986 In this encoding, a wide wide character is represented by the following eight
11987 character sequence if is in wide character range
11993 and by the following ten character sequence if not
11996 [ " a b c d e f " ]
12000 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12001 are the four or six hexadecimal
12002 characters (using uppercase letters) of the wide wide character code. For
12003 example, @code{["01A345"]} is used to represent the wide wide character
12004 with code @code{16#01A345#}.
12006 This scheme is compatible with use of the full Wide_Wide_Character set.
12007 On input, brackets coding can also be used for upper half characters,
12008 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12009 is only used for wide characters with a code greater than @code{16#FF#}.
12014 If is also possible to use the other Wide_Character encoding methods,
12015 such as Shift-JIS, but the other schemes cannot support the full range
12016 of wide wide characters.
12017 An attempt to output a character that cannot
12018 be represented using the encoding scheme for the file causes
12019 Constraint_Error to be raised. An invalid wide character sequence on
12020 input also causes Constraint_Error to be raised.
12023 * Wide_Wide_Text_IO Stream Pointer Positioning::
12024 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12027 @node Wide_Wide_Text_IO Stream Pointer Positioning
12028 @subsection Stream Pointer Positioning
12031 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12032 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12035 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12036 normal lower ASCII set (i.e.@: a character in the range:
12038 @smallexample @c ada
12039 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12043 then although the logical position of the file pointer is unchanged by
12044 the @code{Look_Ahead} call, the stream is physically positioned past the
12045 wide character sequence. Again this is to avoid the need for buffering
12046 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12047 indication that this situation has occurred so that this is not visible
12048 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
12049 can be observed if the wide text file shares a stream with another file.
12051 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12052 @subsection Reading and Writing Non-Regular Files
12055 As in the case of Text_IO, when a non-regular file is read, it is
12056 assumed that the file contains no page marks (any form characters are
12057 treated as data characters), and @code{End_Of_Page} always returns
12058 @code{False}. Similarly, the end of file indication is not sticky, so
12059 it is possible to read beyond an end of file.
12065 A stream file is a sequence of bytes, where individual elements are
12066 written to the file as described in the Ada Reference Manual. The type
12067 @code{Stream_Element} is simply a byte. There are two ways to read or
12068 write a stream file.
12072 The operations @code{Read} and @code{Write} directly read or write a
12073 sequence of stream elements with no control information.
12076 The stream attributes applied to a stream file transfer data in the
12077 manner described for stream attributes.
12081 @section Shared Files
12084 Section A.14 of the Ada Reference Manual allows implementations to
12085 provide a wide variety of behavior if an attempt is made to access the
12086 same external file with two or more internal files.
12088 To provide a full range of functionality, while at the same time
12089 minimizing the problems of portability caused by this implementation
12090 dependence, GNAT handles file sharing as follows:
12094 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12095 to open two or more files with the same full name is considered an error
12096 and is not supported. The exception @code{Use_Error} will be
12097 raised. Note that a file that is not explicitly closed by the program
12098 remains open until the program terminates.
12101 If the form parameter @samp{shared=no} appears in the form string, the
12102 file can be opened or created with its own separate stream identifier,
12103 regardless of whether other files sharing the same external file are
12104 opened. The exact effect depends on how the C stream routines handle
12105 multiple accesses to the same external files using separate streams.
12108 If the form parameter @samp{shared=yes} appears in the form string for
12109 each of two or more files opened using the same full name, the same
12110 stream is shared between these files, and the semantics are as described
12111 in Ada Reference Manual, Section A.14.
12115 When a program that opens multiple files with the same name is ported
12116 from another Ada compiler to GNAT, the effect will be that
12117 @code{Use_Error} is raised.
12119 The documentation of the original compiler and the documentation of the
12120 program should then be examined to determine if file sharing was
12121 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12122 and @code{Create} calls as required.
12124 When a program is ported from GNAT to some other Ada compiler, no
12125 special attention is required unless the @samp{shared=@var{xxx}} form
12126 parameter is used in the program. In this case, you must examine the
12127 documentation of the new compiler to see if it supports the required
12128 file sharing semantics, and form strings modified appropriately. Of
12129 course it may be the case that the program cannot be ported if the
12130 target compiler does not support the required functionality. The best
12131 approach in writing portable code is to avoid file sharing (and hence
12132 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12135 One common use of file sharing in Ada 83 is the use of instantiations of
12136 Sequential_IO on the same file with different types, to achieve
12137 heterogeneous input-output. Although this approach will work in GNAT if
12138 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12139 for this purpose (using the stream attributes)
12141 @node Filenames encoding
12142 @section Filenames encoding
12145 An encoding form parameter can be used to specify the filename
12146 encoding @samp{encoding=@var{xxx}}.
12150 If the form parameter @samp{encoding=utf8} appears in the form string, the
12151 filename must be encoded in UTF-8.
12154 If the form parameter @samp{encoding=8bits} appears in the form
12155 string, the filename must be a standard 8bits string.
12158 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12159 value UTF-8 is used. This encoding form parameter is only supported on
12160 the Windows platform. On the other Operating Systems the runtime is
12161 supporting UTF-8 natively.
12164 @section Open Modes
12167 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12168 using the mode shown in the following table:
12171 @center @code{Open} and @code{Create} Call Modes
12173 @b{OPEN } @b{CREATE}
12174 Append_File "r+" "w+"
12176 Out_File (Direct_IO) "r+" "w"
12177 Out_File (all other cases) "w" "w"
12178 Inout_File "r+" "w+"
12182 If text file translation is required, then either @samp{b} or @samp{t}
12183 is added to the mode, depending on the setting of Text. Text file
12184 translation refers to the mapping of CR/LF sequences in an external file
12185 to LF characters internally. This mapping only occurs in DOS and
12186 DOS-like systems, and is not relevant to other systems.
12188 A special case occurs with Stream_IO@. As shown in the above table, the
12189 file is initially opened in @samp{r} or @samp{w} mode for the
12190 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
12191 subsequently requires switching from reading to writing or vice-versa,
12192 then the file is reopened in @samp{r+} mode to permit the required operation.
12194 @node Operations on C Streams
12195 @section Operations on C Streams
12196 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12197 access to the C library functions for operations on C streams:
12199 @smallexample @c adanocomment
12200 package Interfaces.C_Streams is
12201 -- Note: the reason we do not use the types that are in
12202 -- Interfaces.C is that we want to avoid dragging in the
12203 -- code in this unit if possible.
12204 subtype chars is System.Address;
12205 -- Pointer to null-terminated array of characters
12206 subtype FILEs is System.Address;
12207 -- Corresponds to the C type FILE*
12208 subtype voids is System.Address;
12209 -- Corresponds to the C type void*
12210 subtype int is Integer;
12211 subtype long is Long_Integer;
12212 -- Note: the above types are subtypes deliberately, and it
12213 -- is part of this spec that the above correspondences are
12214 -- guaranteed. This means that it is legitimate to, for
12215 -- example, use Integer instead of int. We provide these
12216 -- synonyms for clarity, but in some cases it may be
12217 -- convenient to use the underlying types (for example to
12218 -- avoid an unnecessary dependency of a spec on the spec
12220 type size_t is mod 2 ** Standard'Address_Size;
12221 NULL_Stream : constant FILEs;
12222 -- Value returned (NULL in C) to indicate an
12223 -- fdopen/fopen/tmpfile error
12224 ----------------------------------
12225 -- Constants Defined in stdio.h --
12226 ----------------------------------
12227 EOF : constant int;
12228 -- Used by a number of routines to indicate error or
12230 IOFBF : constant int;
12231 IOLBF : constant int;
12232 IONBF : constant int;
12233 -- Used to indicate buffering mode for setvbuf call
12234 SEEK_CUR : constant int;
12235 SEEK_END : constant int;
12236 SEEK_SET : constant int;
12237 -- Used to indicate origin for fseek call
12238 function stdin return FILEs;
12239 function stdout return FILEs;
12240 function stderr return FILEs;
12241 -- Streams associated with standard files
12242 --------------------------
12243 -- Standard C functions --
12244 --------------------------
12245 -- The functions selected below are ones that are
12246 -- available in DOS, OS/2, UNIX and Xenix (but not
12247 -- necessarily in ANSI C). These are very thin interfaces
12248 -- which copy exactly the C headers. For more
12249 -- documentation on these functions, see the Microsoft C
12250 -- "Run-Time Library Reference" (Microsoft Press, 1990,
12251 -- ISBN 1-55615-225-6), which includes useful information
12252 -- on system compatibility.
12253 procedure clearerr (stream : FILEs);
12254 function fclose (stream : FILEs) return int;
12255 function fdopen (handle : int; mode : chars) return FILEs;
12256 function feof (stream : FILEs) return int;
12257 function ferror (stream : FILEs) return int;
12258 function fflush (stream : FILEs) return int;
12259 function fgetc (stream : FILEs) return int;
12260 function fgets (strng : chars; n : int; stream : FILEs)
12262 function fileno (stream : FILEs) return int;
12263 function fopen (filename : chars; Mode : chars)
12265 -- Note: to maintain target independence, use
12266 -- text_translation_required, a boolean variable defined in
12267 -- a-sysdep.c to deal with the target dependent text
12268 -- translation requirement. If this variable is set,
12269 -- then b/t should be appended to the standard mode
12270 -- argument to set the text translation mode off or on
12272 function fputc (C : int; stream : FILEs) return int;
12273 function fputs (Strng : chars; Stream : FILEs) return int;
12290 function ftell (stream : FILEs) return long;
12297 function isatty (handle : int) return int;
12298 procedure mktemp (template : chars);
12299 -- The return value (which is just a pointer to template)
12301 procedure rewind (stream : FILEs);
12302 function rmtmp return int;
12310 function tmpfile return FILEs;
12311 function ungetc (c : int; stream : FILEs) return int;
12312 function unlink (filename : chars) return int;
12313 ---------------------
12314 -- Extra functions --
12315 ---------------------
12316 -- These functions supply slightly thicker bindings than
12317 -- those above. They are derived from functions in the
12318 -- C Run-Time Library, but may do a bit more work than
12319 -- just directly calling one of the Library functions.
12320 function is_regular_file (handle : int) return int;
12321 -- Tests if given handle is for a regular file (result 1)
12322 -- or for a non-regular file (pipe or device, result 0).
12323 ---------------------------------
12324 -- Control of Text/Binary Mode --
12325 ---------------------------------
12326 -- If text_translation_required is true, then the following
12327 -- functions may be used to dynamically switch a file from
12328 -- binary to text mode or vice versa. These functions have
12329 -- no effect if text_translation_required is false (i.e. in
12330 -- normal UNIX mode). Use fileno to get a stream handle.
12331 procedure set_binary_mode (handle : int);
12332 procedure set_text_mode (handle : int);
12333 ----------------------------
12334 -- Full Path Name support --
12335 ----------------------------
12336 procedure full_name (nam : chars; buffer : chars);
12337 -- Given a NUL terminated string representing a file
12338 -- name, returns in buffer a NUL terminated string
12339 -- representing the full path name for the file name.
12340 -- On systems where it is relevant the drive is also
12341 -- part of the full path name. It is the responsibility
12342 -- of the caller to pass an actual parameter for buffer
12343 -- that is big enough for any full path name. Use
12344 -- max_path_len given below as the size of buffer.
12345 max_path_len : integer;
12346 -- Maximum length of an allowable full path name on the
12347 -- system, including a terminating NUL character.
12348 end Interfaces.C_Streams;
12351 @node Interfacing to C Streams
12352 @section Interfacing to C Streams
12355 The packages in this section permit interfacing Ada files to C Stream
12358 @smallexample @c ada
12359 with Interfaces.C_Streams;
12360 package Ada.Sequential_IO.C_Streams is
12361 function C_Stream (F : File_Type)
12362 return Interfaces.C_Streams.FILEs;
12364 (File : in out File_Type;
12365 Mode : in File_Mode;
12366 C_Stream : in Interfaces.C_Streams.FILEs;
12367 Form : in String := "");
12368 end Ada.Sequential_IO.C_Streams;
12370 with Interfaces.C_Streams;
12371 package Ada.Direct_IO.C_Streams is
12372 function C_Stream (F : File_Type)
12373 return Interfaces.C_Streams.FILEs;
12375 (File : in out File_Type;
12376 Mode : in File_Mode;
12377 C_Stream : in Interfaces.C_Streams.FILEs;
12378 Form : in String := "");
12379 end Ada.Direct_IO.C_Streams;
12381 with Interfaces.C_Streams;
12382 package Ada.Text_IO.C_Streams is
12383 function C_Stream (F : File_Type)
12384 return Interfaces.C_Streams.FILEs;
12386 (File : in out File_Type;
12387 Mode : in File_Mode;
12388 C_Stream : in Interfaces.C_Streams.FILEs;
12389 Form : in String := "");
12390 end Ada.Text_IO.C_Streams;
12392 with Interfaces.C_Streams;
12393 package Ada.Wide_Text_IO.C_Streams is
12394 function C_Stream (F : File_Type)
12395 return Interfaces.C_Streams.FILEs;
12397 (File : in out File_Type;
12398 Mode : in File_Mode;
12399 C_Stream : in Interfaces.C_Streams.FILEs;
12400 Form : in String := "");
12401 end Ada.Wide_Text_IO.C_Streams;
12403 with Interfaces.C_Streams;
12404 package Ada.Wide_Wide_Text_IO.C_Streams is
12405 function C_Stream (F : File_Type)
12406 return Interfaces.C_Streams.FILEs;
12408 (File : in out File_Type;
12409 Mode : in File_Mode;
12410 C_Stream : in Interfaces.C_Streams.FILEs;
12411 Form : in String := "");
12412 end Ada.Wide_Wide_Text_IO.C_Streams;
12414 with Interfaces.C_Streams;
12415 package Ada.Stream_IO.C_Streams is
12416 function C_Stream (F : File_Type)
12417 return Interfaces.C_Streams.FILEs;
12419 (File : in out File_Type;
12420 Mode : in File_Mode;
12421 C_Stream : in Interfaces.C_Streams.FILEs;
12422 Form : in String := "");
12423 end Ada.Stream_IO.C_Streams;
12427 In each of these six packages, the @code{C_Stream} function obtains the
12428 @code{FILE} pointer from a currently opened Ada file. It is then
12429 possible to use the @code{Interfaces.C_Streams} package to operate on
12430 this stream, or the stream can be passed to a C program which can
12431 operate on it directly. Of course the program is responsible for
12432 ensuring that only appropriate sequences of operations are executed.
12434 One particular use of relevance to an Ada program is that the
12435 @code{setvbuf} function can be used to control the buffering of the
12436 stream used by an Ada file. In the absence of such a call the standard
12437 default buffering is used.
12439 The @code{Open} procedures in these packages open a file giving an
12440 existing C Stream instead of a file name. Typically this stream is
12441 imported from a C program, allowing an Ada file to operate on an
12444 @node The GNAT Library
12445 @chapter The GNAT Library
12448 The GNAT library contains a number of general and special purpose packages.
12449 It represents functionality that the GNAT developers have found useful, and
12450 which is made available to GNAT users. The packages described here are fully
12451 supported, and upwards compatibility will be maintained in future releases,
12452 so you can use these facilities with the confidence that the same functionality
12453 will be available in future releases.
12455 The chapter here simply gives a brief summary of the facilities available.
12456 The full documentation is found in the spec file for the package. The full
12457 sources of these library packages, including both spec and body, are provided
12458 with all GNAT releases. For example, to find out the full specifications of
12459 the SPITBOL pattern matching capability, including a full tutorial and
12460 extensive examples, look in the @file{g-spipat.ads} file in the library.
12462 For each entry here, the package name (as it would appear in a @code{with}
12463 clause) is given, followed by the name of the corresponding spec file in
12464 parentheses. The packages are children in four hierarchies, @code{Ada},
12465 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
12466 GNAT-specific hierarchy.
12468 Note that an application program should only use packages in one of these
12469 four hierarchies if the package is defined in the Ada Reference Manual,
12470 or is listed in this section of the GNAT Programmers Reference Manual.
12471 All other units should be considered internal implementation units and
12472 should not be directly @code{with}'ed by application code. The use of
12473 a @code{with} statement that references one of these internal implementation
12474 units makes an application potentially dependent on changes in versions
12475 of GNAT, and will generate a warning message.
12478 * Ada.Characters.Latin_9 (a-chlat9.ads)::
12479 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
12480 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
12481 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
12482 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
12483 * Ada.Command_Line.Remove (a-colire.ads)::
12484 * Ada.Command_Line.Environment (a-colien.ads)::
12485 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
12486 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
12487 * Ada.Exceptions.Traceback (a-exctra.ads)::
12488 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
12489 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
12490 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
12491 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
12492 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
12493 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
12494 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
12495 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
12496 * GNAT.Altivec (g-altive.ads)::
12497 * GNAT.Altivec.Conversions (g-altcon.ads)::
12498 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
12499 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
12500 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
12501 * GNAT.Array_Split (g-arrspl.ads)::
12502 * GNAT.AWK (g-awk.ads)::
12503 * GNAT.Bounded_Buffers (g-boubuf.ads)::
12504 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
12505 * GNAT.Bubble_Sort (g-bubsor.ads)::
12506 * GNAT.Bubble_Sort_A (g-busora.ads)::
12507 * GNAT.Bubble_Sort_G (g-busorg.ads)::
12508 * GNAT.Byte_Swapping (g-bytswa.ads)::
12509 * GNAT.Calendar (g-calend.ads)::
12510 * GNAT.Calendar.Time_IO (g-catiio.ads)::
12511 * GNAT.CRC32 (g-crc32.ads)::
12512 * GNAT.Case_Util (g-casuti.ads)::
12513 * GNAT.CGI (g-cgi.ads)::
12514 * GNAT.CGI.Cookie (g-cgicoo.ads)::
12515 * GNAT.CGI.Debug (g-cgideb.ads)::
12516 * GNAT.Command_Line (g-comlin.ads)::
12517 * GNAT.Compiler_Version (g-comver.ads)::
12518 * GNAT.Ctrl_C (g-ctrl_c.ads)::
12519 * GNAT.Current_Exception (g-curexc.ads)::
12520 * GNAT.Debug_Pools (g-debpoo.ads)::
12521 * GNAT.Debug_Utilities (g-debuti.ads)::
12522 * GNAT.Directory_Operations (g-dirope.ads)::
12523 * GNAT.Dynamic_HTables (g-dynhta.ads)::
12524 * GNAT.Dynamic_Tables (g-dyntab.ads)::
12525 * GNAT.Exception_Actions (g-excact.ads)::
12526 * GNAT.Exception_Traces (g-exctra.ads)::
12527 * GNAT.Exceptions (g-except.ads)::
12528 * GNAT.Expect (g-expect.ads)::
12529 * GNAT.Float_Control (g-flocon.ads)::
12530 * GNAT.Heap_Sort (g-heasor.ads)::
12531 * GNAT.Heap_Sort_A (g-hesora.ads)::
12532 * GNAT.Heap_Sort_G (g-hesorg.ads)::
12533 * GNAT.HTable (g-htable.ads)::
12534 * GNAT.IO (g-io.ads)::
12535 * GNAT.IO_Aux (g-io_aux.ads)::
12536 * GNAT.Lock_Files (g-locfil.ads)::
12537 * GNAT.MD5 (g-md5.ads)::
12538 * GNAT.Memory_Dump (g-memdum.ads)::
12539 * GNAT.Most_Recent_Exception (g-moreex.ads)::
12540 * GNAT.OS_Lib (g-os_lib.ads)::
12541 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
12542 * GNAT.Regexp (g-regexp.ads)::
12543 * GNAT.Registry (g-regist.ads)::
12544 * GNAT.Regpat (g-regpat.ads)::
12545 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
12546 * GNAT.Semaphores (g-semaph.ads)::
12547 * GNAT.SHA1 (g-sha1.ads)::
12548 * GNAT.Signals (g-signal.ads)::
12549 * GNAT.Sockets (g-socket.ads)::
12550 * GNAT.Source_Info (g-souinf.ads)::
12551 * GNAT.Spell_Checker (g-speche.ads)::
12552 * GNAT.Spitbol.Patterns (g-spipat.ads)::
12553 * GNAT.Spitbol (g-spitbo.ads)::
12554 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
12555 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
12556 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
12557 * GNAT.Strings (g-string.ads)::
12558 * GNAT.String_Split (g-strspl.ads)::
12559 * GNAT.UTF_32 (g-utf_32.ads)::
12560 * GNAT.Table (g-table.ads)::
12561 * GNAT.Task_Lock (g-tasloc.ads)::
12562 * GNAT.Threads (g-thread.ads)::
12563 * GNAT.Traceback (g-traceb.ads)::
12564 * GNAT.Traceback.Symbolic (g-trasym.ads)::
12565 * GNAT.Wide_String_Split (g-wistsp.ads)::
12566 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
12567 * Interfaces.C.Extensions (i-cexten.ads)::
12568 * Interfaces.C.Streams (i-cstrea.ads)::
12569 * Interfaces.CPP (i-cpp.ads)::
12570 * Interfaces.Os2lib (i-os2lib.ads)::
12571 * Interfaces.Os2lib.Errors (i-os2err.ads)::
12572 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
12573 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
12574 * Interfaces.Packed_Decimal (i-pacdec.ads)::
12575 * Interfaces.VxWorks (i-vxwork.ads)::
12576 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
12577 * System.Address_Image (s-addima.ads)::
12578 * System.Assertions (s-assert.ads)::
12579 * System.Memory (s-memory.ads)::
12580 * System.Partition_Interface (s-parint.ads)::
12581 * System.Restrictions (s-restri.ads)::
12582 * System.Rident (s-rident.ads)::
12583 * System.Task_Info (s-tasinf.ads)::
12584 * System.Wch_Cnv (s-wchcnv.ads)::
12585 * System.Wch_Con (s-wchcon.ads)::
12588 @node Ada.Characters.Latin_9 (a-chlat9.ads)
12589 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12590 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12591 @cindex Latin_9 constants for Character
12594 This child of @code{Ada.Characters}
12595 provides a set of definitions corresponding to those in the
12596 RM-defined package @code{Ada.Characters.Latin_1} but with the
12597 few modifications required for @code{Latin-9}
12598 The provision of such a package
12599 is specifically authorized by the Ada Reference Manual
12602 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
12603 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12604 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12605 @cindex Latin_1 constants for Wide_Character
12608 This child of @code{Ada.Characters}
12609 provides a set of definitions corresponding to those in the
12610 RM-defined package @code{Ada.Characters.Latin_1} but with the
12611 types of the constants being @code{Wide_Character}
12612 instead of @code{Character}. The provision of such a package
12613 is specifically authorized by the Ada Reference Manual
12616 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
12617 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12618 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12619 @cindex Latin_9 constants for Wide_Character
12622 This child of @code{Ada.Characters}
12623 provides a set of definitions corresponding to those in the
12624 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12625 types of the constants being @code{Wide_Character}
12626 instead of @code{Character}. The provision of such a package
12627 is specifically authorized by the Ada Reference Manual
12630 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
12631 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12632 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12633 @cindex Latin_1 constants for Wide_Wide_Character
12636 This child of @code{Ada.Characters}
12637 provides a set of definitions corresponding to those in the
12638 RM-defined package @code{Ada.Characters.Latin_1} but with the
12639 types of the constants being @code{Wide_Wide_Character}
12640 instead of @code{Character}. The provision of such a package
12641 is specifically authorized by the Ada Reference Manual
12644 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
12645 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12646 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12647 @cindex Latin_9 constants for Wide_Wide_Character
12650 This child of @code{Ada.Characters}
12651 provides a set of definitions corresponding to those in the
12652 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12653 types of the constants being @code{Wide_Wide_Character}
12654 instead of @code{Character}. The provision of such a package
12655 is specifically authorized by the Ada Reference Manual
12658 @node Ada.Command_Line.Remove (a-colire.ads)
12659 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12660 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12661 @cindex Removing command line arguments
12662 @cindex Command line, argument removal
12665 This child of @code{Ada.Command_Line}
12666 provides a mechanism for logically removing
12667 arguments from the argument list. Once removed, an argument is not visible
12668 to further calls on the subprograms in @code{Ada.Command_Line} will not
12669 see the removed argument.
12671 @node Ada.Command_Line.Environment (a-colien.ads)
12672 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12673 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12674 @cindex Environment entries
12677 This child of @code{Ada.Command_Line}
12678 provides a mechanism for obtaining environment values on systems
12679 where this concept makes sense.
12681 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12682 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12683 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12684 @cindex C Streams, Interfacing with Direct_IO
12687 This package provides subprograms that allow interfacing between
12688 C streams and @code{Direct_IO}. The stream identifier can be
12689 extracted from a file opened on the Ada side, and an Ada file
12690 can be constructed from a stream opened on the C side.
12692 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12693 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12694 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12695 @cindex Null_Occurrence, testing for
12698 This child subprogram provides a way of testing for the null
12699 exception occurrence (@code{Null_Occurrence}) without raising
12702 @node Ada.Exceptions.Traceback (a-exctra.ads)
12703 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12704 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12705 @cindex Traceback for Exception Occurrence
12708 This child package provides the subprogram (@code{Tracebacks}) to
12709 give a traceback array of addresses based on an exception
12712 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12713 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12714 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12715 @cindex C Streams, Interfacing with Sequential_IO
12718 This package provides subprograms that allow interfacing between
12719 C streams and @code{Sequential_IO}. The stream identifier can be
12720 extracted from a file opened on the Ada side, and an Ada file
12721 can be constructed from a stream opened on the C side.
12723 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12724 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12725 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12726 @cindex C Streams, Interfacing with Stream_IO
12729 This package provides subprograms that allow interfacing between
12730 C streams and @code{Stream_IO}. The stream identifier can be
12731 extracted from a file opened on the Ada side, and an Ada file
12732 can be constructed from a stream opened on the C side.
12734 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
12735 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12736 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12737 @cindex @code{Unbounded_String}, IO support
12738 @cindex @code{Text_IO}, extensions for unbounded strings
12741 This package provides subprograms for Text_IO for unbounded
12742 strings, avoiding the necessity for an intermediate operation
12743 with ordinary strings.
12745 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
12746 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12747 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12748 @cindex @code{Unbounded_Wide_String}, IO support
12749 @cindex @code{Text_IO}, extensions for unbounded wide strings
12752 This package provides subprograms for Text_IO for unbounded
12753 wide strings, avoiding the necessity for an intermediate operation
12754 with ordinary wide strings.
12756 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
12757 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12758 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12759 @cindex @code{Unbounded_Wide_Wide_String}, IO support
12760 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
12763 This package provides subprograms for Text_IO for unbounded
12764 wide wide strings, avoiding the necessity for an intermediate operation
12765 with ordinary wide wide strings.
12767 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
12768 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12769 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12770 @cindex C Streams, Interfacing with @code{Text_IO}
12773 This package provides subprograms that allow interfacing between
12774 C streams and @code{Text_IO}. The stream identifier can be
12775 extracted from a file opened on the Ada side, and an Ada file
12776 can be constructed from a stream opened on the C side.
12778 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
12779 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12780 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12781 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
12784 This package provides subprograms that allow interfacing between
12785 C streams and @code{Wide_Text_IO}. The stream identifier can be
12786 extracted from a file opened on the Ada side, and an Ada file
12787 can be constructed from a stream opened on the C side.
12789 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
12790 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12791 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12792 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
12795 This package provides subprograms that allow interfacing between
12796 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
12797 extracted from a file opened on the Ada side, and an Ada file
12798 can be constructed from a stream opened on the C side.
12800 @node GNAT.Altivec (g-altive.ads)
12801 @section @code{GNAT.Altivec} (@file{g-altive.ads})
12802 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
12806 This is the root package of the GNAT AltiVec binding. It provides
12807 definitions of constants and types common to all the versions of the
12810 @node GNAT.Altivec.Conversions (g-altcon.ads)
12811 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12812 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12816 This package provides the Vector/View conversion routines.
12818 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
12819 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12820 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12824 This package exposes the Ada interface to the AltiVec operations on
12825 vector objects. A soft emulation is included by default in the GNAT
12826 library. The hard binding is provided as a separate package. This unit
12827 is common to both bindings.
12829 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
12830 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12831 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12835 This package exposes the various vector types part of the Ada binding
12836 to AltiVec facilities.
12838 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
12839 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12840 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12844 This package provides public 'View' data types from/to which private
12845 vector representations can be converted via
12846 GNAT.Altivec.Conversions. This allows convenient access to individual
12847 vector elements and provides a simple way to initialize vector
12850 @node GNAT.Array_Split (g-arrspl.ads)
12851 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12852 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12853 @cindex Array splitter
12856 Useful array-manipulation routines: given a set of separators, split
12857 an array wherever the separators appear, and provide direct access
12858 to the resulting slices.
12860 @node GNAT.AWK (g-awk.ads)
12861 @section @code{GNAT.AWK} (@file{g-awk.ads})
12862 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
12867 Provides AWK-like parsing functions, with an easy interface for parsing one
12868 or more files containing formatted data. The file is viewed as a database
12869 where each record is a line and a field is a data element in this line.
12871 @node GNAT.Bounded_Buffers (g-boubuf.ads)
12872 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12873 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12875 @cindex Bounded Buffers
12878 Provides a concurrent generic bounded buffer abstraction. Instances are
12879 useful directly or as parts of the implementations of other abstractions,
12882 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
12883 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12884 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12889 Provides a thread-safe asynchronous intertask mailbox communication facility.
12891 @node GNAT.Bubble_Sort (g-bubsor.ads)
12892 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12893 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12895 @cindex Bubble sort
12898 Provides a general implementation of bubble sort usable for sorting arbitrary
12899 data items. Exchange and comparison procedures are provided by passing
12900 access-to-procedure values.
12902 @node GNAT.Bubble_Sort_A (g-busora.ads)
12903 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12904 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12906 @cindex Bubble sort
12909 Provides a general implementation of bubble sort usable for sorting arbitrary
12910 data items. Move and comparison procedures are provided by passing
12911 access-to-procedure values. This is an older version, retained for
12912 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
12914 @node GNAT.Bubble_Sort_G (g-busorg.ads)
12915 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12916 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12918 @cindex Bubble sort
12921 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
12922 are provided as generic parameters, this improves efficiency, especially
12923 if the procedures can be inlined, at the expense of duplicating code for
12924 multiple instantiations.
12926 @node GNAT.Byte_Swapping (g-bytswa.ads)
12927 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
12928 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
12929 @cindex Byte swapping
12933 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
12934 Machine-specific implementations are available in some cases.
12936 @node GNAT.Calendar (g-calend.ads)
12937 @section @code{GNAT.Calendar} (@file{g-calend.ads})
12938 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
12939 @cindex @code{Calendar}
12942 Extends the facilities provided by @code{Ada.Calendar} to include handling
12943 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
12944 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
12945 C @code{timeval} format.
12947 @node GNAT.Calendar.Time_IO (g-catiio.ads)
12948 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12949 @cindex @code{Calendar}
12951 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12953 @node GNAT.CRC32 (g-crc32.ads)
12954 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
12955 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
12957 @cindex Cyclic Redundancy Check
12960 This package implements the CRC-32 algorithm. For a full description
12961 of this algorithm see
12962 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
12963 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
12964 Aug.@: 1988. Sarwate, D.V@.
12966 @node GNAT.Case_Util (g-casuti.ads)
12967 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
12968 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
12969 @cindex Casing utilities
12970 @cindex Character handling (@code{GNAT.Case_Util})
12973 A set of simple routines for handling upper and lower casing of strings
12974 without the overhead of the full casing tables
12975 in @code{Ada.Characters.Handling}.
12977 @node GNAT.CGI (g-cgi.ads)
12978 @section @code{GNAT.CGI} (@file{g-cgi.ads})
12979 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
12980 @cindex CGI (Common Gateway Interface)
12983 This is a package for interfacing a GNAT program with a Web server via the
12984 Common Gateway Interface (CGI)@. Basically this package parses the CGI
12985 parameters, which are a set of key/value pairs sent by the Web server. It
12986 builds a table whose index is the key and provides some services to deal
12989 @node GNAT.CGI.Cookie (g-cgicoo.ads)
12990 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12991 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12992 @cindex CGI (Common Gateway Interface) cookie support
12993 @cindex Cookie support in CGI
12996 This is a package to interface a GNAT program with a Web server via the
12997 Common Gateway Interface (CGI). It exports services to deal with Web
12998 cookies (piece of information kept in the Web client software).
13000 @node GNAT.CGI.Debug (g-cgideb.ads)
13001 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13002 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13003 @cindex CGI (Common Gateway Interface) debugging
13006 This is a package to help debugging CGI (Common Gateway Interface)
13007 programs written in Ada.
13009 @node GNAT.Command_Line (g-comlin.ads)
13010 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13011 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13012 @cindex Command line
13015 Provides a high level interface to @code{Ada.Command_Line} facilities,
13016 including the ability to scan for named switches with optional parameters
13017 and expand file names using wild card notations.
13019 @node GNAT.Compiler_Version (g-comver.ads)
13020 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13021 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13022 @cindex Compiler Version
13023 @cindex Version, of compiler
13026 Provides a routine for obtaining the version of the compiler used to
13027 compile the program. More accurately this is the version of the binder
13028 used to bind the program (this will normally be the same as the version
13029 of the compiler if a consistent tool set is used to compile all units
13032 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13033 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13034 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13038 Provides a simple interface to handle Ctrl-C keyboard events.
13040 @node GNAT.Current_Exception (g-curexc.ads)
13041 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13042 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13043 @cindex Current exception
13044 @cindex Exception retrieval
13047 Provides access to information on the current exception that has been raised
13048 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13049 specification syntax.
13050 This is particularly useful in simulating typical facilities for
13051 obtaining information about exceptions provided by Ada 83 compilers.
13053 @node GNAT.Debug_Pools (g-debpoo.ads)
13054 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13055 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13057 @cindex Debug pools
13058 @cindex Memory corruption debugging
13061 Provide a debugging storage pools that helps tracking memory corruption
13062 problems. See section ``Finding memory problems with GNAT Debug Pool'' in
13063 the @cite{GNAT User's Guide}.
13065 @node GNAT.Debug_Utilities (g-debuti.ads)
13066 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13067 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13071 Provides a few useful utilities for debugging purposes, including conversion
13072 to and from string images of address values. Supports both C and Ada formats
13073 for hexadecimal literals.
13075 @node GNAT.Directory_Operations (g-dirope.ads)
13076 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13077 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13078 @cindex Directory operations
13081 Provides a set of routines for manipulating directories, including changing
13082 the current directory, making new directories, and scanning the files in a
13085 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13086 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13087 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13088 @cindex Hash tables
13091 A generic implementation of hash tables that can be used to hash arbitrary
13092 data. Provided in two forms, a simple form with built in hash functions,
13093 and a more complex form in which the hash function is supplied.
13096 This package provides a facility similar to that of @code{GNAT.HTable},
13097 except that this package declares a type that can be used to define
13098 dynamic instances of the hash table, while an instantiation of
13099 @code{GNAT.HTable} creates a single instance of the hash table.
13101 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13102 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13103 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13104 @cindex Table implementation
13105 @cindex Arrays, extendable
13108 A generic package providing a single dimension array abstraction where the
13109 length of the array can be dynamically modified.
13112 This package provides a facility similar to that of @code{GNAT.Table},
13113 except that this package declares a type that can be used to define
13114 dynamic instances of the table, while an instantiation of
13115 @code{GNAT.Table} creates a single instance of the table type.
13117 @node GNAT.Exception_Actions (g-excact.ads)
13118 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13119 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13120 @cindex Exception actions
13123 Provides callbacks when an exception is raised. Callbacks can be registered
13124 for specific exceptions, or when any exception is raised. This
13125 can be used for instance to force a core dump to ease debugging.
13127 @node GNAT.Exception_Traces (g-exctra.ads)
13128 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13129 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13130 @cindex Exception traces
13134 Provides an interface allowing to control automatic output upon exception
13137 @node GNAT.Exceptions (g-except.ads)
13138 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
13139 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
13140 @cindex Exceptions, Pure
13141 @cindex Pure packages, exceptions
13144 Normally it is not possible to raise an exception with
13145 a message from a subprogram in a pure package, since the
13146 necessary types and subprograms are in @code{Ada.Exceptions}
13147 which is not a pure unit. @code{GNAT.Exceptions} provides a
13148 facility for getting around this limitation for a few
13149 predefined exceptions, and for example allow raising
13150 @code{Constraint_Error} with a message from a pure subprogram.
13152 @node GNAT.Expect (g-expect.ads)
13153 @section @code{GNAT.Expect} (@file{g-expect.ads})
13154 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
13157 Provides a set of subprograms similar to what is available
13158 with the standard Tcl Expect tool.
13159 It allows you to easily spawn and communicate with an external process.
13160 You can send commands or inputs to the process, and compare the output
13161 with some expected regular expression. Currently @code{GNAT.Expect}
13162 is implemented on all native GNAT ports except for OpenVMS@.
13163 It is not implemented for cross ports, and in particular is not
13164 implemented for VxWorks or LynxOS@.
13166 @node GNAT.Float_Control (g-flocon.ads)
13167 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
13168 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
13169 @cindex Floating-Point Processor
13172 Provides an interface for resetting the floating-point processor into the
13173 mode required for correct semantic operation in Ada. Some third party
13174 library calls may cause this mode to be modified, and the Reset procedure
13175 in this package can be used to reestablish the required mode.
13177 @node GNAT.Heap_Sort (g-heasor.ads)
13178 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13179 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13183 Provides a general implementation of heap sort usable for sorting arbitrary
13184 data items. Exchange and comparison procedures are provided by passing
13185 access-to-procedure values. The algorithm used is a modified heap sort
13186 that performs approximately N*log(N) comparisons in the worst case.
13188 @node GNAT.Heap_Sort_A (g-hesora.ads)
13189 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13190 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13194 Provides a general implementation of heap sort usable for sorting arbitrary
13195 data items. Move and comparison procedures are provided by passing
13196 access-to-procedure values. The algorithm used is a modified heap sort
13197 that performs approximately N*log(N) comparisons in the worst case.
13198 This differs from @code{GNAT.Heap_Sort} in having a less convenient
13199 interface, but may be slightly more efficient.
13201 @node GNAT.Heap_Sort_G (g-hesorg.ads)
13202 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13203 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13207 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
13208 are provided as generic parameters, this improves efficiency, especially
13209 if the procedures can be inlined, at the expense of duplicating code for
13210 multiple instantiations.
13212 @node GNAT.HTable (g-htable.ads)
13213 @section @code{GNAT.HTable} (@file{g-htable.ads})
13214 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
13215 @cindex Hash tables
13218 A generic implementation of hash tables that can be used to hash arbitrary
13219 data. Provides two approaches, one a simple static approach, and the other
13220 allowing arbitrary dynamic hash tables.
13222 @node GNAT.IO (g-io.ads)
13223 @section @code{GNAT.IO} (@file{g-io.ads})
13224 @cindex @code{GNAT.IO} (@file{g-io.ads})
13226 @cindex Input/Output facilities
13229 A simple preelaborable input-output package that provides a subset of
13230 simple Text_IO functions for reading characters and strings from
13231 Standard_Input, and writing characters, strings and integers to either
13232 Standard_Output or Standard_Error.
13234 @node GNAT.IO_Aux (g-io_aux.ads)
13235 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13236 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13238 @cindex Input/Output facilities
13240 Provides some auxiliary functions for use with Text_IO, including a test
13241 for whether a file exists, and functions for reading a line of text.
13243 @node GNAT.Lock_Files (g-locfil.ads)
13244 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13245 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13246 @cindex File locking
13247 @cindex Locking using files
13250 Provides a general interface for using files as locks. Can be used for
13251 providing program level synchronization.
13253 @node GNAT.MD5 (g-md5.ads)
13254 @section @code{GNAT.MD5} (@file{g-md5.ads})
13255 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
13256 @cindex Message Digest MD5
13259 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
13261 @node GNAT.Memory_Dump (g-memdum.ads)
13262 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13263 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13264 @cindex Dump Memory
13267 Provides a convenient routine for dumping raw memory to either the
13268 standard output or standard error files. Uses GNAT.IO for actual
13271 @node GNAT.Most_Recent_Exception (g-moreex.ads)
13272 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13273 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13274 @cindex Exception, obtaining most recent
13277 Provides access to the most recently raised exception. Can be used for
13278 various logging purposes, including duplicating functionality of some
13279 Ada 83 implementation dependent extensions.
13281 @node GNAT.OS_Lib (g-os_lib.ads)
13282 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13283 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13284 @cindex Operating System interface
13285 @cindex Spawn capability
13288 Provides a range of target independent operating system interface functions,
13289 including time/date management, file operations, subprocess management,
13290 including a portable spawn procedure, and access to environment variables
13291 and error return codes.
13293 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
13294 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13295 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13296 @cindex Hash functions
13299 Provides a generator of static minimal perfect hash functions. No
13300 collisions occur and each item can be retrieved from the table in one
13301 probe (perfect property). The hash table size corresponds to the exact
13302 size of the key set and no larger (minimal property). The key set has to
13303 be know in advance (static property). The hash functions are also order
13304 preserving. If w2 is inserted after w1 in the generator, their
13305 hashcode are in the same order. These hashing functions are very
13306 convenient for use with realtime applications.
13308 @node GNAT.Regexp (g-regexp.ads)
13309 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
13310 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
13311 @cindex Regular expressions
13312 @cindex Pattern matching
13315 A simple implementation of regular expressions, using a subset of regular
13316 expression syntax copied from familiar Unix style utilities. This is the
13317 simples of the three pattern matching packages provided, and is particularly
13318 suitable for ``file globbing'' applications.
13320 @node GNAT.Registry (g-regist.ads)
13321 @section @code{GNAT.Registry} (@file{g-regist.ads})
13322 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
13323 @cindex Windows Registry
13326 This is a high level binding to the Windows registry. It is possible to
13327 do simple things like reading a key value, creating a new key. For full
13328 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
13329 package provided with the Win32Ada binding
13331 @node GNAT.Regpat (g-regpat.ads)
13332 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
13333 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
13334 @cindex Regular expressions
13335 @cindex Pattern matching
13338 A complete implementation of Unix-style regular expression matching, copied
13339 from the original V7 style regular expression library written in C by
13340 Henry Spencer (and binary compatible with this C library).
13342 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
13343 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13344 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13345 @cindex Secondary Stack Info
13348 Provide the capability to query the high water mark of the current task's
13351 @node GNAT.Semaphores (g-semaph.ads)
13352 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
13353 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
13357 Provides classic counting and binary semaphores using protected types.
13359 @node GNAT.SHA1 (g-sha1.ads)
13360 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
13361 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
13362 @cindex Secure Hash Algorithm SHA-1
13365 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
13367 @node GNAT.Signals (g-signal.ads)
13368 @section @code{GNAT.Signals} (@file{g-signal.ads})
13369 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
13373 Provides the ability to manipulate the blocked status of signals on supported
13376 @node GNAT.Sockets (g-socket.ads)
13377 @section @code{GNAT.Sockets} (@file{g-socket.ads})
13378 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
13382 A high level and portable interface to develop sockets based applications.
13383 This package is based on the sockets thin binding found in
13384 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
13385 on all native GNAT ports except for OpenVMS@. It is not implemented
13386 for the LynxOS@ cross port.
13388 @node GNAT.Source_Info (g-souinf.ads)
13389 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
13390 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
13391 @cindex Source Information
13394 Provides subprograms that give access to source code information known at
13395 compile time, such as the current file name and line number.
13397 @node GNAT.Spell_Checker (g-speche.ads)
13398 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13399 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13400 @cindex Spell checking
13403 Provides a function for determining whether one string is a plausible
13404 near misspelling of another string.
13406 @node GNAT.Spitbol.Patterns (g-spipat.ads)
13407 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13408 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13409 @cindex SPITBOL pattern matching
13410 @cindex Pattern matching
13413 A complete implementation of SNOBOL4 style pattern matching. This is the
13414 most elaborate of the pattern matching packages provided. It fully duplicates
13415 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
13416 efficient algorithm developed by Robert Dewar for the SPITBOL system.
13418 @node GNAT.Spitbol (g-spitbo.ads)
13419 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13420 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13421 @cindex SPITBOL interface
13424 The top level package of the collection of SPITBOL-style functionality, this
13425 package provides basic SNOBOL4 string manipulation functions, such as
13426 Pad, Reverse, Trim, Substr capability, as well as a generic table function
13427 useful for constructing arbitrary mappings from strings in the style of
13428 the SNOBOL4 TABLE function.
13430 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
13431 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13432 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13433 @cindex Sets of strings
13434 @cindex SPITBOL Tables
13437 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13438 for type @code{Standard.Boolean}, giving an implementation of sets of
13441 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
13442 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13443 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13444 @cindex Integer maps
13446 @cindex SPITBOL Tables
13449 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13450 for type @code{Standard.Integer}, giving an implementation of maps
13451 from string to integer values.
13453 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
13454 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13455 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13456 @cindex String maps
13458 @cindex SPITBOL Tables
13461 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
13462 a variable length string type, giving an implementation of general
13463 maps from strings to strings.
13465 @node GNAT.Strings (g-string.ads)
13466 @section @code{GNAT.Strings} (@file{g-string.ads})
13467 @cindex @code{GNAT.Strings} (@file{g-string.ads})
13470 Common String access types and related subprograms. Basically it
13471 defines a string access and an array of string access types.
13473 @node GNAT.String_Split (g-strspl.ads)
13474 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
13475 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
13476 @cindex String splitter
13479 Useful string manipulation routines: given a set of separators, split
13480 a string wherever the separators appear, and provide direct access
13481 to the resulting slices. This package is instantiated from
13482 @code{GNAT.Array_Split}.
13484 @node GNAT.UTF_32 (g-utf_32.ads)
13485 @section @code{GNAT.UTF_32} (@file{g-table.ads})
13486 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
13487 @cindex Wide character codes
13490 This is a package intended to be used in conjunction with the
13491 @code{Wide_Character} type in Ada 95 and the
13492 @code{Wide_Wide_Character} type in Ada 2005 (available
13493 in @code{GNAT} in Ada 2005 mode). This package contains
13494 Unicode categorization routines, as well as lexical
13495 categorization routines corresponding to the Ada 2005
13496 lexical rules for identifiers and strings, and also a
13497 lower case to upper case fold routine corresponding to
13498 the Ada 2005 rules for identifier equivalence.
13500 @node GNAT.Table (g-table.ads)
13501 @section @code{GNAT.Table} (@file{g-table.ads})
13502 @cindex @code{GNAT.Table} (@file{g-table.ads})
13503 @cindex Table implementation
13504 @cindex Arrays, extendable
13507 A generic package providing a single dimension array abstraction where the
13508 length of the array can be dynamically modified.
13511 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
13512 except that this package declares a single instance of the table type,
13513 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
13514 used to define dynamic instances of the table.
13516 @node GNAT.Task_Lock (g-tasloc.ads)
13517 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13518 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13519 @cindex Task synchronization
13520 @cindex Task locking
13524 A very simple facility for locking and unlocking sections of code using a
13525 single global task lock. Appropriate for use in situations where contention
13526 between tasks is very rarely expected.
13528 @node GNAT.Threads (g-thread.ads)
13529 @section @code{GNAT.Threads} (@file{g-thread.ads})
13530 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
13531 @cindex Foreign threads
13532 @cindex Threads, foreign
13535 Provides facilities for creating and destroying threads with explicit calls.
13536 These threads are known to the GNAT run-time system. These subprograms are
13537 exported C-convention procedures intended to be called from foreign code.
13538 By using these primitives rather than directly calling operating systems
13539 routines, compatibility with the Ada tasking run-time is provided.
13541 @node GNAT.Traceback (g-traceb.ads)
13542 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
13543 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
13544 @cindex Trace back facilities
13547 Provides a facility for obtaining non-symbolic traceback information, useful
13548 in various debugging situations.
13550 @node GNAT.Traceback.Symbolic (g-trasym.ads)
13551 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13552 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13553 @cindex Trace back facilities
13556 Provides symbolic traceback information that includes the subprogram
13557 name and line number information. Note that this capability is not available
13558 on all targets, see g-trasym.ads for list of supported targets.
13560 @node GNAT.Wide_String_Split (g-wistsp.ads)
13561 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13562 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13563 @cindex Wide_String splitter
13566 Useful wide string manipulation routines: given a set of separators, split
13567 a wide string wherever the separators appear, and provide direct access
13568 to the resulting slices. This package is instantiated from
13569 @code{GNAT.Array_Split}.
13571 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
13572 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13573 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13574 @cindex Wide_Wide_String splitter
13577 Useful wide wide string manipulation routines: given a set of separators, split
13578 a wide wide string wherever the separators appear, and provide direct access
13579 to the resulting slices. This package is instantiated from
13580 @code{GNAT.Array_Split}.
13582 @node Interfaces.C.Extensions (i-cexten.ads)
13583 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13584 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13587 This package contains additional C-related definitions, intended
13588 for use with either manually or automatically generated bindings
13591 @node Interfaces.C.Streams (i-cstrea.ads)
13592 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13593 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13594 @cindex C streams, interfacing
13597 This package is a binding for the most commonly used operations
13600 @node Interfaces.CPP (i-cpp.ads)
13601 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
13602 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
13603 @cindex C++ interfacing
13604 @cindex Interfacing, to C++
13607 This package provides facilities for use in interfacing to C++. It
13608 is primarily intended to be used in connection with automated tools
13609 for the generation of C++ interfaces.
13611 @node Interfaces.Os2lib (i-os2lib.ads)
13612 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13613 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13614 @cindex Interfacing, to OS/2
13615 @cindex OS/2 interfacing
13618 This package provides interface definitions to the OS/2 library.
13619 It is a thin binding which is a direct translation of the
13620 various @file{<bse@.h>} files.
13622 @node Interfaces.Os2lib.Errors (i-os2err.ads)
13623 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13624 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13625 @cindex OS/2 Error codes
13626 @cindex Interfacing, to OS/2
13627 @cindex OS/2 interfacing
13630 This package provides definitions of the OS/2 error codes.
13632 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
13633 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13634 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13635 @cindex Interfacing, to OS/2
13636 @cindex Synchronization, OS/2
13637 @cindex OS/2 synchronization primitives
13640 This is a child package that provides definitions for interfacing
13641 to the @code{OS/2} synchronization primitives.
13643 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
13644 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13645 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13646 @cindex Interfacing, to OS/2
13647 @cindex Thread control, OS/2
13648 @cindex OS/2 thread interfacing
13651 This is a child package that provides definitions for interfacing
13652 to the @code{OS/2} thread primitives.
13654 @node Interfaces.Packed_Decimal (i-pacdec.ads)
13655 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13656 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13657 @cindex IBM Packed Format
13658 @cindex Packed Decimal
13661 This package provides a set of routines for conversions to and
13662 from a packed decimal format compatible with that used on IBM
13665 @node Interfaces.VxWorks (i-vxwork.ads)
13666 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13667 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13668 @cindex Interfacing to VxWorks
13669 @cindex VxWorks, interfacing
13672 This package provides a limited binding to the VxWorks API.
13673 In particular, it interfaces with the
13674 VxWorks hardware interrupt facilities.
13676 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
13677 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13678 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13679 @cindex Interfacing to VxWorks' I/O
13680 @cindex VxWorks, I/O interfacing
13681 @cindex VxWorks, Get_Immediate
13682 @cindex Get_Immediate, VxWorks
13685 This package provides a binding to the ioctl (IO/Control)
13686 function of VxWorks, defining a set of option values and
13687 function codes. A particular use of this package is
13688 to enable the use of Get_Immediate under VxWorks.
13690 @node System.Address_Image (s-addima.ads)
13691 @section @code{System.Address_Image} (@file{s-addima.ads})
13692 @cindex @code{System.Address_Image} (@file{s-addima.ads})
13693 @cindex Address image
13694 @cindex Image, of an address
13697 This function provides a useful debugging
13698 function that gives an (implementation dependent)
13699 string which identifies an address.
13701 @node System.Assertions (s-assert.ads)
13702 @section @code{System.Assertions} (@file{s-assert.ads})
13703 @cindex @code{System.Assertions} (@file{s-assert.ads})
13705 @cindex Assert_Failure, exception
13708 This package provides the declaration of the exception raised
13709 by an run-time assertion failure, as well as the routine that
13710 is used internally to raise this assertion.
13712 @node System.Memory (s-memory.ads)
13713 @section @code{System.Memory} (@file{s-memory.ads})
13714 @cindex @code{System.Memory} (@file{s-memory.ads})
13715 @cindex Memory allocation
13718 This package provides the interface to the low level routines used
13719 by the generated code for allocation and freeing storage for the
13720 default storage pool (analogous to the C routines malloc and free.
13721 It also provides a reallocation interface analogous to the C routine
13722 realloc. The body of this unit may be modified to provide alternative
13723 allocation mechanisms for the default pool, and in addition, direct
13724 calls to this unit may be made for low level allocation uses (for
13725 example see the body of @code{GNAT.Tables}).
13727 @node System.Partition_Interface (s-parint.ads)
13728 @section @code{System.Partition_Interface} (@file{s-parint.ads})
13729 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
13730 @cindex Partition interfacing functions
13733 This package provides facilities for partition interfacing. It
13734 is used primarily in a distribution context when using Annex E
13737 @node System.Restrictions (s-restri.ads)
13738 @section @code{System.Restrictions} (@file{s-restri.ads})
13739 @cindex @code{System.Restrictions} (@file{s-restri.ads})
13740 @cindex Run-time restrictions access
13743 This package provides facilities for accessing at run-time
13744 the status of restrictions specified at compile time for
13745 the partition. Information is available both with regard
13746 to actual restrictions specified, and with regard to
13747 compiler determined information on which restrictions
13748 are violated by one or more packages in the partition.
13750 @node System.Rident (s-rident.ads)
13751 @section @code{System.Rident} (@file{s-rident.ads})
13752 @cindex @code{System.Rident} (@file{s-rident.ads})
13753 @cindex Restrictions definitions
13756 This package provides definitions of the restrictions
13757 identifiers supported by GNAT, and also the format of
13758 the restrictions provided in package System.Restrictions.
13759 It is not normally necessary to @code{with} this generic package
13760 since the necessary instantiation is included in
13761 package System.Restrictions.
13763 @node System.Task_Info (s-tasinf.ads)
13764 @section @code{System.Task_Info} (@file{s-tasinf.ads})
13765 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
13766 @cindex Task_Info pragma
13769 This package provides target dependent functionality that is used
13770 to support the @code{Task_Info} pragma
13772 @node System.Wch_Cnv (s-wchcnv.ads)
13773 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13774 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13775 @cindex Wide Character, Representation
13776 @cindex Wide String, Conversion
13777 @cindex Representation of wide characters
13780 This package provides routines for converting between
13781 wide and wide wide characters and a representation as a value of type
13782 @code{Standard.String}, using a specified wide character
13783 encoding method. It uses definitions in
13784 package @code{System.Wch_Con}.
13786 @node System.Wch_Con (s-wchcon.ads)
13787 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
13788 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
13791 This package provides definitions and descriptions of
13792 the various methods used for encoding wide characters
13793 in ordinary strings. These definitions are used by
13794 the package @code{System.Wch_Cnv}.
13796 @node Interfacing to Other Languages
13797 @chapter Interfacing to Other Languages
13799 The facilities in annex B of the Ada Reference Manual are fully
13800 implemented in GNAT, and in addition, a full interface to C++ is
13804 * Interfacing to C::
13805 * Interfacing to C++::
13806 * Interfacing to COBOL::
13807 * Interfacing to Fortran::
13808 * Interfacing to non-GNAT Ada code::
13811 @node Interfacing to C
13812 @section Interfacing to C
13815 Interfacing to C with GNAT can use one of two approaches:
13819 The types in the package @code{Interfaces.C} may be used.
13821 Standard Ada types may be used directly. This may be less portable to
13822 other compilers, but will work on all GNAT compilers, which guarantee
13823 correspondence between the C and Ada types.
13827 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
13828 effect, since this is the default. The following table shows the
13829 correspondence between Ada scalar types and the corresponding C types.
13834 @item Short_Integer
13836 @item Short_Short_Integer
13840 @item Long_Long_Integer
13848 @item Long_Long_Float
13849 This is the longest floating-point type supported by the hardware.
13853 Additionally, there are the following general correspondences between Ada
13857 Ada enumeration types map to C enumeration types directly if pragma
13858 @code{Convention C} is specified, which causes them to have int
13859 length. Without pragma @code{Convention C}, Ada enumeration types map to
13860 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
13861 @code{int}, respectively) depending on the number of values passed.
13862 This is the only case in which pragma @code{Convention C} affects the
13863 representation of an Ada type.
13866 Ada access types map to C pointers, except for the case of pointers to
13867 unconstrained types in Ada, which have no direct C equivalent.
13870 Ada arrays map directly to C arrays.
13873 Ada records map directly to C structures.
13876 Packed Ada records map to C structures where all members are bit fields
13877 of the length corresponding to the @code{@var{type}'Size} value in Ada.
13880 @node Interfacing to C++
13881 @section Interfacing to C++
13884 The interface to C++ makes use of the following pragmas, which are
13885 primarily intended to be constructed automatically using a binding generator
13886 tool, although it is possible to construct them by hand. No suitable binding
13887 generator tool is supplied with GNAT though.
13889 Using these pragmas it is possible to achieve complete
13890 inter-operability between Ada tagged types and C++ class definitions.
13891 See @ref{Implementation Defined Pragmas}, for more details.
13894 @item pragma CPP_Class ([Entity =>] @var{local_NAME})
13895 The argument denotes an entity in the current declarative region that is
13896 declared as a tagged or untagged record type. It indicates that the type
13897 corresponds to an externally declared C++ class type, and is to be laid
13898 out the same way that C++ would lay out the type.
13900 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
13901 for backward compatibility but its functionality is available
13902 using pragma @code{Import} with @code{Convention} = @code{CPP}.
13904 @item pragma CPP_Constructor ([Entity =>] @var{local_NAME})
13905 This pragma identifies an imported function (imported in the usual way
13906 with pragma @code{Import}) as corresponding to a C++ constructor.
13909 @node Interfacing to COBOL
13910 @section Interfacing to COBOL
13913 Interfacing to COBOL is achieved as described in section B.4 of
13914 the Ada Reference Manual.
13916 @node Interfacing to Fortran
13917 @section Interfacing to Fortran
13920 Interfacing to Fortran is achieved as described in section B.5 of the
13921 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
13922 multi-dimensional array causes the array to be stored in column-major
13923 order as required for convenient interface to Fortran.
13925 @node Interfacing to non-GNAT Ada code
13926 @section Interfacing to non-GNAT Ada code
13928 It is possible to specify the convention @code{Ada} in a pragma
13929 @code{Import} or pragma @code{Export}. However this refers to
13930 the calling conventions used by GNAT, which may or may not be
13931 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
13932 compiler to allow interoperation.
13934 If arguments types are kept simple, and if the foreign compiler generally
13935 follows system calling conventions, then it may be possible to integrate
13936 files compiled by other Ada compilers, provided that the elaboration
13937 issues are adequately addressed (for example by eliminating the
13938 need for any load time elaboration).
13940 In particular, GNAT running on VMS is designed to
13941 be highly compatible with the DEC Ada 83 compiler, so this is one
13942 case in which it is possible to import foreign units of this type,
13943 provided that the data items passed are restricted to simple scalar
13944 values or simple record types without variants, or simple array
13945 types with fixed bounds.
13947 @node Specialized Needs Annexes
13948 @chapter Specialized Needs Annexes
13951 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
13952 required in all implementations. However, as described in this chapter,
13953 GNAT implements all of these annexes:
13956 @item Systems Programming (Annex C)
13957 The Systems Programming Annex is fully implemented.
13959 @item Real-Time Systems (Annex D)
13960 The Real-Time Systems Annex is fully implemented.
13962 @item Distributed Systems (Annex E)
13963 Stub generation is fully implemented in the GNAT compiler. In addition,
13964 a complete compatible PCS is available as part of the GLADE system,
13965 a separate product. When the two
13966 products are used in conjunction, this annex is fully implemented.
13968 @item Information Systems (Annex F)
13969 The Information Systems annex is fully implemented.
13971 @item Numerics (Annex G)
13972 The Numerics Annex is fully implemented.
13974 @item Safety and Security / High-Integrity Systems (Annex H)
13975 The Safety and Security Annex (termed the High-Integrity Systems Annex
13976 in Ada 2005) is fully implemented.
13979 @node Implementation of Specific Ada Features
13980 @chapter Implementation of Specific Ada Features
13983 This chapter describes the GNAT implementation of several Ada language
13987 * Machine Code Insertions::
13988 * GNAT Implementation of Tasking::
13989 * GNAT Implementation of Shared Passive Packages::
13990 * Code Generation for Array Aggregates::
13991 * The Size of Discriminated Records with Default Discriminants::
13992 * Strict Conformance to the Ada Reference Manual::
13995 @node Machine Code Insertions
13996 @section Machine Code Insertions
13997 @cindex Machine Code insertions
14000 Package @code{Machine_Code} provides machine code support as described
14001 in the Ada Reference Manual in two separate forms:
14004 Machine code statements, consisting of qualified expressions that
14005 fit the requirements of RM section 13.8.
14007 An intrinsic callable procedure, providing an alternative mechanism of
14008 including machine instructions in a subprogram.
14012 The two features are similar, and both are closely related to the mechanism
14013 provided by the asm instruction in the GNU C compiler. Full understanding
14014 and use of the facilities in this package requires understanding the asm
14015 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
14016 by Richard Stallman. The relevant section is titled ``Extensions to the C
14017 Language Family'' @result{} ``Assembler Instructions with C Expression
14020 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14021 semantic restrictions and effects as described below. Both are provided so
14022 that the procedure call can be used as a statement, and the function call
14023 can be used to form a code_statement.
14025 The first example given in the GCC documentation is the C @code{asm}
14028 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14032 The equivalent can be written for GNAT as:
14034 @smallexample @c ada
14035 Asm ("fsinx %1 %0",
14036 My_Float'Asm_Output ("=f", result),
14037 My_Float'Asm_Input ("f", angle));
14041 The first argument to @code{Asm} is the assembler template, and is
14042 identical to what is used in GNU C@. This string must be a static
14043 expression. The second argument is the output operand list. It is
14044 either a single @code{Asm_Output} attribute reference, or a list of such
14045 references enclosed in parentheses (technically an array aggregate of
14048 The @code{Asm_Output} attribute denotes a function that takes two
14049 parameters. The first is a string, the second is the name of a variable
14050 of the type designated by the attribute prefix. The first (string)
14051 argument is required to be a static expression and designates the
14052 constraint for the parameter (e.g.@: what kind of register is
14053 required). The second argument is the variable to be updated with the
14054 result. The possible values for constraint are the same as those used in
14055 the RTL, and are dependent on the configuration file used to build the
14056 GCC back end. If there are no output operands, then this argument may
14057 either be omitted, or explicitly given as @code{No_Output_Operands}.
14059 The second argument of @code{@var{my_float}'Asm_Output} functions as
14060 though it were an @code{out} parameter, which is a little curious, but
14061 all names have the form of expressions, so there is no syntactic
14062 irregularity, even though normally functions would not be permitted
14063 @code{out} parameters. The third argument is the list of input
14064 operands. It is either a single @code{Asm_Input} attribute reference, or
14065 a list of such references enclosed in parentheses (technically an array
14066 aggregate of such references).
14068 The @code{Asm_Input} attribute denotes a function that takes two
14069 parameters. The first is a string, the second is an expression of the
14070 type designated by the prefix. The first (string) argument is required
14071 to be a static expression, and is the constraint for the parameter,
14072 (e.g.@: what kind of register is required). The second argument is the
14073 value to be used as the input argument. The possible values for the
14074 constant are the same as those used in the RTL, and are dependent on
14075 the configuration file used to built the GCC back end.
14077 If there are no input operands, this argument may either be omitted, or
14078 explicitly given as @code{No_Input_Operands}. The fourth argument, not
14079 present in the above example, is a list of register names, called the
14080 @dfn{clobber} argument. This argument, if given, must be a static string
14081 expression, and is a space or comma separated list of names of registers
14082 that must be considered destroyed as a result of the @code{Asm} call. If
14083 this argument is the null string (the default value), then the code
14084 generator assumes that no additional registers are destroyed.
14086 The fifth argument, not present in the above example, called the
14087 @dfn{volatile} argument, is by default @code{False}. It can be set to
14088 the literal value @code{True} to indicate to the code generator that all
14089 optimizations with respect to the instruction specified should be
14090 suppressed, and that in particular, for an instruction that has outputs,
14091 the instruction will still be generated, even if none of the outputs are
14092 used. See the full description in the GCC manual for further details.
14093 Generally it is strongly advisable to use Volatile for any ASM statement
14094 that is missing either input or output operands, or when two or more ASM
14095 statements appear in sequence, to avoid unwanted optimizations. A warning
14096 is generated if this advice is not followed.
14098 The @code{Asm} subprograms may be used in two ways. First the procedure
14099 forms can be used anywhere a procedure call would be valid, and
14100 correspond to what the RM calls ``intrinsic'' routines. Such calls can
14101 be used to intersperse machine instructions with other Ada statements.
14102 Second, the function forms, which return a dummy value of the limited
14103 private type @code{Asm_Insn}, can be used in code statements, and indeed
14104 this is the only context where such calls are allowed. Code statements
14105 appear as aggregates of the form:
14107 @smallexample @c ada
14108 Asm_Insn'(Asm (@dots{}));
14109 Asm_Insn'(Asm_Volatile (@dots{}));
14113 In accordance with RM rules, such code statements are allowed only
14114 within subprograms whose entire body consists of such statements. It is
14115 not permissible to intermix such statements with other Ada statements.
14117 Typically the form using intrinsic procedure calls is more convenient
14118 and more flexible. The code statement form is provided to meet the RM
14119 suggestion that such a facility should be made available. The following
14120 is the exact syntax of the call to @code{Asm}. As usual, if named notation
14121 is used, the arguments may be given in arbitrary order, following the
14122 normal rules for use of positional and named arguments)
14126 [Template =>] static_string_EXPRESSION
14127 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
14128 [,[Inputs =>] INPUT_OPERAND_LIST ]
14129 [,[Clobber =>] static_string_EXPRESSION ]
14130 [,[Volatile =>] static_boolean_EXPRESSION] )
14132 OUTPUT_OPERAND_LIST ::=
14133 [PREFIX.]No_Output_Operands
14134 | OUTPUT_OPERAND_ATTRIBUTE
14135 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
14137 OUTPUT_OPERAND_ATTRIBUTE ::=
14138 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
14140 INPUT_OPERAND_LIST ::=
14141 [PREFIX.]No_Input_Operands
14142 | INPUT_OPERAND_ATTRIBUTE
14143 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
14145 INPUT_OPERAND_ATTRIBUTE ::=
14146 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
14150 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
14151 are declared in the package @code{Machine_Code} and must be referenced
14152 according to normal visibility rules. In particular if there is no
14153 @code{use} clause for this package, then appropriate package name
14154 qualification is required.
14156 @node GNAT Implementation of Tasking
14157 @section GNAT Implementation of Tasking
14160 This chapter outlines the basic GNAT approach to tasking (in particular,
14161 a multi-layered library for portability) and discusses issues related
14162 to compliance with the Real-Time Systems Annex.
14165 * Mapping Ada Tasks onto the Underlying Kernel Threads::
14166 * Ensuring Compliance with the Real-Time Annex::
14169 @node Mapping Ada Tasks onto the Underlying Kernel Threads
14170 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
14173 GNAT's run-time support comprises two layers:
14176 @item GNARL (GNAT Run-time Layer)
14177 @item GNULL (GNAT Low-level Library)
14181 In GNAT, Ada's tasking services rely on a platform and OS independent
14182 layer known as GNARL@. This code is responsible for implementing the
14183 correct semantics of Ada's task creation, rendezvous, protected
14186 GNARL decomposes Ada's tasking semantics into simpler lower level
14187 operations such as create a thread, set the priority of a thread,
14188 yield, create a lock, lock/unlock, etc. The spec for these low-level
14189 operations constitutes GNULLI, the GNULL Interface. This interface is
14190 directly inspired from the POSIX real-time API@.
14192 If the underlying executive or OS implements the POSIX standard
14193 faithfully, the GNULL Interface maps as is to the services offered by
14194 the underlying kernel. Otherwise, some target dependent glue code maps
14195 the services offered by the underlying kernel to the semantics expected
14198 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
14199 key point is that each Ada task is mapped on a thread in the underlying
14200 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
14202 In addition Ada task priorities map onto the underlying thread priorities.
14203 Mapping Ada tasks onto the underlying kernel threads has several advantages:
14207 The underlying scheduler is used to schedule the Ada tasks. This
14208 makes Ada tasks as efficient as kernel threads from a scheduling
14212 Interaction with code written in C containing threads is eased
14213 since at the lowest level Ada tasks and C threads map onto the same
14214 underlying kernel concept.
14217 When an Ada task is blocked during I/O the remaining Ada tasks are
14221 On multiprocessor systems Ada tasks can execute in parallel.
14225 Some threads libraries offer a mechanism to fork a new process, with the
14226 child process duplicating the threads from the parent.
14228 support this functionality when the parent contains more than one task.
14229 @cindex Forking a new process
14231 @node Ensuring Compliance with the Real-Time Annex
14232 @subsection Ensuring Compliance with the Real-Time Annex
14233 @cindex Real-Time Systems Annex compliance
14236 Although mapping Ada tasks onto
14237 the underlying threads has significant advantages, it does create some
14238 complications when it comes to respecting the scheduling semantics
14239 specified in the real-time annex (Annex D).
14241 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
14242 scheduling policy states:
14245 @emph{When the active priority of a ready task that is not running
14246 changes, or the setting of its base priority takes effect, the
14247 task is removed from the ready queue for its old active priority
14248 and is added at the tail of the ready queue for its new active
14249 priority, except in the case where the active priority is lowered
14250 due to the loss of inherited priority, in which case the task is
14251 added at the head of the ready queue for its new active priority.}
14255 While most kernels do put tasks at the end of the priority queue when
14256 a task changes its priority, (which respects the main
14257 FIFO_Within_Priorities requirement), almost none keep a thread at the
14258 beginning of its priority queue when its priority drops from the loss
14259 of inherited priority.
14261 As a result most vendors have provided incomplete Annex D implementations.
14263 The GNAT run-time, has a nice cooperative solution to this problem
14264 which ensures that accurate FIFO_Within_Priorities semantics are
14267 The principle is as follows. When an Ada task T is about to start
14268 running, it checks whether some other Ada task R with the same
14269 priority as T has been suspended due to the loss of priority
14270 inheritance. If this is the case, T yields and is placed at the end of
14271 its priority queue. When R arrives at the front of the queue it
14274 Note that this simple scheme preserves the relative order of the tasks
14275 that were ready to execute in the priority queue where R has been
14278 @node GNAT Implementation of Shared Passive Packages
14279 @section GNAT Implementation of Shared Passive Packages
14280 @cindex Shared passive packages
14283 GNAT fully implements the pragma @code{Shared_Passive} for
14284 @cindex pragma @code{Shared_Passive}
14285 the purpose of designating shared passive packages.
14286 This allows the use of passive partitions in the
14287 context described in the Ada Reference Manual; i.e. for communication
14288 between separate partitions of a distributed application using the
14289 features in Annex E.
14291 @cindex Distribution Systems Annex
14293 However, the implementation approach used by GNAT provides for more
14294 extensive usage as follows:
14297 @item Communication between separate programs
14299 This allows separate programs to access the data in passive
14300 partitions, using protected objects for synchronization where
14301 needed. The only requirement is that the two programs have a
14302 common shared file system. It is even possible for programs
14303 running on different machines with different architectures
14304 (e.g. different endianness) to communicate via the data in
14305 a passive partition.
14307 @item Persistence between program runs
14309 The data in a passive package can persist from one run of a
14310 program to another, so that a later program sees the final
14311 values stored by a previous run of the same program.
14316 The implementation approach used is to store the data in files. A
14317 separate stream file is created for each object in the package, and
14318 an access to an object causes the corresponding file to be read or
14321 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
14322 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
14323 set to the directory to be used for these files.
14324 The files in this directory
14325 have names that correspond to their fully qualified names. For
14326 example, if we have the package
14328 @smallexample @c ada
14330 pragma Shared_Passive (X);
14337 and the environment variable is set to @code{/stemp/}, then the files created
14338 will have the names:
14346 These files are created when a value is initially written to the object, and
14347 the files are retained until manually deleted. This provides the persistence
14348 semantics. If no file exists, it means that no partition has assigned a value
14349 to the variable; in this case the initial value declared in the package
14350 will be used. This model ensures that there are no issues in synchronizing
14351 the elaboration process, since elaboration of passive packages elaborates the
14352 initial values, but does not create the files.
14354 The files are written using normal @code{Stream_IO} access.
14355 If you want to be able
14356 to communicate between programs or partitions running on different
14357 architectures, then you should use the XDR versions of the stream attribute
14358 routines, since these are architecture independent.
14360 If active synchronization is required for access to the variables in the
14361 shared passive package, then as described in the Ada Reference Manual, the
14362 package may contain protected objects used for this purpose. In this case
14363 a lock file (whose name is @file{___lock} (three underscores)
14364 is created in the shared memory directory.
14365 @cindex @file{___lock} file (for shared passive packages)
14366 This is used to provide the required locking
14367 semantics for proper protected object synchronization.
14369 As of January 2003, GNAT supports shared passive packages on all platforms
14370 except for OpenVMS.
14372 @node Code Generation for Array Aggregates
14373 @section Code Generation for Array Aggregates
14376 * Static constant aggregates with static bounds::
14377 * Constant aggregates with unconstrained nominal types::
14378 * Aggregates with static bounds::
14379 * Aggregates with non-static bounds::
14380 * Aggregates in assignment statements::
14384 Aggregates have a rich syntax and allow the user to specify the values of
14385 complex data structures by means of a single construct. As a result, the
14386 code generated for aggregates can be quite complex and involve loops, case
14387 statements and multiple assignments. In the simplest cases, however, the
14388 compiler will recognize aggregates whose components and constraints are
14389 fully static, and in those cases the compiler will generate little or no
14390 executable code. The following is an outline of the code that GNAT generates
14391 for various aggregate constructs. For further details, you will find it
14392 useful to examine the output produced by the -gnatG flag to see the expanded
14393 source that is input to the code generator. You may also want to examine
14394 the assembly code generated at various levels of optimization.
14396 The code generated for aggregates depends on the context, the component values,
14397 and the type. In the context of an object declaration the code generated is
14398 generally simpler than in the case of an assignment. As a general rule, static
14399 component values and static subtypes also lead to simpler code.
14401 @node Static constant aggregates with static bounds
14402 @subsection Static constant aggregates with static bounds
14405 For the declarations:
14406 @smallexample @c ada
14407 type One_Dim is array (1..10) of integer;
14408 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
14412 GNAT generates no executable code: the constant ar0 is placed in static memory.
14413 The same is true for constant aggregates with named associations:
14415 @smallexample @c ada
14416 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
14417 Cr3 : constant One_Dim := (others => 7777);
14421 The same is true for multidimensional constant arrays such as:
14423 @smallexample @c ada
14424 type two_dim is array (1..3, 1..3) of integer;
14425 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
14429 The same is true for arrays of one-dimensional arrays: the following are
14432 @smallexample @c ada
14433 type ar1b is array (1..3) of boolean;
14434 type ar_ar is array (1..3) of ar1b;
14435 None : constant ar1b := (others => false); -- fully static
14436 None2 : constant ar_ar := (1..3 => None); -- fully static
14440 However, for multidimensional aggregates with named associations, GNAT will
14441 generate assignments and loops, even if all associations are static. The
14442 following two declarations generate a loop for the first dimension, and
14443 individual component assignments for the second dimension:
14445 @smallexample @c ada
14446 Zero1: constant two_dim := (1..3 => (1..3 => 0));
14447 Zero2: constant two_dim := (others => (others => 0));
14450 @node Constant aggregates with unconstrained nominal types
14451 @subsection Constant aggregates with unconstrained nominal types
14454 In such cases the aggregate itself establishes the subtype, so that
14455 associations with @code{others} cannot be used. GNAT determines the
14456 bounds for the actual subtype of the aggregate, and allocates the
14457 aggregate statically as well. No code is generated for the following:
14459 @smallexample @c ada
14460 type One_Unc is array (natural range <>) of integer;
14461 Cr_Unc : constant One_Unc := (12,24,36);
14464 @node Aggregates with static bounds
14465 @subsection Aggregates with static bounds
14468 In all previous examples the aggregate was the initial (and immutable) value
14469 of a constant. If the aggregate initializes a variable, then code is generated
14470 for it as a combination of individual assignments and loops over the target
14471 object. The declarations
14473 @smallexample @c ada
14474 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
14475 Cr_Var2 : One_Dim := (others > -1);
14479 generate the equivalent of
14481 @smallexample @c ada
14487 for I in Cr_Var2'range loop
14488 Cr_Var2 (I) := =-1;
14492 @node Aggregates with non-static bounds
14493 @subsection Aggregates with non-static bounds
14496 If the bounds of the aggregate are not statically compatible with the bounds
14497 of the nominal subtype of the target, then constraint checks have to be
14498 generated on the bounds. For a multidimensional array, constraint checks may
14499 have to be applied to sub-arrays individually, if they do not have statically
14500 compatible subtypes.
14502 @node Aggregates in assignment statements
14503 @subsection Aggregates in assignment statements
14506 In general, aggregate assignment requires the construction of a temporary,
14507 and a copy from the temporary to the target of the assignment. This is because
14508 it is not always possible to convert the assignment into a series of individual
14509 component assignments. For example, consider the simple case:
14511 @smallexample @c ada
14516 This cannot be converted into:
14518 @smallexample @c ada
14524 So the aggregate has to be built first in a separate location, and then
14525 copied into the target. GNAT recognizes simple cases where this intermediate
14526 step is not required, and the assignments can be performed in place, directly
14527 into the target. The following sufficient criteria are applied:
14531 The bounds of the aggregate are static, and the associations are static.
14533 The components of the aggregate are static constants, names of
14534 simple variables that are not renamings, or expressions not involving
14535 indexed components whose operands obey these rules.
14539 If any of these conditions are violated, the aggregate will be built in
14540 a temporary (created either by the front-end or the code generator) and then
14541 that temporary will be copied onto the target.
14544 @node The Size of Discriminated Records with Default Discriminants
14545 @section The Size of Discriminated Records with Default Discriminants
14548 If a discriminated type @code{T} has discriminants with default values, it is
14549 possible to declare an object of this type without providing an explicit
14552 @smallexample @c ada
14554 type Size is range 1..100;
14556 type Rec (D : Size := 15) is record
14557 Name : String (1..D);
14565 Such an object is said to be @emph{unconstrained}.
14566 The discriminant of the object
14567 can be modified by a full assignment to the object, as long as it preserves the
14568 relation between the value of the discriminant, and the value of the components
14571 @smallexample @c ada
14573 Word := (3, "yes");
14575 Word := (5, "maybe");
14577 Word := (5, "no"); -- raises Constraint_Error
14582 In order to support this behavior efficiently, an unconstrained object is
14583 given the maximum size that any value of the type requires. In the case
14584 above, @code{Word} has storage for the discriminant and for
14585 a @code{String} of length 100.
14586 It is important to note that unconstrained objects do not require dynamic
14587 allocation. It would be an improper implementation to place on the heap those
14588 components whose size depends on discriminants. (This improper implementation
14589 was used by some Ada83 compilers, where the @code{Name} component above
14591 been stored as a pointer to a dynamic string). Following the principle that
14592 dynamic storage management should never be introduced implicitly,
14593 an Ada compiler should reserve the full size for an unconstrained declared
14594 object, and place it on the stack.
14596 This maximum size approach
14597 has been a source of surprise to some users, who expect the default
14598 values of the discriminants to determine the size reserved for an
14599 unconstrained object: ``If the default is 15, why should the object occupy
14601 The answer, of course, is that the discriminant may be later modified,
14602 and its full range of values must be taken into account. This is why the
14607 type Rec (D : Positive := 15) is record
14608 Name : String (1..D);
14616 is flagged by the compiler with a warning:
14617 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
14618 because the required size includes @code{Positive'Last}
14619 bytes. As the first example indicates, the proper approach is to declare an
14620 index type of ``reasonable'' range so that unconstrained objects are not too
14623 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
14624 created in the heap by means of an allocator, then it is @emph{not}
14626 it is constrained by the default values of the discriminants, and those values
14627 cannot be modified by full assignment. This is because in the presence of
14628 aliasing all views of the object (which may be manipulated by different tasks,
14629 say) must be consistent, so it is imperative that the object, once created,
14632 @node Strict Conformance to the Ada Reference Manual
14633 @section Strict Conformance to the Ada Reference Manual
14636 The dynamic semantics defined by the Ada Reference Manual impose a set of
14637 run-time checks to be generated. By default, the GNAT compiler will insert many
14638 run-time checks into the compiled code, including most of those required by the
14639 Ada Reference Manual. However, there are three checks that are not enabled
14640 in the default mode for efficiency reasons: arithmetic overflow checking for
14641 integer operations (including division by zero), checks for access before
14642 elaboration on subprogram calls, and stack overflow checking (most operating
14643 systems do not perform this check by default).
14645 Strict conformance to the Ada Reference Manual can be achieved by adding
14646 three compiler options for overflow checking for integer operations
14647 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
14648 calls and generic instantiations (@option{-gnatE}), and stack overflow
14649 checking (@option{-fstack-check}).
14651 Note that the result of a floating point arithmetic operation in overflow and
14652 invalid situations, when the @code{Machine_Overflows} attribute of the result
14653 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
14654 case for machines compliant with the IEEE floating-point standard, but on
14655 machines that are not fully compliant with this standard, such as Alpha, the
14656 @option{-mieee} compiler flag must be used for achieving IEEE confirming
14657 behavior (although at the cost of a significant performance penalty), so
14658 infinite and and NaN values are properly generated.
14661 @node Project File Reference
14662 @chapter Project File Reference
14665 This chapter describes the syntax and semantics of project files.
14666 Project files specify the options to be used when building a system.
14667 Project files can specify global settings for all tools,
14668 as well as tool-specific settings.
14669 See the chapter on project files in the GNAT Users guide for examples of use.
14673 * Lexical Elements::
14675 * Empty declarations::
14676 * Typed string declarations::
14680 * Project Attributes::
14681 * Attribute References::
14682 * External Values::
14683 * Case Construction::
14685 * Package Renamings::
14687 * Project Extensions::
14688 * Project File Elaboration::
14691 @node Reserved Words
14692 @section Reserved Words
14695 All Ada reserved words are reserved in project files, and cannot be used
14696 as variable names or project names. In addition, the following are
14697 also reserved in project files:
14700 @item @code{extends}
14702 @item @code{external}
14704 @item @code{project}
14708 @node Lexical Elements
14709 @section Lexical Elements
14712 Rules for identifiers are the same as in Ada. Identifiers
14713 are case-insensitive. Strings are case sensitive, except where noted.
14714 Comments have the same form as in Ada.
14724 simple_name @{. simple_name@}
14728 @section Declarations
14731 Declarations introduce new entities that denote types, variables, attributes,
14732 and packages. Some declarations can only appear immediately within a project
14733 declaration. Others can appear within a project or within a package.
14737 declarative_item ::=
14738 simple_declarative_item |
14739 typed_string_declaration |
14740 package_declaration
14742 simple_declarative_item ::=
14743 variable_declaration |
14744 typed_variable_declaration |
14745 attribute_declaration |
14746 case_construction |
14750 @node Empty declarations
14751 @section Empty declarations
14754 empty_declaration ::=
14758 An empty declaration is allowed anywhere a declaration is allowed.
14761 @node Typed string declarations
14762 @section Typed string declarations
14765 Typed strings are sequences of string literals. Typed strings are the only
14766 named types in project files. They are used in case constructions, where they
14767 provide support for conditional attribute definitions.
14771 typed_string_declaration ::=
14772 @b{type} <typed_string_>_simple_name @b{is}
14773 ( string_literal @{, string_literal@} );
14777 A typed string declaration can only appear immediately within a project
14780 All the string literals in a typed string declaration must be distinct.
14786 Variables denote values, and appear as constituents of expressions.
14789 typed_variable_declaration ::=
14790 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
14792 variable_declaration ::=
14793 <variable_>simple_name := expression;
14797 The elaboration of a variable declaration introduces the variable and
14798 assigns to it the value of the expression. The name of the variable is
14799 available after the assignment symbol.
14802 A typed_variable can only be declare once.
14805 a non typed variable can be declared multiple times.
14808 Before the completion of its first declaration, the value of variable
14809 is the null string.
14812 @section Expressions
14815 An expression is a formula that defines a computation or retrieval of a value.
14816 In a project file the value of an expression is either a string or a list
14817 of strings. A string value in an expression is either a literal, the current
14818 value of a variable, an external value, an attribute reference, or a
14819 concatenation operation.
14832 attribute_reference
14838 ( <string_>expression @{ , <string_>expression @} )
14841 @subsection Concatenation
14843 The following concatenation functions are defined:
14845 @smallexample @c ada
14846 function "&" (X : String; Y : String) return String;
14847 function "&" (X : String_List; Y : String) return String_List;
14848 function "&" (X : String_List; Y : String_List) return String_List;
14852 @section Attributes
14855 An attribute declaration defines a property of a project or package. This
14856 property can later be queried by means of an attribute reference.
14857 Attribute values are strings or string lists.
14859 Some attributes are associative arrays. These attributes are mappings whose
14860 domain is a set of strings. These attributes are declared one association
14861 at a time, by specifying a point in the domain and the corresponding image
14862 of the attribute. They may also be declared as a full associative array,
14863 getting the same associations as the corresponding attribute in an imported
14864 or extended project.
14866 Attributes that are not associative arrays are called simple attributes.
14870 attribute_declaration ::=
14871 full_associative_array_declaration |
14872 @b{for} attribute_designator @b{use} expression ;
14874 full_associative_array_declaration ::=
14875 @b{for} <associative_array_attribute_>simple_name @b{use}
14876 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
14878 attribute_designator ::=
14879 <simple_attribute_>simple_name |
14880 <associative_array_attribute_>simple_name ( string_literal )
14884 Some attributes are project-specific, and can only appear immediately within
14885 a project declaration. Others are package-specific, and can only appear within
14886 the proper package.
14888 The expression in an attribute definition must be a string or a string_list.
14889 The string literal appearing in the attribute_designator of an associative
14890 array attribute is case-insensitive.
14892 @node Project Attributes
14893 @section Project Attributes
14896 The following attributes apply to a project. All of them are simple
14901 Expression must be a path name. The attribute defines the
14902 directory in which the object files created by the build are to be placed. If
14903 not specified, object files are placed in the project directory.
14906 Expression must be a path name. The attribute defines the
14907 directory in which the executables created by the build are to be placed.
14908 If not specified, executables are placed in the object directory.
14911 Expression must be a list of path names. The attribute
14912 defines the directories in which the source files for the project are to be
14913 found. If not specified, source files are found in the project directory.
14916 Expression must be a list of file names. The attribute
14917 defines the individual files, in the project directory, which are to be used
14918 as sources for the project. File names are path_names that contain no directory
14919 information. If the project has no sources the attribute must be declared
14920 explicitly with an empty list.
14922 @item Source_List_File
14923 Expression must a single path name. The attribute
14924 defines a text file that contains a list of source file names to be used
14925 as sources for the project
14928 Expression must be a path name. The attribute defines the
14929 directory in which a library is to be built. The directory must exist, must
14930 be distinct from the project's object directory, and must be writable.
14933 Expression must be a string that is a legal file name,
14934 without extension. The attribute defines a string that is used to generate
14935 the name of the library to be built by the project.
14938 Argument must be a string value that must be one of the
14939 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
14940 string is case-insensitive. If this attribute is not specified, the library is
14941 a static library. Otherwise, the library may be dynamic or relocatable. This
14942 distinction is operating-system dependent.
14944 @item Library_Version
14945 Expression must be a string value whose interpretation
14946 is platform dependent. On UNIX, it is used only for dynamic/relocatable
14947 libraries as the internal name of the library (the @code{"soname"}). If the
14948 library file name (built from the @code{Library_Name}) is different from the
14949 @code{Library_Version}, then the library file will be a symbolic link to the
14950 actual file whose name will be @code{Library_Version}.
14952 @item Library_Interface
14953 Expression must be a string list. Each element of the string list
14954 must designate a unit of the project.
14955 If this attribute is present in a Library Project File, then the project
14956 file is a Stand-alone Library_Project_File.
14958 @item Library_Auto_Init
14959 Expression must be a single string "true" or "false", case-insensitive.
14960 If this attribute is present in a Stand-alone Library Project File,
14961 it indicates if initialization is automatic when the dynamic library
14964 @item Library_Options
14965 Expression must be a string list. Indicates additional switches that
14966 are to be used when building a shared library.
14969 Expression must be a single string. Designates an alternative to "gcc"
14970 for building shared libraries.
14972 @item Library_Src_Dir
14973 Expression must be a path name. The attribute defines the
14974 directory in which the sources of the interfaces of a Stand-alone Library will
14975 be copied. The directory must exist, must be distinct from the project's
14976 object directory and source directories of all projects in the project tree,
14977 and must be writable.
14979 @item Library_Src_Dir
14980 Expression must be a path name. The attribute defines the
14981 directory in which the ALI files of a Library will
14982 be copied. The directory must exist, must be distinct from the project's
14983 object directory and source directories of all projects in the project tree,
14984 and must be writable.
14986 @item Library_Symbol_File
14987 Expression must be a single string. Its value is the single file name of a
14988 symbol file to be created when building a stand-alone library when the
14989 symbol policy is either "compliant", "controlled" or "restricted",
14990 on platforms that support symbol control, such as VMS. When symbol policy
14991 is "direct", then a file with this name must exist in the object directory.
14993 @item Library_Reference_Symbol_File
14994 Expression must be a single string. Its value is the path name of a
14995 reference symbol file that is read when the symbol policy is either
14996 "compliant" or "controlled", on platforms that support symbol control,
14997 such as VMS, when building a stand-alone library. The path may be an absolute
14998 path or a path relative to the project directory.
15000 @item Library_Symbol_Policy
15001 Expression must be a single string. Its case-insensitive value can only be
15002 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15004 This attribute is not taken into account on all platforms. It controls the
15005 policy for exported symbols and, on some platforms (like VMS) that have the
15006 notions of major and minor IDs built in the library files, it controls
15007 the setting of these IDs.
15009 "autonomous" or "default": exported symbols are not controlled.
15011 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15012 it is equivalent to policy "autonomous". If there are exported symbols in
15013 the reference symbol file that are not in the object files of the interfaces,
15014 the major ID of the library is increased. If there are symbols in the
15015 object files of the interfaces that are not in the reference symbol file,
15016 these symbols are put at the end of the list in the newly created symbol file
15017 and the minor ID is increased.
15019 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15020 The library will fail to build if the exported symbols in the object files of
15021 the interfaces do not match exactly the symbol in the symbol file.
15023 "restricted": The attribute Library_Symbol_File must be defined. The library
15024 will fail to build if there are symbols in the symbol file that are not in
15025 the exported symbols of the object files of the interfaces. Additional symbols
15026 in the object files are not added to the symbol file.
15028 "direct": The attribute Library_Symbol_File must be defined and must designate
15029 an existing file in the object directory. This symbol file is passed directly
15030 to the underlying linker without any symbol processing.
15033 Expression must be a list of strings that are legal file names.
15034 These file names designate existing compilation units in the source directory
15035 that are legal main subprograms.
15037 When a project file is elaborated, as part of the execution of a gnatmake
15038 command, one or several executables are built and placed in the Exec_Dir.
15039 If the gnatmake command does not include explicit file names, the executables
15040 that are built correspond to the files specified by this attribute.
15042 @item Externally_Built
15043 Expression must be a single string. Its value must be either "true" of "false",
15044 case-insensitive. The default is "false". When the value of this attribute is
15045 "true", no attempt is made to compile the sources or to build the library,
15046 when the project is a library project.
15048 @item Main_Language
15049 This is a simple attribute. Its value is a string that specifies the
15050 language of the main program.
15053 Expression must be a string list. Each string designates
15054 a programming language that is known to GNAT. The strings are case-insensitive.
15056 @item Locally_Removed_Files
15057 This attribute is legal only in a project file that extends another.
15058 Expression must be a list of strings that are legal file names.
15059 Each file name must designate a source that would normally be inherited
15060 by the current project file. It cannot designate an immediate source that is
15061 not inherited. Each of the source files in the list are not considered to
15062 be sources of the project file: they are not inherited.
15065 @node Attribute References
15066 @section Attribute References
15069 Attribute references are used to retrieve the value of previously defined
15070 attribute for a package or project.
15073 attribute_reference ::=
15074 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
15076 attribute_prefix ::=
15078 <project_simple_name | package_identifier |
15079 <project_>simple_name . package_identifier
15083 If an attribute has not been specified for a given package or project, its
15084 value is the null string or the empty list.
15086 @node External Values
15087 @section External Values
15090 An external value is an expression whose value is obtained from the command
15091 that invoked the processing of the current project file (typically a
15097 @b{external} ( string_literal [, string_literal] )
15101 The first string_literal is the string to be used on the command line or
15102 in the environment to specify the external value. The second string_literal,
15103 if present, is the default to use if there is no specification for this
15104 external value either on the command line or in the environment.
15106 @node Case Construction
15107 @section Case Construction
15110 A case construction supports attribute and variable declarations that depend
15111 on the value of a previously declared variable.
15115 case_construction ::=
15116 @b{case} <typed_variable_>name @b{is}
15121 @b{when} discrete_choice_list =>
15122 @{case_construction |
15123 attribute_declaration |
15124 variable_declaration |
15125 empty_declaration@}
15127 discrete_choice_list ::=
15128 string_literal @{| string_literal@} |
15133 Inside a case construction, variable declarations must be for variables that
15134 have already been declared before the case construction.
15136 All choices in a choice list must be distinct. The choice lists of two
15137 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
15138 alternatives do not need to include all values of the type. An @code{others}
15139 choice must appear last in the list of alternatives.
15145 A package provides a grouping of variable declarations and attribute
15146 declarations to be used when invoking various GNAT tools. The name of
15147 the package indicates the tool(s) to which it applies.
15151 package_declaration ::=
15152 package_specification | package_renaming
15154 package_specification ::=
15155 @b{package} package_identifier @b{is}
15156 @{simple_declarative_item@}
15157 @b{end} package_identifier ;
15159 package_identifier ::=
15160 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
15161 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
15162 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
15165 @subsection Package Naming
15168 The attributes of a @code{Naming} package specifies the naming conventions
15169 that apply to the source files in a project. When invoking other GNAT tools,
15170 they will use the sources in the source directories that satisfy these
15171 naming conventions.
15173 The following attributes apply to a @code{Naming} package:
15177 This is a simple attribute whose value is a string. Legal values of this
15178 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
15179 These strings are themselves case insensitive.
15182 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
15184 @item Dot_Replacement
15185 This is a simple attribute whose string value satisfies the following
15189 @item It must not be empty
15190 @item It cannot start or end with an alphanumeric character
15191 @item It cannot be a single underscore
15192 @item It cannot start with an underscore followed by an alphanumeric
15193 @item It cannot contain a dot @code{'.'} if longer than one character
15197 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
15200 This is an associative array attribute, defined on language names,
15201 whose image is a string that must satisfy the following
15205 @item It must not be empty
15206 @item It cannot start with an alphanumeric character
15207 @item It cannot start with an underscore followed by an alphanumeric character
15211 For Ada, the attribute denotes the suffix used in file names that contain
15212 library unit declarations, that is to say units that are package and
15213 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
15214 specified, then the default is @code{".ads"}.
15216 For C and C++, the attribute denotes the suffix used in file names that
15217 contain prototypes.
15220 This is an associative array attribute defined on language names,
15221 whose image is a string that must satisfy the following
15225 @item It must not be empty
15226 @item It cannot start with an alphanumeric character
15227 @item It cannot start with an underscore followed by an alphanumeric character
15228 @item It cannot be a suffix of @code{Spec_Suffix}
15232 For Ada, the attribute denotes the suffix used in file names that contain
15233 library bodies, that is to say units that are package and subprogram bodies.
15234 If @code{Body_Suffix ("Ada")} is not specified, then the default is
15237 For C and C++, the attribute denotes the suffix used in file names that contain
15240 @item Separate_Suffix
15241 This is a simple attribute whose value satisfies the same conditions as
15242 @code{Body_Suffix}.
15244 This attribute is specific to Ada. It denotes the suffix used in file names
15245 that contain separate bodies. If it is not specified, then it defaults to same
15246 value as @code{Body_Suffix ("Ada")}.
15249 This is an associative array attribute, specific to Ada, defined over
15250 compilation unit names. The image is a string that is the name of the file
15251 that contains that library unit. The file name is case sensitive if the
15252 conventions of the host operating system require it.
15255 This is an associative array attribute, specific to Ada, defined over
15256 compilation unit names. The image is a string that is the name of the file
15257 that contains the library unit body for the named unit. The file name is case
15258 sensitive if the conventions of the host operating system require it.
15260 @item Specification_Exceptions
15261 This is an associative array attribute defined on language names,
15262 whose value is a list of strings.
15264 This attribute is not significant for Ada.
15266 For C and C++, each string in the list denotes the name of a file that
15267 contains prototypes, but whose suffix is not necessarily the
15268 @code{Spec_Suffix} for the language.
15270 @item Implementation_Exceptions
15271 This is an associative array attribute defined on language names,
15272 whose value is a list of strings.
15274 This attribute is not significant for Ada.
15276 For C and C++, each string in the list denotes the name of a file that
15277 contains source code, but whose suffix is not necessarily the
15278 @code{Body_Suffix} for the language.
15281 The following attributes of package @code{Naming} are obsolescent. They are
15282 kept as synonyms of other attributes for compatibility with previous versions
15283 of the Project Manager.
15286 @item Specification_Suffix
15287 This is a synonym of @code{Spec_Suffix}.
15289 @item Implementation_Suffix
15290 This is a synonym of @code{Body_Suffix}.
15292 @item Specification
15293 This is a synonym of @code{Spec}.
15295 @item Implementation
15296 This is a synonym of @code{Body}.
15299 @subsection package Compiler
15302 The attributes of the @code{Compiler} package specify the compilation options
15303 to be used by the underlying compiler.
15306 @item Default_Switches
15307 This is an associative array attribute. Its
15308 domain is a set of language names. Its range is a string list that
15309 specifies the compilation options to be used when compiling a component
15310 written in that language, for which no file-specific switches have been
15314 This is an associative array attribute. Its domain is
15315 a set of file names. Its range is a string list that specifies the
15316 compilation options to be used when compiling the named file. If a file
15317 is not specified in the Switches attribute, it is compiled with the
15318 options specified by Default_Switches of its language, if defined.
15320 @item Local_Configuration_Pragmas.
15321 This is a simple attribute, whose
15322 value is a path name that designates a file containing configuration pragmas
15323 to be used for all invocations of the compiler for immediate sources of the
15327 @subsection package Builder
15330 The attributes of package @code{Builder} specify the compilation, binding, and
15331 linking options to be used when building an executable for a project. The
15332 following attributes apply to package @code{Builder}:
15335 @item Default_Switches
15336 This is an associative array attribute. Its
15337 domain is a set of language names. Its range is a string list that
15338 specifies options to be used when building a main
15339 written in that language, for which no file-specific switches have been
15343 This is an associative array attribute. Its domain is
15344 a set of file names. Its range is a string list that specifies
15345 options to be used when building the named main file. If a main file
15346 is not specified in the Switches attribute, it is built with the
15347 options specified by Default_Switches of its language, if defined.
15349 @item Global_Configuration_Pragmas
15350 This is a simple attribute, whose
15351 value is a path name that designates a file that contains configuration pragmas
15352 to be used in every build of an executable. If both local and global
15353 configuration pragmas are specified, a compilation makes use of both sets.
15357 This is an associative array attribute. Its domain is
15358 a set of main source file names. Its range is a simple string that specifies
15359 the executable file name to be used when linking the specified main source.
15360 If a main source is not specified in the Executable attribute, the executable
15361 file name is deducted from the main source file name.
15362 This attribute has no effect if its value is the empty string.
15364 @item Executable_Suffix
15365 This is a simple attribute whose value is the suffix to be added to
15366 the executables that don't have an attribute Executable specified.
15369 @subsection package Gnatls
15372 The attributes of package @code{Gnatls} specify the tool options to be used
15373 when invoking the library browser @command{gnatls}.
15374 The following attributes apply to package @code{Gnatls}:
15378 This is a single attribute with a string list value. Each non empty string
15379 in the list is an option when invoking @code{gnatls}.
15382 @subsection package Binder
15385 The attributes of package @code{Binder} specify the options to be used
15386 when invoking the binder in the construction of an executable.
15387 The following attributes apply to package @code{Binder}:
15390 @item Default_Switches
15391 This is an associative array attribute. Its
15392 domain is a set of language names. Its range is a string list that
15393 specifies options to be used when binding a main
15394 written in that language, for which no file-specific switches have been
15398 This is an associative array attribute. Its domain is
15399 a set of file names. Its range is a string list that specifies
15400 options to be used when binding the named main file. If a main file
15401 is not specified in the Switches attribute, it is bound with the
15402 options specified by Default_Switches of its language, if defined.
15405 @subsection package Linker
15408 The attributes of package @code{Linker} specify the options to be used when
15409 invoking the linker in the construction of an executable.
15410 The following attributes apply to package @code{Linker}:
15413 @item Default_Switches
15414 This is an associative array attribute. Its
15415 domain is a set of language names. Its range is a string list that
15416 specifies options to be used when linking a main
15417 written in that language, for which no file-specific switches have been
15421 This is an associative array attribute. Its domain is
15422 a set of file names. Its range is a string list that specifies
15423 options to be used when linking the named main file. If a main file
15424 is not specified in the Switches attribute, it is linked with the
15425 options specified by Default_Switches of its language, if defined.
15427 @item Linker_Options
15428 This is a string list attribute. Its value specifies additional options that
15429 be given to the linker when linking an executable. This attribute is not
15430 used in the main project, only in projects imported directly or indirectly.
15434 @subsection package Cross_Reference
15437 The attributes of package @code{Cross_Reference} specify the tool options
15439 when invoking the library tool @command{gnatxref}.
15440 The following attributes apply to package @code{Cross_Reference}:
15443 @item Default_Switches
15444 This is an associative array attribute. Its
15445 domain is a set of language names. Its range is a string list that
15446 specifies options to be used when calling @command{gnatxref} on a source
15447 written in that language, for which no file-specific switches have been
15451 This is an associative array attribute. Its domain is
15452 a set of file names. Its range is a string list that specifies
15453 options to be used when calling @command{gnatxref} on the named main source.
15454 If a source is not specified in the Switches attribute, @command{gnatxref} will
15455 be called with the options specified by Default_Switches of its language,
15459 @subsection package Finder
15462 The attributes of package @code{Finder} specify the tool options to be used
15463 when invoking the search tool @command{gnatfind}.
15464 The following attributes apply to package @code{Finder}:
15467 @item Default_Switches
15468 This is an associative array attribute. Its
15469 domain is a set of language names. Its range is a string list that
15470 specifies options to be used when calling @command{gnatfind} on a source
15471 written in that language, for which no file-specific switches have been
15475 This is an associative array attribute. Its domain is
15476 a set of file names. Its range is a string list that specifies
15477 options to be used when calling @command{gnatfind} on the named main source.
15478 If a source is not specified in the Switches attribute, @command{gnatfind} will
15479 be called with the options specified by Default_Switches of its language,
15483 @subsection package Pretty_Printer
15486 The attributes of package @code{Pretty_Printer}
15487 specify the tool options to be used
15488 when invoking the formatting tool @command{gnatpp}.
15489 The following attributes apply to package @code{Pretty_Printer}:
15492 @item Default_switches
15493 This is an associative array attribute. Its
15494 domain is a set of language names. Its range is a string list that
15495 specifies options to be used when calling @command{gnatpp} on a source
15496 written in that language, for which no file-specific switches have been
15500 This is an associative array attribute. Its domain is
15501 a set of file names. Its range is a string list that specifies
15502 options to be used when calling @command{gnatpp} on the named main source.
15503 If a source is not specified in the Switches attribute, @command{gnatpp} will
15504 be called with the options specified by Default_Switches of its language,
15508 @subsection package gnatstub
15511 The attributes of package @code{gnatstub}
15512 specify the tool options to be used
15513 when invoking the tool @command{gnatstub}.
15514 The following attributes apply to package @code{gnatstub}:
15517 @item Default_switches
15518 This is an associative array attribute. Its
15519 domain is a set of language names. Its range is a string list that
15520 specifies options to be used when calling @command{gnatstub} on a source
15521 written in that language, for which no file-specific switches have been
15525 This is an associative array attribute. Its domain is
15526 a set of file names. Its range is a string list that specifies
15527 options to be used when calling @command{gnatstub} on the named main source.
15528 If a source is not specified in the Switches attribute, @command{gnatpp} will
15529 be called with the options specified by Default_Switches of its language,
15533 @subsection package Eliminate
15536 The attributes of package @code{Eliminate}
15537 specify the tool options to be used
15538 when invoking the tool @command{gnatelim}.
15539 The following attributes apply to package @code{Eliminate}:
15542 @item Default_switches
15543 This is an associative array attribute. Its
15544 domain is a set of language names. Its range is a string list that
15545 specifies options to be used when calling @command{gnatelim} on a source
15546 written in that language, for which no file-specific switches have been
15550 This is an associative array attribute. Its domain is
15551 a set of file names. Its range is a string list that specifies
15552 options to be used when calling @command{gnatelim} on the named main source.
15553 If a source is not specified in the Switches attribute, @command{gnatelim} will
15554 be called with the options specified by Default_Switches of its language,
15558 @subsection package Metrics
15561 The attributes of package @code{Metrics}
15562 specify the tool options to be used
15563 when invoking the tool @command{gnatmetric}.
15564 The following attributes apply to package @code{Metrics}:
15567 @item Default_switches
15568 This is an associative array attribute. Its
15569 domain is a set of language names. Its range is a string list that
15570 specifies options to be used when calling @command{gnatmetric} on a source
15571 written in that language, for which no file-specific switches have been
15575 This is an associative array attribute. Its domain is
15576 a set of file names. Its range is a string list that specifies
15577 options to be used when calling @command{gnatmetric} on the named main source.
15578 If a source is not specified in the Switches attribute, @command{gnatmetric}
15579 will be called with the options specified by Default_Switches of its language,
15583 @subsection package IDE
15586 The attributes of package @code{IDE} specify the options to be used when using
15587 an Integrated Development Environment such as @command{GPS}.
15591 This is a simple attribute. Its value is a string that designates the remote
15592 host in a cross-compilation environment, to be used for remote compilation and
15593 debugging. This field should not be specified when running on the local
15597 This is a simple attribute. Its value is a string that specifies the
15598 name of IP address of the embedded target in a cross-compilation environment,
15599 on which the program should execute.
15601 @item Communication_Protocol
15602 This is a simple string attribute. Its value is the name of the protocol
15603 to use to communicate with the target in a cross-compilation environment,
15604 e.g. @code{"wtx"} or @code{"vxworks"}.
15606 @item Compiler_Command
15607 This is an associative array attribute, whose domain is a language name. Its
15608 value is string that denotes the command to be used to invoke the compiler.
15609 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
15610 gnatmake, in particular in the handling of switches.
15612 @item Debugger_Command
15613 This is simple attribute, Its value is a string that specifies the name of
15614 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
15616 @item Default_Switches
15617 This is an associative array attribute. Its indexes are the name of the
15618 external tools that the GNAT Programming System (GPS) is supporting. Its
15619 value is a list of switches to use when invoking that tool.
15622 This is a simple attribute. Its value is a string that specifies the name
15623 of the @command{gnatls} utility to be used to retrieve information about the
15624 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
15627 This is a simple attribute. Its value is a string used to specify the
15628 Version Control System (VCS) to be used for this project, e.g CVS, RCS
15629 ClearCase or Perforce.
15631 @item VCS_File_Check
15632 This is a simple attribute. Its value is a string that specifies the
15633 command used by the VCS to check the validity of a file, either
15634 when the user explicitly asks for a check, or as a sanity check before
15635 doing the check-in.
15637 @item VCS_Log_Check
15638 This is a simple attribute. Its value is a string that specifies
15639 the command used by the VCS to check the validity of a log file.
15643 @node Package Renamings
15644 @section Package Renamings
15647 A package can be defined by a renaming declaration. The new package renames
15648 a package declared in a different project file, and has the same attributes
15649 as the package it renames.
15652 package_renaming ::==
15653 @b{package} package_identifier @b{renames}
15654 <project_>simple_name.package_identifier ;
15658 The package_identifier of the renamed package must be the same as the
15659 package_identifier. The project whose name is the prefix of the renamed
15660 package must contain a package declaration with this name. This project
15661 must appear in the context_clause of the enclosing project declaration,
15662 or be the parent project of the enclosing child project.
15668 A project file specifies a set of rules for constructing a software system.
15669 A project file can be self-contained, or depend on other project files.
15670 Dependencies are expressed through a context clause that names other projects.
15676 context_clause project_declaration
15678 project_declaration ::=
15679 simple_project_declaration | project_extension
15681 simple_project_declaration ::=
15682 @b{project} <project_>simple_name @b{is}
15683 @{declarative_item@}
15684 @b{end} <project_>simple_name;
15690 [@b{limited}] @b{with} path_name @{ , path_name @} ;
15697 A path name denotes a project file. A path name can be absolute or relative.
15698 An absolute path name includes a sequence of directories, in the syntax of
15699 the host operating system, that identifies uniquely the project file in the
15700 file system. A relative path name identifies the project file, relative
15701 to the directory that contains the current project, or relative to a
15702 directory listed in the environment variable ADA_PROJECT_PATH.
15703 Path names are case sensitive if file names in the host operating system
15704 are case sensitive.
15706 The syntax of the environment variable ADA_PROJECT_PATH is a list of
15707 directory names separated by colons (semicolons on Windows).
15709 A given project name can appear only once in a context_clause.
15711 It is illegal for a project imported by a context clause to refer, directly
15712 or indirectly, to the project in which this context clause appears (the
15713 dependency graph cannot contain cycles), except when one of the with_clause
15714 in the cycle is a @code{limited with}.
15716 @node Project Extensions
15717 @section Project Extensions
15720 A project extension introduces a new project, which inherits the declarations
15721 of another project.
15725 project_extension ::=
15726 @b{project} <project_>simple_name @b{extends} path_name @b{is}
15727 @{declarative_item@}
15728 @b{end} <project_>simple_name;
15732 The project extension declares a child project. The child project inherits
15733 all the declarations and all the files of the parent project, These inherited
15734 declaration can be overridden in the child project, by means of suitable
15737 @node Project File Elaboration
15738 @section Project File Elaboration
15741 A project file is processed as part of the invocation of a gnat tool that
15742 uses the project option. Elaboration of the process file consists in the
15743 sequential elaboration of all its declarations. The computed values of
15744 attributes and variables in the project are then used to establish the
15745 environment in which the gnat tool will execute.
15747 @node Obsolescent Features
15748 @chapter Obsolescent Features
15751 This chapter describes features that are provided by GNAT, but are
15752 considered obsolescent since there are preferred ways of achieving
15753 the same effect. These features are provided solely for historical
15754 compatibility purposes.
15757 * pragma No_Run_Time::
15758 * pragma Ravenscar::
15759 * pragma Restricted_Run_Time::
15762 @node pragma No_Run_Time
15763 @section pragma No_Run_Time
15765 The pragma @code{No_Run_Time} is used to achieve an affect similar
15766 to the use of the "Zero Foot Print" configurable run time, but without
15767 requiring a specially configured run time. The result of using this
15768 pragma, which must be used for all units in a partition, is to restrict
15769 the use of any language features requiring run-time support code. The
15770 preferred usage is to use an appropriately configured run-time that
15771 includes just those features that are to be made accessible.
15773 @node pragma Ravenscar
15774 @section pragma Ravenscar
15776 The pragma @code{Ravenscar} has exactly the same effect as pragma
15777 @code{Profile (Ravenscar)}. The latter usage is preferred since it
15778 is part of the new Ada 2005 standard.
15780 @node pragma Restricted_Run_Time
15781 @section pragma Restricted_Run_Time
15783 The pragma @code{Restricted_Run_Time} has exactly the same effect as
15784 pragma @code{Profile (Restricted)}. The latter usage is
15785 preferred since the Ada 2005 pragma @code{Profile} is intended for
15786 this kind of implementation dependent addition.
15789 @c GNU Free Documentation License
15791 @node Index,,GNU Free Documentation License, Top