1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
15 @setfilename gnat_rm.info
18 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.2 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts. A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
32 @settitle GNAT Reference Manual
34 @setchapternewpage odd
37 @include gcc-common.texi
39 @dircategory GNU Ada tools
41 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
50 @vskip 0pt plus 1filll
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Project File Reference::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
89 --- The Detailed Node Listing ---
93 * What This Reference Manual Contains::
94 * Related Information::
96 Implementation Defined Pragmas
98 * Pragma Abort_Defer::
106 * Pragma C_Pass_By_Copy::
108 * Pragma Check_Name::
109 * Pragma Check_Policy::
111 * Pragma Common_Object::
112 * Pragma Compile_Time_Error::
113 * Pragma Compile_Time_Warning::
114 * Pragma Complete_Representation::
115 * Pragma Complex_Representation::
116 * Pragma Component_Alignment::
117 * Pragma Convention_Identifier::
119 * Pragma CPP_Constructor::
120 * Pragma CPP_Virtual::
121 * Pragma CPP_Vtable::
123 * Pragma Debug_Policy::
124 * Pragma Detect_Blocking::
125 * Pragma Elaboration_Checks::
127 * Pragma Export_Exception::
128 * Pragma Export_Function::
129 * Pragma Export_Object::
130 * Pragma Export_Procedure::
131 * Pragma Export_Value::
132 * Pragma Export_Valued_Procedure::
133 * Pragma Extend_System::
135 * Pragma External_Name_Casing::
137 * Pragma Favor_Top_Level::
138 * Pragma Finalize_Storage_Only::
139 * Pragma Float_Representation::
141 * Pragma Implemented_By_Entry::
142 * Pragma Implicit_Packing::
143 * Pragma Import_Exception::
144 * Pragma Import_Function::
145 * Pragma Import_Object::
146 * Pragma Import_Procedure::
147 * Pragma Import_Valued_Procedure::
148 * Pragma Initialize_Scalars::
149 * Pragma Inline_Always::
150 * Pragma Inline_Generic::
152 * Pragma Interface_Name::
153 * Pragma Interrupt_Handler::
154 * Pragma Interrupt_State::
155 * Pragma Keep_Names::
158 * Pragma Linker_Alias::
159 * Pragma Linker_Constructor::
160 * Pragma Linker_Destructor::
161 * Pragma Linker_Section::
162 * Pragma Long_Float::
163 * Pragma Machine_Attribute::
165 * Pragma Main_Storage::
168 * Pragma No_Strict_Aliasing ::
169 * Pragma Normalize_Scalars::
170 * Pragma Obsolescent::
171 * Pragma Optimize_Alignment::
173 * Pragma Persistent_BSS::
175 * Pragma Postcondition::
176 * Pragma Precondition::
177 * Pragma Profile (Ravenscar)::
178 * Pragma Profile (Restricted)::
179 * Pragma Psect_Object::
180 * Pragma Pure_Function::
181 * Pragma Restriction_Warnings::
183 * Pragma Source_File_Name::
184 * Pragma Source_File_Name_Project::
185 * Pragma Source_Reference::
186 * Pragma Stream_Convert::
187 * Pragma Style_Checks::
190 * Pragma Suppress_All::
191 * Pragma Suppress_Exception_Locations::
192 * Pragma Suppress_Initialization::
195 * Pragma Task_Storage::
196 * Pragma Time_Slice::
198 * Pragma Unchecked_Union::
199 * Pragma Unimplemented_Unit::
200 * Pragma Universal_Aliasing ::
201 * Pragma Universal_Data::
202 * Pragma Unmodified::
203 * Pragma Unreferenced::
204 * Pragma Unreferenced_Objects::
205 * Pragma Unreserve_All_Interrupts::
206 * Pragma Unsuppress::
207 * Pragma Use_VADS_Size::
208 * Pragma Validity_Checks::
211 * Pragma Weak_External::
212 * Pragma Wide_Character_Encoding::
214 Implementation Defined Attributes
224 * Default_Bit_Order::
234 * Has_Access_Values::
235 * Has_Discriminants::
242 * Max_Interrupt_Priority::
244 * Maximum_Alignment::
249 * Passed_By_Reference::
262 * Unconstrained_Array::
263 * Universal_Literal_String::
264 * Unrestricted_Access::
270 The Implementation of Standard I/O
272 * Standard I/O Packages::
278 * Wide_Wide_Text_IO::
281 * Filenames encoding::
283 * Operations on C Streams::
284 * Interfacing to C Streams::
288 * Ada.Characters.Latin_9 (a-chlat9.ads)::
289 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
290 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
291 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
292 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
293 * Ada.Command_Line.Environment (a-colien.ads)::
294 * Ada.Command_Line.Remove (a-colire.ads)::
295 * Ada.Command_Line.Response_File (a-clrefi.ads)::
296 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
297 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
298 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
299 * Ada.Exceptions.Traceback (a-exctra.ads)::
300 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
301 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
302 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
303 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
304 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
305 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
306 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
307 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
308 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
309 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
310 * GNAT.Altivec (g-altive.ads)::
311 * GNAT.Altivec.Conversions (g-altcon.ads)::
312 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
313 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
314 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
315 * GNAT.Array_Split (g-arrspl.ads)::
316 * GNAT.AWK (g-awk.ads)::
317 * GNAT.Bounded_Buffers (g-boubuf.ads)::
318 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
319 * GNAT.Bubble_Sort (g-bubsor.ads)::
320 * GNAT.Bubble_Sort_A (g-busora.ads)::
321 * GNAT.Bubble_Sort_G (g-busorg.ads)::
322 * GNAT.Byte_Order_Mark (g-byorma.ads)::
323 * GNAT.Byte_Swapping (g-bytswa.ads)::
324 * GNAT.Calendar (g-calend.ads)::
325 * GNAT.Calendar.Time_IO (g-catiio.ads)::
326 * GNAT.Case_Util (g-casuti.ads)::
327 * GNAT.CGI (g-cgi.ads)::
328 * GNAT.CGI.Cookie (g-cgicoo.ads)::
329 * GNAT.CGI.Debug (g-cgideb.ads)::
330 * GNAT.Command_Line (g-comlin.ads)::
331 * GNAT.Compiler_Version (g-comver.ads)::
332 * GNAT.Ctrl_C (g-ctrl_c.ads)::
333 * GNAT.CRC32 (g-crc32.ads)::
334 * GNAT.Current_Exception (g-curexc.ads)::
335 * GNAT.Debug_Pools (g-debpoo.ads)::
336 * GNAT.Debug_Utilities (g-debuti.ads)::
337 * GNAT.Decode_String (g-decstr.ads)::
338 * GNAT.Decode_UTF8_String (g-deutst.ads)::
339 * GNAT.Directory_Operations (g-dirope.ads)::
340 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
341 * GNAT.Dynamic_HTables (g-dynhta.ads)::
342 * GNAT.Dynamic_Tables (g-dyntab.ads)::
343 * GNAT.Encode_String (g-encstr.ads)::
344 * GNAT.Encode_UTF8_String (g-enutst.ads)::
345 * GNAT.Exception_Actions (g-excact.ads)::
346 * GNAT.Exception_Traces (g-exctra.ads)::
347 * GNAT.Exceptions (g-except.ads)::
348 * GNAT.Expect (g-expect.ads)::
349 * GNAT.Float_Control (g-flocon.ads)::
350 * GNAT.Heap_Sort (g-heasor.ads)::
351 * GNAT.Heap_Sort_A (g-hesora.ads)::
352 * GNAT.Heap_Sort_G (g-hesorg.ads)::
353 * GNAT.HTable (g-htable.ads)::
354 * GNAT.IO (g-io.ads)::
355 * GNAT.IO_Aux (g-io_aux.ads)::
356 * GNAT.Lock_Files (g-locfil.ads)::
357 * GNAT.MD5 (g-md5.ads)::
358 * GNAT.Memory_Dump (g-memdum.ads)::
359 * GNAT.Most_Recent_Exception (g-moreex.ads)::
360 * GNAT.OS_Lib (g-os_lib.ads)::
361 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
362 * GNAT.Random_Numbers (g-rannum.ads)::
363 * GNAT.Regexp (g-regexp.ads)::
364 * GNAT.Registry (g-regist.ads)::
365 * GNAT.Regpat (g-regpat.ads)::
366 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
367 * GNAT.Semaphores (g-semaph.ads)::
368 * GNAT.Serial_Communications (g-sercom.ads)::
369 * GNAT.SHA1 (g-sha1.ads)::
370 * GNAT.Signals (g-signal.ads)::
371 * GNAT.Sockets (g-socket.ads)::
372 * GNAT.Source_Info (g-souinf.ads)::
373 * GNAT.Spelling_Checker (g-speche.ads)::
374 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
375 * GNAT.Spitbol.Patterns (g-spipat.ads)::
376 * GNAT.Spitbol (g-spitbo.ads)::
377 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
378 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
379 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
380 * GNAT.Strings (g-string.ads)::
381 * GNAT.String_Split (g-strspl.ads)::
382 * GNAT.Table (g-table.ads)::
383 * GNAT.Task_Lock (g-tasloc.ads)::
384 * GNAT.Threads (g-thread.ads)::
385 * GNAT.Time_Stamp (g-timsta.ads)::
386 * GNAT.Traceback (g-traceb.ads)::
387 * GNAT.Traceback.Symbolic (g-trasym.ads)::
388 * GNAT.UTF_32 (g-utf_32.ads)::
389 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
390 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
391 * GNAT.Wide_String_Split (g-wistsp.ads)::
392 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
393 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
394 * Interfaces.C.Extensions (i-cexten.ads)::
395 * Interfaces.C.Streams (i-cstrea.ads)::
396 * Interfaces.CPP (i-cpp.ads)::
397 * Interfaces.Packed_Decimal (i-pacdec.ads)::
398 * Interfaces.VxWorks (i-vxwork.ads)::
399 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
400 * System.Address_Image (s-addima.ads)::
401 * System.Assertions (s-assert.ads)::
402 * System.Memory (s-memory.ads)::
403 * System.Partition_Interface (s-parint.ads)::
404 * System.Pool_Global (s-pooglo.ads)::
405 * System.Pool_Local (s-pooloc.ads)::
406 * System.Restrictions (s-restri.ads)::
407 * System.Rident (s-rident.ads)::
408 * System.Task_Info (s-tasinf.ads)::
409 * System.Wch_Cnv (s-wchcnv.ads)::
410 * System.Wch_Con (s-wchcon.ads)::
414 * Text_IO Stream Pointer Positioning::
415 * Text_IO Reading and Writing Non-Regular Files::
417 * Treating Text_IO Files as Streams::
418 * Text_IO Extensions::
419 * Text_IO Facilities for Unbounded Strings::
423 * Wide_Text_IO Stream Pointer Positioning::
424 * Wide_Text_IO Reading and Writing Non-Regular Files::
428 * Wide_Wide_Text_IO Stream Pointer Positioning::
429 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
431 Interfacing to Other Languages
434 * Interfacing to C++::
435 * Interfacing to COBOL::
436 * Interfacing to Fortran::
437 * Interfacing to non-GNAT Ada code::
439 Specialized Needs Annexes
441 Implementation of Specific Ada Features
442 * Machine Code Insertions::
443 * GNAT Implementation of Tasking::
444 * GNAT Implementation of Shared Passive Packages::
445 * Code Generation for Array Aggregates::
446 * The Size of Discriminated Records with Default Discriminants::
447 * Strict Conformance to the Ada Reference Manual::
449 Project File Reference
453 GNU Free Documentation License
460 @node About This Guide
461 @unnumbered About This Guide
464 This manual contains useful information in writing programs using the
465 @value{EDITION} compiler. It includes information on implementation dependent
466 characteristics of @value{EDITION}, including all the information required by
467 Annex M of the Ada language standard.
469 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
470 Ada 83 compatibility mode.
471 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
472 but you can override with a compiler switch
473 to explicitly specify the language version.
474 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
475 @value{EDITION} User's Guide}, for details on these switches.)
476 Throughout this manual, references to ``Ada'' without a year suffix
477 apply to both the Ada 95 and Ada 2005 versions of the language.
479 Ada is designed to be highly portable.
480 In general, a program will have the same effect even when compiled by
481 different compilers on different platforms.
482 However, since Ada is designed to be used in a
483 wide variety of applications, it also contains a number of system
484 dependent features to be used in interfacing to the external world.
485 @cindex Implementation-dependent features
488 Note: Any program that makes use of implementation-dependent features
489 may be non-portable. You should follow good programming practice and
490 isolate and clearly document any sections of your program that make use
491 of these features in a non-portable manner.
494 For ease of exposition, ``GNAT Pro'' will be referred to simply as
495 ``GNAT'' in the remainder of this document.
499 * What This Reference Manual Contains::
501 * Related Information::
504 @node What This Reference Manual Contains
505 @unnumberedsec What This Reference Manual Contains
508 This reference manual contains the following chapters:
512 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
513 pragmas, which can be used to extend and enhance the functionality of the
517 @ref{Implementation Defined Attributes}, lists GNAT
518 implementation-dependent attributes which can be used to extend and
519 enhance the functionality of the compiler.
522 @ref{Implementation Advice}, provides information on generally
523 desirable behavior which are not requirements that all compilers must
524 follow since it cannot be provided on all systems, or which may be
525 undesirable on some systems.
528 @ref{Implementation Defined Characteristics}, provides a guide to
529 minimizing implementation dependent features.
532 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
533 implemented by GNAT, and how they can be imported into user
534 application programs.
537 @ref{Representation Clauses and Pragmas}, describes in detail the
538 way that GNAT represents data, and in particular the exact set
539 of representation clauses and pragmas that is accepted.
542 @ref{Standard Library Routines}, provides a listing of packages and a
543 brief description of the functionality that is provided by Ada's
544 extensive set of standard library routines as implemented by GNAT@.
547 @ref{The Implementation of Standard I/O}, details how the GNAT
548 implementation of the input-output facilities.
551 @ref{The GNAT Library}, is a catalog of packages that complement
552 the Ada predefined library.
555 @ref{Interfacing to Other Languages}, describes how programs
556 written in Ada using GNAT can be interfaced to other programming
559 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
560 of the specialized needs annexes.
563 @ref{Implementation of Specific Ada Features}, discusses issues related
564 to GNAT's implementation of machine code insertions, tasking, and several
568 @ref{Project File Reference}, presents the syntax and semantics
572 @ref{Obsolescent Features} documents implementation dependent features,
573 including pragmas and attributes, which are considered obsolescent, since
574 there are other preferred ways of achieving the same results. These
575 obsolescent forms are retained for backwards compatibility.
579 @cindex Ada 95 Language Reference Manual
580 @cindex Ada 2005 Language Reference Manual
582 This reference manual assumes a basic familiarity with the Ada 95 language, as
583 described in the International Standard ANSI/ISO/IEC-8652:1995,
585 It does not require knowledge of the new features introduced by Ada 2005,
586 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
588 Both reference manuals are included in the GNAT documentation
592 @unnumberedsec Conventions
593 @cindex Conventions, typographical
594 @cindex Typographical conventions
597 Following are examples of the typographical and graphic conventions used
602 @code{Functions}, @code{utility program names}, @code{standard names},
609 @file{File names}, @samp{button names}, and @samp{field names}.
612 @code{Variables}, @env{environment variables}, and @var{metasyntactic
619 [optional information or parameters]
622 Examples are described by text
624 and then shown this way.
629 Commands that are entered by the user are preceded in this manual by the
630 characters @samp{$ } (dollar sign followed by space). If your system uses this
631 sequence as a prompt, then the commands will appear exactly as you see them
632 in the manual. If your system uses some other prompt, then the command will
633 appear with the @samp{$} replaced by whatever prompt character you are using.
635 @node Related Information
636 @unnumberedsec Related Information
638 See the following documents for further information on GNAT:
642 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
643 @value{EDITION} User's Guide}, which provides information on how to use the
644 GNAT compiler system.
647 @cite{Ada 95 Reference Manual}, which contains all reference
648 material for the Ada 95 programming language.
651 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
652 of the Ada 95 standard. The annotations describe
653 detailed aspects of the design decision, and in particular contain useful
654 sections on Ada 83 compatibility.
657 @cite{Ada 2005 Reference Manual}, which contains all reference
658 material for the Ada 2005 programming language.
661 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
662 of the Ada 2005 standard. The annotations describe
663 detailed aspects of the design decision, and in particular contain useful
664 sections on Ada 83 and Ada 95 compatibility.
667 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
668 which contains specific information on compatibility between GNAT and
672 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
673 describes in detail the pragmas and attributes provided by the DEC Ada 83
678 @node Implementation Defined Pragmas
679 @chapter Implementation Defined Pragmas
682 Ada defines a set of pragmas that can be used to supply additional
683 information to the compiler. These language defined pragmas are
684 implemented in GNAT and work as described in the Ada Reference
687 In addition, Ada allows implementations to define additional pragmas
688 whose meaning is defined by the implementation. GNAT provides a number
689 of these implementation-defined pragmas, which can be used to extend
690 and enhance the functionality of the compiler. This section of the GNAT
691 Reference Manual describes these additional pragmas.
693 Note that any program using these pragmas might not be portable to other
694 compilers (although GNAT implements this set of pragmas on all
695 platforms). Therefore if portability to other compilers is an important
696 consideration, the use of these pragmas should be minimized.
699 * Pragma Abort_Defer::
707 * Pragma C_Pass_By_Copy::
709 * Pragma Check_Name::
710 * Pragma Check_Policy::
712 * Pragma Common_Object::
713 * Pragma Compile_Time_Error::
714 * Pragma Compile_Time_Warning::
715 * Pragma Complete_Representation::
716 * Pragma Complex_Representation::
717 * Pragma Component_Alignment::
718 * Pragma Convention_Identifier::
720 * Pragma CPP_Constructor::
721 * Pragma CPP_Virtual::
722 * Pragma CPP_Vtable::
724 * Pragma Debug_Policy::
725 * Pragma Detect_Blocking::
726 * Pragma Elaboration_Checks::
728 * Pragma Export_Exception::
729 * Pragma Export_Function::
730 * Pragma Export_Object::
731 * Pragma Export_Procedure::
732 * Pragma Export_Value::
733 * Pragma Export_Valued_Procedure::
734 * Pragma Extend_System::
736 * Pragma External_Name_Casing::
738 * Pragma Favor_Top_Level::
739 * Pragma Finalize_Storage_Only::
740 * Pragma Float_Representation::
742 * Pragma Implemented_By_Entry::
743 * Pragma Implicit_Packing::
744 * Pragma Import_Exception::
745 * Pragma Import_Function::
746 * Pragma Import_Object::
747 * Pragma Import_Procedure::
748 * Pragma Import_Valued_Procedure::
749 * Pragma Initialize_Scalars::
750 * Pragma Inline_Always::
751 * Pragma Inline_Generic::
753 * Pragma Interface_Name::
754 * Pragma Interrupt_Handler::
755 * Pragma Interrupt_State::
756 * Pragma Keep_Names::
759 * Pragma Linker_Alias::
760 * Pragma Linker_Constructor::
761 * Pragma Linker_Destructor::
762 * Pragma Linker_Section::
763 * Pragma Long_Float::
764 * Pragma Machine_Attribute::
766 * Pragma Main_Storage::
769 * Pragma No_Strict_Aliasing::
770 * Pragma Normalize_Scalars::
771 * Pragma Obsolescent::
772 * Pragma Optimize_Alignment::
774 * Pragma Persistent_BSS::
776 * Pragma Postcondition::
777 * Pragma Precondition::
778 * Pragma Profile (Ravenscar)::
779 * Pragma Profile (Restricted)::
780 * Pragma Psect_Object::
781 * Pragma Pure_Function::
782 * Pragma Restriction_Warnings::
784 * Pragma Source_File_Name::
785 * Pragma Source_File_Name_Project::
786 * Pragma Source_Reference::
787 * Pragma Stream_Convert::
788 * Pragma Style_Checks::
791 * Pragma Suppress_All::
792 * Pragma Suppress_Exception_Locations::
793 * Pragma Suppress_Initialization::
796 * Pragma Task_Storage::
797 * Pragma Time_Slice::
799 * Pragma Unchecked_Union::
800 * Pragma Unimplemented_Unit::
801 * Pragma Universal_Aliasing ::
802 * Pragma Universal_Data::
803 * Pragma Unmodified::
804 * Pragma Unreferenced::
805 * Pragma Unreferenced_Objects::
806 * Pragma Unreserve_All_Interrupts::
807 * Pragma Unsuppress::
808 * Pragma Use_VADS_Size::
809 * Pragma Validity_Checks::
812 * Pragma Weak_External::
813 * Pragma Wide_Character_Encoding::
816 @node Pragma Abort_Defer
817 @unnumberedsec Pragma Abort_Defer
819 @cindex Deferring aborts
827 This pragma must appear at the start of the statement sequence of a
828 handled sequence of statements (right after the @code{begin}). It has
829 the effect of deferring aborts for the sequence of statements (but not
830 for the declarations or handlers, if any, associated with this statement
834 @unnumberedsec Pragma Ada_83
843 A configuration pragma that establishes Ada 83 mode for the unit to
844 which it applies, regardless of the mode set by the command line
845 switches. In Ada 83 mode, GNAT attempts to be as compatible with
846 the syntax and semantics of Ada 83, as defined in the original Ada
847 83 Reference Manual as possible. In particular, the keywords added by Ada 95
848 and Ada 2005 are not recognized, optional package bodies are allowed,
849 and generics may name types with unknown discriminants without using
850 the @code{(<>)} notation. In addition, some but not all of the additional
851 restrictions of Ada 83 are enforced.
853 Ada 83 mode is intended for two purposes. Firstly, it allows existing
854 Ada 83 code to be compiled and adapted to GNAT with less effort.
855 Secondly, it aids in keeping code backwards compatible with Ada 83.
856 However, there is no guarantee that code that is processed correctly
857 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
858 83 compiler, since GNAT does not enforce all the additional checks
862 @unnumberedsec Pragma Ada_95
871 A configuration pragma that establishes Ada 95 mode for the unit to which
872 it applies, regardless of the mode set by the command line switches.
873 This mode is set automatically for the @code{Ada} and @code{System}
874 packages and their children, so you need not specify it in these
875 contexts. This pragma is useful when writing a reusable component that
876 itself uses Ada 95 features, but which is intended to be usable from
877 either Ada 83 or Ada 95 programs.
880 @unnumberedsec Pragma Ada_05
889 A configuration pragma that establishes Ada 2005 mode for the unit to which
890 it applies, regardless of the mode set by the command line switches.
891 This mode is set automatically for the @code{Ada} and @code{System}
892 packages and their children, so you need not specify it in these
893 contexts. This pragma is useful when writing a reusable component that
894 itself uses Ada 2005 features, but which is intended to be usable from
895 either Ada 83 or Ada 95 programs.
897 @node Pragma Ada_2005
898 @unnumberedsec Pragma Ada_2005
907 This configuration pragma is a synonym for pragma Ada_05 and has the
908 same syntax and effect.
910 @node Pragma Annotate
911 @unnumberedsec Pragma Annotate
916 pragma Annotate (IDENTIFIER @{, ARG@});
918 ARG ::= NAME | EXPRESSION
922 This pragma is used to annotate programs. @var{identifier} identifies
923 the type of annotation. GNAT verifies that it is an identifier, but does
924 not otherwise analyze it. The @var{arg} argument
925 can be either a string literal or an
926 expression. String literals are assumed to be of type
927 @code{Standard.String}. Names of entities are simply analyzed as entity
928 names. All other expressions are analyzed as expressions, and must be
931 The analyzed pragma is retained in the tree, but not otherwise processed
932 by any part of the GNAT compiler. This pragma is intended for use by
933 external tools, including ASIS@.
936 @unnumberedsec Pragma Assert
943 [, string_EXPRESSION]);
947 The effect of this pragma depends on whether the corresponding command
948 line switch is set to activate assertions. The pragma expands into code
949 equivalent to the following:
952 if assertions-enabled then
953 if not boolean_EXPRESSION then
954 System.Assertions.Raise_Assert_Failure
961 The string argument, if given, is the message that will be associated
962 with the exception occurrence if the exception is raised. If no second
963 argument is given, the default message is @samp{@var{file}:@var{nnn}},
964 where @var{file} is the name of the source file containing the assert,
965 and @var{nnn} is the line number of the assert. A pragma is not a
966 statement, so if a statement sequence contains nothing but a pragma
967 assert, then a null statement is required in addition, as in:
972 pragma Assert (K > 3, "Bad value for K");
978 Note that, as with the @code{if} statement to which it is equivalent, the
979 type of the expression is either @code{Standard.Boolean}, or any type derived
980 from this standard type.
982 If assertions are disabled (switch @option{-gnata} not used), then there
983 is no run-time effect (and in particular, any side effects from the
984 expression will not occur at run time). (The expression is still
985 analyzed at compile time, and may cause types to be frozen if they are
986 mentioned here for the first time).
988 If assertions are enabled, then the given expression is tested, and if
989 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
990 which results in the raising of @code{Assert_Failure} with the given message.
992 You should generally avoid side effects in the expression arguments of
993 this pragma, because these side effects will turn on and off with the
994 setting of the assertions mode, resulting in assertions that have an
995 effect on the program. However, the expressions are analyzed for
996 semantic correctness whether or not assertions are enabled, so turning
997 assertions on and off cannot affect the legality of a program.
999 @node Pragma Ast_Entry
1000 @unnumberedsec Pragma Ast_Entry
1005 @smallexample @c ada
1006 pragma AST_Entry (entry_IDENTIFIER);
1010 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1011 argument is the simple name of a single entry; at most one @code{AST_Entry}
1012 pragma is allowed for any given entry. This pragma must be used in
1013 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1014 the entry declaration and in the same task type specification or single task
1015 as the entry to which it applies. This pragma specifies that the given entry
1016 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1017 resulting from an OpenVMS system service call. The pragma does not affect
1018 normal use of the entry. For further details on this pragma, see the
1019 DEC Ada Language Reference Manual, section 9.12a.
1021 @node Pragma C_Pass_By_Copy
1022 @unnumberedsec Pragma C_Pass_By_Copy
1023 @cindex Passing by copy
1024 @findex C_Pass_By_Copy
1027 @smallexample @c ada
1028 pragma C_Pass_By_Copy
1029 ([Max_Size =>] static_integer_EXPRESSION);
1033 Normally the default mechanism for passing C convention records to C
1034 convention subprograms is to pass them by reference, as suggested by RM
1035 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1036 this default, by requiring that record formal parameters be passed by
1037 copy if all of the following conditions are met:
1041 The size of the record type does not exceed the value specified for
1044 The record type has @code{Convention C}.
1046 The formal parameter has this record type, and the subprogram has a
1047 foreign (non-Ada) convention.
1051 If these conditions are met the argument is passed by copy, i.e.@: in a
1052 manner consistent with what C expects if the corresponding formal in the
1053 C prototype is a struct (rather than a pointer to a struct).
1055 You can also pass records by copy by specifying the convention
1056 @code{C_Pass_By_Copy} for the record type, or by using the extended
1057 @code{Import} and @code{Export} pragmas, which allow specification of
1058 passing mechanisms on a parameter by parameter basis.
1061 @unnumberedsec Pragma Check
1063 @cindex Named assertions
1067 @smallexample @c ada
1069 [Name =>] Identifier,
1070 [Check =>] Boolean_EXPRESSION
1071 [, [Message =>] string_EXPRESSION] );
1075 This pragma is similar to the predefined pragma @code{Assert} except that an
1076 extra identifier argument is present. In conjunction with pragma
1077 @code{Check_Policy}, this can be used to define groups of assertions that can
1078 be independently controlled. The identifier @code{Assertion} is special, it
1079 refers to the normal set of pragma @code{Assert} statements. The identifiers
1080 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1081 names, so these three names would normally not be used directly in a pragma
1084 Checks introduced by this pragma are normally deactivated by default. They can
1085 be activated either by the command line option @option{-gnata}, which turns on
1086 all checks, or individually controlled using pragma @code{Check_Policy}.
1088 @node Pragma Check_Name
1089 @unnumberedsec Pragma Check_Name
1090 @cindex Defining check names
1091 @cindex Check names, defining
1095 @smallexample @c ada
1096 pragma Check_Name (check_name_IDENTIFIER);
1100 This is a configuration pragma that defines a new implementation
1101 defined check name (unless IDENTIFIER matches one of the predefined
1102 check names, in which case the pragma has no effect). Check names
1103 are global to a partition, so if two or more configuration pragmas
1104 are present in a partition mentioning the same name, only one new
1105 check name is introduced.
1107 An implementation defined check name introduced with this pragma may
1108 be used in only three contexts: @code{pragma Suppress},
1109 @code{pragma Unsuppress},
1110 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1111 any of these three cases, the check name must be visible. A check
1112 name is visible if it is in the configuration pragmas applying to
1113 the current unit, or if it appears at the start of any unit that
1114 is part of the dependency set of the current unit (e.g., units that
1115 are mentioned in @code{with} clauses).
1117 @node Pragma Check_Policy
1118 @unnumberedsec Pragma Check_Policy
1119 @cindex Controlling assertions
1120 @cindex Assertions, control
1121 @cindex Check pragma control
1122 @cindex Named assertions
1126 @smallexample @c ada
1127 pragma Check_Policy ([Name =>] Identifier, POLICY_IDENTIFIER);
1129 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1133 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1134 except that it controls sets of named assertions introduced using the
1135 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1136 @code{Assertion_Policy}) can be used within a declarative part, in which case
1137 it controls the status to the end of the corresponding construct (in a manner
1138 identical to pragma @code{Suppress)}.
1140 The identifier given as the first argument corresponds to a name used in
1141 associated @code{Check} pragmas. For example, if the pragma:
1143 @smallexample @c ada
1144 pragma Check_Policy (Critical_Error, Off);
1148 is given, then subsequent @code{Check} pragmas whose first argument is also
1149 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1150 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1151 @code{Check_Policy} with this identifier is similar to the normal
1152 @code{Assertion_Policy} pragma except that it can appear within a
1155 The special identifiers @code{Precondition} and @code{Postcondition} control
1156 the status of preconditions and postconditions. If a @code{Precondition} pragma
1157 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1158 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1159 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1162 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1163 to turn on corresponding checks. The default for a set of checks for which no
1164 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1165 @option{-gnata} is given, which turns on all checks by default.
1167 The check policy settings @code{Check} and @code{Ignore} are also recognized
1168 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1169 compatibility with the standard @code{Assertion_Policy} pragma.
1171 @node Pragma Comment
1172 @unnumberedsec Pragma Comment
1177 @smallexample @c ada
1178 pragma Comment (static_string_EXPRESSION);
1182 This is almost identical in effect to pragma @code{Ident}. It allows the
1183 placement of a comment into the object file and hence into the
1184 executable file if the operating system permits such usage. The
1185 difference is that @code{Comment}, unlike @code{Ident}, has
1186 no limitations on placement of the pragma (it can be placed
1187 anywhere in the main source unit), and if more than one pragma
1188 is used, all comments are retained.
1190 @node Pragma Common_Object
1191 @unnumberedsec Pragma Common_Object
1192 @findex Common_Object
1196 @smallexample @c ada
1197 pragma Common_Object (
1198 [Internal =>] LOCAL_NAME
1199 [, [External =>] EXTERNAL_SYMBOL]
1200 [, [Size =>] EXTERNAL_SYMBOL] );
1204 | static_string_EXPRESSION
1208 This pragma enables the shared use of variables stored in overlaid
1209 linker areas corresponding to the use of @code{COMMON}
1210 in Fortran. The single
1211 object @var{LOCAL_NAME} is assigned to the area designated by
1212 the @var{External} argument.
1213 You may define a record to correspond to a series
1214 of fields. The @var{Size} argument
1215 is syntax checked in GNAT, but otherwise ignored.
1217 @code{Common_Object} is not supported on all platforms. If no
1218 support is available, then the code generator will issue a message
1219 indicating that the necessary attribute for implementation of this
1220 pragma is not available.
1222 @node Pragma Compile_Time_Error
1223 @unnumberedsec Pragma Compile_Time_Error
1224 @findex Compile_Time_Error
1228 @smallexample @c ada
1229 pragma Compile_Time_Error
1230 (boolean_EXPRESSION, static_string_EXPRESSION);
1234 This pragma can be used to generate additional compile time
1236 is particularly useful in generics, where errors can be issued for
1237 specific problematic instantiations. The first parameter is a boolean
1238 expression. The pragma is effective only if the value of this expression
1239 is known at compile time, and has the value True. The set of expressions
1240 whose values are known at compile time includes all static boolean
1241 expressions, and also other values which the compiler can determine
1242 at compile time (e.g., the size of a record type set by an explicit
1243 size representation clause, or the value of a variable which was
1244 initialized to a constant and is known not to have been modified).
1245 If these conditions are met, an error message is generated using
1246 the value given as the second argument. This string value may contain
1247 embedded ASCII.LF characters to break the message into multiple lines.
1249 @node Pragma Compile_Time_Warning
1250 @unnumberedsec Pragma Compile_Time_Warning
1251 @findex Compile_Time_Warning
1255 @smallexample @c ada
1256 pragma Compile_Time_Warning
1257 (boolean_EXPRESSION, static_string_EXPRESSION);
1261 Same as pragma Compile_Time_Error, except a warning is issued instead
1262 of an error message. Note that if this pragma is used in a package that
1263 is with'ed by a client, the client will get the warning even though it
1264 is issued by a with'ed package (normally warnings in with'ed units are
1265 suppressed, but this is a special exception to that rule).
1267 One typical use is within a generic where compile time known characteristics
1268 of formal parameters are tested, and warnings given appropriately. Another use
1269 with a first parameter of True is to warn a client about use of a package,
1270 for example that it is not fully implemented.
1272 @node Pragma Complete_Representation
1273 @unnumberedsec Pragma Complete_Representation
1274 @findex Complete_Representation
1278 @smallexample @c ada
1279 pragma Complete_Representation;
1283 This pragma must appear immediately within a record representation
1284 clause. Typical placements are before the first component clause
1285 or after the last component clause. The effect is to give an error
1286 message if any component is missing a component clause. This pragma
1287 may be used to ensure that a record representation clause is
1288 complete, and that this invariant is maintained if fields are
1289 added to the record in the future.
1291 @node Pragma Complex_Representation
1292 @unnumberedsec Pragma Complex_Representation
1293 @findex Complex_Representation
1297 @smallexample @c ada
1298 pragma Complex_Representation
1299 ([Entity =>] LOCAL_NAME);
1303 The @var{Entity} argument must be the name of a record type which has
1304 two fields of the same floating-point type. The effect of this pragma is
1305 to force gcc to use the special internal complex representation form for
1306 this record, which may be more efficient. Note that this may result in
1307 the code for this type not conforming to standard ABI (application
1308 binary interface) requirements for the handling of record types. For
1309 example, in some environments, there is a requirement for passing
1310 records by pointer, and the use of this pragma may result in passing
1311 this type in floating-point registers.
1313 @node Pragma Component_Alignment
1314 @unnumberedsec Pragma Component_Alignment
1315 @cindex Alignments of components
1316 @findex Component_Alignment
1320 @smallexample @c ada
1321 pragma Component_Alignment (
1322 [Form =>] ALIGNMENT_CHOICE
1323 [, [Name =>] type_LOCAL_NAME]);
1325 ALIGNMENT_CHOICE ::=
1333 Specifies the alignment of components in array or record types.
1334 The meaning of the @var{Form} argument is as follows:
1337 @findex Component_Size
1338 @item Component_Size
1339 Aligns scalar components and subcomponents of the array or record type
1340 on boundaries appropriate to their inherent size (naturally
1341 aligned). For example, 1-byte components are aligned on byte boundaries,
1342 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1343 integer components are aligned on 4-byte boundaries and so on. These
1344 alignment rules correspond to the normal rules for C compilers on all
1345 machines except the VAX@.
1347 @findex Component_Size_4
1348 @item Component_Size_4
1349 Naturally aligns components with a size of four or fewer
1350 bytes. Components that are larger than 4 bytes are placed on the next
1353 @findex Storage_Unit
1355 Specifies that array or record components are byte aligned, i.e.@:
1356 aligned on boundaries determined by the value of the constant
1357 @code{System.Storage_Unit}.
1361 Specifies that array or record components are aligned on default
1362 boundaries, appropriate to the underlying hardware or operating system or
1363 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1364 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1365 the @code{Default} choice is the same as @code{Component_Size} (natural
1370 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1371 refer to a local record or array type, and the specified alignment
1372 choice applies to the specified type. The use of
1373 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1374 @code{Component_Alignment} pragma to be ignored. The use of
1375 @code{Component_Alignment} together with a record representation clause
1376 is only effective for fields not specified by the representation clause.
1378 If the @code{Name} parameter is absent, the pragma can be used as either
1379 a configuration pragma, in which case it applies to one or more units in
1380 accordance with the normal rules for configuration pragmas, or it can be
1381 used within a declarative part, in which case it applies to types that
1382 are declared within this declarative part, or within any nested scope
1383 within this declarative part. In either case it specifies the alignment
1384 to be applied to any record or array type which has otherwise standard
1387 If the alignment for a record or array type is not specified (using
1388 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1389 clause), the GNAT uses the default alignment as described previously.
1391 @node Pragma Convention_Identifier
1392 @unnumberedsec Pragma Convention_Identifier
1393 @findex Convention_Identifier
1394 @cindex Conventions, synonyms
1398 @smallexample @c ada
1399 pragma Convention_Identifier (
1400 [Name =>] IDENTIFIER,
1401 [Convention =>] convention_IDENTIFIER);
1405 This pragma provides a mechanism for supplying synonyms for existing
1406 convention identifiers. The @code{Name} identifier can subsequently
1407 be used as a synonym for the given convention in other pragmas (including
1408 for example pragma @code{Import} or another @code{Convention_Identifier}
1409 pragma). As an example of the use of this, suppose you had legacy code
1410 which used Fortran77 as the identifier for Fortran. Then the pragma:
1412 @smallexample @c ada
1413 pragma Convention_Identifier (Fortran77, Fortran);
1417 would allow the use of the convention identifier @code{Fortran77} in
1418 subsequent code, avoiding the need to modify the sources. As another
1419 example, you could use this to parametrize convention requirements
1420 according to systems. Suppose you needed to use @code{Stdcall} on
1421 windows systems, and @code{C} on some other system, then you could
1422 define a convention identifier @code{Library} and use a single
1423 @code{Convention_Identifier} pragma to specify which convention
1424 would be used system-wide.
1426 @node Pragma CPP_Class
1427 @unnumberedsec Pragma CPP_Class
1429 @cindex Interfacing with C++
1433 @smallexample @c ada
1434 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1438 The argument denotes an entity in the current declarative region that is
1439 declared as a tagged record type. It indicates that the type corresponds
1440 to an externally declared C++ class type, and is to be laid out the same
1441 way that C++ would lay out the type.
1443 Types for which @code{CPP_Class} is specified do not have assignment or
1444 equality operators defined (such operations can be imported or declared
1445 as subprograms as required). Initialization is allowed only by constructor
1446 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1447 limited if not explicitly declared as limited or derived from a limited
1448 type, and a warning is issued in that case.
1450 Pragma @code{CPP_Class} is intended primarily for automatic generation
1451 using an automatic binding generator tool.
1452 See @ref{Interfacing to C++} for related information.
1454 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1455 for backward compatibility but its functionality is available
1456 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1458 @node Pragma CPP_Constructor
1459 @unnumberedsec Pragma CPP_Constructor
1460 @cindex Interfacing with C++
1461 @findex CPP_Constructor
1465 @smallexample @c ada
1466 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1467 [, [External_Name =>] static_string_EXPRESSION ]
1468 [, [Link_Name =>] static_string_EXPRESSION ]);
1472 This pragma identifies an imported function (imported in the usual way
1473 with pragma @code{Import}) as corresponding to a C++ constructor. If
1474 @code{External_Name} and @code{Link_Name} are not specified then the
1475 @code{Entity} argument is a name that must have been previously mentioned
1476 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1477 must be of one of the following forms:
1481 @code{function @var{Fname} return @var{T}'Class}
1484 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1488 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1490 The first form is the default constructor, used when an object of type
1491 @var{T} is created on the Ada side with no explicit constructor. Other
1492 constructors (including the copy constructor, which is simply a special
1493 case of the second form in which the one and only argument is of type
1494 @var{T}), can only appear in two contexts:
1498 On the right side of an initialization of an object of type @var{T}.
1500 In an extension aggregate for an object of a type derived from @var{T}.
1504 Although the constructor is described as a function that returns a value
1505 on the Ada side, it is typically a procedure with an extra implicit
1506 argument (the object being initialized) at the implementation
1507 level. GNAT issues the appropriate call, whatever it is, to get the
1508 object properly initialized.
1510 In the case of derived objects, you may use one of two possible forms
1511 for declaring and creating an object:
1514 @item @code{New_Object : Derived_T}
1515 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1519 In the first case the default constructor is called and extension fields
1520 if any are initialized according to the default initialization
1521 expressions in the Ada declaration. In the second case, the given
1522 constructor is called and the extension aggregate indicates the explicit
1523 values of the extension fields.
1525 If no constructors are imported, it is impossible to create any objects
1526 on the Ada side. If no default constructor is imported, only the
1527 initialization forms using an explicit call to a constructor are
1530 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1531 using an automatic binding generator tool.
1532 See @ref{Interfacing to C++} for more related information.
1534 @node Pragma CPP_Virtual
1535 @unnumberedsec Pragma CPP_Virtual
1536 @cindex Interfacing to C++
1539 This pragma is now obsolete has has no effect because GNAT generates
1540 the same object layout than the G++ compiler.
1542 See @ref{Interfacing to C++} for related information.
1544 @node Pragma CPP_Vtable
1545 @unnumberedsec Pragma CPP_Vtable
1546 @cindex Interfacing with C++
1549 This pragma is now obsolete has has no effect because GNAT generates
1550 the same object layout than the G++ compiler.
1552 See @ref{Interfacing to C++} for related information.
1555 @unnumberedsec Pragma Debug
1560 @smallexample @c ada
1561 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1563 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1565 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1569 The procedure call argument has the syntactic form of an expression, meeting
1570 the syntactic requirements for pragmas.
1572 If debug pragmas are not enabled or if the condition is present and evaluates
1573 to False, this pragma has no effect. If debug pragmas are enabled, the
1574 semantics of the pragma is exactly equivalent to the procedure call statement
1575 corresponding to the argument with a terminating semicolon. Pragmas are
1576 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1577 intersperse calls to debug procedures in the middle of declarations. Debug
1578 pragmas can be enabled either by use of the command line switch @option{-gnata}
1579 or by use of the configuration pragma @code{Debug_Policy}.
1581 @node Pragma Debug_Policy
1582 @unnumberedsec Pragma Debug_Policy
1583 @findex Debug_Policy
1587 @smallexample @c ada
1588 pragma Debug_Policy (CHECK | IGNORE);
1592 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1593 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1594 This pragma overrides the effect of the @option{-gnata} switch on the
1597 @node Pragma Detect_Blocking
1598 @unnumberedsec Pragma Detect_Blocking
1599 @findex Detect_Blocking
1603 @smallexample @c ada
1604 pragma Detect_Blocking;
1608 This is a configuration pragma that forces the detection of potentially
1609 blocking operations within a protected operation, and to raise Program_Error
1612 @node Pragma Elaboration_Checks
1613 @unnumberedsec Pragma Elaboration_Checks
1614 @cindex Elaboration control
1615 @findex Elaboration_Checks
1619 @smallexample @c ada
1620 pragma Elaboration_Checks (Dynamic | Static);
1624 This is a configuration pragma that provides control over the
1625 elaboration model used by the compilation affected by the
1626 pragma. If the parameter is @code{Dynamic},
1627 then the dynamic elaboration
1628 model described in the Ada Reference Manual is used, as though
1629 the @option{-gnatE} switch had been specified on the command
1630 line. If the parameter is @code{Static}, then the default GNAT static
1631 model is used. This configuration pragma overrides the setting
1632 of the command line. For full details on the elaboration models
1633 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1634 gnat_ugn, @value{EDITION} User's Guide}.
1636 @node Pragma Eliminate
1637 @unnumberedsec Pragma Eliminate
1638 @cindex Elimination of unused subprograms
1643 @smallexample @c ada
1645 [Unit_Name =>] IDENTIFIER |
1646 SELECTED_COMPONENT);
1649 [Unit_Name =>] IDENTIFIER |
1651 [Entity =>] IDENTIFIER |
1652 SELECTED_COMPONENT |
1654 [,OVERLOADING_RESOLUTION]);
1656 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1659 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1662 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1664 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1665 Result_Type => result_SUBTYPE_NAME]
1667 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1668 SUBTYPE_NAME ::= STRING_VALUE
1670 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1671 SOURCE_TRACE ::= STRING_VALUE
1673 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1677 This pragma indicates that the given entity is not used outside the
1678 compilation unit it is defined in. The entity must be an explicitly declared
1679 subprogram; this includes generic subprogram instances and
1680 subprograms declared in generic package instances.
1682 If the entity to be eliminated is a library level subprogram, then
1683 the first form of pragma @code{Eliminate} is used with only a single argument.
1684 In this form, the @code{Unit_Name} argument specifies the name of the
1685 library level unit to be eliminated.
1687 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1688 are required. If item is an entity of a library package, then the first
1689 argument specifies the unit name, and the second argument specifies
1690 the particular entity. If the second argument is in string form, it must
1691 correspond to the internal manner in which GNAT stores entity names (see
1692 compilation unit Namet in the compiler sources for details).
1694 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1695 to distinguish between overloaded subprograms. If a pragma does not contain
1696 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1697 subprograms denoted by the first two parameters.
1699 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1700 to be eliminated in a manner similar to that used for the extended
1701 @code{Import} and @code{Export} pragmas, except that the subtype names are
1702 always given as strings. At the moment, this form of distinguishing
1703 overloaded subprograms is implemented only partially, so we do not recommend
1704 using it for practical subprogram elimination.
1706 Note that in case of a parameterless procedure its profile is represented
1707 as @code{Parameter_Types => ("")}
1709 Alternatively, the @code{Source_Location} parameter is used to specify
1710 which overloaded alternative is to be eliminated by pointing to the
1711 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1712 source text. The string literal (or concatenation of string literals)
1713 given as SOURCE_TRACE must have the following format:
1715 @smallexample @c ada
1716 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1721 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1722 FILE_NAME ::= STRING_LITERAL
1723 LINE_NUMBER ::= DIGIT @{DIGIT@}
1726 SOURCE_TRACE should be the short name of the source file (with no directory
1727 information), and LINE_NUMBER is supposed to point to the line where the
1728 defining name of the subprogram is located.
1730 For the subprograms that are not a part of generic instantiations, only one
1731 SOURCE_LOCATION is used. If a subprogram is declared in a package
1732 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1733 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1734 second one denotes the declaration of the corresponding subprogram in the
1735 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1736 in case of nested instantiations.
1738 The effect of the pragma is to allow the compiler to eliminate
1739 the code or data associated with the named entity. Any reference to
1740 an eliminated entity outside the compilation unit it is defined in,
1741 causes a compile time or link time error.
1743 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1744 in a system independent manner, with unused entities eliminated, without
1745 the requirement of modifying the source text. Normally the required set
1746 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1747 tool. Elimination of unused entities local to a compilation unit is
1748 automatic, without requiring the use of pragma @code{Eliminate}.
1750 Note that the reason this pragma takes string literals where names might
1751 be expected is that a pragma @code{Eliminate} can appear in a context where the
1752 relevant names are not visible.
1754 Note that any change in the source files that includes removing, splitting of
1755 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1758 It is legal to use pragma Eliminate where the referenced entity is a
1759 dispatching operation, but it is not clear what this would mean, since
1760 in general the call does not know which entity is actually being called.
1761 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1763 @node Pragma Export_Exception
1764 @unnumberedsec Pragma Export_Exception
1766 @findex Export_Exception
1770 @smallexample @c ada
1771 pragma Export_Exception (
1772 [Internal =>] LOCAL_NAME
1773 [, [External =>] EXTERNAL_SYMBOL]
1774 [, [Form =>] Ada | VMS]
1775 [, [Code =>] static_integer_EXPRESSION]);
1779 | static_string_EXPRESSION
1783 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1784 causes the specified exception to be propagated outside of the Ada program,
1785 so that it can be handled by programs written in other OpenVMS languages.
1786 This pragma establishes an external name for an Ada exception and makes the
1787 name available to the OpenVMS Linker as a global symbol. For further details
1788 on this pragma, see the
1789 DEC Ada Language Reference Manual, section 13.9a3.2.
1791 @node Pragma Export_Function
1792 @unnumberedsec Pragma Export_Function
1793 @cindex Argument passing mechanisms
1794 @findex Export_Function
1799 @smallexample @c ada
1800 pragma Export_Function (
1801 [Internal =>] LOCAL_NAME
1802 [, [External =>] EXTERNAL_SYMBOL]
1803 [, [Parameter_Types =>] PARAMETER_TYPES]
1804 [, [Result_Type =>] result_SUBTYPE_MARK]
1805 [, [Mechanism =>] MECHANISM]
1806 [, [Result_Mechanism =>] MECHANISM_NAME]);
1810 | static_string_EXPRESSION
1815 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1819 | subtype_Name ' Access
1823 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1825 MECHANISM_ASSOCIATION ::=
1826 [formal_parameter_NAME =>] MECHANISM_NAME
1831 | Descriptor [([Class =>] CLASS_NAME)]
1833 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1837 Use this pragma to make a function externally callable and optionally
1838 provide information on mechanisms to be used for passing parameter and
1839 result values. We recommend, for the purposes of improving portability,
1840 this pragma always be used in conjunction with a separate pragma
1841 @code{Export}, which must precede the pragma @code{Export_Function}.
1842 GNAT does not require a separate pragma @code{Export}, but if none is
1843 present, @code{Convention Ada} is assumed, which is usually
1844 not what is wanted, so it is usually appropriate to use this
1845 pragma in conjunction with a @code{Export} or @code{Convention}
1846 pragma that specifies the desired foreign convention.
1847 Pragma @code{Export_Function}
1848 (and @code{Export}, if present) must appear in the same declarative
1849 region as the function to which they apply.
1851 @var{internal_name} must uniquely designate the function to which the
1852 pragma applies. If more than one function name exists of this name in
1853 the declarative part you must use the @code{Parameter_Types} and
1854 @code{Result_Type} parameters is mandatory to achieve the required
1855 unique designation. @var{subtype_mark}s in these parameters must
1856 exactly match the subtypes in the corresponding function specification,
1857 using positional notation to match parameters with subtype marks.
1858 The form with an @code{'Access} attribute can be used to match an
1859 anonymous access parameter.
1862 @cindex Passing by descriptor
1863 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1865 @cindex Suppressing external name
1866 Special treatment is given if the EXTERNAL is an explicit null
1867 string or a static string expressions that evaluates to the null
1868 string. In this case, no external name is generated. This form
1869 still allows the specification of parameter mechanisms.
1871 @node Pragma Export_Object
1872 @unnumberedsec Pragma Export_Object
1873 @findex Export_Object
1877 @smallexample @c ada
1878 pragma Export_Object
1879 [Internal =>] LOCAL_NAME
1880 [, [External =>] EXTERNAL_SYMBOL]
1881 [, [Size =>] EXTERNAL_SYMBOL]
1885 | static_string_EXPRESSION
1889 This pragma designates an object as exported, and apart from the
1890 extended rules for external symbols, is identical in effect to the use of
1891 the normal @code{Export} pragma applied to an object. You may use a
1892 separate Export pragma (and you probably should from the point of view
1893 of portability), but it is not required. @var{Size} is syntax checked,
1894 but otherwise ignored by GNAT@.
1896 @node Pragma Export_Procedure
1897 @unnumberedsec Pragma Export_Procedure
1898 @findex Export_Procedure
1902 @smallexample @c ada
1903 pragma Export_Procedure (
1904 [Internal =>] LOCAL_NAME
1905 [, [External =>] EXTERNAL_SYMBOL]
1906 [, [Parameter_Types =>] PARAMETER_TYPES]
1907 [, [Mechanism =>] MECHANISM]);
1911 | static_string_EXPRESSION
1916 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1920 | subtype_Name ' Access
1924 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1926 MECHANISM_ASSOCIATION ::=
1927 [formal_parameter_NAME =>] MECHANISM_NAME
1932 | Descriptor [([Class =>] CLASS_NAME)]
1934 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1938 This pragma is identical to @code{Export_Function} except that it
1939 applies to a procedure rather than a function and the parameters
1940 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1941 GNAT does not require a separate pragma @code{Export}, but if none is
1942 present, @code{Convention Ada} is assumed, which is usually
1943 not what is wanted, so it is usually appropriate to use this
1944 pragma in conjunction with a @code{Export} or @code{Convention}
1945 pragma that specifies the desired foreign convention.
1948 @cindex Passing by descriptor
1949 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1951 @cindex Suppressing external name
1952 Special treatment is given if the EXTERNAL is an explicit null
1953 string or a static string expressions that evaluates to the null
1954 string. In this case, no external name is generated. This form
1955 still allows the specification of parameter mechanisms.
1957 @node Pragma Export_Value
1958 @unnumberedsec Pragma Export_Value
1959 @findex Export_Value
1963 @smallexample @c ada
1964 pragma Export_Value (
1965 [Value =>] static_integer_EXPRESSION,
1966 [Link_Name =>] static_string_EXPRESSION);
1970 This pragma serves to export a static integer value for external use.
1971 The first argument specifies the value to be exported. The Link_Name
1972 argument specifies the symbolic name to be associated with the integer
1973 value. This pragma is useful for defining a named static value in Ada
1974 that can be referenced in assembly language units to be linked with
1975 the application. This pragma is currently supported only for the
1976 AAMP target and is ignored for other targets.
1978 @node Pragma Export_Valued_Procedure
1979 @unnumberedsec Pragma Export_Valued_Procedure
1980 @findex Export_Valued_Procedure
1984 @smallexample @c ada
1985 pragma Export_Valued_Procedure (
1986 [Internal =>] LOCAL_NAME
1987 [, [External =>] EXTERNAL_SYMBOL]
1988 [, [Parameter_Types =>] PARAMETER_TYPES]
1989 [, [Mechanism =>] MECHANISM]);
1993 | static_string_EXPRESSION
1998 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2002 | subtype_Name ' Access
2006 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2008 MECHANISM_ASSOCIATION ::=
2009 [formal_parameter_NAME =>] MECHANISM_NAME
2014 | Descriptor [([Class =>] CLASS_NAME)]
2016 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2020 This pragma is identical to @code{Export_Procedure} except that the
2021 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2022 mode @code{OUT}, and externally the subprogram is treated as a function
2023 with this parameter as the result of the function. GNAT provides for
2024 this capability to allow the use of @code{OUT} and @code{IN OUT}
2025 parameters in interfacing to external functions (which are not permitted
2027 GNAT does not require a separate pragma @code{Export}, but if none is
2028 present, @code{Convention Ada} is assumed, which is almost certainly
2029 not what is wanted since the whole point of this pragma is to interface
2030 with foreign language functions, so it is usually appropriate to use this
2031 pragma in conjunction with a @code{Export} or @code{Convention}
2032 pragma that specifies the desired foreign convention.
2035 @cindex Passing by descriptor
2036 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2038 @cindex Suppressing external name
2039 Special treatment is given if the EXTERNAL is an explicit null
2040 string or a static string expressions that evaluates to the null
2041 string. In this case, no external name is generated. This form
2042 still allows the specification of parameter mechanisms.
2044 @node Pragma Extend_System
2045 @unnumberedsec Pragma Extend_System
2046 @cindex @code{system}, extending
2048 @findex Extend_System
2052 @smallexample @c ada
2053 pragma Extend_System ([Name =>] IDENTIFIER);
2057 This pragma is used to provide backwards compatibility with other
2058 implementations that extend the facilities of package @code{System}. In
2059 GNAT, @code{System} contains only the definitions that are present in
2060 the Ada RM@. However, other implementations, notably the DEC Ada 83
2061 implementation, provide many extensions to package @code{System}.
2063 For each such implementation accommodated by this pragma, GNAT provides a
2064 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2065 implementation, which provides the required additional definitions. You
2066 can use this package in two ways. You can @code{with} it in the normal
2067 way and access entities either by selection or using a @code{use}
2068 clause. In this case no special processing is required.
2070 However, if existing code contains references such as
2071 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2072 definitions provided in package @code{System}, you may use this pragma
2073 to extend visibility in @code{System} in a non-standard way that
2074 provides greater compatibility with the existing code. Pragma
2075 @code{Extend_System} is a configuration pragma whose single argument is
2076 the name of the package containing the extended definition
2077 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2078 control of this pragma will be processed using special visibility
2079 processing that looks in package @code{System.Aux_@var{xxx}} where
2080 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2081 package @code{System}, but not found in package @code{System}.
2083 You can use this pragma either to access a predefined @code{System}
2084 extension supplied with the compiler, for example @code{Aux_DEC} or
2085 you can construct your own extension unit following the above
2086 definition. Note that such a package is a child of @code{System}
2087 and thus is considered part of the implementation. To compile
2088 it you will have to use the appropriate switch for compiling
2089 system units. @xref{Top, @value{EDITION} User's Guide, About This
2090 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2092 @node Pragma External
2093 @unnumberedsec Pragma External
2098 @smallexample @c ada
2100 [ Convention =>] convention_IDENTIFIER,
2101 [ Entity =>] LOCAL_NAME
2102 [, [External_Name =>] static_string_EXPRESSION ]
2103 [, [Link_Name =>] static_string_EXPRESSION ]);
2107 This pragma is identical in syntax and semantics to pragma
2108 @code{Export} as defined in the Ada Reference Manual. It is
2109 provided for compatibility with some Ada 83 compilers that
2110 used this pragma for exactly the same purposes as pragma
2111 @code{Export} before the latter was standardized.
2113 @node Pragma External_Name_Casing
2114 @unnumberedsec Pragma External_Name_Casing
2115 @cindex Dec Ada 83 casing compatibility
2116 @cindex External Names, casing
2117 @cindex Casing of External names
2118 @findex External_Name_Casing
2122 @smallexample @c ada
2123 pragma External_Name_Casing (
2124 Uppercase | Lowercase
2125 [, Uppercase | Lowercase | As_Is]);
2129 This pragma provides control over the casing of external names associated
2130 with Import and Export pragmas. There are two cases to consider:
2133 @item Implicit external names
2134 Implicit external names are derived from identifiers. The most common case
2135 arises when a standard Ada Import or Export pragma is used with only two
2138 @smallexample @c ada
2139 pragma Import (C, C_Routine);
2143 Since Ada is a case-insensitive language, the spelling of the identifier in
2144 the Ada source program does not provide any information on the desired
2145 casing of the external name, and so a convention is needed. In GNAT the
2146 default treatment is that such names are converted to all lower case
2147 letters. This corresponds to the normal C style in many environments.
2148 The first argument of pragma @code{External_Name_Casing} can be used to
2149 control this treatment. If @code{Uppercase} is specified, then the name
2150 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2151 then the normal default of all lower case letters will be used.
2153 This same implicit treatment is also used in the case of extended DEC Ada 83
2154 compatible Import and Export pragmas where an external name is explicitly
2155 specified using an identifier rather than a string.
2157 @item Explicit external names
2158 Explicit external names are given as string literals. The most common case
2159 arises when a standard Ada Import or Export pragma is used with three
2162 @smallexample @c ada
2163 pragma Import (C, C_Routine, "C_routine");
2167 In this case, the string literal normally provides the exact casing required
2168 for the external name. The second argument of pragma
2169 @code{External_Name_Casing} may be used to modify this behavior.
2170 If @code{Uppercase} is specified, then the name
2171 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2172 then the name will be forced to all lowercase letters. A specification of
2173 @code{As_Is} provides the normal default behavior in which the casing is
2174 taken from the string provided.
2178 This pragma may appear anywhere that a pragma is valid. In particular, it
2179 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2180 case it applies to all subsequent compilations, or it can be used as a program
2181 unit pragma, in which case it only applies to the current unit, or it can
2182 be used more locally to control individual Import/Export pragmas.
2184 It is primarily intended for use with OpenVMS systems, where many
2185 compilers convert all symbols to upper case by default. For interfacing to
2186 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2189 @smallexample @c ada
2190 pragma External_Name_Casing (Uppercase, Uppercase);
2194 to enforce the upper casing of all external symbols.
2196 @node Pragma Fast_Math
2197 @unnumberedsec Pragma Fast_Math
2202 @smallexample @c ada
2207 This is a configuration pragma which activates a mode in which speed is
2208 considered more important for floating-point operations than absolutely
2209 accurate adherence to the requirements of the standard. Currently the
2210 following operations are affected:
2213 @item Complex Multiplication
2214 The normal simple formula for complex multiplication can result in intermediate
2215 overflows for numbers near the end of the range. The Ada standard requires that
2216 this situation be detected and corrected by scaling, but in Fast_Math mode such
2217 cases will simply result in overflow. Note that to take advantage of this you
2218 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2219 under control of the pragma, rather than use the preinstantiated versions.
2222 @node Pragma Favor_Top_Level
2223 @unnumberedsec Pragma Favor_Top_Level
2224 @findex Favor_Top_Level
2228 @smallexample @c ada
2229 pragma Favor_Top_Level (type_NAME);
2233 The named type must be an access-to-subprogram type. This pragma is an
2234 efficiency hint to the compiler, regarding the use of 'Access or
2235 'Unrestricted_Access on nested (non-library-level) subprograms. The
2236 pragma means that nested subprograms are not used with this type, or
2237 are rare, so that the generated code should be efficient in the
2238 top-level case. When this pragma is used, dynamically generated
2239 trampolines may be used on some targets for nested subprograms.
2240 See also the No_Implicit_Dynamic_Code restriction.
2242 @node Pragma Finalize_Storage_Only
2243 @unnumberedsec Pragma Finalize_Storage_Only
2244 @findex Finalize_Storage_Only
2248 @smallexample @c ada
2249 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2253 This pragma allows the compiler not to emit a Finalize call for objects
2254 defined at the library level. This is mostly useful for types where
2255 finalization is only used to deal with storage reclamation since in most
2256 environments it is not necessary to reclaim memory just before terminating
2257 execution, hence the name.
2259 @node Pragma Float_Representation
2260 @unnumberedsec Pragma Float_Representation
2262 @findex Float_Representation
2266 @smallexample @c ada
2267 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2269 FLOAT_REP ::= VAX_Float | IEEE_Float
2273 In the one argument form, this pragma is a configuration pragma which
2274 allows control over the internal representation chosen for the predefined
2275 floating point types declared in the packages @code{Standard} and
2276 @code{System}. On all systems other than OpenVMS, the argument must
2277 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2278 argument may be @code{VAX_Float} to specify the use of the VAX float
2279 format for the floating-point types in Standard. This requires that
2280 the standard runtime libraries be recompiled. @xref{The GNAT Run-Time
2281 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2282 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2284 The two argument form specifies the representation to be used for
2285 the specified floating-point type. On all systems other than OpenVMS,
2287 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2288 argument may be @code{VAX_Float} to specify the use of the VAX float
2293 For digits values up to 6, F float format will be used.
2295 For digits values from 7 to 9, G float format will be used.
2297 For digits values from 10 to 15, F float format will be used.
2299 Digits values above 15 are not allowed.
2303 @unnumberedsec Pragma Ident
2308 @smallexample @c ada
2309 pragma Ident (static_string_EXPRESSION);
2313 This pragma provides a string identification in the generated object file,
2314 if the system supports the concept of this kind of identification string.
2315 This pragma is allowed only in the outermost declarative part or
2316 declarative items of a compilation unit. If more than one @code{Ident}
2317 pragma is given, only the last one processed is effective.
2319 On OpenVMS systems, the effect of the pragma is identical to the effect of
2320 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2321 maximum allowed length is 31 characters, so if it is important to
2322 maintain compatibility with this compiler, you should obey this length
2325 @node Pragma Implemented_By_Entry
2326 @unnumberedsec Pragma Implemented_By_Entry
2327 @findex Implemented_By_Entry
2331 @smallexample @c ada
2332 pragma Implemented_By_Entry (LOCAL_NAME);
2336 This is a representation pragma which applies to protected, synchronized and
2337 task interface primitives. If the pragma is applied to primitive operation Op
2338 of interface Iface, it is illegal to override Op in a type that implements
2339 Iface, with anything other than an entry.
2341 @smallexample @c ada
2342 type Iface is protected interface;
2343 procedure Do_Something (Object : in out Iface) is abstract;
2344 pragma Implemented_By_Entry (Do_Something);
2346 protected type P is new Iface with
2347 procedure Do_Something; -- Illegal
2350 task type T is new Iface with
2351 entry Do_Something; -- Legal
2356 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2357 is intended to be used in conjunction with dispatching requeue statements as
2358 described in AI05-0030. Should the ARG decide on an official name and syntax,
2359 this pragma will become language-defined rather than GNAT-specific.
2361 @node Pragma Implicit_Packing
2362 @unnumberedsec Pragma Implicit_Packing
2363 @findex Implicit_Packing
2367 @smallexample @c ada
2368 pragma Implicit_Packing;
2372 This is a configuration pragma that requests implicit packing for packed
2373 arrays for which a size clause is given but no explicit pragma Pack or
2374 specification of Component_Size is present. Consider this example:
2376 @smallexample @c ada
2377 type R is array (0 .. 7) of Boolean;
2382 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2383 does not change the layout of a composite object. So the Size clause in the
2384 above example is normally rejected, since the default layout of the array uses
2385 8-bit components, and thus the array requires a minimum of 64 bits.
2387 If this declaration is compiled in a region of code covered by an occurrence
2388 of the configuration pragma Implicit_Packing, then the Size clause in this
2389 and similar examples will cause implicit packing and thus be accepted. For
2390 this implicit packing to occur, the type in question must be an array of small
2391 components whose size is known at compile time, and the Size clause must
2392 specify the exact size that corresponds to the length of the array multiplied
2393 by the size in bits of the component type.
2394 @cindex Array packing
2396 @node Pragma Import_Exception
2397 @unnumberedsec Pragma Import_Exception
2399 @findex Import_Exception
2403 @smallexample @c ada
2404 pragma Import_Exception (
2405 [Internal =>] LOCAL_NAME
2406 [, [External =>] EXTERNAL_SYMBOL]
2407 [, [Form =>] Ada | VMS]
2408 [, [Code =>] static_integer_EXPRESSION]);
2412 | static_string_EXPRESSION
2416 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2417 It allows OpenVMS conditions (for example, from OpenVMS system services or
2418 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2419 The pragma specifies that the exception associated with an exception
2420 declaration in an Ada program be defined externally (in non-Ada code).
2421 For further details on this pragma, see the
2422 DEC Ada Language Reference Manual, section 13.9a.3.1.
2424 @node Pragma Import_Function
2425 @unnumberedsec Pragma Import_Function
2426 @findex Import_Function
2430 @smallexample @c ada
2431 pragma Import_Function (
2432 [Internal =>] LOCAL_NAME,
2433 [, [External =>] EXTERNAL_SYMBOL]
2434 [, [Parameter_Types =>] PARAMETER_TYPES]
2435 [, [Result_Type =>] SUBTYPE_MARK]
2436 [, [Mechanism =>] MECHANISM]
2437 [, [Result_Mechanism =>] MECHANISM_NAME]
2438 [, [First_Optional_Parameter =>] IDENTIFIER]);
2442 | static_string_EXPRESSION
2446 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2450 | subtype_Name ' Access
2454 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2456 MECHANISM_ASSOCIATION ::=
2457 [formal_parameter_NAME =>] MECHANISM_NAME
2462 | Descriptor [([Class =>] CLASS_NAME)]
2464 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2468 This pragma is used in conjunction with a pragma @code{Import} to
2469 specify additional information for an imported function. The pragma
2470 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2471 @code{Import_Function} pragma and both must appear in the same
2472 declarative part as the function specification.
2474 The @var{Internal} argument must uniquely designate
2475 the function to which the
2476 pragma applies. If more than one function name exists of this name in
2477 the declarative part you must use the @code{Parameter_Types} and
2478 @var{Result_Type} parameters to achieve the required unique
2479 designation. Subtype marks in these parameters must exactly match the
2480 subtypes in the corresponding function specification, using positional
2481 notation to match parameters with subtype marks.
2482 The form with an @code{'Access} attribute can be used to match an
2483 anonymous access parameter.
2485 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2486 parameters to specify passing mechanisms for the
2487 parameters and result. If you specify a single mechanism name, it
2488 applies to all parameters. Otherwise you may specify a mechanism on a
2489 parameter by parameter basis using either positional or named
2490 notation. If the mechanism is not specified, the default mechanism
2494 @cindex Passing by descriptor
2495 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2497 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2498 It specifies that the designated parameter and all following parameters
2499 are optional, meaning that they are not passed at the generated code
2500 level (this is distinct from the notion of optional parameters in Ada
2501 where the parameters are passed anyway with the designated optional
2502 parameters). All optional parameters must be of mode @code{IN} and have
2503 default parameter values that are either known at compile time
2504 expressions, or uses of the @code{'Null_Parameter} attribute.
2506 @node Pragma Import_Object
2507 @unnumberedsec Pragma Import_Object
2508 @findex Import_Object
2512 @smallexample @c ada
2513 pragma Import_Object
2514 [Internal =>] LOCAL_NAME
2515 [, [External =>] EXTERNAL_SYMBOL]
2516 [, [Size =>] EXTERNAL_SYMBOL]);
2520 | static_string_EXPRESSION
2524 This pragma designates an object as imported, and apart from the
2525 extended rules for external symbols, is identical in effect to the use of
2526 the normal @code{Import} pragma applied to an object. Unlike the
2527 subprogram case, you need not use a separate @code{Import} pragma,
2528 although you may do so (and probably should do so from a portability
2529 point of view). @var{size} is syntax checked, but otherwise ignored by
2532 @node Pragma Import_Procedure
2533 @unnumberedsec Pragma Import_Procedure
2534 @findex Import_Procedure
2538 @smallexample @c ada
2539 pragma Import_Procedure (
2540 [Internal =>] LOCAL_NAME
2541 [, [External =>] EXTERNAL_SYMBOL]
2542 [, [Parameter_Types =>] PARAMETER_TYPES]
2543 [, [Mechanism =>] MECHANISM]
2544 [, [First_Optional_Parameter =>] IDENTIFIER]);
2548 | static_string_EXPRESSION
2552 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2556 | subtype_Name ' Access
2560 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2562 MECHANISM_ASSOCIATION ::=
2563 [formal_parameter_NAME =>] MECHANISM_NAME
2568 | Descriptor [([Class =>] CLASS_NAME)]
2570 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2574 This pragma is identical to @code{Import_Function} except that it
2575 applies to a procedure rather than a function and the parameters
2576 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2578 @node Pragma Import_Valued_Procedure
2579 @unnumberedsec Pragma Import_Valued_Procedure
2580 @findex Import_Valued_Procedure
2584 @smallexample @c ada
2585 pragma Import_Valued_Procedure (
2586 [Internal =>] LOCAL_NAME
2587 [, [External =>] EXTERNAL_SYMBOL]
2588 [, [Parameter_Types =>] PARAMETER_TYPES]
2589 [, [Mechanism =>] MECHANISM]
2590 [, [First_Optional_Parameter =>] IDENTIFIER]);
2594 | static_string_EXPRESSION
2598 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2602 | subtype_Name ' Access
2606 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2608 MECHANISM_ASSOCIATION ::=
2609 [formal_parameter_NAME =>] MECHANISM_NAME
2614 | Descriptor [([Class =>] CLASS_NAME)]
2616 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2620 This pragma is identical to @code{Import_Procedure} except that the
2621 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2622 mode @code{OUT}, and externally the subprogram is treated as a function
2623 with this parameter as the result of the function. The purpose of this
2624 capability is to allow the use of @code{OUT} and @code{IN OUT}
2625 parameters in interfacing to external functions (which are not permitted
2626 in Ada functions). You may optionally use the @code{Mechanism}
2627 parameters to specify passing mechanisms for the parameters.
2628 If you specify a single mechanism name, it applies to all parameters.
2629 Otherwise you may specify a mechanism on a parameter by parameter
2630 basis using either positional or named notation. If the mechanism is not
2631 specified, the default mechanism is used.
2633 Note that it is important to use this pragma in conjunction with a separate
2634 pragma Import that specifies the desired convention, since otherwise the
2635 default convention is Ada, which is almost certainly not what is required.
2637 @node Pragma Initialize_Scalars
2638 @unnumberedsec Pragma Initialize_Scalars
2639 @findex Initialize_Scalars
2640 @cindex debugging with Initialize_Scalars
2644 @smallexample @c ada
2645 pragma Initialize_Scalars;
2649 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2650 two important differences. First, there is no requirement for the pragma
2651 to be used uniformly in all units of a partition, in particular, it is fine
2652 to use this just for some or all of the application units of a partition,
2653 without needing to recompile the run-time library.
2655 In the case where some units are compiled with the pragma, and some without,
2656 then a declaration of a variable where the type is defined in package
2657 Standard or is locally declared will always be subject to initialization,
2658 as will any declaration of a scalar variable. For composite variables,
2659 whether the variable is initialized may also depend on whether the package
2660 in which the type of the variable is declared is compiled with the pragma.
2662 The other important difference is that you can control the value used
2663 for initializing scalar objects. At bind time, you can select several
2664 options for initialization. You can
2665 initialize with invalid values (similar to Normalize_Scalars, though for
2666 Initialize_Scalars it is not always possible to determine the invalid
2667 values in complex cases like signed component fields with non-standard
2668 sizes). You can also initialize with high or
2669 low values, or with a specified bit pattern. See the users guide for binder
2670 options for specifying these cases.
2672 This means that you can compile a program, and then without having to
2673 recompile the program, you can run it with different values being used
2674 for initializing otherwise uninitialized values, to test if your program
2675 behavior depends on the choice. Of course the behavior should not change,
2676 and if it does, then most likely you have an erroneous reference to an
2677 uninitialized value.
2679 It is even possible to change the value at execution time eliminating even
2680 the need to rebind with a different switch using an environment variable.
2681 See the GNAT users guide for details.
2683 Note that pragma @code{Initialize_Scalars} is particularly useful in
2684 conjunction with the enhanced validity checking that is now provided
2685 in GNAT, which checks for invalid values under more conditions.
2686 Using this feature (see description of the @option{-gnatV} flag in the
2687 users guide) in conjunction with pragma @code{Initialize_Scalars}
2688 provides a powerful new tool to assist in the detection of problems
2689 caused by uninitialized variables.
2691 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2692 effect on the generated code. This may cause your code to be
2693 substantially larger. It may also cause an increase in the amount
2694 of stack required, so it is probably a good idea to turn on stack
2695 checking (see description of stack checking in the GNAT users guide)
2696 when using this pragma.
2698 @node Pragma Inline_Always
2699 @unnumberedsec Pragma Inline_Always
2700 @findex Inline_Always
2704 @smallexample @c ada
2705 pragma Inline_Always (NAME [, NAME]);
2709 Similar to pragma @code{Inline} except that inlining is not subject to
2710 the use of option @option{-gnatn} and the inlining happens regardless of
2711 whether this option is used.
2713 @node Pragma Inline_Generic
2714 @unnumberedsec Pragma Inline_Generic
2715 @findex Inline_Generic
2719 @smallexample @c ada
2720 pragma Inline_Generic (generic_package_NAME);
2724 This is implemented for compatibility with DEC Ada 83 and is recognized,
2725 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2726 by default when using GNAT@.
2728 @node Pragma Interface
2729 @unnumberedsec Pragma Interface
2734 @smallexample @c ada
2736 [Convention =>] convention_identifier,
2737 [Entity =>] local_NAME
2738 [, [External_Name =>] static_string_expression]
2739 [, [Link_Name =>] static_string_expression]);
2743 This pragma is identical in syntax and semantics to
2744 the standard Ada pragma @code{Import}. It is provided for compatibility
2745 with Ada 83. The definition is upwards compatible both with pragma
2746 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2747 with some extended implementations of this pragma in certain Ada 83
2750 @node Pragma Interface_Name
2751 @unnumberedsec Pragma Interface_Name
2752 @findex Interface_Name
2756 @smallexample @c ada
2757 pragma Interface_Name (
2758 [Entity =>] LOCAL_NAME
2759 [, [External_Name =>] static_string_EXPRESSION]
2760 [, [Link_Name =>] static_string_EXPRESSION]);
2764 This pragma provides an alternative way of specifying the interface name
2765 for an interfaced subprogram, and is provided for compatibility with Ada
2766 83 compilers that use the pragma for this purpose. You must provide at
2767 least one of @var{External_Name} or @var{Link_Name}.
2769 @node Pragma Interrupt_Handler
2770 @unnumberedsec Pragma Interrupt_Handler
2771 @findex Interrupt_Handler
2775 @smallexample @c ada
2776 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2780 This program unit pragma is supported for parameterless protected procedures
2781 as described in Annex C of the Ada Reference Manual. On the AAMP target
2782 the pragma can also be specified for nonprotected parameterless procedures
2783 that are declared at the library level (which includes procedures
2784 declared at the top level of a library package). In the case of AAMP,
2785 when this pragma is applied to a nonprotected procedure, the instruction
2786 @code{IERET} is generated for returns from the procedure, enabling
2787 maskable interrupts, in place of the normal return instruction.
2789 @node Pragma Interrupt_State
2790 @unnumberedsec Pragma Interrupt_State
2791 @findex Interrupt_State
2795 @smallexample @c ada
2796 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2800 Normally certain interrupts are reserved to the implementation. Any attempt
2801 to attach an interrupt causes Program_Error to be raised, as described in
2802 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2803 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2804 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2805 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2806 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2807 Ada exceptions, or used to implement run-time functions such as the
2808 @code{abort} statement and stack overflow checking.
2810 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2811 such uses of interrupts. It subsumes the functionality of pragma
2812 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2813 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2814 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2815 and may be used to mark interrupts required by the board support package
2818 Interrupts can be in one of three states:
2822 The interrupt is reserved (no Ada handler can be installed), and the
2823 Ada run-time may not install a handler. As a result you are guaranteed
2824 standard system default action if this interrupt is raised.
2828 The interrupt is reserved (no Ada handler can be installed). The run time
2829 is allowed to install a handler for internal control purposes, but is
2830 not required to do so.
2834 The interrupt is unreserved. The user may install a handler to provide
2839 These states are the allowed values of the @code{State} parameter of the
2840 pragma. The @code{Name} parameter is a value of the type
2841 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2842 @code{Ada.Interrupts.Names}.
2844 This is a configuration pragma, and the binder will check that there
2845 are no inconsistencies between different units in a partition in how a
2846 given interrupt is specified. It may appear anywhere a pragma is legal.
2848 The effect is to move the interrupt to the specified state.
2850 By declaring interrupts to be SYSTEM, you guarantee the standard system
2851 action, such as a core dump.
2853 By declaring interrupts to be USER, you guarantee that you can install
2856 Note that certain signals on many operating systems cannot be caught and
2857 handled by applications. In such cases, the pragma is ignored. See the
2858 operating system documentation, or the value of the array @code{Reserved}
2859 declared in the spec of package @code{System.OS_Interface}.
2861 Overriding the default state of signals used by the Ada runtime may interfere
2862 with an application's runtime behavior in the cases of the synchronous signals,
2863 and in the case of the signal used to implement the @code{abort} statement.
2865 @node Pragma Keep_Names
2866 @unnumberedsec Pragma Keep_Names
2871 @smallexample @c ada
2872 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2876 The @var{LOCAL_NAME} argument
2877 must refer to an enumeration first subtype
2878 in the current declarative part. The effect is to retain the enumeration
2879 literal names for use by @code{Image} and @code{Value} even if a global
2880 @code{Discard_Names} pragma applies. This is useful when you want to
2881 generally suppress enumeration literal names and for example you therefore
2882 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2883 want to retain the names for specific enumeration types.
2885 @node Pragma License
2886 @unnumberedsec Pragma License
2888 @cindex License checking
2892 @smallexample @c ada
2893 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2897 This pragma is provided to allow automated checking for appropriate license
2898 conditions with respect to the standard and modified GPL@. A pragma
2899 @code{License}, which is a configuration pragma that typically appears at
2900 the start of a source file or in a separate @file{gnat.adc} file, specifies
2901 the licensing conditions of a unit as follows:
2905 This is used for a unit that can be freely used with no license restrictions.
2906 Examples of such units are public domain units, and units from the Ada
2910 This is used for a unit that is licensed under the unmodified GPL, and which
2911 therefore cannot be @code{with}'ed by a restricted unit.
2914 This is used for a unit licensed under the GNAT modified GPL that includes
2915 a special exception paragraph that specifically permits the inclusion of
2916 the unit in programs without requiring the entire program to be released
2920 This is used for a unit that is restricted in that it is not permitted to
2921 depend on units that are licensed under the GPL@. Typical examples are
2922 proprietary code that is to be released under more restrictive license
2923 conditions. Note that restricted units are permitted to @code{with} units
2924 which are licensed under the modified GPL (this is the whole point of the
2930 Normally a unit with no @code{License} pragma is considered to have an
2931 unknown license, and no checking is done. However, standard GNAT headers
2932 are recognized, and license information is derived from them as follows.
2936 A GNAT license header starts with a line containing 78 hyphens. The following
2937 comment text is searched for the appearance of any of the following strings.
2939 If the string ``GNU General Public License'' is found, then the unit is assumed
2940 to have GPL license, unless the string ``As a special exception'' follows, in
2941 which case the license is assumed to be modified GPL@.
2943 If one of the strings
2944 ``This specification is adapted from the Ada Semantic Interface'' or
2945 ``This specification is derived from the Ada Reference Manual'' is found
2946 then the unit is assumed to be unrestricted.
2950 These default actions means that a program with a restricted license pragma
2951 will automatically get warnings if a GPL unit is inappropriately
2952 @code{with}'ed. For example, the program:
2954 @smallexample @c ada
2957 procedure Secret_Stuff is
2963 if compiled with pragma @code{License} (@code{Restricted}) in a
2964 @file{gnat.adc} file will generate the warning:
2969 >>> license of withed unit "Sem_Ch3" is incompatible
2971 2. with GNAT.Sockets;
2972 3. procedure Secret_Stuff is
2976 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2977 compiler and is licensed under the
2978 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2979 run time, and is therefore licensed under the modified GPL@.
2981 @node Pragma Link_With
2982 @unnumberedsec Pragma Link_With
2987 @smallexample @c ada
2988 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2992 This pragma is provided for compatibility with certain Ada 83 compilers.
2993 It has exactly the same effect as pragma @code{Linker_Options} except
2994 that spaces occurring within one of the string expressions are treated
2995 as separators. For example, in the following case:
2997 @smallexample @c ada
2998 pragma Link_With ("-labc -ldef");
3002 results in passing the strings @code{-labc} and @code{-ldef} as two
3003 separate arguments to the linker. In addition pragma Link_With allows
3004 multiple arguments, with the same effect as successive pragmas.
3006 @node Pragma Linker_Alias
3007 @unnumberedsec Pragma Linker_Alias
3008 @findex Linker_Alias
3012 @smallexample @c ada
3013 pragma Linker_Alias (
3014 [Entity =>] LOCAL_NAME,
3015 [Target =>] static_string_EXPRESSION);
3019 @var{LOCAL_NAME} must refer to an object that is declared at the library
3020 level. This pragma establishes the given entity as a linker alias for the
3021 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3022 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3023 @var{static_string_EXPRESSION} in the object file, that is to say no space
3024 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3025 to the same address as @var{static_string_EXPRESSION} by the linker.
3027 The actual linker name for the target must be used (e.g.@: the fully
3028 encoded name with qualification in Ada, or the mangled name in C++),
3029 or it must be declared using the C convention with @code{pragma Import}
3030 or @code{pragma Export}.
3032 Not all target machines support this pragma. On some of them it is accepted
3033 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3035 @smallexample @c ada
3036 -- Example of the use of pragma Linker_Alias
3040 pragma Export (C, i);
3042 new_name_for_i : Integer;
3043 pragma Linker_Alias (new_name_for_i, "i");
3047 @node Pragma Linker_Constructor
3048 @unnumberedsec Pragma Linker_Constructor
3049 @findex Linker_Constructor
3053 @smallexample @c ada
3054 pragma Linker_Constructor (procedure_LOCAL_NAME);
3058 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3059 is declared at the library level. A procedure to which this pragma is
3060 applied will be treated as an initialization routine by the linker.
3061 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3062 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3063 of the executable is called (or immediately after the shared library is
3064 loaded if the procedure is linked in a shared library), in particular
3065 before the Ada run-time environment is set up.
3067 Because of these specific contexts, the set of operations such a procedure
3068 can perform is very limited and the type of objects it can manipulate is
3069 essentially restricted to the elementary types. In particular, it must only
3070 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3072 This pragma is used by GNAT to implement auto-initialization of shared Stand
3073 Alone Libraries, which provides a related capability without the restrictions
3074 listed above. Where possible, the use of Stand Alone Libraries is preferable
3075 to the use of this pragma.
3077 @node Pragma Linker_Destructor
3078 @unnumberedsec Pragma Linker_Destructor
3079 @findex Linker_Destructor
3083 @smallexample @c ada
3084 pragma Linker_Destructor (procedure_LOCAL_NAME);
3088 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3089 is declared at the library level. A procedure to which this pragma is
3090 applied will be treated as a finalization routine by the linker.
3091 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3092 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3093 of the executable has exited (or immediately before the shared library
3094 is unloaded if the procedure is linked in a shared library), in particular
3095 after the Ada run-time environment is shut down.
3097 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3098 because of these specific contexts.
3100 @node Pragma Linker_Section
3101 @unnumberedsec Pragma Linker_Section
3102 @findex Linker_Section
3106 @smallexample @c ada
3107 pragma Linker_Section (
3108 [Entity =>] LOCAL_NAME,
3109 [Section =>] static_string_EXPRESSION);
3113 @var{LOCAL_NAME} must refer to an object that is declared at the library
3114 level. This pragma specifies the name of the linker section for the given
3115 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3116 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3117 section of the executable (assuming the linker doesn't rename the section).
3119 The compiler normally places library-level objects in standard sections
3120 depending on their type: procedures and functions generally go in the
3121 @code{.text} section, initialized variables in the @code{.data} section
3122 and uninitialized variables in the @code{.bss} section.
3124 Other, special sections may exist on given target machines to map special
3125 hardware, for example I/O ports or flash memory. This pragma is a means to
3126 defer the final layout of the executable to the linker, thus fully working
3127 at the symbolic level with the compiler.
3129 Some file formats do not support arbitrary sections so not all target
3130 machines support this pragma. The use of this pragma may cause a program
3131 execution to be erroneous if it is used to place an entity into an
3132 inappropriate section (e.g.@: a modified variable into the @code{.text}
3133 section). See also @code{pragma Persistent_BSS}.
3135 @smallexample @c ada
3136 -- Example of the use of pragma Linker_Section
3140 pragma Volatile (Port_A);
3141 pragma Linker_Section (Port_A, ".bss.port_a");
3144 pragma Volatile (Port_B);
3145 pragma Linker_Section (Port_B, ".bss.port_b");
3149 @node Pragma Long_Float
3150 @unnumberedsec Pragma Long_Float
3156 @smallexample @c ada
3157 pragma Long_Float (FLOAT_FORMAT);
3159 FLOAT_FORMAT ::= D_Float | G_Float
3163 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3164 It allows control over the internal representation chosen for the predefined
3165 type @code{Long_Float} and for floating point type representations with
3166 @code{digits} specified in the range 7 through 15.
3167 For further details on this pragma, see the
3168 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3169 this pragma, the standard runtime libraries must be recompiled.
3170 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3171 @value{EDITION} User's Guide OpenVMS}, for a description of the
3172 @code{GNAT LIBRARY} command.
3174 @node Pragma Machine_Attribute
3175 @unnumberedsec Pragma Machine_Attribute
3176 @findex Machine_Attribute
3180 @smallexample @c ada
3181 pragma Machine_Attribute (
3182 [Entity =>] LOCAL_NAME,
3183 [Attribute_Name =>] static_string_EXPRESSION
3184 [, [Info =>] static_string_EXPRESSION] );
3188 Machine-dependent attributes can be specified for types and/or
3189 declarations. This pragma is semantically equivalent to
3190 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3191 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3192 in GNU C, where @code{@var{attribute_name}} is recognized by the
3193 target macro @code{TARGET_ATTRIBUTE_TABLE} which is defined for each
3194 machine. The optional parameter @var{info} is transformed into an
3195 identifier, which may make this pragma unusable for some attributes
3196 (parameter of some attributes must be a number or a string).
3197 @xref{Target Attributes,, Defining target-specific uses of
3198 @code{__attribute__}, gccint, GNU Compiler Colletion (GCC) Internals},
3199 further information. It is not possible to specify
3200 attributes defined by other languages, only attributes defined by the
3201 machine the code is intended to run on.
3204 @unnumberedsec Pragma Main
3210 @smallexample @c ada
3212 (MAIN_OPTION [, MAIN_OPTION]);
3215 [STACK_SIZE =>] static_integer_EXPRESSION
3216 | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
3217 | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
3221 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3222 no effect in GNAT, other than being syntax checked.
3224 @node Pragma Main_Storage
3225 @unnumberedsec Pragma Main_Storage
3227 @findex Main_Storage
3231 @smallexample @c ada
3233 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3235 MAIN_STORAGE_OPTION ::=
3236 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3237 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3241 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3242 no effect in GNAT, other than being syntax checked. Note that the pragma
3243 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3245 @node Pragma No_Body
3246 @unnumberedsec Pragma No_Body
3251 @smallexample @c ada
3256 There are a number of cases in which a package spec does not require a body,
3257 and in fact a body is not permitted. GNAT will not permit the spec to be
3258 compiled if there is a body around. The pragma No_Body allows you to provide
3259 a body file, even in a case where no body is allowed. The body file must
3260 contain only comments and a single No_Body pragma. This is recognized by
3261 the compiler as indicating that no body is logically present.
3263 This is particularly useful during maintenance when a package is modified in
3264 such a way that a body needed before is no longer needed. The provision of a
3265 dummy body with a No_Body pragma ensures that there is no interference from
3266 earlier versions of the package body.
3268 @node Pragma No_Return
3269 @unnumberedsec Pragma No_Return
3274 @smallexample @c ada
3275 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3279 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3280 declarations in the current declarative part. A procedure to which this
3281 pragma is applied may not contain any explicit @code{return} statements.
3282 In addition, if the procedure contains any implicit returns from falling
3283 off the end of a statement sequence, then execution of that implicit
3284 return will cause Program_Error to be raised.
3286 One use of this pragma is to identify procedures whose only purpose is to raise
3287 an exception. Another use of this pragma is to suppress incorrect warnings
3288 about missing returns in functions, where the last statement of a function
3289 statement sequence is a call to such a procedure.
3291 Note that in Ada 2005 mode, this pragma is part of the language, and is
3292 identical in effect to the pragma as implemented in Ada 95 mode.
3294 @node Pragma No_Strict_Aliasing
3295 @unnumberedsec Pragma No_Strict_Aliasing
3296 @findex No_Strict_Aliasing
3300 @smallexample @c ada
3301 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3305 @var{type_LOCAL_NAME} must refer to an access type
3306 declaration in the current declarative part. The effect is to inhibit
3307 strict aliasing optimization for the given type. The form with no
3308 arguments is a configuration pragma which applies to all access types
3309 declared in units to which the pragma applies. For a detailed
3310 description of the strict aliasing optimization, and the situations
3311 in which it must be suppressed, see @ref{Optimization and Strict
3312 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3314 @node Pragma Normalize_Scalars
3315 @unnumberedsec Pragma Normalize_Scalars
3316 @findex Normalize_Scalars
3320 @smallexample @c ada
3321 pragma Normalize_Scalars;
3325 This is a language defined pragma which is fully implemented in GNAT@. The
3326 effect is to cause all scalar objects that are not otherwise initialized
3327 to be initialized. The initial values are implementation dependent and
3331 @item Standard.Character
3333 Objects whose root type is Standard.Character are initialized to
3334 Character'Last unless the subtype range excludes NUL (in which case
3335 NUL is used). This choice will always generate an invalid value if
3338 @item Standard.Wide_Character
3340 Objects whose root type is Standard.Wide_Character are initialized to
3341 Wide_Character'Last unless the subtype range excludes NUL (in which case
3342 NUL is used). This choice will always generate an invalid value if
3345 @item Standard.Wide_Wide_Character
3347 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3348 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3349 which case NUL is used). This choice will always generate an invalid value if
3354 Objects of an integer type are treated differently depending on whether
3355 negative values are present in the subtype. If no negative values are
3356 present, then all one bits is used as the initial value except in the
3357 special case where zero is excluded from the subtype, in which case
3358 all zero bits are used. This choice will always generate an invalid
3359 value if one exists.
3361 For subtypes with negative values present, the largest negative number
3362 is used, except in the unusual case where this largest negative number
3363 is in the subtype, and the largest positive number is not, in which case
3364 the largest positive value is used. This choice will always generate
3365 an invalid value if one exists.
3367 @item Floating-Point Types
3368 Objects of all floating-point types are initialized to all 1-bits. For
3369 standard IEEE format, this corresponds to a NaN (not a number) which is
3370 indeed an invalid value.
3372 @item Fixed-Point Types
3373 Objects of all fixed-point types are treated as described above for integers,
3374 with the rules applying to the underlying integer value used to represent
3375 the fixed-point value.
3378 Objects of a modular type are initialized to all one bits, except in
3379 the special case where zero is excluded from the subtype, in which
3380 case all zero bits are used. This choice will always generate an
3381 invalid value if one exists.
3383 @item Enumeration types
3384 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3385 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3386 whose Pos value is zero, in which case a code of zero is used. This choice
3387 will always generate an invalid value if one exists.
3391 @node Pragma Obsolescent
3392 @unnumberedsec Pragma Obsolescent
3397 @smallexample @c ada
3399 (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3403 This pragma can occur immediately following a declaration of an entity,
3404 including the case of a record component, and usually the Entity name
3405 must match the name of the entity declared by this declaration.
3406 Alternatively, the pragma can immediately follow an
3407 enumeration type declaration, where the entity argument names one of the
3408 enumeration literals.
3410 This pragma is used to indicate that the named entity
3411 is considered obsolescent and should not be used. Typically this is
3412 used when an API must be modified by eventually removing or modifying
3413 existing subprograms or other entities. The pragma can be used at an
3414 intermediate stage when the entity is still present, but will be
3417 The effect of this pragma is to output a warning message on
3418 a call to a program thus marked that the
3419 subprogram is obsolescent if the appropriate warning option in the
3420 compiler is activated. If the string parameter is present, then a second
3421 warning message is given containing this text.
3422 In addition, a call to such a program is considered a violation of
3423 pragma Restrictions (No_Obsolescent_Features).
3425 This pragma can also be used as a program unit pragma for a package,
3426 in which case the entity name is the name of the package, and the
3427 pragma indicates that the entire package is considered
3428 obsolescent. In this case a client @code{with}'ing such a package
3429 violates the restriction, and the @code{with} statement is
3430 flagged with warnings if the warning option is set.
3432 If the optional third parameter is present (which must be exactly
3433 the identifier Ada_05, no other argument is allowed), then the
3434 indication of obsolescence applies only when compiling in Ada 2005
3435 mode. This is primarily intended for dealing with the situations
3436 in the predefined library where subprograms or packages
3437 have become defined as obsolescent in Ada 2005
3438 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3440 The following examples show typical uses of this pragma:
3442 @smallexample @c ada
3445 (Entity => p, "use pp instead of p");
3451 (Entity => q2, "use q2new instead");
3453 type R is new integer;
3455 (Entity => R, "use RR in Ada 2005", Ada_05);
3460 pragma Obsolescent (Entity => F2);
3464 type E is (a, bc, 'd', quack);
3465 pragma Obsolescent (Entity => bc)
3466 pragma Obsolescent (Entity => 'd')
3469 (a, b : character) return character;
3470 pragma Obsolescent (Entity => "+");
3475 In an earlier version of GNAT, the Entity parameter was not required,
3476 and this form is still accepted for compatibility purposes. If the
3477 Entity parameter is omitted, then the pragma applies to the declaration
3478 immediately preceding the pragma (this form cannot be used for the
3479 enumeration literal case).
3481 @node Pragma Optimize_Alignment
3482 @unnumberedsec Pragma Optimize_Alignment
3483 @findex Optimize_Alignment
3484 @cindex Alignment, default settings
3488 @smallexample @c ada
3489 pragma Optimize_Alignment (TIME | SPACE | OFF);
3493 This is a configuration pragma which affects the choice of default alignments
3494 for types where no alignment is explicitly specified. There is a time/space
3495 trade-off in the selection of these values. Large alignments result in more
3496 efficient code, at the expense of larger data space, since sizes have to be
3497 increased to match these alignments. Smaller alignments save space, but the
3498 access code is slower. The normal choice of default alignments (which is what
3499 you get if you do not use this pragma, or if you use an argument of OFF),
3500 tries to balance these two requirements.
3502 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3503 First any packed record is given an alignment of 1. Second, if a size is given
3504 for the type, then the alignment is chosen to avoid increasing this size. For
3507 @smallexample @c ada
3517 In the default mode, this type gets an alignment of 4, so that access to the
3518 Integer field X are efficient. But this means that objects of the type end up
3519 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3520 allowed to be bigger than the size of the type, but it can waste space if for
3521 example fields of type R appear in an enclosing record. If the above type is
3522 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3524 Specifying TIME causes larger default alignments to be chosen in the case of
3525 small types with sizes that are not a power of 2. For example, consider:
3527 @smallexample @c ada
3539 The default alignment for this record is normally 1, but if this type is
3540 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3541 to 4, which wastes space for objects of the type, since they are now 4 bytes
3542 long, but results in more efficient access when the whole record is referenced.
3544 As noted above, this is a configuration pragma, and there is a requirement
3545 that all units in a partition be compiled with a consistent setting of the
3546 optimization setting. This would normally be achieved by use of a configuration
3547 pragma file containing the appropriate setting. The exception to this rule is
3548 that units with an explicit configuration pragma in the same file as the source
3549 unit are excluded from the consistency check, as are all predefined units. The
3550 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3551 pragma appears at the start of the file.
3553 @node Pragma Passive
3554 @unnumberedsec Pragma Passive
3559 @smallexample @c ada
3560 pragma Passive [(Semaphore | No)];
3564 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3565 compatibility with DEC Ada 83 implementations, where it is used within a
3566 task definition to request that a task be made passive. If the argument
3567 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3568 treats the pragma as an assertion that the containing task is passive
3569 and that optimization of context switch with this task is permitted and
3570 desired. If the argument @code{No} is present, the task must not be
3571 optimized. GNAT does not attempt to optimize any tasks in this manner
3572 (since protected objects are available in place of passive tasks).
3574 @node Pragma Persistent_BSS
3575 @unnumberedsec Pragma Persistent_BSS
3576 @findex Persistent_BSS
3580 @smallexample @c ada
3581 pragma Persistent_BSS [(LOCAL_NAME)]
3585 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3586 section. On some targets the linker and loader provide for special
3587 treatment of this section, allowing a program to be reloaded without
3588 affecting the contents of this data (hence the name persistent).
3590 There are two forms of usage. If an argument is given, it must be the
3591 local name of a library level object, with no explicit initialization
3592 and whose type is potentially persistent. If no argument is given, then
3593 the pragma is a configuration pragma, and applies to all library level
3594 objects with no explicit initialization of potentially persistent types.
3596 A potentially persistent type is a scalar type, or a non-tagged,
3597 non-discriminated record, all of whose components have no explicit
3598 initialization and are themselves of a potentially persistent type,
3599 or an array, all of whose constraints are static, and whose component
3600 type is potentially persistent.
3602 If this pragma is used on a target where this feature is not supported,
3603 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3605 @node Pragma Polling
3606 @unnumberedsec Pragma Polling
3611 @smallexample @c ada
3612 pragma Polling (ON | OFF);
3616 This pragma controls the generation of polling code. This is normally off.
3617 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3618 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3619 runtime library, and can be found in file @file{a-excpol.adb}.
3621 Pragma @code{Polling} can appear as a configuration pragma (for example it
3622 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3623 can be used in the statement or declaration sequence to control polling
3626 A call to the polling routine is generated at the start of every loop and
3627 at the start of every subprogram call. This guarantees that the @code{Poll}
3628 routine is called frequently, and places an upper bound (determined by
3629 the complexity of the code) on the period between two @code{Poll} calls.
3631 The primary purpose of the polling interface is to enable asynchronous
3632 aborts on targets that cannot otherwise support it (for example Windows
3633 NT), but it may be used for any other purpose requiring periodic polling.
3634 The standard version is null, and can be replaced by a user program. This
3635 will require re-compilation of the @code{Ada.Exceptions} package that can
3636 be found in files @file{a-except.ads} and @file{a-except.adb}.
3638 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3639 distribution) is used to enable the asynchronous abort capability on
3640 targets that do not normally support the capability. The version of
3641 @code{Poll} in this file makes a call to the appropriate runtime routine
3642 to test for an abort condition.
3644 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3645 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3648 @node Pragma Postcondition
3649 @unnumberedsec Pragma Postcondition
3650 @cindex Postconditions
3651 @cindex Checks, postconditions
3652 @findex Postconditions
3656 @smallexample @c ada
3657 pragma Postcondition (
3658 [Check =>] Boolean_Expression
3659 [,[Message =>] String_Expression]);
3663 The @code{Postcondition} pragma allows specification of automatic
3664 postcondition checks for subprograms. These checks are similar to
3665 assertions, but are automatically inserted just prior to the return
3666 statements of the subprogram with which they are associated.
3667 Furthermore, the boolean expression which is the condition which
3668 must be true may contain references to function'Result in the case
3669 of a function to refer to the returned value.
3671 @code{Postcondition} pragmas may appear either immediate following the
3672 (separate) declaration of a subprogram, or at the start of the
3673 declarations of a subprogram body. Only other pragmas may intervene
3674 (that is appear between the subprogram declaration and its
3675 postconditions, or appear before the postcondition in the
3676 declaration sequence in a subprogram body). In the case of a
3677 postcondition appearing after a subprogram declaration, the
3678 formal arguments of the subprogram are visible, and can be
3679 referenced in the postcondition expressions.
3681 The postconditions are collected and automatically tested just
3682 before any return (implicit or explicit) in the subprogram body.
3683 A postcondition is only recognized if postconditions are active
3684 at the time the pragma is encountered. The compiler switch @option{gnata}
3685 turns on all postconditions by default, and pragma @code{Check_Policy}
3686 with an identifier of @code{Postcondition} can also be used to
3687 control whether postconditions are active.
3689 The general approach is that postconditions are placed in the spec
3690 if they represent functional aspects which make sense to the client.
3691 For example we might have:
3693 @smallexample @c ada
3694 function Direction return Integer;
3695 pragma Postcondition
3696 (Direction'Result = +1
3698 Direction'Result = -1);
3702 which serves to document that the result must be +1 or -1, and
3703 will test that this is the case at run time if postcondition
3706 Postconditions within the subprogram body can be used to
3707 check that some internal aspect of the implementation,
3708 not visible to the client, is operating as expected.
3709 For instance if a square root routine keeps an internal
3710 counter of the number of times it is called, then we
3711 might have the following postcondition:
3713 @smallexample @c ada
3714 Sqrt_Calls : Natural := 0;
3716 function Sqrt (Arg : Float) return Float is
3717 pragma Postcondition
3718 (Sqrt_Calls = Sqrt_Calls'Old + 1);
3724 As this example, shows, the use of the @code{Old} attribute
3725 is often useful in postconditions to refer to the state on
3726 entry to the subprogram.
3728 Note that postconditions are only checked on normal returns
3729 from the subprogram. If an abnormal return results from
3730 raising an exception, then the postconditions are not checked.
3732 If a postcondition fails, then the exception
3733 @code{System.Assertions.Assert_Failure} is raised. If
3734 a message argument was supplied, then the given string
3735 will be used as the exception message. If no message
3736 argument was supplied, then the default message has
3737 the form "Postcondition failed at file:line". The
3738 exception is raised in the context of the subprogram
3739 body, so it is possible to catch postcondition failures
3740 within the subprogram body itself.
3742 Within a package spec, normal visibility rules
3743 in Ada would prevent forward references within a
3744 postcondition pragma to functions defined later in
3745 the same package. This would introduce undesirable
3746 ordering constraints. To avoid this problem, all
3747 postcondition pragmas are analyzed at the end of
3748 the package spec, allowing forward references.
3750 The following example shows that this even allows
3751 mutually recursive postconditions as in:
3753 @smallexample @c ada
3754 package Parity_Functions is
3755 function Odd (X : Natural) return Boolean;
3756 pragma Postcondition
3760 (x /= 0 and then Even (X - 1))));
3762 function Even (X : Natural) return Boolean;
3763 pragma Postcondition
3767 (x /= 1 and then Odd (X - 1))));
3769 end Parity_Functions;
3773 There are no restrictions on the complexity or form of
3774 conditions used within @code{Postcondition} pragmas.
3775 The following example shows that it is even possible
3776 to verify performance behavior.
3778 @smallexample @c ada
3781 Performance : constant Float;
3782 -- Performance constant set by implementation
3783 -- to match target architecture behavior.
3785 procedure Treesort (Arg : String);
3786 -- Sorts characters of argument using N*logN sort
3787 pragma Postcondition
3788 (Float (Clock - Clock'Old) <=
3789 Float (Arg'Length) *
3790 log (Float (Arg'Length)) *
3795 @node Pragma Precondition
3796 @unnumberedsec Pragma Precondition
3797 @cindex Preconditions
3798 @cindex Checks, preconditions
3799 @findex Preconditions
3803 @smallexample @c ada
3804 pragma Precondition (
3805 [Check =>] Boolean_Expression
3806 [,[Message =>] String_Expression]);
3810 The @code{Precondition} pragma is similar to @code{Postcondition}
3811 except that the corresponding checks take place immediately upon
3812 entry to the subprogram, and if a precondition fails, the exception
3813 is raised in the context of the caller, and the attribute 'Result
3814 cannot be used within the precondition expression.
3816 Otherwise, the placement and visibility rules are identical to those
3817 described for postconditions. The following is an example of use
3818 within a package spec:
3820 @smallexample @c ada
3821 package Math_Functions is
3823 function Sqrt (Arg : Float) return Float;
3824 pragma Precondition (Arg >= 0.0)
3829 @code{Postcondition} pragmas may appear either immediate following the
3830 (separate) declaration of a subprogram, or at the start of the
3831 declarations of a subprogram body. Only other pragmas may intervene
3832 (that is appear between the subprogram declaration and its
3833 postconditions, or appear before the postcondition in the
3834 declaration sequence in a subprogram body).
3836 @node Pragma Profile (Ravenscar)
3837 @unnumberedsec Pragma Profile (Ravenscar)
3842 @smallexample @c ada
3843 pragma Profile (Ravenscar);
3847 A configuration pragma that establishes the following set of configuration
3851 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3852 [RM D.2.2] Tasks are dispatched following a preemptive
3853 priority-ordered scheduling policy.
3855 @item Locking_Policy (Ceiling_Locking)
3856 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3857 the ceiling priority of the corresponding protected object.
3859 @c @item Detect_Blocking
3860 @c This pragma forces the detection of potentially blocking operations within a
3861 @c protected operation, and to raise Program_Error if that happens.
3865 plus the following set of restrictions:
3868 @item Max_Entry_Queue_Length = 1
3869 Defines the maximum number of calls that are queued on a (protected) entry.
3870 Note that this restrictions is checked at run time. Violation of this
3871 restriction results in the raising of Program_Error exception at the point of
3872 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3873 always 1 and hence no task can be queued on a protected entry.
3875 @item Max_Protected_Entries = 1
3876 [RM D.7] Specifies the maximum number of entries per protected type. The
3877 bounds of every entry family of a protected unit shall be static, or shall be
3878 defined by a discriminant of a subtype whose corresponding bound is static.
3879 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3881 @item Max_Task_Entries = 0
3882 [RM D.7] Specifies the maximum number of entries
3883 per task. The bounds of every entry family
3884 of a task unit shall be static, or shall be
3885 defined by a discriminant of a subtype whose
3886 corresponding bound is static. A value of zero
3887 indicates that no rendezvous are possible. For
3888 the Profile (Ravenscar), the value of Max_Task_Entries is always
3891 @item No_Abort_Statements
3892 [RM D.7] There are no abort_statements, and there are
3893 no calls to Task_Identification.Abort_Task.
3895 @item No_Asynchronous_Control
3896 There are no semantic dependences on the package
3897 Asynchronous_Task_Control.
3900 There are no semantic dependencies on the package Ada.Calendar.
3902 @item No_Dynamic_Attachment
3903 There is no call to any of the operations defined in package Ada.Interrupts
3904 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3905 Detach_Handler, and Reference).
3907 @item No_Dynamic_Priorities
3908 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3910 @item No_Implicit_Heap_Allocations
3911 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3913 @item No_Local_Protected_Objects
3914 Protected objects and access types that designate
3915 such objects shall be declared only at library level.
3917 @item No_Local_Timing_Events
3918 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
3919 declared at the library level.
3921 @item No_Protected_Type_Allocators
3922 There are no allocators for protected types or
3923 types containing protected subcomponents.
3925 @item No_Relative_Delay
3926 There are no delay_relative statements.
3928 @item No_Requeue_Statements
3929 Requeue statements are not allowed.
3931 @item No_Select_Statements
3932 There are no select_statements.
3934 @item No_Specific_Termination_Handlers
3935 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
3936 or to Ada.Task_Termination.Specific_Handler.
3938 @item No_Task_Allocators
3939 [RM D.7] There are no allocators for task types
3940 or types containing task subcomponents.
3942 @item No_Task_Attributes_Package
3943 There are no semantic dependencies on the Ada.Task_Attributes package.
3945 @item No_Task_Hierarchy
3946 [RM D.7] All (non-environment) tasks depend
3947 directly on the environment task of the partition.
3949 @item No_Task_Termination
3950 Tasks which terminate are erroneous.
3952 @item No_Unchecked_Conversion
3953 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
3955 @item No_Unchecked_Deallocation
3956 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
3958 @item Simple_Barriers
3959 Entry barrier condition expressions shall be either static
3960 boolean expressions or boolean objects which are declared in
3961 the protected type which contains the entry.
3965 This set of configuration pragmas and restrictions correspond to the
3966 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3967 published by the @cite{International Real-Time Ada Workshop}, 1997,
3968 and whose most recent description is available at
3969 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
3971 The original definition of the profile was revised at subsequent IRTAW
3972 meetings. It has been included in the ISO
3973 @cite{Guide for the Use of the Ada Programming Language in High
3974 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3975 the next revision of the standard. The formal definition given by
3976 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3977 AI-305) available at
3978 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3979 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3982 The above set is a superset of the restrictions provided by pragma
3983 @code{Profile (Restricted)}, it includes six additional restrictions
3984 (@code{Simple_Barriers}, @code{No_Select_Statements},
3985 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3986 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
3987 that pragma @code{Profile (Ravenscar)}, like the pragma
3988 @code{Profile (Restricted)},
3989 automatically causes the use of a simplified,
3990 more efficient version of the tasking run-time system.
3992 @node Pragma Profile (Restricted)
3993 @unnumberedsec Pragma Profile (Restricted)
3994 @findex Restricted Run Time
3998 @smallexample @c ada
3999 pragma Profile (Restricted);
4003 A configuration pragma that establishes the following set of restrictions:
4006 @item No_Abort_Statements
4007 @item No_Entry_Queue
4008 @item No_Task_Hierarchy
4009 @item No_Task_Allocators
4010 @item No_Dynamic_Priorities
4011 @item No_Terminate_Alternatives
4012 @item No_Dynamic_Attachment
4013 @item No_Protected_Type_Allocators
4014 @item No_Local_Protected_Objects
4015 @item No_Requeue_Statements
4016 @item No_Task_Attributes_Package
4017 @item Max_Asynchronous_Select_Nesting = 0
4018 @item Max_Task_Entries = 0
4019 @item Max_Protected_Entries = 1
4020 @item Max_Select_Alternatives = 0
4024 This set of restrictions causes the automatic selection of a simplified
4025 version of the run time that provides improved performance for the
4026 limited set of tasking functionality permitted by this set of restrictions.
4028 @node Pragma Psect_Object
4029 @unnumberedsec Pragma Psect_Object
4030 @findex Psect_Object
4034 @smallexample @c ada
4035 pragma Psect_Object (
4036 [Internal =>] LOCAL_NAME,
4037 [, [External =>] EXTERNAL_SYMBOL]
4038 [, [Size =>] EXTERNAL_SYMBOL]);
4042 | static_string_EXPRESSION
4046 This pragma is identical in effect to pragma @code{Common_Object}.
4048 @node Pragma Pure_Function
4049 @unnumberedsec Pragma Pure_Function
4050 @findex Pure_Function
4054 @smallexample @c ada
4055 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4059 This pragma appears in the same declarative part as a function
4060 declaration (or a set of function declarations if more than one
4061 overloaded declaration exists, in which case the pragma applies
4062 to all entities). It specifies that the function @code{Entity} is
4063 to be considered pure for the purposes of code generation. This means
4064 that the compiler can assume that there are no side effects, and
4065 in particular that two calls with identical arguments produce the
4066 same result. It also means that the function can be used in an
4069 Note that, quite deliberately, there are no static checks to try
4070 to ensure that this promise is met, so @code{Pure_Function} can be used
4071 with functions that are conceptually pure, even if they do modify
4072 global variables. For example, a square root function that is
4073 instrumented to count the number of times it is called is still
4074 conceptually pure, and can still be optimized, even though it
4075 modifies a global variable (the count). Memo functions are another
4076 example (where a table of previous calls is kept and consulted to
4077 avoid re-computation).
4080 Note: Most functions in a @code{Pure} package are automatically pure, and
4081 there is no need to use pragma @code{Pure_Function} for such functions. One
4082 exception is any function that has at least one formal of type
4083 @code{System.Address} or a type derived from it. Such functions are not
4084 considered pure by default, since the compiler assumes that the
4085 @code{Address} parameter may be functioning as a pointer and that the
4086 referenced data may change even if the address value does not.
4087 Similarly, imported functions are not considered to be pure by default,
4088 since there is no way of checking that they are in fact pure. The use
4089 of pragma @code{Pure_Function} for such a function will override these default
4090 assumption, and cause the compiler to treat a designated subprogram as pure
4093 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4094 applies to the underlying renamed function. This can be used to
4095 disambiguate cases of overloading where some but not all functions
4096 in a set of overloaded functions are to be designated as pure.
4098 If pragma @code{Pure_Function} is applied to a library level function, the
4099 function is also considered pure from an optimization point of view, but the
4100 unit is not a Pure unit in the categorization sense. So for example, a function
4101 thus marked is free to @code{with} non-pure units.
4103 @node Pragma Restriction_Warnings
4104 @unnumberedsec Pragma Restriction_Warnings
4105 @findex Restriction_Warnings
4109 @smallexample @c ada
4110 pragma Restriction_Warnings
4111 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4115 This pragma allows a series of restriction identifiers to be
4116 specified (the list of allowed identifiers is the same as for
4117 pragma @code{Restrictions}). For each of these identifiers
4118 the compiler checks for violations of the restriction, but
4119 generates a warning message rather than an error message
4120 if the restriction is violated.
4123 @unnumberedsec Pragma Shared
4127 This pragma is provided for compatibility with Ada 83. The syntax and
4128 semantics are identical to pragma Atomic.
4130 @node Pragma Source_File_Name
4131 @unnumberedsec Pragma Source_File_Name
4132 @findex Source_File_Name
4136 @smallexample @c ada
4137 pragma Source_File_Name (
4138 [Unit_Name =>] unit_NAME,
4139 Spec_File_Name => STRING_LITERAL);
4141 pragma Source_File_Name (
4142 [Unit_Name =>] unit_NAME,
4143 Body_File_Name => STRING_LITERAL);
4147 Use this to override the normal naming convention. It is a configuration
4148 pragma, and so has the usual applicability of configuration pragmas
4149 (i.e.@: it applies to either an entire partition, or to all units in a
4150 compilation, or to a single unit, depending on how it is used.
4151 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4152 the second argument is required, and indicates whether this is the file
4153 name for the spec or for the body.
4155 Another form of the @code{Source_File_Name} pragma allows
4156 the specification of patterns defining alternative file naming schemes
4157 to apply to all files.
4159 @smallexample @c ada
4160 pragma Source_File_Name
4161 (Spec_File_Name => STRING_LITERAL
4162 [,Casing => CASING_SPEC]
4163 [,Dot_Replacement => STRING_LITERAL]);
4165 pragma Source_File_Name
4166 (Body_File_Name => STRING_LITERAL
4167 [,Casing => CASING_SPEC]
4168 [,Dot_Replacement => STRING_LITERAL]);
4170 pragma Source_File_Name
4171 (Subunit_File_Name => STRING_LITERAL
4172 [,Casing => CASING_SPEC]
4173 [,Dot_Replacement => STRING_LITERAL]);
4175 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4179 The first argument is a pattern that contains a single asterisk indicating
4180 the point at which the unit name is to be inserted in the pattern string
4181 to form the file name. The second argument is optional. If present it
4182 specifies the casing of the unit name in the resulting file name string.
4183 The default is lower case. Finally the third argument allows for systematic
4184 replacement of any dots in the unit name by the specified string literal.
4186 A pragma Source_File_Name cannot appear after a
4187 @ref{Pragma Source_File_Name_Project}.
4189 For more details on the use of the @code{Source_File_Name} pragma,
4190 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4191 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4194 @node Pragma Source_File_Name_Project
4195 @unnumberedsec Pragma Source_File_Name_Project
4196 @findex Source_File_Name_Project
4199 This pragma has the same syntax and semantics as pragma Source_File_Name.
4200 It is only allowed as a stand alone configuration pragma.
4201 It cannot appear after a @ref{Pragma Source_File_Name}, and
4202 most importantly, once pragma Source_File_Name_Project appears,
4203 no further Source_File_Name pragmas are allowed.
4205 The intention is that Source_File_Name_Project pragmas are always
4206 generated by the Project Manager in a manner consistent with the naming
4207 specified in a project file, and when naming is controlled in this manner,
4208 it is not permissible to attempt to modify this naming scheme using
4209 Source_File_Name pragmas (which would not be known to the project manager).
4211 @node Pragma Source_Reference
4212 @unnumberedsec Pragma Source_Reference
4213 @findex Source_Reference
4217 @smallexample @c ada
4218 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4222 This pragma must appear as the first line of a source file.
4223 @var{integer_literal} is the logical line number of the line following
4224 the pragma line (for use in error messages and debugging
4225 information). @var{string_literal} is a static string constant that
4226 specifies the file name to be used in error messages and debugging
4227 information. This is most notably used for the output of @code{gnatchop}
4228 with the @option{-r} switch, to make sure that the original unchopped
4229 source file is the one referred to.
4231 The second argument must be a string literal, it cannot be a static
4232 string expression other than a string literal. This is because its value
4233 is needed for error messages issued by all phases of the compiler.
4235 @node Pragma Stream_Convert
4236 @unnumberedsec Pragma Stream_Convert
4237 @findex Stream_Convert
4241 @smallexample @c ada
4242 pragma Stream_Convert (
4243 [Entity =>] type_LOCAL_NAME,
4244 [Read =>] function_NAME,
4245 [Write =>] function_NAME);
4249 This pragma provides an efficient way of providing stream functions for
4250 types defined in packages. Not only is it simpler to use than declaring
4251 the necessary functions with attribute representation clauses, but more
4252 significantly, it allows the declaration to made in such a way that the
4253 stream packages are not loaded unless they are needed. The use of
4254 the Stream_Convert pragma adds no overhead at all, unless the stream
4255 attributes are actually used on the designated type.
4257 The first argument specifies the type for which stream functions are
4258 provided. The second parameter provides a function used to read values
4259 of this type. It must name a function whose argument type may be any
4260 subtype, and whose returned type must be the type given as the first
4261 argument to the pragma.
4263 The meaning of the @var{Read}
4264 parameter is that if a stream attribute directly
4265 or indirectly specifies reading of the type given as the first parameter,
4266 then a value of the type given as the argument to the Read function is
4267 read from the stream, and then the Read function is used to convert this
4268 to the required target type.
4270 Similarly the @var{Write} parameter specifies how to treat write attributes
4271 that directly or indirectly apply to the type given as the first parameter.
4272 It must have an input parameter of the type specified by the first parameter,
4273 and the return type must be the same as the input type of the Read function.
4274 The effect is to first call the Write function to convert to the given stream
4275 type, and then write the result type to the stream.
4277 The Read and Write functions must not be overloaded subprograms. If necessary
4278 renamings can be supplied to meet this requirement.
4279 The usage of this attribute is best illustrated by a simple example, taken
4280 from the GNAT implementation of package Ada.Strings.Unbounded:
4282 @smallexample @c ada
4283 function To_Unbounded (S : String)
4284 return Unbounded_String
4285 renames To_Unbounded_String;
4287 pragma Stream_Convert
4288 (Unbounded_String, To_Unbounded, To_String);
4292 The specifications of the referenced functions, as given in the Ada
4293 Reference Manual are:
4295 @smallexample @c ada
4296 function To_Unbounded_String (Source : String)
4297 return Unbounded_String;
4299 function To_String (Source : Unbounded_String)
4304 The effect is that if the value of an unbounded string is written to a
4305 stream, then the representation of the item in the stream is in the same
4306 format used for @code{Standard.String}, and this same representation is
4307 expected when a value of this type is read from the stream.
4309 @node Pragma Style_Checks
4310 @unnumberedsec Pragma Style_Checks
4311 @findex Style_Checks
4315 @smallexample @c ada
4316 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4317 On | Off [, LOCAL_NAME]);
4321 This pragma is used in conjunction with compiler switches to control the
4322 built in style checking provided by GNAT@. The compiler switches, if set,
4323 provide an initial setting for the switches, and this pragma may be used
4324 to modify these settings, or the settings may be provided entirely by
4325 the use of the pragma. This pragma can be used anywhere that a pragma
4326 is legal, including use as a configuration pragma (including use in
4327 the @file{gnat.adc} file).
4329 The form with a string literal specifies which style options are to be
4330 activated. These are additive, so they apply in addition to any previously
4331 set style check options. The codes for the options are the same as those
4332 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4333 For example the following two methods can be used to enable
4338 @smallexample @c ada
4339 pragma Style_Checks ("l");
4344 gcc -c -gnatyl @dots{}
4349 The form ALL_CHECKS activates all standard checks (its use is equivalent
4350 to the use of the @code{gnaty} switch with no options. @xref{Top,
4351 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4352 @value{EDITION} User's Guide}, for details.
4354 The forms with @code{Off} and @code{On}
4355 can be used to temporarily disable style checks
4356 as shown in the following example:
4358 @smallexample @c ada
4362 pragma Style_Checks ("k"); -- requires keywords in lower case
4363 pragma Style_Checks (Off); -- turn off style checks
4364 NULL; -- this will not generate an error message
4365 pragma Style_Checks (On); -- turn style checks back on
4366 NULL; -- this will generate an error message
4370 Finally the two argument form is allowed only if the first argument is
4371 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4372 for the specified entity, as shown in the following example:
4374 @smallexample @c ada
4378 pragma Style_Checks ("r"); -- require consistency of identifier casing
4380 Rf1 : Integer := ARG; -- incorrect, wrong case
4381 pragma Style_Checks (Off, Arg);
4382 Rf2 : Integer := ARG; -- OK, no error
4385 @node Pragma Subtitle
4386 @unnumberedsec Pragma Subtitle
4391 @smallexample @c ada
4392 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4396 This pragma is recognized for compatibility with other Ada compilers
4397 but is ignored by GNAT@.
4399 @node Pragma Suppress
4400 @unnumberedsec Pragma Suppress
4405 @smallexample @c ada
4406 pragma Suppress (Identifier [, [On =>] Name]);
4410 This is a standard pragma, and supports all the check names required in
4411 the RM. It is included here because GNAT recognizes one additional check
4412 name: @code{Alignment_Check} which can be used to suppress alignment checks
4413 on addresses used in address clauses. Such checks can also be suppressed
4414 by suppressing range checks, but the specific use of @code{Alignment_Check}
4415 allows suppression of alignment checks without suppressing other range checks.
4417 @node Pragma Suppress_All
4418 @unnumberedsec Pragma Suppress_All
4419 @findex Suppress_All
4423 @smallexample @c ada
4424 pragma Suppress_All;
4428 This pragma can only appear immediately following a compilation
4429 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
4430 which it follows. This pragma is implemented for compatibility with DEC
4431 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
4432 configuration pragma is the preferred usage in GNAT@.
4434 @node Pragma Suppress_Exception_Locations
4435 @unnumberedsec Pragma Suppress_Exception_Locations
4436 @findex Suppress_Exception_Locations
4440 @smallexample @c ada
4441 pragma Suppress_Exception_Locations;
4445 In normal mode, a raise statement for an exception by default generates
4446 an exception message giving the file name and line number for the location
4447 of the raise. This is useful for debugging and logging purposes, but this
4448 entails extra space for the strings for the messages. The configuration
4449 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4450 generation of these strings, with the result that space is saved, but the
4451 exception message for such raises is null. This configuration pragma may
4452 appear in a global configuration pragma file, or in a specific unit as
4453 usual. It is not required that this pragma be used consistently within
4454 a partition, so it is fine to have some units within a partition compiled
4455 with this pragma and others compiled in normal mode without it.
4457 @node Pragma Suppress_Initialization
4458 @unnumberedsec Pragma Suppress_Initialization
4459 @findex Suppress_Initialization
4460 @cindex Suppressing initialization
4461 @cindex Initialization, suppression of
4465 @smallexample @c ada
4466 pragma Suppress_Initialization ([Entity =>] type_Name);
4470 This pragma suppresses any implicit or explicit initialization
4471 associated with the given type name for all variables of this type.
4473 @node Pragma Task_Info
4474 @unnumberedsec Pragma Task_Info
4479 @smallexample @c ada
4480 pragma Task_Info (EXPRESSION);
4484 This pragma appears within a task definition (like pragma
4485 @code{Priority}) and applies to the task in which it appears. The
4486 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4487 The @code{Task_Info} pragma provides system dependent control over
4488 aspects of tasking implementation, for example, the ability to map
4489 tasks to specific processors. For details on the facilities available
4490 for the version of GNAT that you are using, see the documentation
4491 in the spec of package System.Task_Info in the runtime
4494 @node Pragma Task_Name
4495 @unnumberedsec Pragma Task_Name
4500 @smallexample @c ada
4501 pragma Task_Name (string_EXPRESSION);
4505 This pragma appears within a task definition (like pragma
4506 @code{Priority}) and applies to the task in which it appears. The
4507 argument must be of type String, and provides a name to be used for
4508 the task instance when the task is created. Note that this expression
4509 is not required to be static, and in particular, it can contain
4510 references to task discriminants. This facility can be used to
4511 provide different names for different tasks as they are created,
4512 as illustrated in the example below.
4514 The task name is recorded internally in the run-time structures
4515 and is accessible to tools like the debugger. In addition the
4516 routine @code{Ada.Task_Identification.Image} will return this
4517 string, with a unique task address appended.
4519 @smallexample @c ada
4520 -- Example of the use of pragma Task_Name
4522 with Ada.Task_Identification;
4523 use Ada.Task_Identification;
4524 with Text_IO; use Text_IO;
4527 type Astring is access String;
4529 task type Task_Typ (Name : access String) is
4530 pragma Task_Name (Name.all);
4533 task body Task_Typ is
4534 Nam : constant String := Image (Current_Task);
4536 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4539 type Ptr_Task is access Task_Typ;
4540 Task_Var : Ptr_Task;
4544 new Task_Typ (new String'("This is task 1"));
4546 new Task_Typ (new String'("This is task 2"));
4550 @node Pragma Task_Storage
4551 @unnumberedsec Pragma Task_Storage
4552 @findex Task_Storage
4555 @smallexample @c ada
4556 pragma Task_Storage (
4557 [Task_Type =>] LOCAL_NAME,
4558 [Top_Guard =>] static_integer_EXPRESSION);
4562 This pragma specifies the length of the guard area for tasks. The guard
4563 area is an additional storage area allocated to a task. A value of zero
4564 means that either no guard area is created or a minimal guard area is
4565 created, depending on the target. This pragma can appear anywhere a
4566 @code{Storage_Size} attribute definition clause is allowed for a task
4569 @node Pragma Time_Slice
4570 @unnumberedsec Pragma Time_Slice
4575 @smallexample @c ada
4576 pragma Time_Slice (static_duration_EXPRESSION);
4580 For implementations of GNAT on operating systems where it is possible
4581 to supply a time slice value, this pragma may be used for this purpose.
4582 It is ignored if it is used in a system that does not allow this control,
4583 or if it appears in other than the main program unit.
4585 Note that the effect of this pragma is identical to the effect of the
4586 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4589 @unnumberedsec Pragma Title
4594 @smallexample @c ada
4595 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4598 [Title =>] STRING_LITERAL,
4599 | [Subtitle =>] STRING_LITERAL
4603 Syntax checked but otherwise ignored by GNAT@. This is a listing control
4604 pragma used in DEC Ada 83 implementations to provide a title and/or
4605 subtitle for the program listing. The program listing generated by GNAT
4606 does not have titles or subtitles.
4608 Unlike other pragmas, the full flexibility of named notation is allowed
4609 for this pragma, i.e.@: the parameters may be given in any order if named
4610 notation is used, and named and positional notation can be mixed
4611 following the normal rules for procedure calls in Ada.
4613 @node Pragma Unchecked_Union
4614 @unnumberedsec Pragma Unchecked_Union
4616 @findex Unchecked_Union
4620 @smallexample @c ada
4621 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4625 This pragma is used to specify a representation of a record type that is
4626 equivalent to a C union. It was introduced as a GNAT implementation defined
4627 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4628 pragma, making it language defined, and GNAT fully implements this extended
4629 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4630 details, consult the Ada 2005 Reference Manual, section B.3.3.
4632 @node Pragma Unimplemented_Unit
4633 @unnumberedsec Pragma Unimplemented_Unit
4634 @findex Unimplemented_Unit
4638 @smallexample @c ada
4639 pragma Unimplemented_Unit;
4643 If this pragma occurs in a unit that is processed by the compiler, GNAT
4644 aborts with the message @samp{@var{xxx} not implemented}, where
4645 @var{xxx} is the name of the current compilation unit. This pragma is
4646 intended to allow the compiler to handle unimplemented library units in
4649 The abort only happens if code is being generated. Thus you can use
4650 specs of unimplemented packages in syntax or semantic checking mode.
4652 @node Pragma Universal_Aliasing
4653 @unnumberedsec Pragma Universal_Aliasing
4654 @findex Universal_Aliasing
4658 @smallexample @c ada
4659 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4663 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4664 declarative part. The effect is to inhibit strict type-based aliasing
4665 optimization for the given type. In other words, the effect is as though
4666 access types designating this type were subject to pragma No_Strict_Aliasing.
4667 For a detailed description of the strict aliasing optimization, and the
4668 situations in which it must be suppressed, @xref{Optimization and Strict
4669 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4671 @node Pragma Universal_Data
4672 @unnumberedsec Pragma Universal_Data
4673 @findex Universal_Data
4677 @smallexample @c ada
4678 pragma Universal_Data [(library_unit_Name)];
4682 This pragma is supported only for the AAMP target and is ignored for
4683 other targets. The pragma specifies that all library-level objects
4684 (Counter 0 data) associated with the library unit are to be accessed
4685 and updated using universal addressing (24-bit addresses for AAMP5)
4686 rather than the default of 16-bit Data Environment (DENV) addressing.
4687 Use of this pragma will generally result in less efficient code for
4688 references to global data associated with the library unit, but
4689 allows such data to be located anywhere in memory. This pragma is
4690 a library unit pragma, but can also be used as a configuration pragma
4691 (including use in the @file{gnat.adc} file). The functionality
4692 of this pragma is also available by applying the -univ switch on the
4693 compilations of units where universal addressing of the data is desired.
4695 @node Pragma Unmodified
4696 @unnumberedsec Pragma Unmodified
4698 @cindex Warnings, unmodified
4702 @smallexample @c ada
4703 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4707 This pragma signals that the assignable entities (variables,
4708 @code{out} parameters, @code{in out} parameters) whose names are listed are
4709 deliberately not assigned in the current source unit. This
4710 suppresses warnings about the
4711 entities being referenced but not assigned, and in addition a warning will be
4712 generated if one of these entities is in fact assigned in the
4713 same unit as the pragma (or in the corresponding body, or one
4716 This is particularly useful for clearly signaling that a particular
4717 parameter is not modified, even though the spec suggests that it might
4720 @node Pragma Unreferenced
4721 @unnumberedsec Pragma Unreferenced
4722 @findex Unreferenced
4723 @cindex Warnings, unreferenced
4727 @smallexample @c ada
4728 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4729 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4733 This pragma signals that the entities whose names are listed are
4734 deliberately not referenced in the current source unit. This
4735 suppresses warnings about the
4736 entities being unreferenced, and in addition a warning will be
4737 generated if one of these entities is in fact referenced in the
4738 same unit as the pragma (or in the corresponding body, or one
4741 This is particularly useful for clearly signaling that a particular
4742 parameter is not referenced in some particular subprogram implementation
4743 and that this is deliberate. It can also be useful in the case of
4744 objects declared only for their initialization or finalization side
4747 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4748 current scope, then the entity most recently declared is the one to which
4749 the pragma applies. Note that in the case of accept formals, the pragma
4750 Unreferenced may appear immediately after the keyword @code{do} which
4751 allows the indication of whether or not accept formals are referenced
4752 or not to be given individually for each accept statement.
4754 The left hand side of an assignment does not count as a reference for the
4755 purpose of this pragma. Thus it is fine to assign to an entity for which
4756 pragma Unreferenced is given.
4758 Note that if a warning is desired for all calls to a given subprogram,
4759 regardless of whether they occur in the same unit as the subprogram
4760 declaration, then this pragma should not be used (calls from another
4761 unit would not be flagged); pragma Obsolescent can be used instead
4762 for this purpose, see @xref{Pragma Obsolescent}.
4764 The second form of pragma @code{Unreferenced} is used within a context
4765 clause. In this case the arguments must be unit names of units previously
4766 mentioned in @code{with} clauses (similar to the usage of pragma
4767 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4768 units and unreferenced entities within these units.
4770 @node Pragma Unreferenced_Objects
4771 @unnumberedsec Pragma Unreferenced_Objects
4772 @findex Unreferenced_Objects
4773 @cindex Warnings, unreferenced
4777 @smallexample @c ada
4778 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4782 This pragma signals that for the types or subtypes whose names are
4783 listed, objects which are declared with one of these types or subtypes may
4784 not be referenced, and if no references appear, no warnings are given.
4786 This is particularly useful for objects which are declared solely for their
4787 initialization and finalization effect. Such variables are sometimes referred
4788 to as RAII variables (Resource Acquisition Is Initialization). Using this
4789 pragma on the relevant type (most typically a limited controlled type), the
4790 compiler will automatically suppress unwanted warnings about these variables
4791 not being referenced.
4793 @node Pragma Unreserve_All_Interrupts
4794 @unnumberedsec Pragma Unreserve_All_Interrupts
4795 @findex Unreserve_All_Interrupts
4799 @smallexample @c ada
4800 pragma Unreserve_All_Interrupts;
4804 Normally certain interrupts are reserved to the implementation. Any attempt
4805 to attach an interrupt causes Program_Error to be raised, as described in
4806 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4807 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
4808 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4809 interrupt execution.
4811 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4812 a program, then all such interrupts are unreserved. This allows the
4813 program to handle these interrupts, but disables their standard
4814 functions. For example, if this pragma is used, then pressing
4815 @kbd{Ctrl-C} will not automatically interrupt execution. However,
4816 a program can then handle the @code{SIGINT} interrupt as it chooses.
4818 For a full list of the interrupts handled in a specific implementation,
4819 see the source code for the spec of @code{Ada.Interrupts.Names} in
4820 file @file{a-intnam.ads}. This is a target dependent file that contains the
4821 list of interrupts recognized for a given target. The documentation in
4822 this file also specifies what interrupts are affected by the use of
4823 the @code{Unreserve_All_Interrupts} pragma.
4825 For a more general facility for controlling what interrupts can be
4826 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4827 of the @code{Unreserve_All_Interrupts} pragma.
4829 @node Pragma Unsuppress
4830 @unnumberedsec Pragma Unsuppress
4835 @smallexample @c ada
4836 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4840 This pragma undoes the effect of a previous pragma @code{Suppress}. If
4841 there is no corresponding pragma @code{Suppress} in effect, it has no
4842 effect. The range of the effect is the same as for pragma
4843 @code{Suppress}. The meaning of the arguments is identical to that used
4844 in pragma @code{Suppress}.
4846 One important application is to ensure that checks are on in cases where
4847 code depends on the checks for its correct functioning, so that the code
4848 will compile correctly even if the compiler switches are set to suppress
4851 @node Pragma Use_VADS_Size
4852 @unnumberedsec Pragma Use_VADS_Size
4853 @cindex @code{Size}, VADS compatibility
4854 @findex Use_VADS_Size
4858 @smallexample @c ada
4859 pragma Use_VADS_Size;
4863 This is a configuration pragma. In a unit to which it applies, any use
4864 of the 'Size attribute is automatically interpreted as a use of the
4865 'VADS_Size attribute. Note that this may result in incorrect semantic
4866 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
4867 the handling of existing code which depends on the interpretation of Size
4868 as implemented in the VADS compiler. See description of the VADS_Size
4869 attribute for further details.
4871 @node Pragma Validity_Checks
4872 @unnumberedsec Pragma Validity_Checks
4873 @findex Validity_Checks
4877 @smallexample @c ada
4878 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4882 This pragma is used in conjunction with compiler switches to control the
4883 built-in validity checking provided by GNAT@. The compiler switches, if set
4884 provide an initial setting for the switches, and this pragma may be used
4885 to modify these settings, or the settings may be provided entirely by
4886 the use of the pragma. This pragma can be used anywhere that a pragma
4887 is legal, including use as a configuration pragma (including use in
4888 the @file{gnat.adc} file).
4890 The form with a string literal specifies which validity options are to be
4891 activated. The validity checks are first set to include only the default
4892 reference manual settings, and then a string of letters in the string
4893 specifies the exact set of options required. The form of this string
4894 is exactly as described for the @option{-gnatVx} compiler switch (see the
4895 GNAT users guide for details). For example the following two methods
4896 can be used to enable validity checking for mode @code{in} and
4897 @code{in out} subprogram parameters:
4901 @smallexample @c ada
4902 pragma Validity_Checks ("im");
4907 gcc -c -gnatVim @dots{}
4912 The form ALL_CHECKS activates all standard checks (its use is equivalent
4913 to the use of the @code{gnatva} switch.
4915 The forms with @code{Off} and @code{On}
4916 can be used to temporarily disable validity checks
4917 as shown in the following example:
4919 @smallexample @c ada
4923 pragma Validity_Checks ("c"); -- validity checks for copies
4924 pragma Validity_Checks (Off); -- turn off validity checks
4925 A := B; -- B will not be validity checked
4926 pragma Validity_Checks (On); -- turn validity checks back on
4927 A := C; -- C will be validity checked
4930 @node Pragma Volatile
4931 @unnumberedsec Pragma Volatile
4936 @smallexample @c ada
4937 pragma Volatile (LOCAL_NAME);
4941 This pragma is defined by the Ada Reference Manual, and the GNAT
4942 implementation is fully conformant with this definition. The reason it
4943 is mentioned in this section is that a pragma of the same name was supplied
4944 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
4945 implementation of pragma Volatile is upwards compatible with the
4946 implementation in DEC Ada 83.
4948 @node Pragma Warnings
4949 @unnumberedsec Pragma Warnings
4954 @smallexample @c ada
4955 pragma Warnings (On | Off);
4956 pragma Warnings (On | Off, LOCAL_NAME);
4957 pragma Warnings (static_string_EXPRESSION);
4958 pragma Warnings (On | Off, static_string_EXPRESSION);
4962 Normally warnings are enabled, with the output being controlled by
4963 the command line switch. Warnings (@code{Off}) turns off generation of
4964 warnings until a Warnings (@code{On}) is encountered or the end of the
4965 current unit. If generation of warnings is turned off using this
4966 pragma, then no warning messages are output, regardless of the
4967 setting of the command line switches.
4969 The form with a single argument may be used as a configuration pragma.
4971 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
4972 the specified entity. This suppression is effective from the point where
4973 it occurs till the end of the extended scope of the variable (similar to
4974 the scope of @code{Suppress}).
4976 The form with a single static_string_EXPRESSION argument provides more precise
4977 control over which warnings are active. The string is a list of letters
4978 specifying which warnings are to be activated and which deactivated. The
4979 code for these letters is the same as the string used in the command
4980 line switch controlling warnings. The following is a brief summary. For
4981 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
4985 a turn on all optional warnings (except d h l .o)
4986 A turn off all optional warnings
4987 .a* turn on warnings for failing assertions
4988 .A turn off warnings for failing assertions
4989 b turn on warnings for bad fixed value (not multiple of small)
4990 B* turn off warnings for bad fixed value (not multiple of small)
4991 c turn on warnings for constant conditional
4992 C* turn off warnings for constant conditional
4993 .c turn on warnings for unrepped components
4994 .C* turn off warnings for unrepped components
4995 d turn on warnings for implicit dereference
4996 D* turn off warnings for implicit dereference
4997 e treat all warnings as errors
4998 f turn on warnings for unreferenced formal
4999 F* turn off warnings for unreferenced formal
5000 g* turn on warnings for unrecognized pragma
5001 G turn off warnings for unrecognized pragma
5002 h turn on warnings for hiding variable
5003 H* turn off warnings for hiding variable
5004 i* turn on warnings for implementation unit
5005 I turn off warnings for implementation unit
5006 j turn on warnings for obsolescent (annex J) feature
5007 J* turn off warnings for obsolescent (annex J) feature
5008 k turn on warnings on constant variable
5009 K* turn off warnings on constant variable
5010 l turn on warnings for missing elaboration pragma
5011 L* turn off warnings for missing elaboration pragma
5012 m turn on warnings for variable assigned but not read
5013 M* turn off warnings for variable assigned but not read
5014 n* normal warning mode (cancels -gnatws/-gnatwe)
5015 o* turn on warnings for address clause overlay
5016 O turn off warnings for address clause overlay
5017 .o turn on warnings for out parameters assigned but not read
5018 .O* turn off warnings for out parameters assigned but not read
5019 p turn on warnings for ineffective pragma Inline in frontend
5020 P* turn off warnings for ineffective pragma Inline in frontend
5021 q* turn on warnings for questionable missing parentheses
5022 Q turn off warnings for questionable missing parentheses
5023 r turn on warnings for redundant construct
5024 R* turn off warnings for redundant construct
5025 .r turn on warnings for object renaming function
5026 .R* turn off warnings for object renaming function
5027 s suppress all warnings
5028 t turn on warnings for tracking deleted code
5029 T* turn off warnings for tracking deleted code
5030 u turn on warnings for unused entity
5031 U* turn off warnings for unused entity
5032 v* turn on warnings for unassigned variable
5033 V turn off warnings for unassigned variable
5034 w* turn on warnings for wrong low bound assumption
5035 W turn off warnings for wrong low bound assumption
5036 x* turn on warnings for export/import
5037 X turn off warnings for export/import
5038 .x turn on warnings for non-local exceptions
5039 .X* turn off warnings for non-local exceptions
5040 y* turn on warnings for Ada 2005 incompatibility
5041 Y turn off warnings for Ada 2005 incompatibility
5042 z* turn on convention/size/align warnings for unchecked conversion
5043 Z turn off convention/size/align warnings for unchecked conversion
5044 * indicates default in above list
5048 The specified warnings will be in effect until the end of the program
5049 or another pragma Warnings is encountered. The effect of the pragma is
5050 cumulative. Initially the set of warnings is the standard default set
5051 as possibly modified by compiler switches. Then each pragma Warning
5052 modifies this set of warnings as specified. This form of the pragma may
5053 also be used as a configuration pragma.
5055 The fourth form, with an On|Off parameter and a string, is used to
5056 control individual messages, based on their text. The string argument
5057 is a pattern that is used to match against the text of individual
5058 warning messages (not including the initial "warnings: " tag).
5060 The pattern may contain asterisks which match zero or more characters in
5061 the message. For example, you can use
5062 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5063 message @code{warning: 960 bits of "a" unused}. No other regular
5064 expression notations are permitted. All characters other than asterisk in
5065 these three specific cases are treated as literal characters in the match.
5067 There are two ways to use this pragma. The OFF form can be used as a
5068 configuration pragma. The effect is to suppress all warnings (if any)
5069 that match the pattern string throughout the compilation.
5071 The second usage is to suppress a warning locally, and in this case, two
5072 pragmas must appear in sequence:
5074 @smallexample @c ada
5075 pragma Warnings (Off, Pattern);
5076 @dots{} code where given warning is to be suppressed
5077 pragma Warnings (On, Pattern);
5081 In this usage, the pattern string must match in the Off and On pragmas,
5082 and at least one matching warning must be suppressed.
5084 @node Pragma Weak_External
5085 @unnumberedsec Pragma Weak_External
5086 @findex Weak_External
5090 @smallexample @c ada
5091 pragma Weak_External ([Entity =>] LOCAL_NAME);
5095 @var{LOCAL_NAME} must refer to an object that is declared at the library
5096 level. This pragma specifies that the given entity should be marked as a
5097 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5098 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5099 of a regular symbol, that is to say a symbol that does not have to be
5100 resolved by the linker if used in conjunction with a pragma Import.
5102 When a weak symbol is not resolved by the linker, its address is set to
5103 zero. This is useful in writing interfaces to external modules that may
5104 or may not be linked in the final executable, for example depending on
5105 configuration settings.
5107 If a program references at run time an entity to which this pragma has been
5108 applied, and the corresponding symbol was not resolved at link time, then
5109 the execution of the program is erroneous. It is not erroneous to take the
5110 Address of such an entity, for example to guard potential references,
5111 as shown in the example below.
5113 Some file formats do not support weak symbols so not all target machines
5114 support this pragma.
5116 @smallexample @c ada
5117 -- Example of the use of pragma Weak_External
5119 package External_Module is
5121 pragma Import (C, key);
5122 pragma Weak_External (key);
5123 function Present return boolean;
5124 end External_Module;
5126 with System; use System;
5127 package body External_Module is
5128 function Present return boolean is
5130 return key'Address /= System.Null_Address;
5132 end External_Module;
5135 @node Pragma Wide_Character_Encoding
5136 @unnumberedsec Pragma Wide_Character_Encoding
5137 @findex Wide_Character_Encoding
5141 @smallexample @c ada
5142 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5146 This pragma specifies the wide character encoding to be used in program
5147 source text appearing subsequently. It is a configuration pragma, but may
5148 also be used at any point that a pragma is allowed, and it is permissible
5149 to have more than one such pragma in a file, allowing multiple encodings
5150 to appear within the same file.
5152 The argument can be an identifier or a character literal. In the identifier
5153 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5154 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5155 case it is correspondingly one of the characters @samp{h}, @samp{u},
5156 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5158 Note that when the pragma is used within a file, it affects only the
5159 encoding within that file, and does not affect withed units, specs,
5162 @node Implementation Defined Attributes
5163 @chapter Implementation Defined Attributes
5164 Ada defines (throughout the Ada reference manual,
5165 summarized in Annex K),
5166 a set of attributes that provide useful additional functionality in all
5167 areas of the language. These language defined attributes are implemented
5168 in GNAT and work as described in the Ada Reference Manual.
5170 In addition, Ada allows implementations to define additional
5171 attributes whose meaning is defined by the implementation. GNAT provides
5172 a number of these implementation-dependent attributes which can be used
5173 to extend and enhance the functionality of the compiler. This section of
5174 the GNAT reference manual describes these additional attributes.
5176 Note that any program using these attributes may not be portable to
5177 other compilers (although GNAT implements this set of attributes on all
5178 platforms). Therefore if portability to other compilers is an important
5179 consideration, you should minimize the use of these attributes.
5190 * Default_Bit_Order::
5200 * Has_Access_Values::
5201 * Has_Discriminants::
5208 * Max_Interrupt_Priority::
5210 * Maximum_Alignment::
5215 * Passed_By_Reference::
5228 * Unconstrained_Array::
5229 * Universal_Literal_String::
5230 * Unrestricted_Access::
5238 @unnumberedsec Abort_Signal
5239 @findex Abort_Signal
5241 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5242 prefix) provides the entity for the special exception used to signal
5243 task abort or asynchronous transfer of control. Normally this attribute
5244 should only be used in the tasking runtime (it is highly peculiar, and
5245 completely outside the normal semantics of Ada, for a user program to
5246 intercept the abort exception).
5249 @unnumberedsec Address_Size
5250 @cindex Size of @code{Address}
5251 @findex Address_Size
5253 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5254 prefix) is a static constant giving the number of bits in an
5255 @code{Address}. It is the same value as System.Address'Size,
5256 but has the advantage of being static, while a direct
5257 reference to System.Address'Size is non-static because Address
5261 @unnumberedsec Asm_Input
5264 The @code{Asm_Input} attribute denotes a function that takes two
5265 parameters. The first is a string, the second is an expression of the
5266 type designated by the prefix. The first (string) argument is required
5267 to be a static expression, and is the constraint for the parameter,
5268 (e.g.@: what kind of register is required). The second argument is the
5269 value to be used as the input argument. The possible values for the
5270 constant are the same as those used in the RTL, and are dependent on
5271 the configuration file used to built the GCC back end.
5272 @ref{Machine Code Insertions}
5275 @unnumberedsec Asm_Output
5278 The @code{Asm_Output} attribute denotes a function that takes two
5279 parameters. The first is a string, the second is the name of a variable
5280 of the type designated by the attribute prefix. The first (string)
5281 argument is required to be a static expression and designates the
5282 constraint for the parameter (e.g.@: what kind of register is
5283 required). The second argument is the variable to be updated with the
5284 result. The possible values for constraint are the same as those used in
5285 the RTL, and are dependent on the configuration file used to build the
5286 GCC back end. If there are no output operands, then this argument may
5287 either be omitted, or explicitly given as @code{No_Output_Operands}.
5288 @ref{Machine Code Insertions}
5291 @unnumberedsec AST_Entry
5295 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5296 the name of an entry, it yields a value of the predefined type AST_Handler
5297 (declared in the predefined package System, as extended by the use of
5298 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5299 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5300 Language Reference Manual}, section 9.12a.
5305 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5306 offset within the storage unit (byte) that contains the first bit of
5307 storage allocated for the object. The value of this attribute is of the
5308 type @code{Universal_Integer}, and is always a non-negative number not
5309 exceeding the value of @code{System.Storage_Unit}.
5311 For an object that is a variable or a constant allocated in a register,
5312 the value is zero. (The use of this attribute does not force the
5313 allocation of a variable to memory).
5315 For an object that is a formal parameter, this attribute applies
5316 to either the matching actual parameter or to a copy of the
5317 matching actual parameter.
5319 For an access object the value is zero. Note that
5320 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5321 designated object. Similarly for a record component
5322 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5323 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5324 are subject to index checks.
5326 This attribute is designed to be compatible with the DEC Ada 83 definition
5327 and implementation of the @code{Bit} attribute.
5330 @unnumberedsec Bit_Position
5331 @findex Bit_Position
5333 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5334 of the fields of the record type, yields the bit
5335 offset within the record contains the first bit of
5336 storage allocated for the object. The value of this attribute is of the
5337 type @code{Universal_Integer}. The value depends only on the field
5338 @var{C} and is independent of the alignment of
5339 the containing record @var{R}.
5342 @unnumberedsec Code_Address
5343 @findex Code_Address
5344 @cindex Subprogram address
5345 @cindex Address of subprogram code
5348 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5349 intended effect seems to be to provide
5350 an address value which can be used to call the subprogram by means of
5351 an address clause as in the following example:
5353 @smallexample @c ada
5354 procedure K is @dots{}
5357 for L'Address use K'Address;
5358 pragma Import (Ada, L);
5362 A call to @code{L} is then expected to result in a call to @code{K}@.
5363 In Ada 83, where there were no access-to-subprogram values, this was
5364 a common work-around for getting the effect of an indirect call.
5365 GNAT implements the above use of @code{Address} and the technique
5366 illustrated by the example code works correctly.
5368 However, for some purposes, it is useful to have the address of the start
5369 of the generated code for the subprogram. On some architectures, this is
5370 not necessarily the same as the @code{Address} value described above.
5371 For example, the @code{Address} value may reference a subprogram
5372 descriptor rather than the subprogram itself.
5374 The @code{'Code_Address} attribute, which can only be applied to
5375 subprogram entities, always returns the address of the start of the
5376 generated code of the specified subprogram, which may or may not be
5377 the same value as is returned by the corresponding @code{'Address}
5380 @node Default_Bit_Order
5381 @unnumberedsec Default_Bit_Order
5383 @cindex Little endian
5384 @findex Default_Bit_Order
5386 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5387 permissible prefix), provides the value @code{System.Default_Bit_Order}
5388 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5389 @code{Low_Order_First}). This is used to construct the definition of
5390 @code{Default_Bit_Order} in package @code{System}.
5393 @unnumberedsec Elaborated
5396 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5397 value is a Boolean which indicates whether or not the given unit has been
5398 elaborated. This attribute is primarily intended for internal use by the
5399 generated code for dynamic elaboration checking, but it can also be used
5400 in user programs. The value will always be True once elaboration of all
5401 units has been completed. An exception is for units which need no
5402 elaboration, the value is always False for such units.
5405 @unnumberedsec Elab_Body
5408 This attribute can only be applied to a program unit name. It returns
5409 the entity for the corresponding elaboration procedure for elaborating
5410 the body of the referenced unit. This is used in the main generated
5411 elaboration procedure by the binder and is not normally used in any
5412 other context. However, there may be specialized situations in which it
5413 is useful to be able to call this elaboration procedure from Ada code,
5414 e.g.@: if it is necessary to do selective re-elaboration to fix some
5418 @unnumberedsec Elab_Spec
5421 This attribute can only be applied to a program unit name. It returns
5422 the entity for the corresponding elaboration procedure for elaborating
5423 the spec of the referenced unit. This is used in the main
5424 generated elaboration procedure by the binder and is not normally used
5425 in any other context. However, there may be specialized situations in
5426 which it is useful to be able to call this elaboration procedure from
5427 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5432 @cindex Ada 83 attributes
5435 The @code{Emax} attribute is provided for compatibility with Ada 83. See
5436 the Ada 83 reference manual for an exact description of the semantics of
5440 @unnumberedsec Enabled
5443 The @code{Enabled} attribute allows an application program to check at compile
5444 time to see if the designated check is currently enabled. The prefix is a
5445 simple identifier, referencing any predefined check name (other than
5446 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5447 no argument is given for the attribute, the check is for the general state
5448 of the check, if an argument is given, then it is an entity name, and the
5449 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5450 given naming the entity (if not, then the argument is ignored).
5452 Note that instantiations inherit the check status at the point of the
5453 instantiation, so a useful idiom is to have a library package that
5454 introduces a check name with @code{pragma Check_Name}, and then contains
5455 generic packages or subprograms which use the @code{Enabled} attribute
5456 to see if the check is enabled. A user of this package can then issue
5457 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5458 the package or subprogram, controlling whether the check will be present.
5461 @unnumberedsec Enum_Rep
5462 @cindex Representation of enums
5465 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5466 function with the following spec:
5468 @smallexample @c ada
5469 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5470 return @i{Universal_Integer};
5474 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5475 enumeration type or to a non-overloaded enumeration
5476 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
5477 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5478 enumeration literal or object.
5480 The function returns the representation value for the given enumeration
5481 value. This will be equal to value of the @code{Pos} attribute in the
5482 absence of an enumeration representation clause. This is a static
5483 attribute (i.e.@: the result is static if the argument is static).
5485 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5486 in which case it simply returns the integer value. The reason for this
5487 is to allow it to be used for @code{(<>)} discrete formal arguments in
5488 a generic unit that can be instantiated with either enumeration types
5489 or integer types. Note that if @code{Enum_Rep} is used on a modular
5490 type whose upper bound exceeds the upper bound of the largest signed
5491 integer type, and the argument is a variable, so that the universal
5492 integer calculation is done at run time, then the call to @code{Enum_Rep}
5493 may raise @code{Constraint_Error}.
5496 @unnumberedsec Enum_Val
5497 @cindex Representation of enums
5500 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5501 function with the following spec:
5503 @smallexample @c ada
5504 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5505 return @var{S}'Base};
5509 The function returns the enumeration value whose representation matches the
5510 argument, or raises Constraint_Error if no enumeration literal of the type
5511 has the matching value.
5512 This will be equal to value of the @code{Val} attribute in the
5513 absence of an enumeration representation clause. This is a static
5514 attribute (i.e.@: the result is static if the argument is static).
5517 @unnumberedsec Epsilon
5518 @cindex Ada 83 attributes
5521 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
5522 the Ada 83 reference manual for an exact description of the semantics of
5526 @unnumberedsec Fixed_Value
5529 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5530 function with the following specification:
5532 @smallexample @c ada
5533 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5538 The value returned is the fixed-point value @var{V} such that
5540 @smallexample @c ada
5541 @var{V} = Arg * @var{S}'Small
5545 The effect is thus similar to first converting the argument to the
5546 integer type used to represent @var{S}, and then doing an unchecked
5547 conversion to the fixed-point type. The difference is
5548 that there are full range checks, to ensure that the result is in range.
5549 This attribute is primarily intended for use in implementation of the
5550 input-output functions for fixed-point values.
5552 @node Has_Access_Values
5553 @unnumberedsec Has_Access_Values
5554 @cindex Access values, testing for
5555 @findex Has_Access_Values
5557 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5558 is a Boolean value which is True if the is an access type, or is a composite
5559 type with a component (at any nesting depth) that is an access type, and is
5561 The intended use of this attribute is in conjunction with generic
5562 definitions. If the attribute is applied to a generic private type, it
5563 indicates whether or not the corresponding actual type has access values.
5565 @node Has_Discriminants
5566 @unnumberedsec Has_Discriminants
5567 @cindex Discriminants, testing for
5568 @findex Has_Discriminants
5570 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5571 is a Boolean value which is True if the type has discriminants, and False
5572 otherwise. The intended use of this attribute is in conjunction with generic
5573 definitions. If the attribute is applied to a generic private type, it
5574 indicates whether or not the corresponding actual type has discriminants.
5580 The @code{Img} attribute differs from @code{Image} in that it may be
5581 applied to objects as well as types, in which case it gives the
5582 @code{Image} for the subtype of the object. This is convenient for
5585 @smallexample @c ada
5586 Put_Line ("X = " & X'Img);
5590 has the same meaning as the more verbose:
5592 @smallexample @c ada
5593 Put_Line ("X = " & @var{T}'Image (X));
5597 where @var{T} is the (sub)type of the object @code{X}.
5600 @unnumberedsec Integer_Value
5601 @findex Integer_Value
5603 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5604 function with the following spec:
5606 @smallexample @c ada
5607 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5612 The value returned is the integer value @var{V}, such that
5614 @smallexample @c ada
5615 Arg = @var{V} * @var{T}'Small
5619 where @var{T} is the type of @code{Arg}.
5620 The effect is thus similar to first doing an unchecked conversion from
5621 the fixed-point type to its corresponding implementation type, and then
5622 converting the result to the target integer type. The difference is
5623 that there are full range checks, to ensure that the result is in range.
5624 This attribute is primarily intended for use in implementation of the
5625 standard input-output functions for fixed-point values.
5628 @unnumberedsec Invalid_Value
5629 @findex Invalid_Value
5631 For every scalar type S, S'Invalid_Value returns an undefined value of the
5632 type. If possible this value is an invalid representation for the type. The
5633 value returned is identical to the value used to initialize an otherwise
5634 uninitialized value of the type if pragma Initialize_Scalars is used,
5635 including the ability to modify the value with the binder -Sxx flag and
5636 relevant environment variables at run time.
5639 @unnumberedsec Large
5640 @cindex Ada 83 attributes
5643 The @code{Large} attribute is provided for compatibility with Ada 83. See
5644 the Ada 83 reference manual for an exact description of the semantics of
5648 @unnumberedsec Machine_Size
5649 @findex Machine_Size
5651 This attribute is identical to the @code{Object_Size} attribute. It is
5652 provided for compatibility with the DEC Ada 83 attribute of this name.
5655 @unnumberedsec Mantissa
5656 @cindex Ada 83 attributes
5659 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
5660 the Ada 83 reference manual for an exact description of the semantics of
5663 @node Max_Interrupt_Priority
5664 @unnumberedsec Max_Interrupt_Priority
5665 @cindex Interrupt priority, maximum
5666 @findex Max_Interrupt_Priority
5668 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5669 permissible prefix), provides the same value as
5670 @code{System.Max_Interrupt_Priority}.
5673 @unnumberedsec Max_Priority
5674 @cindex Priority, maximum
5675 @findex Max_Priority
5677 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5678 prefix) provides the same value as @code{System.Max_Priority}.
5680 @node Maximum_Alignment
5681 @unnumberedsec Maximum_Alignment
5682 @cindex Alignment, maximum
5683 @findex Maximum_Alignment
5685 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5686 permissible prefix) provides the maximum useful alignment value for the
5687 target. This is a static value that can be used to specify the alignment
5688 for an object, guaranteeing that it is properly aligned in all
5691 @node Mechanism_Code
5692 @unnumberedsec Mechanism_Code
5693 @cindex Return values, passing mechanism
5694 @cindex Parameters, passing mechanism
5695 @findex Mechanism_Code
5697 @code{@var{function}'Mechanism_Code} yields an integer code for the
5698 mechanism used for the result of function, and
5699 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5700 used for formal parameter number @var{n} (a static integer value with 1
5701 meaning the first parameter) of @var{subprogram}. The code returned is:
5709 by descriptor (default descriptor class)
5711 by descriptor (UBS: unaligned bit string)
5713 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5715 by descriptor (UBA: unaligned bit array)
5717 by descriptor (S: string, also scalar access type parameter)
5719 by descriptor (SB: string with arbitrary bounds)
5721 by descriptor (A: contiguous array)
5723 by descriptor (NCA: non-contiguous array)
5727 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5730 @node Null_Parameter
5731 @unnumberedsec Null_Parameter
5732 @cindex Zero address, passing
5733 @findex Null_Parameter
5735 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5736 type or subtype @var{T} allocated at machine address zero. The attribute
5737 is allowed only as the default expression of a formal parameter, or as
5738 an actual expression of a subprogram call. In either case, the
5739 subprogram must be imported.
5741 The identity of the object is represented by the address zero in the
5742 argument list, independent of the passing mechanism (explicit or
5745 This capability is needed to specify that a zero address should be
5746 passed for a record or other composite object passed by reference.
5747 There is no way of indicating this without the @code{Null_Parameter}
5751 @unnumberedsec Object_Size
5752 @cindex Size, used for objects
5755 The size of an object is not necessarily the same as the size of the type
5756 of an object. This is because by default object sizes are increased to be
5757 a multiple of the alignment of the object. For example,
5758 @code{Natural'Size} is
5759 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5760 Similarly, a record containing an integer and a character:
5762 @smallexample @c ada
5770 will have a size of 40 (that is @code{Rec'Size} will be 40. The
5771 alignment will be 4, because of the
5772 integer field, and so the default size of record objects for this type
5773 will be 64 (8 bytes).
5777 @cindex Capturing Old values
5778 @cindex Postconditions
5780 The attribute Prefix'Old can be used within a
5781 subprogram to refer to the value of the prefix on entry. So for
5782 example if you have an argument of a record type X called Arg1,
5783 you can refer to Arg1.Field'Old which yields the value of
5784 Arg1.Field on entry. The implementation simply involves generating
5785 an object declaration which captures the value on entry. Any
5786 prefix is allowed except one of a limited type (since limited
5787 types cannot be copied to capture their values) or a local variable
5788 (since it does not exist at subprogram entry time).
5790 The following example shows the use of 'Old to implement
5791 a test of a postcondition:
5793 @smallexample @c ada
5804 package body Old_Pkg is
5805 Count : Natural := 0;
5809 ... code manipulating the value of Count
5811 pragma Assert (Count = Count'Old + 1);
5817 Note that it is allowed to apply 'Old to a constant entity, but this will
5818 result in a warning, since the old and new values will always be the same.
5820 @node Passed_By_Reference
5821 @unnumberedsec Passed_By_Reference
5822 @cindex Parameters, when passed by reference
5823 @findex Passed_By_Reference
5825 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5826 a value of type @code{Boolean} value that is @code{True} if the type is
5827 normally passed by reference and @code{False} if the type is normally
5828 passed by copy in calls. For scalar types, the result is always @code{False}
5829 and is static. For non-scalar types, the result is non-static.
5832 @unnumberedsec Pool_Address
5833 @cindex Parameters, when passed by reference
5834 @findex Pool_Address
5836 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
5837 of X within its storage pool. This is the same as
5838 @code{@var{X}'Address}, except that for an unconstrained array whose
5839 bounds are allocated just before the first component,
5840 @code{@var{X}'Pool_Address} returns the address of those bounds,
5841 whereas @code{@var{X}'Address} returns the address of the first
5844 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
5845 the object is allocated'', which could be a user-defined storage pool,
5846 the global heap, on the stack, or in a static memory area. For an
5847 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
5848 what is passed to @code{Allocate} and returned from @code{Deallocate}.
5851 @unnumberedsec Range_Length
5852 @findex Range_Length
5854 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5855 the number of values represented by the subtype (zero for a null
5856 range). The result is static for static subtypes. @code{Range_Length}
5857 applied to the index subtype of a one dimensional array always gives the
5858 same result as @code{Range} applied to the array itself.
5861 @unnumberedsec Safe_Emax
5862 @cindex Ada 83 attributes
5865 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
5866 the Ada 83 reference manual for an exact description of the semantics of
5870 @unnumberedsec Safe_Large
5871 @cindex Ada 83 attributes
5874 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
5875 the Ada 83 reference manual for an exact description of the semantics of
5879 @unnumberedsec Small
5880 @cindex Ada 83 attributes
5883 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5885 GNAT also allows this attribute to be applied to floating-point types
5886 for compatibility with Ada 83. See
5887 the Ada 83 reference manual for an exact description of the semantics of
5888 this attribute when applied to floating-point types.
5891 @unnumberedsec Storage_Unit
5892 @findex Storage_Unit
5894 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5895 prefix) provides the same value as @code{System.Storage_Unit}.
5898 @unnumberedsec Stub_Type
5901 The GNAT implementation of remote access-to-classwide types is
5902 organized as described in AARM section E.4 (20.t): a value of an RACW type
5903 (designating a remote object) is represented as a normal access
5904 value, pointing to a "stub" object which in turn contains the
5905 necessary information to contact the designated remote object. A
5906 call on any dispatching operation of such a stub object does the
5907 remote call, if necessary, using the information in the stub object
5908 to locate the target partition, etc.
5910 For a prefix @code{T} that denotes a remote access-to-classwide type,
5911 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5913 By construction, the layout of @code{T'Stub_Type} is identical to that of
5914 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5915 unit @code{System.Partition_Interface}. Use of this attribute will create
5916 an implicit dependency on this unit.
5919 @unnumberedsec Target_Name
5922 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5923 prefix) provides a static string value that identifies the target
5924 for the current compilation. For GCC implementations, this is the
5925 standard gcc target name without the terminating slash (for
5926 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5932 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5933 provides the same value as @code{System.Tick},
5936 @unnumberedsec To_Address
5939 The @code{System'To_Address}
5940 (@code{System} is the only permissible prefix)
5941 denotes a function identical to
5942 @code{System.Storage_Elements.To_Address} except that
5943 it is a static attribute. This means that if its argument is
5944 a static expression, then the result of the attribute is a
5945 static expression. The result is that such an expression can be
5946 used in contexts (e.g.@: preelaborable packages) which require a
5947 static expression and where the function call could not be used
5948 (since the function call is always non-static, even if its
5949 argument is static).
5952 @unnumberedsec Type_Class
5955 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5956 the value of the type class for the full type of @var{type}. If
5957 @var{type} is a generic formal type, the value is the value for the
5958 corresponding actual subtype. The value of this attribute is of type
5959 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5961 @smallexample @c ada
5963 (Type_Class_Enumeration,
5965 Type_Class_Fixed_Point,
5966 Type_Class_Floating_Point,
5971 Type_Class_Address);
5975 Protected types yield the value @code{Type_Class_Task}, which thus
5976 applies to all concurrent types. This attribute is designed to
5977 be compatible with the DEC Ada 83 attribute of the same name.
5980 @unnumberedsec UET_Address
5983 The @code{UET_Address} attribute can only be used for a prefix which
5984 denotes a library package. It yields the address of the unit exception
5985 table when zero cost exception handling is used. This attribute is
5986 intended only for use within the GNAT implementation. See the unit
5987 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5988 for details on how this attribute is used in the implementation.
5990 @node Unconstrained_Array
5991 @unnumberedsec Unconstrained_Array
5992 @findex Unconstrained_Array
5994 The @code{Unconstrained_Array} attribute can be used with a prefix that
5995 denotes any type or subtype. It is a static attribute that yields
5996 @code{True} if the prefix designates an unconstrained array,
5997 and @code{False} otherwise. In a generic instance, the result is
5998 still static, and yields the result of applying this test to the
6001 @node Universal_Literal_String
6002 @unnumberedsec Universal_Literal_String
6003 @cindex Named numbers, representation of
6004 @findex Universal_Literal_String
6006 The prefix of @code{Universal_Literal_String} must be a named
6007 number. The static result is the string consisting of the characters of
6008 the number as defined in the original source. This allows the user
6009 program to access the actual text of named numbers without intermediate
6010 conversions and without the need to enclose the strings in quotes (which
6011 would preclude their use as numbers). This is used internally for the
6012 construction of values of the floating-point attributes from the file
6013 @file{ttypef.ads}, but may also be used by user programs.
6015 For example, the following program prints the first 50 digits of pi:
6017 @smallexample @c ada
6018 with Text_IO; use Text_IO;
6022 Put (Ada.Numerics.Pi'Universal_Literal_String);
6026 @node Unrestricted_Access
6027 @unnumberedsec Unrestricted_Access
6028 @cindex @code{Access}, unrestricted
6029 @findex Unrestricted_Access
6031 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6032 except that all accessibility and aliased view checks are omitted. This
6033 is a user-beware attribute. It is similar to
6034 @code{Address}, for which it is a desirable replacement where the value
6035 desired is an access type. In other words, its effect is identical to
6036 first applying the @code{Address} attribute and then doing an unchecked
6037 conversion to a desired access type. In GNAT, but not necessarily in
6038 other implementations, the use of static chains for inner level
6039 subprograms means that @code{Unrestricted_Access} applied to a
6040 subprogram yields a value that can be called as long as the subprogram
6041 is in scope (normal Ada accessibility rules restrict this usage).
6043 It is possible to use @code{Unrestricted_Access} for any type, but care
6044 must be exercised if it is used to create pointers to unconstrained
6045 objects. In this case, the resulting pointer has the same scope as the
6046 context of the attribute, and may not be returned to some enclosing
6047 scope. For instance, a function cannot use @code{Unrestricted_Access}
6048 to create a unconstrained pointer and then return that value to the
6052 @unnumberedsec VADS_Size
6053 @cindex @code{Size}, VADS compatibility
6056 The @code{'VADS_Size} attribute is intended to make it easier to port
6057 legacy code which relies on the semantics of @code{'Size} as implemented
6058 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6059 same semantic interpretation. In particular, @code{'VADS_Size} applied
6060 to a predefined or other primitive type with no Size clause yields the
6061 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6062 typical machines). In addition @code{'VADS_Size} applied to an object
6063 gives the result that would be obtained by applying the attribute to
6064 the corresponding type.
6067 @unnumberedsec Value_Size
6068 @cindex @code{Size}, setting for not-first subtype
6070 @code{@var{type}'Value_Size} is the number of bits required to represent
6071 a value of the given subtype. It is the same as @code{@var{type}'Size},
6072 but, unlike @code{Size}, may be set for non-first subtypes.
6075 @unnumberedsec Wchar_T_Size
6076 @findex Wchar_T_Size
6077 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6078 prefix) provides the size in bits of the C @code{wchar_t} type
6079 primarily for constructing the definition of this type in
6080 package @code{Interfaces.C}.
6083 @unnumberedsec Word_Size
6085 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6086 prefix) provides the value @code{System.Word_Size}.
6088 @c ------------------------
6089 @node Implementation Advice
6090 @chapter Implementation Advice
6092 The main text of the Ada Reference Manual describes the required
6093 behavior of all Ada compilers, and the GNAT compiler conforms to
6096 In addition, there are sections throughout the Ada Reference Manual headed
6097 by the phrase ``Implementation advice''. These sections are not normative,
6098 i.e., they do not specify requirements that all compilers must
6099 follow. Rather they provide advice on generally desirable behavior. You
6100 may wonder why they are not requirements. The most typical answer is
6101 that they describe behavior that seems generally desirable, but cannot
6102 be provided on all systems, or which may be undesirable on some systems.
6104 As far as practical, GNAT follows the implementation advice sections in
6105 the Ada Reference Manual. This chapter contains a table giving the
6106 reference manual section number, paragraph number and several keywords
6107 for each advice. Each entry consists of the text of the advice followed
6108 by the GNAT interpretation of this advice. Most often, this simply says
6109 ``followed'', which means that GNAT follows the advice. However, in a
6110 number of cases, GNAT deliberately deviates from this advice, in which
6111 case the text describes what GNAT does and why.
6113 @cindex Error detection
6114 @unnumberedsec 1.1.3(20): Error Detection
6117 If an implementation detects the use of an unsupported Specialized Needs
6118 Annex feature at run time, it should raise @code{Program_Error} if
6121 Not relevant. All specialized needs annex features are either supported,
6122 or diagnosed at compile time.
6125 @unnumberedsec 1.1.3(31): Child Units
6128 If an implementation wishes to provide implementation-defined
6129 extensions to the functionality of a language-defined library unit, it
6130 should normally do so by adding children to the library unit.
6134 @cindex Bounded errors
6135 @unnumberedsec 1.1.5(12): Bounded Errors
6138 If an implementation detects a bounded error or erroneous
6139 execution, it should raise @code{Program_Error}.
6141 Followed in all cases in which the implementation detects a bounded
6142 error or erroneous execution. Not all such situations are detected at
6146 @unnumberedsec 2.8(16): Pragmas
6149 Normally, implementation-defined pragmas should have no semantic effect
6150 for error-free programs; that is, if the implementation-defined pragmas
6151 are removed from a working program, the program should still be legal,
6152 and should still have the same semantics.
6154 The following implementation defined pragmas are exceptions to this
6166 @item CPP_Constructor
6170 @item Interface_Name
6172 @item Machine_Attribute
6174 @item Unimplemented_Unit
6176 @item Unchecked_Union
6181 In each of the above cases, it is essential to the purpose of the pragma
6182 that this advice not be followed. For details see the separate section
6183 on implementation defined pragmas.
6185 @unnumberedsec 2.8(17-19): Pragmas
6188 Normally, an implementation should not define pragmas that can
6189 make an illegal program legal, except as follows:
6193 A pragma used to complete a declaration, such as a pragma @code{Import};
6197 A pragma used to configure the environment by adding, removing, or
6198 replacing @code{library_items}.
6200 See response to paragraph 16 of this same section.
6202 @cindex Character Sets
6203 @cindex Alternative Character Sets
6204 @unnumberedsec 3.5.2(5): Alternative Character Sets
6207 If an implementation supports a mode with alternative interpretations
6208 for @code{Character} and @code{Wide_Character}, the set of graphic
6209 characters of @code{Character} should nevertheless remain a proper
6210 subset of the set of graphic characters of @code{Wide_Character}. Any
6211 character set ``localizations'' should be reflected in the results of
6212 the subprograms defined in the language-defined package
6213 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6214 an alternative interpretation of @code{Character}, the implementation should
6215 also support a corresponding change in what is a legal
6216 @code{identifier_letter}.
6218 Not all wide character modes follow this advice, in particular the JIS
6219 and IEC modes reflect standard usage in Japan, and in these encoding,
6220 the upper half of the Latin-1 set is not part of the wide-character
6221 subset, since the most significant bit is used for wide character
6222 encoding. However, this only applies to the external forms. Internally
6223 there is no such restriction.
6225 @cindex Integer types
6226 @unnumberedsec 3.5.4(28): Integer Types
6230 An implementation should support @code{Long_Integer} in addition to
6231 @code{Integer} if the target machine supports 32-bit (or longer)
6232 arithmetic. No other named integer subtypes are recommended for package
6233 @code{Standard}. Instead, appropriate named integer subtypes should be
6234 provided in the library package @code{Interfaces} (see B.2).
6236 @code{Long_Integer} is supported. Other standard integer types are supported
6237 so this advice is not fully followed. These types
6238 are supported for convenient interface to C, and so that all hardware
6239 types of the machine are easily available.
6240 @unnumberedsec 3.5.4(29): Integer Types
6244 An implementation for a two's complement machine should support
6245 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6246 implementation should support a non-binary modules up to @code{Integer'Last}.
6250 @cindex Enumeration values
6251 @unnumberedsec 3.5.5(8): Enumeration Values
6254 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6255 subtype, if the value of the operand does not correspond to the internal
6256 code for any enumeration literal of its type (perhaps due to an
6257 un-initialized variable), then the implementation should raise
6258 @code{Program_Error}. This is particularly important for enumeration
6259 types with noncontiguous internal codes specified by an
6260 enumeration_representation_clause.
6265 @unnumberedsec 3.5.7(17): Float Types
6268 An implementation should support @code{Long_Float} in addition to
6269 @code{Float} if the target machine supports 11 or more digits of
6270 precision. No other named floating point subtypes are recommended for
6271 package @code{Standard}. Instead, appropriate named floating point subtypes
6272 should be provided in the library package @code{Interfaces} (see B.2).
6274 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6275 former provides improved compatibility with other implementations
6276 supporting this type. The latter corresponds to the highest precision
6277 floating-point type supported by the hardware. On most machines, this
6278 will be the same as @code{Long_Float}, but on some machines, it will
6279 correspond to the IEEE extended form. The notable case is all ia32
6280 (x86) implementations, where @code{Long_Long_Float} corresponds to
6281 the 80-bit extended precision format supported in hardware on this
6282 processor. Note that the 128-bit format on SPARC is not supported,
6283 since this is a software rather than a hardware format.
6285 @cindex Multidimensional arrays
6286 @cindex Arrays, multidimensional
6287 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6290 An implementation should normally represent multidimensional arrays in
6291 row-major order, consistent with the notation used for multidimensional
6292 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6293 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6294 column-major order should be used instead (see B.5, ``Interfacing with
6299 @findex Duration'Small
6300 @unnumberedsec 9.6(30-31): Duration'Small
6303 Whenever possible in an implementation, the value of @code{Duration'Small}
6304 should be no greater than 100 microseconds.
6306 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6310 The time base for @code{delay_relative_statements} should be monotonic;
6311 it need not be the same time base as used for @code{Calendar.Clock}.
6315 @unnumberedsec 10.2.1(12): Consistent Representation
6318 In an implementation, a type declared in a pre-elaborated package should
6319 have the same representation in every elaboration of a given version of
6320 the package, whether the elaborations occur in distinct executions of
6321 the same program, or in executions of distinct programs or partitions
6322 that include the given version.
6324 Followed, except in the case of tagged types. Tagged types involve
6325 implicit pointers to a local copy of a dispatch table, and these pointers
6326 have representations which thus depend on a particular elaboration of the
6327 package. It is not easy to see how it would be possible to follow this
6328 advice without severely impacting efficiency of execution.
6330 @cindex Exception information
6331 @unnumberedsec 11.4.1(19): Exception Information
6334 @code{Exception_Message} by default and @code{Exception_Information}
6335 should produce information useful for
6336 debugging. @code{Exception_Message} should be short, about one
6337 line. @code{Exception_Information} can be long. @code{Exception_Message}
6338 should not include the
6339 @code{Exception_Name}. @code{Exception_Information} should include both
6340 the @code{Exception_Name} and the @code{Exception_Message}.
6342 Followed. For each exception that doesn't have a specified
6343 @code{Exception_Message}, the compiler generates one containing the location
6344 of the raise statement. This location has the form ``file:line'', where
6345 file is the short file name (without path information) and line is the line
6346 number in the file. Note that in the case of the Zero Cost Exception
6347 mechanism, these messages become redundant with the Exception_Information that
6348 contains a full backtrace of the calling sequence, so they are disabled.
6349 To disable explicitly the generation of the source location message, use the
6350 Pragma @code{Discard_Names}.
6352 @cindex Suppression of checks
6353 @cindex Checks, suppression of
6354 @unnumberedsec 11.5(28): Suppression of Checks
6357 The implementation should minimize the code executed for checks that
6358 have been suppressed.
6362 @cindex Representation clauses
6363 @unnumberedsec 13.1 (21-24): Representation Clauses
6366 The recommended level of support for all representation items is
6367 qualified as follows:
6371 An implementation need not support representation items containing
6372 non-static expressions, except that an implementation should support a
6373 representation item for a given entity if each non-static expression in
6374 the representation item is a name that statically denotes a constant
6375 declared before the entity.
6377 Followed. In fact, GNAT goes beyond the recommended level of support
6378 by allowing nonstatic expressions in some representation clauses even
6379 without the need to declare constants initialized with the values of
6383 @smallexample @c ada
6386 for Y'Address use X'Address;>>
6392 An implementation need not support a specification for the @code{Size}
6393 for a given composite subtype, nor the size or storage place for an
6394 object (including a component) of a given composite subtype, unless the
6395 constraints on the subtype and its composite subcomponents (if any) are
6396 all static constraints.
6398 Followed. Size Clauses are not permitted on non-static components, as
6403 An aliased component, or a component whose type is by-reference, should
6404 always be allocated at an addressable location.
6408 @cindex Packed types
6409 @unnumberedsec 13.2(6-8): Packed Types
6412 If a type is packed, then the implementation should try to minimize
6413 storage allocated to objects of the type, possibly at the expense of
6414 speed of accessing components, subject to reasonable complexity in
6415 addressing calculations.
6419 The recommended level of support pragma @code{Pack} is:
6421 For a packed record type, the components should be packed as tightly as
6422 possible subject to the Sizes of the component subtypes, and subject to
6423 any @code{record_representation_clause} that applies to the type; the
6424 implementation may, but need not, reorder components or cross aligned
6425 word boundaries to improve the packing. A component whose @code{Size} is
6426 greater than the word size may be allocated an integral number of words.
6428 Followed. Tight packing of arrays is supported for all component sizes
6429 up to 64-bits. If the array component size is 1 (that is to say, if
6430 the component is a boolean type or an enumeration type with two values)
6431 then values of the type are implicitly initialized to zero. This
6432 happens both for objects of the packed type, and for objects that have a
6433 subcomponent of the packed type.
6437 An implementation should support Address clauses for imported
6441 @cindex @code{Address} clauses
6442 @unnumberedsec 13.3(14-19): Address Clauses
6446 For an array @var{X}, @code{@var{X}'Address} should point at the first
6447 component of the array, and not at the array bounds.
6453 The recommended level of support for the @code{Address} attribute is:
6455 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6456 object that is aliased or of a by-reference type, or is an entity whose
6457 @code{Address} has been specified.
6459 Followed. A valid address will be produced even if none of those
6460 conditions have been met. If necessary, the object is forced into
6461 memory to ensure the address is valid.
6465 An implementation should support @code{Address} clauses for imported
6472 Objects (including subcomponents) that are aliased or of a by-reference
6473 type should be allocated on storage element boundaries.
6479 If the @code{Address} of an object is specified, or it is imported or exported,
6480 then the implementation should not perform optimizations based on
6481 assumptions of no aliases.
6485 @cindex @code{Alignment} clauses
6486 @unnumberedsec 13.3(29-35): Alignment Clauses
6489 The recommended level of support for the @code{Alignment} attribute for
6492 An implementation should support specified Alignments that are factors
6493 and multiples of the number of storage elements per word, subject to the
6500 An implementation need not support specified @code{Alignment}s for
6501 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6502 loaded and stored by available machine instructions.
6508 An implementation need not support specified @code{Alignment}s that are
6509 greater than the maximum @code{Alignment} the implementation ever returns by
6516 The recommended level of support for the @code{Alignment} attribute for
6519 Same as above, for subtypes, but in addition:
6525 For stand-alone library-level objects of statically constrained
6526 subtypes, the implementation should support all @code{Alignment}s
6527 supported by the target linker. For example, page alignment is likely to
6528 be supported for such objects, but not for subtypes.
6532 @cindex @code{Size} clauses
6533 @unnumberedsec 13.3(42-43): Size Clauses
6536 The recommended level of support for the @code{Size} attribute of
6539 A @code{Size} clause should be supported for an object if the specified
6540 @code{Size} is at least as large as its subtype's @code{Size}, and
6541 corresponds to a size in storage elements that is a multiple of the
6542 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6546 @unnumberedsec 13.3(50-56): Size Clauses
6549 If the @code{Size} of a subtype is specified, and allows for efficient
6550 independent addressability (see 9.10) on the target architecture, then
6551 the @code{Size} of the following objects of the subtype should equal the
6552 @code{Size} of the subtype:
6554 Aliased objects (including components).
6560 @code{Size} clause on a composite subtype should not affect the
6561 internal layout of components.
6563 Followed. But note that this can be overridden by use of the implementation
6564 pragma Implicit_Packing in the case of packed arrays.
6568 The recommended level of support for the @code{Size} attribute of subtypes is:
6572 The @code{Size} (if not specified) of a static discrete or fixed point
6573 subtype should be the number of bits needed to represent each value
6574 belonging to the subtype using an unbiased representation, leaving space
6575 for a sign bit only if the subtype contains negative values. If such a
6576 subtype is a first subtype, then an implementation should support a
6577 specified @code{Size} for it that reflects this representation.
6583 For a subtype implemented with levels of indirection, the @code{Size}
6584 should include the size of the pointers, but not the size of what they
6589 @cindex @code{Component_Size} clauses
6590 @unnumberedsec 13.3(71-73): Component Size Clauses
6593 The recommended level of support for the @code{Component_Size}
6598 An implementation need not support specified @code{Component_Sizes} that are
6599 less than the @code{Size} of the component subtype.
6605 An implementation should support specified @code{Component_Size}s that
6606 are factors and multiples of the word size. For such
6607 @code{Component_Size}s, the array should contain no gaps between
6608 components. For other @code{Component_Size}s (if supported), the array
6609 should contain no gaps between components when packing is also
6610 specified; the implementation should forbid this combination in cases
6611 where it cannot support a no-gaps representation.
6615 @cindex Enumeration representation clauses
6616 @cindex Representation clauses, enumeration
6617 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6620 The recommended level of support for enumeration representation clauses
6623 An implementation need not support enumeration representation clauses
6624 for boolean types, but should at minimum support the internal codes in
6625 the range @code{System.Min_Int.System.Max_Int}.
6629 @cindex Record representation clauses
6630 @cindex Representation clauses, records
6631 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6634 The recommended level of support for
6635 @*@code{record_representation_clauses} is:
6637 An implementation should support storage places that can be extracted
6638 with a load, mask, shift sequence of machine code, and set with a load,
6639 shift, mask, store sequence, given the available machine instructions
6646 A storage place should be supported if its size is equal to the
6647 @code{Size} of the component subtype, and it starts and ends on a
6648 boundary that obeys the @code{Alignment} of the component subtype.
6654 If the default bit ordering applies to the declaration of a given type,
6655 then for a component whose subtype's @code{Size} is less than the word
6656 size, any storage place that does not cross an aligned word boundary
6657 should be supported.
6663 An implementation may reserve a storage place for the tag field of a
6664 tagged type, and disallow other components from overlapping that place.
6666 Followed. The storage place for the tag field is the beginning of the tagged
6667 record, and its size is Address'Size. GNAT will reject an explicit component
6668 clause for the tag field.
6672 An implementation need not support a @code{component_clause} for a
6673 component of an extension part if the storage place is not after the
6674 storage places of all components of the parent type, whether or not
6675 those storage places had been specified.
6677 Followed. The above advice on record representation clauses is followed,
6678 and all mentioned features are implemented.
6680 @cindex Storage place attributes
6681 @unnumberedsec 13.5.2(5): Storage Place Attributes
6684 If a component is represented using some form of pointer (such as an
6685 offset) to the actual data of the component, and this data is contiguous
6686 with the rest of the object, then the storage place attributes should
6687 reflect the place of the actual data, not the pointer. If a component is
6688 allocated discontinuously from the rest of the object, then a warning
6689 should be generated upon reference to one of its storage place
6692 Followed. There are no such components in GNAT@.
6694 @cindex Bit ordering
6695 @unnumberedsec 13.5.3(7-8): Bit Ordering
6698 The recommended level of support for the non-default bit ordering is:
6702 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6703 should support the non-default bit ordering in addition to the default
6706 Followed. Word size does not equal storage size in this implementation.
6707 Thus non-default bit ordering is not supported.
6709 @cindex @code{Address}, as private type
6710 @unnumberedsec 13.7(37): Address as Private
6713 @code{Address} should be of a private type.
6717 @cindex Operations, on @code{Address}
6718 @cindex @code{Address}, operations of
6719 @unnumberedsec 13.7.1(16): Address Operations
6722 Operations in @code{System} and its children should reflect the target
6723 environment semantics as closely as is reasonable. For example, on most
6724 machines, it makes sense for address arithmetic to ``wrap around''.
6725 Operations that do not make sense should raise @code{Program_Error}.
6727 Followed. Address arithmetic is modular arithmetic that wraps around. No
6728 operation raises @code{Program_Error}, since all operations make sense.
6730 @cindex Unchecked conversion
6731 @unnumberedsec 13.9(14-17): Unchecked Conversion
6734 The @code{Size} of an array object should not include its bounds; hence,
6735 the bounds should not be part of the converted data.
6741 The implementation should not generate unnecessary run-time checks to
6742 ensure that the representation of @var{S} is a representation of the
6743 target type. It should take advantage of the permission to return by
6744 reference when possible. Restrictions on unchecked conversions should be
6745 avoided unless required by the target environment.
6747 Followed. There are no restrictions on unchecked conversion. A warning is
6748 generated if the source and target types do not have the same size since
6749 the semantics in this case may be target dependent.
6753 The recommended level of support for unchecked conversions is:
6757 Unchecked conversions should be supported and should be reversible in
6758 the cases where this clause defines the result. To enable meaningful use
6759 of unchecked conversion, a contiguous representation should be used for
6760 elementary subtypes, for statically constrained array subtypes whose
6761 component subtype is one of the subtypes described in this paragraph,
6762 and for record subtypes without discriminants whose component subtypes
6763 are described in this paragraph.
6767 @cindex Heap usage, implicit
6768 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6771 An implementation should document any cases in which it dynamically
6772 allocates heap storage for a purpose other than the evaluation of an
6775 Followed, the only other points at which heap storage is dynamically
6776 allocated are as follows:
6780 At initial elaboration time, to allocate dynamically sized global
6784 To allocate space for a task when a task is created.
6787 To extend the secondary stack dynamically when needed. The secondary
6788 stack is used for returning variable length results.
6793 A default (implementation-provided) storage pool for an
6794 access-to-constant type should not have overhead to support deallocation of
6801 A storage pool for an anonymous access type should be created at the
6802 point of an allocator for the type, and be reclaimed when the designated
6803 object becomes inaccessible.
6807 @cindex Unchecked deallocation
6808 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6811 For a standard storage pool, @code{Free} should actually reclaim the
6816 @cindex Stream oriented attributes
6817 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6820 If a stream element is the same size as a storage element, then the
6821 normal in-memory representation should be used by @code{Read} and
6822 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
6823 should use the smallest number of stream elements needed to represent
6824 all values in the base range of the scalar type.
6827 Followed. By default, GNAT uses the interpretation suggested by AI-195,
6828 which specifies using the size of the first subtype.
6829 However, such an implementation is based on direct binary
6830 representations and is therefore target- and endianness-dependent.
6831 To address this issue, GNAT also supplies an alternate implementation
6832 of the stream attributes @code{Read} and @code{Write},
6833 which uses the target-independent XDR standard representation
6835 @cindex XDR representation
6836 @cindex @code{Read} attribute
6837 @cindex @code{Write} attribute
6838 @cindex Stream oriented attributes
6839 The XDR implementation is provided as an alternative body of the
6840 @code{System.Stream_Attributes} package, in the file
6841 @file{s-strxdr.adb} in the GNAT library.
6842 There is no @file{s-strxdr.ads} file.
6843 In order to install the XDR implementation, do the following:
6845 @item Replace the default implementation of the
6846 @code{System.Stream_Attributes} package with the XDR implementation.
6847 For example on a Unix platform issue the commands:
6849 $ mv s-stratt.adb s-strold.adb
6850 $ mv s-strxdr.adb s-stratt.adb
6854 Rebuild the GNAT run-time library as documented in
6855 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
6858 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6861 If an implementation provides additional named predefined integer types,
6862 then the names should end with @samp{Integer} as in
6863 @samp{Long_Integer}. If an implementation provides additional named
6864 predefined floating point types, then the names should end with
6865 @samp{Float} as in @samp{Long_Float}.
6869 @findex Ada.Characters.Handling
6870 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6873 If an implementation provides a localized definition of @code{Character}
6874 or @code{Wide_Character}, then the effects of the subprograms in
6875 @code{Characters.Handling} should reflect the localizations. See also
6878 Followed. GNAT provides no such localized definitions.
6880 @cindex Bounded-length strings
6881 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6884 Bounded string objects should not be implemented by implicit pointers
6885 and dynamic allocation.
6887 Followed. No implicit pointers or dynamic allocation are used.
6889 @cindex Random number generation
6890 @unnumberedsec A.5.2(46-47): Random Number Generation
6893 Any storage associated with an object of type @code{Generator} should be
6894 reclaimed on exit from the scope of the object.
6900 If the generator period is sufficiently long in relation to the number
6901 of distinct initiator values, then each possible value of
6902 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6903 random numbers that does not, in a practical sense, overlap the sequence
6904 initiated by any other value. If this is not possible, then the mapping
6905 between initiator values and generator states should be a rapidly
6906 varying function of the initiator value.
6908 Followed. The generator period is sufficiently long for the first
6909 condition here to hold true.
6911 @findex Get_Immediate
6912 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6915 The @code{Get_Immediate} procedures should be implemented with
6916 unbuffered input. For a device such as a keyboard, input should be
6917 @dfn{available} if a key has already been typed, whereas for a disk
6918 file, input should always be available except at end of file. For a file
6919 associated with a keyboard-like device, any line-editing features of the
6920 underlying operating system should be disabled during the execution of
6921 @code{Get_Immediate}.
6923 Followed on all targets except VxWorks. For VxWorks, there is no way to
6924 provide this functionality that does not result in the input buffer being
6925 flushed before the @code{Get_Immediate} call. A special unit
6926 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6930 @unnumberedsec B.1(39-41): Pragma @code{Export}
6933 If an implementation supports pragma @code{Export} to a given language,
6934 then it should also allow the main subprogram to be written in that
6935 language. It should support some mechanism for invoking the elaboration
6936 of the Ada library units included in the system, and for invoking the
6937 finalization of the environment task. On typical systems, the
6938 recommended mechanism is to provide two subprograms whose link names are
6939 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
6940 elaboration code for library units. @code{adafinal} should contain the
6941 finalization code. These subprograms should have no effect the second
6942 and subsequent time they are called.
6948 Automatic elaboration of pre-elaborated packages should be
6949 provided when pragma @code{Export} is supported.
6951 Followed when the main program is in Ada. If the main program is in a
6952 foreign language, then
6953 @code{adainit} must be called to elaborate pre-elaborated
6958 For each supported convention @var{L} other than @code{Intrinsic}, an
6959 implementation should support @code{Import} and @code{Export} pragmas
6960 for objects of @var{L}-compatible types and for subprograms, and pragma
6961 @code{Convention} for @var{L}-eligible types and for subprograms,
6962 presuming the other language has corresponding features. Pragma
6963 @code{Convention} need not be supported for scalar types.
6967 @cindex Package @code{Interfaces}
6969 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6972 For each implementation-defined convention identifier, there should be a
6973 child package of package Interfaces with the corresponding name. This
6974 package should contain any declarations that would be useful for
6975 interfacing to the language (implementation) represented by the
6976 convention. Any declarations useful for interfacing to any language on
6977 the given hardware architecture should be provided directly in
6980 Followed. An additional package not defined
6981 in the Ada Reference Manual is @code{Interfaces.CPP}, used
6982 for interfacing to C++.
6986 An implementation supporting an interface to C, COBOL, or Fortran should
6987 provide the corresponding package or packages described in the following
6990 Followed. GNAT provides all the packages described in this section.
6992 @cindex C, interfacing with
6993 @unnumberedsec B.3(63-71): Interfacing with C
6996 An implementation should support the following interface correspondences
7003 An Ada procedure corresponds to a void-returning C function.
7009 An Ada function corresponds to a non-void C function.
7015 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7022 An Ada @code{in} parameter of an access-to-object type with designated
7023 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7024 where @var{t} is the C type corresponding to the Ada type @var{T}.
7030 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7031 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7032 argument to a C function, where @var{t} is the C type corresponding to
7033 the Ada type @var{T}. In the case of an elementary @code{out} or
7034 @code{in out} parameter, a pointer to a temporary copy is used to
7035 preserve by-copy semantics.
7041 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7042 @code{@var{t}*} argument to a C function, where @var{t} is the C
7043 structure corresponding to the Ada type @var{T}.
7045 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7046 pragma, or Convention, or by explicitly specifying the mechanism for a given
7047 call using an extended import or export pragma.
7051 An Ada parameter of an array type with component type @var{T}, of any
7052 mode, is passed as a @code{@var{t}*} argument to a C function, where
7053 @var{t} is the C type corresponding to the Ada type @var{T}.
7059 An Ada parameter of an access-to-subprogram type is passed as a pointer
7060 to a C function whose prototype corresponds to the designated
7061 subprogram's specification.
7065 @cindex COBOL, interfacing with
7066 @unnumberedsec B.4(95-98): Interfacing with COBOL
7069 An Ada implementation should support the following interface
7070 correspondences between Ada and COBOL@.
7076 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7077 the COBOL type corresponding to @var{T}.
7083 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7084 the corresponding COBOL type.
7090 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7091 COBOL type corresponding to the Ada parameter type; for scalars, a local
7092 copy is used if necessary to ensure by-copy semantics.
7096 @cindex Fortran, interfacing with
7097 @unnumberedsec B.5(22-26): Interfacing with Fortran
7100 An Ada implementation should support the following interface
7101 correspondences between Ada and Fortran:
7107 An Ada procedure corresponds to a Fortran subroutine.
7113 An Ada function corresponds to a Fortran function.
7119 An Ada parameter of an elementary, array, or record type @var{T} is
7120 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7121 the Fortran type corresponding to the Ada type @var{T}, and where the
7122 INTENT attribute of the corresponding dummy argument matches the Ada
7123 formal parameter mode; the Fortran implementation's parameter passing
7124 conventions are used. For elementary types, a local copy is used if
7125 necessary to ensure by-copy semantics.
7131 An Ada parameter of an access-to-subprogram type is passed as a
7132 reference to a Fortran procedure whose interface corresponds to the
7133 designated subprogram's specification.
7137 @cindex Machine operations
7138 @unnumberedsec C.1(3-5): Access to Machine Operations
7141 The machine code or intrinsic support should allow access to all
7142 operations normally available to assembly language programmers for the
7143 target environment, including privileged instructions, if any.
7149 The interfacing pragmas (see Annex B) should support interface to
7150 assembler; the default assembler should be associated with the
7151 convention identifier @code{Assembler}.
7157 If an entity is exported to assembly language, then the implementation
7158 should allocate it at an addressable location, and should ensure that it
7159 is retained by the linking process, even if not otherwise referenced
7160 from the Ada code. The implementation should assume that any call to a
7161 machine code or assembler subprogram is allowed to read or update every
7162 object that is specified as exported.
7166 @unnumberedsec C.1(10-16): Access to Machine Operations
7169 The implementation should ensure that little or no overhead is
7170 associated with calling intrinsic and machine-code subprograms.
7172 Followed for both intrinsics and machine-code subprograms.
7176 It is recommended that intrinsic subprograms be provided for convenient
7177 access to any machine operations that provide special capabilities or
7178 efficiency and that are not otherwise available through the language
7181 Followed. A full set of machine operation intrinsic subprograms is provided.
7185 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7186 swap, decrement and test, enqueue/dequeue.
7188 Followed on any target supporting such operations.
7192 Standard numeric functions---e.g.@:, sin, log.
7194 Followed on any target supporting such operations.
7198 String manipulation operations---e.g.@:, translate and test.
7200 Followed on any target supporting such operations.
7204 Vector operations---e.g.@:, compare vector against thresholds.
7206 Followed on any target supporting such operations.
7210 Direct operations on I/O ports.
7212 Followed on any target supporting such operations.
7214 @cindex Interrupt support
7215 @unnumberedsec C.3(28): Interrupt Support
7218 If the @code{Ceiling_Locking} policy is not in effect, the
7219 implementation should provide means for the application to specify which
7220 interrupts are to be blocked during protected actions, if the underlying
7221 system allows for a finer-grain control of interrupt blocking.
7223 Followed. The underlying system does not allow for finer-grain control
7224 of interrupt blocking.
7226 @cindex Protected procedure handlers
7227 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7230 Whenever possible, the implementation should allow interrupt handlers to
7231 be called directly by the hardware.
7235 This is never possible under IRIX, so this is followed by default.
7237 Followed on any target where the underlying operating system permits
7242 Whenever practical, violations of any
7243 implementation-defined restrictions should be detected before run time.
7245 Followed. Compile time warnings are given when possible.
7247 @cindex Package @code{Interrupts}
7249 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7253 If implementation-defined forms of interrupt handler procedures are
7254 supported, such as protected procedures with parameters, then for each
7255 such form of a handler, a type analogous to @code{Parameterless_Handler}
7256 should be specified in a child package of @code{Interrupts}, with the
7257 same operations as in the predefined package Interrupts.
7261 @cindex Pre-elaboration requirements
7262 @unnumberedsec C.4(14): Pre-elaboration Requirements
7265 It is recommended that pre-elaborated packages be implemented in such a
7266 way that there should be little or no code executed at run time for the
7267 elaboration of entities not already covered by the Implementation
7270 Followed. Executable code is generated in some cases, e.g.@: loops
7271 to initialize large arrays.
7273 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7277 If the pragma applies to an entity, then the implementation should
7278 reduce the amount of storage used for storing names associated with that
7283 @cindex Package @code{Task_Attributes}
7284 @findex Task_Attributes
7285 @unnumberedsec C.7.2(30): The Package Task_Attributes
7288 Some implementations are targeted to domains in which memory use at run
7289 time must be completely deterministic. For such implementations, it is
7290 recommended that the storage for task attributes will be pre-allocated
7291 statically and not from the heap. This can be accomplished by either
7292 placing restrictions on the number and the size of the task's
7293 attributes, or by using the pre-allocated storage for the first @var{N}
7294 attribute objects, and the heap for the others. In the latter case,
7295 @var{N} should be documented.
7297 Not followed. This implementation is not targeted to such a domain.
7299 @cindex Locking Policies
7300 @unnumberedsec D.3(17): Locking Policies
7304 The implementation should use names that end with @samp{_Locking} for
7305 locking policies defined by the implementation.
7307 Followed. A single implementation-defined locking policy is defined,
7308 whose name (@code{Inheritance_Locking}) follows this suggestion.
7310 @cindex Entry queuing policies
7311 @unnumberedsec D.4(16): Entry Queuing Policies
7314 Names that end with @samp{_Queuing} should be used
7315 for all implementation-defined queuing policies.
7317 Followed. No such implementation-defined queuing policies exist.
7319 @cindex Preemptive abort
7320 @unnumberedsec D.6(9-10): Preemptive Abort
7323 Even though the @code{abort_statement} is included in the list of
7324 potentially blocking operations (see 9.5.1), it is recommended that this
7325 statement be implemented in a way that never requires the task executing
7326 the @code{abort_statement} to block.
7332 On a multi-processor, the delay associated with aborting a task on
7333 another processor should be bounded; the implementation should use
7334 periodic polling, if necessary, to achieve this.
7338 @cindex Tasking restrictions
7339 @unnumberedsec D.7(21): Tasking Restrictions
7342 When feasible, the implementation should take advantage of the specified
7343 restrictions to produce a more efficient implementation.
7345 GNAT currently takes advantage of these restrictions by providing an optimized
7346 run time when the Ravenscar profile and the GNAT restricted run time set
7347 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7348 pragma @code{Profile (Restricted)} for more details.
7350 @cindex Time, monotonic
7351 @unnumberedsec D.8(47-49): Monotonic Time
7354 When appropriate, implementations should provide configuration
7355 mechanisms to change the value of @code{Tick}.
7357 Such configuration mechanisms are not appropriate to this implementation
7358 and are thus not supported.
7362 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7363 be implemented as transformations of the same time base.
7369 It is recommended that the @dfn{best} time base which exists in
7370 the underlying system be available to the application through
7371 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7375 @cindex Partition communication subsystem
7377 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7380 Whenever possible, the PCS on the called partition should allow for
7381 multiple tasks to call the RPC-receiver with different messages and
7382 should allow them to block until the corresponding subprogram body
7385 Followed by GLADE, a separately supplied PCS that can be used with
7390 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7391 should raise @code{Storage_Error} if it runs out of space trying to
7392 write the @code{Item} into the stream.
7394 Followed by GLADE, a separately supplied PCS that can be used with
7397 @cindex COBOL support
7398 @unnumberedsec F(7): COBOL Support
7401 If COBOL (respectively, C) is widely supported in the target
7402 environment, implementations supporting the Information Systems Annex
7403 should provide the child package @code{Interfaces.COBOL} (respectively,
7404 @code{Interfaces.C}) specified in Annex B and should support a
7405 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7406 pragmas (see Annex B), thus allowing Ada programs to interface with
7407 programs written in that language.
7411 @cindex Decimal radix support
7412 @unnumberedsec F.1(2): Decimal Radix Support
7415 Packed decimal should be used as the internal representation for objects
7416 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7418 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
7422 @unnumberedsec G: Numerics
7425 If Fortran (respectively, C) is widely supported in the target
7426 environment, implementations supporting the Numerics Annex
7427 should provide the child package @code{Interfaces.Fortran} (respectively,
7428 @code{Interfaces.C}) specified in Annex B and should support a
7429 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7430 pragmas (see Annex B), thus allowing Ada programs to interface with
7431 programs written in that language.
7435 @cindex Complex types
7436 @unnumberedsec G.1.1(56-58): Complex Types
7439 Because the usual mathematical meaning of multiplication of a complex
7440 operand and a real operand is that of the scaling of both components of
7441 the former by the latter, an implementation should not perform this
7442 operation by first promoting the real operand to complex type and then
7443 performing a full complex multiplication. In systems that, in the
7444 future, support an Ada binding to IEC 559:1989, the latter technique
7445 will not generate the required result when one of the components of the
7446 complex operand is infinite. (Explicit multiplication of the infinite
7447 component by the zero component obtained during promotion yields a NaN
7448 that propagates into the final result.) Analogous advice applies in the
7449 case of multiplication of a complex operand and a pure-imaginary
7450 operand, and in the case of division of a complex operand by a real or
7451 pure-imaginary operand.
7457 Similarly, because the usual mathematical meaning of addition of a
7458 complex operand and a real operand is that the imaginary operand remains
7459 unchanged, an implementation should not perform this operation by first
7460 promoting the real operand to complex type and then performing a full
7461 complex addition. In implementations in which the @code{Signed_Zeros}
7462 attribute of the component type is @code{True} (and which therefore
7463 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7464 predefined arithmetic operations), the latter technique will not
7465 generate the required result when the imaginary component of the complex
7466 operand is a negatively signed zero. (Explicit addition of the negative
7467 zero to the zero obtained during promotion yields a positive zero.)
7468 Analogous advice applies in the case of addition of a complex operand
7469 and a pure-imaginary operand, and in the case of subtraction of a
7470 complex operand and a real or pure-imaginary operand.
7476 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7477 attempt to provide a rational treatment of the signs of zero results and
7478 result components. As one example, the result of the @code{Argument}
7479 function should have the sign of the imaginary component of the
7480 parameter @code{X} when the point represented by that parameter lies on
7481 the positive real axis; as another, the sign of the imaginary component
7482 of the @code{Compose_From_Polar} function should be the same as
7483 (respectively, the opposite of) that of the @code{Argument} parameter when that
7484 parameter has a value of zero and the @code{Modulus} parameter has a
7485 nonnegative (respectively, negative) value.
7489 @cindex Complex elementary functions
7490 @unnumberedsec G.1.2(49): Complex Elementary Functions
7493 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7494 @code{True} should attempt to provide a rational treatment of the signs
7495 of zero results and result components. For example, many of the complex
7496 elementary functions have components that are odd functions of one of
7497 the parameter components; in these cases, the result component should
7498 have the sign of the parameter component at the origin. Other complex
7499 elementary functions have zero components whose sign is opposite that of
7500 a parameter component at the origin, or is always positive or always
7505 @cindex Accuracy requirements
7506 @unnumberedsec G.2.4(19): Accuracy Requirements
7509 The versions of the forward trigonometric functions without a
7510 @code{Cycle} parameter should not be implemented by calling the
7511 corresponding version with a @code{Cycle} parameter of
7512 @code{2.0*Numerics.Pi}, since this will not provide the required
7513 accuracy in some portions of the domain. For the same reason, the
7514 version of @code{Log} without a @code{Base} parameter should not be
7515 implemented by calling the corresponding version with a @code{Base}
7516 parameter of @code{Numerics.e}.
7520 @cindex Complex arithmetic accuracy
7521 @cindex Accuracy, complex arithmetic
7522 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7526 The version of the @code{Compose_From_Polar} function without a
7527 @code{Cycle} parameter should not be implemented by calling the
7528 corresponding version with a @code{Cycle} parameter of
7529 @code{2.0*Numerics.Pi}, since this will not provide the required
7530 accuracy in some portions of the domain.
7534 @c -----------------------------------------
7535 @node Implementation Defined Characteristics
7536 @chapter Implementation Defined Characteristics
7539 In addition to the implementation dependent pragmas and attributes, and
7540 the implementation advice, there are a number of other Ada features
7541 that are potentially implementation dependent. These are mentioned
7542 throughout the Ada Reference Manual, and are summarized in annex M@.
7544 A requirement for conforming Ada compilers is that they provide
7545 documentation describing how the implementation deals with each of these
7546 issues. In this chapter, you will find each point in annex M listed
7547 followed by a description in italic font of how GNAT
7551 implementation on IRIX 5.3 operating system or greater
7553 handles the implementation dependence.
7555 You can use this chapter as a guide to minimizing implementation
7556 dependent features in your programs if portability to other compilers
7557 and other operating systems is an important consideration. The numbers
7558 in each section below correspond to the paragraph number in the Ada
7564 @strong{2}. Whether or not each recommendation given in Implementation
7565 Advice is followed. See 1.1.2(37).
7568 @xref{Implementation Advice}.
7573 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
7576 The complexity of programs that can be processed is limited only by the
7577 total amount of available virtual memory, and disk space for the
7578 generated object files.
7583 @strong{4}. Variations from the standard that are impractical to avoid
7584 given the implementation's execution environment. See 1.1.3(6).
7587 There are no variations from the standard.
7592 @strong{5}. Which @code{code_statement}s cause external
7593 interactions. See 1.1.3(10).
7596 Any @code{code_statement} can potentially cause external interactions.
7601 @strong{6}. The coded representation for the text of an Ada
7602 program. See 2.1(4).
7605 See separate section on source representation.
7610 @strong{7}. The control functions allowed in comments. See 2.1(14).
7613 See separate section on source representation.
7618 @strong{8}. The representation for an end of line. See 2.2(2).
7621 See separate section on source representation.
7626 @strong{9}. Maximum supported line length and lexical element
7627 length. See 2.2(15).
7630 The maximum line length is 255 characters and the maximum length of a
7631 lexical element is also 255 characters.
7636 @strong{10}. Implementation defined pragmas. See 2.8(14).
7640 @xref{Implementation Defined Pragmas}.
7645 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
7648 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7649 parameter, checks that the optimization flag is set, and aborts if it is
7655 @strong{12}. The sequence of characters of the value returned by
7656 @code{@var{S}'Image} when some of the graphic characters of
7657 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
7661 The sequence of characters is as defined by the wide character encoding
7662 method used for the source. See section on source representation for
7668 @strong{13}. The predefined integer types declared in
7669 @code{Standard}. See 3.5.4(25).
7673 @item Short_Short_Integer
7676 (Short) 16 bit signed
7680 64 bit signed (Alpha OpenVMS only)
7681 32 bit signed (all other targets)
7682 @item Long_Long_Integer
7689 @strong{14}. Any nonstandard integer types and the operators defined
7690 for them. See 3.5.4(26).
7693 There are no nonstandard integer types.
7698 @strong{15}. Any nonstandard real types and the operators defined for
7702 There are no nonstandard real types.
7707 @strong{16}. What combinations of requested decimal precision and range
7708 are supported for floating point types. See 3.5.7(7).
7711 The precision and range is as defined by the IEEE standard.
7716 @strong{17}. The predefined floating point types declared in
7717 @code{Standard}. See 3.5.7(16).
7724 (Short) 32 bit IEEE short
7727 @item Long_Long_Float
7728 64 bit IEEE long (80 bit IEEE long on x86 processors)
7734 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
7737 @code{Fine_Delta} is 2**(@minus{}63)
7742 @strong{19}. What combinations of small, range, and digits are
7743 supported for fixed point types. See 3.5.9(10).
7746 Any combinations are permitted that do not result in a small less than
7747 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7748 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7749 is 64 bits (true of all architectures except ia32), then the output from
7750 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
7751 is because floating-point conversions are used to convert fixed point.
7756 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
7757 within an unnamed @code{block_statement}. See 3.9(10).
7760 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7761 decimal integer are allocated.
7766 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
7769 @xref{Implementation Defined Attributes}.
7774 @strong{22}. Any implementation-defined time types. See 9.6(6).
7777 There are no implementation-defined time types.
7782 @strong{23}. The time base associated with relative delays.
7785 See 9.6(20). The time base used is that provided by the C library
7786 function @code{gettimeofday}.
7791 @strong{24}. The time base of the type @code{Calendar.Time}. See
7795 The time base used is that provided by the C library function
7796 @code{gettimeofday}.
7801 @strong{25}. The time zone used for package @code{Calendar}
7802 operations. See 9.6(24).
7805 The time zone used by package @code{Calendar} is the current system time zone
7806 setting for local time, as accessed by the C library function
7812 @strong{26}. Any limit on @code{delay_until_statements} of
7813 @code{select_statements}. See 9.6(29).
7816 There are no such limits.
7821 @strong{27}. Whether or not two non-overlapping parts of a composite
7822 object are independently addressable, in the case where packing, record
7823 layout, or @code{Component_Size} is specified for the object. See
7827 Separate components are independently addressable if they do not share
7828 overlapping storage units.
7833 @strong{28}. The representation for a compilation. See 10.1(2).
7836 A compilation is represented by a sequence of files presented to the
7837 compiler in a single invocation of the @command{gcc} command.
7842 @strong{29}. Any restrictions on compilations that contain multiple
7843 compilation_units. See 10.1(4).
7846 No single file can contain more than one compilation unit, but any
7847 sequence of files can be presented to the compiler as a single
7853 @strong{30}. The mechanisms for creating an environment and for adding
7854 and replacing compilation units. See 10.1.4(3).
7857 See separate section on compilation model.
7862 @strong{31}. The manner of explicitly assigning library units to a
7863 partition. See 10.2(2).
7866 If a unit contains an Ada main program, then the Ada units for the partition
7867 are determined by recursive application of the rules in the Ada Reference
7868 Manual section 10.2(2-6). In other words, the Ada units will be those that
7869 are needed by the main program, and then this definition of need is applied
7870 recursively to those units, and the partition contains the transitive
7871 closure determined by this relationship. In short, all the necessary units
7872 are included, with no need to explicitly specify the list. If additional
7873 units are required, e.g.@: by foreign language units, then all units must be
7874 mentioned in the context clause of one of the needed Ada units.
7876 If the partition contains no main program, or if the main program is in
7877 a language other than Ada, then GNAT
7878 provides the binder options @option{-z} and @option{-n} respectively, and in
7879 this case a list of units can be explicitly supplied to the binder for
7880 inclusion in the partition (all units needed by these units will also
7881 be included automatically). For full details on the use of these
7882 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
7883 @value{EDITION} User's Guide}.
7888 @strong{32}. The implementation-defined means, if any, of specifying
7889 which compilation units are needed by a given compilation unit. See
7893 The units needed by a given compilation unit are as defined in
7894 the Ada Reference Manual section 10.2(2-6). There are no
7895 implementation-defined pragmas or other implementation-defined
7896 means for specifying needed units.
7901 @strong{33}. The manner of designating the main subprogram of a
7902 partition. See 10.2(7).
7905 The main program is designated by providing the name of the
7906 corresponding @file{ALI} file as the input parameter to the binder.
7911 @strong{34}. The order of elaboration of @code{library_items}. See
7915 The first constraint on ordering is that it meets the requirements of
7916 Chapter 10 of the Ada Reference Manual. This still leaves some
7917 implementation dependent choices, which are resolved by first
7918 elaborating bodies as early as possible (i.e., in preference to specs
7919 where there is a choice), and second by evaluating the immediate with
7920 clauses of a unit to determine the probably best choice, and
7921 third by elaborating in alphabetical order of unit names
7922 where a choice still remains.
7927 @strong{35}. Parameter passing and function return for the main
7928 subprogram. See 10.2(21).
7931 The main program has no parameters. It may be a procedure, or a function
7932 returning an integer type. In the latter case, the returned integer
7933 value is the return code of the program (overriding any value that
7934 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7939 @strong{36}. The mechanisms for building and running partitions. See
7943 GNAT itself supports programs with only a single partition. The GNATDIST
7944 tool provided with the GLADE package (which also includes an implementation
7945 of the PCS) provides a completely flexible method for building and running
7946 programs consisting of multiple partitions. See the separate GLADE manual
7952 @strong{37}. The details of program execution, including program
7953 termination. See 10.2(25).
7956 See separate section on compilation model.
7961 @strong{38}. The semantics of any non-active partitions supported by the
7962 implementation. See 10.2(28).
7965 Passive partitions are supported on targets where shared memory is
7966 provided by the operating system. See the GLADE reference manual for
7972 @strong{39}. The information returned by @code{Exception_Message}. See
7976 Exception message returns the null string unless a specific message has
7977 been passed by the program.
7982 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
7983 declared within an unnamed @code{block_statement}. See 11.4.1(12).
7986 Blocks have implementation defined names of the form @code{B@var{nnn}}
7987 where @var{nnn} is an integer.
7992 @strong{41}. The information returned by
7993 @code{Exception_Information}. See 11.4.1(13).
7996 @code{Exception_Information} returns a string in the following format:
7999 @emph{Exception_Name:} nnnnn
8000 @emph{Message:} mmmmm
8002 @emph{Call stack traceback locations:}
8003 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8011 @code{nnnn} is the fully qualified name of the exception in all upper
8012 case letters. This line is always present.
8015 @code{mmmm} is the message (this line present only if message is non-null)
8018 @code{ppp} is the Process Id value as a decimal integer (this line is
8019 present only if the Process Id is nonzero). Currently we are
8020 not making use of this field.
8023 The Call stack traceback locations line and the following values
8024 are present only if at least one traceback location was recorded.
8025 The values are given in C style format, with lower case letters
8026 for a-f, and only as many digits present as are necessary.
8030 The line terminator sequence at the end of each line, including
8031 the last line is a single @code{LF} character (@code{16#0A#}).
8036 @strong{42}. Implementation-defined check names. See 11.5(27).
8039 The implementation defined check name Alignment_Check controls checking of
8040 address clause values for proper alignment (that is, the address supplied
8041 must be consistent with the alignment of the type).
8043 In addition, a user program can add implementation-defined check names
8044 by means of the pragma Check_Name.
8049 @strong{43}. The interpretation of each aspect of representation. See
8053 See separate section on data representations.
8058 @strong{44}. Any restrictions placed upon representation items. See
8062 See separate section on data representations.
8067 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8071 Size for an indefinite subtype is the maximum possible size, except that
8072 for the case of a subprogram parameter, the size of the parameter object
8078 @strong{46}. The default external representation for a type tag. See
8082 The default external representation for a type tag is the fully expanded
8083 name of the type in upper case letters.
8088 @strong{47}. What determines whether a compilation unit is the same in
8089 two different partitions. See 13.3(76).
8092 A compilation unit is the same in two different partitions if and only
8093 if it derives from the same source file.
8098 @strong{48}. Implementation-defined components. See 13.5.1(15).
8101 The only implementation defined component is the tag for a tagged type,
8102 which contains a pointer to the dispatching table.
8107 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8108 ordering. See 13.5.3(5).
8111 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8112 implementation, so no non-default bit ordering is supported. The default
8113 bit ordering corresponds to the natural endianness of the target architecture.
8118 @strong{50}. The contents of the visible part of package @code{System}
8119 and its language-defined children. See 13.7(2).
8122 See the definition of these packages in files @file{system.ads} and
8123 @file{s-stoele.ads}.
8128 @strong{51}. The contents of the visible part of package
8129 @code{System.Machine_Code}, and the meaning of
8130 @code{code_statements}. See 13.8(7).
8133 See the definition and documentation in file @file{s-maccod.ads}.
8138 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8141 Unchecked conversion between types of the same size
8142 results in an uninterpreted transmission of the bits from one type
8143 to the other. If the types are of unequal sizes, then in the case of
8144 discrete types, a shorter source is first zero or sign extended as
8145 necessary, and a shorter target is simply truncated on the left.
8146 For all non-discrete types, the source is first copied if necessary
8147 to ensure that the alignment requirements of the target are met, then
8148 a pointer is constructed to the source value, and the result is obtained
8149 by dereferencing this pointer after converting it to be a pointer to the
8150 target type. Unchecked conversions where the target subtype is an
8151 unconstrained array are not permitted. If the target alignment is
8152 greater than the source alignment, then a copy of the result is
8153 made with appropriate alignment
8158 @strong{53}. The manner of choosing a storage pool for an access type
8159 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8162 There are 3 different standard pools used by the compiler when
8163 @code{Storage_Pool} is not specified depending whether the type is local
8164 to a subprogram or defined at the library level and whether
8165 @code{Storage_Size}is specified or not. See documentation in the runtime
8166 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8167 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8168 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8174 @strong{54}. Whether or not the implementation provides user-accessible
8175 names for the standard pool type(s). See 13.11(17).
8179 See documentation in the sources of the run time mentioned in paragraph
8180 @strong{53} . All these pools are accessible by means of @code{with}'ing
8186 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8189 @code{Storage_Size} is measured in storage units, and refers to the
8190 total space available for an access type collection, or to the primary
8191 stack space for a task.
8196 @strong{56}. Implementation-defined aspects of storage pools. See
8200 See documentation in the sources of the run time mentioned in paragraph
8201 @strong{53} for details on GNAT-defined aspects of storage pools.
8206 @strong{57}. The set of restrictions allowed in a pragma
8207 @code{Restrictions}. See 13.12(7).
8210 All RM defined Restriction identifiers are implemented. The following
8211 additional restriction identifiers are provided. There are two separate
8212 lists of implementation dependent restriction identifiers. The first
8213 set requires consistency throughout a partition (in other words, if the
8214 restriction identifier is used for any compilation unit in the partition,
8215 then all compilation units in the partition must obey the restriction.
8219 @item Simple_Barriers
8220 @findex Simple_Barriers
8221 This restriction ensures at compile time that barriers in entry declarations
8222 for protected types are restricted to either static boolean expressions or
8223 references to simple boolean variables defined in the private part of the
8224 protected type. No other form of entry barriers is permitted. This is one
8225 of the restrictions of the Ravenscar profile for limited tasking (see also
8226 pragma @code{Profile (Ravenscar)}).
8228 @item Max_Entry_Queue_Length => Expr
8229 @findex Max_Entry_Queue_Length
8230 This restriction is a declaration that any protected entry compiled in
8231 the scope of the restriction has at most the specified number of
8232 tasks waiting on the entry
8233 at any one time, and so no queue is required. This restriction is not
8234 checked at compile time. A program execution is erroneous if an attempt
8235 is made to queue more than the specified number of tasks on such an entry.
8239 This restriction ensures at compile time that there is no implicit or
8240 explicit dependence on the package @code{Ada.Calendar}.
8242 @item No_Default_Initialization
8243 @findex No_Default_Initialization
8245 This restriction prohibits any instance of default initialization of variables.
8246 The binder implements a consistency rule which prevents any unit compiled
8247 without the restriction from with'ing a unit with the restriction (this allows
8248 the generation of initialization procedures to be skipped, since you can be
8249 sure that no call is ever generated to an initialization procedure in a unit
8250 with the restriction active). If used in conjunction with Initialize_Scalars or
8251 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8252 without a specific initializer (including the case of OUT scalar parameters).
8254 @item No_Direct_Boolean_Operators
8255 @findex No_Direct_Boolean_Operators
8256 This restriction ensures that no logical (and/or/xor) or comparison
8257 operators are used on operands of type Boolean (or any type derived
8258 from Boolean). This is intended for use in safety critical programs
8259 where the certification protocol requires the use of short-circuit
8260 (and then, or else) forms for all composite boolean operations.
8262 @item No_Dispatching_Calls
8263 @findex No_Dispatching_Calls
8264 This restriction ensures at compile time that the code generated by the
8265 compiler involves no dispatching calls. The use of this restriction allows the
8266 safe use of record extensions, classwide membership tests and other classwide
8267 features not involving implicit dispatching. This restriction ensures that
8268 the code contains no indirect calls through a dispatching mechanism. Note that
8269 this includes internally-generated calls created by the compiler, for example
8270 in the implementation of class-wide objects assignments. The
8271 membership test is allowed in the presence of this restriction, because its
8272 implementation requires no dispatching.
8273 This restriction is comparable to the official Ada restriction
8274 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8275 all classwide constructs that do not imply dispatching.
8276 The following example indicates constructs that violate this restriction.
8280 type T is tagged record
8283 procedure P (X : T);
8285 type DT is new T with record
8286 More_Data : Natural;
8288 procedure Q (X : DT);
8292 procedure Example is
8293 procedure Test (O : T'Class) is
8294 N : Natural := O'Size;-- Error: Dispatching call
8295 C : T'Class := O; -- Error: implicit Dispatching Call
8297 if O in DT'Class then -- OK : Membership test
8298 Q (DT (O)); -- OK : Type conversion plus direct call
8300 P (O); -- Error: Dispatching call
8306 P (Obj); -- OK : Direct call
8307 P (T (Obj)); -- OK : Type conversion plus direct call
8308 P (T'Class (Obj)); -- Error: Dispatching call
8310 Test (Obj); -- OK : Type conversion
8312 if Obj in T'Class then -- OK : Membership test
8318 @item No_Dynamic_Attachment
8319 @findex No_Dynamic_Attachment
8320 This restriction ensures that there is no call to any of the operations
8321 defined in package Ada.Interrupts.
8323 @item No_Enumeration_Maps
8324 @findex No_Enumeration_Maps
8325 This restriction ensures at compile time that no operations requiring
8326 enumeration maps are used (that is Image and Value attributes applied
8327 to enumeration types).
8329 @item No_Entry_Calls_In_Elaboration_Code
8330 @findex No_Entry_Calls_In_Elaboration_Code
8331 This restriction ensures at compile time that no task or protected entry
8332 calls are made during elaboration code. As a result of the use of this
8333 restriction, the compiler can assume that no code past an accept statement
8334 in a task can be executed at elaboration time.
8336 @item No_Exception_Handlers
8337 @findex No_Exception_Handlers
8338 This restriction ensures at compile time that there are no explicit
8339 exception handlers. It also indicates that no exception propagation will
8340 be provided. In this mode, exceptions may be raised but will result in
8341 an immediate call to the last chance handler, a routine that the user
8342 must define with the following profile:
8344 @smallexample @c ada
8345 procedure Last_Chance_Handler
8346 (Source_Location : System.Address; Line : Integer);
8347 pragma Export (C, Last_Chance_Handler,
8348 "__gnat_last_chance_handler");
8351 The parameter is a C null-terminated string representing a message to be
8352 associated with the exception (typically the source location of the raise
8353 statement generated by the compiler). The Line parameter when nonzero
8354 represents the line number in the source program where the raise occurs.
8356 @item No_Exception_Propagation
8357 @findex No_Exception_Propagation
8358 This restriction guarantees that exceptions are never propagated to an outer
8359 subprogram scope). The only case in which an exception may be raised is when
8360 the handler is statically in the same subprogram, so that the effect of a raise
8361 is essentially like a goto statement. Any other raise statement (implicit or
8362 explicit) will be considered unhandled. Exception handlers are allowed, but may
8363 not contain an exception occurrence identifier (exception choice). In addition
8364 use of the package GNAT.Current_Exception is not permitted, and reraise
8365 statements (raise with no operand) are not permitted.
8367 @item No_Exception_Registration
8368 @findex No_Exception_Registration
8369 This restriction ensures at compile time that no stream operations for
8370 types Exception_Id or Exception_Occurrence are used. This also makes it
8371 impossible to pass exceptions to or from a partition with this restriction
8372 in a distributed environment. If this exception is active, then the generated
8373 code is simplified by omitting the otherwise-required global registration
8374 of exceptions when they are declared.
8376 @item No_Implicit_Conditionals
8377 @findex No_Implicit_Conditionals
8378 This restriction ensures that the generated code does not contain any
8379 implicit conditionals, either by modifying the generated code where possible,
8380 or by rejecting any construct that would otherwise generate an implicit
8381 conditional. Note that this check does not include run time constraint
8382 checks, which on some targets may generate implicit conditionals as
8383 well. To control the latter, constraint checks can be suppressed in the
8384 normal manner. Constructs generating implicit conditionals include comparisons
8385 of composite objects and the Max/Min attributes.
8387 @item No_Implicit_Dynamic_Code
8388 @findex No_Implicit_Dynamic_Code
8390 This restriction prevents the compiler from building ``trampolines''.
8391 This is a structure that is built on the stack and contains dynamic
8392 code to be executed at run time. On some targets, a trampoline is
8393 built for the following features: @code{Access},
8394 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8395 nested task bodies; primitive operations of nested tagged types.
8396 Trampolines do not work on machines that prevent execution of stack
8397 data. For example, on windows systems, enabling DEP (data execution
8398 protection) will cause trampolines to raise an exception.
8399 Trampolines are also quite slow at run time.
8401 On many targets, trampolines have been largely eliminated. Look at the
8402 version of system.ads for your target --- if it has
8403 Always_Compatible_Rep equal to False, then trampolines are largely
8404 eliminated. In particular, a trampoline is built for the following
8405 features: @code{Address} of a nested subprogram;
8406 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8407 but only if pragma Favor_Top_Level applies, or the access type has a
8408 foreign-language convention; primitive operations of nested tagged
8411 @item No_Implicit_Loops
8412 @findex No_Implicit_Loops
8413 This restriction ensures that the generated code does not contain any
8414 implicit @code{for} loops, either by modifying
8415 the generated code where possible,
8416 or by rejecting any construct that would otherwise generate an implicit
8417 @code{for} loop. If this restriction is active, it is possible to build
8418 large array aggregates with all static components without generating an
8419 intermediate temporary, and without generating a loop to initialize individual
8420 components. Otherwise, a loop is created for arrays larger than about 5000
8423 @item No_Initialize_Scalars
8424 @findex No_Initialize_Scalars
8425 This restriction ensures that no unit in the partition is compiled with
8426 pragma Initialize_Scalars. This allows the generation of more efficient
8427 code, and in particular eliminates dummy null initialization routines that
8428 are otherwise generated for some record and array types.
8430 @item No_Local_Protected_Objects
8431 @findex No_Local_Protected_Objects
8432 This restriction ensures at compile time that protected objects are
8433 only declared at the library level.
8435 @item No_Protected_Type_Allocators
8436 @findex No_Protected_Type_Allocators
8437 This restriction ensures at compile time that there are no allocator
8438 expressions that attempt to allocate protected objects.
8440 @item No_Secondary_Stack
8441 @findex No_Secondary_Stack
8442 This restriction ensures at compile time that the generated code does not
8443 contain any reference to the secondary stack. The secondary stack is used
8444 to implement functions returning unconstrained objects (arrays or records)
8447 @item No_Select_Statements
8448 @findex No_Select_Statements
8449 This restriction ensures at compile time no select statements of any kind
8450 are permitted, that is the keyword @code{select} may not appear.
8451 This is one of the restrictions of the Ravenscar
8452 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8454 @item No_Standard_Storage_Pools
8455 @findex No_Standard_Storage_Pools
8456 This restriction ensures at compile time that no access types
8457 use the standard default storage pool. Any access type declared must
8458 have an explicit Storage_Pool attribute defined specifying a
8459 user-defined storage pool.
8463 This restriction ensures at compile/bind time that there are no
8464 stream objects created (and therefore no actual stream operations).
8465 This restriction does not forbid dependences on the package
8466 @code{Ada.Streams}. So it is permissible to with
8467 @code{Ada.Streams} (or another package that does so itself)
8468 as long as no actual stream objects are created.
8470 @item No_Task_Attributes_Package
8471 @findex No_Task_Attributes_Package
8472 This restriction ensures at compile time that there are no implicit or
8473 explicit dependencies on the package @code{Ada.Task_Attributes}.
8475 @item No_Task_Termination
8476 @findex No_Task_Termination
8477 This restriction ensures at compile time that no terminate alternatives
8478 appear in any task body.
8482 This restriction prevents the declaration of tasks or task types throughout
8483 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
8484 except that violations are caught at compile time and cause an error message
8485 to be output either by the compiler or binder.
8487 @item Static_Priorities
8488 @findex Static_Priorities
8489 This restriction ensures at compile time that all priority expressions
8490 are static, and that there are no dependencies on the package
8491 @code{Ada.Dynamic_Priorities}.
8493 @item Static_Storage_Size
8494 @findex Static_Storage_Size
8495 This restriction ensures at compile time that any expression appearing
8496 in a Storage_Size pragma or attribute definition clause is static.
8501 The second set of implementation dependent restriction identifiers
8502 does not require partition-wide consistency.
8503 The restriction may be enforced for a single
8504 compilation unit without any effect on any of the
8505 other compilation units in the partition.
8509 @item No_Elaboration_Code
8510 @findex No_Elaboration_Code
8511 This restriction ensures at compile time that no elaboration code is
8512 generated. Note that this is not the same condition as is enforced
8513 by pragma @code{Preelaborate}. There are cases in which pragma
8514 @code{Preelaborate} still permits code to be generated (e.g.@: code
8515 to initialize a large array to all zeroes), and there are cases of units
8516 which do not meet the requirements for pragma @code{Preelaborate},
8517 but for which no elaboration code is generated. Generally, it is
8518 the case that preelaborable units will meet the restrictions, with
8519 the exception of large aggregates initialized with an others_clause,
8520 and exception declarations (which generate calls to a run-time
8521 registry procedure). This restriction is enforced on
8522 a unit by unit basis, it need not be obeyed consistently
8523 throughout a partition.
8525 In the case of aggregates with others, if the aggregate has a dynamic
8526 size, there is no way to eliminate the elaboration code (such dynamic
8527 bounds would be incompatible with @code{Preelaborate} in any case). If
8528 the bounds are static, then use of this restriction actually modifies
8529 the code choice of the compiler to avoid generating a loop, and instead
8530 generate the aggregate statically if possible, no matter how many times
8531 the data for the others clause must be repeatedly generated.
8533 It is not possible to precisely document
8534 the constructs which are compatible with this restriction, since,
8535 unlike most other restrictions, this is not a restriction on the
8536 source code, but a restriction on the generated object code. For
8537 example, if the source contains a declaration:
8540 Val : constant Integer := X;
8544 where X is not a static constant, it may be possible, depending
8545 on complex optimization circuitry, for the compiler to figure
8546 out the value of X at compile time, in which case this initialization
8547 can be done by the loader, and requires no initialization code. It
8548 is not possible to document the precise conditions under which the
8549 optimizer can figure this out.
8551 Note that this the implementation of this restriction requires full
8552 code generation. If it is used in conjunction with "semantics only"
8553 checking, then some cases of violations may be missed.
8555 @item No_Entry_Queue
8556 @findex No_Entry_Queue
8557 This restriction is a declaration that any protected entry compiled in
8558 the scope of the restriction has at most one task waiting on the entry
8559 at any one time, and so no queue is required. This restriction is not
8560 checked at compile time. A program execution is erroneous if an attempt
8561 is made to queue a second task on such an entry.
8563 @item No_Implementation_Attributes
8564 @findex No_Implementation_Attributes
8565 This restriction checks at compile time that no GNAT-defined attributes
8566 are present. With this restriction, the only attributes that can be used
8567 are those defined in the Ada Reference Manual.
8569 @item No_Implementation_Pragmas
8570 @findex No_Implementation_Pragmas
8571 This restriction checks at compile time that no GNAT-defined pragmas
8572 are present. With this restriction, the only pragmas that can be used
8573 are those defined in the Ada Reference Manual.
8575 @item No_Implementation_Restrictions
8576 @findex No_Implementation_Restrictions
8577 This restriction checks at compile time that no GNAT-defined restriction
8578 identifiers (other than @code{No_Implementation_Restrictions} itself)
8579 are present. With this restriction, the only other restriction identifiers
8580 that can be used are those defined in the Ada Reference Manual.
8582 @item No_Wide_Characters
8583 @findex No_Wide_Characters
8584 This restriction ensures at compile time that no uses of the types
8585 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8587 appear, and that no wide or wide wide string or character literals
8588 appear in the program (that is literals representing characters not in
8589 type @code{Character}.
8596 @strong{58}. The consequences of violating limitations on
8597 @code{Restrictions} pragmas. See 13.12(9).
8600 Restrictions that can be checked at compile time result in illegalities
8601 if violated. Currently there are no other consequences of violating
8607 @strong{59}. The representation used by the @code{Read} and
8608 @code{Write} attributes of elementary types in terms of stream
8609 elements. See 13.13.2(9).
8612 The representation is the in-memory representation of the base type of
8613 the type, using the number of bits corresponding to the
8614 @code{@var{type}'Size} value, and the natural ordering of the machine.
8619 @strong{60}. The names and characteristics of the numeric subtypes
8620 declared in the visible part of package @code{Standard}. See A.1(3).
8623 See items describing the integer and floating-point types supported.
8628 @strong{61}. The accuracy actually achieved by the elementary
8629 functions. See A.5.1(1).
8632 The elementary functions correspond to the functions available in the C
8633 library. Only fast math mode is implemented.
8638 @strong{62}. The sign of a zero result from some of the operators or
8639 functions in @code{Numerics.Generic_Elementary_Functions}, when
8640 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
8643 The sign of zeroes follows the requirements of the IEEE 754 standard on
8649 @strong{63}. The value of
8650 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
8653 Maximum image width is 649, see library file @file{a-numran.ads}.
8658 @strong{64}. The value of
8659 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
8662 Maximum image width is 80, see library file @file{a-nudira.ads}.
8667 @strong{65}. The algorithms for random number generation. See
8671 The algorithm is documented in the source files @file{a-numran.ads} and
8672 @file{a-numran.adb}.
8677 @strong{66}. The string representation of a random number generator's
8678 state. See A.5.2(38).
8681 See the documentation contained in the file @file{a-numran.adb}.
8686 @strong{67}. The minimum time interval between calls to the
8687 time-dependent Reset procedure that are guaranteed to initiate different
8688 random number sequences. See A.5.2(45).
8691 The minimum period between reset calls to guarantee distinct series of
8692 random numbers is one microsecond.
8697 @strong{68}. The values of the @code{Model_Mantissa},
8698 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8699 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8700 Annex is not supported. See A.5.3(72).
8703 See the source file @file{ttypef.ads} for the values of all numeric
8709 @strong{69}. Any implementation-defined characteristics of the
8710 input-output packages. See A.7(14).
8713 There are no special implementation defined characteristics for these
8719 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
8723 All type representations are contiguous, and the @code{Buffer_Size} is
8724 the value of @code{@var{type}'Size} rounded up to the next storage unit
8730 @strong{71}. External files for standard input, standard output, and
8731 standard error See A.10(5).
8734 These files are mapped onto the files provided by the C streams
8735 libraries. See source file @file{i-cstrea.ads} for further details.
8740 @strong{72}. The accuracy of the value produced by @code{Put}. See
8744 If more digits are requested in the output than are represented by the
8745 precision of the value, zeroes are output in the corresponding least
8746 significant digit positions.
8751 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
8752 @code{Command_Name}. See A.15(1).
8755 These are mapped onto the @code{argv} and @code{argc} parameters of the
8756 main program in the natural manner.
8761 @strong{74}. Implementation-defined convention names. See B.1(11).
8764 The following convention names are supported
8772 Synonym for Assembler
8774 Synonym for Assembler
8777 @item C_Pass_By_Copy
8778 Allowed only for record types, like C, but also notes that record
8779 is to be passed by copy rather than reference.
8782 @item C_Plus_Plus (or CPP)
8785 Treated the same as C
8787 Treated the same as C
8791 For support of pragma @code{Import} with convention Intrinsic, see
8792 separate section on Intrinsic Subprograms.
8794 Stdcall (used for Windows implementations only). This convention correspond
8795 to the WINAPI (previously called Pascal convention) C/C++ convention under
8796 Windows. A function with this convention cleans the stack before exit.
8802 Stubbed is a special convention used to indicate that the body of the
8803 subprogram will be entirely ignored. Any call to the subprogram
8804 is converted into a raise of the @code{Program_Error} exception. If a
8805 pragma @code{Import} specifies convention @code{stubbed} then no body need
8806 be present at all. This convention is useful during development for the
8807 inclusion of subprograms whose body has not yet been written.
8811 In addition, all otherwise unrecognized convention names are also
8812 treated as being synonymous with convention C@. In all implementations
8813 except for VMS, use of such other names results in a warning. In VMS
8814 implementations, these names are accepted silently.
8819 @strong{75}. The meaning of link names. See B.1(36).
8822 Link names are the actual names used by the linker.
8827 @strong{76}. The manner of choosing link names when neither the link
8828 name nor the address of an imported or exported entity is specified. See
8832 The default linker name is that which would be assigned by the relevant
8833 external language, interpreting the Ada name as being in all lower case
8839 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
8842 The string passed to @code{Linker_Options} is presented uninterpreted as
8843 an argument to the link command, unless it contains ASCII.NUL characters.
8844 NUL characters if they appear act as argument separators, so for example
8846 @smallexample @c ada
8847 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
8851 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8852 linker. The order of linker options is preserved for a given unit. The final
8853 list of options passed to the linker is in reverse order of the elaboration
8854 order. For example, linker options for a body always appear before the options
8855 from the corresponding package spec.
8860 @strong{78}. The contents of the visible part of package
8861 @code{Interfaces} and its language-defined descendants. See B.2(1).
8864 See files with prefix @file{i-} in the distributed library.
8869 @strong{79}. Implementation-defined children of package
8870 @code{Interfaces}. The contents of the visible part of package
8871 @code{Interfaces}. See B.2(11).
8874 See files with prefix @file{i-} in the distributed library.
8879 @strong{80}. The types @code{Floating}, @code{Long_Floating},
8880 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8881 @code{COBOL_Character}; and the initialization of the variables
8882 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8883 @code{Interfaces.COBOL}. See B.4(50).
8890 (Floating) Long_Float
8895 @item Decimal_Element
8897 @item COBOL_Character
8902 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8907 @strong{81}. Support for access to machine instructions. See C.1(1).
8910 See documentation in file @file{s-maccod.ads} in the distributed library.
8915 @strong{82}. Implementation-defined aspects of access to machine
8916 operations. See C.1(9).
8919 See documentation in file @file{s-maccod.ads} in the distributed library.
8924 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
8927 Interrupts are mapped to signals or conditions as appropriate. See
8929 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8930 on the interrupts supported on a particular target.
8935 @strong{84}. Implementation-defined aspects of pre-elaboration. See
8939 GNAT does not permit a partition to be restarted without reloading,
8940 except under control of the debugger.
8945 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
8948 Pragma @code{Discard_Names} causes names of enumeration literals to
8949 be suppressed. In the presence of this pragma, the Image attribute
8950 provides the image of the Pos of the literal, and Value accepts
8956 @strong{86}. The result of the @code{Task_Identification.Image}
8957 attribute. See C.7.1(7).
8960 The result of this attribute is a string that identifies
8961 the object or component that denotes a given task. If a variable @code{Var}
8962 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
8964 is the hexadecimal representation of the virtual address of the corresponding
8965 task control block. If the variable is an array of tasks, the image of each
8966 task will have the form of an indexed component indicating the position of a
8967 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
8968 component of a record, the image of the task will have the form of a selected
8969 component. These rules are fully recursive, so that the image of a task that
8970 is a subcomponent of a composite object corresponds to the expression that
8971 designates this task.
8973 If a task is created by an allocator, its image depends on the context. If the
8974 allocator is part of an object declaration, the rules described above are used
8975 to construct its image, and this image is not affected by subsequent
8976 assignments. If the allocator appears within an expression, the image
8977 includes only the name of the task type.
8979 If the configuration pragma Discard_Names is present, or if the restriction
8980 No_Implicit_Heap_Allocation is in effect, the image reduces to
8981 the numeric suffix, that is to say the hexadecimal representation of the
8982 virtual address of the control block of the task.
8986 @strong{87}. The value of @code{Current_Task} when in a protected entry
8987 or interrupt handler. See C.7.1(17).
8990 Protected entries or interrupt handlers can be executed by any
8991 convenient thread, so the value of @code{Current_Task} is undefined.
8996 @strong{88}. The effect of calling @code{Current_Task} from an entry
8997 body or interrupt handler. See C.7.1(19).
9000 The effect of calling @code{Current_Task} from an entry body or
9001 interrupt handler is to return the identification of the task currently
9007 @strong{89}. Implementation-defined aspects of
9008 @code{Task_Attributes}. See C.7.2(19).
9011 There are no implementation-defined aspects of @code{Task_Attributes}.
9016 @strong{90}. Values of all @code{Metrics}. See D(2).
9019 The metrics information for GNAT depends on the performance of the
9020 underlying operating system. The sources of the run-time for tasking
9021 implementation, together with the output from @option{-gnatG} can be
9022 used to determine the exact sequence of operating systems calls made
9023 to implement various tasking constructs. Together with appropriate
9024 information on the performance of the underlying operating system,
9025 on the exact target in use, this information can be used to determine
9026 the required metrics.
9031 @strong{91}. The declarations of @code{Any_Priority} and
9032 @code{Priority}. See D.1(11).
9035 See declarations in file @file{system.ads}.
9040 @strong{92}. Implementation-defined execution resources. See D.1(15).
9043 There are no implementation-defined execution resources.
9048 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
9049 access to a protected object keeps its processor busy. See D.2.1(3).
9052 On a multi-processor, a task that is waiting for access to a protected
9053 object does not keep its processor busy.
9058 @strong{94}. The affect of implementation defined execution resources
9059 on task dispatching. See D.2.1(9).
9064 Tasks map to IRIX threads, and the dispatching policy is as defined by
9065 the IRIX implementation of threads.
9067 Tasks map to threads in the threads package used by GNAT@. Where possible
9068 and appropriate, these threads correspond to native threads of the
9069 underlying operating system.
9074 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
9075 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9078 There are no implementation-defined policy-identifiers allowed in this
9084 @strong{96}. Implementation-defined aspects of priority inversion. See
9088 Execution of a task cannot be preempted by the implementation processing
9089 of delay expirations for lower priority tasks.
9094 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
9099 Tasks map to IRIX threads, and the dispatching policy is as defined by
9100 the IRIX implementation of threads.
9102 The policy is the same as that of the underlying threads implementation.
9107 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9108 in a pragma @code{Locking_Policy}. See D.3(4).
9111 The only implementation defined policy permitted in GNAT is
9112 @code{Inheritance_Locking}. On targets that support this policy, locking
9113 is implemented by inheritance, i.e.@: the task owning the lock operates
9114 at a priority equal to the highest priority of any task currently
9115 requesting the lock.
9120 @strong{99}. Default ceiling priorities. See D.3(10).
9123 The ceiling priority of protected objects of the type
9124 @code{System.Interrupt_Priority'Last} as described in the Ada
9125 Reference Manual D.3(10),
9130 @strong{100}. The ceiling of any protected object used internally by
9131 the implementation. See D.3(16).
9134 The ceiling priority of internal protected objects is
9135 @code{System.Priority'Last}.
9140 @strong{101}. Implementation-defined queuing policies. See D.4(1).
9143 There are no implementation-defined queuing policies.
9148 @strong{102}. On a multiprocessor, any conditions that cause the
9149 completion of an aborted construct to be delayed later than what is
9150 specified for a single processor. See D.6(3).
9153 The semantics for abort on a multi-processor is the same as on a single
9154 processor, there are no further delays.
9159 @strong{103}. Any operations that implicitly require heap storage
9160 allocation. See D.7(8).
9163 The only operation that implicitly requires heap storage allocation is
9169 @strong{104}. Implementation-defined aspects of pragma
9170 @code{Restrictions}. See D.7(20).
9173 There are no such implementation-defined aspects.
9178 @strong{105}. Implementation-defined aspects of package
9179 @code{Real_Time}. See D.8(17).
9182 There are no implementation defined aspects of package @code{Real_Time}.
9187 @strong{106}. Implementation-defined aspects of
9188 @code{delay_statements}. See D.9(8).
9191 Any difference greater than one microsecond will cause the task to be
9192 delayed (see D.9(7)).
9197 @strong{107}. The upper bound on the duration of interrupt blocking
9198 caused by the implementation. See D.12(5).
9201 The upper bound is determined by the underlying operating system. In
9202 no cases is it more than 10 milliseconds.
9207 @strong{108}. The means for creating and executing distributed
9211 The GLADE package provides a utility GNATDIST for creating and executing
9212 distributed programs. See the GLADE reference manual for further details.
9217 @strong{109}. Any events that can result in a partition becoming
9218 inaccessible. See E.1(7).
9221 See the GLADE reference manual for full details on such events.
9226 @strong{110}. The scheduling policies, treatment of priorities, and
9227 management of shared resources between partitions in certain cases. See
9231 See the GLADE reference manual for full details on these aspects of
9232 multi-partition execution.
9237 @strong{111}. Events that cause the version of a compilation unit to
9241 Editing the source file of a compilation unit, or the source files of
9242 any units on which it is dependent in a significant way cause the version
9243 to change. No other actions cause the version number to change. All changes
9244 are significant except those which affect only layout, capitalization or
9250 @strong{112}. Whether the execution of the remote subprogram is
9251 immediately aborted as a result of cancellation. See E.4(13).
9254 See the GLADE reference manual for details on the effect of abort in
9255 a distributed application.
9260 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
9263 See the GLADE reference manual for a full description of all implementation
9264 defined aspects of the PCS@.
9269 @strong{114}. Implementation-defined interfaces in the PCS@. See
9273 See the GLADE reference manual for a full description of all
9274 implementation defined interfaces.
9279 @strong{115}. The values of named numbers in the package
9280 @code{Decimal}. See F.2(7).
9292 @item Max_Decimal_Digits
9299 @strong{116}. The value of @code{Max_Picture_Length} in the package
9300 @code{Text_IO.Editing}. See F.3.3(16).
9308 @strong{117}. The value of @code{Max_Picture_Length} in the package
9309 @code{Wide_Text_IO.Editing}. See F.3.4(5).
9317 @strong{118}. The accuracy actually achieved by the complex elementary
9318 functions and by other complex arithmetic operations. See G.1(1).
9321 Standard library functions are used for the complex arithmetic
9322 operations. Only fast math mode is currently supported.
9327 @strong{119}. The sign of a zero result (or a component thereof) from
9328 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9329 @code{Real'Signed_Zeros} is True. See G.1.1(53).
9332 The signs of zero values are as recommended by the relevant
9333 implementation advice.
9338 @strong{120}. The sign of a zero result (or a component thereof) from
9339 any operator or function in
9340 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9341 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
9344 The signs of zero values are as recommended by the relevant
9345 implementation advice.
9350 @strong{121}. Whether the strict mode or the relaxed mode is the
9351 default. See G.2(2).
9354 The strict mode is the default. There is no separate relaxed mode. GNAT
9355 provides a highly efficient implementation of strict mode.
9360 @strong{122}. The result interval in certain cases of fixed-to-float
9361 conversion. See G.2.1(10).
9364 For cases where the result interval is implementation dependent, the
9365 accuracy is that provided by performing all operations in 64-bit IEEE
9366 floating-point format.
9371 @strong{123}. The result of a floating point arithmetic operation in
9372 overflow situations, when the @code{Machine_Overflows} attribute of the
9373 result type is @code{False}. See G.2.1(13).
9376 Infinite and NaN values are produced as dictated by the IEEE
9377 floating-point standard.
9379 Note that on machines that are not fully compliant with the IEEE
9380 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9381 must be used for achieving IEEE confirming behavior (although at the cost
9382 of a significant performance penalty), so infinite and NaN values are
9388 @strong{124}. The result interval for division (or exponentiation by a
9389 negative exponent), when the floating point hardware implements division
9390 as multiplication by a reciprocal. See G.2.1(16).
9393 Not relevant, division is IEEE exact.
9398 @strong{125}. The definition of close result set, which determines the
9399 accuracy of certain fixed point multiplications and divisions. See
9403 Operations in the close result set are performed using IEEE long format
9404 floating-point arithmetic. The input operands are converted to
9405 floating-point, the operation is done in floating-point, and the result
9406 is converted to the target type.
9411 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
9412 point multiplication or division for which the result shall be in the
9413 perfect result set. See G.2.3(22).
9416 The result is only defined to be in the perfect result set if the result
9417 can be computed by a single scaling operation involving a scale factor
9418 representable in 64-bits.
9423 @strong{127}. The result of a fixed point arithmetic operation in
9424 overflow situations, when the @code{Machine_Overflows} attribute of the
9425 result type is @code{False}. See G.2.3(27).
9428 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9434 @strong{128}. The result of an elementary function reference in
9435 overflow situations, when the @code{Machine_Overflows} attribute of the
9436 result type is @code{False}. See G.2.4(4).
9439 IEEE infinite and Nan values are produced as appropriate.
9444 @strong{129}. The value of the angle threshold, within which certain
9445 elementary functions, complex arithmetic operations, and complex
9446 elementary functions yield results conforming to a maximum relative
9447 error bound. See G.2.4(10).
9450 Information on this subject is not yet available.
9455 @strong{130}. The accuracy of certain elementary functions for
9456 parameters beyond the angle threshold. See G.2.4(10).
9459 Information on this subject is not yet available.
9464 @strong{131}. The result of a complex arithmetic operation or complex
9465 elementary function reference in overflow situations, when the
9466 @code{Machine_Overflows} attribute of the corresponding real type is
9467 @code{False}. See G.2.6(5).
9470 IEEE infinite and Nan values are produced as appropriate.
9475 @strong{132}. The accuracy of certain complex arithmetic operations and
9476 certain complex elementary functions for parameters (or components
9477 thereof) beyond the angle threshold. See G.2.6(8).
9480 Information on those subjects is not yet available.
9485 @strong{133}. Information regarding bounded errors and erroneous
9486 execution. See H.2(1).
9489 Information on this subject is not yet available.
9494 @strong{134}. Implementation-defined aspects of pragma
9495 @code{Inspection_Point}. See H.3.2(8).
9498 Pragma @code{Inspection_Point} ensures that the variable is live and can
9499 be examined by the debugger at the inspection point.
9504 @strong{135}. Implementation-defined aspects of pragma
9505 @code{Restrictions}. See H.4(25).
9508 There are no implementation-defined aspects of pragma @code{Restrictions}. The
9509 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9510 generated code. Checks must suppressed by use of pragma @code{Suppress}.
9515 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
9519 There are no restrictions on pragma @code{Restrictions}.
9521 @node Intrinsic Subprograms
9522 @chapter Intrinsic Subprograms
9523 @cindex Intrinsic Subprograms
9526 * Intrinsic Operators::
9527 * Enclosing_Entity::
9528 * Exception_Information::
9529 * Exception_Message::
9537 * Shift_Right_Arithmetic::
9542 GNAT allows a user application program to write the declaration:
9544 @smallexample @c ada
9545 pragma Import (Intrinsic, name);
9549 providing that the name corresponds to one of the implemented intrinsic
9550 subprograms in GNAT, and that the parameter profile of the referenced
9551 subprogram meets the requirements. This chapter describes the set of
9552 implemented intrinsic subprograms, and the requirements on parameter profiles.
9553 Note that no body is supplied; as with other uses of pragma Import, the
9554 body is supplied elsewhere (in this case by the compiler itself). Note
9555 that any use of this feature is potentially non-portable, since the
9556 Ada standard does not require Ada compilers to implement this feature.
9558 @node Intrinsic Operators
9559 @section Intrinsic Operators
9560 @cindex Intrinsic operator
9563 All the predefined numeric operators in package Standard
9564 in @code{pragma Import (Intrinsic,..)}
9565 declarations. In the binary operator case, the operands must have the same
9566 size. The operand or operands must also be appropriate for
9567 the operator. For example, for addition, the operands must
9568 both be floating-point or both be fixed-point, and the
9569 right operand for @code{"**"} must have a root type of
9570 @code{Standard.Integer'Base}.
9571 You can use an intrinsic operator declaration as in the following example:
9573 @smallexample @c ada
9574 type Int1 is new Integer;
9575 type Int2 is new Integer;
9577 function "+" (X1 : Int1; X2 : Int2) return Int1;
9578 function "+" (X1 : Int1; X2 : Int2) return Int2;
9579 pragma Import (Intrinsic, "+");
9583 This declaration would permit ``mixed mode'' arithmetic on items
9584 of the differing types @code{Int1} and @code{Int2}.
9585 It is also possible to specify such operators for private types, if the
9586 full views are appropriate arithmetic types.
9588 @node Enclosing_Entity
9589 @section Enclosing_Entity
9590 @cindex Enclosing_Entity
9592 This intrinsic subprogram is used in the implementation of the
9593 library routine @code{GNAT.Source_Info}. The only useful use of the
9594 intrinsic import in this case is the one in this unit, so an
9595 application program should simply call the function
9596 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9597 the current subprogram, package, task, entry, or protected subprogram.
9599 @node Exception_Information
9600 @section Exception_Information
9601 @cindex Exception_Information'
9603 This intrinsic subprogram is used in the implementation of the
9604 library routine @code{GNAT.Current_Exception}. The only useful
9605 use of the intrinsic import in this case is the one in this unit,
9606 so an application program should simply call the function
9607 @code{GNAT.Current_Exception.Exception_Information} to obtain
9608 the exception information associated with the current exception.
9610 @node Exception_Message
9611 @section Exception_Message
9612 @cindex Exception_Message
9614 This intrinsic subprogram is used in the implementation of the
9615 library routine @code{GNAT.Current_Exception}. The only useful
9616 use of the intrinsic import in this case is the one in this unit,
9617 so an application program should simply call the function
9618 @code{GNAT.Current_Exception.Exception_Message} to obtain
9619 the message associated with the current exception.
9621 @node Exception_Name
9622 @section Exception_Name
9623 @cindex Exception_Name
9625 This intrinsic subprogram is used in the implementation of the
9626 library routine @code{GNAT.Current_Exception}. The only useful
9627 use of the intrinsic import in this case is the one in this unit,
9628 so an application program should simply call the function
9629 @code{GNAT.Current_Exception.Exception_Name} to obtain
9630 the name of the current exception.
9636 This intrinsic subprogram is used in the implementation of the
9637 library routine @code{GNAT.Source_Info}. The only useful use of the
9638 intrinsic import in this case is the one in this unit, so an
9639 application program should simply call the function
9640 @code{GNAT.Source_Info.File} to obtain the name of the current
9647 This intrinsic subprogram is used in the implementation of the
9648 library routine @code{GNAT.Source_Info}. The only useful use of the
9649 intrinsic import in this case is the one in this unit, so an
9650 application program should simply call the function
9651 @code{GNAT.Source_Info.Line} to obtain the number of the current
9655 @section Rotate_Left
9658 In standard Ada, the @code{Rotate_Left} function is available only
9659 for the predefined modular types in package @code{Interfaces}. However, in
9660 GNAT it is possible to define a Rotate_Left function for a user
9661 defined modular type or any signed integer type as in this example:
9663 @smallexample @c ada
9665 (Value : My_Modular_Type;
9667 return My_Modular_Type;
9671 The requirements are that the profile be exactly as in the example
9672 above. The only modifications allowed are in the formal parameter
9673 names, and in the type of @code{Value} and the return type, which
9674 must be the same, and must be either a signed integer type, or
9675 a modular integer type with a binary modulus, and the size must
9676 be 8. 16, 32 or 64 bits.
9679 @section Rotate_Right
9680 @cindex Rotate_Right
9682 A @code{Rotate_Right} function can be defined for any user defined
9683 binary modular integer type, or signed integer type, as described
9684 above for @code{Rotate_Left}.
9690 A @code{Shift_Left} function can be defined for any user defined
9691 binary modular integer type, or signed integer type, as described
9692 above for @code{Rotate_Left}.
9695 @section Shift_Right
9698 A @code{Shift_Right} function can be defined for any user defined
9699 binary modular integer type, or signed integer type, as described
9700 above for @code{Rotate_Left}.
9702 @node Shift_Right_Arithmetic
9703 @section Shift_Right_Arithmetic
9704 @cindex Shift_Right_Arithmetic
9706 A @code{Shift_Right_Arithmetic} function can be defined for any user
9707 defined binary modular integer type, or signed integer type, as described
9708 above for @code{Rotate_Left}.
9710 @node Source_Location
9711 @section Source_Location
9712 @cindex Source_Location
9714 This intrinsic subprogram is used in the implementation of the
9715 library routine @code{GNAT.Source_Info}. The only useful use of the
9716 intrinsic import in this case is the one in this unit, so an
9717 application program should simply call the function
9718 @code{GNAT.Source_Info.Source_Location} to obtain the current
9719 source file location.
9721 @node Representation Clauses and Pragmas
9722 @chapter Representation Clauses and Pragmas
9723 @cindex Representation Clauses
9726 * Alignment Clauses::
9728 * Storage_Size Clauses::
9729 * Size of Variant Record Objects::
9730 * Biased Representation ::
9731 * Value_Size and Object_Size Clauses::
9732 * Component_Size Clauses::
9733 * Bit_Order Clauses::
9734 * Effect of Bit_Order on Byte Ordering::
9735 * Pragma Pack for Arrays::
9736 * Pragma Pack for Records::
9737 * Record Representation Clauses::
9738 * Enumeration Clauses::
9740 * Effect of Convention on Representation::
9741 * Determining the Representations chosen by GNAT::
9745 @cindex Representation Clause
9746 @cindex Representation Pragma
9747 @cindex Pragma, representation
9748 This section describes the representation clauses accepted by GNAT, and
9749 their effect on the representation of corresponding data objects.
9751 GNAT fully implements Annex C (Systems Programming). This means that all
9752 the implementation advice sections in chapter 13 are fully implemented.
9753 However, these sections only require a minimal level of support for
9754 representation clauses. GNAT provides much more extensive capabilities,
9755 and this section describes the additional capabilities provided.
9757 @node Alignment Clauses
9758 @section Alignment Clauses
9759 @cindex Alignment Clause
9762 GNAT requires that all alignment clauses specify a power of 2, and all
9763 default alignments are always a power of 2. The default alignment
9764 values are as follows:
9767 @item @emph{Primitive Types}.
9768 For primitive types, the alignment is the minimum of the actual size of
9769 objects of the type divided by @code{Storage_Unit},
9770 and the maximum alignment supported by the target.
9771 (This maximum alignment is given by the GNAT-specific attribute
9772 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9773 @cindex @code{Maximum_Alignment} attribute
9774 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9775 default alignment will be 8 on any target that supports alignments
9776 this large, but on some targets, the maximum alignment may be smaller
9777 than 8, in which case objects of type @code{Long_Float} will be maximally
9780 @item @emph{Arrays}.
9781 For arrays, the alignment is equal to the alignment of the component type
9782 for the normal case where no packing or component size is given. If the
9783 array is packed, and the packing is effective (see separate section on
9784 packed arrays), then the alignment will be one for long packed arrays,
9785 or arrays whose length is not known at compile time. For short packed
9786 arrays, which are handled internally as modular types, the alignment
9787 will be as described for primitive types, e.g.@: a packed array of length
9788 31 bits will have an object size of four bytes, and an alignment of 4.
9790 @item @emph{Records}.
9791 For the normal non-packed case, the alignment of a record is equal to
9792 the maximum alignment of any of its components. For tagged records, this
9793 includes the implicit access type used for the tag. If a pragma @code{Pack}
9794 is used and all components are packable (see separate section on pragma
9795 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9796 record makes it profitable to increase it.
9798 A special case is when:
9801 the size of the record is given explicitly, or a
9802 full record representation clause is given, and
9804 the size of the record is 2, 4, or 8 bytes.
9807 In this case, an alignment is chosen to match the
9808 size of the record. For example, if we have:
9810 @smallexample @c ada
9811 type Small is record
9814 for Small'Size use 16;
9818 then the default alignment of the record type @code{Small} is 2, not 1. This
9819 leads to more efficient code when the record is treated as a unit, and also
9820 allows the type to specified as @code{Atomic} on architectures requiring
9826 An alignment clause may specify a larger alignment than the default value
9827 up to some maximum value dependent on the target (obtainable by using the
9828 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9829 a smaller alignment than the default value for enumeration, integer and
9830 fixed point types, as well as for record types, for example
9832 @smallexample @c ada
9837 for V'alignment use 1;
9841 @cindex Alignment, default
9842 The default alignment for the type @code{V} is 4, as a result of the
9843 Integer field in the record, but it is permissible, as shown, to
9844 override the default alignment of the record with a smaller value.
9847 @section Size Clauses
9851 The default size for a type @code{T} is obtainable through the
9852 language-defined attribute @code{T'Size} and also through the
9853 equivalent GNAT-defined attribute @code{T'Value_Size}.
9854 For objects of type @code{T}, GNAT will generally increase the type size
9855 so that the object size (obtainable through the GNAT-defined attribute
9856 @code{T'Object_Size})
9857 is a multiple of @code{T'Alignment * Storage_Unit}.
9860 @smallexample @c ada
9861 type Smallint is range 1 .. 6;
9870 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9871 as specified by the RM rules,
9872 but objects of this type will have a size of 8
9873 (@code{Smallint'Object_Size} = 8),
9874 since objects by default occupy an integral number
9875 of storage units. On some targets, notably older
9876 versions of the Digital Alpha, the size of stand
9877 alone objects of this type may be 32, reflecting
9878 the inability of the hardware to do byte load/stores.
9880 Similarly, the size of type @code{Rec} is 40 bits
9881 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9882 the alignment is 4, so objects of this type will have
9883 their size increased to 64 bits so that it is a multiple
9884 of the alignment (in bits). This decision is
9885 in accordance with the specific Implementation Advice in RM 13.3(43):
9888 A @code{Size} clause should be supported for an object if the specified
9889 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9890 to a size in storage elements that is a multiple of the object's
9891 @code{Alignment} (if the @code{Alignment} is nonzero).
9895 An explicit size clause may be used to override the default size by
9896 increasing it. For example, if we have:
9898 @smallexample @c ada
9899 type My_Boolean is new Boolean;
9900 for My_Boolean'Size use 32;
9904 then values of this type will always be 32 bits long. In the case of
9905 discrete types, the size can be increased up to 64 bits, with the effect
9906 that the entire specified field is used to hold the value, sign- or
9907 zero-extended as appropriate. If more than 64 bits is specified, then
9908 padding space is allocated after the value, and a warning is issued that
9909 there are unused bits.
9911 Similarly the size of records and arrays may be increased, and the effect
9912 is to add padding bits after the value. This also causes a warning message
9915 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
9916 Size in bits, this corresponds to an object of size 256 megabytes (minus
9917 one). This limitation is true on all targets. The reason for this
9918 limitation is that it improves the quality of the code in many cases
9919 if it is known that a Size value can be accommodated in an object of
9922 @node Storage_Size Clauses
9923 @section Storage_Size Clauses
9924 @cindex Storage_Size Clause
9927 For tasks, the @code{Storage_Size} clause specifies the amount of space
9928 to be allocated for the task stack. This cannot be extended, and if the
9929 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9930 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
9931 or a @code{Storage_Size} pragma in the task definition to set the
9932 appropriate required size. A useful technique is to include in every
9933 task definition a pragma of the form:
9935 @smallexample @c ada
9936 pragma Storage_Size (Default_Stack_Size);
9940 Then @code{Default_Stack_Size} can be defined in a global package, and
9941 modified as required. Any tasks requiring stack sizes different from the
9942 default can have an appropriate alternative reference in the pragma.
9944 You can also use the @option{-d} binder switch to modify the default stack
9947 For access types, the @code{Storage_Size} clause specifies the maximum
9948 space available for allocation of objects of the type. If this space is
9949 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9950 In the case where the access type is declared local to a subprogram, the
9951 use of a @code{Storage_Size} clause triggers automatic use of a special
9952 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9953 space for the pool is automatically reclaimed on exit from the scope in
9954 which the type is declared.
9956 A special case recognized by the compiler is the specification of a
9957 @code{Storage_Size} of zero for an access type. This means that no
9958 items can be allocated from the pool, and this is recognized at compile
9959 time, and all the overhead normally associated with maintaining a fixed
9960 size storage pool is eliminated. Consider the following example:
9962 @smallexample @c ada
9964 type R is array (Natural) of Character;
9965 type P is access all R;
9966 for P'Storage_Size use 0;
9967 -- Above access type intended only for interfacing purposes
9971 procedure g (m : P);
9972 pragma Import (C, g);
9983 As indicated in this example, these dummy storage pools are often useful in
9984 connection with interfacing where no object will ever be allocated. If you
9985 compile the above example, you get the warning:
9988 p.adb:16:09: warning: allocation from empty storage pool
9989 p.adb:16:09: warning: Storage_Error will be raised at run time
9993 Of course in practice, there will not be any explicit allocators in the
9994 case of such an access declaration.
9996 @node Size of Variant Record Objects
9997 @section Size of Variant Record Objects
9998 @cindex Size, variant record objects
9999 @cindex Variant record objects, size
10002 In the case of variant record objects, there is a question whether Size gives
10003 information about a particular variant, or the maximum size required
10004 for any variant. Consider the following program
10006 @smallexample @c ada
10007 with Text_IO; use Text_IO;
10009 type R1 (A : Boolean := False) is record
10011 when True => X : Character;
10012 when False => null;
10020 Put_Line (Integer'Image (V1'Size));
10021 Put_Line (Integer'Image (V2'Size));
10026 Here we are dealing with a variant record, where the True variant
10027 requires 16 bits, and the False variant requires 8 bits.
10028 In the above example, both V1 and V2 contain the False variant,
10029 which is only 8 bits long. However, the result of running the
10038 The reason for the difference here is that the discriminant value of
10039 V1 is fixed, and will always be False. It is not possible to assign
10040 a True variant value to V1, therefore 8 bits is sufficient. On the
10041 other hand, in the case of V2, the initial discriminant value is
10042 False (from the default), but it is possible to assign a True
10043 variant value to V2, therefore 16 bits must be allocated for V2
10044 in the general case, even fewer bits may be needed at any particular
10045 point during the program execution.
10047 As can be seen from the output of this program, the @code{'Size}
10048 attribute applied to such an object in GNAT gives the actual allocated
10049 size of the variable, which is the largest size of any of the variants.
10050 The Ada Reference Manual is not completely clear on what choice should
10051 be made here, but the GNAT behavior seems most consistent with the
10052 language in the RM@.
10054 In some cases, it may be desirable to obtain the size of the current
10055 variant, rather than the size of the largest variant. This can be
10056 achieved in GNAT by making use of the fact that in the case of a
10057 subprogram parameter, GNAT does indeed return the size of the current
10058 variant (because a subprogram has no way of knowing how much space
10059 is actually allocated for the actual).
10061 Consider the following modified version of the above program:
10063 @smallexample @c ada
10064 with Text_IO; use Text_IO;
10066 type R1 (A : Boolean := False) is record
10068 when True => X : Character;
10069 when False => null;
10075 function Size (V : R1) return Integer is
10081 Put_Line (Integer'Image (V2'Size));
10082 Put_Line (Integer'IMage (Size (V2)));
10084 Put_Line (Integer'Image (V2'Size));
10085 Put_Line (Integer'IMage (Size (V2)));
10090 The output from this program is
10100 Here we see that while the @code{'Size} attribute always returns
10101 the maximum size, regardless of the current variant value, the
10102 @code{Size} function does indeed return the size of the current
10105 @node Biased Representation
10106 @section Biased Representation
10107 @cindex Size for biased representation
10108 @cindex Biased representation
10111 In the case of scalars with a range starting at other than zero, it is
10112 possible in some cases to specify a size smaller than the default minimum
10113 value, and in such cases, GNAT uses an unsigned biased representation,
10114 in which zero is used to represent the lower bound, and successive values
10115 represent successive values of the type.
10117 For example, suppose we have the declaration:
10119 @smallexample @c ada
10120 type Small is range -7 .. -4;
10121 for Small'Size use 2;
10125 Although the default size of type @code{Small} is 4, the @code{Size}
10126 clause is accepted by GNAT and results in the following representation
10130 -7 is represented as 2#00#
10131 -6 is represented as 2#01#
10132 -5 is represented as 2#10#
10133 -4 is represented as 2#11#
10137 Biased representation is only used if the specified @code{Size} clause
10138 cannot be accepted in any other manner. These reduced sizes that force
10139 biased representation can be used for all discrete types except for
10140 enumeration types for which a representation clause is given.
10142 @node Value_Size and Object_Size Clauses
10143 @section Value_Size and Object_Size Clauses
10145 @findex Object_Size
10146 @cindex Size, of objects
10149 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10150 number of bits required to hold values of type @code{T}.
10151 Although this interpretation was allowed in Ada 83, it was not required,
10152 and this requirement in practice can cause some significant difficulties.
10153 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10154 However, in Ada 95 and Ada 2005,
10155 @code{Natural'Size} is
10156 typically 31. This means that code may change in behavior when moving
10157 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10159 @smallexample @c ada
10160 type Rec is record;
10166 at 0 range 0 .. Natural'Size - 1;
10167 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10172 In the above code, since the typical size of @code{Natural} objects
10173 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10174 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10175 there are cases where the fact that the object size can exceed the
10176 size of the type causes surprises.
10178 To help get around this problem GNAT provides two implementation
10179 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10180 applied to a type, these attributes yield the size of the type
10181 (corresponding to the RM defined size attribute), and the size of
10182 objects of the type respectively.
10184 The @code{Object_Size} is used for determining the default size of
10185 objects and components. This size value can be referred to using the
10186 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10187 the basis of the determination of the size. The backend is free to
10188 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10189 character might be stored in 32 bits on a machine with no efficient
10190 byte access instructions such as the Alpha.
10192 The default rules for the value of @code{Object_Size} for
10193 discrete types are as follows:
10197 The @code{Object_Size} for base subtypes reflect the natural hardware
10198 size in bits (run the compiler with @option{-gnatS} to find those values
10199 for numeric types). Enumeration types and fixed-point base subtypes have
10200 8, 16, 32 or 64 bits for this size, depending on the range of values
10204 The @code{Object_Size} of a subtype is the same as the
10205 @code{Object_Size} of
10206 the type from which it is obtained.
10209 The @code{Object_Size} of a derived base type is copied from the parent
10210 base type, and the @code{Object_Size} of a derived first subtype is copied
10211 from the parent first subtype.
10215 The @code{Value_Size} attribute
10216 is the (minimum) number of bits required to store a value
10218 This value is used to determine how tightly to pack
10219 records or arrays with components of this type, and also affects
10220 the semantics of unchecked conversion (unchecked conversions where
10221 the @code{Value_Size} values differ generate a warning, and are potentially
10224 The default rules for the value of @code{Value_Size} are as follows:
10228 The @code{Value_Size} for a base subtype is the minimum number of bits
10229 required to store all values of the type (including the sign bit
10230 only if negative values are possible).
10233 If a subtype statically matches the first subtype of a given type, then it has
10234 by default the same @code{Value_Size} as the first subtype. This is a
10235 consequence of RM 13.1(14) (``if two subtypes statically match,
10236 then their subtype-specific aspects are the same''.)
10239 All other subtypes have a @code{Value_Size} corresponding to the minimum
10240 number of bits required to store all values of the subtype. For
10241 dynamic bounds, it is assumed that the value can range down or up
10242 to the corresponding bound of the ancestor
10246 The RM defined attribute @code{Size} corresponds to the
10247 @code{Value_Size} attribute.
10249 The @code{Size} attribute may be defined for a first-named subtype. This sets
10250 the @code{Value_Size} of
10251 the first-named subtype to the given value, and the
10252 @code{Object_Size} of this first-named subtype to the given value padded up
10253 to an appropriate boundary. It is a consequence of the default rules
10254 above that this @code{Object_Size} will apply to all further subtypes. On the
10255 other hand, @code{Value_Size} is affected only for the first subtype, any
10256 dynamic subtypes obtained from it directly, and any statically matching
10257 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
10259 @code{Value_Size} and
10260 @code{Object_Size} may be explicitly set for any subtype using
10261 an attribute definition clause. Note that the use of these attributes
10262 can cause the RM 13.1(14) rule to be violated. If two access types
10263 reference aliased objects whose subtypes have differing @code{Object_Size}
10264 values as a result of explicit attribute definition clauses, then it
10265 is erroneous to convert from one access subtype to the other.
10267 At the implementation level, Esize stores the Object_Size and the
10268 RM_Size field stores the @code{Value_Size} (and hence the value of the
10269 @code{Size} attribute,
10270 which, as noted above, is equivalent to @code{Value_Size}).
10272 To get a feel for the difference, consider the following examples (note
10273 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10276 Object_Size Value_Size
10278 type x1 is range 0 .. 5; 8 3
10280 type x2 is range 0 .. 5;
10281 for x2'size use 12; 16 12
10283 subtype x3 is x2 range 0 .. 3; 16 2
10285 subtype x4 is x2'base range 0 .. 10; 8 4
10287 subtype x5 is x2 range 0 .. dynamic; 16 3*
10289 subtype x6 is x2'base range 0 .. dynamic; 8 3*
10294 Note: the entries marked ``3*'' are not actually specified by the Ada
10295 Reference Manual, but it seems in the spirit of the RM rules to allocate
10296 the minimum number of bits (here 3, given the range for @code{x2})
10297 known to be large enough to hold the given range of values.
10299 So far, so good, but GNAT has to obey the RM rules, so the question is
10300 under what conditions must the RM @code{Size} be used.
10301 The following is a list
10302 of the occasions on which the RM @code{Size} must be used:
10306 Component size for packed arrays or records
10309 Value of the attribute @code{Size} for a type
10312 Warning about sizes not matching for unchecked conversion
10316 For record types, the @code{Object_Size} is always a multiple of the
10317 alignment of the type (this is true for all types). In some cases the
10318 @code{Value_Size} can be smaller. Consider:
10328 On a typical 32-bit architecture, the X component will be four bytes, and
10329 require four-byte alignment, and the Y component will be one byte. In this
10330 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10331 required to store a value of this type, and for example, it is permissible
10332 to have a component of type R in an outer record whose component size is
10333 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10334 since it must be rounded up so that this value is a multiple of the
10335 alignment (4 bytes = 32 bits).
10338 For all other types, the @code{Object_Size}
10339 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10340 Only @code{Size} may be specified for such types.
10342 @node Component_Size Clauses
10343 @section Component_Size Clauses
10344 @cindex Component_Size Clause
10347 Normally, the value specified in a component size clause must be consistent
10348 with the subtype of the array component with regard to size and alignment.
10349 In other words, the value specified must be at least equal to the size
10350 of this subtype, and must be a multiple of the alignment value.
10352 In addition, component size clauses are allowed which cause the array
10353 to be packed, by specifying a smaller value. A first case is for
10354 component size values in the range 1 through 63. The value specified
10355 must not be smaller than the Size of the subtype. GNAT will accurately
10356 honor all packing requests in this range. For example, if we have:
10358 @smallexample @c ada
10359 type r is array (1 .. 8) of Natural;
10360 for r'Component_Size use 31;
10364 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10365 Of course access to the components of such an array is considerably
10366 less efficient than if the natural component size of 32 is used.
10367 A second case is when the subtype of the component is a record type
10368 padded because of its default alignment. For example, if we have:
10370 @smallexample @c ada
10377 type a is array (1 .. 8) of r;
10378 for a'Component_Size use 72;
10382 then the resulting array has a length of 72 bytes, instead of 96 bytes
10383 if the alignment of the record (4) was obeyed.
10385 Note that there is no point in giving both a component size clause
10386 and a pragma Pack for the same array type. if such duplicate
10387 clauses are given, the pragma Pack will be ignored.
10389 @node Bit_Order Clauses
10390 @section Bit_Order Clauses
10391 @cindex Bit_Order Clause
10392 @cindex bit ordering
10393 @cindex ordering, of bits
10396 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10397 attribute. The specification may either correspond to the default bit
10398 order for the target, in which case the specification has no effect and
10399 places no additional restrictions, or it may be for the non-standard
10400 setting (that is the opposite of the default).
10402 In the case where the non-standard value is specified, the effect is
10403 to renumber bits within each byte, but the ordering of bytes is not
10404 affected. There are certain
10405 restrictions placed on component clauses as follows:
10409 @item Components fitting within a single storage unit.
10411 These are unrestricted, and the effect is merely to renumber bits. For
10412 example if we are on a little-endian machine with @code{Low_Order_First}
10413 being the default, then the following two declarations have exactly
10416 @smallexample @c ada
10419 B : Integer range 1 .. 120;
10423 A at 0 range 0 .. 0;
10424 B at 0 range 1 .. 7;
10429 B : Integer range 1 .. 120;
10432 for R2'Bit_Order use High_Order_First;
10435 A at 0 range 7 .. 7;
10436 B at 0 range 0 .. 6;
10441 The useful application here is to write the second declaration with the
10442 @code{Bit_Order} attribute definition clause, and know that it will be treated
10443 the same, regardless of whether the target is little-endian or big-endian.
10445 @item Components occupying an integral number of bytes.
10447 These are components that exactly fit in two or more bytes. Such component
10448 declarations are allowed, but have no effect, since it is important to realize
10449 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10450 In particular, the following attempt at getting an endian-independent integer
10453 @smallexample @c ada
10458 for R2'Bit_Order use High_Order_First;
10461 A at 0 range 0 .. 31;
10466 This declaration will result in a little-endian integer on a
10467 little-endian machine, and a big-endian integer on a big-endian machine.
10468 If byte flipping is required for interoperability between big- and
10469 little-endian machines, this must be explicitly programmed. This capability
10470 is not provided by @code{Bit_Order}.
10472 @item Components that are positioned across byte boundaries
10474 but do not occupy an integral number of bytes. Given that bytes are not
10475 reordered, such fields would occupy a non-contiguous sequence of bits
10476 in memory, requiring non-trivial code to reassemble. They are for this
10477 reason not permitted, and any component clause specifying such a layout
10478 will be flagged as illegal by GNAT@.
10483 Since the misconception that Bit_Order automatically deals with all
10484 endian-related incompatibilities is a common one, the specification of
10485 a component field that is an integral number of bytes will always
10486 generate a warning. This warning may be suppressed using @code{pragma
10487 Warnings (Off)} if desired. The following section contains additional
10488 details regarding the issue of byte ordering.
10490 @node Effect of Bit_Order on Byte Ordering
10491 @section Effect of Bit_Order on Byte Ordering
10492 @cindex byte ordering
10493 @cindex ordering, of bytes
10496 In this section we will review the effect of the @code{Bit_Order} attribute
10497 definition clause on byte ordering. Briefly, it has no effect at all, but
10498 a detailed example will be helpful. Before giving this
10499 example, let us review the precise
10500 definition of the effect of defining @code{Bit_Order}. The effect of a
10501 non-standard bit order is described in section 15.5.3 of the Ada
10505 2 A bit ordering is a method of interpreting the meaning of
10506 the storage place attributes.
10510 To understand the precise definition of storage place attributes in
10511 this context, we visit section 13.5.1 of the manual:
10514 13 A record_representation_clause (without the mod_clause)
10515 specifies the layout. The storage place attributes (see 13.5.2)
10516 are taken from the values of the position, first_bit, and last_bit
10517 expressions after normalizing those values so that first_bit is
10518 less than Storage_Unit.
10522 The critical point here is that storage places are taken from
10523 the values after normalization, not before. So the @code{Bit_Order}
10524 interpretation applies to normalized values. The interpretation
10525 is described in the later part of the 15.5.3 paragraph:
10528 2 A bit ordering is a method of interpreting the meaning of
10529 the storage place attributes. High_Order_First (known in the
10530 vernacular as ``big endian'') means that the first bit of a
10531 storage element (bit 0) is the most significant bit (interpreting
10532 the sequence of bits that represent a component as an unsigned
10533 integer value). Low_Order_First (known in the vernacular as
10534 ``little endian'') means the opposite: the first bit is the
10539 Note that the numbering is with respect to the bits of a storage
10540 unit. In other words, the specification affects only the numbering
10541 of bits within a single storage unit.
10543 We can make the effect clearer by giving an example.
10545 Suppose that we have an external device which presents two bytes, the first
10546 byte presented, which is the first (low addressed byte) of the two byte
10547 record is called Master, and the second byte is called Slave.
10549 The left most (most significant bit is called Control for each byte, and
10550 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10551 (least significant) bit.
10553 On a big-endian machine, we can write the following representation clause
10555 @smallexample @c ada
10556 type Data is record
10557 Master_Control : Bit;
10565 Slave_Control : Bit;
10575 for Data use record
10576 Master_Control at 0 range 0 .. 0;
10577 Master_V1 at 0 range 1 .. 1;
10578 Master_V2 at 0 range 2 .. 2;
10579 Master_V3 at 0 range 3 .. 3;
10580 Master_V4 at 0 range 4 .. 4;
10581 Master_V5 at 0 range 5 .. 5;
10582 Master_V6 at 0 range 6 .. 6;
10583 Master_V7 at 0 range 7 .. 7;
10584 Slave_Control at 1 range 0 .. 0;
10585 Slave_V1 at 1 range 1 .. 1;
10586 Slave_V2 at 1 range 2 .. 2;
10587 Slave_V3 at 1 range 3 .. 3;
10588 Slave_V4 at 1 range 4 .. 4;
10589 Slave_V5 at 1 range 5 .. 5;
10590 Slave_V6 at 1 range 6 .. 6;
10591 Slave_V7 at 1 range 7 .. 7;
10596 Now if we move this to a little endian machine, then the bit ordering within
10597 the byte is backwards, so we have to rewrite the record rep clause as:
10599 @smallexample @c ada
10600 for Data use record
10601 Master_Control at 0 range 7 .. 7;
10602 Master_V1 at 0 range 6 .. 6;
10603 Master_V2 at 0 range 5 .. 5;
10604 Master_V3 at 0 range 4 .. 4;
10605 Master_V4 at 0 range 3 .. 3;
10606 Master_V5 at 0 range 2 .. 2;
10607 Master_V6 at 0 range 1 .. 1;
10608 Master_V7 at 0 range 0 .. 0;
10609 Slave_Control at 1 range 7 .. 7;
10610 Slave_V1 at 1 range 6 .. 6;
10611 Slave_V2 at 1 range 5 .. 5;
10612 Slave_V3 at 1 range 4 .. 4;
10613 Slave_V4 at 1 range 3 .. 3;
10614 Slave_V5 at 1 range 2 .. 2;
10615 Slave_V6 at 1 range 1 .. 1;
10616 Slave_V7 at 1 range 0 .. 0;
10621 It is a nuisance to have to rewrite the clause, especially if
10622 the code has to be maintained on both machines. However,
10623 this is a case that we can handle with the
10624 @code{Bit_Order} attribute if it is implemented.
10625 Note that the implementation is not required on byte addressed
10626 machines, but it is indeed implemented in GNAT.
10627 This means that we can simply use the
10628 first record clause, together with the declaration
10630 @smallexample @c ada
10631 for Data'Bit_Order use High_Order_First;
10635 and the effect is what is desired, namely the layout is exactly the same,
10636 independent of whether the code is compiled on a big-endian or little-endian
10639 The important point to understand is that byte ordering is not affected.
10640 A @code{Bit_Order} attribute definition never affects which byte a field
10641 ends up in, only where it ends up in that byte.
10642 To make this clear, let us rewrite the record rep clause of the previous
10645 @smallexample @c ada
10646 for Data'Bit_Order use High_Order_First;
10647 for Data use record
10648 Master_Control at 0 range 0 .. 0;
10649 Master_V1 at 0 range 1 .. 1;
10650 Master_V2 at 0 range 2 .. 2;
10651 Master_V3 at 0 range 3 .. 3;
10652 Master_V4 at 0 range 4 .. 4;
10653 Master_V5 at 0 range 5 .. 5;
10654 Master_V6 at 0 range 6 .. 6;
10655 Master_V7 at 0 range 7 .. 7;
10656 Slave_Control at 0 range 8 .. 8;
10657 Slave_V1 at 0 range 9 .. 9;
10658 Slave_V2 at 0 range 10 .. 10;
10659 Slave_V3 at 0 range 11 .. 11;
10660 Slave_V4 at 0 range 12 .. 12;
10661 Slave_V5 at 0 range 13 .. 13;
10662 Slave_V6 at 0 range 14 .. 14;
10663 Slave_V7 at 0 range 15 .. 15;
10668 This is exactly equivalent to saying (a repeat of the first example):
10670 @smallexample @c ada
10671 for Data'Bit_Order use High_Order_First;
10672 for Data use record
10673 Master_Control at 0 range 0 .. 0;
10674 Master_V1 at 0 range 1 .. 1;
10675 Master_V2 at 0 range 2 .. 2;
10676 Master_V3 at 0 range 3 .. 3;
10677 Master_V4 at 0 range 4 .. 4;
10678 Master_V5 at 0 range 5 .. 5;
10679 Master_V6 at 0 range 6 .. 6;
10680 Master_V7 at 0 range 7 .. 7;
10681 Slave_Control at 1 range 0 .. 0;
10682 Slave_V1 at 1 range 1 .. 1;
10683 Slave_V2 at 1 range 2 .. 2;
10684 Slave_V3 at 1 range 3 .. 3;
10685 Slave_V4 at 1 range 4 .. 4;
10686 Slave_V5 at 1 range 5 .. 5;
10687 Slave_V6 at 1 range 6 .. 6;
10688 Slave_V7 at 1 range 7 .. 7;
10693 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10694 field. The storage place attributes are obtained by normalizing the
10695 values given so that the @code{First_Bit} value is less than 8. After
10696 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10697 we specified in the other case.
10699 Now one might expect that the @code{Bit_Order} attribute might affect
10700 bit numbering within the entire record component (two bytes in this
10701 case, thus affecting which byte fields end up in), but that is not
10702 the way this feature is defined, it only affects numbering of bits,
10703 not which byte they end up in.
10705 Consequently it never makes sense to specify a starting bit number
10706 greater than 7 (for a byte addressable field) if an attribute
10707 definition for @code{Bit_Order} has been given, and indeed it
10708 may be actively confusing to specify such a value, so the compiler
10709 generates a warning for such usage.
10711 If you do need to control byte ordering then appropriate conditional
10712 values must be used. If in our example, the slave byte came first on
10713 some machines we might write:
10715 @smallexample @c ada
10716 Master_Byte_First constant Boolean := @dots{};
10718 Master_Byte : constant Natural :=
10719 1 - Boolean'Pos (Master_Byte_First);
10720 Slave_Byte : constant Natural :=
10721 Boolean'Pos (Master_Byte_First);
10723 for Data'Bit_Order use High_Order_First;
10724 for Data use record
10725 Master_Control at Master_Byte range 0 .. 0;
10726 Master_V1 at Master_Byte range 1 .. 1;
10727 Master_V2 at Master_Byte range 2 .. 2;
10728 Master_V3 at Master_Byte range 3 .. 3;
10729 Master_V4 at Master_Byte range 4 .. 4;
10730 Master_V5 at Master_Byte range 5 .. 5;
10731 Master_V6 at Master_Byte range 6 .. 6;
10732 Master_V7 at Master_Byte range 7 .. 7;
10733 Slave_Control at Slave_Byte range 0 .. 0;
10734 Slave_V1 at Slave_Byte range 1 .. 1;
10735 Slave_V2 at Slave_Byte range 2 .. 2;
10736 Slave_V3 at Slave_Byte range 3 .. 3;
10737 Slave_V4 at Slave_Byte range 4 .. 4;
10738 Slave_V5 at Slave_Byte range 5 .. 5;
10739 Slave_V6 at Slave_Byte range 6 .. 6;
10740 Slave_V7 at Slave_Byte range 7 .. 7;
10745 Now to switch between machines, all that is necessary is
10746 to set the boolean constant @code{Master_Byte_First} in
10747 an appropriate manner.
10749 @node Pragma Pack for Arrays
10750 @section Pragma Pack for Arrays
10751 @cindex Pragma Pack (for arrays)
10754 Pragma @code{Pack} applied to an array has no effect unless the component type
10755 is packable. For a component type to be packable, it must be one of the
10762 Any type whose size is specified with a size clause
10764 Any packed array type with a static size
10766 Any record type padded because of its default alignment
10770 For all these cases, if the component subtype size is in the range
10771 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10772 component size were specified giving the component subtype size.
10773 For example if we have:
10775 @smallexample @c ada
10776 type r is range 0 .. 17;
10778 type ar is array (1 .. 8) of r;
10783 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10784 and the size of the array @code{ar} will be exactly 40 bits.
10786 Note that in some cases this rather fierce approach to packing can produce
10787 unexpected effects. For example, in Ada 95 and Ada 2005,
10788 subtype @code{Natural} typically has a size of 31, meaning that if you
10789 pack an array of @code{Natural}, you get 31-bit
10790 close packing, which saves a few bits, but results in far less efficient
10791 access. Since many other Ada compilers will ignore such a packing request,
10792 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10793 might not be what is intended. You can easily remove this warning by
10794 using an explicit @code{Component_Size} setting instead, which never generates
10795 a warning, since the intention of the programmer is clear in this case.
10797 GNAT treats packed arrays in one of two ways. If the size of the array is
10798 known at compile time and is less than 64 bits, then internally the array
10799 is represented as a single modular type, of exactly the appropriate number
10800 of bits. If the length is greater than 63 bits, or is not known at compile
10801 time, then the packed array is represented as an array of bytes, and the
10802 length is always a multiple of 8 bits.
10804 Note that to represent a packed array as a modular type, the alignment must
10805 be suitable for the modular type involved. For example, on typical machines
10806 a 32-bit packed array will be represented by a 32-bit modular integer with
10807 an alignment of four bytes. If you explicitly override the default alignment
10808 with an alignment clause that is too small, the modular representation
10809 cannot be used. For example, consider the following set of declarations:
10811 @smallexample @c ada
10812 type R is range 1 .. 3;
10813 type S is array (1 .. 31) of R;
10814 for S'Component_Size use 2;
10816 for S'Alignment use 1;
10820 If the alignment clause were not present, then a 62-bit modular
10821 representation would be chosen (typically with an alignment of 4 or 8
10822 bytes depending on the target). But the default alignment is overridden
10823 with the explicit alignment clause. This means that the modular
10824 representation cannot be used, and instead the array of bytes
10825 representation must be used, meaning that the length must be a multiple
10826 of 8. Thus the above set of declarations will result in a diagnostic
10827 rejecting the size clause and noting that the minimum size allowed is 64.
10829 @cindex Pragma Pack (for type Natural)
10830 @cindex Pragma Pack warning
10832 One special case that is worth noting occurs when the base type of the
10833 component size is 8/16/32 and the subtype is one bit less. Notably this
10834 occurs with subtype @code{Natural}. Consider:
10836 @smallexample @c ada
10837 type Arr is array (1 .. 32) of Natural;
10842 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10843 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10844 Ada 83 compilers did not attempt 31 bit packing.
10846 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10847 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10848 substantial unintended performance penalty when porting legacy Ada 83 code.
10849 To help prevent this, GNAT generates a warning in such cases. If you really
10850 want 31 bit packing in a case like this, you can set the component size
10853 @smallexample @c ada
10854 type Arr is array (1 .. 32) of Natural;
10855 for Arr'Component_Size use 31;
10859 Here 31-bit packing is achieved as required, and no warning is generated,
10860 since in this case the programmer intention is clear.
10862 @node Pragma Pack for Records
10863 @section Pragma Pack for Records
10864 @cindex Pragma Pack (for records)
10867 Pragma @code{Pack} applied to a record will pack the components to reduce
10868 wasted space from alignment gaps and by reducing the amount of space
10869 taken by components. We distinguish between @emph{packable} components and
10870 @emph{non-packable} components.
10871 Components of the following types are considered packable:
10874 All primitive types are packable.
10877 Small packed arrays, whose size does not exceed 64 bits, and where the
10878 size is statically known at compile time, are represented internally
10879 as modular integers, and so they are also packable.
10884 All packable components occupy the exact number of bits corresponding to
10885 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10886 can start on an arbitrary bit boundary.
10888 All other types are non-packable, they occupy an integral number of
10890 are placed at a boundary corresponding to their alignment requirements.
10892 For example, consider the record
10894 @smallexample @c ada
10895 type Rb1 is array (1 .. 13) of Boolean;
10898 type Rb2 is array (1 .. 65) of Boolean;
10913 The representation for the record x2 is as follows:
10915 @smallexample @c ada
10916 for x2'Size use 224;
10918 l1 at 0 range 0 .. 0;
10919 l2 at 0 range 1 .. 64;
10920 l3 at 12 range 0 .. 31;
10921 l4 at 16 range 0 .. 0;
10922 l5 at 16 range 1 .. 13;
10923 l6 at 18 range 0 .. 71;
10928 Studying this example, we see that the packable fields @code{l1}
10930 of length equal to their sizes, and placed at specific bit boundaries (and
10931 not byte boundaries) to
10932 eliminate padding. But @code{l3} is of a non-packable float type, so
10933 it is on the next appropriate alignment boundary.
10935 The next two fields are fully packable, so @code{l4} and @code{l5} are
10936 minimally packed with no gaps. However, type @code{Rb2} is a packed
10937 array that is longer than 64 bits, so it is itself non-packable. Thus
10938 the @code{l6} field is aligned to the next byte boundary, and takes an
10939 integral number of bytes, i.e.@: 72 bits.
10941 @node Record Representation Clauses
10942 @section Record Representation Clauses
10943 @cindex Record Representation Clause
10946 Record representation clauses may be given for all record types, including
10947 types obtained by record extension. Component clauses are allowed for any
10948 static component. The restrictions on component clauses depend on the type
10951 @cindex Component Clause
10952 For all components of an elementary type, the only restriction on component
10953 clauses is that the size must be at least the 'Size value of the type
10954 (actually the Value_Size). There are no restrictions due to alignment,
10955 and such components may freely cross storage boundaries.
10957 Packed arrays with a size up to and including 64 bits are represented
10958 internally using a modular type with the appropriate number of bits, and
10959 thus the same lack of restriction applies. For example, if you declare:
10961 @smallexample @c ada
10962 type R is array (1 .. 49) of Boolean;
10968 then a component clause for a component of type R may start on any
10969 specified bit boundary, and may specify a value of 49 bits or greater.
10971 For packed bit arrays that are longer than 64 bits, there are two
10972 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10973 including the important case of single bits or boolean values, then
10974 there are no limitations on placement of such components, and they
10975 may start and end at arbitrary bit boundaries.
10977 If the component size is not a power of 2 (e.g.@: 3 or 5), then
10978 an array of this type longer than 64 bits must always be placed on
10979 on a storage unit (byte) boundary and occupy an integral number
10980 of storage units (bytes). Any component clause that does not
10981 meet this requirement will be rejected.
10983 Any aliased component, or component of an aliased type, must
10984 have its normal alignment and size. A component clause that
10985 does not meet this requirement will be rejected.
10987 The tag field of a tagged type always occupies an address sized field at
10988 the start of the record. No component clause may attempt to overlay this
10989 tag. When a tagged type appears as a component, the tag field must have
10992 In the case of a record extension T1, of a type T, no component clause applied
10993 to the type T1 can specify a storage location that would overlap the first
10994 T'Size bytes of the record.
10996 For all other component types, including non-bit-packed arrays,
10997 the component can be placed at an arbitrary bit boundary,
10998 so for example, the following is permitted:
11000 @smallexample @c ada
11001 type R is array (1 .. 10) of Boolean;
11010 G at 0 range 0 .. 0;
11011 H at 0 range 1 .. 1;
11012 L at 0 range 2 .. 81;
11013 R at 0 range 82 .. 161;
11018 Note: the above rules apply to recent releases of GNAT 5.
11019 In GNAT 3, there are more severe restrictions on larger components.
11020 For non-primitive types, including packed arrays with a size greater than
11021 64 bits, component clauses must respect the alignment requirement of the
11022 type, in particular, always starting on a byte boundary, and the length
11023 must be a multiple of the storage unit.
11025 @node Enumeration Clauses
11026 @section Enumeration Clauses
11028 The only restriction on enumeration clauses is that the range of values
11029 must be representable. For the signed case, if one or more of the
11030 representation values are negative, all values must be in the range:
11032 @smallexample @c ada
11033 System.Min_Int .. System.Max_Int
11037 For the unsigned case, where all values are nonnegative, the values must
11040 @smallexample @c ada
11041 0 .. System.Max_Binary_Modulus;
11045 A @emph{confirming} representation clause is one in which the values range
11046 from 0 in sequence, i.e.@: a clause that confirms the default representation
11047 for an enumeration type.
11048 Such a confirming representation
11049 is permitted by these rules, and is specially recognized by the compiler so
11050 that no extra overhead results from the use of such a clause.
11052 If an array has an index type which is an enumeration type to which an
11053 enumeration clause has been applied, then the array is stored in a compact
11054 manner. Consider the declarations:
11056 @smallexample @c ada
11057 type r is (A, B, C);
11058 for r use (A => 1, B => 5, C => 10);
11059 type t is array (r) of Character;
11063 The array type t corresponds to a vector with exactly three elements and
11064 has a default size equal to @code{3*Character'Size}. This ensures efficient
11065 use of space, but means that accesses to elements of the array will incur
11066 the overhead of converting representation values to the corresponding
11067 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11069 @node Address Clauses
11070 @section Address Clauses
11071 @cindex Address Clause
11073 The reference manual allows a general restriction on representation clauses,
11074 as found in RM 13.1(22):
11077 An implementation need not support representation
11078 items containing nonstatic expressions, except that
11079 an implementation should support a representation item
11080 for a given entity if each nonstatic expression in the
11081 representation item is a name that statically denotes
11082 a constant declared before the entity.
11086 In practice this is applicable only to address clauses, since this is the
11087 only case in which a non-static expression is permitted by the syntax. As
11088 the AARM notes in sections 13.1 (22.a-22.h):
11091 22.a Reason: This is to avoid the following sort of thing:
11093 22.b X : Integer := F(@dots{});
11094 Y : Address := G(@dots{});
11095 for X'Address use Y;
11097 22.c In the above, we have to evaluate the
11098 initialization expression for X before we
11099 know where to put the result. This seems
11100 like an unreasonable implementation burden.
11102 22.d The above code should instead be written
11105 22.e Y : constant Address := G(@dots{});
11106 X : Integer := F(@dots{});
11107 for X'Address use Y;
11109 22.f This allows the expression ``Y'' to be safely
11110 evaluated before X is created.
11112 22.g The constant could be a formal parameter of mode in.
11114 22.h An implementation can support other nonstatic
11115 expressions if it wants to. Expressions of type
11116 Address are hardly ever static, but their value
11117 might be known at compile time anyway in many
11122 GNAT does indeed permit many additional cases of non-static expressions. In
11123 particular, if the type involved is elementary there are no restrictions
11124 (since in this case, holding a temporary copy of the initialization value,
11125 if one is present, is inexpensive). In addition, if there is no implicit or
11126 explicit initialization, then there are no restrictions. GNAT will reject
11127 only the case where all three of these conditions hold:
11132 The type of the item is non-elementary (e.g.@: a record or array).
11135 There is explicit or implicit initialization required for the object.
11136 Note that access values are always implicitly initialized, and also
11137 in GNAT, certain bit-packed arrays (those having a dynamic length or
11138 a length greater than 64) will also be implicitly initialized to zero.
11141 The address value is non-static. Here GNAT is more permissive than the
11142 RM, and allows the address value to be the address of a previously declared
11143 stand-alone variable, as long as it does not itself have an address clause.
11145 @smallexample @c ada
11146 Anchor : Some_Initialized_Type;
11147 Overlay : Some_Initialized_Type;
11148 for Overlay'Address use Anchor'Address;
11152 However, the prefix of the address clause cannot be an array component, or
11153 a component of a discriminated record.
11158 As noted above in section 22.h, address values are typically non-static. In
11159 particular the To_Address function, even if applied to a literal value, is
11160 a non-static function call. To avoid this minor annoyance, GNAT provides
11161 the implementation defined attribute 'To_Address. The following two
11162 expressions have identical values:
11166 @smallexample @c ada
11167 To_Address (16#1234_0000#)
11168 System'To_Address (16#1234_0000#);
11172 except that the second form is considered to be a static expression, and
11173 thus when used as an address clause value is always permitted.
11176 Additionally, GNAT treats as static an address clause that is an
11177 unchecked_conversion of a static integer value. This simplifies the porting
11178 of legacy code, and provides a portable equivalent to the GNAT attribute
11181 Another issue with address clauses is the interaction with alignment
11182 requirements. When an address clause is given for an object, the address
11183 value must be consistent with the alignment of the object (which is usually
11184 the same as the alignment of the type of the object). If an address clause
11185 is given that specifies an inappropriately aligned address value, then the
11186 program execution is erroneous.
11188 Since this source of erroneous behavior can have unfortunate effects, GNAT
11189 checks (at compile time if possible, generating a warning, or at execution
11190 time with a run-time check) that the alignment is appropriate. If the
11191 run-time check fails, then @code{Program_Error} is raised. This run-time
11192 check is suppressed if range checks are suppressed, or if the special GNAT
11193 check Alignment_Check is suppressed, or if
11194 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11196 Finally, GNAT does not permit overlaying of objects of controlled types or
11197 composite types containing a controlled component. In most cases, the compiler
11198 can detect an attempt at such overlays and will generate a warning at compile
11199 time and a Program_Error exception at run time.
11202 An address clause cannot be given for an exported object. More
11203 understandably the real restriction is that objects with an address
11204 clause cannot be exported. This is because such variables are not
11205 defined by the Ada program, so there is no external object to export.
11208 It is permissible to give an address clause and a pragma Import for the
11209 same object. In this case, the variable is not really defined by the
11210 Ada program, so there is no external symbol to be linked. The link name
11211 and the external name are ignored in this case. The reason that we allow this
11212 combination is that it provides a useful idiom to avoid unwanted
11213 initializations on objects with address clauses.
11215 When an address clause is given for an object that has implicit or
11216 explicit initialization, then by default initialization takes place. This
11217 means that the effect of the object declaration is to overwrite the
11218 memory at the specified address. This is almost always not what the
11219 programmer wants, so GNAT will output a warning:
11229 for Ext'Address use System'To_Address (16#1234_1234#);
11231 >>> warning: implicit initialization of "Ext" may
11232 modify overlaid storage
11233 >>> warning: use pragma Import for "Ext" to suppress
11234 initialization (RM B(24))
11240 As indicated by the warning message, the solution is to use a (dummy) pragma
11241 Import to suppress this initialization. The pragma tell the compiler that the
11242 object is declared and initialized elsewhere. The following package compiles
11243 without warnings (and the initialization is suppressed):
11245 @smallexample @c ada
11253 for Ext'Address use System'To_Address (16#1234_1234#);
11254 pragma Import (Ada, Ext);
11259 A final issue with address clauses involves their use for overlaying
11260 variables, as in the following example:
11261 @cindex Overlaying of objects
11263 @smallexample @c ada
11266 for B'Address use A'Address;
11270 or alternatively, using the form recommended by the RM:
11272 @smallexample @c ada
11274 Addr : constant Address := A'Address;
11276 for B'Address use Addr;
11280 In both of these cases, @code{A}
11281 and @code{B} become aliased to one another via the
11282 address clause. This use of address clauses to overlay
11283 variables, achieving an effect similar to unchecked
11284 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11285 the effect is implementation defined. Furthermore, the
11286 Ada RM specifically recommends that in a situation
11287 like this, @code{B} should be subject to the following
11288 implementation advice (RM 13.3(19)):
11291 19 If the Address of an object is specified, or it is imported
11292 or exported, then the implementation should not perform
11293 optimizations based on assumptions of no aliases.
11297 GNAT follows this recommendation, and goes further by also applying
11298 this recommendation to the overlaid variable (@code{A}
11299 in the above example) in this case. This means that the overlay
11300 works "as expected", in that a modification to one of the variables
11301 will affect the value of the other.
11303 @node Effect of Convention on Representation
11304 @section Effect of Convention on Representation
11305 @cindex Convention, effect on representation
11308 Normally the specification of a foreign language convention for a type or
11309 an object has no effect on the chosen representation. In particular, the
11310 representation chosen for data in GNAT generally meets the standard system
11311 conventions, and for example records are laid out in a manner that is
11312 consistent with C@. This means that specifying convention C (for example)
11315 There are four exceptions to this general rule:
11319 @item Convention Fortran and array subtypes
11320 If pragma Convention Fortran is specified for an array subtype, then in
11321 accordance with the implementation advice in section 3.6.2(11) of the
11322 Ada Reference Manual, the array will be stored in a Fortran-compatible
11323 column-major manner, instead of the normal default row-major order.
11325 @item Convention C and enumeration types
11326 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11327 to accommodate all values of the type. For example, for the enumeration
11330 @smallexample @c ada
11331 type Color is (Red, Green, Blue);
11335 8 bits is sufficient to store all values of the type, so by default, objects
11336 of type @code{Color} will be represented using 8 bits. However, normal C
11337 convention is to use 32 bits for all enum values in C, since enum values
11338 are essentially of type int. If pragma @code{Convention C} is specified for an
11339 Ada enumeration type, then the size is modified as necessary (usually to
11340 32 bits) to be consistent with the C convention for enum values.
11342 Note that this treatment applies only to types. If Convention C is given for
11343 an enumeration object, where the enumeration type is not Convention C, then
11344 Object_Size bits are allocated. For example, for a normal enumeration type,
11345 with less than 256 elements, only 8 bits will be allocated for the object.
11346 Since this may be a surprise in terms of what C expects, GNAT will issue a
11347 warning in this situation. The warning can be suppressed by giving an explicit
11348 size clause specifying the desired size.
11350 @item Convention C/Fortran and Boolean types
11351 In C, the usual convention for boolean values, that is values used for
11352 conditions, is that zero represents false, and nonzero values represent
11353 true. In Ada, the normal convention is that two specific values, typically
11354 0/1, are used to represent false/true respectively.
11356 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11357 value represents true).
11359 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11360 C or Fortran convention for a derived Boolean, as in the following example:
11362 @smallexample @c ada
11363 type C_Switch is new Boolean;
11364 pragma Convention (C, C_Switch);
11368 then the GNAT generated code will treat any nonzero value as true. For truth
11369 values generated by GNAT, the conventional value 1 will be used for True, but
11370 when one of these values is read, any nonzero value is treated as True.
11372 @item Access types on OpenVMS
11373 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11374 arrays) are 64-bits long. An exception to this rule is for the case of
11375 C-convention access types where there is no explicit size clause present (or
11376 inherited for derived types). In this case, GNAT chooses to make these
11377 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11378 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11382 @node Determining the Representations chosen by GNAT
11383 @section Determining the Representations chosen by GNAT
11384 @cindex Representation, determination of
11385 @cindex @option{-gnatR} switch
11388 Although the descriptions in this section are intended to be complete, it is
11389 often easier to simply experiment to see what GNAT accepts and what the
11390 effect is on the layout of types and objects.
11392 As required by the Ada RM, if a representation clause is not accepted, then
11393 it must be rejected as illegal by the compiler. However, when a
11394 representation clause or pragma is accepted, there can still be questions
11395 of what the compiler actually does. For example, if a partial record
11396 representation clause specifies the location of some components and not
11397 others, then where are the non-specified components placed? Or if pragma
11398 @code{Pack} is used on a record, then exactly where are the resulting
11399 fields placed? The section on pragma @code{Pack} in this chapter can be
11400 used to answer the second question, but it is often easier to just see
11401 what the compiler does.
11403 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
11404 with this option, then the compiler will output information on the actual
11405 representations chosen, in a format similar to source representation
11406 clauses. For example, if we compile the package:
11408 @smallexample @c ada
11410 type r (x : boolean) is tagged record
11412 when True => S : String (1 .. 100);
11413 when False => null;
11417 type r2 is new r (false) with record
11422 y2 at 16 range 0 .. 31;
11429 type x1 is array (1 .. 10) of x;
11430 for x1'component_size use 11;
11432 type ia is access integer;
11434 type Rb1 is array (1 .. 13) of Boolean;
11437 type Rb2 is array (1 .. 65) of Boolean;
11453 using the switch @option{-gnatR} we obtain the following output:
11456 Representation information for unit q
11457 -------------------------------------
11460 for r'Alignment use 4;
11462 x at 4 range 0 .. 7;
11463 _tag at 0 range 0 .. 31;
11464 s at 5 range 0 .. 799;
11467 for r2'Size use 160;
11468 for r2'Alignment use 4;
11470 x at 4 range 0 .. 7;
11471 _tag at 0 range 0 .. 31;
11472 _parent at 0 range 0 .. 63;
11473 y2 at 16 range 0 .. 31;
11477 for x'Alignment use 1;
11479 y at 0 range 0 .. 7;
11482 for x1'Size use 112;
11483 for x1'Alignment use 1;
11484 for x1'Component_Size use 11;
11486 for rb1'Size use 13;
11487 for rb1'Alignment use 2;
11488 for rb1'Component_Size use 1;
11490 for rb2'Size use 72;
11491 for rb2'Alignment use 1;
11492 for rb2'Component_Size use 1;
11494 for x2'Size use 224;
11495 for x2'Alignment use 4;
11497 l1 at 0 range 0 .. 0;
11498 l2 at 0 range 1 .. 64;
11499 l3 at 12 range 0 .. 31;
11500 l4 at 16 range 0 .. 0;
11501 l5 at 16 range 1 .. 13;
11502 l6 at 18 range 0 .. 71;
11507 The Size values are actually the Object_Size, i.e.@: the default size that
11508 will be allocated for objects of the type.
11509 The ?? size for type r indicates that we have a variant record, and the
11510 actual size of objects will depend on the discriminant value.
11512 The Alignment values show the actual alignment chosen by the compiler
11513 for each record or array type.
11515 The record representation clause for type r shows where all fields
11516 are placed, including the compiler generated tag field (whose location
11517 cannot be controlled by the programmer).
11519 The record representation clause for the type extension r2 shows all the
11520 fields present, including the parent field, which is a copy of the fields
11521 of the parent type of r2, i.e.@: r1.
11523 The component size and size clauses for types rb1 and rb2 show
11524 the exact effect of pragma @code{Pack} on these arrays, and the record
11525 representation clause for type x2 shows how pragma @code{Pack} affects
11528 In some cases, it may be useful to cut and paste the representation clauses
11529 generated by the compiler into the original source to fix and guarantee
11530 the actual representation to be used.
11532 @node Standard Library Routines
11533 @chapter Standard Library Routines
11536 The Ada Reference Manual contains in Annex A a full description of an
11537 extensive set of standard library routines that can be used in any Ada
11538 program, and which must be provided by all Ada compilers. They are
11539 analogous to the standard C library used by C programs.
11541 GNAT implements all of the facilities described in annex A, and for most
11542 purposes the description in the Ada Reference Manual, or appropriate Ada
11543 text book, will be sufficient for making use of these facilities.
11545 In the case of the input-output facilities,
11546 @xref{The Implementation of Standard I/O},
11547 gives details on exactly how GNAT interfaces to the
11548 file system. For the remaining packages, the Ada Reference Manual
11549 should be sufficient. The following is a list of the packages included,
11550 together with a brief description of the functionality that is provided.
11552 For completeness, references are included to other predefined library
11553 routines defined in other sections of the Ada Reference Manual (these are
11554 cross-indexed from Annex A).
11558 This is a parent package for all the standard library packages. It is
11559 usually included implicitly in your program, and itself contains no
11560 useful data or routines.
11562 @item Ada.Calendar (9.6)
11563 @code{Calendar} provides time of day access, and routines for
11564 manipulating times and durations.
11566 @item Ada.Characters (A.3.1)
11567 This is a dummy parent package that contains no useful entities
11569 @item Ada.Characters.Handling (A.3.2)
11570 This package provides some basic character handling capabilities,
11571 including classification functions for classes of characters (e.g.@: test
11572 for letters, or digits).
11574 @item Ada.Characters.Latin_1 (A.3.3)
11575 This package includes a complete set of definitions of the characters
11576 that appear in type CHARACTER@. It is useful for writing programs that
11577 will run in international environments. For example, if you want an
11578 upper case E with an acute accent in a string, it is often better to use
11579 the definition of @code{UC_E_Acute} in this package. Then your program
11580 will print in an understandable manner even if your environment does not
11581 support these extended characters.
11583 @item Ada.Command_Line (A.15)
11584 This package provides access to the command line parameters and the name
11585 of the current program (analogous to the use of @code{argc} and @code{argv}
11586 in C), and also allows the exit status for the program to be set in a
11587 system-independent manner.
11589 @item Ada.Decimal (F.2)
11590 This package provides constants describing the range of decimal numbers
11591 implemented, and also a decimal divide routine (analogous to the COBOL
11592 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11594 @item Ada.Direct_IO (A.8.4)
11595 This package provides input-output using a model of a set of records of
11596 fixed-length, containing an arbitrary definite Ada type, indexed by an
11597 integer record number.
11599 @item Ada.Dynamic_Priorities (D.5)
11600 This package allows the priorities of a task to be adjusted dynamically
11601 as the task is running.
11603 @item Ada.Exceptions (11.4.1)
11604 This package provides additional information on exceptions, and also
11605 contains facilities for treating exceptions as data objects, and raising
11606 exceptions with associated messages.
11608 @item Ada.Finalization (7.6)
11609 This package contains the declarations and subprograms to support the
11610 use of controlled types, providing for automatic initialization and
11611 finalization (analogous to the constructors and destructors of C++)
11613 @item Ada.Interrupts (C.3.2)
11614 This package provides facilities for interfacing to interrupts, which
11615 includes the set of signals or conditions that can be raised and
11616 recognized as interrupts.
11618 @item Ada.Interrupts.Names (C.3.2)
11619 This package provides the set of interrupt names (actually signal
11620 or condition names) that can be handled by GNAT@.
11622 @item Ada.IO_Exceptions (A.13)
11623 This package defines the set of exceptions that can be raised by use of
11624 the standard IO packages.
11627 This package contains some standard constants and exceptions used
11628 throughout the numerics packages. Note that the constants pi and e are
11629 defined here, and it is better to use these definitions than rolling
11632 @item Ada.Numerics.Complex_Elementary_Functions
11633 Provides the implementation of standard elementary functions (such as
11634 log and trigonometric functions) operating on complex numbers using the
11635 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11636 created by the package @code{Numerics.Complex_Types}.
11638 @item Ada.Numerics.Complex_Types
11639 This is a predefined instantiation of
11640 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11641 build the type @code{Complex} and @code{Imaginary}.
11643 @item Ada.Numerics.Discrete_Random
11644 This package provides a random number generator suitable for generating
11645 random integer values from a specified range.
11647 @item Ada.Numerics.Float_Random
11648 This package provides a random number generator suitable for generating
11649 uniformly distributed floating point values.
11651 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11652 This is a generic version of the package that provides the
11653 implementation of standard elementary functions (such as log and
11654 trigonometric functions) for an arbitrary complex type.
11656 The following predefined instantiations of this package are provided:
11660 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11662 @code{Ada.Numerics.Complex_Elementary_Functions}
11664 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11667 @item Ada.Numerics.Generic_Complex_Types
11668 This is a generic package that allows the creation of complex types,
11669 with associated complex arithmetic operations.
11671 The following predefined instantiations of this package exist
11674 @code{Ada.Numerics.Short_Complex_Complex_Types}
11676 @code{Ada.Numerics.Complex_Complex_Types}
11678 @code{Ada.Numerics.Long_Complex_Complex_Types}
11681 @item Ada.Numerics.Generic_Elementary_Functions
11682 This is a generic package that provides the implementation of standard
11683 elementary functions (such as log an trigonometric functions) for an
11684 arbitrary float type.
11686 The following predefined instantiations of this package exist
11690 @code{Ada.Numerics.Short_Elementary_Functions}
11692 @code{Ada.Numerics.Elementary_Functions}
11694 @code{Ada.Numerics.Long_Elementary_Functions}
11697 @item Ada.Real_Time (D.8)
11698 This package provides facilities similar to those of @code{Calendar}, but
11699 operating with a finer clock suitable for real time control. Note that
11700 annex D requires that there be no backward clock jumps, and GNAT generally
11701 guarantees this behavior, but of course if the external clock on which
11702 the GNAT runtime depends is deliberately reset by some external event,
11703 then such a backward jump may occur.
11705 @item Ada.Sequential_IO (A.8.1)
11706 This package provides input-output facilities for sequential files,
11707 which can contain a sequence of values of a single type, which can be
11708 any Ada type, including indefinite (unconstrained) types.
11710 @item Ada.Storage_IO (A.9)
11711 This package provides a facility for mapping arbitrary Ada types to and
11712 from a storage buffer. It is primarily intended for the creation of new
11715 @item Ada.Streams (13.13.1)
11716 This is a generic package that provides the basic support for the
11717 concept of streams as used by the stream attributes (@code{Input},
11718 @code{Output}, @code{Read} and @code{Write}).
11720 @item Ada.Streams.Stream_IO (A.12.1)
11721 This package is a specialization of the type @code{Streams} defined in
11722 package @code{Streams} together with a set of operations providing
11723 Stream_IO capability. The Stream_IO model permits both random and
11724 sequential access to a file which can contain an arbitrary set of values
11725 of one or more Ada types.
11727 @item Ada.Strings (A.4.1)
11728 This package provides some basic constants used by the string handling
11731 @item Ada.Strings.Bounded (A.4.4)
11732 This package provides facilities for handling variable length
11733 strings. The bounded model requires a maximum length. It is thus
11734 somewhat more limited than the unbounded model, but avoids the use of
11735 dynamic allocation or finalization.
11737 @item Ada.Strings.Fixed (A.4.3)
11738 This package provides facilities for handling fixed length strings.
11740 @item Ada.Strings.Maps (A.4.2)
11741 This package provides facilities for handling character mappings and
11742 arbitrarily defined subsets of characters. For instance it is useful in
11743 defining specialized translation tables.
11745 @item Ada.Strings.Maps.Constants (A.4.6)
11746 This package provides a standard set of predefined mappings and
11747 predefined character sets. For example, the standard upper to lower case
11748 conversion table is found in this package. Note that upper to lower case
11749 conversion is non-trivial if you want to take the entire set of
11750 characters, including extended characters like E with an acute accent,
11751 into account. You should use the mappings in this package (rather than
11752 adding 32 yourself) to do case mappings.
11754 @item Ada.Strings.Unbounded (A.4.5)
11755 This package provides facilities for handling variable length
11756 strings. The unbounded model allows arbitrary length strings, but
11757 requires the use of dynamic allocation and finalization.
11759 @item Ada.Strings.Wide_Bounded (A.4.7)
11760 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11761 @itemx Ada.Strings.Wide_Maps (A.4.7)
11762 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11763 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11764 These packages provide analogous capabilities to the corresponding
11765 packages without @samp{Wide_} in the name, but operate with the types
11766 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11767 and @code{Character}.
11769 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11770 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11771 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11772 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11773 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11774 These packages provide analogous capabilities to the corresponding
11775 packages without @samp{Wide_} in the name, but operate with the types
11776 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11777 of @code{String} and @code{Character}.
11779 @item Ada.Synchronous_Task_Control (D.10)
11780 This package provides some standard facilities for controlling task
11781 communication in a synchronous manner.
11784 This package contains definitions for manipulation of the tags of tagged
11787 @item Ada.Task_Attributes
11788 This package provides the capability of associating arbitrary
11789 task-specific data with separate tasks.
11792 This package provides basic text input-output capabilities for
11793 character, string and numeric data. The subpackages of this
11794 package are listed next.
11796 @item Ada.Text_IO.Decimal_IO
11797 Provides input-output facilities for decimal fixed-point types
11799 @item Ada.Text_IO.Enumeration_IO
11800 Provides input-output facilities for enumeration types.
11802 @item Ada.Text_IO.Fixed_IO
11803 Provides input-output facilities for ordinary fixed-point types.
11805 @item Ada.Text_IO.Float_IO
11806 Provides input-output facilities for float types. The following
11807 predefined instantiations of this generic package are available:
11811 @code{Short_Float_Text_IO}
11813 @code{Float_Text_IO}
11815 @code{Long_Float_Text_IO}
11818 @item Ada.Text_IO.Integer_IO
11819 Provides input-output facilities for integer types. The following
11820 predefined instantiations of this generic package are available:
11823 @item Short_Short_Integer
11824 @code{Ada.Short_Short_Integer_Text_IO}
11825 @item Short_Integer
11826 @code{Ada.Short_Integer_Text_IO}
11828 @code{Ada.Integer_Text_IO}
11830 @code{Ada.Long_Integer_Text_IO}
11831 @item Long_Long_Integer
11832 @code{Ada.Long_Long_Integer_Text_IO}
11835 @item Ada.Text_IO.Modular_IO
11836 Provides input-output facilities for modular (unsigned) types
11838 @item Ada.Text_IO.Complex_IO (G.1.3)
11839 This package provides basic text input-output capabilities for complex
11842 @item Ada.Text_IO.Editing (F.3.3)
11843 This package contains routines for edited output, analogous to the use
11844 of pictures in COBOL@. The picture formats used by this package are a
11845 close copy of the facility in COBOL@.
11847 @item Ada.Text_IO.Text_Streams (A.12.2)
11848 This package provides a facility that allows Text_IO files to be treated
11849 as streams, so that the stream attributes can be used for writing
11850 arbitrary data, including binary data, to Text_IO files.
11852 @item Ada.Unchecked_Conversion (13.9)
11853 This generic package allows arbitrary conversion from one type to
11854 another of the same size, providing for breaking the type safety in
11855 special circumstances.
11857 If the types have the same Size (more accurately the same Value_Size),
11858 then the effect is simply to transfer the bits from the source to the
11859 target type without any modification. This usage is well defined, and
11860 for simple types whose representation is typically the same across
11861 all implementations, gives a portable method of performing such
11864 If the types do not have the same size, then the result is implementation
11865 defined, and thus may be non-portable. The following describes how GNAT
11866 handles such unchecked conversion cases.
11868 If the types are of different sizes, and are both discrete types, then
11869 the effect is of a normal type conversion without any constraint checking.
11870 In particular if the result type has a larger size, the result will be
11871 zero or sign extended. If the result type has a smaller size, the result
11872 will be truncated by ignoring high order bits.
11874 If the types are of different sizes, and are not both discrete types,
11875 then the conversion works as though pointers were created to the source
11876 and target, and the pointer value is converted. The effect is that bits
11877 are copied from successive low order storage units and bits of the source
11878 up to the length of the target type.
11880 A warning is issued if the lengths differ, since the effect in this
11881 case is implementation dependent, and the above behavior may not match
11882 that of some other compiler.
11884 A pointer to one type may be converted to a pointer to another type using
11885 unchecked conversion. The only case in which the effect is undefined is
11886 when one or both pointers are pointers to unconstrained array types. In
11887 this case, the bounds information may get incorrectly transferred, and in
11888 particular, GNAT uses double size pointers for such types, and it is
11889 meaningless to convert between such pointer types. GNAT will issue a
11890 warning if the alignment of the target designated type is more strict
11891 than the alignment of the source designated type (since the result may
11892 be unaligned in this case).
11894 A pointer other than a pointer to an unconstrained array type may be
11895 converted to and from System.Address. Such usage is common in Ada 83
11896 programs, but note that Ada.Address_To_Access_Conversions is the
11897 preferred method of performing such conversions in Ada 95 and Ada 2005.
11899 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11900 used in conjunction with pointers to unconstrained objects, since
11901 the bounds information cannot be handled correctly in this case.
11903 @item Ada.Unchecked_Deallocation (13.11.2)
11904 This generic package allows explicit freeing of storage previously
11905 allocated by use of an allocator.
11907 @item Ada.Wide_Text_IO (A.11)
11908 This package is similar to @code{Ada.Text_IO}, except that the external
11909 file supports wide character representations, and the internal types are
11910 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11911 and @code{String}. It contains generic subpackages listed next.
11913 @item Ada.Wide_Text_IO.Decimal_IO
11914 Provides input-output facilities for decimal fixed-point types
11916 @item Ada.Wide_Text_IO.Enumeration_IO
11917 Provides input-output facilities for enumeration types.
11919 @item Ada.Wide_Text_IO.Fixed_IO
11920 Provides input-output facilities for ordinary fixed-point types.
11922 @item Ada.Wide_Text_IO.Float_IO
11923 Provides input-output facilities for float types. The following
11924 predefined instantiations of this generic package are available:
11928 @code{Short_Float_Wide_Text_IO}
11930 @code{Float_Wide_Text_IO}
11932 @code{Long_Float_Wide_Text_IO}
11935 @item Ada.Wide_Text_IO.Integer_IO
11936 Provides input-output facilities for integer types. The following
11937 predefined instantiations of this generic package are available:
11940 @item Short_Short_Integer
11941 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11942 @item Short_Integer
11943 @code{Ada.Short_Integer_Wide_Text_IO}
11945 @code{Ada.Integer_Wide_Text_IO}
11947 @code{Ada.Long_Integer_Wide_Text_IO}
11948 @item Long_Long_Integer
11949 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11952 @item Ada.Wide_Text_IO.Modular_IO
11953 Provides input-output facilities for modular (unsigned) types
11955 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11956 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11957 external file supports wide character representations.
11959 @item Ada.Wide_Text_IO.Editing (F.3.4)
11960 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11961 types are @code{Wide_Character} and @code{Wide_String} instead of
11962 @code{Character} and @code{String}.
11964 @item Ada.Wide_Text_IO.Streams (A.12.3)
11965 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11966 types are @code{Wide_Character} and @code{Wide_String} instead of
11967 @code{Character} and @code{String}.
11969 @item Ada.Wide_Wide_Text_IO (A.11)
11970 This package is similar to @code{Ada.Text_IO}, except that the external
11971 file supports wide character representations, and the internal types are
11972 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11973 and @code{String}. It contains generic subpackages listed next.
11975 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11976 Provides input-output facilities for decimal fixed-point types
11978 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11979 Provides input-output facilities for enumeration types.
11981 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11982 Provides input-output facilities for ordinary fixed-point types.
11984 @item Ada.Wide_Wide_Text_IO.Float_IO
11985 Provides input-output facilities for float types. The following
11986 predefined instantiations of this generic package are available:
11990 @code{Short_Float_Wide_Wide_Text_IO}
11992 @code{Float_Wide_Wide_Text_IO}
11994 @code{Long_Float_Wide_Wide_Text_IO}
11997 @item Ada.Wide_Wide_Text_IO.Integer_IO
11998 Provides input-output facilities for integer types. The following
11999 predefined instantiations of this generic package are available:
12002 @item Short_Short_Integer
12003 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12004 @item Short_Integer
12005 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12007 @code{Ada.Integer_Wide_Wide_Text_IO}
12009 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12010 @item Long_Long_Integer
12011 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12014 @item Ada.Wide_Wide_Text_IO.Modular_IO
12015 Provides input-output facilities for modular (unsigned) types
12017 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12018 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12019 external file supports wide character representations.
12021 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12022 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12023 types are @code{Wide_Character} and @code{Wide_String} instead of
12024 @code{Character} and @code{String}.
12026 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12027 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12028 types are @code{Wide_Character} and @code{Wide_String} instead of
12029 @code{Character} and @code{String}.
12034 @node The Implementation of Standard I/O
12035 @chapter The Implementation of Standard I/O
12038 GNAT implements all the required input-output facilities described in
12039 A.6 through A.14. These sections of the Ada Reference Manual describe the
12040 required behavior of these packages from the Ada point of view, and if
12041 you are writing a portable Ada program that does not need to know the
12042 exact manner in which Ada maps to the outside world when it comes to
12043 reading or writing external files, then you do not need to read this
12044 chapter. As long as your files are all regular files (not pipes or
12045 devices), and as long as you write and read the files only from Ada, the
12046 description in the Ada Reference Manual is sufficient.
12048 However, if you want to do input-output to pipes or other devices, such
12049 as the keyboard or screen, or if the files you are dealing with are
12050 either generated by some other language, or to be read by some other
12051 language, then you need to know more about the details of how the GNAT
12052 implementation of these input-output facilities behaves.
12054 In this chapter we give a detailed description of exactly how GNAT
12055 interfaces to the file system. As always, the sources of the system are
12056 available to you for answering questions at an even more detailed level,
12057 but for most purposes the information in this chapter will suffice.
12059 Another reason that you may need to know more about how input-output is
12060 implemented arises when you have a program written in mixed languages
12061 where, for example, files are shared between the C and Ada sections of
12062 the same program. GNAT provides some additional facilities, in the form
12063 of additional child library packages, that facilitate this sharing, and
12064 these additional facilities are also described in this chapter.
12067 * Standard I/O Packages::
12073 * Wide_Wide_Text_IO::
12076 * Filenames encoding::
12078 * Operations on C Streams::
12079 * Interfacing to C Streams::
12082 @node Standard I/O Packages
12083 @section Standard I/O Packages
12086 The Standard I/O packages described in Annex A for
12092 Ada.Text_IO.Complex_IO
12094 Ada.Text_IO.Text_Streams
12098 Ada.Wide_Text_IO.Complex_IO
12100 Ada.Wide_Text_IO.Text_Streams
12102 Ada.Wide_Wide_Text_IO
12104 Ada.Wide_Wide_Text_IO.Complex_IO
12106 Ada.Wide_Wide_Text_IO.Text_Streams
12116 are implemented using the C
12117 library streams facility; where
12121 All files are opened using @code{fopen}.
12123 All input/output operations use @code{fread}/@code{fwrite}.
12127 There is no internal buffering of any kind at the Ada library level. The only
12128 buffering is that provided at the system level in the implementation of the
12129 library routines that support streams. This facilitates shared use of these
12130 streams by mixed language programs. Note though that system level buffering is
12131 explicitly enabled at elaboration of the standard I/O packages and that can
12132 have an impact on mixed language programs, in particular those using I/O before
12133 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12134 the Ada elaboration routine before performing any I/O or when impractical,
12135 flush the common I/O streams and in particular Standard_Output before
12136 elaborating the Ada code.
12139 @section FORM Strings
12142 The format of a FORM string in GNAT is:
12145 "keyword=value,keyword=value,@dots{},keyword=value"
12149 where letters may be in upper or lower case, and there are no spaces
12150 between values. The order of the entries is not important. Currently
12151 there are two keywords defined.
12155 WCEM=[n|h|u|s|e|8|b]
12159 The use of these parameters is described later in this section.
12165 Direct_IO can only be instantiated for definite types. This is a
12166 restriction of the Ada language, which means that the records are fixed
12167 length (the length being determined by @code{@var{type}'Size}, rounded
12168 up to the next storage unit boundary if necessary).
12170 The records of a Direct_IO file are simply written to the file in index
12171 sequence, with the first record starting at offset zero, and subsequent
12172 records following. There is no control information of any kind. For
12173 example, if 32-bit integers are being written, each record takes
12174 4-bytes, so the record at index @var{K} starts at offset
12175 (@var{K}@minus{}1)*4.
12177 There is no limit on the size of Direct_IO files, they are expanded as
12178 necessary to accommodate whatever records are written to the file.
12180 @node Sequential_IO
12181 @section Sequential_IO
12184 Sequential_IO may be instantiated with either a definite (constrained)
12185 or indefinite (unconstrained) type.
12187 For the definite type case, the elements written to the file are simply
12188 the memory images of the data values with no control information of any
12189 kind. The resulting file should be read using the same type, no validity
12190 checking is performed on input.
12192 For the indefinite type case, the elements written consist of two
12193 parts. First is the size of the data item, written as the memory image
12194 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12195 the data value. The resulting file can only be read using the same
12196 (unconstrained) type. Normal assignment checks are performed on these
12197 read operations, and if these checks fail, @code{Data_Error} is
12198 raised. In particular, in the array case, the lengths must match, and in
12199 the variant record case, if the variable for a particular read operation
12200 is constrained, the discriminants must match.
12202 Note that it is not possible to use Sequential_IO to write variable
12203 length array items, and then read the data back into different length
12204 arrays. For example, the following will raise @code{Data_Error}:
12206 @smallexample @c ada
12207 package IO is new Sequential_IO (String);
12212 IO.Write (F, "hello!")
12213 IO.Reset (F, Mode=>In_File);
12220 On some Ada implementations, this will print @code{hell}, but the program is
12221 clearly incorrect, since there is only one element in the file, and that
12222 element is the string @code{hello!}.
12224 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12225 using Stream_IO, and this is the preferred mechanism. In particular, the
12226 above program fragment rewritten to use Stream_IO will work correctly.
12232 Text_IO files consist of a stream of characters containing the following
12233 special control characters:
12236 LF (line feed, 16#0A#) Line Mark
12237 FF (form feed, 16#0C#) Page Mark
12241 A canonical Text_IO file is defined as one in which the following
12242 conditions are met:
12246 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12250 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12251 end of a page and consequently can appear only immediately following a
12252 @code{LF} (line mark) character.
12255 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12256 (line mark, page mark). In the former case, the page mark is implicitly
12257 assumed to be present.
12261 A file written using Text_IO will be in canonical form provided that no
12262 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12263 or @code{Put_Line}. There will be no @code{FF} character at the end of
12264 the file unless an explicit @code{New_Page} operation was performed
12265 before closing the file.
12267 A canonical Text_IO file that is a regular file (i.e., not a device or a
12268 pipe) can be read using any of the routines in Text_IO@. The
12269 semantics in this case will be exactly as defined in the Ada Reference
12270 Manual, and all the routines in Text_IO are fully implemented.
12272 A text file that does not meet the requirements for a canonical Text_IO
12273 file has one of the following:
12277 The file contains @code{FF} characters not immediately following a
12278 @code{LF} character.
12281 The file contains @code{LF} or @code{FF} characters written by
12282 @code{Put} or @code{Put_Line}, which are not logically considered to be
12283 line marks or page marks.
12286 The file ends in a character other than @code{LF} or @code{FF},
12287 i.e.@: there is no explicit line mark or page mark at the end of the file.
12291 Text_IO can be used to read such non-standard text files but subprograms
12292 to do with line or page numbers do not have defined meanings. In
12293 particular, a @code{FF} character that does not follow a @code{LF}
12294 character may or may not be treated as a page mark from the point of
12295 view of page and line numbering. Every @code{LF} character is considered
12296 to end a line, and there is an implied @code{LF} character at the end of
12300 * Text_IO Stream Pointer Positioning::
12301 * Text_IO Reading and Writing Non-Regular Files::
12303 * Treating Text_IO Files as Streams::
12304 * Text_IO Extensions::
12305 * Text_IO Facilities for Unbounded Strings::
12308 @node Text_IO Stream Pointer Positioning
12309 @subsection Stream Pointer Positioning
12312 @code{Ada.Text_IO} has a definition of current position for a file that
12313 is being read. No internal buffering occurs in Text_IO, and usually the
12314 physical position in the stream used to implement the file corresponds
12315 to this logical position defined by Text_IO@. There are two exceptions:
12319 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12320 is positioned past the @code{LF} (line mark) that precedes the page
12321 mark. Text_IO maintains an internal flag so that subsequent read
12322 operations properly handle the logical position which is unchanged by
12323 the @code{End_Of_Page} call.
12326 After a call to @code{End_Of_File} that returns @code{True}, if the
12327 Text_IO file was positioned before the line mark at the end of file
12328 before the call, then the logical position is unchanged, but the stream
12329 is physically positioned right at the end of file (past the line mark,
12330 and past a possible page mark following the line mark. Again Text_IO
12331 maintains internal flags so that subsequent read operations properly
12332 handle the logical position.
12336 These discrepancies have no effect on the observable behavior of
12337 Text_IO, but if a single Ada stream is shared between a C program and
12338 Ada program, or shared (using @samp{shared=yes} in the form string)
12339 between two Ada files, then the difference may be observable in some
12342 @node Text_IO Reading and Writing Non-Regular Files
12343 @subsection Reading and Writing Non-Regular Files
12346 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
12347 can be used for reading and writing. Writing is not affected and the
12348 sequence of characters output is identical to the normal file case, but
12349 for reading, the behavior of Text_IO is modified to avoid undesirable
12350 look-ahead as follows:
12352 An input file that is not a regular file is considered to have no page
12353 marks. Any @code{Ascii.FF} characters (the character normally used for a
12354 page mark) appearing in the file are considered to be data
12355 characters. In particular:
12359 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12360 following a line mark. If a page mark appears, it will be treated as a
12364 This avoids the need to wait for an extra character to be typed or
12365 entered from the pipe to complete one of these operations.
12368 @code{End_Of_Page} always returns @code{False}
12371 @code{End_Of_File} will return @code{False} if there is a page mark at
12372 the end of the file.
12376 Output to non-regular files is the same as for regular files. Page marks
12377 may be written to non-regular files using @code{New_Page}, but as noted
12378 above they will not be treated as page marks on input if the output is
12379 piped to another Ada program.
12381 Another important discrepancy when reading non-regular files is that the end
12382 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
12383 pressing the @key{EOT} key,
12385 is signaled once (i.e.@: the test @code{End_Of_File}
12386 will yield @code{True}, or a read will
12387 raise @code{End_Error}), but then reading can resume
12388 to read data past that end of
12389 file indication, until another end of file indication is entered.
12391 @node Get_Immediate
12392 @subsection Get_Immediate
12393 @cindex Get_Immediate
12396 Get_Immediate returns the next character (including control characters)
12397 from the input file. In particular, Get_Immediate will return LF or FF
12398 characters used as line marks or page marks. Such operations leave the
12399 file positioned past the control character, and it is thus not treated
12400 as having its normal function. This means that page, line and column
12401 counts after this kind of Get_Immediate call are set as though the mark
12402 did not occur. In the case where a Get_Immediate leaves the file
12403 positioned between the line mark and page mark (which is not normally
12404 possible), it is undefined whether the FF character will be treated as a
12407 @node Treating Text_IO Files as Streams
12408 @subsection Treating Text_IO Files as Streams
12409 @cindex Stream files
12412 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12413 as a stream. Data written to a Text_IO file in this stream mode is
12414 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
12415 16#0C# (@code{FF}), the resulting file may have non-standard
12416 format. Similarly if read operations are used to read from a Text_IO
12417 file treated as a stream, then @code{LF} and @code{FF} characters may be
12418 skipped and the effect is similar to that described above for
12419 @code{Get_Immediate}.
12421 @node Text_IO Extensions
12422 @subsection Text_IO Extensions
12423 @cindex Text_IO extensions
12426 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12427 to the standard @code{Text_IO} package:
12430 @item function File_Exists (Name : String) return Boolean;
12431 Determines if a file of the given name exists.
12433 @item function Get_Line return String;
12434 Reads a string from the standard input file. The value returned is exactly
12435 the length of the line that was read.
12437 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12438 Similar, except that the parameter File specifies the file from which
12439 the string is to be read.
12443 @node Text_IO Facilities for Unbounded Strings
12444 @subsection Text_IO Facilities for Unbounded Strings
12445 @cindex Text_IO for unbounded strings
12446 @cindex Unbounded_String, Text_IO operations
12449 The package @code{Ada.Strings.Unbounded.Text_IO}
12450 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12451 subprograms useful for Text_IO operations on unbounded strings:
12455 @item function Get_Line (File : File_Type) return Unbounded_String;
12456 Reads a line from the specified file
12457 and returns the result as an unbounded string.
12459 @item procedure Put (File : File_Type; U : Unbounded_String);
12460 Writes the value of the given unbounded string to the specified file
12461 Similar to the effect of
12462 @code{Put (To_String (U))} except that an extra copy is avoided.
12464 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12465 Writes the value of the given unbounded string to the specified file,
12466 followed by a @code{New_Line}.
12467 Similar to the effect of @code{Put_Line (To_String (U))} except
12468 that an extra copy is avoided.
12472 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12473 and is optional. If the parameter is omitted, then the standard input or
12474 output file is referenced as appropriate.
12476 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12477 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12478 @code{Wide_Text_IO} functionality for unbounded wide strings.
12480 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12481 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12482 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12485 @section Wide_Text_IO
12488 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12489 both input and output files may contain special sequences that represent
12490 wide character values. The encoding scheme for a given file may be
12491 specified using a FORM parameter:
12498 as part of the FORM string (WCEM = wide character encoding method),
12499 where @var{x} is one of the following characters
12505 Upper half encoding
12517 The encoding methods match those that
12518 can be used in a source
12519 program, but there is no requirement that the encoding method used for
12520 the source program be the same as the encoding method used for files,
12521 and different files may use different encoding methods.
12523 The default encoding method for the standard files, and for opened files
12524 for which no WCEM parameter is given in the FORM string matches the
12525 wide character encoding specified for the main program (the default
12526 being brackets encoding if no coding method was specified with -gnatW).
12530 In this encoding, a wide character is represented by a five character
12538 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12539 characters (using upper case letters) of the wide character code. For
12540 example, ESC A345 is used to represent the wide character with code
12541 16#A345#. This scheme is compatible with use of the full
12542 @code{Wide_Character} set.
12544 @item Upper Half Coding
12545 The wide character with encoding 16#abcd#, where the upper bit is on
12546 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12547 16#cd#. The second byte may never be a format control character, but is
12548 not required to be in the upper half. This method can be also used for
12549 shift-JIS or EUC where the internal coding matches the external coding.
12551 @item Shift JIS Coding
12552 A wide character is represented by a two character sequence 16#ab# and
12553 16#cd#, with the restrictions described for upper half encoding as
12554 described above. The internal character code is the corresponding JIS
12555 character according to the standard algorithm for Shift-JIS
12556 conversion. Only characters defined in the JIS code set table can be
12557 used with this encoding method.
12560 A wide character is represented by a two character sequence 16#ab# and
12561 16#cd#, with both characters being in the upper half. The internal
12562 character code is the corresponding JIS character according to the EUC
12563 encoding algorithm. Only characters defined in the JIS code set table
12564 can be used with this encoding method.
12567 A wide character is represented using
12568 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12569 10646-1/Am.2. Depending on the character value, the representation
12570 is a one, two, or three byte sequence:
12573 16#0000#-16#007f#: 2#0xxxxxxx#
12574 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12575 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12579 where the @var{xxx} bits correspond to the left-padded bits of the
12580 16-bit character value. Note that all lower half ASCII characters
12581 are represented as ASCII bytes and all upper half characters and
12582 other wide characters are represented as sequences of upper-half
12583 (The full UTF-8 scheme allows for encoding 31-bit characters as
12584 6-byte sequences, but in this implementation, all UTF-8 sequences
12585 of four or more bytes length will raise a Constraint_Error, as
12586 will all invalid UTF-8 sequences.)
12588 @item Brackets Coding
12589 In this encoding, a wide character is represented by the following eight
12590 character sequence:
12597 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12598 characters (using uppercase letters) of the wide character code. For
12599 example, @code{["A345"]} is used to represent the wide character with code
12601 This scheme is compatible with use of the full Wide_Character set.
12602 On input, brackets coding can also be used for upper half characters,
12603 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12604 is only used for wide characters with a code greater than @code{16#FF#}.
12606 Note that brackets coding is not normally used in the context of
12607 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12608 a portable way of encoding source files. In the context of Wide_Text_IO
12609 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12610 any instance of the left bracket character other than to encode wide
12611 character values using the brackets encoding method. In practice it is
12612 expected that some standard wide character encoding method such
12613 as UTF-8 will be used for text input output.
12615 If brackets notation is used, then any occurrence of a left bracket
12616 in the input file which is not the start of a valid wide character
12617 sequence will cause Constraint_Error to be raised. It is possible to
12618 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12619 input will interpret this as a left bracket.
12621 However, when a left bracket is output, it will be output as a left bracket
12622 and not as ["5B"]. We make this decision because for normal use of
12623 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12624 brackets. For example, if we write:
12627 Put_Line ("Start of output [first run]");
12631 we really do not want to have the left bracket in this message clobbered so
12632 that the output reads:
12635 Start of output ["5B"]first run]
12639 In practice brackets encoding is reasonably useful for normal Put_Line use
12640 since we won't get confused between left brackets and wide character
12641 sequences in the output. But for input, or when files are written out
12642 and read back in, it really makes better sense to use one of the standard
12643 encoding methods such as UTF-8.
12648 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12649 not all wide character
12650 values can be represented. An attempt to output a character that cannot
12651 be represented using the encoding scheme for the file causes
12652 Constraint_Error to be raised. An invalid wide character sequence on
12653 input also causes Constraint_Error to be raised.
12656 * Wide_Text_IO Stream Pointer Positioning::
12657 * Wide_Text_IO Reading and Writing Non-Regular Files::
12660 @node Wide_Text_IO Stream Pointer Positioning
12661 @subsection Stream Pointer Positioning
12664 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12665 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12668 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12669 normal lower ASCII set (i.e.@: a character in the range:
12671 @smallexample @c ada
12672 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12676 then although the logical position of the file pointer is unchanged by
12677 the @code{Look_Ahead} call, the stream is physically positioned past the
12678 wide character sequence. Again this is to avoid the need for buffering
12679 or backup, and all @code{Wide_Text_IO} routines check the internal
12680 indication that this situation has occurred so that this is not visible
12681 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
12682 can be observed if the wide text file shares a stream with another file.
12684 @node Wide_Text_IO Reading and Writing Non-Regular Files
12685 @subsection Reading and Writing Non-Regular Files
12688 As in the case of Text_IO, when a non-regular file is read, it is
12689 assumed that the file contains no page marks (any form characters are
12690 treated as data characters), and @code{End_Of_Page} always returns
12691 @code{False}. Similarly, the end of file indication is not sticky, so
12692 it is possible to read beyond an end of file.
12694 @node Wide_Wide_Text_IO
12695 @section Wide_Wide_Text_IO
12698 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12699 both input and output files may contain special sequences that represent
12700 wide wide character values. The encoding scheme for a given file may be
12701 specified using a FORM parameter:
12708 as part of the FORM string (WCEM = wide character encoding method),
12709 where @var{x} is one of the following characters
12715 Upper half encoding
12727 The encoding methods match those that
12728 can be used in a source
12729 program, but there is no requirement that the encoding method used for
12730 the source program be the same as the encoding method used for files,
12731 and different files may use different encoding methods.
12733 The default encoding method for the standard files, and for opened files
12734 for which no WCEM parameter is given in the FORM string matches the
12735 wide character encoding specified for the main program (the default
12736 being brackets encoding if no coding method was specified with -gnatW).
12741 A wide character is represented using
12742 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12743 10646-1/Am.2. Depending on the character value, the representation
12744 is a one, two, three, or four byte sequence:
12747 16#000000#-16#00007f#: 2#0xxxxxxx#
12748 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12749 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12750 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12754 where the @var{xxx} bits correspond to the left-padded bits of the
12755 21-bit character value. Note that all lower half ASCII characters
12756 are represented as ASCII bytes and all upper half characters and
12757 other wide characters are represented as sequences of upper-half
12760 @item Brackets Coding
12761 In this encoding, a wide wide character is represented by the following eight
12762 character sequence if is in wide character range
12768 and by the following ten character sequence if not
12771 [ " a b c d e f " ]
12775 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12776 are the four or six hexadecimal
12777 characters (using uppercase letters) of the wide wide character code. For
12778 example, @code{["01A345"]} is used to represent the wide wide character
12779 with code @code{16#01A345#}.
12781 This scheme is compatible with use of the full Wide_Wide_Character set.
12782 On input, brackets coding can also be used for upper half characters,
12783 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12784 is only used for wide characters with a code greater than @code{16#FF#}.
12789 If is also possible to use the other Wide_Character encoding methods,
12790 such as Shift-JIS, but the other schemes cannot support the full range
12791 of wide wide characters.
12792 An attempt to output a character that cannot
12793 be represented using the encoding scheme for the file causes
12794 Constraint_Error to be raised. An invalid wide character sequence on
12795 input also causes Constraint_Error to be raised.
12798 * Wide_Wide_Text_IO Stream Pointer Positioning::
12799 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12802 @node Wide_Wide_Text_IO Stream Pointer Positioning
12803 @subsection Stream Pointer Positioning
12806 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12807 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12810 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12811 normal lower ASCII set (i.e.@: a character in the range:
12813 @smallexample @c ada
12814 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12818 then although the logical position of the file pointer is unchanged by
12819 the @code{Look_Ahead} call, the stream is physically positioned past the
12820 wide character sequence. Again this is to avoid the need for buffering
12821 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12822 indication that this situation has occurred so that this is not visible
12823 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
12824 can be observed if the wide text file shares a stream with another file.
12826 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12827 @subsection Reading and Writing Non-Regular Files
12830 As in the case of Text_IO, when a non-regular file is read, it is
12831 assumed that the file contains no page marks (any form characters are
12832 treated as data characters), and @code{End_Of_Page} always returns
12833 @code{False}. Similarly, the end of file indication is not sticky, so
12834 it is possible to read beyond an end of file.
12840 A stream file is a sequence of bytes, where individual elements are
12841 written to the file as described in the Ada Reference Manual. The type
12842 @code{Stream_Element} is simply a byte. There are two ways to read or
12843 write a stream file.
12847 The operations @code{Read} and @code{Write} directly read or write a
12848 sequence of stream elements with no control information.
12851 The stream attributes applied to a stream file transfer data in the
12852 manner described for stream attributes.
12856 @section Shared Files
12859 Section A.14 of the Ada Reference Manual allows implementations to
12860 provide a wide variety of behavior if an attempt is made to access the
12861 same external file with two or more internal files.
12863 To provide a full range of functionality, while at the same time
12864 minimizing the problems of portability caused by this implementation
12865 dependence, GNAT handles file sharing as follows:
12869 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12870 to open two or more files with the same full name is considered an error
12871 and is not supported. The exception @code{Use_Error} will be
12872 raised. Note that a file that is not explicitly closed by the program
12873 remains open until the program terminates.
12876 If the form parameter @samp{shared=no} appears in the form string, the
12877 file can be opened or created with its own separate stream identifier,
12878 regardless of whether other files sharing the same external file are
12879 opened. The exact effect depends on how the C stream routines handle
12880 multiple accesses to the same external files using separate streams.
12883 If the form parameter @samp{shared=yes} appears in the form string for
12884 each of two or more files opened using the same full name, the same
12885 stream is shared between these files, and the semantics are as described
12886 in Ada Reference Manual, Section A.14.
12890 When a program that opens multiple files with the same name is ported
12891 from another Ada compiler to GNAT, the effect will be that
12892 @code{Use_Error} is raised.
12894 The documentation of the original compiler and the documentation of the
12895 program should then be examined to determine if file sharing was
12896 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12897 and @code{Create} calls as required.
12899 When a program is ported from GNAT to some other Ada compiler, no
12900 special attention is required unless the @samp{shared=@var{xxx}} form
12901 parameter is used in the program. In this case, you must examine the
12902 documentation of the new compiler to see if it supports the required
12903 file sharing semantics, and form strings modified appropriately. Of
12904 course it may be the case that the program cannot be ported if the
12905 target compiler does not support the required functionality. The best
12906 approach in writing portable code is to avoid file sharing (and hence
12907 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12910 One common use of file sharing in Ada 83 is the use of instantiations of
12911 Sequential_IO on the same file with different types, to achieve
12912 heterogeneous input-output. Although this approach will work in GNAT if
12913 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12914 for this purpose (using the stream attributes)
12916 @node Filenames encoding
12917 @section Filenames encoding
12920 An encoding form parameter can be used to specify the filename
12921 encoding @samp{encoding=@var{xxx}}.
12925 If the form parameter @samp{encoding=utf8} appears in the form string, the
12926 filename must be encoded in UTF-8.
12929 If the form parameter @samp{encoding=8bits} appears in the form
12930 string, the filename must be a standard 8bits string.
12933 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12934 value UTF-8 is used. This encoding form parameter is only supported on
12935 the Windows platform. On the other Operating Systems the runtime is
12936 supporting UTF-8 natively.
12939 @section Open Modes
12942 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12943 using the mode shown in the following table:
12946 @center @code{Open} and @code{Create} Call Modes
12948 @b{OPEN } @b{CREATE}
12949 Append_File "r+" "w+"
12951 Out_File (Direct_IO) "r+" "w"
12952 Out_File (all other cases) "w" "w"
12953 Inout_File "r+" "w+"
12957 If text file translation is required, then either @samp{b} or @samp{t}
12958 is added to the mode, depending on the setting of Text. Text file
12959 translation refers to the mapping of CR/LF sequences in an external file
12960 to LF characters internally. This mapping only occurs in DOS and
12961 DOS-like systems, and is not relevant to other systems.
12963 A special case occurs with Stream_IO@. As shown in the above table, the
12964 file is initially opened in @samp{r} or @samp{w} mode for the
12965 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
12966 subsequently requires switching from reading to writing or vice-versa,
12967 then the file is reopened in @samp{r+} mode to permit the required operation.
12969 @node Operations on C Streams
12970 @section Operations on C Streams
12971 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12972 access to the C library functions for operations on C streams:
12974 @smallexample @c adanocomment
12975 package Interfaces.C_Streams is
12976 -- Note: the reason we do not use the types that are in
12977 -- Interfaces.C is that we want to avoid dragging in the
12978 -- code in this unit if possible.
12979 subtype chars is System.Address;
12980 -- Pointer to null-terminated array of characters
12981 subtype FILEs is System.Address;
12982 -- Corresponds to the C type FILE*
12983 subtype voids is System.Address;
12984 -- Corresponds to the C type void*
12985 subtype int is Integer;
12986 subtype long is Long_Integer;
12987 -- Note: the above types are subtypes deliberately, and it
12988 -- is part of this spec that the above correspondences are
12989 -- guaranteed. This means that it is legitimate to, for
12990 -- example, use Integer instead of int. We provide these
12991 -- synonyms for clarity, but in some cases it may be
12992 -- convenient to use the underlying types (for example to
12993 -- avoid an unnecessary dependency of a spec on the spec
12995 type size_t is mod 2 ** Standard'Address_Size;
12996 NULL_Stream : constant FILEs;
12997 -- Value returned (NULL in C) to indicate an
12998 -- fdopen/fopen/tmpfile error
12999 ----------------------------------
13000 -- Constants Defined in stdio.h --
13001 ----------------------------------
13002 EOF : constant int;
13003 -- Used by a number of routines to indicate error or
13005 IOFBF : constant int;
13006 IOLBF : constant int;
13007 IONBF : constant int;
13008 -- Used to indicate buffering mode for setvbuf call
13009 SEEK_CUR : constant int;
13010 SEEK_END : constant int;
13011 SEEK_SET : constant int;
13012 -- Used to indicate origin for fseek call
13013 function stdin return FILEs;
13014 function stdout return FILEs;
13015 function stderr return FILEs;
13016 -- Streams associated with standard files
13017 --------------------------
13018 -- Standard C functions --
13019 --------------------------
13020 -- The functions selected below are ones that are
13021 -- available in DOS, OS/2, UNIX and Xenix (but not
13022 -- necessarily in ANSI C). These are very thin interfaces
13023 -- which copy exactly the C headers. For more
13024 -- documentation on these functions, see the Microsoft C
13025 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13026 -- ISBN 1-55615-225-6), which includes useful information
13027 -- on system compatibility.
13028 procedure clearerr (stream : FILEs);
13029 function fclose (stream : FILEs) return int;
13030 function fdopen (handle : int; mode : chars) return FILEs;
13031 function feof (stream : FILEs) return int;
13032 function ferror (stream : FILEs) return int;
13033 function fflush (stream : FILEs) return int;
13034 function fgetc (stream : FILEs) return int;
13035 function fgets (strng : chars; n : int; stream : FILEs)
13037 function fileno (stream : FILEs) return int;
13038 function fopen (filename : chars; Mode : chars)
13040 -- Note: to maintain target independence, use
13041 -- text_translation_required, a boolean variable defined in
13042 -- a-sysdep.c to deal with the target dependent text
13043 -- translation requirement. If this variable is set,
13044 -- then b/t should be appended to the standard mode
13045 -- argument to set the text translation mode off or on
13047 function fputc (C : int; stream : FILEs) return int;
13048 function fputs (Strng : chars; Stream : FILEs) return int;
13065 function ftell (stream : FILEs) return long;
13072 function isatty (handle : int) return int;
13073 procedure mktemp (template : chars);
13074 -- The return value (which is just a pointer to template)
13076 procedure rewind (stream : FILEs);
13077 function rmtmp return int;
13085 function tmpfile return FILEs;
13086 function ungetc (c : int; stream : FILEs) return int;
13087 function unlink (filename : chars) return int;
13088 ---------------------
13089 -- Extra functions --
13090 ---------------------
13091 -- These functions supply slightly thicker bindings than
13092 -- those above. They are derived from functions in the
13093 -- C Run-Time Library, but may do a bit more work than
13094 -- just directly calling one of the Library functions.
13095 function is_regular_file (handle : int) return int;
13096 -- Tests if given handle is for a regular file (result 1)
13097 -- or for a non-regular file (pipe or device, result 0).
13098 ---------------------------------
13099 -- Control of Text/Binary Mode --
13100 ---------------------------------
13101 -- If text_translation_required is true, then the following
13102 -- functions may be used to dynamically switch a file from
13103 -- binary to text mode or vice versa. These functions have
13104 -- no effect if text_translation_required is false (i.e.@: in
13105 -- normal UNIX mode). Use fileno to get a stream handle.
13106 procedure set_binary_mode (handle : int);
13107 procedure set_text_mode (handle : int);
13108 ----------------------------
13109 -- Full Path Name support --
13110 ----------------------------
13111 procedure full_name (nam : chars; buffer : chars);
13112 -- Given a NUL terminated string representing a file
13113 -- name, returns in buffer a NUL terminated string
13114 -- representing the full path name for the file name.
13115 -- On systems where it is relevant the drive is also
13116 -- part of the full path name. It is the responsibility
13117 -- of the caller to pass an actual parameter for buffer
13118 -- that is big enough for any full path name. Use
13119 -- max_path_len given below as the size of buffer.
13120 max_path_len : integer;
13121 -- Maximum length of an allowable full path name on the
13122 -- system, including a terminating NUL character.
13123 end Interfaces.C_Streams;
13126 @node Interfacing to C Streams
13127 @section Interfacing to C Streams
13130 The packages in this section permit interfacing Ada files to C Stream
13133 @smallexample @c ada
13134 with Interfaces.C_Streams;
13135 package Ada.Sequential_IO.C_Streams is
13136 function C_Stream (F : File_Type)
13137 return Interfaces.C_Streams.FILEs;
13139 (File : in out File_Type;
13140 Mode : in File_Mode;
13141 C_Stream : in Interfaces.C_Streams.FILEs;
13142 Form : in String := "");
13143 end Ada.Sequential_IO.C_Streams;
13145 with Interfaces.C_Streams;
13146 package Ada.Direct_IO.C_Streams is
13147 function C_Stream (F : File_Type)
13148 return Interfaces.C_Streams.FILEs;
13150 (File : in out File_Type;
13151 Mode : in File_Mode;
13152 C_Stream : in Interfaces.C_Streams.FILEs;
13153 Form : in String := "");
13154 end Ada.Direct_IO.C_Streams;
13156 with Interfaces.C_Streams;
13157 package Ada.Text_IO.C_Streams is
13158 function C_Stream (F : File_Type)
13159 return Interfaces.C_Streams.FILEs;
13161 (File : in out File_Type;
13162 Mode : in File_Mode;
13163 C_Stream : in Interfaces.C_Streams.FILEs;
13164 Form : in String := "");
13165 end Ada.Text_IO.C_Streams;
13167 with Interfaces.C_Streams;
13168 package Ada.Wide_Text_IO.C_Streams is
13169 function C_Stream (F : File_Type)
13170 return Interfaces.C_Streams.FILEs;
13172 (File : in out File_Type;
13173 Mode : in File_Mode;
13174 C_Stream : in Interfaces.C_Streams.FILEs;
13175 Form : in String := "");
13176 end Ada.Wide_Text_IO.C_Streams;
13178 with Interfaces.C_Streams;
13179 package Ada.Wide_Wide_Text_IO.C_Streams is
13180 function C_Stream (F : File_Type)
13181 return Interfaces.C_Streams.FILEs;
13183 (File : in out File_Type;
13184 Mode : in File_Mode;
13185 C_Stream : in Interfaces.C_Streams.FILEs;
13186 Form : in String := "");
13187 end Ada.Wide_Wide_Text_IO.C_Streams;
13189 with Interfaces.C_Streams;
13190 package Ada.Stream_IO.C_Streams is
13191 function C_Stream (F : File_Type)
13192 return Interfaces.C_Streams.FILEs;
13194 (File : in out File_Type;
13195 Mode : in File_Mode;
13196 C_Stream : in Interfaces.C_Streams.FILEs;
13197 Form : in String := "");
13198 end Ada.Stream_IO.C_Streams;
13202 In each of these six packages, the @code{C_Stream} function obtains the
13203 @code{FILE} pointer from a currently opened Ada file. It is then
13204 possible to use the @code{Interfaces.C_Streams} package to operate on
13205 this stream, or the stream can be passed to a C program which can
13206 operate on it directly. Of course the program is responsible for
13207 ensuring that only appropriate sequences of operations are executed.
13209 One particular use of relevance to an Ada program is that the
13210 @code{setvbuf} function can be used to control the buffering of the
13211 stream used by an Ada file. In the absence of such a call the standard
13212 default buffering is used.
13214 The @code{Open} procedures in these packages open a file giving an
13215 existing C Stream instead of a file name. Typically this stream is
13216 imported from a C program, allowing an Ada file to operate on an
13219 @node The GNAT Library
13220 @chapter The GNAT Library
13223 The GNAT library contains a number of general and special purpose packages.
13224 It represents functionality that the GNAT developers have found useful, and
13225 which is made available to GNAT users. The packages described here are fully
13226 supported, and upwards compatibility will be maintained in future releases,
13227 so you can use these facilities with the confidence that the same functionality
13228 will be available in future releases.
13230 The chapter here simply gives a brief summary of the facilities available.
13231 The full documentation is found in the spec file for the package. The full
13232 sources of these library packages, including both spec and body, are provided
13233 with all GNAT releases. For example, to find out the full specifications of
13234 the SPITBOL pattern matching capability, including a full tutorial and
13235 extensive examples, look in the @file{g-spipat.ads} file in the library.
13237 For each entry here, the package name (as it would appear in a @code{with}
13238 clause) is given, followed by the name of the corresponding spec file in
13239 parentheses. The packages are children in four hierarchies, @code{Ada},
13240 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13241 GNAT-specific hierarchy.
13243 Note that an application program should only use packages in one of these
13244 four hierarchies if the package is defined in the Ada Reference Manual,
13245 or is listed in this section of the GNAT Programmers Reference Manual.
13246 All other units should be considered internal implementation units and
13247 should not be directly @code{with}'ed by application code. The use of
13248 a @code{with} statement that references one of these internal implementation
13249 units makes an application potentially dependent on changes in versions
13250 of GNAT, and will generate a warning message.
13253 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13254 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13255 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13256 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13257 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13258 * Ada.Command_Line.Environment (a-colien.ads)::
13259 * Ada.Command_Line.Remove (a-colire.ads)::
13260 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13261 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13262 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13263 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13264 * Ada.Exceptions.Traceback (a-exctra.ads)::
13265 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13266 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13267 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13268 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13269 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13270 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13271 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13272 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13273 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13274 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13275 * GNAT.Altivec (g-altive.ads)::
13276 * GNAT.Altivec.Conversions (g-altcon.ads)::
13277 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13278 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13279 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13280 * GNAT.Array_Split (g-arrspl.ads)::
13281 * GNAT.AWK (g-awk.ads)::
13282 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13283 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13284 * GNAT.Bubble_Sort (g-bubsor.ads)::
13285 * GNAT.Bubble_Sort_A (g-busora.ads)::
13286 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13287 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13288 * GNAT.Byte_Swapping (g-bytswa.ads)::
13289 * GNAT.Calendar (g-calend.ads)::
13290 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13291 * GNAT.Case_Util (g-casuti.ads)::
13292 * GNAT.CGI (g-cgi.ads)::
13293 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13294 * GNAT.CGI.Debug (g-cgideb.ads)::
13295 * GNAT.Command_Line (g-comlin.ads)::
13296 * GNAT.Compiler_Version (g-comver.ads)::
13297 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13298 * GNAT.CRC32 (g-crc32.ads)::
13299 * GNAT.Current_Exception (g-curexc.ads)::
13300 * GNAT.Debug_Pools (g-debpoo.ads)::
13301 * GNAT.Debug_Utilities (g-debuti.ads)::
13302 * GNAT.Decode_String (g-decstr.ads)::
13303 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13304 * GNAT.Directory_Operations (g-dirope.ads)::
13305 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13306 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13307 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13308 * GNAT.Encode_String (g-encstr.ads)::
13309 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13310 * GNAT.Exception_Actions (g-excact.ads)::
13311 * GNAT.Exception_Traces (g-exctra.ads)::
13312 * GNAT.Exceptions (g-except.ads)::
13313 * GNAT.Expect (g-expect.ads)::
13314 * GNAT.Float_Control (g-flocon.ads)::
13315 * GNAT.Heap_Sort (g-heasor.ads)::
13316 * GNAT.Heap_Sort_A (g-hesora.ads)::
13317 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13318 * GNAT.HTable (g-htable.ads)::
13319 * GNAT.IO (g-io.ads)::
13320 * GNAT.IO_Aux (g-io_aux.ads)::
13321 * GNAT.Lock_Files (g-locfil.ads)::
13322 * GNAT.MD5 (g-md5.ads)::
13323 * GNAT.Memory_Dump (g-memdum.ads)::
13324 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13325 * GNAT.OS_Lib (g-os_lib.ads)::
13326 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13327 * GNAT.Random_Numbers (g-rannum.ads)::
13328 * GNAT.Regexp (g-regexp.ads)::
13329 * GNAT.Registry (g-regist.ads)::
13330 * GNAT.Regpat (g-regpat.ads)::
13331 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13332 * GNAT.Semaphores (g-semaph.ads)::
13333 * GNAT.Serial_Communications (g-sercom.ads)::
13334 * GNAT.SHA1 (g-sha1.ads)::
13335 * GNAT.Signals (g-signal.ads)::
13336 * GNAT.Sockets (g-socket.ads)::
13337 * GNAT.Source_Info (g-souinf.ads)::
13338 * GNAT.Spelling_Checker (g-speche.ads)::
13339 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13340 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13341 * GNAT.Spitbol (g-spitbo.ads)::
13342 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13343 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13344 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13345 * GNAT.Strings (g-string.ads)::
13346 * GNAT.String_Split (g-strspl.ads)::
13347 * GNAT.Table (g-table.ads)::
13348 * GNAT.Task_Lock (g-tasloc.ads)::
13349 * GNAT.Threads (g-thread.ads)::
13350 * GNAT.Time_Stamp (g-timsta.ads)::
13351 * GNAT.Traceback (g-traceb.ads)::
13352 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13353 * GNAT.UTF_32 (g-utf_32.ads)::
13354 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13355 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13356 * GNAT.Wide_String_Split (g-wistsp.ads)::
13357 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13358 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13359 * Interfaces.C.Extensions (i-cexten.ads)::
13360 * Interfaces.C.Streams (i-cstrea.ads)::
13361 * Interfaces.CPP (i-cpp.ads)::
13362 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13363 * Interfaces.VxWorks (i-vxwork.ads)::
13364 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13365 * System.Address_Image (s-addima.ads)::
13366 * System.Assertions (s-assert.ads)::
13367 * System.Memory (s-memory.ads)::
13368 * System.Partition_Interface (s-parint.ads)::
13369 * System.Pool_Global (s-pooglo.ads)::
13370 * System.Pool_Local (s-pooloc.ads)::
13371 * System.Restrictions (s-restri.ads)::
13372 * System.Rident (s-rident.ads)::
13373 * System.Task_Info (s-tasinf.ads)::
13374 * System.Wch_Cnv (s-wchcnv.ads)::
13375 * System.Wch_Con (s-wchcon.ads)::
13378 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13379 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13380 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13381 @cindex Latin_9 constants for Character
13384 This child of @code{Ada.Characters}
13385 provides a set of definitions corresponding to those in the
13386 RM-defined package @code{Ada.Characters.Latin_1} but with the
13387 few modifications required for @code{Latin-9}
13388 The provision of such a package
13389 is specifically authorized by the Ada Reference Manual
13392 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13393 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13394 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13395 @cindex Latin_1 constants for Wide_Character
13398 This child of @code{Ada.Characters}
13399 provides a set of definitions corresponding to those in the
13400 RM-defined package @code{Ada.Characters.Latin_1} but with the
13401 types of the constants being @code{Wide_Character}
13402 instead of @code{Character}. The provision of such a package
13403 is specifically authorized by the Ada Reference Manual
13406 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13407 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13408 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13409 @cindex Latin_9 constants for Wide_Character
13412 This child of @code{Ada.Characters}
13413 provides a set of definitions corresponding to those in the
13414 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13415 types of the constants being @code{Wide_Character}
13416 instead of @code{Character}. The provision of such a package
13417 is specifically authorized by the Ada Reference Manual
13420 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13421 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13422 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13423 @cindex Latin_1 constants for Wide_Wide_Character
13426 This child of @code{Ada.Characters}
13427 provides a set of definitions corresponding to those in the
13428 RM-defined package @code{Ada.Characters.Latin_1} but with the
13429 types of the constants being @code{Wide_Wide_Character}
13430 instead of @code{Character}. The provision of such a package
13431 is specifically authorized by the Ada Reference Manual
13434 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13435 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13436 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13437 @cindex Latin_9 constants for Wide_Wide_Character
13440 This child of @code{Ada.Characters}
13441 provides a set of definitions corresponding to those in the
13442 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13443 types of the constants being @code{Wide_Wide_Character}
13444 instead of @code{Character}. The provision of such a package
13445 is specifically authorized by the Ada Reference Manual
13448 @node Ada.Command_Line.Environment (a-colien.ads)
13449 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13450 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13451 @cindex Environment entries
13454 This child of @code{Ada.Command_Line}
13455 provides a mechanism for obtaining environment values on systems
13456 where this concept makes sense.
13458 @node Ada.Command_Line.Remove (a-colire.ads)
13459 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13460 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13461 @cindex Removing command line arguments
13462 @cindex Command line, argument removal
13465 This child of @code{Ada.Command_Line}
13466 provides a mechanism for logically removing
13467 arguments from the argument list. Once removed, an argument is not visible
13468 to further calls on the subprograms in @code{Ada.Command_Line} will not
13469 see the removed argument.
13471 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13472 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13473 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13474 @cindex Response file for command line
13475 @cindex Command line, response file
13476 @cindex Command line, handling long command lines
13479 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13480 getting command line arguments from a text file, called a "response file".
13481 Using a response file allow passing a set of arguments to an executable longer
13482 than the maximum allowed by the system on the command line.
13484 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13485 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13486 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13487 @cindex C Streams, Interfacing with Direct_IO
13490 This package provides subprograms that allow interfacing between
13491 C streams and @code{Direct_IO}. The stream identifier can be
13492 extracted from a file opened on the Ada side, and an Ada file
13493 can be constructed from a stream opened on the C side.
13495 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13496 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13497 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13498 @cindex Null_Occurrence, testing for
13501 This child subprogram provides a way of testing for the null
13502 exception occurrence (@code{Null_Occurrence}) without raising
13505 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13506 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13507 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13508 @cindex Null_Occurrence, testing for
13511 This child subprogram is used for handling otherwise unhandled
13512 exceptions (hence the name last chance), and perform clean ups before
13513 terminating the program. Note that this subprogram never returns.
13515 @node Ada.Exceptions.Traceback (a-exctra.ads)
13516 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13517 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13518 @cindex Traceback for Exception Occurrence
13521 This child package provides the subprogram (@code{Tracebacks}) to
13522 give a traceback array of addresses based on an exception
13525 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13526 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13527 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13528 @cindex C Streams, Interfacing with Sequential_IO
13531 This package provides subprograms that allow interfacing between
13532 C streams and @code{Sequential_IO}. The stream identifier can be
13533 extracted from a file opened on the Ada side, and an Ada file
13534 can be constructed from a stream opened on the C side.
13536 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13537 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13538 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13539 @cindex C Streams, Interfacing with Stream_IO
13542 This package provides subprograms that allow interfacing between
13543 C streams and @code{Stream_IO}. The stream identifier can be
13544 extracted from a file opened on the Ada side, and an Ada file
13545 can be constructed from a stream opened on the C side.
13547 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13548 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13549 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13550 @cindex @code{Unbounded_String}, IO support
13551 @cindex @code{Text_IO}, extensions for unbounded strings
13554 This package provides subprograms for Text_IO for unbounded
13555 strings, avoiding the necessity for an intermediate operation
13556 with ordinary strings.
13558 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13559 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13560 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13561 @cindex @code{Unbounded_Wide_String}, IO support
13562 @cindex @code{Text_IO}, extensions for unbounded wide strings
13565 This package provides subprograms for Text_IO for unbounded
13566 wide strings, avoiding the necessity for an intermediate operation
13567 with ordinary wide strings.
13569 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13570 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13571 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13572 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13573 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13576 This package provides subprograms for Text_IO for unbounded
13577 wide wide strings, avoiding the necessity for an intermediate operation
13578 with ordinary wide wide strings.
13580 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13581 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13582 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13583 @cindex C Streams, Interfacing with @code{Text_IO}
13586 This package provides subprograms that allow interfacing between
13587 C streams and @code{Text_IO}. The stream identifier can be
13588 extracted from a file opened on the Ada side, and an Ada file
13589 can be constructed from a stream opened on the C side.
13591 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13592 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13593 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13594 @cindex Unicode categorization, Wide_Character
13597 This package provides subprograms that allow categorization of
13598 Wide_Character values according to Unicode categories.
13600 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13601 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13602 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13603 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13606 This package provides subprograms that allow interfacing between
13607 C streams and @code{Wide_Text_IO}. The stream identifier can be
13608 extracted from a file opened on the Ada side, and an Ada file
13609 can be constructed from a stream opened on the C side.
13611 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13612 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13613 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13614 @cindex Unicode categorization, Wide_Wide_Character
13617 This package provides subprograms that allow categorization of
13618 Wide_Wide_Character values according to Unicode categories.
13620 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13621 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13622 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13623 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13626 This package provides subprograms that allow interfacing between
13627 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
13628 extracted from a file opened on the Ada side, and an Ada file
13629 can be constructed from a stream opened on the C side.
13631 @node GNAT.Altivec (g-altive.ads)
13632 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13633 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13637 This is the root package of the GNAT AltiVec binding. It provides
13638 definitions of constants and types common to all the versions of the
13641 @node GNAT.Altivec.Conversions (g-altcon.ads)
13642 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13643 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13647 This package provides the Vector/View conversion routines.
13649 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13650 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13651 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13655 This package exposes the Ada interface to the AltiVec operations on
13656 vector objects. A soft emulation is included by default in the GNAT
13657 library. The hard binding is provided as a separate package. This unit
13658 is common to both bindings.
13660 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13661 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13662 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13666 This package exposes the various vector types part of the Ada binding
13667 to AltiVec facilities.
13669 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13670 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13671 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13675 This package provides public 'View' data types from/to which private
13676 vector representations can be converted via
13677 GNAT.Altivec.Conversions. This allows convenient access to individual
13678 vector elements and provides a simple way to initialize vector
13681 @node GNAT.Array_Split (g-arrspl.ads)
13682 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13683 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13684 @cindex Array splitter
13687 Useful array-manipulation routines: given a set of separators, split
13688 an array wherever the separators appear, and provide direct access
13689 to the resulting slices.
13691 @node GNAT.AWK (g-awk.ads)
13692 @section @code{GNAT.AWK} (@file{g-awk.ads})
13693 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13698 Provides AWK-like parsing functions, with an easy interface for parsing one
13699 or more files containing formatted data. The file is viewed as a database
13700 where each record is a line and a field is a data element in this line.
13702 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13703 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13704 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13706 @cindex Bounded Buffers
13709 Provides a concurrent generic bounded buffer abstraction. Instances are
13710 useful directly or as parts of the implementations of other abstractions,
13713 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13714 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13715 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13720 Provides a thread-safe asynchronous intertask mailbox communication facility.
13722 @node GNAT.Bubble_Sort (g-bubsor.ads)
13723 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13724 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13726 @cindex Bubble sort
13729 Provides a general implementation of bubble sort usable for sorting arbitrary
13730 data items. Exchange and comparison procedures are provided by passing
13731 access-to-procedure values.
13733 @node GNAT.Bubble_Sort_A (g-busora.ads)
13734 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13735 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13737 @cindex Bubble sort
13740 Provides a general implementation of bubble sort usable for sorting arbitrary
13741 data items. Move and comparison procedures are provided by passing
13742 access-to-procedure values. This is an older version, retained for
13743 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13745 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13746 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13747 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13749 @cindex Bubble sort
13752 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13753 are provided as generic parameters, this improves efficiency, especially
13754 if the procedures can be inlined, at the expense of duplicating code for
13755 multiple instantiations.
13757 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13758 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13759 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13760 @cindex UTF-8 representation
13761 @cindex Wide characte representations
13764 Provides a routine which given a string, reads the start of the string to
13765 see whether it is one of the standard byte order marks (BOM's) which signal
13766 the encoding of the string. The routine includes detection of special XML
13767 sequences for various UCS input formats.
13769 @node GNAT.Byte_Swapping (g-bytswa.ads)
13770 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13771 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13772 @cindex Byte swapping
13776 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13777 Machine-specific implementations are available in some cases.
13779 @node GNAT.Calendar (g-calend.ads)
13780 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13781 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13782 @cindex @code{Calendar}
13785 Extends the facilities provided by @code{Ada.Calendar} to include handling
13786 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13787 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13788 C @code{timeval} format.
13790 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13791 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13792 @cindex @code{Calendar}
13794 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13796 @node GNAT.CRC32 (g-crc32.ads)
13797 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13798 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13800 @cindex Cyclic Redundancy Check
13803 This package implements the CRC-32 algorithm. For a full description
13804 of this algorithm see
13805 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13806 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13807 Aug.@: 1988. Sarwate, D.V@.
13809 @node GNAT.Case_Util (g-casuti.ads)
13810 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13811 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13812 @cindex Casing utilities
13813 @cindex Character handling (@code{GNAT.Case_Util})
13816 A set of simple routines for handling upper and lower casing of strings
13817 without the overhead of the full casing tables
13818 in @code{Ada.Characters.Handling}.
13820 @node GNAT.CGI (g-cgi.ads)
13821 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13822 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13823 @cindex CGI (Common Gateway Interface)
13826 This is a package for interfacing a GNAT program with a Web server via the
13827 Common Gateway Interface (CGI)@. Basically this package parses the CGI
13828 parameters, which are a set of key/value pairs sent by the Web server. It
13829 builds a table whose index is the key and provides some services to deal
13832 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13833 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13834 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13835 @cindex CGI (Common Gateway Interface) cookie support
13836 @cindex Cookie support in CGI
13839 This is a package to interface a GNAT program with a Web server via the
13840 Common Gateway Interface (CGI). It exports services to deal with Web
13841 cookies (piece of information kept in the Web client software).
13843 @node GNAT.CGI.Debug (g-cgideb.ads)
13844 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13845 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13846 @cindex CGI (Common Gateway Interface) debugging
13849 This is a package to help debugging CGI (Common Gateway Interface)
13850 programs written in Ada.
13852 @node GNAT.Command_Line (g-comlin.ads)
13853 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13854 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13855 @cindex Command line
13858 Provides a high level interface to @code{Ada.Command_Line} facilities,
13859 including the ability to scan for named switches with optional parameters
13860 and expand file names using wild card notations.
13862 @node GNAT.Compiler_Version (g-comver.ads)
13863 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13864 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13865 @cindex Compiler Version
13866 @cindex Version, of compiler
13869 Provides a routine for obtaining the version of the compiler used to
13870 compile the program. More accurately this is the version of the binder
13871 used to bind the program (this will normally be the same as the version
13872 of the compiler if a consistent tool set is used to compile all units
13875 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13876 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13877 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13881 Provides a simple interface to handle Ctrl-C keyboard events.
13883 @node GNAT.Current_Exception (g-curexc.ads)
13884 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13885 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13886 @cindex Current exception
13887 @cindex Exception retrieval
13890 Provides access to information on the current exception that has been raised
13891 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13892 specification syntax.
13893 This is particularly useful in simulating typical facilities for
13894 obtaining information about exceptions provided by Ada 83 compilers.
13896 @node GNAT.Debug_Pools (g-debpoo.ads)
13897 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13898 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13900 @cindex Debug pools
13901 @cindex Memory corruption debugging
13904 Provide a debugging storage pools that helps tracking memory corruption
13905 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
13906 @value{EDITION} User's Guide}.
13908 @node GNAT.Debug_Utilities (g-debuti.ads)
13909 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13910 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13914 Provides a few useful utilities for debugging purposes, including conversion
13915 to and from string images of address values. Supports both C and Ada formats
13916 for hexadecimal literals.
13918 @node GNAT.Decode_String (g-decstr.ads)
13919 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
13920 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
13921 @cindex Decoding strings
13922 @cindex String decoding
13923 @cindex Wide character encoding
13928 A generic package providing routines for decoding wide character and wide wide
13929 character strings encoded as sequences of 8-bit characters using a specified
13930 encoding method. Includes validation routines, and also routines for stepping
13931 to next or previous encoded character in an encoded string.
13932 Useful in conjunction with Unicode character coding. Note there is a
13933 preinstantiation for UTF-8. See next entry.
13935 @node GNAT.Decode_UTF8_String (g-deutst.ads)
13936 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13937 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13938 @cindex Decoding strings
13939 @cindex Decoding UTF-8 strings
13940 @cindex UTF-8 string decoding
13941 @cindex Wide character decoding
13946 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
13948 @node GNAT.Directory_Operations (g-dirope.ads)
13949 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13950 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13951 @cindex Directory operations
13954 Provides a set of routines for manipulating directories, including changing
13955 the current directory, making new directories, and scanning the files in a
13958 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
13959 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13960 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13961 @cindex Directory operations iteration
13964 A child unit of GNAT.Directory_Operations providing additional operations
13965 for iterating through directories.
13967 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13968 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13969 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13970 @cindex Hash tables
13973 A generic implementation of hash tables that can be used to hash arbitrary
13974 data. Provided in two forms, a simple form with built in hash functions,
13975 and a more complex form in which the hash function is supplied.
13978 This package provides a facility similar to that of @code{GNAT.HTable},
13979 except that this package declares a type that can be used to define
13980 dynamic instances of the hash table, while an instantiation of
13981 @code{GNAT.HTable} creates a single instance of the hash table.
13983 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13984 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13985 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13986 @cindex Table implementation
13987 @cindex Arrays, extendable
13990 A generic package providing a single dimension array abstraction where the
13991 length of the array can be dynamically modified.
13994 This package provides a facility similar to that of @code{GNAT.Table},
13995 except that this package declares a type that can be used to define
13996 dynamic instances of the table, while an instantiation of
13997 @code{GNAT.Table} creates a single instance of the table type.
13999 @node GNAT.Encode_String (g-encstr.ads)
14000 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14001 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14002 @cindex Encoding strings
14003 @cindex String encoding
14004 @cindex Wide character encoding
14009 A generic package providing routines for encoding wide character and wide
14010 wide character strings as sequences of 8-bit characters using a specified
14011 encoding method. Useful in conjunction with Unicode character coding.
14012 Note there is a preinstantiation for UTF-8. See next entry.
14014 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14015 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14016 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14017 @cindex Encoding strings
14018 @cindex Encoding UTF-8 strings
14019 @cindex UTF-8 string encoding
14020 @cindex Wide character encoding
14025 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14027 @node GNAT.Exception_Actions (g-excact.ads)
14028 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14029 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14030 @cindex Exception actions
14033 Provides callbacks when an exception is raised. Callbacks can be registered
14034 for specific exceptions, or when any exception is raised. This
14035 can be used for instance to force a core dump to ease debugging.
14037 @node GNAT.Exception_Traces (g-exctra.ads)
14038 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14039 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14040 @cindex Exception traces
14044 Provides an interface allowing to control automatic output upon exception
14047 @node GNAT.Exceptions (g-except.ads)
14048 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14049 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14050 @cindex Exceptions, Pure
14051 @cindex Pure packages, exceptions
14054 Normally it is not possible to raise an exception with
14055 a message from a subprogram in a pure package, since the
14056 necessary types and subprograms are in @code{Ada.Exceptions}
14057 which is not a pure unit. @code{GNAT.Exceptions} provides a
14058 facility for getting around this limitation for a few
14059 predefined exceptions, and for example allow raising
14060 @code{Constraint_Error} with a message from a pure subprogram.
14062 @node GNAT.Expect (g-expect.ads)
14063 @section @code{GNAT.Expect} (@file{g-expect.ads})
14064 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14067 Provides a set of subprograms similar to what is available
14068 with the standard Tcl Expect tool.
14069 It allows you to easily spawn and communicate with an external process.
14070 You can send commands or inputs to the process, and compare the output
14071 with some expected regular expression. Currently @code{GNAT.Expect}
14072 is implemented on all native GNAT ports except for OpenVMS@.
14073 It is not implemented for cross ports, and in particular is not
14074 implemented for VxWorks or LynxOS@.
14076 @node GNAT.Float_Control (g-flocon.ads)
14077 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14078 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14079 @cindex Floating-Point Processor
14082 Provides an interface for resetting the floating-point processor into the
14083 mode required for correct semantic operation in Ada. Some third party
14084 library calls may cause this mode to be modified, and the Reset procedure
14085 in this package can be used to reestablish the required mode.
14087 @node GNAT.Heap_Sort (g-heasor.ads)
14088 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14089 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14093 Provides a general implementation of heap sort usable for sorting arbitrary
14094 data items. Exchange and comparison procedures are provided by passing
14095 access-to-procedure values. The algorithm used is a modified heap sort
14096 that performs approximately N*log(N) comparisons in the worst case.
14098 @node GNAT.Heap_Sort_A (g-hesora.ads)
14099 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14100 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14104 Provides a general implementation of heap sort usable for sorting arbitrary
14105 data items. Move and comparison procedures are provided by passing
14106 access-to-procedure values. The algorithm used is a modified heap sort
14107 that performs approximately N*log(N) comparisons in the worst case.
14108 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14109 interface, but may be slightly more efficient.
14111 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14112 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14113 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14117 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14118 are provided as generic parameters, this improves efficiency, especially
14119 if the procedures can be inlined, at the expense of duplicating code for
14120 multiple instantiations.
14122 @node GNAT.HTable (g-htable.ads)
14123 @section @code{GNAT.HTable} (@file{g-htable.ads})
14124 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14125 @cindex Hash tables
14128 A generic implementation of hash tables that can be used to hash arbitrary
14129 data. Provides two approaches, one a simple static approach, and the other
14130 allowing arbitrary dynamic hash tables.
14132 @node GNAT.IO (g-io.ads)
14133 @section @code{GNAT.IO} (@file{g-io.ads})
14134 @cindex @code{GNAT.IO} (@file{g-io.ads})
14136 @cindex Input/Output facilities
14139 A simple preelaborable input-output package that provides a subset of
14140 simple Text_IO functions for reading characters and strings from
14141 Standard_Input, and writing characters, strings and integers to either
14142 Standard_Output or Standard_Error.
14144 @node GNAT.IO_Aux (g-io_aux.ads)
14145 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14146 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14148 @cindex Input/Output facilities
14150 Provides some auxiliary functions for use with Text_IO, including a test
14151 for whether a file exists, and functions for reading a line of text.
14153 @node GNAT.Lock_Files (g-locfil.ads)
14154 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14155 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14156 @cindex File locking
14157 @cindex Locking using files
14160 Provides a general interface for using files as locks. Can be used for
14161 providing program level synchronization.
14163 @node GNAT.MD5 (g-md5.ads)
14164 @section @code{GNAT.MD5} (@file{g-md5.ads})
14165 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14166 @cindex Message Digest MD5
14169 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14171 @node GNAT.Memory_Dump (g-memdum.ads)
14172 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14173 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14174 @cindex Dump Memory
14177 Provides a convenient routine for dumping raw memory to either the
14178 standard output or standard error files. Uses GNAT.IO for actual
14181 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14182 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14183 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14184 @cindex Exception, obtaining most recent
14187 Provides access to the most recently raised exception. Can be used for
14188 various logging purposes, including duplicating functionality of some
14189 Ada 83 implementation dependent extensions.
14191 @node GNAT.OS_Lib (g-os_lib.ads)
14192 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14193 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14194 @cindex Operating System interface
14195 @cindex Spawn capability
14198 Provides a range of target independent operating system interface functions,
14199 including time/date management, file operations, subprocess management,
14200 including a portable spawn procedure, and access to environment variables
14201 and error return codes.
14203 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14204 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14205 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14206 @cindex Hash functions
14209 Provides a generator of static minimal perfect hash functions. No
14210 collisions occur and each item can be retrieved from the table in one
14211 probe (perfect property). The hash table size corresponds to the exact
14212 size of the key set and no larger (minimal property). The key set has to
14213 be know in advance (static property). The hash functions are also order
14214 preserving. If w2 is inserted after w1 in the generator, their
14215 hashcode are in the same order. These hashing functions are very
14216 convenient for use with realtime applications.
14218 @node GNAT.Random_Numbers (g-rannum.ads)
14219 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14220 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14221 @cindex Random number generation
14224 Provides random number capabilities which extend those available in the
14225 standard Ada library and are more convenient to use.
14227 @node GNAT.Regexp (g-regexp.ads)
14228 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14229 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14230 @cindex Regular expressions
14231 @cindex Pattern matching
14234 A simple implementation of regular expressions, using a subset of regular
14235 expression syntax copied from familiar Unix style utilities. This is the
14236 simples of the three pattern matching packages provided, and is particularly
14237 suitable for ``file globbing'' applications.
14239 @node GNAT.Registry (g-regist.ads)
14240 @section @code{GNAT.Registry} (@file{g-regist.ads})
14241 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14242 @cindex Windows Registry
14245 This is a high level binding to the Windows registry. It is possible to
14246 do simple things like reading a key value, creating a new key. For full
14247 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14248 package provided with the Win32Ada binding
14250 @node GNAT.Regpat (g-regpat.ads)
14251 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14252 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14253 @cindex Regular expressions
14254 @cindex Pattern matching
14257 A complete implementation of Unix-style regular expression matching, copied
14258 from the original V7 style regular expression library written in C by
14259 Henry Spencer (and binary compatible with this C library).
14261 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14262 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14263 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14264 @cindex Secondary Stack Info
14267 Provide the capability to query the high water mark of the current task's
14270 @node GNAT.Semaphores (g-semaph.ads)
14271 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14272 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14276 Provides classic counting and binary semaphores using protected types.
14278 @node GNAT.Serial_Communications (g-sercom.ads)
14279 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14280 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14281 @cindex Serial_Communications
14284 Provides a simple interface to send and receive data over a serial
14285 port. This is only supported on GNU/Linux and Windows.
14287 @node GNAT.SHA1 (g-sha1.ads)
14288 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14289 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14290 @cindex Secure Hash Algorithm SHA-1
14293 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14295 @node GNAT.Signals (g-signal.ads)
14296 @section @code{GNAT.Signals} (@file{g-signal.ads})
14297 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14301 Provides the ability to manipulate the blocked status of signals on supported
14304 @node GNAT.Sockets (g-socket.ads)
14305 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14306 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14310 A high level and portable interface to develop sockets based applications.
14311 This package is based on the sockets thin binding found in
14312 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14313 on all native GNAT ports except for OpenVMS@. It is not implemented
14314 for the LynxOS@ cross port.
14316 @node GNAT.Source_Info (g-souinf.ads)
14317 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14318 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14319 @cindex Source Information
14322 Provides subprograms that give access to source code information known at
14323 compile time, such as the current file name and line number.
14325 @node GNAT.Spelling_Checker (g-speche.ads)
14326 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14327 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14328 @cindex Spell checking
14331 Provides a function for determining whether one string is a plausible
14332 near misspelling of another string.
14334 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14335 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14336 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14337 @cindex Spell checking
14340 Provides a generic function that can be instantiated with a string type for
14341 determining whether one string is a plausible near misspelling of another
14344 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14345 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14346 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14347 @cindex SPITBOL pattern matching
14348 @cindex Pattern matching
14351 A complete implementation of SNOBOL4 style pattern matching. This is the
14352 most elaborate of the pattern matching packages provided. It fully duplicates
14353 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14354 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14356 @node GNAT.Spitbol (g-spitbo.ads)
14357 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14358 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14359 @cindex SPITBOL interface
14362 The top level package of the collection of SPITBOL-style functionality, this
14363 package provides basic SNOBOL4 string manipulation functions, such as
14364 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14365 useful for constructing arbitrary mappings from strings in the style of
14366 the SNOBOL4 TABLE function.
14368 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14369 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14370 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14371 @cindex Sets of strings
14372 @cindex SPITBOL Tables
14375 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14376 for type @code{Standard.Boolean}, giving an implementation of sets of
14379 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14380 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14381 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14382 @cindex Integer maps
14384 @cindex SPITBOL Tables
14387 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14388 for type @code{Standard.Integer}, giving an implementation of maps
14389 from string to integer values.
14391 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14392 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14393 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14394 @cindex String maps
14396 @cindex SPITBOL Tables
14399 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14400 a variable length string type, giving an implementation of general
14401 maps from strings to strings.
14403 @node GNAT.Strings (g-string.ads)
14404 @section @code{GNAT.Strings} (@file{g-string.ads})
14405 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14408 Common String access types and related subprograms. Basically it
14409 defines a string access and an array of string access types.
14411 @node GNAT.String_Split (g-strspl.ads)
14412 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14413 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14414 @cindex String splitter
14417 Useful string manipulation routines: given a set of separators, split
14418 a string wherever the separators appear, and provide direct access
14419 to the resulting slices. This package is instantiated from
14420 @code{GNAT.Array_Split}.
14422 @node GNAT.Table (g-table.ads)
14423 @section @code{GNAT.Table} (@file{g-table.ads})
14424 @cindex @code{GNAT.Table} (@file{g-table.ads})
14425 @cindex Table implementation
14426 @cindex Arrays, extendable
14429 A generic package providing a single dimension array abstraction where the
14430 length of the array can be dynamically modified.
14433 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14434 except that this package declares a single instance of the table type,
14435 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14436 used to define dynamic instances of the table.
14438 @node GNAT.Task_Lock (g-tasloc.ads)
14439 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14440 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14441 @cindex Task synchronization
14442 @cindex Task locking
14446 A very simple facility for locking and unlocking sections of code using a
14447 single global task lock. Appropriate for use in situations where contention
14448 between tasks is very rarely expected.
14450 @node GNAT.Time_Stamp (g-timsta.ads)
14451 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14452 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14454 @cindex Current time
14457 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14458 represents the current date and time in ISO 8601 format. This is a very simple
14459 routine with minimal code and there are no dependencies on any other unit.
14461 @node GNAT.Threads (g-thread.ads)
14462 @section @code{GNAT.Threads} (@file{g-thread.ads})
14463 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14464 @cindex Foreign threads
14465 @cindex Threads, foreign
14468 Provides facilities for dealing with foreign threads which need to be known
14469 by the GNAT run-time system. Consult the documentation of this package for
14470 further details if your program has threads that are created by a non-Ada
14471 environment which then accesses Ada code.
14473 @node GNAT.Traceback (g-traceb.ads)
14474 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14475 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14476 @cindex Trace back facilities
14479 Provides a facility for obtaining non-symbolic traceback information, useful
14480 in various debugging situations.
14482 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14483 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14484 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14485 @cindex Trace back facilities
14487 @node GNAT.UTF_32 (g-utf_32.ads)
14488 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14489 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14490 @cindex Wide character codes
14493 This is a package intended to be used in conjunction with the
14494 @code{Wide_Character} type in Ada 95 and the
14495 @code{Wide_Wide_Character} type in Ada 2005 (available
14496 in @code{GNAT} in Ada 2005 mode). This package contains
14497 Unicode categorization routines, as well as lexical
14498 categorization routines corresponding to the Ada 2005
14499 lexical rules for identifiers and strings, and also a
14500 lower case to upper case fold routine corresponding to
14501 the Ada 2005 rules for identifier equivalence.
14503 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14504 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14505 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14506 @cindex Spell checking
14509 Provides a function for determining whether one wide wide string is a plausible
14510 near misspelling of another wide wide string, where the strings are represented
14511 using the UTF_32_String type defined in System.Wch_Cnv.
14513 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14514 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14515 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14516 @cindex Spell checking
14519 Provides a function for determining whether one wide string is a plausible
14520 near misspelling of another wide string.
14522 @node GNAT.Wide_String_Split (g-wistsp.ads)
14523 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14524 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14525 @cindex Wide_String splitter
14528 Useful wide string manipulation routines: given a set of separators, split
14529 a wide string wherever the separators appear, and provide direct access
14530 to the resulting slices. This package is instantiated from
14531 @code{GNAT.Array_Split}.
14533 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14534 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14535 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14536 @cindex Spell checking
14539 Provides a function for determining whether one wide wide string is a plausible
14540 near misspelling of another wide wide string.
14542 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14543 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14544 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14545 @cindex Wide_Wide_String splitter
14548 Useful wide wide string manipulation routines: given a set of separators, split
14549 a wide wide string wherever the separators appear, and provide direct access
14550 to the resulting slices. This package is instantiated from
14551 @code{GNAT.Array_Split}.
14553 @node Interfaces.C.Extensions (i-cexten.ads)
14554 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14555 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14558 This package contains additional C-related definitions, intended
14559 for use with either manually or automatically generated bindings
14562 @node Interfaces.C.Streams (i-cstrea.ads)
14563 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14564 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14565 @cindex C streams, interfacing
14568 This package is a binding for the most commonly used operations
14571 @node Interfaces.CPP (i-cpp.ads)
14572 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14573 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14574 @cindex C++ interfacing
14575 @cindex Interfacing, to C++
14578 This package provides facilities for use in interfacing to C++. It
14579 is primarily intended to be used in connection with automated tools
14580 for the generation of C++ interfaces.
14582 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14583 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14584 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14585 @cindex IBM Packed Format
14586 @cindex Packed Decimal
14589 This package provides a set of routines for conversions to and
14590 from a packed decimal format compatible with that used on IBM
14593 @node Interfaces.VxWorks (i-vxwork.ads)
14594 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14595 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14596 @cindex Interfacing to VxWorks
14597 @cindex VxWorks, interfacing
14600 This package provides a limited binding to the VxWorks API.
14601 In particular, it interfaces with the
14602 VxWorks hardware interrupt facilities.
14604 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14605 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14606 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14607 @cindex Interfacing to VxWorks' I/O
14608 @cindex VxWorks, I/O interfacing
14609 @cindex VxWorks, Get_Immediate
14610 @cindex Get_Immediate, VxWorks
14613 This package provides a binding to the ioctl (IO/Control)
14614 function of VxWorks, defining a set of option values and
14615 function codes. A particular use of this package is
14616 to enable the use of Get_Immediate under VxWorks.
14618 @node System.Address_Image (s-addima.ads)
14619 @section @code{System.Address_Image} (@file{s-addima.ads})
14620 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14621 @cindex Address image
14622 @cindex Image, of an address
14625 This function provides a useful debugging
14626 function that gives an (implementation dependent)
14627 string which identifies an address.
14629 @node System.Assertions (s-assert.ads)
14630 @section @code{System.Assertions} (@file{s-assert.ads})
14631 @cindex @code{System.Assertions} (@file{s-assert.ads})
14633 @cindex Assert_Failure, exception
14636 This package provides the declaration of the exception raised
14637 by an run-time assertion failure, as well as the routine that
14638 is used internally to raise this assertion.
14640 @node System.Memory (s-memory.ads)
14641 @section @code{System.Memory} (@file{s-memory.ads})
14642 @cindex @code{System.Memory} (@file{s-memory.ads})
14643 @cindex Memory allocation
14646 This package provides the interface to the low level routines used
14647 by the generated code for allocation and freeing storage for the
14648 default storage pool (analogous to the C routines malloc and free.
14649 It also provides a reallocation interface analogous to the C routine
14650 realloc. The body of this unit may be modified to provide alternative
14651 allocation mechanisms for the default pool, and in addition, direct
14652 calls to this unit may be made for low level allocation uses (for
14653 example see the body of @code{GNAT.Tables}).
14655 @node System.Partition_Interface (s-parint.ads)
14656 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14657 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14658 @cindex Partition interfacing functions
14661 This package provides facilities for partition interfacing. It
14662 is used primarily in a distribution context when using Annex E
14665 @node System.Pool_Global (s-pooglo.ads)
14666 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14667 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14668 @cindex Storage pool, global
14669 @cindex Global storage pool
14672 This package provides a storage pool that is equivalent to the default
14673 storage pool used for access types for which no pool is specifically
14674 declared. It uses malloc/free to allocate/free and does not attempt to
14675 do any automatic reclamation.
14677 @node System.Pool_Local (s-pooloc.ads)
14678 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14679 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14680 @cindex Storage pool, local
14681 @cindex Local storage pool
14684 This package provides a storage pool that is intended for use with locally
14685 defined access types. It uses malloc/free for allocate/free, and maintains
14686 a list of allocated blocks, so that all storage allocated for the pool can
14687 be freed automatically when the pool is finalized.
14689 @node System.Restrictions (s-restri.ads)
14690 @section @code{System.Restrictions} (@file{s-restri.ads})
14691 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14692 @cindex Run-time restrictions access
14695 This package provides facilities for accessing at run time
14696 the status of restrictions specified at compile time for
14697 the partition. Information is available both with regard
14698 to actual restrictions specified, and with regard to
14699 compiler determined information on which restrictions
14700 are violated by one or more packages in the partition.
14702 @node System.Rident (s-rident.ads)
14703 @section @code{System.Rident} (@file{s-rident.ads})
14704 @cindex @code{System.Rident} (@file{s-rident.ads})
14705 @cindex Restrictions definitions
14708 This package provides definitions of the restrictions
14709 identifiers supported by GNAT, and also the format of
14710 the restrictions provided in package System.Restrictions.
14711 It is not normally necessary to @code{with} this generic package
14712 since the necessary instantiation is included in
14713 package System.Restrictions.
14715 @node System.Task_Info (s-tasinf.ads)
14716 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14717 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14718 @cindex Task_Info pragma
14721 This package provides target dependent functionality that is used
14722 to support the @code{Task_Info} pragma
14724 @node System.Wch_Cnv (s-wchcnv.ads)
14725 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14726 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14727 @cindex Wide Character, Representation
14728 @cindex Wide String, Conversion
14729 @cindex Representation of wide characters
14732 This package provides routines for converting between
14733 wide and wide wide characters and a representation as a value of type
14734 @code{Standard.String}, using a specified wide character
14735 encoding method. It uses definitions in
14736 package @code{System.Wch_Con}.
14738 @node System.Wch_Con (s-wchcon.ads)
14739 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14740 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14743 This package provides definitions and descriptions of
14744 the various methods used for encoding wide characters
14745 in ordinary strings. These definitions are used by
14746 the package @code{System.Wch_Cnv}.
14748 @node Interfacing to Other Languages
14749 @chapter Interfacing to Other Languages
14751 The facilities in annex B of the Ada Reference Manual are fully
14752 implemented in GNAT, and in addition, a full interface to C++ is
14756 * Interfacing to C::
14757 * Interfacing to C++::
14758 * Interfacing to COBOL::
14759 * Interfacing to Fortran::
14760 * Interfacing to non-GNAT Ada code::
14763 @node Interfacing to C
14764 @section Interfacing to C
14767 Interfacing to C with GNAT can use one of two approaches:
14771 The types in the package @code{Interfaces.C} may be used.
14773 Standard Ada types may be used directly. This may be less portable to
14774 other compilers, but will work on all GNAT compilers, which guarantee
14775 correspondence between the C and Ada types.
14779 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14780 effect, since this is the default. The following table shows the
14781 correspondence between Ada scalar types and the corresponding C types.
14786 @item Short_Integer
14788 @item Short_Short_Integer
14792 @item Long_Long_Integer
14800 @item Long_Long_Float
14801 This is the longest floating-point type supported by the hardware.
14805 Additionally, there are the following general correspondences between Ada
14809 Ada enumeration types map to C enumeration types directly if pragma
14810 @code{Convention C} is specified, which causes them to have int
14811 length. Without pragma @code{Convention C}, Ada enumeration types map to
14812 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14813 @code{int}, respectively) depending on the number of values passed.
14814 This is the only case in which pragma @code{Convention C} affects the
14815 representation of an Ada type.
14818 Ada access types map to C pointers, except for the case of pointers to
14819 unconstrained types in Ada, which have no direct C equivalent.
14822 Ada arrays map directly to C arrays.
14825 Ada records map directly to C structures.
14828 Packed Ada records map to C structures where all members are bit fields
14829 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14832 @node Interfacing to C++
14833 @section Interfacing to C++
14836 The interface to C++ makes use of the following pragmas, which are
14837 primarily intended to be constructed automatically using a binding generator
14838 tool, although it is possible to construct them by hand. No suitable binding
14839 generator tool is supplied with GNAT though.
14841 Using these pragmas it is possible to achieve complete
14842 inter-operability between Ada tagged types and C++ class definitions.
14843 See @ref{Implementation Defined Pragmas}, for more details.
14846 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
14847 The argument denotes an entity in the current declarative region that is
14848 declared as a tagged or untagged record type. It indicates that the type
14849 corresponds to an externally declared C++ class type, and is to be laid
14850 out the same way that C++ would lay out the type.
14852 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14853 for backward compatibility but its functionality is available
14854 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14856 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
14857 This pragma identifies an imported function (imported in the usual way
14858 with pragma @code{Import}) as corresponding to a C++ constructor.
14861 @node Interfacing to COBOL
14862 @section Interfacing to COBOL
14865 Interfacing to COBOL is achieved as described in section B.4 of
14866 the Ada Reference Manual.
14868 @node Interfacing to Fortran
14869 @section Interfacing to Fortran
14872 Interfacing to Fortran is achieved as described in section B.5 of the
14873 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
14874 multi-dimensional array causes the array to be stored in column-major
14875 order as required for convenient interface to Fortran.
14877 @node Interfacing to non-GNAT Ada code
14878 @section Interfacing to non-GNAT Ada code
14880 It is possible to specify the convention @code{Ada} in a pragma
14881 @code{Import} or pragma @code{Export}. However this refers to
14882 the calling conventions used by GNAT, which may or may not be
14883 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14884 compiler to allow interoperation.
14886 If arguments types are kept simple, and if the foreign compiler generally
14887 follows system calling conventions, then it may be possible to integrate
14888 files compiled by other Ada compilers, provided that the elaboration
14889 issues are adequately addressed (for example by eliminating the
14890 need for any load time elaboration).
14892 In particular, GNAT running on VMS is designed to
14893 be highly compatible with the DEC Ada 83 compiler, so this is one
14894 case in which it is possible to import foreign units of this type,
14895 provided that the data items passed are restricted to simple scalar
14896 values or simple record types without variants, or simple array
14897 types with fixed bounds.
14899 @node Specialized Needs Annexes
14900 @chapter Specialized Needs Annexes
14903 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14904 required in all implementations. However, as described in this chapter,
14905 GNAT implements all of these annexes:
14908 @item Systems Programming (Annex C)
14909 The Systems Programming Annex is fully implemented.
14911 @item Real-Time Systems (Annex D)
14912 The Real-Time Systems Annex is fully implemented.
14914 @item Distributed Systems (Annex E)
14915 Stub generation is fully implemented in the GNAT compiler. In addition,
14916 a complete compatible PCS is available as part of the GLADE system,
14917 a separate product. When the two
14918 products are used in conjunction, this annex is fully implemented.
14920 @item Information Systems (Annex F)
14921 The Information Systems annex is fully implemented.
14923 @item Numerics (Annex G)
14924 The Numerics Annex is fully implemented.
14926 @item Safety and Security / High-Integrity Systems (Annex H)
14927 The Safety and Security Annex (termed the High-Integrity Systems Annex
14928 in Ada 2005) is fully implemented.
14931 @node Implementation of Specific Ada Features
14932 @chapter Implementation of Specific Ada Features
14935 This chapter describes the GNAT implementation of several Ada language
14939 * Machine Code Insertions::
14940 * GNAT Implementation of Tasking::
14941 * GNAT Implementation of Shared Passive Packages::
14942 * Code Generation for Array Aggregates::
14943 * The Size of Discriminated Records with Default Discriminants::
14944 * Strict Conformance to the Ada Reference Manual::
14947 @node Machine Code Insertions
14948 @section Machine Code Insertions
14949 @cindex Machine Code insertions
14952 Package @code{Machine_Code} provides machine code support as described
14953 in the Ada Reference Manual in two separate forms:
14956 Machine code statements, consisting of qualified expressions that
14957 fit the requirements of RM section 13.8.
14959 An intrinsic callable procedure, providing an alternative mechanism of
14960 including machine instructions in a subprogram.
14964 The two features are similar, and both are closely related to the mechanism
14965 provided by the asm instruction in the GNU C compiler. Full understanding
14966 and use of the facilities in this package requires understanding the asm
14967 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
14968 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
14970 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14971 semantic restrictions and effects as described below. Both are provided so
14972 that the procedure call can be used as a statement, and the function call
14973 can be used to form a code_statement.
14975 The first example given in the GCC documentation is the C @code{asm}
14978 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14982 The equivalent can be written for GNAT as:
14984 @smallexample @c ada
14985 Asm ("fsinx %1 %0",
14986 My_Float'Asm_Output ("=f", result),
14987 My_Float'Asm_Input ("f", angle));
14991 The first argument to @code{Asm} is the assembler template, and is
14992 identical to what is used in GNU C@. This string must be a static
14993 expression. The second argument is the output operand list. It is
14994 either a single @code{Asm_Output} attribute reference, or a list of such
14995 references enclosed in parentheses (technically an array aggregate of
14998 The @code{Asm_Output} attribute denotes a function that takes two
14999 parameters. The first is a string, the second is the name of a variable
15000 of the type designated by the attribute prefix. The first (string)
15001 argument is required to be a static expression and designates the
15002 constraint for the parameter (e.g.@: what kind of register is
15003 required). The second argument is the variable to be updated with the
15004 result. The possible values for constraint are the same as those used in
15005 the RTL, and are dependent on the configuration file used to build the
15006 GCC back end. If there are no output operands, then this argument may
15007 either be omitted, or explicitly given as @code{No_Output_Operands}.
15009 The second argument of @code{@var{my_float}'Asm_Output} functions as
15010 though it were an @code{out} parameter, which is a little curious, but
15011 all names have the form of expressions, so there is no syntactic
15012 irregularity, even though normally functions would not be permitted
15013 @code{out} parameters. The third argument is the list of input
15014 operands. It is either a single @code{Asm_Input} attribute reference, or
15015 a list of such references enclosed in parentheses (technically an array
15016 aggregate of such references).
15018 The @code{Asm_Input} attribute denotes a function that takes two
15019 parameters. The first is a string, the second is an expression of the
15020 type designated by the prefix. The first (string) argument is required
15021 to be a static expression, and is the constraint for the parameter,
15022 (e.g.@: what kind of register is required). The second argument is the
15023 value to be used as the input argument. The possible values for the
15024 constant are the same as those used in the RTL, and are dependent on
15025 the configuration file used to built the GCC back end.
15027 If there are no input operands, this argument may either be omitted, or
15028 explicitly given as @code{No_Input_Operands}. The fourth argument, not
15029 present in the above example, is a list of register names, called the
15030 @dfn{clobber} argument. This argument, if given, must be a static string
15031 expression, and is a space or comma separated list of names of registers
15032 that must be considered destroyed as a result of the @code{Asm} call. If
15033 this argument is the null string (the default value), then the code
15034 generator assumes that no additional registers are destroyed.
15036 The fifth argument, not present in the above example, called the
15037 @dfn{volatile} argument, is by default @code{False}. It can be set to
15038 the literal value @code{True} to indicate to the code generator that all
15039 optimizations with respect to the instruction specified should be
15040 suppressed, and that in particular, for an instruction that has outputs,
15041 the instruction will still be generated, even if none of the outputs are
15042 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15043 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15044 Generally it is strongly advisable to use Volatile for any ASM statement
15045 that is missing either input or output operands, or when two or more ASM
15046 statements appear in sequence, to avoid unwanted optimizations. A warning
15047 is generated if this advice is not followed.
15049 The @code{Asm} subprograms may be used in two ways. First the procedure
15050 forms can be used anywhere a procedure call would be valid, and
15051 correspond to what the RM calls ``intrinsic'' routines. Such calls can
15052 be used to intersperse machine instructions with other Ada statements.
15053 Second, the function forms, which return a dummy value of the limited
15054 private type @code{Asm_Insn}, can be used in code statements, and indeed
15055 this is the only context where such calls are allowed. Code statements
15056 appear as aggregates of the form:
15058 @smallexample @c ada
15059 Asm_Insn'(Asm (@dots{}));
15060 Asm_Insn'(Asm_Volatile (@dots{}));
15064 In accordance with RM rules, such code statements are allowed only
15065 within subprograms whose entire body consists of such statements. It is
15066 not permissible to intermix such statements with other Ada statements.
15068 Typically the form using intrinsic procedure calls is more convenient
15069 and more flexible. The code statement form is provided to meet the RM
15070 suggestion that such a facility should be made available. The following
15071 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15072 is used, the arguments may be given in arbitrary order, following the
15073 normal rules for use of positional and named arguments)
15077 [Template =>] static_string_EXPRESSION
15078 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
15079 [,[Inputs =>] INPUT_OPERAND_LIST ]
15080 [,[Clobber =>] static_string_EXPRESSION ]
15081 [,[Volatile =>] static_boolean_EXPRESSION] )
15083 OUTPUT_OPERAND_LIST ::=
15084 [PREFIX.]No_Output_Operands
15085 | OUTPUT_OPERAND_ATTRIBUTE
15086 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15088 OUTPUT_OPERAND_ATTRIBUTE ::=
15089 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15091 INPUT_OPERAND_LIST ::=
15092 [PREFIX.]No_Input_Operands
15093 | INPUT_OPERAND_ATTRIBUTE
15094 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15096 INPUT_OPERAND_ATTRIBUTE ::=
15097 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15101 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15102 are declared in the package @code{Machine_Code} and must be referenced
15103 according to normal visibility rules. In particular if there is no
15104 @code{use} clause for this package, then appropriate package name
15105 qualification is required.
15107 @node GNAT Implementation of Tasking
15108 @section GNAT Implementation of Tasking
15111 This chapter outlines the basic GNAT approach to tasking (in particular,
15112 a multi-layered library for portability) and discusses issues related
15113 to compliance with the Real-Time Systems Annex.
15116 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15117 * Ensuring Compliance with the Real-Time Annex::
15120 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15121 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15124 GNAT's run-time support comprises two layers:
15127 @item GNARL (GNAT Run-time Layer)
15128 @item GNULL (GNAT Low-level Library)
15132 In GNAT, Ada's tasking services rely on a platform and OS independent
15133 layer known as GNARL@. This code is responsible for implementing the
15134 correct semantics of Ada's task creation, rendezvous, protected
15137 GNARL decomposes Ada's tasking semantics into simpler lower level
15138 operations such as create a thread, set the priority of a thread,
15139 yield, create a lock, lock/unlock, etc. The spec for these low-level
15140 operations constitutes GNULLI, the GNULL Interface. This interface is
15141 directly inspired from the POSIX real-time API@.
15143 If the underlying executive or OS implements the POSIX standard
15144 faithfully, the GNULL Interface maps as is to the services offered by
15145 the underlying kernel. Otherwise, some target dependent glue code maps
15146 the services offered by the underlying kernel to the semantics expected
15149 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15150 key point is that each Ada task is mapped on a thread in the underlying
15151 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
15153 In addition Ada task priorities map onto the underlying thread priorities.
15154 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15158 The underlying scheduler is used to schedule the Ada tasks. This
15159 makes Ada tasks as efficient as kernel threads from a scheduling
15163 Interaction with code written in C containing threads is eased
15164 since at the lowest level Ada tasks and C threads map onto the same
15165 underlying kernel concept.
15168 When an Ada task is blocked during I/O the remaining Ada tasks are
15172 On multiprocessor systems Ada tasks can execute in parallel.
15176 Some threads libraries offer a mechanism to fork a new process, with the
15177 child process duplicating the threads from the parent.
15179 support this functionality when the parent contains more than one task.
15180 @cindex Forking a new process
15182 @node Ensuring Compliance with the Real-Time Annex
15183 @subsection Ensuring Compliance with the Real-Time Annex
15184 @cindex Real-Time Systems Annex compliance
15187 Although mapping Ada tasks onto
15188 the underlying threads has significant advantages, it does create some
15189 complications when it comes to respecting the scheduling semantics
15190 specified in the real-time annex (Annex D).
15192 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15193 scheduling policy states:
15196 @emph{When the active priority of a ready task that is not running
15197 changes, or the setting of its base priority takes effect, the
15198 task is removed from the ready queue for its old active priority
15199 and is added at the tail of the ready queue for its new active
15200 priority, except in the case where the active priority is lowered
15201 due to the loss of inherited priority, in which case the task is
15202 added at the head of the ready queue for its new active priority.}
15206 While most kernels do put tasks at the end of the priority queue when
15207 a task changes its priority, (which respects the main
15208 FIFO_Within_Priorities requirement), almost none keep a thread at the
15209 beginning of its priority queue when its priority drops from the loss
15210 of inherited priority.
15212 As a result most vendors have provided incomplete Annex D implementations.
15214 The GNAT run-time, has a nice cooperative solution to this problem
15215 which ensures that accurate FIFO_Within_Priorities semantics are
15218 The principle is as follows. When an Ada task T is about to start
15219 running, it checks whether some other Ada task R with the same
15220 priority as T has been suspended due to the loss of priority
15221 inheritance. If this is the case, T yields and is placed at the end of
15222 its priority queue. When R arrives at the front of the queue it
15225 Note that this simple scheme preserves the relative order of the tasks
15226 that were ready to execute in the priority queue where R has been
15229 @node GNAT Implementation of Shared Passive Packages
15230 @section GNAT Implementation of Shared Passive Packages
15231 @cindex Shared passive packages
15234 GNAT fully implements the pragma @code{Shared_Passive} for
15235 @cindex pragma @code{Shared_Passive}
15236 the purpose of designating shared passive packages.
15237 This allows the use of passive partitions in the
15238 context described in the Ada Reference Manual; i.e., for communication
15239 between separate partitions of a distributed application using the
15240 features in Annex E.
15242 @cindex Distribution Systems Annex
15244 However, the implementation approach used by GNAT provides for more
15245 extensive usage as follows:
15248 @item Communication between separate programs
15250 This allows separate programs to access the data in passive
15251 partitions, using protected objects for synchronization where
15252 needed. The only requirement is that the two programs have a
15253 common shared file system. It is even possible for programs
15254 running on different machines with different architectures
15255 (e.g.@: different endianness) to communicate via the data in
15256 a passive partition.
15258 @item Persistence between program runs
15260 The data in a passive package can persist from one run of a
15261 program to another, so that a later program sees the final
15262 values stored by a previous run of the same program.
15267 The implementation approach used is to store the data in files. A
15268 separate stream file is created for each object in the package, and
15269 an access to an object causes the corresponding file to be read or
15272 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15273 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15274 set to the directory to be used for these files.
15275 The files in this directory
15276 have names that correspond to their fully qualified names. For
15277 example, if we have the package
15279 @smallexample @c ada
15281 pragma Shared_Passive (X);
15288 and the environment variable is set to @code{/stemp/}, then the files created
15289 will have the names:
15297 These files are created when a value is initially written to the object, and
15298 the files are retained until manually deleted. This provides the persistence
15299 semantics. If no file exists, it means that no partition has assigned a value
15300 to the variable; in this case the initial value declared in the package
15301 will be used. This model ensures that there are no issues in synchronizing
15302 the elaboration process, since elaboration of passive packages elaborates the
15303 initial values, but does not create the files.
15305 The files are written using normal @code{Stream_IO} access.
15306 If you want to be able
15307 to communicate between programs or partitions running on different
15308 architectures, then you should use the XDR versions of the stream attribute
15309 routines, since these are architecture independent.
15311 If active synchronization is required for access to the variables in the
15312 shared passive package, then as described in the Ada Reference Manual, the
15313 package may contain protected objects used for this purpose. In this case
15314 a lock file (whose name is @file{___lock} (three underscores)
15315 is created in the shared memory directory.
15316 @cindex @file{___lock} file (for shared passive packages)
15317 This is used to provide the required locking
15318 semantics for proper protected object synchronization.
15320 As of January 2003, GNAT supports shared passive packages on all platforms
15321 except for OpenVMS.
15323 @node Code Generation for Array Aggregates
15324 @section Code Generation for Array Aggregates
15327 * Static constant aggregates with static bounds::
15328 * Constant aggregates with unconstrained nominal types::
15329 * Aggregates with static bounds::
15330 * Aggregates with non-static bounds::
15331 * Aggregates in assignment statements::
15335 Aggregates have a rich syntax and allow the user to specify the values of
15336 complex data structures by means of a single construct. As a result, the
15337 code generated for aggregates can be quite complex and involve loops, case
15338 statements and multiple assignments. In the simplest cases, however, the
15339 compiler will recognize aggregates whose components and constraints are
15340 fully static, and in those cases the compiler will generate little or no
15341 executable code. The following is an outline of the code that GNAT generates
15342 for various aggregate constructs. For further details, you will find it
15343 useful to examine the output produced by the -gnatG flag to see the expanded
15344 source that is input to the code generator. You may also want to examine
15345 the assembly code generated at various levels of optimization.
15347 The code generated for aggregates depends on the context, the component values,
15348 and the type. In the context of an object declaration the code generated is
15349 generally simpler than in the case of an assignment. As a general rule, static
15350 component values and static subtypes also lead to simpler code.
15352 @node Static constant aggregates with static bounds
15353 @subsection Static constant aggregates with static bounds
15356 For the declarations:
15357 @smallexample @c ada
15358 type One_Dim is array (1..10) of integer;
15359 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15363 GNAT generates no executable code: the constant ar0 is placed in static memory.
15364 The same is true for constant aggregates with named associations:
15366 @smallexample @c ada
15367 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15368 Cr3 : constant One_Dim := (others => 7777);
15372 The same is true for multidimensional constant arrays such as:
15374 @smallexample @c ada
15375 type two_dim is array (1..3, 1..3) of integer;
15376 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15380 The same is true for arrays of one-dimensional arrays: the following are
15383 @smallexample @c ada
15384 type ar1b is array (1..3) of boolean;
15385 type ar_ar is array (1..3) of ar1b;
15386 None : constant ar1b := (others => false); -- fully static
15387 None2 : constant ar_ar := (1..3 => None); -- fully static
15391 However, for multidimensional aggregates with named associations, GNAT will
15392 generate assignments and loops, even if all associations are static. The
15393 following two declarations generate a loop for the first dimension, and
15394 individual component assignments for the second dimension:
15396 @smallexample @c ada
15397 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15398 Zero2: constant two_dim := (others => (others => 0));
15401 @node Constant aggregates with unconstrained nominal types
15402 @subsection Constant aggregates with unconstrained nominal types
15405 In such cases the aggregate itself establishes the subtype, so that
15406 associations with @code{others} cannot be used. GNAT determines the
15407 bounds for the actual subtype of the aggregate, and allocates the
15408 aggregate statically as well. No code is generated for the following:
15410 @smallexample @c ada
15411 type One_Unc is array (natural range <>) of integer;
15412 Cr_Unc : constant One_Unc := (12,24,36);
15415 @node Aggregates with static bounds
15416 @subsection Aggregates with static bounds
15419 In all previous examples the aggregate was the initial (and immutable) value
15420 of a constant. If the aggregate initializes a variable, then code is generated
15421 for it as a combination of individual assignments and loops over the target
15422 object. The declarations
15424 @smallexample @c ada
15425 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15426 Cr_Var2 : One_Dim := (others > -1);
15430 generate the equivalent of
15432 @smallexample @c ada
15438 for I in Cr_Var2'range loop
15443 @node Aggregates with non-static bounds
15444 @subsection Aggregates with non-static bounds
15447 If the bounds of the aggregate are not statically compatible with the bounds
15448 of the nominal subtype of the target, then constraint checks have to be
15449 generated on the bounds. For a multidimensional array, constraint checks may
15450 have to be applied to sub-arrays individually, if they do not have statically
15451 compatible subtypes.
15453 @node Aggregates in assignment statements
15454 @subsection Aggregates in assignment statements
15457 In general, aggregate assignment requires the construction of a temporary,
15458 and a copy from the temporary to the target of the assignment. This is because
15459 it is not always possible to convert the assignment into a series of individual
15460 component assignments. For example, consider the simple case:
15462 @smallexample @c ada
15467 This cannot be converted into:
15469 @smallexample @c ada
15475 So the aggregate has to be built first in a separate location, and then
15476 copied into the target. GNAT recognizes simple cases where this intermediate
15477 step is not required, and the assignments can be performed in place, directly
15478 into the target. The following sufficient criteria are applied:
15482 The bounds of the aggregate are static, and the associations are static.
15484 The components of the aggregate are static constants, names of
15485 simple variables that are not renamings, or expressions not involving
15486 indexed components whose operands obey these rules.
15490 If any of these conditions are violated, the aggregate will be built in
15491 a temporary (created either by the front-end or the code generator) and then
15492 that temporary will be copied onto the target.
15495 @node The Size of Discriminated Records with Default Discriminants
15496 @section The Size of Discriminated Records with Default Discriminants
15499 If a discriminated type @code{T} has discriminants with default values, it is
15500 possible to declare an object of this type without providing an explicit
15503 @smallexample @c ada
15505 type Size is range 1..100;
15507 type Rec (D : Size := 15) is record
15508 Name : String (1..D);
15516 Such an object is said to be @emph{unconstrained}.
15517 The discriminant of the object
15518 can be modified by a full assignment to the object, as long as it preserves the
15519 relation between the value of the discriminant, and the value of the components
15522 @smallexample @c ada
15524 Word := (3, "yes");
15526 Word := (5, "maybe");
15528 Word := (5, "no"); -- raises Constraint_Error
15533 In order to support this behavior efficiently, an unconstrained object is
15534 given the maximum size that any value of the type requires. In the case
15535 above, @code{Word} has storage for the discriminant and for
15536 a @code{String} of length 100.
15537 It is important to note that unconstrained objects do not require dynamic
15538 allocation. It would be an improper implementation to place on the heap those
15539 components whose size depends on discriminants. (This improper implementation
15540 was used by some Ada83 compilers, where the @code{Name} component above
15542 been stored as a pointer to a dynamic string). Following the principle that
15543 dynamic storage management should never be introduced implicitly,
15544 an Ada compiler should reserve the full size for an unconstrained declared
15545 object, and place it on the stack.
15547 This maximum size approach
15548 has been a source of surprise to some users, who expect the default
15549 values of the discriminants to determine the size reserved for an
15550 unconstrained object: ``If the default is 15, why should the object occupy
15552 The answer, of course, is that the discriminant may be later modified,
15553 and its full range of values must be taken into account. This is why the
15558 type Rec (D : Positive := 15) is record
15559 Name : String (1..D);
15567 is flagged by the compiler with a warning:
15568 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15569 because the required size includes @code{Positive'Last}
15570 bytes. As the first example indicates, the proper approach is to declare an
15571 index type of ``reasonable'' range so that unconstrained objects are not too
15574 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15575 created in the heap by means of an allocator, then it is @emph{not}
15577 it is constrained by the default values of the discriminants, and those values
15578 cannot be modified by full assignment. This is because in the presence of
15579 aliasing all views of the object (which may be manipulated by different tasks,
15580 say) must be consistent, so it is imperative that the object, once created,
15583 @node Strict Conformance to the Ada Reference Manual
15584 @section Strict Conformance to the Ada Reference Manual
15587 The dynamic semantics defined by the Ada Reference Manual impose a set of
15588 run-time checks to be generated. By default, the GNAT compiler will insert many
15589 run-time checks into the compiled code, including most of those required by the
15590 Ada Reference Manual. However, there are three checks that are not enabled
15591 in the default mode for efficiency reasons: arithmetic overflow checking for
15592 integer operations (including division by zero), checks for access before
15593 elaboration on subprogram calls, and stack overflow checking (most operating
15594 systems do not perform this check by default).
15596 Strict conformance to the Ada Reference Manual can be achieved by adding
15597 three compiler options for overflow checking for integer operations
15598 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15599 calls and generic instantiations (@option{-gnatE}), and stack overflow
15600 checking (@option{-fstack-check}).
15602 Note that the result of a floating point arithmetic operation in overflow and
15603 invalid situations, when the @code{Machine_Overflows} attribute of the result
15604 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15605 case for machines compliant with the IEEE floating-point standard, but on
15606 machines that are not fully compliant with this standard, such as Alpha, the
15607 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15608 behavior (although at the cost of a significant performance penalty), so
15609 infinite and and NaN values are properly generated.
15612 @node Project File Reference
15613 @chapter Project File Reference
15616 This chapter describes the syntax and semantics of project files.
15617 Project files specify the options to be used when building a system.
15618 Project files can specify global settings for all tools,
15619 as well as tool-specific settings.
15620 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15621 for examples of use.
15625 * Lexical Elements::
15627 * Empty declarations::
15628 * Typed string declarations::
15632 * Project Attributes::
15633 * Attribute References::
15634 * External Values::
15635 * Case Construction::
15637 * Package Renamings::
15639 * Project Extensions::
15640 * Project File Elaboration::
15643 @node Reserved Words
15644 @section Reserved Words
15647 All Ada reserved words are reserved in project files, and cannot be used
15648 as variable names or project names. In addition, the following are
15649 also reserved in project files:
15652 @item @code{extends}
15654 @item @code{external}
15656 @item @code{project}
15660 @node Lexical Elements
15661 @section Lexical Elements
15664 Rules for identifiers are the same as in Ada. Identifiers
15665 are case-insensitive. Strings are case sensitive, except where noted.
15666 Comments have the same form as in Ada.
15676 simple_name @{. simple_name@}
15680 @section Declarations
15683 Declarations introduce new entities that denote types, variables, attributes,
15684 and packages. Some declarations can only appear immediately within a project
15685 declaration. Others can appear within a project or within a package.
15689 declarative_item ::=
15690 simple_declarative_item |
15691 typed_string_declaration |
15692 package_declaration
15694 simple_declarative_item ::=
15695 variable_declaration |
15696 typed_variable_declaration |
15697 attribute_declaration |
15698 case_construction |
15702 @node Empty declarations
15703 @section Empty declarations
15706 empty_declaration ::=
15710 An empty declaration is allowed anywhere a declaration is allowed.
15713 @node Typed string declarations
15714 @section Typed string declarations
15717 Typed strings are sequences of string literals. Typed strings are the only
15718 named types in project files. They are used in case constructions, where they
15719 provide support for conditional attribute definitions.
15723 typed_string_declaration ::=
15724 @b{type} <typed_string_>_simple_name @b{is}
15725 ( string_literal @{, string_literal@} );
15729 A typed string declaration can only appear immediately within a project
15732 All the string literals in a typed string declaration must be distinct.
15738 Variables denote values, and appear as constituents of expressions.
15741 typed_variable_declaration ::=
15742 <typed_variable_>simple_name : <typed_string_>name := string_expression ;
15744 variable_declaration ::=
15745 <variable_>simple_name := expression;
15749 The elaboration of a variable declaration introduces the variable and
15750 assigns to it the value of the expression. The name of the variable is
15751 available after the assignment symbol.
15754 A typed_variable can only be declare once.
15757 a non-typed variable can be declared multiple times.
15760 Before the completion of its first declaration, the value of variable
15761 is the null string.
15764 @section Expressions
15767 An expression is a formula that defines a computation or retrieval of a value.
15768 In a project file the value of an expression is either a string or a list
15769 of strings. A string value in an expression is either a literal, the current
15770 value of a variable, an external value, an attribute reference, or a
15771 concatenation operation.
15784 attribute_reference
15790 ( <string_>expression @{ , <string_>expression @} )
15793 @subsection Concatenation
15795 The following concatenation functions are defined:
15797 @smallexample @c ada
15798 function "&" (X : String; Y : String) return String;
15799 function "&" (X : String_List; Y : String) return String_List;
15800 function "&" (X : String_List; Y : String_List) return String_List;
15804 @section Attributes
15807 An attribute declaration defines a property of a project or package. This
15808 property can later be queried by means of an attribute reference.
15809 Attribute values are strings or string lists.
15811 Some attributes are associative arrays. These attributes are mappings whose
15812 domain is a set of strings. These attributes are declared one association
15813 at a time, by specifying a point in the domain and the corresponding image
15814 of the attribute. They may also be declared as a full associative array,
15815 getting the same associations as the corresponding attribute in an imported
15816 or extended project.
15818 Attributes that are not associative arrays are called simple attributes.
15822 attribute_declaration ::=
15823 full_associative_array_declaration |
15824 @b{for} attribute_designator @b{use} expression ;
15826 full_associative_array_declaration ::=
15827 @b{for} <associative_array_attribute_>simple_name @b{use}
15828 <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15830 attribute_designator ::=
15831 <simple_attribute_>simple_name |
15832 <associative_array_attribute_>simple_name ( string_literal )
15836 Some attributes are project-specific, and can only appear immediately within
15837 a project declaration. Others are package-specific, and can only appear within
15838 the proper package.
15840 The expression in an attribute definition must be a string or a string_list.
15841 The string literal appearing in the attribute_designator of an associative
15842 array attribute is case-insensitive.
15844 @node Project Attributes
15845 @section Project Attributes
15848 The following attributes apply to a project. All of them are simple
15853 Expression must be a path name. The attribute defines the
15854 directory in which the object files created by the build are to be placed. If
15855 not specified, object files are placed in the project directory.
15858 Expression must be a path name. The attribute defines the
15859 directory in which the executables created by the build are to be placed.
15860 If not specified, executables are placed in the object directory.
15863 Expression must be a list of path names. The attribute
15864 defines the directories in which the source files for the project are to be
15865 found. If not specified, source files are found in the project directory.
15866 If a string in the list ends with "/**", then the directory that precedes
15867 "/**" and all of its subdirectories (recursively) are included in the list
15868 of source directories.
15870 @item Excluded_Source_Dirs
15871 Expression must be a list of strings. Each entry designates a directory that
15872 is not to be included in the list of source directories of the project.
15873 This is normally used when there are strings ending with "/**" in the value
15874 of attribute Source_Dirs.
15877 Expression must be a list of file names. The attribute
15878 defines the individual files, in the project directory, which are to be used
15879 as sources for the project. File names are path_names that contain no directory
15880 information. If the project has no sources the attribute must be declared
15881 explicitly with an empty list.
15883 @item Excluded_Source_Files (Locally_Removed_Files)
15884 Expression must be a list of strings that are legal file names.
15885 Each file name must designate a source that would normally be a source file
15886 in the source directories of the project or, if the project file is an
15887 extending project file, inherited by the current project file. It cannot
15888 designate an immediate source that is not inherited. Each of the source files
15889 in the list are not considered to be sources of the project file: they are not
15890 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15891 Excluded_Source_Files is preferred.
15893 @item Source_List_File
15894 Expression must a single path name. The attribute
15895 defines a text file that contains a list of source file names to be used
15896 as sources for the project
15899 Expression must be a path name. The attribute defines the
15900 directory in which a library is to be built. The directory must exist, must
15901 be distinct from the project's object directory, and must be writable.
15904 Expression must be a string that is a legal file name,
15905 without extension. The attribute defines a string that is used to generate
15906 the name of the library to be built by the project.
15909 Argument must be a string value that must be one of the
15910 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15911 string is case-insensitive. If this attribute is not specified, the library is
15912 a static library. Otherwise, the library may be dynamic or relocatable. This
15913 distinction is operating-system dependent.
15915 @item Library_Version
15916 Expression must be a string value whose interpretation
15917 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15918 libraries as the internal name of the library (the @code{"soname"}). If the
15919 library file name (built from the @code{Library_Name}) is different from the
15920 @code{Library_Version}, then the library file will be a symbolic link to the
15921 actual file whose name will be @code{Library_Version}.
15923 @item Library_Interface
15924 Expression must be a string list. Each element of the string list
15925 must designate a unit of the project.
15926 If this attribute is present in a Library Project File, then the project
15927 file is a Stand-alone Library_Project_File.
15929 @item Library_Auto_Init
15930 Expression must be a single string "true" or "false", case-insensitive.
15931 If this attribute is present in a Stand-alone Library Project File,
15932 it indicates if initialization is automatic when the dynamic library
15935 @item Library_Options
15936 Expression must be a string list. Indicates additional switches that
15937 are to be used when building a shared library.
15940 Expression must be a single string. Designates an alternative to "gcc"
15941 for building shared libraries.
15943 @item Library_Src_Dir
15944 Expression must be a path name. The attribute defines the
15945 directory in which the sources of the interfaces of a Stand-alone Library will
15946 be copied. The directory must exist, must be distinct from the project's
15947 object directory and source directories of all projects in the project tree,
15948 and must be writable.
15950 @item Library_Src_Dir
15951 Expression must be a path name. The attribute defines the
15952 directory in which the ALI files of a Library will
15953 be copied. The directory must exist, must be distinct from the project's
15954 object directory and source directories of all projects in the project tree,
15955 and must be writable.
15957 @item Library_Symbol_File
15958 Expression must be a single string. Its value is the single file name of a
15959 symbol file to be created when building a stand-alone library when the
15960 symbol policy is either "compliant", "controlled" or "restricted",
15961 on platforms that support symbol control, such as VMS. When symbol policy
15962 is "direct", then a file with this name must exist in the object directory.
15964 @item Library_Reference_Symbol_File
15965 Expression must be a single string. Its value is the path name of a
15966 reference symbol file that is read when the symbol policy is either
15967 "compliant" or "controlled", on platforms that support symbol control,
15968 such as VMS, when building a stand-alone library. The path may be an absolute
15969 path or a path relative to the project directory.
15971 @item Library_Symbol_Policy
15972 Expression must be a single string. Its case-insensitive value can only be
15973 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15975 This attribute is not taken into account on all platforms. It controls the
15976 policy for exported symbols and, on some platforms (like VMS) that have the
15977 notions of major and minor IDs built in the library files, it controls
15978 the setting of these IDs.
15980 "autonomous" or "default": exported symbols are not controlled.
15982 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15983 it is equivalent to policy "autonomous". If there are exported symbols in
15984 the reference symbol file that are not in the object files of the interfaces,
15985 the major ID of the library is increased. If there are symbols in the
15986 object files of the interfaces that are not in the reference symbol file,
15987 these symbols are put at the end of the list in the newly created symbol file
15988 and the minor ID is increased.
15990 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15991 The library will fail to build if the exported symbols in the object files of
15992 the interfaces do not match exactly the symbol in the symbol file.
15994 "restricted": The attribute Library_Symbol_File must be defined. The library
15995 will fail to build if there are symbols in the symbol file that are not in
15996 the exported symbols of the object files of the interfaces. Additional symbols
15997 in the object files are not added to the symbol file.
15999 "direct": The attribute Library_Symbol_File must be defined and must designate
16000 an existing file in the object directory. This symbol file is passed directly
16001 to the underlying linker without any symbol processing.
16004 Expression must be a list of strings that are legal file names.
16005 These file names designate existing compilation units in the source directory
16006 that are legal main subprograms.
16008 When a project file is elaborated, as part of the execution of a gnatmake
16009 command, one or several executables are built and placed in the Exec_Dir.
16010 If the gnatmake command does not include explicit file names, the executables
16011 that are built correspond to the files specified by this attribute.
16013 @item Externally_Built
16014 Expression must be a single string. Its value must be either "true" of "false",
16015 case-insensitive. The default is "false". When the value of this attribute is
16016 "true", no attempt is made to compile the sources or to build the library,
16017 when the project is a library project.
16019 @item Main_Language
16020 This is a simple attribute. Its value is a string that specifies the
16021 language of the main program.
16024 Expression must be a string list. Each string designates
16025 a programming language that is known to GNAT. The strings are case-insensitive.
16029 @node Attribute References
16030 @section Attribute References
16033 Attribute references are used to retrieve the value of previously defined
16034 attribute for a package or project.
16037 attribute_reference ::=
16038 attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16040 attribute_prefix ::=
16042 <project_simple_name | package_identifier |
16043 <project_>simple_name . package_identifier
16047 If an attribute has not been specified for a given package or project, its
16048 value is the null string or the empty list.
16050 @node External Values
16051 @section External Values
16054 An external value is an expression whose value is obtained from the command
16055 that invoked the processing of the current project file (typically a
16061 @b{external} ( string_literal [, string_literal] )
16065 The first string_literal is the string to be used on the command line or
16066 in the environment to specify the external value. The second string_literal,
16067 if present, is the default to use if there is no specification for this
16068 external value either on the command line or in the environment.
16070 @node Case Construction
16071 @section Case Construction
16074 A case construction supports attribute and variable declarations that depend
16075 on the value of a previously declared variable.
16079 case_construction ::=
16080 @b{case} <typed_variable_>name @b{is}
16085 @b{when} discrete_choice_list =>
16086 @{case_construction |
16087 attribute_declaration |
16088 variable_declaration |
16089 empty_declaration@}
16091 discrete_choice_list ::=
16092 string_literal @{| string_literal@} |
16097 Inside a case construction, variable declarations must be for variables that
16098 have already been declared before the case construction.
16100 All choices in a choice list must be distinct. The choice lists of two
16101 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16102 alternatives do not need to include all values of the type. An @code{others}
16103 choice must appear last in the list of alternatives.
16109 A package provides a grouping of variable declarations and attribute
16110 declarations to be used when invoking various GNAT tools. The name of
16111 the package indicates the tool(s) to which it applies.
16115 package_declaration ::=
16116 package_spec | package_renaming
16119 @b{package} package_identifier @b{is}
16120 @{simple_declarative_item@}
16121 @b{end} package_identifier ;
16123 package_identifier ::=
16124 @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16125 @code{Linker} | @code{Finder} | @code{Cross_Reference} |
16126 @code{gnatls} | @code{IDE} | @code{Pretty_Printer}
16129 @subsection Package Naming
16132 The attributes of a @code{Naming} package specifies the naming conventions
16133 that apply to the source files in a project. When invoking other GNAT tools,
16134 they will use the sources in the source directories that satisfy these
16135 naming conventions.
16137 The following attributes apply to a @code{Naming} package:
16141 This is a simple attribute whose value is a string. Legal values of this
16142 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16143 These strings are themselves case insensitive.
16146 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16148 @item Dot_Replacement
16149 This is a simple attribute whose string value satisfies the following
16153 @item It must not be empty
16154 @item It cannot start or end with an alphanumeric character
16155 @item It cannot be a single underscore
16156 @item It cannot start with an underscore followed by an alphanumeric
16157 @item It cannot contain a dot @code{'.'} if longer than one character
16161 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16164 This is an associative array attribute, defined on language names,
16165 whose image is a string that must satisfy the following
16169 @item It must not be empty
16170 @item It cannot start with an alphanumeric character
16171 @item It cannot start with an underscore followed by an alphanumeric character
16175 For Ada, the attribute denotes the suffix used in file names that contain
16176 library unit declarations, that is to say units that are package and
16177 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16178 specified, then the default is @code{".ads"}.
16180 For C and C++, the attribute denotes the suffix used in file names that
16181 contain prototypes.
16184 This is an associative array attribute defined on language names,
16185 whose image is a string that must satisfy the following
16189 @item It must not be empty
16190 @item It cannot start with an alphanumeric character
16191 @item It cannot start with an underscore followed by an alphanumeric character
16192 @item It cannot be a suffix of @code{Spec_Suffix}
16196 For Ada, the attribute denotes the suffix used in file names that contain
16197 library bodies, that is to say units that are package and subprogram bodies.
16198 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16201 For C and C++, the attribute denotes the suffix used in file names that contain
16204 @item Separate_Suffix
16205 This is a simple attribute whose value satisfies the same conditions as
16206 @code{Body_Suffix}.
16208 This attribute is specific to Ada. It denotes the suffix used in file names
16209 that contain separate bodies. If it is not specified, then it defaults to same
16210 value as @code{Body_Suffix ("Ada")}.
16213 This is an associative array attribute, specific to Ada, defined over
16214 compilation unit names. The image is a string that is the name of the file
16215 that contains that library unit. The file name is case sensitive if the
16216 conventions of the host operating system require it.
16219 This is an associative array attribute, specific to Ada, defined over
16220 compilation unit names. The image is a string that is the name of the file
16221 that contains the library unit body for the named unit. The file name is case
16222 sensitive if the conventions of the host operating system require it.
16224 @item Specification_Exceptions
16225 This is an associative array attribute defined on language names,
16226 whose value is a list of strings.
16228 This attribute is not significant for Ada.
16230 For C and C++, each string in the list denotes the name of a file that
16231 contains prototypes, but whose suffix is not necessarily the
16232 @code{Spec_Suffix} for the language.
16234 @item Implementation_Exceptions
16235 This is an associative array attribute defined on language names,
16236 whose value is a list of strings.
16238 This attribute is not significant for Ada.
16240 For C and C++, each string in the list denotes the name of a file that
16241 contains source code, but whose suffix is not necessarily the
16242 @code{Body_Suffix} for the language.
16245 The following attributes of package @code{Naming} are obsolescent. They are
16246 kept as synonyms of other attributes for compatibility with previous versions
16247 of the Project Manager.
16250 @item Specification_Suffix
16251 This is a synonym of @code{Spec_Suffix}.
16253 @item Implementation_Suffix
16254 This is a synonym of @code{Body_Suffix}.
16256 @item Specification
16257 This is a synonym of @code{Spec}.
16259 @item Implementation
16260 This is a synonym of @code{Body}.
16263 @subsection package Compiler
16266 The attributes of the @code{Compiler} package specify the compilation options
16267 to be used by the underlying compiler.
16270 @item Default_Switches
16271 This is an associative array attribute. Its
16272 domain is a set of language names. Its range is a string list that
16273 specifies the compilation options to be used when compiling a component
16274 written in that language, for which no file-specific switches have been
16278 This is an associative array attribute. Its domain is
16279 a set of file names. Its range is a string list that specifies the
16280 compilation options to be used when compiling the named file. If a file
16281 is not specified in the Switches attribute, it is compiled with the
16282 options specified by Default_Switches of its language, if defined.
16284 @item Local_Configuration_Pragmas.
16285 This is a simple attribute, whose
16286 value is a path name that designates a file containing configuration pragmas
16287 to be used for all invocations of the compiler for immediate sources of the
16291 @subsection package Builder
16294 The attributes of package @code{Builder} specify the compilation, binding, and
16295 linking options to be used when building an executable for a project. The
16296 following attributes apply to package @code{Builder}:
16299 @item Default_Switches
16300 This is an associative array attribute. Its
16301 domain is a set of language names. Its range is a string list that
16302 specifies options to be used when building a main
16303 written in that language, for which no file-specific switches have been
16307 This is an associative array attribute. Its domain is
16308 a set of file names. Its range is a string list that specifies
16309 options to be used when building the named main file. If a main file
16310 is not specified in the Switches attribute, it is built with the
16311 options specified by Default_Switches of its language, if defined.
16313 @item Global_Configuration_Pragmas
16314 This is a simple attribute, whose
16315 value is a path name that designates a file that contains configuration pragmas
16316 to be used in every build of an executable. If both local and global
16317 configuration pragmas are specified, a compilation makes use of both sets.
16321 This is an associative array attribute. Its domain is
16322 a set of main source file names. Its range is a simple string that specifies
16323 the executable file name to be used when linking the specified main source.
16324 If a main source is not specified in the Executable attribute, the executable
16325 file name is deducted from the main source file name.
16326 This attribute has no effect if its value is the empty string.
16328 @item Executable_Suffix
16329 This is a simple attribute whose value is the suffix to be added to
16330 the executables that don't have an attribute Executable specified.
16333 @subsection package Gnatls
16336 The attributes of package @code{Gnatls} specify the tool options to be used
16337 when invoking the library browser @command{gnatls}.
16338 The following attributes apply to package @code{Gnatls}:
16342 This is a single attribute with a string list value. Each nonempty string
16343 in the list is an option when invoking @code{gnatls}.
16346 @subsection package Binder
16349 The attributes of package @code{Binder} specify the options to be used
16350 when invoking the binder in the construction of an executable.
16351 The following attributes apply to package @code{Binder}:
16354 @item Default_Switches
16355 This is an associative array attribute. Its
16356 domain is a set of language names. Its range is a string list that
16357 specifies options to be used when binding a main
16358 written in that language, for which no file-specific switches have been
16362 This is an associative array attribute. Its domain is
16363 a set of file names. Its range is a string list that specifies
16364 options to be used when binding the named main file. If a main file
16365 is not specified in the Switches attribute, it is bound with the
16366 options specified by Default_Switches of its language, if defined.
16369 @subsection package Linker
16372 The attributes of package @code{Linker} specify the options to be used when
16373 invoking the linker in the construction of an executable.
16374 The following attributes apply to package @code{Linker}:
16377 @item Default_Switches
16378 This is an associative array attribute. Its
16379 domain is a set of language names. Its range is a string list that
16380 specifies options to be used when linking a main
16381 written in that language, for which no file-specific switches have been
16385 This is an associative array attribute. Its domain is
16386 a set of file names. Its range is a string list that specifies
16387 options to be used when linking the named main file. If a main file
16388 is not specified in the Switches attribute, it is linked with the
16389 options specified by Default_Switches of its language, if defined.
16391 @item Linker_Options
16392 This is a string list attribute. Its value specifies additional options that
16393 be given to the linker when linking an executable. This attribute is not
16394 used in the main project, only in projects imported directly or indirectly.
16398 @subsection package Cross_Reference
16401 The attributes of package @code{Cross_Reference} specify the tool options
16403 when invoking the library tool @command{gnatxref}.
16404 The following attributes apply to package @code{Cross_Reference}:
16407 @item Default_Switches
16408 This is an associative array attribute. Its
16409 domain is a set of language names. Its range is a string list that
16410 specifies options to be used when calling @command{gnatxref} on a source
16411 written in that language, for which no file-specific switches have been
16415 This is an associative array attribute. Its domain is
16416 a set of file names. Its range is a string list that specifies
16417 options to be used when calling @command{gnatxref} on the named main source.
16418 If a source is not specified in the Switches attribute, @command{gnatxref} will
16419 be called with the options specified by Default_Switches of its language,
16423 @subsection package Finder
16426 The attributes of package @code{Finder} specify the tool options to be used
16427 when invoking the search tool @command{gnatfind}.
16428 The following attributes apply to package @code{Finder}:
16431 @item Default_Switches
16432 This is an associative array attribute. Its
16433 domain is a set of language names. Its range is a string list that
16434 specifies options to be used when calling @command{gnatfind} on a source
16435 written in that language, for which no file-specific switches have been
16439 This is an associative array attribute. Its domain is
16440 a set of file names. Its range is a string list that specifies
16441 options to be used when calling @command{gnatfind} on the named main source.
16442 If a source is not specified in the Switches attribute, @command{gnatfind} will
16443 be called with the options specified by Default_Switches of its language,
16447 @subsection package Pretty_Printer
16450 The attributes of package @code{Pretty_Printer}
16451 specify the tool options to be used
16452 when invoking the formatting tool @command{gnatpp}.
16453 The following attributes apply to package @code{Pretty_Printer}:
16456 @item Default_switches
16457 This is an associative array attribute. Its
16458 domain is a set of language names. Its range is a string list that
16459 specifies options to be used when calling @command{gnatpp} on a source
16460 written in that language, for which no file-specific switches have been
16464 This is an associative array attribute. Its domain is
16465 a set of file names. Its range is a string list that specifies
16466 options to be used when calling @command{gnatpp} on the named main source.
16467 If a source is not specified in the Switches attribute, @command{gnatpp} will
16468 be called with the options specified by Default_Switches of its language,
16472 @subsection package gnatstub
16475 The attributes of package @code{gnatstub}
16476 specify the tool options to be used
16477 when invoking the tool @command{gnatstub}.
16478 The following attributes apply to package @code{gnatstub}:
16481 @item Default_switches
16482 This is an associative array attribute. Its
16483 domain is a set of language names. Its range is a string list that
16484 specifies options to be used when calling @command{gnatstub} on a source
16485 written in that language, for which no file-specific switches have been
16489 This is an associative array attribute. Its domain is
16490 a set of file names. Its range is a string list that specifies
16491 options to be used when calling @command{gnatstub} on the named main source.
16492 If a source is not specified in the Switches attribute, @command{gnatpp} will
16493 be called with the options specified by Default_Switches of its language,
16497 @subsection package Eliminate
16500 The attributes of package @code{Eliminate}
16501 specify the tool options to be used
16502 when invoking the tool @command{gnatelim}.
16503 The following attributes apply to package @code{Eliminate}:
16506 @item Default_switches
16507 This is an associative array attribute. Its
16508 domain is a set of language names. Its range is a string list that
16509 specifies options to be used when calling @command{gnatelim} on a source
16510 written in that language, for which no file-specific switches have been
16514 This is an associative array attribute. Its domain is
16515 a set of file names. Its range is a string list that specifies
16516 options to be used when calling @command{gnatelim} on the named main source.
16517 If a source is not specified in the Switches attribute, @command{gnatelim} will
16518 be called with the options specified by Default_Switches of its language,
16522 @subsection package Metrics
16525 The attributes of package @code{Metrics}
16526 specify the tool options to be used
16527 when invoking the tool @command{gnatmetric}.
16528 The following attributes apply to package @code{Metrics}:
16531 @item Default_switches
16532 This is an associative array attribute. Its
16533 domain is a set of language names. Its range is a string list that
16534 specifies options to be used when calling @command{gnatmetric} on a source
16535 written in that language, for which no file-specific switches have been
16539 This is an associative array attribute. Its domain is
16540 a set of file names. Its range is a string list that specifies
16541 options to be used when calling @command{gnatmetric} on the named main source.
16542 If a source is not specified in the Switches attribute, @command{gnatmetric}
16543 will be called with the options specified by Default_Switches of its language,
16547 @subsection package IDE
16550 The attributes of package @code{IDE} specify the options to be used when using
16551 an Integrated Development Environment such as @command{GPS}.
16555 This is a simple attribute. Its value is a string that designates the remote
16556 host in a cross-compilation environment, to be used for remote compilation and
16557 debugging. This field should not be specified when running on the local
16561 This is a simple attribute. Its value is a string that specifies the
16562 name of IP address of the embedded target in a cross-compilation environment,
16563 on which the program should execute.
16565 @item Communication_Protocol
16566 This is a simple string attribute. Its value is the name of the protocol
16567 to use to communicate with the target in a cross-compilation environment,
16568 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16570 @item Compiler_Command
16571 This is an associative array attribute, whose domain is a language name. Its
16572 value is string that denotes the command to be used to invoke the compiler.
16573 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16574 gnatmake, in particular in the handling of switches.
16576 @item Debugger_Command
16577 This is simple attribute, Its value is a string that specifies the name of
16578 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16580 @item Default_Switches
16581 This is an associative array attribute. Its indexes are the name of the
16582 external tools that the GNAT Programming System (GPS) is supporting. Its
16583 value is a list of switches to use when invoking that tool.
16586 This is a simple attribute. Its value is a string that specifies the name
16587 of the @command{gnatls} utility to be used to retrieve information about the
16588 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16591 This is a simple attribute. Its value is a string used to specify the
16592 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16593 ClearCase or Perforce.
16595 @item VCS_File_Check
16596 This is a simple attribute. Its value is a string that specifies the
16597 command used by the VCS to check the validity of a file, either
16598 when the user explicitly asks for a check, or as a sanity check before
16599 doing the check-in.
16601 @item VCS_Log_Check
16602 This is a simple attribute. Its value is a string that specifies
16603 the command used by the VCS to check the validity of a log file.
16605 @item VCS_Repository_Root
16606 The VCS repository root path. This is used to create tags or branches
16607 of the repository. For subversion the value should be the @code{URL}
16608 as specified to check-out the working copy of the repository.
16610 @item VCS_Patch_Root
16611 The local root directory to use for building patch file. All patch chunks
16612 will be relative to this path. The root project directory is used if
16613 this value is not defined.
16617 @node Package Renamings
16618 @section Package Renamings
16621 A package can be defined by a renaming declaration. The new package renames
16622 a package declared in a different project file, and has the same attributes
16623 as the package it renames.
16626 package_renaming ::==
16627 @b{package} package_identifier @b{renames}
16628 <project_>simple_name.package_identifier ;
16632 The package_identifier of the renamed package must be the same as the
16633 package_identifier. The project whose name is the prefix of the renamed
16634 package must contain a package declaration with this name. This project
16635 must appear in the context_clause of the enclosing project declaration,
16636 or be the parent project of the enclosing child project.
16642 A project file specifies a set of rules for constructing a software system.
16643 A project file can be self-contained, or depend on other project files.
16644 Dependencies are expressed through a context clause that names other projects.
16650 context_clause project_declaration
16652 project_declaration ::=
16653 simple_project_declaration | project_extension
16655 simple_project_declaration ::=
16656 @b{project} <project_>simple_name @b{is}
16657 @{declarative_item@}
16658 @b{end} <project_>simple_name;
16664 [@b{limited}] @b{with} path_name @{ , path_name @} ;
16671 A path name denotes a project file. A path name can be absolute or relative.
16672 An absolute path name includes a sequence of directories, in the syntax of
16673 the host operating system, that identifies uniquely the project file in the
16674 file system. A relative path name identifies the project file, relative
16675 to the directory that contains the current project, or relative to a
16676 directory listed in the environment variable ADA_PROJECT_PATH.
16677 Path names are case sensitive if file names in the host operating system
16678 are case sensitive.
16680 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16681 directory names separated by colons (semicolons on Windows).
16683 A given project name can appear only once in a context_clause.
16685 It is illegal for a project imported by a context clause to refer, directly
16686 or indirectly, to the project in which this context clause appears (the
16687 dependency graph cannot contain cycles), except when one of the with_clause
16688 in the cycle is a @code{limited with}.
16690 @node Project Extensions
16691 @section Project Extensions
16694 A project extension introduces a new project, which inherits the declarations
16695 of another project.
16699 project_extension ::=
16700 @b{project} <project_>simple_name @b{extends} path_name @b{is}
16701 @{declarative_item@}
16702 @b{end} <project_>simple_name;
16706 The project extension declares a child project. The child project inherits
16707 all the declarations and all the files of the parent project, These inherited
16708 declaration can be overridden in the child project, by means of suitable
16711 @node Project File Elaboration
16712 @section Project File Elaboration
16715 A project file is processed as part of the invocation of a gnat tool that
16716 uses the project option. Elaboration of the process file consists in the
16717 sequential elaboration of all its declarations. The computed values of
16718 attributes and variables in the project are then used to establish the
16719 environment in which the gnat tool will execute.
16721 @node Obsolescent Features
16722 @chapter Obsolescent Features
16725 This chapter describes features that are provided by GNAT, but are
16726 considered obsolescent since there are preferred ways of achieving
16727 the same effect. These features are provided solely for historical
16728 compatibility purposes.
16731 * pragma No_Run_Time::
16732 * pragma Ravenscar::
16733 * pragma Restricted_Run_Time::
16736 @node pragma No_Run_Time
16737 @section pragma No_Run_Time
16739 The pragma @code{No_Run_Time} is used to achieve an affect similar
16740 to the use of the "Zero Foot Print" configurable run time, but without
16741 requiring a specially configured run time. The result of using this
16742 pragma, which must be used for all units in a partition, is to restrict
16743 the use of any language features requiring run-time support code. The
16744 preferred usage is to use an appropriately configured run-time that
16745 includes just those features that are to be made accessible.
16747 @node pragma Ravenscar
16748 @section pragma Ravenscar
16750 The pragma @code{Ravenscar} has exactly the same effect as pragma
16751 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16752 is part of the new Ada 2005 standard.
16754 @node pragma Restricted_Run_Time
16755 @section pragma Restricted_Run_Time
16757 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16758 pragma @code{Profile (Restricted)}. The latter usage is
16759 preferred since the Ada 2005 pragma @code{Profile} is intended for
16760 this kind of implementation dependent addition.
16763 @c GNU Free Documentation License
16765 @node Index,,GNU Free Documentation License, Top