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.3 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 * Implementation of Ada 2012 Features::
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::
107 * Pragma Assertion_Policy::
108 * Pragma Assume_No_Invalid_Values::
110 * Pragma C_Pass_By_Copy::
112 * Pragma Check_Name::
113 * Pragma Check_Policy::
115 * Pragma Common_Object::
116 * Pragma Compile_Time_Error::
117 * Pragma Compile_Time_Warning::
118 * Pragma Compiler_Unit::
119 * Pragma Complete_Representation::
120 * Pragma Complex_Representation::
121 * Pragma Component_Alignment::
122 * Pragma Convention_Identifier::
124 * Pragma CPP_Constructor::
125 * Pragma CPP_Virtual::
126 * Pragma CPP_Vtable::
128 * Pragma Debug_Policy::
129 * Pragma Detect_Blocking::
130 * Pragma Elaboration_Checks::
132 * Pragma Export_Exception::
133 * Pragma Export_Function::
134 * Pragma Export_Object::
135 * Pragma Export_Procedure::
136 * Pragma Export_Value::
137 * Pragma Export_Valued_Procedure::
138 * Pragma Extend_System::
139 * Pragma Extensions_Allowed::
141 * Pragma External_Name_Casing::
143 * Pragma Favor_Top_Level::
144 * Pragma Finalize_Storage_Only::
145 * Pragma Float_Representation::
147 * Pragma Implemented::
148 * Pragma Implicit_Packing::
149 * Pragma Import_Exception::
150 * Pragma Import_Function::
151 * Pragma Import_Object::
152 * Pragma Import_Procedure::
153 * Pragma Import_Valued_Procedure::
154 * Pragma Initialize_Scalars::
155 * Pragma Inline_Always::
156 * Pragma Inline_Generic::
158 * Pragma Interface_Name::
159 * Pragma Interrupt_Handler::
160 * Pragma Interrupt_State::
162 * Pragma Keep_Names::
165 * Pragma Linker_Alias::
166 * Pragma Linker_Constructor::
167 * Pragma Linker_Destructor::
168 * Pragma Linker_Section::
169 * Pragma Long_Float::
170 * Pragma Machine_Attribute::
172 * Pragma Main_Storage::
175 * Pragma No_Strict_Aliasing ::
176 * Pragma Normalize_Scalars::
177 * Pragma Obsolescent::
178 * Pragma Optimize_Alignment::
181 * Pragma Persistent_BSS::
183 * Pragma Postcondition::
184 * Pragma Precondition::
185 * Pragma Profile (Ravenscar)::
186 * Pragma Profile (Restricted)::
187 * Pragma Psect_Object::
188 * Pragma Pure_Function::
189 * Pragma Restriction_Warnings::
191 * Pragma Short_Circuit_And_Or::
192 * Pragma Short_Descriptors::
193 * Pragma Source_File_Name::
194 * Pragma Source_File_Name_Project::
195 * Pragma Source_Reference::
196 * Pragma Static_Elaboration_Desired::
197 * Pragma Stream_Convert::
198 * Pragma Style_Checks::
201 * Pragma Suppress_All::
202 * Pragma Suppress_Exception_Locations::
203 * Pragma Suppress_Initialization::
206 * Pragma Task_Storage::
208 * Pragma Thread_Local_Storage::
209 * Pragma Time_Slice::
211 * Pragma Unchecked_Union::
212 * Pragma Unimplemented_Unit::
213 * Pragma Universal_Aliasing ::
214 * Pragma Universal_Data::
215 * Pragma Unmodified::
216 * Pragma Unreferenced::
217 * Pragma Unreferenced_Objects::
218 * Pragma Unreserve_All_Interrupts::
219 * Pragma Unsuppress::
220 * Pragma Use_VADS_Size::
221 * Pragma Validity_Checks::
224 * Pragma Weak_External::
225 * Pragma Wide_Character_Encoding::
227 Implementation Defined Attributes
238 * Default_Bit_Order::
250 * Has_Access_Values::
251 * Has_Discriminants::
258 * Max_Interrupt_Priority::
260 * Maximum_Alignment::
265 * Passed_By_Reference::
274 * System_Allocator_Alignment::
280 * Unconstrained_Array::
281 * Universal_Literal_String::
282 * Unrestricted_Access::
288 The Implementation of Standard I/O
290 * Standard I/O Packages::
296 * Wide_Wide_Text_IO::
300 * Filenames encoding::
302 * Operations on C Streams::
303 * Interfacing to C Streams::
307 * Ada.Characters.Latin_9 (a-chlat9.ads)::
308 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
309 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
310 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
311 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
312 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
313 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
314 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
315 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
316 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
317 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
318 * Ada.Command_Line.Environment (a-colien.ads)::
319 * Ada.Command_Line.Remove (a-colire.ads)::
320 * Ada.Command_Line.Response_File (a-clrefi.ads)::
321 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
322 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
323 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
324 * Ada.Exceptions.Traceback (a-exctra.ads)::
325 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
326 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
327 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
328 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
329 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
330 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
331 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
332 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
333 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
334 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
335 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
336 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
337 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
338 * GNAT.Altivec (g-altive.ads)::
339 * GNAT.Altivec.Conversions (g-altcon.ads)::
340 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
341 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
342 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
343 * GNAT.Array_Split (g-arrspl.ads)::
344 * GNAT.AWK (g-awk.ads)::
345 * GNAT.Bounded_Buffers (g-boubuf.ads)::
346 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
347 * GNAT.Bubble_Sort (g-bubsor.ads)::
348 * GNAT.Bubble_Sort_A (g-busora.ads)::
349 * GNAT.Bubble_Sort_G (g-busorg.ads)::
350 * GNAT.Byte_Order_Mark (g-byorma.ads)::
351 * GNAT.Byte_Swapping (g-bytswa.ads)::
352 * GNAT.Calendar (g-calend.ads)::
353 * GNAT.Calendar.Time_IO (g-catiio.ads)::
354 * GNAT.Case_Util (g-casuti.ads)::
355 * GNAT.CGI (g-cgi.ads)::
356 * GNAT.CGI.Cookie (g-cgicoo.ads)::
357 * GNAT.CGI.Debug (g-cgideb.ads)::
358 * GNAT.Command_Line (g-comlin.ads)::
359 * GNAT.Compiler_Version (g-comver.ads)::
360 * GNAT.Ctrl_C (g-ctrl_c.ads)::
361 * GNAT.CRC32 (g-crc32.ads)::
362 * GNAT.Current_Exception (g-curexc.ads)::
363 * GNAT.Debug_Pools (g-debpoo.ads)::
364 * GNAT.Debug_Utilities (g-debuti.ads)::
365 * GNAT.Decode_String (g-decstr.ads)::
366 * GNAT.Decode_UTF8_String (g-deutst.ads)::
367 * GNAT.Directory_Operations (g-dirope.ads)::
368 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
369 * GNAT.Dynamic_HTables (g-dynhta.ads)::
370 * GNAT.Dynamic_Tables (g-dyntab.ads)::
371 * GNAT.Encode_String (g-encstr.ads)::
372 * GNAT.Encode_UTF8_String (g-enutst.ads)::
373 * GNAT.Exception_Actions (g-excact.ads)::
374 * GNAT.Exception_Traces (g-exctra.ads)::
375 * GNAT.Exceptions (g-except.ads)::
376 * GNAT.Expect (g-expect.ads)::
377 * GNAT.Float_Control (g-flocon.ads)::
378 * GNAT.Heap_Sort (g-heasor.ads)::
379 * GNAT.Heap_Sort_A (g-hesora.ads)::
380 * GNAT.Heap_Sort_G (g-hesorg.ads)::
381 * GNAT.HTable (g-htable.ads)::
382 * GNAT.IO (g-io.ads)::
383 * GNAT.IO_Aux (g-io_aux.ads)::
384 * GNAT.Lock_Files (g-locfil.ads)::
385 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
386 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
387 * GNAT.MD5 (g-md5.ads)::
388 * GNAT.Memory_Dump (g-memdum.ads)::
389 * GNAT.Most_Recent_Exception (g-moreex.ads)::
390 * GNAT.OS_Lib (g-os_lib.ads)::
391 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
392 * GNAT.Random_Numbers (g-rannum.ads)::
393 * GNAT.Regexp (g-regexp.ads)::
394 * GNAT.Registry (g-regist.ads)::
395 * GNAT.Regpat (g-regpat.ads)::
396 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
397 * GNAT.Semaphores (g-semaph.ads)::
398 * GNAT.Serial_Communications (g-sercom.ads)::
399 * GNAT.SHA1 (g-sha1.ads)::
400 * GNAT.SHA224 (g-sha224.ads)::
401 * GNAT.SHA256 (g-sha256.ads)::
402 * GNAT.SHA384 (g-sha384.ads)::
403 * GNAT.SHA512 (g-sha512.ads)::
404 * GNAT.Signals (g-signal.ads)::
405 * GNAT.Sockets (g-socket.ads)::
406 * GNAT.Source_Info (g-souinf.ads)::
407 * GNAT.Spelling_Checker (g-speche.ads)::
408 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
409 * GNAT.Spitbol.Patterns (g-spipat.ads)::
410 * GNAT.Spitbol (g-spitbo.ads)::
411 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
412 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
413 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
414 * GNAT.SSE (g-sse.ads)::
415 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
416 * GNAT.Strings (g-string.ads)::
417 * GNAT.String_Split (g-strspl.ads)::
418 * GNAT.Table (g-table.ads)::
419 * GNAT.Task_Lock (g-tasloc.ads)::
420 * GNAT.Threads (g-thread.ads)::
421 * GNAT.Time_Stamp (g-timsta.ads)::
422 * GNAT.Traceback (g-traceb.ads)::
423 * GNAT.Traceback.Symbolic (g-trasym.ads)::
424 * GNAT.UTF_32 (g-utf_32.ads)::
425 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
426 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
427 * GNAT.Wide_String_Split (g-wistsp.ads)::
428 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
429 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
430 * Interfaces.C.Extensions (i-cexten.ads)::
431 * Interfaces.C.Streams (i-cstrea.ads)::
432 * Interfaces.CPP (i-cpp.ads)::
433 * Interfaces.Packed_Decimal (i-pacdec.ads)::
434 * Interfaces.VxWorks (i-vxwork.ads)::
435 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
436 * System.Address_Image (s-addima.ads)::
437 * System.Assertions (s-assert.ads)::
438 * System.Memory (s-memory.ads)::
439 * System.Partition_Interface (s-parint.ads)::
440 * System.Pool_Global (s-pooglo.ads)::
441 * System.Pool_Local (s-pooloc.ads)::
442 * System.Restrictions (s-restri.ads)::
443 * System.Rident (s-rident.ads)::
444 * System.Strings.Stream_Ops (s-ststop.ads)::
445 * System.Task_Info (s-tasinf.ads)::
446 * System.Wch_Cnv (s-wchcnv.ads)::
447 * System.Wch_Con (s-wchcon.ads)::
451 * Text_IO Stream Pointer Positioning::
452 * Text_IO Reading and Writing Non-Regular Files::
454 * Treating Text_IO Files as Streams::
455 * Text_IO Extensions::
456 * Text_IO Facilities for Unbounded Strings::
460 * Wide_Text_IO Stream Pointer Positioning::
461 * Wide_Text_IO Reading and Writing Non-Regular Files::
465 * Wide_Wide_Text_IO Stream Pointer Positioning::
466 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
468 Interfacing to Other Languages
471 * Interfacing to C++::
472 * Interfacing to COBOL::
473 * Interfacing to Fortran::
474 * Interfacing to non-GNAT Ada code::
476 Specialized Needs Annexes
478 Implementation of Specific Ada Features
479 * Machine Code Insertions::
480 * GNAT Implementation of Tasking::
481 * GNAT Implementation of Shared Passive Packages::
482 * Code Generation for Array Aggregates::
483 * The Size of Discriminated Records with Default Discriminants::
484 * Strict Conformance to the Ada Reference Manual::
486 Implementation of Ada 2012 Features
490 GNU Free Documentation License
497 @node About This Guide
498 @unnumbered About This Guide
501 This manual contains useful information in writing programs using the
502 @value{EDITION} compiler. It includes information on implementation dependent
503 characteristics of @value{EDITION}, including all the information required by
504 Annex M of the Ada language standard.
506 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
507 Ada 83 compatibility mode.
508 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
509 but you can override with a compiler switch
510 to explicitly specify the language version.
511 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
512 @value{EDITION} User's Guide}, for details on these switches.)
513 Throughout this manual, references to ``Ada'' without a year suffix
514 apply to both the Ada 95 and Ada 2005 versions of the language.
516 Ada is designed to be highly portable.
517 In general, a program will have the same effect even when compiled by
518 different compilers on different platforms.
519 However, since Ada is designed to be used in a
520 wide variety of applications, it also contains a number of system
521 dependent features to be used in interfacing to the external world.
522 @cindex Implementation-dependent features
525 Note: Any program that makes use of implementation-dependent features
526 may be non-portable. You should follow good programming practice and
527 isolate and clearly document any sections of your program that make use
528 of these features in a non-portable manner.
531 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
532 ``GNAT'' in the remainder of this document.
536 * What This Reference Manual Contains::
538 * Related Information::
541 @node What This Reference Manual Contains
542 @unnumberedsec What This Reference Manual Contains
545 This reference manual contains the following chapters:
549 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
550 pragmas, which can be used to extend and enhance the functionality of the
554 @ref{Implementation Defined Attributes}, lists GNAT
555 implementation-dependent attributes which can be used to extend and
556 enhance the functionality of the compiler.
559 @ref{Implementation Advice}, provides information on generally
560 desirable behavior which are not requirements that all compilers must
561 follow since it cannot be provided on all systems, or which may be
562 undesirable on some systems.
565 @ref{Implementation Defined Characteristics}, provides a guide to
566 minimizing implementation dependent features.
569 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
570 implemented by GNAT, and how they can be imported into user
571 application programs.
574 @ref{Representation Clauses and Pragmas}, describes in detail the
575 way that GNAT represents data, and in particular the exact set
576 of representation clauses and pragmas that is accepted.
579 @ref{Standard Library Routines}, provides a listing of packages and a
580 brief description of the functionality that is provided by Ada's
581 extensive set of standard library routines as implemented by GNAT@.
584 @ref{The Implementation of Standard I/O}, details how the GNAT
585 implementation of the input-output facilities.
588 @ref{The GNAT Library}, is a catalog of packages that complement
589 the Ada predefined library.
592 @ref{Interfacing to Other Languages}, describes how programs
593 written in Ada using GNAT can be interfaced to other programming
596 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
597 of the specialized needs annexes.
600 @ref{Implementation of Specific Ada Features}, discusses issues related
601 to GNAT's implementation of machine code insertions, tasking, and several
605 @ref{Implementation of Ada 2012 Features}, describes the status of the
606 GNAT implementation of the Ada 2012 language standard.
609 @ref{Obsolescent Features} documents implementation dependent features,
610 including pragmas and attributes, which are considered obsolescent, since
611 there are other preferred ways of achieving the same results. These
612 obsolescent forms are retained for backwards compatibility.
616 @cindex Ada 95 Language Reference Manual
617 @cindex Ada 2005 Language Reference Manual
619 This reference manual assumes a basic familiarity with the Ada 95 language, as
620 described in the International Standard ANSI/ISO/IEC-8652:1995,
622 It does not require knowledge of the new features introduced by Ada 2005,
623 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
625 Both reference manuals are included in the GNAT documentation
629 @unnumberedsec Conventions
630 @cindex Conventions, typographical
631 @cindex Typographical conventions
634 Following are examples of the typographical and graphic conventions used
639 @code{Functions}, @code{utility program names}, @code{standard names},
646 @file{File names}, @samp{button names}, and @samp{field names}.
649 @code{Variables}, @env{environment variables}, and @var{metasyntactic
656 [optional information or parameters]
659 Examples are described by text
661 and then shown this way.
666 Commands that are entered by the user are preceded in this manual by the
667 characters @samp{$ } (dollar sign followed by space). If your system uses this
668 sequence as a prompt, then the commands will appear exactly as you see them
669 in the manual. If your system uses some other prompt, then the command will
670 appear with the @samp{$} replaced by whatever prompt character you are using.
672 @node Related Information
673 @unnumberedsec Related Information
675 See the following documents for further information on GNAT:
679 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
680 @value{EDITION} User's Guide}, which provides information on how to use the
681 GNAT compiler system.
684 @cite{Ada 95 Reference Manual}, which contains all reference
685 material for the Ada 95 programming language.
688 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
689 of the Ada 95 standard. The annotations describe
690 detailed aspects of the design decision, and in particular contain useful
691 sections on Ada 83 compatibility.
694 @cite{Ada 2005 Reference Manual}, which contains all reference
695 material for the Ada 2005 programming language.
698 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
699 of the Ada 2005 standard. The annotations describe
700 detailed aspects of the design decision, and in particular contain useful
701 sections on Ada 83 and Ada 95 compatibility.
704 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
705 which contains specific information on compatibility between GNAT and
709 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
710 describes in detail the pragmas and attributes provided by the DEC Ada 83
715 @node Implementation Defined Pragmas
716 @chapter Implementation Defined Pragmas
719 Ada defines a set of pragmas that can be used to supply additional
720 information to the compiler. These language defined pragmas are
721 implemented in GNAT and work as described in the Ada Reference Manual.
723 In addition, Ada allows implementations to define additional pragmas
724 whose meaning is defined by the implementation. GNAT provides a number
725 of these implementation-defined pragmas, which can be used to extend
726 and enhance the functionality of the compiler. This section of the GNAT
727 Reference Manual describes these additional pragmas.
729 Note that any program using these pragmas might not be portable to other
730 compilers (although GNAT implements this set of pragmas on all
731 platforms). Therefore if portability to other compilers is an important
732 consideration, the use of these pragmas should be minimized.
735 * Pragma Abort_Defer::
744 * Pragma Assertion_Policy::
745 * Pragma Assume_No_Invalid_Values::
747 * Pragma C_Pass_By_Copy::
749 * Pragma Check_Name::
750 * Pragma Check_Policy::
752 * Pragma Common_Object::
753 * Pragma Compile_Time_Error::
754 * Pragma Compile_Time_Warning::
755 * Pragma Compiler_Unit::
756 * Pragma Complete_Representation::
757 * Pragma Complex_Representation::
758 * Pragma Component_Alignment::
759 * Pragma Convention_Identifier::
761 * Pragma CPP_Constructor::
762 * Pragma CPP_Virtual::
763 * Pragma CPP_Vtable::
765 * Pragma Debug_Policy::
766 * Pragma Detect_Blocking::
767 * Pragma Elaboration_Checks::
769 * Pragma Export_Exception::
770 * Pragma Export_Function::
771 * Pragma Export_Object::
772 * Pragma Export_Procedure::
773 * Pragma Export_Value::
774 * Pragma Export_Valued_Procedure::
775 * Pragma Extend_System::
776 * Pragma Extensions_Allowed::
778 * Pragma External_Name_Casing::
780 * Pragma Favor_Top_Level::
781 * Pragma Finalize_Storage_Only::
782 * Pragma Float_Representation::
784 * Pragma Implemented::
785 * Pragma Implicit_Packing::
786 * Pragma Import_Exception::
787 * Pragma Import_Function::
788 * Pragma Import_Object::
789 * Pragma Import_Procedure::
790 * Pragma Import_Valued_Procedure::
791 * Pragma Initialize_Scalars::
792 * Pragma Inline_Always::
793 * Pragma Inline_Generic::
795 * Pragma Interface_Name::
796 * Pragma Interrupt_Handler::
797 * Pragma Interrupt_State::
799 * Pragma Keep_Names::
802 * Pragma Linker_Alias::
803 * Pragma Linker_Constructor::
804 * Pragma Linker_Destructor::
805 * Pragma Linker_Section::
806 * Pragma Long_Float::
807 * Pragma Machine_Attribute::
809 * Pragma Main_Storage::
812 * Pragma No_Strict_Aliasing::
813 * Pragma Normalize_Scalars::
814 * Pragma Obsolescent::
815 * Pragma Optimize_Alignment::
818 * Pragma Persistent_BSS::
820 * Pragma Postcondition::
821 * Pragma Precondition::
822 * Pragma Profile (Ravenscar)::
823 * Pragma Profile (Restricted)::
824 * Pragma Psect_Object::
825 * Pragma Pure_Function::
826 * Pragma Restriction_Warnings::
828 * Pragma Short_Circuit_And_Or::
829 * Pragma Short_Descriptors::
830 * Pragma Source_File_Name::
831 * Pragma Source_File_Name_Project::
832 * Pragma Source_Reference::
833 * Pragma Static_Elaboration_Desired::
834 * Pragma Stream_Convert::
835 * Pragma Style_Checks::
838 * Pragma Suppress_All::
839 * Pragma Suppress_Exception_Locations::
840 * Pragma Suppress_Initialization::
843 * Pragma Task_Storage::
845 * Pragma Thread_Local_Storage::
846 * Pragma Time_Slice::
848 * Pragma Unchecked_Union::
849 * Pragma Unimplemented_Unit::
850 * Pragma Universal_Aliasing ::
851 * Pragma Universal_Data::
852 * Pragma Unmodified::
853 * Pragma Unreferenced::
854 * Pragma Unreferenced_Objects::
855 * Pragma Unreserve_All_Interrupts::
856 * Pragma Unsuppress::
857 * Pragma Use_VADS_Size::
858 * Pragma Validity_Checks::
861 * Pragma Weak_External::
862 * Pragma Wide_Character_Encoding::
865 @node Pragma Abort_Defer
866 @unnumberedsec Pragma Abort_Defer
868 @cindex Deferring aborts
876 This pragma must appear at the start of the statement sequence of a
877 handled sequence of statements (right after the @code{begin}). It has
878 the effect of deferring aborts for the sequence of statements (but not
879 for the declarations or handlers, if any, associated with this statement
883 @unnumberedsec Pragma Ada_83
892 A configuration pragma that establishes Ada 83 mode for the unit to
893 which it applies, regardless of the mode set by the command line
894 switches. In Ada 83 mode, GNAT attempts to be as compatible with
895 the syntax and semantics of Ada 83, as defined in the original Ada
896 83 Reference Manual as possible. In particular, the keywords added by Ada 95
897 and Ada 2005 are not recognized, optional package bodies are allowed,
898 and generics may name types with unknown discriminants without using
899 the @code{(<>)} notation. In addition, some but not all of the additional
900 restrictions of Ada 83 are enforced.
902 Ada 83 mode is intended for two purposes. Firstly, it allows existing
903 Ada 83 code to be compiled and adapted to GNAT with less effort.
904 Secondly, it aids in keeping code backwards compatible with Ada 83.
905 However, there is no guarantee that code that is processed correctly
906 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
907 83 compiler, since GNAT does not enforce all the additional checks
911 @unnumberedsec Pragma Ada_95
920 A configuration pragma that establishes Ada 95 mode for the unit to which
921 it applies, regardless of the mode set by the command line switches.
922 This mode is set automatically for the @code{Ada} and @code{System}
923 packages and their children, so you need not specify it in these
924 contexts. This pragma is useful when writing a reusable component that
925 itself uses Ada 95 features, but which is intended to be usable from
926 either Ada 83 or Ada 95 programs.
929 @unnumberedsec Pragma Ada_05
938 A configuration pragma that establishes Ada 2005 mode for the unit to which
939 it applies, regardless of the mode set by the command line switches.
940 This pragma is useful when writing a reusable component that
941 itself uses Ada 2005 features, but which is intended to be usable from
942 either Ada 83 or Ada 95 programs.
944 @node Pragma Ada_2005
945 @unnumberedsec Pragma Ada_2005
954 This configuration pragma is a synonym for pragma Ada_05 and has the
955 same syntax and effect.
958 @unnumberedsec Pragma Ada_12
967 A configuration pragma that establishes Ada 2012 mode for the unit to which
968 it applies, regardless of the mode set by the command line switches.
969 This mode is set automatically for the @code{Ada} and @code{System}
970 packages and their children, so you need not specify it in these
971 contexts. This pragma is useful when writing a reusable component that
972 itself uses Ada 2012 features, but which is intended to be usable from
973 Ada 83, Ada 95, or Ada 2005 programs.
975 @node Pragma Ada_2012
976 @unnumberedsec Pragma Ada_2012
985 This configuration pragma is a synonym for pragma Ada_12 and has the
986 same syntax and effect.
988 @node Pragma Annotate
989 @unnumberedsec Pragma Annotate
994 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
996 ARG ::= NAME | EXPRESSION
1000 This pragma is used to annotate programs. @var{identifier} identifies
1001 the type of annotation. GNAT verifies that it is an identifier, but does
1002 not otherwise analyze it. The second optional identifier is also left
1003 unanalyzed, and by convention is used to control the action of the tool to
1004 which the annotation is addressed. The remaining @var{arg} arguments
1005 can be either string literals or more generally expressions.
1006 String literals are assumed to be either of type
1007 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1008 depending on the character literals they contain.
1009 All other kinds of arguments are analyzed as expressions, and must be
1012 The analyzed pragma is retained in the tree, but not otherwise processed
1013 by any part of the GNAT compiler, except to generate corresponding note
1014 lines in the generated ALI file. For the format of these note lines, see
1015 the compiler source file lib-writ.ads. This pragma is intended for use by
1016 external tools, including ASIS@. The use of pragma Annotate does not
1017 affect the compilation process in any way.
1020 @unnumberedsec Pragma Assert
1024 @smallexample @c ada
1027 [, string_EXPRESSION]);
1031 The effect of this pragma depends on whether the corresponding command
1032 line switch is set to activate assertions. The pragma expands into code
1033 equivalent to the following:
1035 @smallexample @c ada
1036 if assertions-enabled then
1037 if not boolean_EXPRESSION then
1038 System.Assertions.Raise_Assert_Failure
1039 (string_EXPRESSION);
1045 The string argument, if given, is the message that will be associated
1046 with the exception occurrence if the exception is raised. If no second
1047 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1048 where @var{file} is the name of the source file containing the assert,
1049 and @var{nnn} is the line number of the assert. A pragma is not a
1050 statement, so if a statement sequence contains nothing but a pragma
1051 assert, then a null statement is required in addition, as in:
1053 @smallexample @c ada
1056 pragma Assert (K > 3, "Bad value for K");
1062 Note that, as with the @code{if} statement to which it is equivalent, the
1063 type of the expression is either @code{Standard.Boolean}, or any type derived
1064 from this standard type.
1066 If assertions are disabled (switch @option{-gnata} not used), then there
1067 is no run-time effect (and in particular, any side effects from the
1068 expression will not occur at run time). (The expression is still
1069 analyzed at compile time, and may cause types to be frozen if they are
1070 mentioned here for the first time).
1072 If assertions are enabled, then the given expression is tested, and if
1073 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1074 which results in the raising of @code{Assert_Failure} with the given message.
1076 You should generally avoid side effects in the expression arguments of
1077 this pragma, because these side effects will turn on and off with the
1078 setting of the assertions mode, resulting in assertions that have an
1079 effect on the program. However, the expressions are analyzed for
1080 semantic correctness whether or not assertions are enabled, so turning
1081 assertions on and off cannot affect the legality of a program.
1083 Note that the implementation defined policy @code{DISABLE}, given in a
1084 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1086 Note: this is a standard language-defined pragma in versions
1087 of Ada from 2005 on. In GNAT, it is implemented in all versions
1088 of Ada, and the DISABLE policy is an implementation-defined
1092 @node Pragma Assertion_Policy
1093 @unnumberedsec Pragma Assertion_Policy
1094 @findex Debug_Policy
1098 @smallexample @c ada
1099 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1103 If the argument is @code{CHECK}, then pragma @code{Assert} is enabled.
1104 If the argument is @code{IGNORE}, then pragma @code{Assert} is ignored.
1105 This pragma overrides the effect of the @option{-gnata} switch on the
1108 The implementation defined policy @code{DISABLE} is like
1109 @code{IGNORE} except that it completely disables semantic
1110 checking of the argument to @code{pragma Assert}. This may
1111 be useful when the pragma argument references subprograms
1112 in a with'ed package which is replaced by a dummy package
1113 for the final build.
1115 Note: this is a standard language-defined pragma in versions
1116 of Ada from 2005 on. In GNAT, it is implemented in all versions
1117 of Ada, and the DISABLE policy is an implementation-defined
1120 @node Pragma Assume_No_Invalid_Values
1121 @unnumberedsec Pragma Assume_No_Invalid_Values
1122 @findex Assume_No_Invalid_Values
1123 @cindex Invalid representations
1124 @cindex Invalid values
1127 @smallexample @c ada
1128 pragma Assume_No_Invalid_Values (On | Off);
1132 This is a configuration pragma that controls the assumptions made by the
1133 compiler about the occurrence of invalid representations (invalid values)
1136 The default behavior (corresponding to an Off argument for this pragma), is
1137 to assume that values may in general be invalid unless the compiler can
1138 prove they are valid. Consider the following example:
1140 @smallexample @c ada
1141 V1 : Integer range 1 .. 10;
1142 V2 : Integer range 11 .. 20;
1144 for J in V2 .. V1 loop
1150 if V1 and V2 have valid values, then the loop is known at compile
1151 time not to execute since the lower bound must be greater than the
1152 upper bound. However in default mode, no such assumption is made,
1153 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1154 is given, the compiler will assume that any occurrence of a variable
1155 other than in an explicit @code{'Valid} test always has a valid
1156 value, and the loop above will be optimized away.
1158 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1159 you know your code is free of uninitialized variables and other
1160 possible sources of invalid representations, and may result in
1161 more efficient code. A program that accesses an invalid representation
1162 with this pragma in effect is erroneous, so no guarantees can be made
1165 It is peculiar though permissible to use this pragma in conjunction
1166 with validity checking (-gnatVa). In such cases, accessing invalid
1167 values will generally give an exception, though formally the program
1168 is erroneous so there are no guarantees that this will always be the
1169 case, and it is recommended that these two options not be used together.
1171 @node Pragma Ast_Entry
1172 @unnumberedsec Pragma Ast_Entry
1177 @smallexample @c ada
1178 pragma AST_Entry (entry_IDENTIFIER);
1182 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1183 argument is the simple name of a single entry; at most one @code{AST_Entry}
1184 pragma is allowed for any given entry. This pragma must be used in
1185 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1186 the entry declaration and in the same task type specification or single task
1187 as the entry to which it applies. This pragma specifies that the given entry
1188 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1189 resulting from an OpenVMS system service call. The pragma does not affect
1190 normal use of the entry. For further details on this pragma, see the
1191 DEC Ada Language Reference Manual, section 9.12a.
1193 @node Pragma C_Pass_By_Copy
1194 @unnumberedsec Pragma C_Pass_By_Copy
1195 @cindex Passing by copy
1196 @findex C_Pass_By_Copy
1199 @smallexample @c ada
1200 pragma C_Pass_By_Copy
1201 ([Max_Size =>] static_integer_EXPRESSION);
1205 Normally the default mechanism for passing C convention records to C
1206 convention subprograms is to pass them by reference, as suggested by RM
1207 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1208 this default, by requiring that record formal parameters be passed by
1209 copy if all of the following conditions are met:
1213 The size of the record type does not exceed the value specified for
1216 The record type has @code{Convention C}.
1218 The formal parameter has this record type, and the subprogram has a
1219 foreign (non-Ada) convention.
1223 If these conditions are met the argument is passed by copy, i.e.@: in a
1224 manner consistent with what C expects if the corresponding formal in the
1225 C prototype is a struct (rather than a pointer to a struct).
1227 You can also pass records by copy by specifying the convention
1228 @code{C_Pass_By_Copy} for the record type, or by using the extended
1229 @code{Import} and @code{Export} pragmas, which allow specification of
1230 passing mechanisms on a parameter by parameter basis.
1233 @unnumberedsec Pragma Check
1235 @cindex Named assertions
1239 @smallexample @c ada
1241 [Name =>] Identifier,
1242 [Check =>] Boolean_EXPRESSION
1243 [, [Message =>] string_EXPRESSION] );
1247 This pragma is similar to the predefined pragma @code{Assert} except that an
1248 extra identifier argument is present. In conjunction with pragma
1249 @code{Check_Policy}, this can be used to define groups of assertions that can
1250 be independently controlled. The identifier @code{Assertion} is special, it
1251 refers to the normal set of pragma @code{Assert} statements. The identifiers
1252 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1253 names, so these three names would normally not be used directly in a pragma
1256 Checks introduced by this pragma are normally deactivated by default. They can
1257 be activated either by the command line option @option{-gnata}, which turns on
1258 all checks, or individually controlled using pragma @code{Check_Policy}.
1260 @node Pragma Check_Name
1261 @unnumberedsec Pragma Check_Name
1262 @cindex Defining check names
1263 @cindex Check names, defining
1267 @smallexample @c ada
1268 pragma Check_Name (check_name_IDENTIFIER);
1272 This is a configuration pragma that defines a new implementation
1273 defined check name (unless IDENTIFIER matches one of the predefined
1274 check names, in which case the pragma has no effect). Check names
1275 are global to a partition, so if two or more configuration pragmas
1276 are present in a partition mentioning the same name, only one new
1277 check name is introduced.
1279 An implementation defined check name introduced with this pragma may
1280 be used in only three contexts: @code{pragma Suppress},
1281 @code{pragma Unsuppress},
1282 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1283 any of these three cases, the check name must be visible. A check
1284 name is visible if it is in the configuration pragmas applying to
1285 the current unit, or if it appears at the start of any unit that
1286 is part of the dependency set of the current unit (e.g., units that
1287 are mentioned in @code{with} clauses).
1289 @node Pragma Check_Policy
1290 @unnumberedsec Pragma Check_Policy
1291 @cindex Controlling assertions
1292 @cindex Assertions, control
1293 @cindex Check pragma control
1294 @cindex Named assertions
1298 @smallexample @c ada
1300 ([Name =>] Identifier,
1301 [Policy =>] POLICY_IDENTIFIER);
1303 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1307 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1308 except that it controls sets of named assertions introduced using the
1309 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1310 @code{Assertion_Policy}) can be used within a declarative part, in which case
1311 it controls the status to the end of the corresponding construct (in a manner
1312 identical to pragma @code{Suppress)}.
1314 The identifier given as the first argument corresponds to a name used in
1315 associated @code{Check} pragmas. For example, if the pragma:
1317 @smallexample @c ada
1318 pragma Check_Policy (Critical_Error, OFF);
1322 is given, then subsequent @code{Check} pragmas whose first argument is also
1323 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1324 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1325 @code{Check_Policy} with this identifier is similar to the normal
1326 @code{Assertion_Policy} pragma except that it can appear within a
1329 The special identifiers @code{Precondition} and @code{Postcondition} control
1330 the status of preconditions and postconditions. If a @code{Precondition} pragma
1331 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1332 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1333 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1336 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1337 to turn on corresponding checks. The default for a set of checks for which no
1338 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1339 @option{-gnata} is given, which turns on all checks by default.
1341 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1342 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1343 compatibility with the standard @code{Assertion_Policy} pragma.
1345 The implementation defined policy @code{DISABLE} is like
1346 @code{OFF} except that it completely disables semantic
1347 checking of the argument to the corresponding class of
1348 pragmas. This may be useful when the pragma arguments reference
1349 subprograms in a with'ed package which is replaced by a dummy package
1350 for the final build.
1352 @node Pragma Comment
1353 @unnumberedsec Pragma Comment
1358 @smallexample @c ada
1359 pragma Comment (static_string_EXPRESSION);
1363 This is almost identical in effect to pragma @code{Ident}. It allows the
1364 placement of a comment into the object file and hence into the
1365 executable file if the operating system permits such usage. The
1366 difference is that @code{Comment}, unlike @code{Ident}, has
1367 no limitations on placement of the pragma (it can be placed
1368 anywhere in the main source unit), and if more than one pragma
1369 is used, all comments are retained.
1371 @node Pragma Common_Object
1372 @unnumberedsec Pragma Common_Object
1373 @findex Common_Object
1377 @smallexample @c ada
1378 pragma Common_Object (
1379 [Internal =>] LOCAL_NAME
1380 [, [External =>] EXTERNAL_SYMBOL]
1381 [, [Size =>] EXTERNAL_SYMBOL] );
1385 | static_string_EXPRESSION
1389 This pragma enables the shared use of variables stored in overlaid
1390 linker areas corresponding to the use of @code{COMMON}
1391 in Fortran. The single
1392 object @var{LOCAL_NAME} is assigned to the area designated by
1393 the @var{External} argument.
1394 You may define a record to correspond to a series
1395 of fields. The @var{Size} argument
1396 is syntax checked in GNAT, but otherwise ignored.
1398 @code{Common_Object} is not supported on all platforms. If no
1399 support is available, then the code generator will issue a message
1400 indicating that the necessary attribute for implementation of this
1401 pragma is not available.
1403 @node Pragma Compile_Time_Error
1404 @unnumberedsec Pragma Compile_Time_Error
1405 @findex Compile_Time_Error
1409 @smallexample @c ada
1410 pragma Compile_Time_Error
1411 (boolean_EXPRESSION, static_string_EXPRESSION);
1415 This pragma can be used to generate additional compile time
1417 is particularly useful in generics, where errors can be issued for
1418 specific problematic instantiations. The first parameter is a boolean
1419 expression. The pragma is effective only if the value of this expression
1420 is known at compile time, and has the value True. The set of expressions
1421 whose values are known at compile time includes all static boolean
1422 expressions, and also other values which the compiler can determine
1423 at compile time (e.g., the size of a record type set by an explicit
1424 size representation clause, or the value of a variable which was
1425 initialized to a constant and is known not to have been modified).
1426 If these conditions are met, an error message is generated using
1427 the value given as the second argument. This string value may contain
1428 embedded ASCII.LF characters to break the message into multiple lines.
1430 @node Pragma Compile_Time_Warning
1431 @unnumberedsec Pragma Compile_Time_Warning
1432 @findex Compile_Time_Warning
1436 @smallexample @c ada
1437 pragma Compile_Time_Warning
1438 (boolean_EXPRESSION, static_string_EXPRESSION);
1442 Same as pragma Compile_Time_Error, except a warning is issued instead
1443 of an error message. Note that if this pragma is used in a package that
1444 is with'ed by a client, the client will get the warning even though it
1445 is issued by a with'ed package (normally warnings in with'ed units are
1446 suppressed, but this is a special exception to that rule).
1448 One typical use is within a generic where compile time known characteristics
1449 of formal parameters are tested, and warnings given appropriately. Another use
1450 with a first parameter of True is to warn a client about use of a package,
1451 for example that it is not fully implemented.
1453 @node Pragma Compiler_Unit
1454 @unnumberedsec Pragma Compiler_Unit
1455 @findex Compiler_Unit
1459 @smallexample @c ada
1460 pragma Compiler_Unit;
1464 This pragma is intended only for internal use in the GNAT run-time library.
1465 It indicates that the unit is used as part of the compiler build. The effect
1466 is to disallow constructs (raise with message, conditional expressions etc)
1467 that would cause trouble when bootstrapping using an older version of GNAT.
1468 For the exact list of restrictions, see the compiler sources and references
1469 to Is_Compiler_Unit.
1471 @node Pragma Complete_Representation
1472 @unnumberedsec Pragma Complete_Representation
1473 @findex Complete_Representation
1477 @smallexample @c ada
1478 pragma Complete_Representation;
1482 This pragma must appear immediately within a record representation
1483 clause. Typical placements are before the first component clause
1484 or after the last component clause. The effect is to give an error
1485 message if any component is missing a component clause. This pragma
1486 may be used to ensure that a record representation clause is
1487 complete, and that this invariant is maintained if fields are
1488 added to the record in the future.
1490 @node Pragma Complex_Representation
1491 @unnumberedsec Pragma Complex_Representation
1492 @findex Complex_Representation
1496 @smallexample @c ada
1497 pragma Complex_Representation
1498 ([Entity =>] LOCAL_NAME);
1502 The @var{Entity} argument must be the name of a record type which has
1503 two fields of the same floating-point type. The effect of this pragma is
1504 to force gcc to use the special internal complex representation form for
1505 this record, which may be more efficient. Note that this may result in
1506 the code for this type not conforming to standard ABI (application
1507 binary interface) requirements for the handling of record types. For
1508 example, in some environments, there is a requirement for passing
1509 records by pointer, and the use of this pragma may result in passing
1510 this type in floating-point registers.
1512 @node Pragma Component_Alignment
1513 @unnumberedsec Pragma Component_Alignment
1514 @cindex Alignments of components
1515 @findex Component_Alignment
1519 @smallexample @c ada
1520 pragma Component_Alignment (
1521 [Form =>] ALIGNMENT_CHOICE
1522 [, [Name =>] type_LOCAL_NAME]);
1524 ALIGNMENT_CHOICE ::=
1532 Specifies the alignment of components in array or record types.
1533 The meaning of the @var{Form} argument is as follows:
1536 @findex Component_Size
1537 @item Component_Size
1538 Aligns scalar components and subcomponents of the array or record type
1539 on boundaries appropriate to their inherent size (naturally
1540 aligned). For example, 1-byte components are aligned on byte boundaries,
1541 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1542 integer components are aligned on 4-byte boundaries and so on. These
1543 alignment rules correspond to the normal rules for C compilers on all
1544 machines except the VAX@.
1546 @findex Component_Size_4
1547 @item Component_Size_4
1548 Naturally aligns components with a size of four or fewer
1549 bytes. Components that are larger than 4 bytes are placed on the next
1552 @findex Storage_Unit
1554 Specifies that array or record components are byte aligned, i.e.@:
1555 aligned on boundaries determined by the value of the constant
1556 @code{System.Storage_Unit}.
1560 Specifies that array or record components are aligned on default
1561 boundaries, appropriate to the underlying hardware or operating system or
1562 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1563 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1564 the @code{Default} choice is the same as @code{Component_Size} (natural
1569 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1570 refer to a local record or array type, and the specified alignment
1571 choice applies to the specified type. The use of
1572 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1573 @code{Component_Alignment} pragma to be ignored. The use of
1574 @code{Component_Alignment} together with a record representation clause
1575 is only effective for fields not specified by the representation clause.
1577 If the @code{Name} parameter is absent, the pragma can be used as either
1578 a configuration pragma, in which case it applies to one or more units in
1579 accordance with the normal rules for configuration pragmas, or it can be
1580 used within a declarative part, in which case it applies to types that
1581 are declared within this declarative part, or within any nested scope
1582 within this declarative part. In either case it specifies the alignment
1583 to be applied to any record or array type which has otherwise standard
1586 If the alignment for a record or array type is not specified (using
1587 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1588 clause), the GNAT uses the default alignment as described previously.
1590 @node Pragma Convention_Identifier
1591 @unnumberedsec Pragma Convention_Identifier
1592 @findex Convention_Identifier
1593 @cindex Conventions, synonyms
1597 @smallexample @c ada
1598 pragma Convention_Identifier (
1599 [Name =>] IDENTIFIER,
1600 [Convention =>] convention_IDENTIFIER);
1604 This pragma provides a mechanism for supplying synonyms for existing
1605 convention identifiers. The @code{Name} identifier can subsequently
1606 be used as a synonym for the given convention in other pragmas (including
1607 for example pragma @code{Import} or another @code{Convention_Identifier}
1608 pragma). As an example of the use of this, suppose you had legacy code
1609 which used Fortran77 as the identifier for Fortran. Then the pragma:
1611 @smallexample @c ada
1612 pragma Convention_Identifier (Fortran77, Fortran);
1616 would allow the use of the convention identifier @code{Fortran77} in
1617 subsequent code, avoiding the need to modify the sources. As another
1618 example, you could use this to parameterize convention requirements
1619 according to systems. Suppose you needed to use @code{Stdcall} on
1620 windows systems, and @code{C} on some other system, then you could
1621 define a convention identifier @code{Library} and use a single
1622 @code{Convention_Identifier} pragma to specify which convention
1623 would be used system-wide.
1625 @node Pragma CPP_Class
1626 @unnumberedsec Pragma CPP_Class
1628 @cindex Interfacing with C++
1632 @smallexample @c ada
1633 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1637 The argument denotes an entity in the current declarative region that is
1638 declared as a record type. It indicates that the type corresponds to an
1639 externally declared C++ class type, and is to be laid out the same way
1640 that C++ would lay out the type. If the C++ class has virtual primitives
1641 then the record must be declared as a tagged record type.
1643 Types for which @code{CPP_Class} is specified do not have assignment or
1644 equality operators defined (such operations can be imported or declared
1645 as subprograms as required). Initialization is allowed only by constructor
1646 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1647 limited if not explicitly declared as limited or derived from a limited
1648 type, and an error is issued in that case.
1650 Pragma @code{CPP_Class} is intended primarily for automatic generation
1651 using an automatic binding generator tool.
1652 See @ref{Interfacing to C++} for related information.
1654 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1655 for backward compatibility but its functionality is available
1656 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1658 @node Pragma CPP_Constructor
1659 @unnumberedsec Pragma CPP_Constructor
1660 @cindex Interfacing with C++
1661 @findex CPP_Constructor
1665 @smallexample @c ada
1666 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1667 [, [External_Name =>] static_string_EXPRESSION ]
1668 [, [Link_Name =>] static_string_EXPRESSION ]);
1672 This pragma identifies an imported function (imported in the usual way
1673 with pragma @code{Import}) as corresponding to a C++ constructor. If
1674 @code{External_Name} and @code{Link_Name} are not specified then the
1675 @code{Entity} argument is a name that must have been previously mentioned
1676 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1677 must be of one of the following forms:
1681 @code{function @var{Fname} return @var{T}}
1685 @code{function @var{Fname} return @var{T}'Class}
1688 @code{function @var{Fname} (@dots{}) return @var{T}}
1692 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1696 where @var{T} is a limited record type imported from C++ with pragma
1697 @code{Import} and @code{Convention} = @code{CPP}.
1699 The first two forms import the default constructor, used when an object
1700 of type @var{T} is created on the Ada side with no explicit constructor.
1701 The latter two forms cover all the non-default constructors of the type.
1702 See the GNAT users guide for details.
1704 If no constructors are imported, it is impossible to create any objects
1705 on the Ada side and the type is implicitly declared abstract.
1707 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1708 using an automatic binding generator tool.
1709 See @ref{Interfacing to C++} for more related information.
1711 Note: The use of functions returning class-wide types for constructors is
1712 currently obsolete. They are supported for backward compatibility. The
1713 use of functions returning the type T leave the Ada sources more clear
1714 because the imported C++ constructors always return an object of type T;
1715 that is, they never return an object whose type is a descendant of type T.
1717 @node Pragma CPP_Virtual
1718 @unnumberedsec Pragma CPP_Virtual
1719 @cindex Interfacing to C++
1722 This pragma is now obsolete has has no effect because GNAT generates
1723 the same object layout than the G++ compiler.
1725 See @ref{Interfacing to C++} for related information.
1727 @node Pragma CPP_Vtable
1728 @unnumberedsec Pragma CPP_Vtable
1729 @cindex Interfacing with C++
1732 This pragma is now obsolete has has no effect because GNAT generates
1733 the same object layout than the G++ compiler.
1735 See @ref{Interfacing to C++} for related information.
1738 @unnumberedsec Pragma Debug
1743 @smallexample @c ada
1744 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1746 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1748 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1752 The procedure call argument has the syntactic form of an expression, meeting
1753 the syntactic requirements for pragmas.
1755 If debug pragmas are not enabled or if the condition is present and evaluates
1756 to False, this pragma has no effect. If debug pragmas are enabled, the
1757 semantics of the pragma is exactly equivalent to the procedure call statement
1758 corresponding to the argument with a terminating semicolon. Pragmas are
1759 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1760 intersperse calls to debug procedures in the middle of declarations. Debug
1761 pragmas can be enabled either by use of the command line switch @option{-gnata}
1762 or by use of the configuration pragma @code{Debug_Policy}.
1764 @node Pragma Debug_Policy
1765 @unnumberedsec Pragma Debug_Policy
1766 @findex Debug_Policy
1770 @smallexample @c ada
1771 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
1775 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1776 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1777 This pragma overrides the effect of the @option{-gnata} switch on the
1780 The implementation defined policy @code{DISABLE} is like
1781 @code{IGNORE} except that it completely disables semantic
1782 checking of the argument to @code{pragma Debug}. This may
1783 be useful when the pragma argument references subprograms
1784 in a with'ed package which is replaced by a dummy package
1785 for the final build.
1787 @node Pragma Detect_Blocking
1788 @unnumberedsec Pragma Detect_Blocking
1789 @findex Detect_Blocking
1793 @smallexample @c ada
1794 pragma Detect_Blocking;
1798 This is a configuration pragma that forces the detection of potentially
1799 blocking operations within a protected operation, and to raise Program_Error
1802 @node Pragma Elaboration_Checks
1803 @unnumberedsec Pragma Elaboration_Checks
1804 @cindex Elaboration control
1805 @findex Elaboration_Checks
1809 @smallexample @c ada
1810 pragma Elaboration_Checks (Dynamic | Static);
1814 This is a configuration pragma that provides control over the
1815 elaboration model used by the compilation affected by the
1816 pragma. If the parameter is @code{Dynamic},
1817 then the dynamic elaboration
1818 model described in the Ada Reference Manual is used, as though
1819 the @option{-gnatE} switch had been specified on the command
1820 line. If the parameter is @code{Static}, then the default GNAT static
1821 model is used. This configuration pragma overrides the setting
1822 of the command line. For full details on the elaboration models
1823 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1824 gnat_ugn, @value{EDITION} User's Guide}.
1826 @node Pragma Eliminate
1827 @unnumberedsec Pragma Eliminate
1828 @cindex Elimination of unused subprograms
1833 @smallexample @c ada
1834 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
1835 [Source_Location =>] STRING_LITERAL);
1839 The string literal given for the source location is a string which
1840 specifies the line number of the occurrence of the entity, using
1841 the syntax for SOURCE_TRACE given below:
1843 @smallexample @c ada
1844 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
1849 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
1851 LINE_NUMBER ::= DIGIT @{DIGIT@}
1855 Spaces around the colon in a @code{Source_Reference} are optional.
1857 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
1858 explicit subprogram declaration, where the @code{entity} name in this
1859 designator appears on the source line specified by the source location.
1861 The source trace that is given as the @code{Source_Location} shall obey the
1862 following rules. The @code{FILE_NAME} is the short name (with no directory
1863 information) of an Ada source file, given using exactly the required syntax
1864 for the underlying file system (e.g. case is important if the underlying
1865 operating system is case sensitive). @code{LINE_NUMBER} gives the line
1866 number of the occurrence of the @code{entity}
1867 as a decimal literal without an exponent or point. If an @code{entity} is not
1868 declared in a generic instantiation (this includes generic subprogram
1869 instances), the source trace includes only one source reference. If an entity
1870 is declared inside a generic instantiation, its source trace (when parsing
1871 from left to right) starts with the source location of the declaration of the
1872 entity in the generic unit and ends with the source location of the
1873 instantiation (it is given in square brackets). This approach is recursively
1874 used in case of nested instantiations: the rightmost (nested most deeply in
1875 square brackets) element of the source trace is the location of the outermost
1876 instantiation, the next to left element is the location of the next (first
1877 nested) instantiation in the code of the corresponding generic unit, and so
1878 on, and the leftmost element (that is out of any square brackets) is the
1879 location of the declaration of the entity to eliminate in a generic unit.
1881 Note that the @code{Source_Location} argument specifies which of a set of
1882 similarly named entities is being eliminated, dealing both with overloading,
1883 and also appearence of the same entity name in different scopes.
1885 This pragma indicates that the given entity is not used in the program to be
1886 compiled and built. The effect of the pragma is to allow the compiler to
1887 eliminate the code or data associated with the named entity. Any reference to
1888 an eliminated entity causes a compile-time or link-time error.
1890 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1891 in a system-independent manner, with unused entities eliminated, without
1892 needing to modify the source text. Normally the required set of
1893 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
1895 Any source file change that removes, splits, or
1896 adds lines may make the set of Eliminate pragmas invalid because their
1897 @code{Source_Location} argument values may get out of date.
1899 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
1900 operation. In this case all the subprograms to which the given operation can
1901 dispatch are considered to be unused (are never called as a result of a direct
1902 or a dispatching call).
1904 @node Pragma Export_Exception
1905 @unnumberedsec Pragma Export_Exception
1907 @findex Export_Exception
1911 @smallexample @c ada
1912 pragma Export_Exception (
1913 [Internal =>] LOCAL_NAME
1914 [, [External =>] EXTERNAL_SYMBOL]
1915 [, [Form =>] Ada | VMS]
1916 [, [Code =>] static_integer_EXPRESSION]);
1920 | static_string_EXPRESSION
1924 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1925 causes the specified exception to be propagated outside of the Ada program,
1926 so that it can be handled by programs written in other OpenVMS languages.
1927 This pragma establishes an external name for an Ada exception and makes the
1928 name available to the OpenVMS Linker as a global symbol. For further details
1929 on this pragma, see the
1930 DEC Ada Language Reference Manual, section 13.9a3.2.
1932 @node Pragma Export_Function
1933 @unnumberedsec Pragma Export_Function
1934 @cindex Argument passing mechanisms
1935 @findex Export_Function
1940 @smallexample @c ada
1941 pragma Export_Function (
1942 [Internal =>] LOCAL_NAME
1943 [, [External =>] EXTERNAL_SYMBOL]
1944 [, [Parameter_Types =>] PARAMETER_TYPES]
1945 [, [Result_Type =>] result_SUBTYPE_MARK]
1946 [, [Mechanism =>] MECHANISM]
1947 [, [Result_Mechanism =>] MECHANISM_NAME]);
1951 | static_string_EXPRESSION
1956 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1960 | subtype_Name ' Access
1964 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1966 MECHANISM_ASSOCIATION ::=
1967 [formal_parameter_NAME =>] MECHANISM_NAME
1972 | Descriptor [([Class =>] CLASS_NAME)]
1973 | Short_Descriptor [([Class =>] CLASS_NAME)]
1975 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1979 Use this pragma to make a function externally callable and optionally
1980 provide information on mechanisms to be used for passing parameter and
1981 result values. We recommend, for the purposes of improving portability,
1982 this pragma always be used in conjunction with a separate pragma
1983 @code{Export}, which must precede the pragma @code{Export_Function}.
1984 GNAT does not require a separate pragma @code{Export}, but if none is
1985 present, @code{Convention Ada} is assumed, which is usually
1986 not what is wanted, so it is usually appropriate to use this
1987 pragma in conjunction with a @code{Export} or @code{Convention}
1988 pragma that specifies the desired foreign convention.
1989 Pragma @code{Export_Function}
1990 (and @code{Export}, if present) must appear in the same declarative
1991 region as the function to which they apply.
1993 @var{internal_name} must uniquely designate the function to which the
1994 pragma applies. If more than one function name exists of this name in
1995 the declarative part you must use the @code{Parameter_Types} and
1996 @code{Result_Type} parameters is mandatory to achieve the required
1997 unique designation. @var{subtype_mark}s in these parameters must
1998 exactly match the subtypes in the corresponding function specification,
1999 using positional notation to match parameters with subtype marks.
2000 The form with an @code{'Access} attribute can be used to match an
2001 anonymous access parameter.
2004 @cindex Passing by descriptor
2005 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2006 The default behavior for Export_Function is to accept either 64bit or
2007 32bit descriptors unless short_descriptor is specified, then only 32bit
2008 descriptors are accepted.
2010 @cindex Suppressing external name
2011 Special treatment is given if the EXTERNAL is an explicit null
2012 string or a static string expressions that evaluates to the null
2013 string. In this case, no external name is generated. This form
2014 still allows the specification of parameter mechanisms.
2016 @node Pragma Export_Object
2017 @unnumberedsec Pragma Export_Object
2018 @findex Export_Object
2022 @smallexample @c ada
2023 pragma Export_Object
2024 [Internal =>] LOCAL_NAME
2025 [, [External =>] EXTERNAL_SYMBOL]
2026 [, [Size =>] EXTERNAL_SYMBOL]
2030 | static_string_EXPRESSION
2034 This pragma designates an object as exported, and apart from the
2035 extended rules for external symbols, is identical in effect to the use of
2036 the normal @code{Export} pragma applied to an object. You may use a
2037 separate Export pragma (and you probably should from the point of view
2038 of portability), but it is not required. @var{Size} is syntax checked,
2039 but otherwise ignored by GNAT@.
2041 @node Pragma Export_Procedure
2042 @unnumberedsec Pragma Export_Procedure
2043 @findex Export_Procedure
2047 @smallexample @c ada
2048 pragma Export_Procedure (
2049 [Internal =>] LOCAL_NAME
2050 [, [External =>] EXTERNAL_SYMBOL]
2051 [, [Parameter_Types =>] PARAMETER_TYPES]
2052 [, [Mechanism =>] MECHANISM]);
2056 | static_string_EXPRESSION
2061 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2065 | subtype_Name ' Access
2069 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2071 MECHANISM_ASSOCIATION ::=
2072 [formal_parameter_NAME =>] MECHANISM_NAME
2077 | Descriptor [([Class =>] CLASS_NAME)]
2078 | Short_Descriptor [([Class =>] CLASS_NAME)]
2080 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2084 This pragma is identical to @code{Export_Function} except that it
2085 applies to a procedure rather than a function and the parameters
2086 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2087 GNAT does not require a separate pragma @code{Export}, but if none is
2088 present, @code{Convention Ada} is assumed, which is usually
2089 not what is wanted, so it is usually appropriate to use this
2090 pragma in conjunction with a @code{Export} or @code{Convention}
2091 pragma that specifies the desired foreign convention.
2094 @cindex Passing by descriptor
2095 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2096 The default behavior for Export_Procedure is to accept either 64bit or
2097 32bit descriptors unless short_descriptor is specified, then only 32bit
2098 descriptors are accepted.
2100 @cindex Suppressing external name
2101 Special treatment is given if the EXTERNAL is an explicit null
2102 string or a static string expressions that evaluates to the null
2103 string. In this case, no external name is generated. This form
2104 still allows the specification of parameter mechanisms.
2106 @node Pragma Export_Value
2107 @unnumberedsec Pragma Export_Value
2108 @findex Export_Value
2112 @smallexample @c ada
2113 pragma Export_Value (
2114 [Value =>] static_integer_EXPRESSION,
2115 [Link_Name =>] static_string_EXPRESSION);
2119 This pragma serves to export a static integer value for external use.
2120 The first argument specifies the value to be exported. The Link_Name
2121 argument specifies the symbolic name to be associated with the integer
2122 value. This pragma is useful for defining a named static value in Ada
2123 that can be referenced in assembly language units to be linked with
2124 the application. This pragma is currently supported only for the
2125 AAMP target and is ignored for other targets.
2127 @node Pragma Export_Valued_Procedure
2128 @unnumberedsec Pragma Export_Valued_Procedure
2129 @findex Export_Valued_Procedure
2133 @smallexample @c ada
2134 pragma Export_Valued_Procedure (
2135 [Internal =>] LOCAL_NAME
2136 [, [External =>] EXTERNAL_SYMBOL]
2137 [, [Parameter_Types =>] PARAMETER_TYPES]
2138 [, [Mechanism =>] MECHANISM]);
2142 | static_string_EXPRESSION
2147 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2151 | subtype_Name ' Access
2155 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2157 MECHANISM_ASSOCIATION ::=
2158 [formal_parameter_NAME =>] MECHANISM_NAME
2163 | Descriptor [([Class =>] CLASS_NAME)]
2164 | Short_Descriptor [([Class =>] CLASS_NAME)]
2166 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2170 This pragma is identical to @code{Export_Procedure} except that the
2171 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2172 mode @code{OUT}, and externally the subprogram is treated as a function
2173 with this parameter as the result of the function. GNAT provides for
2174 this capability to allow the use of @code{OUT} and @code{IN OUT}
2175 parameters in interfacing to external functions (which are not permitted
2177 GNAT does not require a separate pragma @code{Export}, but if none is
2178 present, @code{Convention Ada} is assumed, which is almost certainly
2179 not what is wanted since the whole point of this pragma is to interface
2180 with foreign language functions, so it is usually appropriate to use this
2181 pragma in conjunction with a @code{Export} or @code{Convention}
2182 pragma that specifies the desired foreign convention.
2185 @cindex Passing by descriptor
2186 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2187 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2188 32bit descriptors unless short_descriptor is specified, then only 32bit
2189 descriptors are accepted.
2191 @cindex Suppressing external name
2192 Special treatment is given if the EXTERNAL is an explicit null
2193 string or a static string expressions that evaluates to the null
2194 string. In this case, no external name is generated. This form
2195 still allows the specification of parameter mechanisms.
2197 @node Pragma Extend_System
2198 @unnumberedsec Pragma Extend_System
2199 @cindex @code{system}, extending
2201 @findex Extend_System
2205 @smallexample @c ada
2206 pragma Extend_System ([Name =>] IDENTIFIER);
2210 This pragma is used to provide backwards compatibility with other
2211 implementations that extend the facilities of package @code{System}. In
2212 GNAT, @code{System} contains only the definitions that are present in
2213 the Ada RM@. However, other implementations, notably the DEC Ada 83
2214 implementation, provide many extensions to package @code{System}.
2216 For each such implementation accommodated by this pragma, GNAT provides a
2217 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2218 implementation, which provides the required additional definitions. You
2219 can use this package in two ways. You can @code{with} it in the normal
2220 way and access entities either by selection or using a @code{use}
2221 clause. In this case no special processing is required.
2223 However, if existing code contains references such as
2224 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2225 definitions provided in package @code{System}, you may use this pragma
2226 to extend visibility in @code{System} in a non-standard way that
2227 provides greater compatibility with the existing code. Pragma
2228 @code{Extend_System} is a configuration pragma whose single argument is
2229 the name of the package containing the extended definition
2230 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2231 control of this pragma will be processed using special visibility
2232 processing that looks in package @code{System.Aux_@var{xxx}} where
2233 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2234 package @code{System}, but not found in package @code{System}.
2236 You can use this pragma either to access a predefined @code{System}
2237 extension supplied with the compiler, for example @code{Aux_DEC} or
2238 you can construct your own extension unit following the above
2239 definition. Note that such a package is a child of @code{System}
2240 and thus is considered part of the implementation. To compile
2241 it you will have to use the appropriate switch for compiling
2243 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2246 @node Pragma Extensions_Allowed
2247 @unnumberedsec Pragma Extensions_Allowed
2248 @cindex Ada Extensions
2249 @cindex GNAT Extensions
2250 @findex Extensions_Allowed
2254 @smallexample @c ada
2255 pragma Extensions_Allowed (On | Off);
2259 This configuration pragma enables or disables the implementation
2260 extension mode (the use of Off as a parameter cancels the effect
2261 of the @option{-gnatX} command switch).
2263 In extension mode, the latest version of the Ada language is
2264 implemented (currently Ada 2012), and in addition a small number
2265 of GNAT specific extensions are recognized as follows:
2268 @item Constrained attribute for generic objects
2269 The @code{Constrained} attribute is permitted for objects of
2270 generic types. The result indicates if the corresponding actual
2275 @node Pragma External
2276 @unnumberedsec Pragma External
2281 @smallexample @c ada
2283 [ Convention =>] convention_IDENTIFIER,
2284 [ Entity =>] LOCAL_NAME
2285 [, [External_Name =>] static_string_EXPRESSION ]
2286 [, [Link_Name =>] static_string_EXPRESSION ]);
2290 This pragma is identical in syntax and semantics to pragma
2291 @code{Export} as defined in the Ada Reference Manual. It is
2292 provided for compatibility with some Ada 83 compilers that
2293 used this pragma for exactly the same purposes as pragma
2294 @code{Export} before the latter was standardized.
2296 @node Pragma External_Name_Casing
2297 @unnumberedsec Pragma External_Name_Casing
2298 @cindex Dec Ada 83 casing compatibility
2299 @cindex External Names, casing
2300 @cindex Casing of External names
2301 @findex External_Name_Casing
2305 @smallexample @c ada
2306 pragma External_Name_Casing (
2307 Uppercase | Lowercase
2308 [, Uppercase | Lowercase | As_Is]);
2312 This pragma provides control over the casing of external names associated
2313 with Import and Export pragmas. There are two cases to consider:
2316 @item Implicit external names
2317 Implicit external names are derived from identifiers. The most common case
2318 arises when a standard Ada Import or Export pragma is used with only two
2321 @smallexample @c ada
2322 pragma Import (C, C_Routine);
2326 Since Ada is a case-insensitive language, the spelling of the identifier in
2327 the Ada source program does not provide any information on the desired
2328 casing of the external name, and so a convention is needed. In GNAT the
2329 default treatment is that such names are converted to all lower case
2330 letters. This corresponds to the normal C style in many environments.
2331 The first argument of pragma @code{External_Name_Casing} can be used to
2332 control this treatment. If @code{Uppercase} is specified, then the name
2333 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2334 then the normal default of all lower case letters will be used.
2336 This same implicit treatment is also used in the case of extended DEC Ada 83
2337 compatible Import and Export pragmas where an external name is explicitly
2338 specified using an identifier rather than a string.
2340 @item Explicit external names
2341 Explicit external names are given as string literals. The most common case
2342 arises when a standard Ada Import or Export pragma is used with three
2345 @smallexample @c ada
2346 pragma Import (C, C_Routine, "C_routine");
2350 In this case, the string literal normally provides the exact casing required
2351 for the external name. The second argument of pragma
2352 @code{External_Name_Casing} may be used to modify this behavior.
2353 If @code{Uppercase} is specified, then the name
2354 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2355 then the name will be forced to all lowercase letters. A specification of
2356 @code{As_Is} provides the normal default behavior in which the casing is
2357 taken from the string provided.
2361 This pragma may appear anywhere that a pragma is valid. In particular, it
2362 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2363 case it applies to all subsequent compilations, or it can be used as a program
2364 unit pragma, in which case it only applies to the current unit, or it can
2365 be used more locally to control individual Import/Export pragmas.
2367 It is primarily intended for use with OpenVMS systems, where many
2368 compilers convert all symbols to upper case by default. For interfacing to
2369 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2372 @smallexample @c ada
2373 pragma External_Name_Casing (Uppercase, Uppercase);
2377 to enforce the upper casing of all external symbols.
2379 @node Pragma Fast_Math
2380 @unnumberedsec Pragma Fast_Math
2385 @smallexample @c ada
2390 This is a configuration pragma which activates a mode in which speed is
2391 considered more important for floating-point operations than absolutely
2392 accurate adherence to the requirements of the standard. Currently the
2393 following operations are affected:
2396 @item Complex Multiplication
2397 The normal simple formula for complex multiplication can result in intermediate
2398 overflows for numbers near the end of the range. The Ada standard requires that
2399 this situation be detected and corrected by scaling, but in Fast_Math mode such
2400 cases will simply result in overflow. Note that to take advantage of this you
2401 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2402 under control of the pragma, rather than use the preinstantiated versions.
2405 @node Pragma Favor_Top_Level
2406 @unnumberedsec Pragma Favor_Top_Level
2407 @findex Favor_Top_Level
2411 @smallexample @c ada
2412 pragma Favor_Top_Level (type_NAME);
2416 The named type must be an access-to-subprogram type. This pragma is an
2417 efficiency hint to the compiler, regarding the use of 'Access or
2418 'Unrestricted_Access on nested (non-library-level) subprograms. The
2419 pragma means that nested subprograms are not used with this type, or
2420 are rare, so that the generated code should be efficient in the
2421 top-level case. When this pragma is used, dynamically generated
2422 trampolines may be used on some targets for nested subprograms.
2423 See also the No_Implicit_Dynamic_Code restriction.
2425 @node Pragma Finalize_Storage_Only
2426 @unnumberedsec Pragma Finalize_Storage_Only
2427 @findex Finalize_Storage_Only
2431 @smallexample @c ada
2432 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2436 This pragma allows the compiler not to emit a Finalize call for objects
2437 defined at the library level. This is mostly useful for types where
2438 finalization is only used to deal with storage reclamation since in most
2439 environments it is not necessary to reclaim memory just before terminating
2440 execution, hence the name.
2442 @node Pragma Float_Representation
2443 @unnumberedsec Pragma Float_Representation
2445 @findex Float_Representation
2449 @smallexample @c ada
2450 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2452 FLOAT_REP ::= VAX_Float | IEEE_Float
2456 In the one argument form, this pragma is a configuration pragma which
2457 allows control over the internal representation chosen for the predefined
2458 floating point types declared in the packages @code{Standard} and
2459 @code{System}. On all systems other than OpenVMS, the argument must
2460 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2461 argument may be @code{VAX_Float} to specify the use of the VAX float
2462 format for the floating-point types in Standard. This requires that
2463 the standard runtime libraries be recompiled.
2465 The two argument form specifies the representation to be used for
2466 the specified floating-point type. On all systems other than OpenVMS,
2468 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2469 argument may be @code{VAX_Float} to specify the use of the VAX float
2474 For digits values up to 6, F float format will be used.
2476 For digits values from 7 to 9, D float format will be used.
2478 For digits values from 10 to 15, G float format will be used.
2480 Digits values above 15 are not allowed.
2484 @unnumberedsec Pragma Ident
2489 @smallexample @c ada
2490 pragma Ident (static_string_EXPRESSION);
2494 This pragma provides a string identification in the generated object file,
2495 if the system supports the concept of this kind of identification string.
2496 This pragma is allowed only in the outermost declarative part or
2497 declarative items of a compilation unit. If more than one @code{Ident}
2498 pragma is given, only the last one processed is effective.
2500 On OpenVMS systems, the effect of the pragma is identical to the effect of
2501 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2502 maximum allowed length is 31 characters, so if it is important to
2503 maintain compatibility with this compiler, you should obey this length
2506 @node Pragma Implemented
2507 @unnumberedsec Pragma Implemented
2512 @smallexample @c ada
2513 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2515 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2519 This is an Ada 2012 representation pragma which applies to protected, task
2520 and synchronized interface primitives. The use of pragma Implemented provides
2521 a way to impose a static requirement on the overriding operation by adhering
2522 to one of the three implementation kids: entry, protected procedure or any of
2525 @smallexample @c ada
2526 type Synch_Iface is synchronized interface;
2527 procedure Prim_Op (Obj : in out Iface) is abstract;
2528 pragma Implemented (Prim_Op, By_Protected_Procedure);
2530 protected type Prot_1 is new Synch_Iface with
2531 procedure Prim_Op; -- Legal
2534 protected type Prot_2 is new Synch_Iface with
2535 entry Prim_Op; -- Illegal
2538 task type Task_Typ is new Synch_Iface with
2539 entry Prim_Op; -- Illegal
2544 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2545 Implemented determines the runtime behavior of the requeue. Implementation kind
2546 By_Entry guarantees that the action of requeueing will proceed from an entry to
2547 another entry. Implementation kind By_Protected_Procedure transforms the
2548 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2549 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2550 the target's overriding subprogram kind.
2552 @node Pragma Implicit_Packing
2553 @unnumberedsec Pragma Implicit_Packing
2554 @findex Implicit_Packing
2558 @smallexample @c ada
2559 pragma Implicit_Packing;
2563 This is a configuration pragma that requests implicit packing for packed
2564 arrays for which a size clause is given but no explicit pragma Pack or
2565 specification of Component_Size is present. It also applies to records
2566 where no record representation clause is present. Consider this example:
2568 @smallexample @c ada
2569 type R is array (0 .. 7) of Boolean;
2574 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2575 does not change the layout of a composite object. So the Size clause in the
2576 above example is normally rejected, since the default layout of the array uses
2577 8-bit components, and thus the array requires a minimum of 64 bits.
2579 If this declaration is compiled in a region of code covered by an occurrence
2580 of the configuration pragma Implicit_Packing, then the Size clause in this
2581 and similar examples will cause implicit packing and thus be accepted. For
2582 this implicit packing to occur, the type in question must be an array of small
2583 components whose size is known at compile time, and the Size clause must
2584 specify the exact size that corresponds to the length of the array multiplied
2585 by the size in bits of the component type.
2586 @cindex Array packing
2588 Similarly, the following example shows the use in the record case
2590 @smallexample @c ada
2592 a, b, c, d, e, f, g, h : boolean;
2599 Without a pragma Pack, each Boolean field requires 8 bits, so the
2600 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2601 sufficient. The use of pragma Implicit_Packing allows this record
2602 declaration to compile without an explicit pragma Pack.
2603 @node Pragma Import_Exception
2604 @unnumberedsec Pragma Import_Exception
2606 @findex Import_Exception
2610 @smallexample @c ada
2611 pragma Import_Exception (
2612 [Internal =>] LOCAL_NAME
2613 [, [External =>] EXTERNAL_SYMBOL]
2614 [, [Form =>] Ada | VMS]
2615 [, [Code =>] static_integer_EXPRESSION]);
2619 | static_string_EXPRESSION
2623 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2624 It allows OpenVMS conditions (for example, from OpenVMS system services or
2625 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2626 The pragma specifies that the exception associated with an exception
2627 declaration in an Ada program be defined externally (in non-Ada code).
2628 For further details on this pragma, see the
2629 DEC Ada Language Reference Manual, section 13.9a.3.1.
2631 @node Pragma Import_Function
2632 @unnumberedsec Pragma Import_Function
2633 @findex Import_Function
2637 @smallexample @c ada
2638 pragma Import_Function (
2639 [Internal =>] LOCAL_NAME,
2640 [, [External =>] EXTERNAL_SYMBOL]
2641 [, [Parameter_Types =>] PARAMETER_TYPES]
2642 [, [Result_Type =>] SUBTYPE_MARK]
2643 [, [Mechanism =>] MECHANISM]
2644 [, [Result_Mechanism =>] MECHANISM_NAME]
2645 [, [First_Optional_Parameter =>] IDENTIFIER]);
2649 | static_string_EXPRESSION
2653 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2657 | subtype_Name ' Access
2661 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2663 MECHANISM_ASSOCIATION ::=
2664 [formal_parameter_NAME =>] MECHANISM_NAME
2669 | Descriptor [([Class =>] CLASS_NAME)]
2670 | Short_Descriptor [([Class =>] CLASS_NAME)]
2672 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2676 This pragma is used in conjunction with a pragma @code{Import} to
2677 specify additional information for an imported function. The pragma
2678 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2679 @code{Import_Function} pragma and both must appear in the same
2680 declarative part as the function specification.
2682 The @var{Internal} argument must uniquely designate
2683 the function to which the
2684 pragma applies. If more than one function name exists of this name in
2685 the declarative part you must use the @code{Parameter_Types} and
2686 @var{Result_Type} parameters to achieve the required unique
2687 designation. Subtype marks in these parameters must exactly match the
2688 subtypes in the corresponding function specification, using positional
2689 notation to match parameters with subtype marks.
2690 The form with an @code{'Access} attribute can be used to match an
2691 anonymous access parameter.
2693 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2694 parameters to specify passing mechanisms for the
2695 parameters and result. If you specify a single mechanism name, it
2696 applies to all parameters. Otherwise you may specify a mechanism on a
2697 parameter by parameter basis using either positional or named
2698 notation. If the mechanism is not specified, the default mechanism
2702 @cindex Passing by descriptor
2703 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2704 The default behavior for Import_Function is to pass a 64bit descriptor
2705 unless short_descriptor is specified, then a 32bit descriptor is passed.
2707 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2708 It specifies that the designated parameter and all following parameters
2709 are optional, meaning that they are not passed at the generated code
2710 level (this is distinct from the notion of optional parameters in Ada
2711 where the parameters are passed anyway with the designated optional
2712 parameters). All optional parameters must be of mode @code{IN} and have
2713 default parameter values that are either known at compile time
2714 expressions, or uses of the @code{'Null_Parameter} attribute.
2716 @node Pragma Import_Object
2717 @unnumberedsec Pragma Import_Object
2718 @findex Import_Object
2722 @smallexample @c ada
2723 pragma Import_Object
2724 [Internal =>] LOCAL_NAME
2725 [, [External =>] EXTERNAL_SYMBOL]
2726 [, [Size =>] EXTERNAL_SYMBOL]);
2730 | static_string_EXPRESSION
2734 This pragma designates an object as imported, and apart from the
2735 extended rules for external symbols, is identical in effect to the use of
2736 the normal @code{Import} pragma applied to an object. Unlike the
2737 subprogram case, you need not use a separate @code{Import} pragma,
2738 although you may do so (and probably should do so from a portability
2739 point of view). @var{size} is syntax checked, but otherwise ignored by
2742 @node Pragma Import_Procedure
2743 @unnumberedsec Pragma Import_Procedure
2744 @findex Import_Procedure
2748 @smallexample @c ada
2749 pragma Import_Procedure (
2750 [Internal =>] LOCAL_NAME
2751 [, [External =>] EXTERNAL_SYMBOL]
2752 [, [Parameter_Types =>] PARAMETER_TYPES]
2753 [, [Mechanism =>] MECHANISM]
2754 [, [First_Optional_Parameter =>] IDENTIFIER]);
2758 | static_string_EXPRESSION
2762 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2766 | subtype_Name ' Access
2770 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2772 MECHANISM_ASSOCIATION ::=
2773 [formal_parameter_NAME =>] MECHANISM_NAME
2778 | Descriptor [([Class =>] CLASS_NAME)]
2779 | Short_Descriptor [([Class =>] CLASS_NAME)]
2781 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2785 This pragma is identical to @code{Import_Function} except that it
2786 applies to a procedure rather than a function and the parameters
2787 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2789 @node Pragma Import_Valued_Procedure
2790 @unnumberedsec Pragma Import_Valued_Procedure
2791 @findex Import_Valued_Procedure
2795 @smallexample @c ada
2796 pragma Import_Valued_Procedure (
2797 [Internal =>] LOCAL_NAME
2798 [, [External =>] EXTERNAL_SYMBOL]
2799 [, [Parameter_Types =>] PARAMETER_TYPES]
2800 [, [Mechanism =>] MECHANISM]
2801 [, [First_Optional_Parameter =>] IDENTIFIER]);
2805 | static_string_EXPRESSION
2809 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2813 | subtype_Name ' Access
2817 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2819 MECHANISM_ASSOCIATION ::=
2820 [formal_parameter_NAME =>] MECHANISM_NAME
2825 | Descriptor [([Class =>] CLASS_NAME)]
2826 | Short_Descriptor [([Class =>] CLASS_NAME)]
2828 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2832 This pragma is identical to @code{Import_Procedure} except that the
2833 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2834 mode @code{OUT}, and externally the subprogram is treated as a function
2835 with this parameter as the result of the function. The purpose of this
2836 capability is to allow the use of @code{OUT} and @code{IN OUT}
2837 parameters in interfacing to external functions (which are not permitted
2838 in Ada functions). You may optionally use the @code{Mechanism}
2839 parameters to specify passing mechanisms for the parameters.
2840 If you specify a single mechanism name, it applies to all parameters.
2841 Otherwise you may specify a mechanism on a parameter by parameter
2842 basis using either positional or named notation. If the mechanism is not
2843 specified, the default mechanism is used.
2845 Note that it is important to use this pragma in conjunction with a separate
2846 pragma Import that specifies the desired convention, since otherwise the
2847 default convention is Ada, which is almost certainly not what is required.
2849 @node Pragma Initialize_Scalars
2850 @unnumberedsec Pragma Initialize_Scalars
2851 @findex Initialize_Scalars
2852 @cindex debugging with Initialize_Scalars
2856 @smallexample @c ada
2857 pragma Initialize_Scalars;
2861 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2862 two important differences. First, there is no requirement for the pragma
2863 to be used uniformly in all units of a partition, in particular, it is fine
2864 to use this just for some or all of the application units of a partition,
2865 without needing to recompile the run-time library.
2867 In the case where some units are compiled with the pragma, and some without,
2868 then a declaration of a variable where the type is defined in package
2869 Standard or is locally declared will always be subject to initialization,
2870 as will any declaration of a scalar variable. For composite variables,
2871 whether the variable is initialized may also depend on whether the package
2872 in which the type of the variable is declared is compiled with the pragma.
2874 The other important difference is that you can control the value used
2875 for initializing scalar objects. At bind time, you can select several
2876 options for initialization. You can
2877 initialize with invalid values (similar to Normalize_Scalars, though for
2878 Initialize_Scalars it is not always possible to determine the invalid
2879 values in complex cases like signed component fields with non-standard
2880 sizes). You can also initialize with high or
2881 low values, or with a specified bit pattern. See the users guide for binder
2882 options for specifying these cases.
2884 This means that you can compile a program, and then without having to
2885 recompile the program, you can run it with different values being used
2886 for initializing otherwise uninitialized values, to test if your program
2887 behavior depends on the choice. Of course the behavior should not change,
2888 and if it does, then most likely you have an erroneous reference to an
2889 uninitialized value.
2891 It is even possible to change the value at execution time eliminating even
2892 the need to rebind with a different switch using an environment variable.
2893 See the GNAT users guide for details.
2895 Note that pragma @code{Initialize_Scalars} is particularly useful in
2896 conjunction with the enhanced validity checking that is now provided
2897 in GNAT, which checks for invalid values under more conditions.
2898 Using this feature (see description of the @option{-gnatV} flag in the
2899 users guide) in conjunction with pragma @code{Initialize_Scalars}
2900 provides a powerful new tool to assist in the detection of problems
2901 caused by uninitialized variables.
2903 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2904 effect on the generated code. This may cause your code to be
2905 substantially larger. It may also cause an increase in the amount
2906 of stack required, so it is probably a good idea to turn on stack
2907 checking (see description of stack checking in the GNAT users guide)
2908 when using this pragma.
2910 @node Pragma Inline_Always
2911 @unnumberedsec Pragma Inline_Always
2912 @findex Inline_Always
2916 @smallexample @c ada
2917 pragma Inline_Always (NAME [, NAME]);
2921 Similar to pragma @code{Inline} except that inlining is not subject to
2922 the use of option @option{-gnatn} and the inlining happens regardless of
2923 whether this option is used.
2925 @node Pragma Inline_Generic
2926 @unnumberedsec Pragma Inline_Generic
2927 @findex Inline_Generic
2931 @smallexample @c ada
2932 pragma Inline_Generic (generic_package_NAME);
2936 This is implemented for compatibility with DEC Ada 83 and is recognized,
2937 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2938 by default when using GNAT@.
2940 @node Pragma Interface
2941 @unnumberedsec Pragma Interface
2946 @smallexample @c ada
2948 [Convention =>] convention_identifier,
2949 [Entity =>] local_NAME
2950 [, [External_Name =>] static_string_expression]
2951 [, [Link_Name =>] static_string_expression]);
2955 This pragma is identical in syntax and semantics to
2956 the standard Ada pragma @code{Import}. It is provided for compatibility
2957 with Ada 83. The definition is upwards compatible both with pragma
2958 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2959 with some extended implementations of this pragma in certain Ada 83
2960 implementations. The only difference between pragma @code{Interface}
2961 and pragma @code{Import} is that there is special circuitry to allow
2962 both pragmas to appear for the same subprogram entity (normally it
2963 is illegal to have multiple @code{Import} pragmas. This is useful in
2964 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2967 @node Pragma Interface_Name
2968 @unnumberedsec Pragma Interface_Name
2969 @findex Interface_Name
2973 @smallexample @c ada
2974 pragma Interface_Name (
2975 [Entity =>] LOCAL_NAME
2976 [, [External_Name =>] static_string_EXPRESSION]
2977 [, [Link_Name =>] static_string_EXPRESSION]);
2981 This pragma provides an alternative way of specifying the interface name
2982 for an interfaced subprogram, and is provided for compatibility with Ada
2983 83 compilers that use the pragma for this purpose. You must provide at
2984 least one of @var{External_Name} or @var{Link_Name}.
2986 @node Pragma Interrupt_Handler
2987 @unnumberedsec Pragma Interrupt_Handler
2988 @findex Interrupt_Handler
2992 @smallexample @c ada
2993 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2997 This program unit pragma is supported for parameterless protected procedures
2998 as described in Annex C of the Ada Reference Manual. On the AAMP target
2999 the pragma can also be specified for nonprotected parameterless procedures
3000 that are declared at the library level (which includes procedures
3001 declared at the top level of a library package). In the case of AAMP,
3002 when this pragma is applied to a nonprotected procedure, the instruction
3003 @code{IERET} is generated for returns from the procedure, enabling
3004 maskable interrupts, in place of the normal return instruction.
3006 @node Pragma Interrupt_State
3007 @unnumberedsec Pragma Interrupt_State
3008 @findex Interrupt_State
3012 @smallexample @c ada
3013 pragma Interrupt_State
3015 [State =>] SYSTEM | RUNTIME | USER);
3019 Normally certain interrupts are reserved to the implementation. Any attempt
3020 to attach an interrupt causes Program_Error to be raised, as described in
3021 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3022 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3023 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3024 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3025 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3026 Ada exceptions, or used to implement run-time functions such as the
3027 @code{abort} statement and stack overflow checking.
3029 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3030 such uses of interrupts. It subsumes the functionality of pragma
3031 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3032 available on Windows or VMS. On all other platforms than VxWorks,
3033 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3034 and may be used to mark interrupts required by the board support package
3037 Interrupts can be in one of three states:
3041 The interrupt is reserved (no Ada handler can be installed), and the
3042 Ada run-time may not install a handler. As a result you are guaranteed
3043 standard system default action if this interrupt is raised.
3047 The interrupt is reserved (no Ada handler can be installed). The run time
3048 is allowed to install a handler for internal control purposes, but is
3049 not required to do so.
3053 The interrupt is unreserved. The user may install a handler to provide
3058 These states are the allowed values of the @code{State} parameter of the
3059 pragma. The @code{Name} parameter is a value of the type
3060 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3061 @code{Ada.Interrupts.Names}.
3063 This is a configuration pragma, and the binder will check that there
3064 are no inconsistencies between different units in a partition in how a
3065 given interrupt is specified. It may appear anywhere a pragma is legal.
3067 The effect is to move the interrupt to the specified state.
3069 By declaring interrupts to be SYSTEM, you guarantee the standard system
3070 action, such as a core dump.
3072 By declaring interrupts to be USER, you guarantee that you can install
3075 Note that certain signals on many operating systems cannot be caught and
3076 handled by applications. In such cases, the pragma is ignored. See the
3077 operating system documentation, or the value of the array @code{Reserved}
3078 declared in the spec of package @code{System.OS_Interface}.
3080 Overriding the default state of signals used by the Ada runtime may interfere
3081 with an application's runtime behavior in the cases of the synchronous signals,
3082 and in the case of the signal used to implement the @code{abort} statement.
3084 @node Pragma Invariant
3085 @unnumberedsec Pragma Invariant
3090 @smallexample @c ada
3092 ([Entity =>] private_type_LOCAL_NAME,
3093 [Check =>] EXPRESSION
3094 [,[Message =>] String_Expression]);
3098 This pragma provides exactly the same capabilities as the Invariant aspect
3099 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The Invariant
3100 aspect is fully implemented in Ada 2012 mode, but since it requires the use
3101 of the aspect syntax, which is not available exception in 2012 mode, it is
3102 not possible to use the Invariant aspect in earlier versions of Ada. However
3103 the Invariant pragma may be used in any version of Ada.
3105 The pragma must appear within the visible part of the package specification,
3106 after the type to which its Entity argument appears. As with the Invariant
3107 aspect, the Check expression is not analyzed until the end of the visible
3108 part of the package, so it may contain forward references. The Message
3109 argument, if present, provides the exception message used if the invariant
3110 is violated. If no Message parameter is provided, a default message that
3111 identifies the line on which the pragma appears is used.
3113 It is permissible to have multiple Invariants for the same type entity, in
3114 which case they are and'ed together. It is permissible to use this pragma
3115 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3116 invariant pragma for the same entity.
3118 For further details on the use of this pragma, see the Ada 2012 documentation
3119 of the Invariant aspect.
3121 @node Pragma Keep_Names
3122 @unnumberedsec Pragma Keep_Names
3127 @smallexample @c ada
3128 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3132 The @var{LOCAL_NAME} argument
3133 must refer to an enumeration first subtype
3134 in the current declarative part. The effect is to retain the enumeration
3135 literal names for use by @code{Image} and @code{Value} even if a global
3136 @code{Discard_Names} pragma applies. This is useful when you want to
3137 generally suppress enumeration literal names and for example you therefore
3138 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3139 want to retain the names for specific enumeration types.
3141 @node Pragma License
3142 @unnumberedsec Pragma License
3144 @cindex License checking
3148 @smallexample @c ada
3149 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3153 This pragma is provided to allow automated checking for appropriate license
3154 conditions with respect to the standard and modified GPL@. A pragma
3155 @code{License}, which is a configuration pragma that typically appears at
3156 the start of a source file or in a separate @file{gnat.adc} file, specifies
3157 the licensing conditions of a unit as follows:
3161 This is used for a unit that can be freely used with no license restrictions.
3162 Examples of such units are public domain units, and units from the Ada
3166 This is used for a unit that is licensed under the unmodified GPL, and which
3167 therefore cannot be @code{with}'ed by a restricted unit.
3170 This is used for a unit licensed under the GNAT modified GPL that includes
3171 a special exception paragraph that specifically permits the inclusion of
3172 the unit in programs without requiring the entire program to be released
3176 This is used for a unit that is restricted in that it is not permitted to
3177 depend on units that are licensed under the GPL@. Typical examples are
3178 proprietary code that is to be released under more restrictive license
3179 conditions. Note that restricted units are permitted to @code{with} units
3180 which are licensed under the modified GPL (this is the whole point of the
3186 Normally a unit with no @code{License} pragma is considered to have an
3187 unknown license, and no checking is done. However, standard GNAT headers
3188 are recognized, and license information is derived from them as follows.
3192 A GNAT license header starts with a line containing 78 hyphens. The following
3193 comment text is searched for the appearance of any of the following strings.
3195 If the string ``GNU General Public License'' is found, then the unit is assumed
3196 to have GPL license, unless the string ``As a special exception'' follows, in
3197 which case the license is assumed to be modified GPL@.
3199 If one of the strings
3200 ``This specification is adapted from the Ada Semantic Interface'' or
3201 ``This specification is derived from the Ada Reference Manual'' is found
3202 then the unit is assumed to be unrestricted.
3206 These default actions means that a program with a restricted license pragma
3207 will automatically get warnings if a GPL unit is inappropriately
3208 @code{with}'ed. For example, the program:
3210 @smallexample @c ada
3213 procedure Secret_Stuff is
3219 if compiled with pragma @code{License} (@code{Restricted}) in a
3220 @file{gnat.adc} file will generate the warning:
3225 >>> license of withed unit "Sem_Ch3" is incompatible
3227 2. with GNAT.Sockets;
3228 3. procedure Secret_Stuff is
3232 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3233 compiler and is licensed under the
3234 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3235 run time, and is therefore licensed under the modified GPL@.
3237 @node Pragma Link_With
3238 @unnumberedsec Pragma Link_With
3243 @smallexample @c ada
3244 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3248 This pragma is provided for compatibility with certain Ada 83 compilers.
3249 It has exactly the same effect as pragma @code{Linker_Options} except
3250 that spaces occurring within one of the string expressions are treated
3251 as separators. For example, in the following case:
3253 @smallexample @c ada
3254 pragma Link_With ("-labc -ldef");
3258 results in passing the strings @code{-labc} and @code{-ldef} as two
3259 separate arguments to the linker. In addition pragma Link_With allows
3260 multiple arguments, with the same effect as successive pragmas.
3262 @node Pragma Linker_Alias
3263 @unnumberedsec Pragma Linker_Alias
3264 @findex Linker_Alias
3268 @smallexample @c ada
3269 pragma Linker_Alias (
3270 [Entity =>] LOCAL_NAME,
3271 [Target =>] static_string_EXPRESSION);
3275 @var{LOCAL_NAME} must refer to an object that is declared at the library
3276 level. This pragma establishes the given entity as a linker alias for the
3277 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3278 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3279 @var{static_string_EXPRESSION} in the object file, that is to say no space
3280 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3281 to the same address as @var{static_string_EXPRESSION} by the linker.
3283 The actual linker name for the target must be used (e.g.@: the fully
3284 encoded name with qualification in Ada, or the mangled name in C++),
3285 or it must be declared using the C convention with @code{pragma Import}
3286 or @code{pragma Export}.
3288 Not all target machines support this pragma. On some of them it is accepted
3289 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3291 @smallexample @c ada
3292 -- Example of the use of pragma Linker_Alias
3296 pragma Export (C, i);
3298 new_name_for_i : Integer;
3299 pragma Linker_Alias (new_name_for_i, "i");
3303 @node Pragma Linker_Constructor
3304 @unnumberedsec Pragma Linker_Constructor
3305 @findex Linker_Constructor
3309 @smallexample @c ada
3310 pragma Linker_Constructor (procedure_LOCAL_NAME);
3314 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3315 is declared at the library level. A procedure to which this pragma is
3316 applied will be treated as an initialization routine by the linker.
3317 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3318 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3319 of the executable is called (or immediately after the shared library is
3320 loaded if the procedure is linked in a shared library), in particular
3321 before the Ada run-time environment is set up.
3323 Because of these specific contexts, the set of operations such a procedure
3324 can perform is very limited and the type of objects it can manipulate is
3325 essentially restricted to the elementary types. In particular, it must only
3326 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3328 This pragma is used by GNAT to implement auto-initialization of shared Stand
3329 Alone Libraries, which provides a related capability without the restrictions
3330 listed above. Where possible, the use of Stand Alone Libraries is preferable
3331 to the use of this pragma.
3333 @node Pragma Linker_Destructor
3334 @unnumberedsec Pragma Linker_Destructor
3335 @findex Linker_Destructor
3339 @smallexample @c ada
3340 pragma Linker_Destructor (procedure_LOCAL_NAME);
3344 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3345 is declared at the library level. A procedure to which this pragma is
3346 applied will be treated as a finalization routine by the linker.
3347 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3348 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3349 of the executable has exited (or immediately before the shared library
3350 is unloaded if the procedure is linked in a shared library), in particular
3351 after the Ada run-time environment is shut down.
3353 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3354 because of these specific contexts.
3356 @node Pragma Linker_Section
3357 @unnumberedsec Pragma Linker_Section
3358 @findex Linker_Section
3362 @smallexample @c ada
3363 pragma Linker_Section (
3364 [Entity =>] LOCAL_NAME,
3365 [Section =>] static_string_EXPRESSION);
3369 @var{LOCAL_NAME} must refer to an object that is declared at the library
3370 level. This pragma specifies the name of the linker section for the given
3371 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3372 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3373 section of the executable (assuming the linker doesn't rename the section).
3375 The compiler normally places library-level objects in standard sections
3376 depending on their type: procedures and functions generally go in the
3377 @code{.text} section, initialized variables in the @code{.data} section
3378 and uninitialized variables in the @code{.bss} section.
3380 Other, special sections may exist on given target machines to map special
3381 hardware, for example I/O ports or flash memory. This pragma is a means to
3382 defer the final layout of the executable to the linker, thus fully working
3383 at the symbolic level with the compiler.
3385 Some file formats do not support arbitrary sections so not all target
3386 machines support this pragma. The use of this pragma may cause a program
3387 execution to be erroneous if it is used to place an entity into an
3388 inappropriate section (e.g.@: a modified variable into the @code{.text}
3389 section). See also @code{pragma Persistent_BSS}.
3391 @smallexample @c ada
3392 -- Example of the use of pragma Linker_Section
3396 pragma Volatile (Port_A);
3397 pragma Linker_Section (Port_A, ".bss.port_a");
3400 pragma Volatile (Port_B);
3401 pragma Linker_Section (Port_B, ".bss.port_b");
3405 @node Pragma Long_Float
3406 @unnumberedsec Pragma Long_Float
3412 @smallexample @c ada
3413 pragma Long_Float (FLOAT_FORMAT);
3415 FLOAT_FORMAT ::= D_Float | G_Float
3419 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3420 It allows control over the internal representation chosen for the predefined
3421 type @code{Long_Float} and for floating point type representations with
3422 @code{digits} specified in the range 7 through 15.
3423 For further details on this pragma, see the
3424 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3425 this pragma, the standard runtime libraries must be recompiled.
3427 @node Pragma Machine_Attribute
3428 @unnumberedsec Pragma Machine_Attribute
3429 @findex Machine_Attribute
3433 @smallexample @c ada
3434 pragma Machine_Attribute (
3435 [Entity =>] LOCAL_NAME,
3436 [Attribute_Name =>] static_string_EXPRESSION
3437 [, [Info =>] static_EXPRESSION] );
3441 Machine-dependent attributes can be specified for types and/or
3442 declarations. This pragma is semantically equivalent to
3443 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3444 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3445 in GNU C, where @code{@var{attribute_name}} is recognized by the
3446 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3447 specific macro. A string literal for the optional parameter @var{info}
3448 is transformed into an identifier, which may make this pragma unusable
3449 for some attributes. @xref{Target Attributes,, Defining target-specific
3450 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3451 Internals}, further information.
3454 @unnumberedsec Pragma Main
3460 @smallexample @c ada
3462 (MAIN_OPTION [, MAIN_OPTION]);
3465 [Stack_Size =>] static_integer_EXPRESSION
3466 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3467 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3471 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3472 no effect in GNAT, other than being syntax checked.
3474 @node Pragma Main_Storage
3475 @unnumberedsec Pragma Main_Storage
3477 @findex Main_Storage
3481 @smallexample @c ada
3483 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3485 MAIN_STORAGE_OPTION ::=
3486 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3487 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3491 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3492 no effect in GNAT, other than being syntax checked. Note that the pragma
3493 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3495 @node Pragma No_Body
3496 @unnumberedsec Pragma No_Body
3501 @smallexample @c ada
3506 There are a number of cases in which a package spec does not require a body,
3507 and in fact a body is not permitted. GNAT will not permit the spec to be
3508 compiled if there is a body around. The pragma No_Body allows you to provide
3509 a body file, even in a case where no body is allowed. The body file must
3510 contain only comments and a single No_Body pragma. This is recognized by
3511 the compiler as indicating that no body is logically present.
3513 This is particularly useful during maintenance when a package is modified in
3514 such a way that a body needed before is no longer needed. The provision of a
3515 dummy body with a No_Body pragma ensures that there is no interference from
3516 earlier versions of the package body.
3518 @node Pragma No_Return
3519 @unnumberedsec Pragma No_Return
3524 @smallexample @c ada
3525 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3529 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3530 declarations in the current declarative part. A procedure to which this
3531 pragma is applied may not contain any explicit @code{return} statements.
3532 In addition, if the procedure contains any implicit returns from falling
3533 off the end of a statement sequence, then execution of that implicit
3534 return will cause Program_Error to be raised.
3536 One use of this pragma is to identify procedures whose only purpose is to raise
3537 an exception. Another use of this pragma is to suppress incorrect warnings
3538 about missing returns in functions, where the last statement of a function
3539 statement sequence is a call to such a procedure.
3541 Note that in Ada 2005 mode, this pragma is part of the language, and is
3542 identical in effect to the pragma as implemented in Ada 95 mode.
3544 @node Pragma No_Strict_Aliasing
3545 @unnumberedsec Pragma No_Strict_Aliasing
3546 @findex No_Strict_Aliasing
3550 @smallexample @c ada
3551 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3555 @var{type_LOCAL_NAME} must refer to an access type
3556 declaration in the current declarative part. The effect is to inhibit
3557 strict aliasing optimization for the given type. The form with no
3558 arguments is a configuration pragma which applies to all access types
3559 declared in units to which the pragma applies. For a detailed
3560 description of the strict aliasing optimization, and the situations
3561 in which it must be suppressed, see @ref{Optimization and Strict
3562 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3564 This pragma currently has no effects on access to unconstrained array types.
3566 @node Pragma Normalize_Scalars
3567 @unnumberedsec Pragma Normalize_Scalars
3568 @findex Normalize_Scalars
3572 @smallexample @c ada
3573 pragma Normalize_Scalars;
3577 This is a language defined pragma which is fully implemented in GNAT@. The
3578 effect is to cause all scalar objects that are not otherwise initialized
3579 to be initialized. The initial values are implementation dependent and
3583 @item Standard.Character
3585 Objects whose root type is Standard.Character are initialized to
3586 Character'Last unless the subtype range excludes NUL (in which case
3587 NUL is used). This choice will always generate an invalid value if
3590 @item Standard.Wide_Character
3592 Objects whose root type is Standard.Wide_Character are initialized to
3593 Wide_Character'Last unless the subtype range excludes NUL (in which case
3594 NUL is used). This choice will always generate an invalid value if
3597 @item Standard.Wide_Wide_Character
3599 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3600 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3601 which case NUL is used). This choice will always generate an invalid value if
3606 Objects of an integer type are treated differently depending on whether
3607 negative values are present in the subtype. If no negative values are
3608 present, then all one bits is used as the initial value except in the
3609 special case where zero is excluded from the subtype, in which case
3610 all zero bits are used. This choice will always generate an invalid
3611 value if one exists.
3613 For subtypes with negative values present, the largest negative number
3614 is used, except in the unusual case where this largest negative number
3615 is in the subtype, and the largest positive number is not, in which case
3616 the largest positive value is used. This choice will always generate
3617 an invalid value if one exists.
3619 @item Floating-Point Types
3620 Objects of all floating-point types are initialized to all 1-bits. For
3621 standard IEEE format, this corresponds to a NaN (not a number) which is
3622 indeed an invalid value.
3624 @item Fixed-Point Types
3625 Objects of all fixed-point types are treated as described above for integers,
3626 with the rules applying to the underlying integer value used to represent
3627 the fixed-point value.
3630 Objects of a modular type are initialized to all one bits, except in
3631 the special case where zero is excluded from the subtype, in which
3632 case all zero bits are used. This choice will always generate an
3633 invalid value if one exists.
3635 @item Enumeration types
3636 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3637 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3638 whose Pos value is zero, in which case a code of zero is used. This choice
3639 will always generate an invalid value if one exists.
3643 @node Pragma Obsolescent
3644 @unnumberedsec Pragma Obsolescent
3649 @smallexample @c ada
3652 pragma Obsolescent (
3653 [Message =>] static_string_EXPRESSION
3654 [,[Version =>] Ada_05]]);
3656 pragma Obsolescent (
3658 [,[Message =>] static_string_EXPRESSION
3659 [,[Version =>] Ada_05]] );
3663 This pragma can occur immediately following a declaration of an entity,
3664 including the case of a record component. If no Entity argument is present,
3665 then this declaration is the one to which the pragma applies. If an Entity
3666 parameter is present, it must either match the name of the entity in this
3667 declaration, or alternatively, the pragma can immediately follow an enumeration
3668 type declaration, where the Entity argument names one of the enumeration
3671 This pragma is used to indicate that the named entity
3672 is considered obsolescent and should not be used. Typically this is
3673 used when an API must be modified by eventually removing or modifying
3674 existing subprograms or other entities. The pragma can be used at an
3675 intermediate stage when the entity is still present, but will be
3678 The effect of this pragma is to output a warning message on a reference to
3679 an entity thus marked that the subprogram is obsolescent if the appropriate
3680 warning option in the compiler is activated. If the Message parameter is
3681 present, then a second warning message is given containing this text. In
3682 addition, a reference to the entity is considered to be a violation of pragma
3683 Restrictions (No_Obsolescent_Features).
3685 This pragma can also be used as a program unit pragma for a package,
3686 in which case the entity name is the name of the package, and the
3687 pragma indicates that the entire package is considered
3688 obsolescent. In this case a client @code{with}'ing such a package
3689 violates the restriction, and the @code{with} statement is
3690 flagged with warnings if the warning option is set.
3692 If the Version parameter is present (which must be exactly
3693 the identifier Ada_05, no other argument is allowed), then the
3694 indication of obsolescence applies only when compiling in Ada 2005
3695 mode. This is primarily intended for dealing with the situations
3696 in the predefined library where subprograms or packages
3697 have become defined as obsolescent in Ada 2005
3698 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3700 The following examples show typical uses of this pragma:
3702 @smallexample @c ada
3704 pragma Obsolescent (p, Message => "use pp instead of p");
3709 pragma Obsolescent ("use q2new instead");
3711 type R is new integer;
3714 Message => "use RR in Ada 2005",
3724 type E is (a, bc, 'd', quack);
3725 pragma Obsolescent (Entity => bc)
3726 pragma Obsolescent (Entity => 'd')
3729 (a, b : character) return character;
3730 pragma Obsolescent (Entity => "+");
3735 Note that, as for all pragmas, if you use a pragma argument identifier,
3736 then all subsequent parameters must also use a pragma argument identifier.
3737 So if you specify "Entity =>" for the Entity argument, and a Message
3738 argument is present, it must be preceded by "Message =>".
3740 @node Pragma Optimize_Alignment
3741 @unnumberedsec Pragma Optimize_Alignment
3742 @findex Optimize_Alignment
3743 @cindex Alignment, default settings
3747 @smallexample @c ada
3748 pragma Optimize_Alignment (TIME | SPACE | OFF);
3752 This is a configuration pragma which affects the choice of default alignments
3753 for types where no alignment is explicitly specified. There is a time/space
3754 trade-off in the selection of these values. Large alignments result in more
3755 efficient code, at the expense of larger data space, since sizes have to be
3756 increased to match these alignments. Smaller alignments save space, but the
3757 access code is slower. The normal choice of default alignments (which is what
3758 you get if you do not use this pragma, or if you use an argument of OFF),
3759 tries to balance these two requirements.
3761 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3762 First any packed record is given an alignment of 1. Second, if a size is given
3763 for the type, then the alignment is chosen to avoid increasing this size. For
3766 @smallexample @c ada
3776 In the default mode, this type gets an alignment of 4, so that access to the
3777 Integer field X are efficient. But this means that objects of the type end up
3778 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3779 allowed to be bigger than the size of the type, but it can waste space if for
3780 example fields of type R appear in an enclosing record. If the above type is
3781 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3783 Specifying TIME causes larger default alignments to be chosen in the case of
3784 small types with sizes that are not a power of 2. For example, consider:
3786 @smallexample @c ada
3798 The default alignment for this record is normally 1, but if this type is
3799 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3800 to 4, which wastes space for objects of the type, since they are now 4 bytes
3801 long, but results in more efficient access when the whole record is referenced.
3803 As noted above, this is a configuration pragma, and there is a requirement
3804 that all units in a partition be compiled with a consistent setting of the
3805 optimization setting. This would normally be achieved by use of a configuration
3806 pragma file containing the appropriate setting. The exception to this rule is
3807 that units with an explicit configuration pragma in the same file as the source
3808 unit are excluded from the consistency check, as are all predefined units. The
3809 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3810 pragma appears at the start of the file.
3812 @node Pragma Ordered
3813 @unnumberedsec Pragma Ordered
3815 @findex pragma @code{Ordered}
3819 @smallexample @c ada
3820 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3824 Most enumeration types are from a conceptual point of view unordered.
3825 For example, consider:
3827 @smallexample @c ada
3828 type Color is (Red, Blue, Green, Yellow);
3832 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
3833 but really these relations make no sense; the enumeration type merely
3834 specifies a set of possible colors, and the order is unimportant.
3836 For unordered enumeration types, it is generally a good idea if
3837 clients avoid comparisons (other than equality or inequality) and
3838 explicit ranges. (A @emph{client} is a unit where the type is referenced,
3839 other than the unit where the type is declared, its body, and its subunits.)
3840 For example, if code buried in some client says:
3842 @smallexample @c ada
3843 if Current_Color < Yellow then ...
3844 if Current_Color in Blue .. Green then ...
3848 then the client code is relying on the order, which is undesirable.
3849 It makes the code hard to read and creates maintenance difficulties if
3850 entries have to be added to the enumeration type. Instead,
3851 the code in the client should list the possibilities, or an
3852 appropriate subtype should be declared in the unit that declares
3853 the original enumeration type. E.g., the following subtype could
3854 be declared along with the type @code{Color}:
3856 @smallexample @c ada
3857 subtype RBG is Color range Red .. Green;
3861 and then the client could write:
3863 @smallexample @c ada
3864 if Current_Color in RBG then ...
3865 if Current_Color = Blue or Current_Color = Green then ...
3869 However, some enumeration types are legitimately ordered from a conceptual
3870 point of view. For example, if you declare:
3872 @smallexample @c ada
3873 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3877 then the ordering imposed by the language is reasonable, and
3878 clients can depend on it, writing for example:
3880 @smallexample @c ada
3881 if D in Mon .. Fri then ...
3886 The pragma @option{Ordered} is provided to mark enumeration types that
3887 are conceptually ordered, alerting the reader that clients may depend
3888 on the ordering. GNAT provides a pragma to mark enumerations as ordered
3889 rather than one to mark them as unordered, since in our experience,
3890 the great majority of enumeration types are conceptually unordered.
3892 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
3893 and @code{Wide_Wide_Character}
3894 are considered to be ordered types, so each is declared with a
3895 pragma @code{Ordered} in package @code{Standard}.
3897 Normally pragma @code{Ordered} serves only as documentation and a guide for
3898 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
3899 requests warnings for inappropriate uses (comparisons and explicit
3900 subranges) for unordered types. If this switch is used, then any
3901 enumeration type not marked with pragma @code{Ordered} will be considered
3902 as unordered, and will generate warnings for inappropriate uses.
3904 For additional information please refer to the description of the
3905 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
3907 @node Pragma Passive
3908 @unnumberedsec Pragma Passive
3913 @smallexample @c ada
3914 pragma Passive [(Semaphore | No)];
3918 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3919 compatibility with DEC Ada 83 implementations, where it is used within a
3920 task definition to request that a task be made passive. If the argument
3921 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3922 treats the pragma as an assertion that the containing task is passive
3923 and that optimization of context switch with this task is permitted and
3924 desired. If the argument @code{No} is present, the task must not be
3925 optimized. GNAT does not attempt to optimize any tasks in this manner
3926 (since protected objects are available in place of passive tasks).
3928 @node Pragma Persistent_BSS
3929 @unnumberedsec Pragma Persistent_BSS
3930 @findex Persistent_BSS
3934 @smallexample @c ada
3935 pragma Persistent_BSS [(LOCAL_NAME)]
3939 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3940 section. On some targets the linker and loader provide for special
3941 treatment of this section, allowing a program to be reloaded without
3942 affecting the contents of this data (hence the name persistent).
3944 There are two forms of usage. If an argument is given, it must be the
3945 local name of a library level object, with no explicit initialization
3946 and whose type is potentially persistent. If no argument is given, then
3947 the pragma is a configuration pragma, and applies to all library level
3948 objects with no explicit initialization of potentially persistent types.
3950 A potentially persistent type is a scalar type, or a non-tagged,
3951 non-discriminated record, all of whose components have no explicit
3952 initialization and are themselves of a potentially persistent type,
3953 or an array, all of whose constraints are static, and whose component
3954 type is potentially persistent.
3956 If this pragma is used on a target where this feature is not supported,
3957 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3959 @node Pragma Polling
3960 @unnumberedsec Pragma Polling
3965 @smallexample @c ada
3966 pragma Polling (ON | OFF);
3970 This pragma controls the generation of polling code. This is normally off.
3971 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3972 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3973 runtime library, and can be found in file @file{a-excpol.adb}.
3975 Pragma @code{Polling} can appear as a configuration pragma (for example it
3976 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3977 can be used in the statement or declaration sequence to control polling
3980 A call to the polling routine is generated at the start of every loop and
3981 at the start of every subprogram call. This guarantees that the @code{Poll}
3982 routine is called frequently, and places an upper bound (determined by
3983 the complexity of the code) on the period between two @code{Poll} calls.
3985 The primary purpose of the polling interface is to enable asynchronous
3986 aborts on targets that cannot otherwise support it (for example Windows
3987 NT), but it may be used for any other purpose requiring periodic polling.
3988 The standard version is null, and can be replaced by a user program. This
3989 will require re-compilation of the @code{Ada.Exceptions} package that can
3990 be found in files @file{a-except.ads} and @file{a-except.adb}.
3992 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3993 distribution) is used to enable the asynchronous abort capability on
3994 targets that do not normally support the capability. The version of
3995 @code{Poll} in this file makes a call to the appropriate runtime routine
3996 to test for an abort condition.
3998 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3999 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4002 @node Pragma Postcondition
4003 @unnumberedsec Pragma Postcondition
4004 @cindex Postconditions
4005 @cindex Checks, postconditions
4006 @findex Postconditions
4010 @smallexample @c ada
4011 pragma Postcondition (
4012 [Check =>] Boolean_Expression
4013 [,[Message =>] String_Expression]);
4017 The @code{Postcondition} pragma allows specification of automatic
4018 postcondition checks for subprograms. These checks are similar to
4019 assertions, but are automatically inserted just prior to the return
4020 statements of the subprogram with which they are associated (including
4021 implicit returns at the end of procedure bodies and associated
4022 exception handlers).
4024 In addition, the boolean expression which is the condition which
4025 must be true may contain references to function'Result in the case
4026 of a function to refer to the returned value.
4028 @code{Postcondition} pragmas may appear either immediately following the
4029 (separate) declaration of a subprogram, or at the start of the
4030 declarations of a subprogram body. Only other pragmas may intervene
4031 (that is appear between the subprogram declaration and its
4032 postconditions, or appear before the postcondition in the
4033 declaration sequence in a subprogram body). In the case of a
4034 postcondition appearing after a subprogram declaration, the
4035 formal arguments of the subprogram are visible, and can be
4036 referenced in the postcondition expressions.
4038 The postconditions are collected and automatically tested just
4039 before any return (implicit or explicit) in the subprogram body.
4040 A postcondition is only recognized if postconditions are active
4041 at the time the pragma is encountered. The compiler switch @option{gnata}
4042 turns on all postconditions by default, and pragma @code{Check_Policy}
4043 with an identifier of @code{Postcondition} can also be used to
4044 control whether postconditions are active.
4046 The general approach is that postconditions are placed in the spec
4047 if they represent functional aspects which make sense to the client.
4048 For example we might have:
4050 @smallexample @c ada
4051 function Direction return Integer;
4052 pragma Postcondition
4053 (Direction'Result = +1
4055 Direction'Result = -1);
4059 which serves to document that the result must be +1 or -1, and
4060 will test that this is the case at run time if postcondition
4063 Postconditions within the subprogram body can be used to
4064 check that some internal aspect of the implementation,
4065 not visible to the client, is operating as expected.
4066 For instance if a square root routine keeps an internal
4067 counter of the number of times it is called, then we
4068 might have the following postcondition:
4070 @smallexample @c ada
4071 Sqrt_Calls : Natural := 0;
4073 function Sqrt (Arg : Float) return Float is
4074 pragma Postcondition
4075 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4081 As this example, shows, the use of the @code{Old} attribute
4082 is often useful in postconditions to refer to the state on
4083 entry to the subprogram.
4085 Note that postconditions are only checked on normal returns
4086 from the subprogram. If an abnormal return results from
4087 raising an exception, then the postconditions are not checked.
4089 If a postcondition fails, then the exception
4090 @code{System.Assertions.Assert_Failure} is raised. If
4091 a message argument was supplied, then the given string
4092 will be used as the exception message. If no message
4093 argument was supplied, then the default message has
4094 the form "Postcondition failed at file:line". The
4095 exception is raised in the context of the subprogram
4096 body, so it is possible to catch postcondition failures
4097 within the subprogram body itself.
4099 Within a package spec, normal visibility rules
4100 in Ada would prevent forward references within a
4101 postcondition pragma to functions defined later in
4102 the same package. This would introduce undesirable
4103 ordering constraints. To avoid this problem, all
4104 postcondition pragmas are analyzed at the end of
4105 the package spec, allowing forward references.
4107 The following example shows that this even allows
4108 mutually recursive postconditions as in:
4110 @smallexample @c ada
4111 package Parity_Functions is
4112 function Odd (X : Natural) return Boolean;
4113 pragma Postcondition
4117 (x /= 0 and then Even (X - 1))));
4119 function Even (X : Natural) return Boolean;
4120 pragma Postcondition
4124 (x /= 1 and then Odd (X - 1))));
4126 end Parity_Functions;
4130 There are no restrictions on the complexity or form of
4131 conditions used within @code{Postcondition} pragmas.
4132 The following example shows that it is even possible
4133 to verify performance behavior.
4135 @smallexample @c ada
4138 Performance : constant Float;
4139 -- Performance constant set by implementation
4140 -- to match target architecture behavior.
4142 procedure Treesort (Arg : String);
4143 -- Sorts characters of argument using N*logN sort
4144 pragma Postcondition
4145 (Float (Clock - Clock'Old) <=
4146 Float (Arg'Length) *
4147 log (Float (Arg'Length)) *
4153 Note: postcondition pragmas associated with subprograms that are
4154 marked as Inline_Always, or those marked as Inline with front-end
4155 inlining (-gnatN option set) are accepted and legality-checked
4156 by the compiler, but are ignored at run-time even if postcondition
4157 checking is enabled.
4159 @node Pragma Precondition
4160 @unnumberedsec Pragma Precondition
4161 @cindex Preconditions
4162 @cindex Checks, preconditions
4163 @findex Preconditions
4167 @smallexample @c ada
4168 pragma Precondition (
4169 [Check =>] Boolean_Expression
4170 [,[Message =>] String_Expression]);
4174 The @code{Precondition} pragma is similar to @code{Postcondition}
4175 except that the corresponding checks take place immediately upon
4176 entry to the subprogram, and if a precondition fails, the exception
4177 is raised in the context of the caller, and the attribute 'Result
4178 cannot be used within the precondition expression.
4180 Otherwise, the placement and visibility rules are identical to those
4181 described for postconditions. The following is an example of use
4182 within a package spec:
4184 @smallexample @c ada
4185 package Math_Functions is
4187 function Sqrt (Arg : Float) return Float;
4188 pragma Precondition (Arg >= 0.0)
4194 @code{Precondition} pragmas may appear either immediately following the
4195 (separate) declaration of a subprogram, or at the start of the
4196 declarations of a subprogram body. Only other pragmas may intervene
4197 (that is appear between the subprogram declaration and its
4198 postconditions, or appear before the postcondition in the
4199 declaration sequence in a subprogram body).
4201 Note: postcondition pragmas associated with subprograms that are
4202 marked as Inline_Always, or those marked as Inline with front-end
4203 inlining (-gnatN option set) are accepted and legality-checked
4204 by the compiler, but are ignored at run-time even if postcondition
4205 checking is enabled.
4207 @node Pragma Profile (Ravenscar)
4208 @unnumberedsec Pragma Profile (Ravenscar)
4213 @smallexample @c ada
4214 pragma Profile (Ravenscar);
4218 A configuration pragma that establishes the following set of configuration
4222 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4223 [RM D.2.2] Tasks are dispatched following a preemptive
4224 priority-ordered scheduling policy.
4226 @item Locking_Policy (Ceiling_Locking)
4227 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4228 the ceiling priority of the corresponding protected object.
4230 @c @item Detect_Blocking
4231 @c This pragma forces the detection of potentially blocking operations within a
4232 @c protected operation, and to raise Program_Error if that happens.
4236 plus the following set of restrictions:
4239 @item Max_Entry_Queue_Length => 1
4240 Defines the maximum number of calls that are queued on a (protected) entry.
4241 Note that this restrictions is checked at run time. Violation of this
4242 restriction results in the raising of Program_Error exception at the point of
4243 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4244 always 1 and hence no task can be queued on a protected entry.
4246 @item Max_Protected_Entries => 1
4247 [RM D.7] Specifies the maximum number of entries per protected type. The
4248 bounds of every entry family of a protected unit shall be static, or shall be
4249 defined by a discriminant of a subtype whose corresponding bound is static.
4250 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4252 @item Max_Task_Entries => 0
4253 [RM D.7] Specifies the maximum number of entries
4254 per task. The bounds of every entry family
4255 of a task unit shall be static, or shall be
4256 defined by a discriminant of a subtype whose
4257 corresponding bound is static. A value of zero
4258 indicates that no rendezvous are possible. For
4259 the Profile (Ravenscar), the value of Max_Task_Entries is always
4262 @item No_Abort_Statements
4263 [RM D.7] There are no abort_statements, and there are
4264 no calls to Task_Identification.Abort_Task.
4266 @item No_Dynamic_Attachment
4267 There is no call to any of the operations defined in package Ada.Interrupts
4268 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4269 Detach_Handler, and Reference).
4271 @item No_Dynamic_Priorities
4272 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4274 @item No_Implicit_Heap_Allocations
4275 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4277 @item No_Local_Protected_Objects
4278 Protected objects and access types that designate
4279 such objects shall be declared only at library level.
4281 @item No_Local_Timing_Events
4282 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4283 declared at the library level.
4285 @item No_Protected_Type_Allocators
4286 There are no allocators for protected types or
4287 types containing protected subcomponents.
4289 @item No_Relative_Delay
4290 There are no delay_relative statements.
4292 @item No_Requeue_Statements
4293 Requeue statements are not allowed.
4295 @item No_Select_Statements
4296 There are no select_statements.
4298 @item No_Specific_Termination_Handlers
4299 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4300 or to Ada.Task_Termination.Specific_Handler.
4302 @item No_Task_Allocators
4303 [RM D.7] There are no allocators for task types
4304 or types containing task subcomponents.
4306 @item No_Task_Hierarchy
4307 [RM D.7] All (non-environment) tasks depend
4308 directly on the environment task of the partition.
4310 @item No_Task_Termination
4311 Tasks which terminate are erroneous.
4313 @item Simple_Barriers
4314 Entry barrier condition expressions shall be either static
4315 boolean expressions or boolean objects which are declared in
4316 the protected type which contains the entry.
4320 The Ravenscar profile also includes the following restrictions that specify
4321 that there are no semantic dependences on the corresponding predefined
4325 @item No_Dependence => Ada.Asynchronous_Task_Control
4326 @item No_Dependence => Ada.Calendar
4327 @item No_Dependence => Ada.Execution_Time.Group_Budget
4328 @item No_Dependence => Ada.Execution_Time.Timers
4329 @item No_Dependence => Ada.Task_Attributes
4330 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4335 This set of configuration pragmas and restrictions correspond to the
4336 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4337 published by the @cite{International Real-Time Ada Workshop}, 1997,
4338 and whose most recent description is available at
4339 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4341 The original definition of the profile was revised at subsequent IRTAW
4342 meetings. It has been included in the ISO
4343 @cite{Guide for the Use of the Ada Programming Language in High
4344 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4345 the next revision of the standard. The formal definition given by
4346 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4347 AI-305) available at
4348 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4349 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4351 The above set is a superset of the restrictions provided by pragma
4352 @code{Profile (Restricted)}, it includes six additional restrictions
4353 (@code{Simple_Barriers}, @code{No_Select_Statements},
4354 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4355 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4356 that pragma @code{Profile (Ravenscar)}, like the pragma
4357 @code{Profile (Restricted)},
4358 automatically causes the use of a simplified,
4359 more efficient version of the tasking run-time system.
4361 @node Pragma Profile (Restricted)
4362 @unnumberedsec Pragma Profile (Restricted)
4363 @findex Restricted Run Time
4367 @smallexample @c ada
4368 pragma Profile (Restricted);
4372 A configuration pragma that establishes the following set of restrictions:
4375 @item No_Abort_Statements
4376 @item No_Entry_Queue
4377 @item No_Task_Hierarchy
4378 @item No_Task_Allocators
4379 @item No_Dynamic_Priorities
4380 @item No_Terminate_Alternatives
4381 @item No_Dynamic_Attachment
4382 @item No_Protected_Type_Allocators
4383 @item No_Local_Protected_Objects
4384 @item No_Requeue_Statements
4385 @item No_Task_Attributes_Package
4386 @item Max_Asynchronous_Select_Nesting = 0
4387 @item Max_Task_Entries = 0
4388 @item Max_Protected_Entries = 1
4389 @item Max_Select_Alternatives = 0
4393 This set of restrictions causes the automatic selection of a simplified
4394 version of the run time that provides improved performance for the
4395 limited set of tasking functionality permitted by this set of restrictions.
4397 @node Pragma Psect_Object
4398 @unnumberedsec Pragma Psect_Object
4399 @findex Psect_Object
4403 @smallexample @c ada
4404 pragma Psect_Object (
4405 [Internal =>] LOCAL_NAME,
4406 [, [External =>] EXTERNAL_SYMBOL]
4407 [, [Size =>] EXTERNAL_SYMBOL]);
4411 | static_string_EXPRESSION
4415 This pragma is identical in effect to pragma @code{Common_Object}.
4417 @node Pragma Pure_Function
4418 @unnumberedsec Pragma Pure_Function
4419 @findex Pure_Function
4423 @smallexample @c ada
4424 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4428 This pragma appears in the same declarative part as a function
4429 declaration (or a set of function declarations if more than one
4430 overloaded declaration exists, in which case the pragma applies
4431 to all entities). It specifies that the function @code{Entity} is
4432 to be considered pure for the purposes of code generation. This means
4433 that the compiler can assume that there are no side effects, and
4434 in particular that two calls with identical arguments produce the
4435 same result. It also means that the function can be used in an
4438 Note that, quite deliberately, there are no static checks to try
4439 to ensure that this promise is met, so @code{Pure_Function} can be used
4440 with functions that are conceptually pure, even if they do modify
4441 global variables. For example, a square root function that is
4442 instrumented to count the number of times it is called is still
4443 conceptually pure, and can still be optimized, even though it
4444 modifies a global variable (the count). Memo functions are another
4445 example (where a table of previous calls is kept and consulted to
4446 avoid re-computation).
4448 Note also that the normal rules excluding optimization of subprograms
4449 in pure units (when parameter types are descended from System.Address,
4450 or when the full view of a parameter type is limited), do not apply
4451 for the Pure_Function case. If you explicitly specify Pure_Function,
4452 the compiler may optimize away calls with identical arguments, and
4453 if that results in unexpected behavior, the proper action is not to
4454 use the pragma for subprograms that are not (conceptually) pure.
4457 Note: Most functions in a @code{Pure} package are automatically pure, and
4458 there is no need to use pragma @code{Pure_Function} for such functions. One
4459 exception is any function that has at least one formal of type
4460 @code{System.Address} or a type derived from it. Such functions are not
4461 considered pure by default, since the compiler assumes that the
4462 @code{Address} parameter may be functioning as a pointer and that the
4463 referenced data may change even if the address value does not.
4464 Similarly, imported functions are not considered to be pure by default,
4465 since there is no way of checking that they are in fact pure. The use
4466 of pragma @code{Pure_Function} for such a function will override these default
4467 assumption, and cause the compiler to treat a designated subprogram as pure
4470 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4471 applies to the underlying renamed function. This can be used to
4472 disambiguate cases of overloading where some but not all functions
4473 in a set of overloaded functions are to be designated as pure.
4475 If pragma @code{Pure_Function} is applied to a library level function, the
4476 function is also considered pure from an optimization point of view, but the
4477 unit is not a Pure unit in the categorization sense. So for example, a function
4478 thus marked is free to @code{with} non-pure units.
4480 @node Pragma Restriction_Warnings
4481 @unnumberedsec Pragma Restriction_Warnings
4482 @findex Restriction_Warnings
4486 @smallexample @c ada
4487 pragma Restriction_Warnings
4488 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4492 This pragma allows a series of restriction identifiers to be
4493 specified (the list of allowed identifiers is the same as for
4494 pragma @code{Restrictions}). For each of these identifiers
4495 the compiler checks for violations of the restriction, but
4496 generates a warning message rather than an error message
4497 if the restriction is violated.
4500 @unnumberedsec Pragma Shared
4504 This pragma is provided for compatibility with Ada 83. The syntax and
4505 semantics are identical to pragma Atomic.
4507 @node Pragma Short_Circuit_And_Or
4508 @unnumberedsec Pragma Short_Circuit_And_Or
4509 @findex Short_Circuit_And_Or
4512 This configuration pragma causes any occurrence of the AND operator applied to
4513 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4514 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4515 may be useful in the context of certification protocols requiring the use of
4516 short-circuited logical operators. If this configuration pragma occurs locally
4517 within the file being compiled, it applies only to the file being compiled.
4518 There is no requirement that all units in a partition use this option.
4520 @node Pragma Short_Descriptors
4521 @unnumberedsec Pragma Short_Descriptors
4522 @findex Short_Descriptors
4526 @smallexample @c ada
4527 pragma Short_Descriptors
4531 In VMS versions of the compiler, this configuration pragma causes all
4532 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4533 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4534 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4537 @node Pragma Source_File_Name
4538 @unnumberedsec Pragma Source_File_Name
4539 @findex Source_File_Name
4543 @smallexample @c ada
4544 pragma Source_File_Name (
4545 [Unit_Name =>] unit_NAME,
4546 Spec_File_Name => STRING_LITERAL,
4547 [Index => INTEGER_LITERAL]);
4549 pragma Source_File_Name (
4550 [Unit_Name =>] unit_NAME,
4551 Body_File_Name => STRING_LITERAL,
4552 [Index => INTEGER_LITERAL]);
4556 Use this to override the normal naming convention. It is a configuration
4557 pragma, and so has the usual applicability of configuration pragmas
4558 (i.e.@: it applies to either an entire partition, or to all units in a
4559 compilation, or to a single unit, depending on how it is used.
4560 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4561 the second argument is required, and indicates whether this is the file
4562 name for the spec or for the body.
4564 The optional Index argument should be used when a file contains multiple
4565 units, and when you do not want to use @code{gnatchop} to separate then
4566 into multiple files (which is the recommended procedure to limit the
4567 number of recompilations that are needed when some sources change).
4568 For instance, if the source file @file{source.ada} contains
4570 @smallexample @c ada
4582 you could use the following configuration pragmas:
4584 @smallexample @c ada
4585 pragma Source_File_Name
4586 (B, Spec_File_Name => "source.ada", Index => 1);
4587 pragma Source_File_Name
4588 (A, Body_File_Name => "source.ada", Index => 2);
4591 Note that the @code{gnatname} utility can also be used to generate those
4592 configuration pragmas.
4594 Another form of the @code{Source_File_Name} pragma allows
4595 the specification of patterns defining alternative file naming schemes
4596 to apply to all files.
4598 @smallexample @c ada
4599 pragma Source_File_Name
4600 ( [Spec_File_Name =>] STRING_LITERAL
4601 [,[Casing =>] CASING_SPEC]
4602 [,[Dot_Replacement =>] STRING_LITERAL]);
4604 pragma Source_File_Name
4605 ( [Body_File_Name =>] STRING_LITERAL
4606 [,[Casing =>] CASING_SPEC]
4607 [,[Dot_Replacement =>] STRING_LITERAL]);
4609 pragma Source_File_Name
4610 ( [Subunit_File_Name =>] STRING_LITERAL
4611 [,[Casing =>] CASING_SPEC]
4612 [,[Dot_Replacement =>] STRING_LITERAL]);
4614 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4618 The first argument is a pattern that contains a single asterisk indicating
4619 the point at which the unit name is to be inserted in the pattern string
4620 to form the file name. The second argument is optional. If present it
4621 specifies the casing of the unit name in the resulting file name string.
4622 The default is lower case. Finally the third argument allows for systematic
4623 replacement of any dots in the unit name by the specified string literal.
4625 Note that Source_File_Name pragmas should not be used if you are using
4626 project files. The reason for this rule is that the project manager is not
4627 aware of these pragmas, and so other tools that use the projet file would not
4628 be aware of the intended naming conventions. If you are using project files,
4629 file naming is controlled by Source_File_Name_Project pragmas, which are
4630 usually supplied automatically by the project manager. A pragma
4631 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
4633 For more details on the use of the @code{Source_File_Name} pragma,
4634 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4635 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4638 @node Pragma Source_File_Name_Project
4639 @unnumberedsec Pragma Source_File_Name_Project
4640 @findex Source_File_Name_Project
4643 This pragma has the same syntax and semantics as pragma Source_File_Name.
4644 It is only allowed as a stand alone configuration pragma.
4645 It cannot appear after a @ref{Pragma Source_File_Name}, and
4646 most importantly, once pragma Source_File_Name_Project appears,
4647 no further Source_File_Name pragmas are allowed.
4649 The intention is that Source_File_Name_Project pragmas are always
4650 generated by the Project Manager in a manner consistent with the naming
4651 specified in a project file, and when naming is controlled in this manner,
4652 it is not permissible to attempt to modify this naming scheme using
4653 Source_File_Name or Source_File_Name_Project pragmas (which would not be
4654 known to the project manager).
4656 @node Pragma Source_Reference
4657 @unnumberedsec Pragma Source_Reference
4658 @findex Source_Reference
4662 @smallexample @c ada
4663 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4667 This pragma must appear as the first line of a source file.
4668 @var{integer_literal} is the logical line number of the line following
4669 the pragma line (for use in error messages and debugging
4670 information). @var{string_literal} is a static string constant that
4671 specifies the file name to be used in error messages and debugging
4672 information. This is most notably used for the output of @code{gnatchop}
4673 with the @option{-r} switch, to make sure that the original unchopped
4674 source file is the one referred to.
4676 The second argument must be a string literal, it cannot be a static
4677 string expression other than a string literal. This is because its value
4678 is needed for error messages issued by all phases of the compiler.
4680 @node Pragma Static_Elaboration_Desired
4681 @unnumberedsec Pragma Static_Elaboration_Desired
4682 @findex Static_Elaboration_Desired
4686 @smallexample @c ada
4687 pragma Static_Elaboration_Desired;
4691 This pragma is used to indicate that the compiler should attempt to initialize
4692 statically the objects declared in the library unit to which the pragma applies,
4693 when these objects are initialized (explicitly or implicitly) by an aggregate.
4694 In the absence of this pragma, aggregates in object declarations are expanded
4695 into assignments and loops, even when the aggregate components are static
4696 constants. When the aggregate is present the compiler builds a static expression
4697 that requires no run-time code, so that the initialized object can be placed in
4698 read-only data space. If the components are not static, or the aggregate has
4699 more that 100 components, the compiler emits a warning that the pragma cannot
4700 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
4701 construction of larger aggregates with static components that include an others
4704 @node Pragma Stream_Convert
4705 @unnumberedsec Pragma Stream_Convert
4706 @findex Stream_Convert
4710 @smallexample @c ada
4711 pragma Stream_Convert (
4712 [Entity =>] type_LOCAL_NAME,
4713 [Read =>] function_NAME,
4714 [Write =>] function_NAME);
4718 This pragma provides an efficient way of providing stream functions for
4719 types defined in packages. Not only is it simpler to use than declaring
4720 the necessary functions with attribute representation clauses, but more
4721 significantly, it allows the declaration to made in such a way that the
4722 stream packages are not loaded unless they are needed. The use of
4723 the Stream_Convert pragma adds no overhead at all, unless the stream
4724 attributes are actually used on the designated type.
4726 The first argument specifies the type for which stream functions are
4727 provided. The second parameter provides a function used to read values
4728 of this type. It must name a function whose argument type may be any
4729 subtype, and whose returned type must be the type given as the first
4730 argument to the pragma.
4732 The meaning of the @var{Read}
4733 parameter is that if a stream attribute directly
4734 or indirectly specifies reading of the type given as the first parameter,
4735 then a value of the type given as the argument to the Read function is
4736 read from the stream, and then the Read function is used to convert this
4737 to the required target type.
4739 Similarly the @var{Write} parameter specifies how to treat write attributes
4740 that directly or indirectly apply to the type given as the first parameter.
4741 It must have an input parameter of the type specified by the first parameter,
4742 and the return type must be the same as the input type of the Read function.
4743 The effect is to first call the Write function to convert to the given stream
4744 type, and then write the result type to the stream.
4746 The Read and Write functions must not be overloaded subprograms. If necessary
4747 renamings can be supplied to meet this requirement.
4748 The usage of this attribute is best illustrated by a simple example, taken
4749 from the GNAT implementation of package Ada.Strings.Unbounded:
4751 @smallexample @c ada
4752 function To_Unbounded (S : String)
4753 return Unbounded_String
4754 renames To_Unbounded_String;
4756 pragma Stream_Convert
4757 (Unbounded_String, To_Unbounded, To_String);
4761 The specifications of the referenced functions, as given in the Ada
4762 Reference Manual are:
4764 @smallexample @c ada
4765 function To_Unbounded_String (Source : String)
4766 return Unbounded_String;
4768 function To_String (Source : Unbounded_String)
4773 The effect is that if the value of an unbounded string is written to a stream,
4774 then the representation of the item in the stream is in the same format that
4775 would be used for @code{Standard.String'Output}, and this same representation
4776 is expected when a value of this type is read from the stream. Note that the
4777 value written always includes the bounds, even for Unbounded_String'Write,
4778 since Unbounded_String is not an array type.
4780 @node Pragma Style_Checks
4781 @unnumberedsec Pragma Style_Checks
4782 @findex Style_Checks
4786 @smallexample @c ada
4787 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4788 On | Off [, LOCAL_NAME]);
4792 This pragma is used in conjunction with compiler switches to control the
4793 built in style checking provided by GNAT@. The compiler switches, if set,
4794 provide an initial setting for the switches, and this pragma may be used
4795 to modify these settings, or the settings may be provided entirely by
4796 the use of the pragma. This pragma can be used anywhere that a pragma
4797 is legal, including use as a configuration pragma (including use in
4798 the @file{gnat.adc} file).
4800 The form with a string literal specifies which style options are to be
4801 activated. These are additive, so they apply in addition to any previously
4802 set style check options. The codes for the options are the same as those
4803 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4804 For example the following two methods can be used to enable
4809 @smallexample @c ada
4810 pragma Style_Checks ("l");
4815 gcc -c -gnatyl @dots{}
4820 The form ALL_CHECKS activates all standard checks (its use is equivalent
4821 to the use of the @code{gnaty} switch with no options. @xref{Top,
4822 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4823 @value{EDITION} User's Guide}, for details.)
4825 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4826 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4827 options (i.e. equivalent to -gnatyg).
4829 The forms with @code{Off} and @code{On}
4830 can be used to temporarily disable style checks
4831 as shown in the following example:
4833 @smallexample @c ada
4837 pragma Style_Checks ("k"); -- requires keywords in lower case
4838 pragma Style_Checks (Off); -- turn off style checks
4839 NULL; -- this will not generate an error message
4840 pragma Style_Checks (On); -- turn style checks back on
4841 NULL; -- this will generate an error message
4845 Finally the two argument form is allowed only if the first argument is
4846 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4847 for the specified entity, as shown in the following example:
4849 @smallexample @c ada
4853 pragma Style_Checks ("r"); -- require consistency of identifier casing
4855 Rf1 : Integer := ARG; -- incorrect, wrong case
4856 pragma Style_Checks (Off, Arg);
4857 Rf2 : Integer := ARG; -- OK, no error
4860 @node Pragma Subtitle
4861 @unnumberedsec Pragma Subtitle
4866 @smallexample @c ada
4867 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4871 This pragma is recognized for compatibility with other Ada compilers
4872 but is ignored by GNAT@.
4874 @node Pragma Suppress
4875 @unnumberedsec Pragma Suppress
4880 @smallexample @c ada
4881 pragma Suppress (Identifier [, [On =>] Name]);
4885 This is a standard pragma, and supports all the check names required in
4886 the RM. It is included here because GNAT recognizes one additional check
4887 name: @code{Alignment_Check} which can be used to suppress alignment checks
4888 on addresses used in address clauses. Such checks can also be suppressed
4889 by suppressing range checks, but the specific use of @code{Alignment_Check}
4890 allows suppression of alignment checks without suppressing other range checks.
4892 Note that pragma Suppress gives the compiler permission to omit
4893 checks, but does not require the compiler to omit checks. The compiler
4894 will generate checks if they are essentially free, even when they are
4895 suppressed. In particular, if the compiler can prove that a certain
4896 check will necessarily fail, it will generate code to do an
4897 unconditional ``raise'', even if checks are suppressed. The compiler
4900 Of course, run-time checks are omitted whenever the compiler can prove
4901 that they will not fail, whether or not checks are suppressed.
4903 @node Pragma Suppress_All
4904 @unnumberedsec Pragma Suppress_All
4905 @findex Suppress_All
4909 @smallexample @c ada
4910 pragma Suppress_All;
4914 This pragma can appear anywhere within a unit.
4915 The effect is to apply @code{Suppress (All_Checks)} to the unit
4916 in which it appears. This pragma is implemented for compatibility with DEC
4917 Ada 83 usage where it appears at the end of a unit, and for compatibility
4918 with Rational Ada, where it appears as a program unit pragma.
4919 The use of the standard Ada pragma @code{Suppress (All_Checks)}
4920 as a normal configuration pragma is the preferred usage in GNAT@.
4922 @node Pragma Suppress_Exception_Locations
4923 @unnumberedsec Pragma Suppress_Exception_Locations
4924 @findex Suppress_Exception_Locations
4928 @smallexample @c ada
4929 pragma Suppress_Exception_Locations;
4933 In normal mode, a raise statement for an exception by default generates
4934 an exception message giving the file name and line number for the location
4935 of the raise. This is useful for debugging and logging purposes, but this
4936 entails extra space for the strings for the messages. The configuration
4937 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4938 generation of these strings, with the result that space is saved, but the
4939 exception message for such raises is null. This configuration pragma may
4940 appear in a global configuration pragma file, or in a specific unit as
4941 usual. It is not required that this pragma be used consistently within
4942 a partition, so it is fine to have some units within a partition compiled
4943 with this pragma and others compiled in normal mode without it.
4945 @node Pragma Suppress_Initialization
4946 @unnumberedsec Pragma Suppress_Initialization
4947 @findex Suppress_Initialization
4948 @cindex Suppressing initialization
4949 @cindex Initialization, suppression of
4953 @smallexample @c ada
4954 pragma Suppress_Initialization ([Entity =>] type_Name);
4958 This pragma suppresses any implicit or explicit initialization
4959 associated with the given type name for all variables of this type,
4960 including initialization resulting from the use of pragmas
4961 Normalize_Scalars or Initialize_Scalars.
4963 This is considered a representation item, so it cannot be given after
4964 the type is frozen. It applies to all subsequent object declarations,
4965 and also any allocator that creates objects of the type.
4967 If the pragma is given for the first subtype, then it is considered
4968 to apply to the base type and all its subtypes. If the pragma is given
4969 for other than a first subtype, then it applies only to the given subtype.
4970 The pragma may not be given after the type is frozen.
4972 @node Pragma Task_Info
4973 @unnumberedsec Pragma Task_Info
4978 @smallexample @c ada
4979 pragma Task_Info (EXPRESSION);
4983 This pragma appears within a task definition (like pragma
4984 @code{Priority}) and applies to the task in which it appears. The
4985 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4986 The @code{Task_Info} pragma provides system dependent control over
4987 aspects of tasking implementation, for example, the ability to map
4988 tasks to specific processors. For details on the facilities available
4989 for the version of GNAT that you are using, see the documentation
4990 in the spec of package System.Task_Info in the runtime
4993 @node Pragma Task_Name
4994 @unnumberedsec Pragma Task_Name
4999 @smallexample @c ada
5000 pragma Task_Name (string_EXPRESSION);
5004 This pragma appears within a task definition (like pragma
5005 @code{Priority}) and applies to the task in which it appears. The
5006 argument must be of type String, and provides a name to be used for
5007 the task instance when the task is created. Note that this expression
5008 is not required to be static, and in particular, it can contain
5009 references to task discriminants. This facility can be used to
5010 provide different names for different tasks as they are created,
5011 as illustrated in the example below.
5013 The task name is recorded internally in the run-time structures
5014 and is accessible to tools like the debugger. In addition the
5015 routine @code{Ada.Task_Identification.Image} will return this
5016 string, with a unique task address appended.
5018 @smallexample @c ada
5019 -- Example of the use of pragma Task_Name
5021 with Ada.Task_Identification;
5022 use Ada.Task_Identification;
5023 with Text_IO; use Text_IO;
5026 type Astring is access String;
5028 task type Task_Typ (Name : access String) is
5029 pragma Task_Name (Name.all);
5032 task body Task_Typ is
5033 Nam : constant String := Image (Current_Task);
5035 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5038 type Ptr_Task is access Task_Typ;
5039 Task_Var : Ptr_Task;
5043 new Task_Typ (new String'("This is task 1"));
5045 new Task_Typ (new String'("This is task 2"));
5049 @node Pragma Task_Storage
5050 @unnumberedsec Pragma Task_Storage
5051 @findex Task_Storage
5054 @smallexample @c ada
5055 pragma Task_Storage (
5056 [Task_Type =>] LOCAL_NAME,
5057 [Top_Guard =>] static_integer_EXPRESSION);
5061 This pragma specifies the length of the guard area for tasks. The guard
5062 area is an additional storage area allocated to a task. A value of zero
5063 means that either no guard area is created or a minimal guard area is
5064 created, depending on the target. This pragma can appear anywhere a
5065 @code{Storage_Size} attribute definition clause is allowed for a task
5068 @node Pragma Test_Case
5069 @unnumberedsec Pragma Test_Case
5075 @smallexample @c ada
5077 [Name =>] static_string_Expression
5078 ,[Mode =>] (Nominal | Robustness)
5079 [, Requires => Boolean_Expression]
5080 [, Ensures => Boolean_Expression]);
5084 The @code{Test_Case} pragma allows defining fine-grain specifications
5085 for use by testing and verification tools. The compiler checks its
5086 validity but the presence of pragma @code{Test_Case} does not lead to
5087 any modification of the code generated by the compiler.
5089 @code{Test_Case} pragmas may only appear immediately following the
5090 (separate) declaration of a subprogram in a package declaration, inside
5091 a package spec unit. Only other pragmas may intervene (that is appear
5092 between the subprogram declaration and a test case).
5094 The compiler checks that boolean expressions given in @code{Requires} and
5095 @code{Ensures} are valid, where the rules for @code{Requires} are the
5096 same as the rule for an expression in @code{Precondition} and the rules
5097 for @code{Ensures} are the same as the rule for an expression in
5098 @code{Postcondition}. In particular, attributes @code{'Old} and
5099 @code{'Result} can only be used within the @code{Ensures}
5100 expression. The following is an example of use within a package spec:
5102 @smallexample @c ada
5103 package Math_Functions is
5105 function Sqrt (Arg : Float) return Float;
5106 pragma Test_Case (Name => "Test 1",
5108 Requires => Arg < 100,
5109 Ensures => Sqrt'Result < 10);
5115 The meaning of a test case is that, if the associated subprogram is
5116 executed in a context where @code{Requires} holds, then @code{Ensures}
5117 should hold when the subprogram returns. Mode @code{Nominal} indicates
5118 that the input context should satisfy the precondition of the
5119 subprogram, and the output context should then satisfy its
5120 postcondition. More @code{Robustness} indicates that the pre- and
5121 postcondition of the subprogram should be ignored for this test case.
5123 @node Pragma Thread_Local_Storage
5124 @unnumberedsec Pragma Thread_Local_Storage
5125 @findex Thread_Local_Storage
5126 @cindex Task specific storage
5127 @cindex TLS (Thread Local Storage)
5130 @smallexample @c ada
5131 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5135 This pragma specifies that the specified entity, which must be
5136 a variable declared in a library level package, is to be marked as
5137 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5138 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5139 (and hence each Ada task) to see a distinct copy of the variable.
5141 The variable may not have default initialization, and if there is
5142 an explicit initialization, it must be either @code{null} for an
5143 access variable, or a static expression for a scalar variable.
5144 This provides a low level mechanism similar to that provided by
5145 the @code{Ada.Task_Attributes} package, but much more efficient
5146 and is also useful in writing interface code that will interact
5147 with foreign threads.
5149 If this pragma is used on a system where @code{TLS} is not supported,
5150 then an error message will be generated and the program will be rejected.
5152 @node Pragma Time_Slice
5153 @unnumberedsec Pragma Time_Slice
5158 @smallexample @c ada
5159 pragma Time_Slice (static_duration_EXPRESSION);
5163 For implementations of GNAT on operating systems where it is possible
5164 to supply a time slice value, this pragma may be used for this purpose.
5165 It is ignored if it is used in a system that does not allow this control,
5166 or if it appears in other than the main program unit.
5168 Note that the effect of this pragma is identical to the effect of the
5169 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5172 @unnumberedsec Pragma Title
5177 @smallexample @c ada
5178 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5181 [Title =>] STRING_LITERAL,
5182 | [Subtitle =>] STRING_LITERAL
5186 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5187 pragma used in DEC Ada 83 implementations to provide a title and/or
5188 subtitle for the program listing. The program listing generated by GNAT
5189 does not have titles or subtitles.
5191 Unlike other pragmas, the full flexibility of named notation is allowed
5192 for this pragma, i.e.@: the parameters may be given in any order if named
5193 notation is used, and named and positional notation can be mixed
5194 following the normal rules for procedure calls in Ada.
5196 @node Pragma Unchecked_Union
5197 @unnumberedsec Pragma Unchecked_Union
5199 @findex Unchecked_Union
5203 @smallexample @c ada
5204 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5208 This pragma is used to specify a representation of a record type that is
5209 equivalent to a C union. It was introduced as a GNAT implementation defined
5210 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5211 pragma, making it language defined, and GNAT fully implements this extended
5212 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5213 details, consult the Ada 2005 Reference Manual, section B.3.3.
5215 @node Pragma Unimplemented_Unit
5216 @unnumberedsec Pragma Unimplemented_Unit
5217 @findex Unimplemented_Unit
5221 @smallexample @c ada
5222 pragma Unimplemented_Unit;
5226 If this pragma occurs in a unit that is processed by the compiler, GNAT
5227 aborts with the message @samp{@var{xxx} not implemented}, where
5228 @var{xxx} is the name of the current compilation unit. This pragma is
5229 intended to allow the compiler to handle unimplemented library units in
5232 The abort only happens if code is being generated. Thus you can use
5233 specs of unimplemented packages in syntax or semantic checking mode.
5235 @node Pragma Universal_Aliasing
5236 @unnumberedsec Pragma Universal_Aliasing
5237 @findex Universal_Aliasing
5241 @smallexample @c ada
5242 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5246 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5247 declarative part. The effect is to inhibit strict type-based aliasing
5248 optimization for the given type. In other words, the effect is as though
5249 access types designating this type were subject to pragma No_Strict_Aliasing.
5250 For a detailed description of the strict aliasing optimization, and the
5251 situations in which it must be suppressed, @xref{Optimization and Strict
5252 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5254 @node Pragma Universal_Data
5255 @unnumberedsec Pragma Universal_Data
5256 @findex Universal_Data
5260 @smallexample @c ada
5261 pragma Universal_Data [(library_unit_Name)];
5265 This pragma is supported only for the AAMP target and is ignored for
5266 other targets. The pragma specifies that all library-level objects
5267 (Counter 0 data) associated with the library unit are to be accessed
5268 and updated using universal addressing (24-bit addresses for AAMP5)
5269 rather than the default of 16-bit Data Environment (DENV) addressing.
5270 Use of this pragma will generally result in less efficient code for
5271 references to global data associated with the library unit, but
5272 allows such data to be located anywhere in memory. This pragma is
5273 a library unit pragma, but can also be used as a configuration pragma
5274 (including use in the @file{gnat.adc} file). The functionality
5275 of this pragma is also available by applying the -univ switch on the
5276 compilations of units where universal addressing of the data is desired.
5278 @node Pragma Unmodified
5279 @unnumberedsec Pragma Unmodified
5281 @cindex Warnings, unmodified
5285 @smallexample @c ada
5286 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5290 This pragma signals that the assignable entities (variables,
5291 @code{out} parameters, @code{in out} parameters) whose names are listed are
5292 deliberately not assigned in the current source unit. This
5293 suppresses warnings about the
5294 entities being referenced but not assigned, and in addition a warning will be
5295 generated if one of these entities is in fact assigned in the
5296 same unit as the pragma (or in the corresponding body, or one
5299 This is particularly useful for clearly signaling that a particular
5300 parameter is not modified, even though the spec suggests that it might
5303 @node Pragma Unreferenced
5304 @unnumberedsec Pragma Unreferenced
5305 @findex Unreferenced
5306 @cindex Warnings, unreferenced
5310 @smallexample @c ada
5311 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5312 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5316 This pragma signals that the entities whose names are listed are
5317 deliberately not referenced in the current source unit. This
5318 suppresses warnings about the
5319 entities being unreferenced, and in addition a warning will be
5320 generated if one of these entities is in fact referenced in the
5321 same unit as the pragma (or in the corresponding body, or one
5324 This is particularly useful for clearly signaling that a particular
5325 parameter is not referenced in some particular subprogram implementation
5326 and that this is deliberate. It can also be useful in the case of
5327 objects declared only for their initialization or finalization side
5330 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5331 current scope, then the entity most recently declared is the one to which
5332 the pragma applies. Note that in the case of accept formals, the pragma
5333 Unreferenced may appear immediately after the keyword @code{do} which
5334 allows the indication of whether or not accept formals are referenced
5335 or not to be given individually for each accept statement.
5337 The left hand side of an assignment does not count as a reference for the
5338 purpose of this pragma. Thus it is fine to assign to an entity for which
5339 pragma Unreferenced is given.
5341 Note that if a warning is desired for all calls to a given subprogram,
5342 regardless of whether they occur in the same unit as the subprogram
5343 declaration, then this pragma should not be used (calls from another
5344 unit would not be flagged); pragma Obsolescent can be used instead
5345 for this purpose, see @xref{Pragma Obsolescent}.
5347 The second form of pragma @code{Unreferenced} is used within a context
5348 clause. In this case the arguments must be unit names of units previously
5349 mentioned in @code{with} clauses (similar to the usage of pragma
5350 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5351 units and unreferenced entities within these units.
5353 @node Pragma Unreferenced_Objects
5354 @unnumberedsec Pragma Unreferenced_Objects
5355 @findex Unreferenced_Objects
5356 @cindex Warnings, unreferenced
5360 @smallexample @c ada
5361 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5365 This pragma signals that for the types or subtypes whose names are
5366 listed, objects which are declared with one of these types or subtypes may
5367 not be referenced, and if no references appear, no warnings are given.
5369 This is particularly useful for objects which are declared solely for their
5370 initialization and finalization effect. Such variables are sometimes referred
5371 to as RAII variables (Resource Acquisition Is Initialization). Using this
5372 pragma on the relevant type (most typically a limited controlled type), the
5373 compiler will automatically suppress unwanted warnings about these variables
5374 not being referenced.
5376 @node Pragma Unreserve_All_Interrupts
5377 @unnumberedsec Pragma Unreserve_All_Interrupts
5378 @findex Unreserve_All_Interrupts
5382 @smallexample @c ada
5383 pragma Unreserve_All_Interrupts;
5387 Normally certain interrupts are reserved to the implementation. Any attempt
5388 to attach an interrupt causes Program_Error to be raised, as described in
5389 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5390 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5391 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5392 interrupt execution.
5394 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5395 a program, then all such interrupts are unreserved. This allows the
5396 program to handle these interrupts, but disables their standard
5397 functions. For example, if this pragma is used, then pressing
5398 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5399 a program can then handle the @code{SIGINT} interrupt as it chooses.
5401 For a full list of the interrupts handled in a specific implementation,
5402 see the source code for the spec of @code{Ada.Interrupts.Names} in
5403 file @file{a-intnam.ads}. This is a target dependent file that contains the
5404 list of interrupts recognized for a given target. The documentation in
5405 this file also specifies what interrupts are affected by the use of
5406 the @code{Unreserve_All_Interrupts} pragma.
5408 For a more general facility for controlling what interrupts can be
5409 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5410 of the @code{Unreserve_All_Interrupts} pragma.
5412 @node Pragma Unsuppress
5413 @unnumberedsec Pragma Unsuppress
5418 @smallexample @c ada
5419 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5423 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5424 there is no corresponding pragma @code{Suppress} in effect, it has no
5425 effect. The range of the effect is the same as for pragma
5426 @code{Suppress}. The meaning of the arguments is identical to that used
5427 in pragma @code{Suppress}.
5429 One important application is to ensure that checks are on in cases where
5430 code depends on the checks for its correct functioning, so that the code
5431 will compile correctly even if the compiler switches are set to suppress
5434 @node Pragma Use_VADS_Size
5435 @unnumberedsec Pragma Use_VADS_Size
5436 @cindex @code{Size}, VADS compatibility
5437 @findex Use_VADS_Size
5441 @smallexample @c ada
5442 pragma Use_VADS_Size;
5446 This is a configuration pragma. In a unit to which it applies, any use
5447 of the 'Size attribute is automatically interpreted as a use of the
5448 'VADS_Size attribute. Note that this may result in incorrect semantic
5449 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5450 the handling of existing code which depends on the interpretation of Size
5451 as implemented in the VADS compiler. See description of the VADS_Size
5452 attribute for further details.
5454 @node Pragma Validity_Checks
5455 @unnumberedsec Pragma Validity_Checks
5456 @findex Validity_Checks
5460 @smallexample @c ada
5461 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5465 This pragma is used in conjunction with compiler switches to control the
5466 built-in validity checking provided by GNAT@. The compiler switches, if set
5467 provide an initial setting for the switches, and this pragma may be used
5468 to modify these settings, or the settings may be provided entirely by
5469 the use of the pragma. This pragma can be used anywhere that a pragma
5470 is legal, including use as a configuration pragma (including use in
5471 the @file{gnat.adc} file).
5473 The form with a string literal specifies which validity options are to be
5474 activated. The validity checks are first set to include only the default
5475 reference manual settings, and then a string of letters in the string
5476 specifies the exact set of options required. The form of this string
5477 is exactly as described for the @option{-gnatVx} compiler switch (see the
5478 GNAT users guide for details). For example the following two methods
5479 can be used to enable validity checking for mode @code{in} and
5480 @code{in out} subprogram parameters:
5484 @smallexample @c ada
5485 pragma Validity_Checks ("im");
5490 gcc -c -gnatVim @dots{}
5495 The form ALL_CHECKS activates all standard checks (its use is equivalent
5496 to the use of the @code{gnatva} switch.
5498 The forms with @code{Off} and @code{On}
5499 can be used to temporarily disable validity checks
5500 as shown in the following example:
5502 @smallexample @c ada
5506 pragma Validity_Checks ("c"); -- validity checks for copies
5507 pragma Validity_Checks (Off); -- turn off validity checks
5508 A := B; -- B will not be validity checked
5509 pragma Validity_Checks (On); -- turn validity checks back on
5510 A := C; -- C will be validity checked
5513 @node Pragma Volatile
5514 @unnumberedsec Pragma Volatile
5519 @smallexample @c ada
5520 pragma Volatile (LOCAL_NAME);
5524 This pragma is defined by the Ada Reference Manual, and the GNAT
5525 implementation is fully conformant with this definition. The reason it
5526 is mentioned in this section is that a pragma of the same name was supplied
5527 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5528 implementation of pragma Volatile is upwards compatible with the
5529 implementation in DEC Ada 83.
5531 @node Pragma Warnings
5532 @unnumberedsec Pragma Warnings
5537 @smallexample @c ada
5538 pragma Warnings (On | Off);
5539 pragma Warnings (On | Off, LOCAL_NAME);
5540 pragma Warnings (static_string_EXPRESSION);
5541 pragma Warnings (On | Off, static_string_EXPRESSION);
5545 Normally warnings are enabled, with the output being controlled by
5546 the command line switch. Warnings (@code{Off}) turns off generation of
5547 warnings until a Warnings (@code{On}) is encountered or the end of the
5548 current unit. If generation of warnings is turned off using this
5549 pragma, then no warning messages are output, regardless of the
5550 setting of the command line switches.
5552 The form with a single argument may be used as a configuration pragma.
5554 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5555 the specified entity. This suppression is effective from the point where
5556 it occurs till the end of the extended scope of the variable (similar to
5557 the scope of @code{Suppress}).
5559 The form with a single static_string_EXPRESSION argument provides more precise
5560 control over which warnings are active. The string is a list of letters
5561 specifying which warnings are to be activated and which deactivated. The
5562 code for these letters is the same as the string used in the command
5563 line switch controlling warnings. For a brief summary, use the gnatmake
5564 command with no arguments, which will generate usage information containing
5565 the list of warnings switches supported. For
5566 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5570 The specified warnings will be in effect until the end of the program
5571 or another pragma Warnings is encountered. The effect of the pragma is
5572 cumulative. Initially the set of warnings is the standard default set
5573 as possibly modified by compiler switches. Then each pragma Warning
5574 modifies this set of warnings as specified. This form of the pragma may
5575 also be used as a configuration pragma.
5577 The fourth form, with an On|Off parameter and a string, is used to
5578 control individual messages, based on their text. The string argument
5579 is a pattern that is used to match against the text of individual
5580 warning messages (not including the initial "warning: " tag).
5582 The pattern may contain asterisks, which match zero or more characters in
5583 the message. For example, you can use
5584 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5585 message @code{warning: 960 bits of "a" unused}. No other regular
5586 expression notations are permitted. All characters other than asterisk in
5587 these three specific cases are treated as literal characters in the match.
5589 There are two ways to use this pragma. The OFF form can be used as a
5590 configuration pragma. The effect is to suppress all warnings (if any)
5591 that match the pattern string throughout the compilation.
5593 The second usage is to suppress a warning locally, and in this case, two
5594 pragmas must appear in sequence:
5596 @smallexample @c ada
5597 pragma Warnings (Off, Pattern);
5598 @dots{} code where given warning is to be suppressed
5599 pragma Warnings (On, Pattern);
5603 In this usage, the pattern string must match in the Off and On pragmas,
5604 and at least one matching warning must be suppressed.
5606 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5607 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5608 be useful in checking whether obsolete pragmas in existing programs are hiding
5611 Note: pragma Warnings does not affect the processing of style messages. See
5612 separate entry for pragma Style_Checks for control of style messages.
5614 @node Pragma Weak_External
5615 @unnumberedsec Pragma Weak_External
5616 @findex Weak_External
5620 @smallexample @c ada
5621 pragma Weak_External ([Entity =>] LOCAL_NAME);
5625 @var{LOCAL_NAME} must refer to an object that is declared at the library
5626 level. This pragma specifies that the given entity should be marked as a
5627 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5628 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5629 of a regular symbol, that is to say a symbol that does not have to be
5630 resolved by the linker if used in conjunction with a pragma Import.
5632 When a weak symbol is not resolved by the linker, its address is set to
5633 zero. This is useful in writing interfaces to external modules that may
5634 or may not be linked in the final executable, for example depending on
5635 configuration settings.
5637 If a program references at run time an entity to which this pragma has been
5638 applied, and the corresponding symbol was not resolved at link time, then
5639 the execution of the program is erroneous. It is not erroneous to take the
5640 Address of such an entity, for example to guard potential references,
5641 as shown in the example below.
5643 Some file formats do not support weak symbols so not all target machines
5644 support this pragma.
5646 @smallexample @c ada
5647 -- Example of the use of pragma Weak_External
5649 package External_Module is
5651 pragma Import (C, key);
5652 pragma Weak_External (key);
5653 function Present return boolean;
5654 end External_Module;
5656 with System; use System;
5657 package body External_Module is
5658 function Present return boolean is
5660 return key'Address /= System.Null_Address;
5662 end External_Module;
5665 @node Pragma Wide_Character_Encoding
5666 @unnumberedsec Pragma Wide_Character_Encoding
5667 @findex Wide_Character_Encoding
5671 @smallexample @c ada
5672 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5676 This pragma specifies the wide character encoding to be used in program
5677 source text appearing subsequently. It is a configuration pragma, but may
5678 also be used at any point that a pragma is allowed, and it is permissible
5679 to have more than one such pragma in a file, allowing multiple encodings
5680 to appear within the same file.
5682 The argument can be an identifier or a character literal. In the identifier
5683 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5684 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5685 case it is correspondingly one of the characters @samp{h}, @samp{u},
5686 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5688 Note that when the pragma is used within a file, it affects only the
5689 encoding within that file, and does not affect withed units, specs,
5692 @node Implementation Defined Attributes
5693 @chapter Implementation Defined Attributes
5694 Ada defines (throughout the Ada reference manual,
5695 summarized in Annex K),
5696 a set of attributes that provide useful additional functionality in all
5697 areas of the language. These language defined attributes are implemented
5698 in GNAT and work as described in the Ada Reference Manual.
5700 In addition, Ada allows implementations to define additional
5701 attributes whose meaning is defined by the implementation. GNAT provides
5702 a number of these implementation-dependent attributes which can be used
5703 to extend and enhance the functionality of the compiler. This section of
5704 the GNAT reference manual describes these additional attributes.
5706 Note that any program using these attributes may not be portable to
5707 other compilers (although GNAT implements this set of attributes on all
5708 platforms). Therefore if portability to other compilers is an important
5709 consideration, you should minimize the use of these attributes.
5719 * Compiler_Version::
5721 * Default_Bit_Order::
5733 * Has_Access_Values::
5734 * Has_Discriminants::
5741 * Max_Interrupt_Priority::
5743 * Maximum_Alignment::
5748 * Passed_By_Reference::
5758 * System_Allocator_Alignment::
5764 * Unconstrained_Array::
5765 * Universal_Literal_String::
5766 * Unrestricted_Access::
5774 @unnumberedsec Abort_Signal
5775 @findex Abort_Signal
5777 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5778 prefix) provides the entity for the special exception used to signal
5779 task abort or asynchronous transfer of control. Normally this attribute
5780 should only be used in the tasking runtime (it is highly peculiar, and
5781 completely outside the normal semantics of Ada, for a user program to
5782 intercept the abort exception).
5785 @unnumberedsec Address_Size
5786 @cindex Size of @code{Address}
5787 @findex Address_Size
5789 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5790 prefix) is a static constant giving the number of bits in an
5791 @code{Address}. It is the same value as System.Address'Size,
5792 but has the advantage of being static, while a direct
5793 reference to System.Address'Size is non-static because Address
5797 @unnumberedsec Asm_Input
5800 The @code{Asm_Input} attribute denotes a function that takes two
5801 parameters. The first is a string, the second is an expression of the
5802 type designated by the prefix. The first (string) argument is required
5803 to be a static expression, and is the constraint for the parameter,
5804 (e.g.@: what kind of register is required). The second argument is the
5805 value to be used as the input argument. The possible values for the
5806 constant are the same as those used in the RTL, and are dependent on
5807 the configuration file used to built the GCC back end.
5808 @ref{Machine Code Insertions}
5811 @unnumberedsec Asm_Output
5814 The @code{Asm_Output} attribute denotes a function that takes two
5815 parameters. The first is a string, the second is the name of a variable
5816 of the type designated by the attribute prefix. The first (string)
5817 argument is required to be a static expression and designates the
5818 constraint for the parameter (e.g.@: what kind of register is
5819 required). The second argument is the variable to be updated with the
5820 result. The possible values for constraint are the same as those used in
5821 the RTL, and are dependent on the configuration file used to build the
5822 GCC back end. If there are no output operands, then this argument may
5823 either be omitted, or explicitly given as @code{No_Output_Operands}.
5824 @ref{Machine Code Insertions}
5827 @unnumberedsec AST_Entry
5831 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5832 the name of an entry, it yields a value of the predefined type AST_Handler
5833 (declared in the predefined package System, as extended by the use of
5834 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5835 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5836 Language Reference Manual}, section 9.12a.
5841 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5842 offset within the storage unit (byte) that contains the first bit of
5843 storage allocated for the object. The value of this attribute is of the
5844 type @code{Universal_Integer}, and is always a non-negative number not
5845 exceeding the value of @code{System.Storage_Unit}.
5847 For an object that is a variable or a constant allocated in a register,
5848 the value is zero. (The use of this attribute does not force the
5849 allocation of a variable to memory).
5851 For an object that is a formal parameter, this attribute applies
5852 to either the matching actual parameter or to a copy of the
5853 matching actual parameter.
5855 For an access object the value is zero. Note that
5856 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5857 designated object. Similarly for a record component
5858 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5859 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5860 are subject to index checks.
5862 This attribute is designed to be compatible with the DEC Ada 83 definition
5863 and implementation of the @code{Bit} attribute.
5866 @unnumberedsec Bit_Position
5867 @findex Bit_Position
5869 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
5870 of the fields of the record type, yields the bit
5871 offset within the record contains the first bit of
5872 storage allocated for the object. The value of this attribute is of the
5873 type @code{Universal_Integer}. The value depends only on the field
5874 @var{C} and is independent of the alignment of
5875 the containing record @var{R}.
5877 @node Compiler_Version
5878 @unnumberedsec Compiler_Version
5879 @findex Compiler_Version
5881 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5882 prefix) yields a static string identifying the version of the compiler
5883 being used to compile the unit containing the attribute reference. A
5884 typical result would be something like "@value{EDITION} @i{version} (20090221)".
5887 @unnumberedsec Code_Address
5888 @findex Code_Address
5889 @cindex Subprogram address
5890 @cindex Address of subprogram code
5893 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5894 intended effect seems to be to provide
5895 an address value which can be used to call the subprogram by means of
5896 an address clause as in the following example:
5898 @smallexample @c ada
5899 procedure K is @dots{}
5902 for L'Address use K'Address;
5903 pragma Import (Ada, L);
5907 A call to @code{L} is then expected to result in a call to @code{K}@.
5908 In Ada 83, where there were no access-to-subprogram values, this was
5909 a common work-around for getting the effect of an indirect call.
5910 GNAT implements the above use of @code{Address} and the technique
5911 illustrated by the example code works correctly.
5913 However, for some purposes, it is useful to have the address of the start
5914 of the generated code for the subprogram. On some architectures, this is
5915 not necessarily the same as the @code{Address} value described above.
5916 For example, the @code{Address} value may reference a subprogram
5917 descriptor rather than the subprogram itself.
5919 The @code{'Code_Address} attribute, which can only be applied to
5920 subprogram entities, always returns the address of the start of the
5921 generated code of the specified subprogram, which may or may not be
5922 the same value as is returned by the corresponding @code{'Address}
5925 @node Default_Bit_Order
5926 @unnumberedsec Default_Bit_Order
5928 @cindex Little endian
5929 @findex Default_Bit_Order
5931 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5932 permissible prefix), provides the value @code{System.Default_Bit_Order}
5933 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5934 @code{Low_Order_First}). This is used to construct the definition of
5935 @code{Default_Bit_Order} in package @code{System}.
5937 @node Descriptor_Size
5938 @unnumberedsec Descriptor_Size
5941 @findex Descriptor_Size
5943 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
5944 descriptor allocated for a type. The result is non-zero only for unconstrained
5945 array types and the returned value is of type universal integer. In GNAT, an
5946 array descriptor contains bounds information and is located immediately before
5947 the first element of the array.
5949 @smallexample @c ada
5950 type Unconstr_Array is array (Positive range <>) of Boolean;
5951 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
5955 The attribute takes into account any additional padding due to type alignment.
5956 In the example above, the descriptor contains two values of type
5957 @code{Positive} representing the low and high bound. Since @code{Positive} has
5958 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
5959 Positive'Size + 2} or 64 bits.
5962 @unnumberedsec Elaborated
5965 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5966 value is a Boolean which indicates whether or not the given unit has been
5967 elaborated. This attribute is primarily intended for internal use by the
5968 generated code for dynamic elaboration checking, but it can also be used
5969 in user programs. The value will always be True once elaboration of all
5970 units has been completed. An exception is for units which need no
5971 elaboration, the value is always False for such units.
5974 @unnumberedsec Elab_Body
5977 This attribute can only be applied to a program unit name. It returns
5978 the entity for the corresponding elaboration procedure for elaborating
5979 the body of the referenced unit. This is used in the main generated
5980 elaboration procedure by the binder and is not normally used in any
5981 other context. However, there may be specialized situations in which it
5982 is useful to be able to call this elaboration procedure from Ada code,
5983 e.g.@: if it is necessary to do selective re-elaboration to fix some
5987 @unnumberedsec Elab_Spec
5990 This attribute can only be applied to a program unit name. It returns
5991 the entity for the corresponding elaboration procedure for elaborating
5992 the spec of the referenced unit. This is used in the main
5993 generated elaboration procedure by the binder and is not normally used
5994 in any other context. However, there may be specialized situations in
5995 which it is useful to be able to call this elaboration procedure from
5996 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5999 @node Elab_Subp_Body
6000 @unnumberedsec Elab_Subp_Body
6001 @findex Elab_Subp_Body
6003 This attribute can only be applied to a library level subprogram
6004 name and is only allowed in CodePeer mode. It returns the entity
6005 for the corresponding elaboration procedure for elaborating the body
6006 of the referenced subprogram unit. This is used in the main generated
6007 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6012 @cindex Ada 83 attributes
6015 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6016 the Ada 83 reference manual for an exact description of the semantics of
6020 @unnumberedsec Enabled
6023 The @code{Enabled} attribute allows an application program to check at compile
6024 time to see if the designated check is currently enabled. The prefix is a
6025 simple identifier, referencing any predefined check name (other than
6026 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6027 no argument is given for the attribute, the check is for the general state
6028 of the check, if an argument is given, then it is an entity name, and the
6029 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6030 given naming the entity (if not, then the argument is ignored).
6032 Note that instantiations inherit the check status at the point of the
6033 instantiation, so a useful idiom is to have a library package that
6034 introduces a check name with @code{pragma Check_Name}, and then contains
6035 generic packages or subprograms which use the @code{Enabled} attribute
6036 to see if the check is enabled. A user of this package can then issue
6037 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6038 the package or subprogram, controlling whether the check will be present.
6041 @unnumberedsec Enum_Rep
6042 @cindex Representation of enums
6045 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6046 function with the following spec:
6048 @smallexample @c ada
6049 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6050 return @i{Universal_Integer};
6054 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6055 enumeration type or to a non-overloaded enumeration
6056 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6057 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6058 enumeration literal or object.
6060 The function returns the representation value for the given enumeration
6061 value. This will be equal to value of the @code{Pos} attribute in the
6062 absence of an enumeration representation clause. This is a static
6063 attribute (i.e.@: the result is static if the argument is static).
6065 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6066 in which case it simply returns the integer value. The reason for this
6067 is to allow it to be used for @code{(<>)} discrete formal arguments in
6068 a generic unit that can be instantiated with either enumeration types
6069 or integer types. Note that if @code{Enum_Rep} is used on a modular
6070 type whose upper bound exceeds the upper bound of the largest signed
6071 integer type, and the argument is a variable, so that the universal
6072 integer calculation is done at run time, then the call to @code{Enum_Rep}
6073 may raise @code{Constraint_Error}.
6076 @unnumberedsec Enum_Val
6077 @cindex Representation of enums
6080 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6081 function with the following spec:
6083 @smallexample @c ada
6084 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6085 return @var{S}'Base};
6089 The function returns the enumeration value whose representation matches the
6090 argument, or raises Constraint_Error if no enumeration literal of the type
6091 has the matching value.
6092 This will be equal to value of the @code{Val} attribute in the
6093 absence of an enumeration representation clause. This is a static
6094 attribute (i.e.@: the result is static if the argument is static).
6097 @unnumberedsec Epsilon
6098 @cindex Ada 83 attributes
6101 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6102 the Ada 83 reference manual for an exact description of the semantics of
6106 @unnumberedsec Fixed_Value
6109 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6110 function with the following specification:
6112 @smallexample @c ada
6113 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6118 The value returned is the fixed-point value @var{V} such that
6120 @smallexample @c ada
6121 @var{V} = Arg * @var{S}'Small
6125 The effect is thus similar to first converting the argument to the
6126 integer type used to represent @var{S}, and then doing an unchecked
6127 conversion to the fixed-point type. The difference is
6128 that there are full range checks, to ensure that the result is in range.
6129 This attribute is primarily intended for use in implementation of the
6130 input-output functions for fixed-point values.
6132 @node Has_Access_Values
6133 @unnumberedsec Has_Access_Values
6134 @cindex Access values, testing for
6135 @findex Has_Access_Values
6137 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6138 is a Boolean value which is True if the is an access type, or is a composite
6139 type with a component (at any nesting depth) that is an access type, and is
6141 The intended use of this attribute is in conjunction with generic
6142 definitions. If the attribute is applied to a generic private type, it
6143 indicates whether or not the corresponding actual type has access values.
6145 @node Has_Discriminants
6146 @unnumberedsec Has_Discriminants
6147 @cindex Discriminants, testing for
6148 @findex Has_Discriminants
6150 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6151 is a Boolean value which is True if the type has discriminants, and False
6152 otherwise. The intended use of this attribute is in conjunction with generic
6153 definitions. If the attribute is applied to a generic private type, it
6154 indicates whether or not the corresponding actual type has discriminants.
6160 The @code{Img} attribute differs from @code{Image} in that it may be
6161 applied to objects as well as types, in which case it gives the
6162 @code{Image} for the subtype of the object. This is convenient for
6165 @smallexample @c ada
6166 Put_Line ("X = " & X'Img);
6170 has the same meaning as the more verbose:
6172 @smallexample @c ada
6173 Put_Line ("X = " & @var{T}'Image (X));
6177 where @var{T} is the (sub)type of the object @code{X}.
6180 @unnumberedsec Integer_Value
6181 @findex Integer_Value
6183 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6184 function with the following spec:
6186 @smallexample @c ada
6187 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6192 The value returned is the integer value @var{V}, such that
6194 @smallexample @c ada
6195 Arg = @var{V} * @var{T}'Small
6199 where @var{T} is the type of @code{Arg}.
6200 The effect is thus similar to first doing an unchecked conversion from
6201 the fixed-point type to its corresponding implementation type, and then
6202 converting the result to the target integer type. The difference is
6203 that there are full range checks, to ensure that the result is in range.
6204 This attribute is primarily intended for use in implementation of the
6205 standard input-output functions for fixed-point values.
6208 @unnumberedsec Invalid_Value
6209 @findex Invalid_Value
6211 For every scalar type S, S'Invalid_Value returns an undefined value of the
6212 type. If possible this value is an invalid representation for the type. The
6213 value returned is identical to the value used to initialize an otherwise
6214 uninitialized value of the type if pragma Initialize_Scalars is used,
6215 including the ability to modify the value with the binder -Sxx flag and
6216 relevant environment variables at run time.
6219 @unnumberedsec Large
6220 @cindex Ada 83 attributes
6223 The @code{Large} attribute is provided for compatibility with Ada 83. See
6224 the Ada 83 reference manual for an exact description of the semantics of
6228 @unnumberedsec Machine_Size
6229 @findex Machine_Size
6231 This attribute is identical to the @code{Object_Size} attribute. It is
6232 provided for compatibility with the DEC Ada 83 attribute of this name.
6235 @unnumberedsec Mantissa
6236 @cindex Ada 83 attributes
6239 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6240 the Ada 83 reference manual for an exact description of the semantics of
6243 @node Max_Interrupt_Priority
6244 @unnumberedsec Max_Interrupt_Priority
6245 @cindex Interrupt priority, maximum
6246 @findex Max_Interrupt_Priority
6248 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6249 permissible prefix), provides the same value as
6250 @code{System.Max_Interrupt_Priority}.
6253 @unnumberedsec Max_Priority
6254 @cindex Priority, maximum
6255 @findex Max_Priority
6257 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6258 prefix) provides the same value as @code{System.Max_Priority}.
6260 @node Maximum_Alignment
6261 @unnumberedsec Maximum_Alignment
6262 @cindex Alignment, maximum
6263 @findex Maximum_Alignment
6265 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6266 permissible prefix) provides the maximum useful alignment value for the
6267 target. This is a static value that can be used to specify the alignment
6268 for an object, guaranteeing that it is properly aligned in all
6271 @node Mechanism_Code
6272 @unnumberedsec Mechanism_Code
6273 @cindex Return values, passing mechanism
6274 @cindex Parameters, passing mechanism
6275 @findex Mechanism_Code
6277 @code{@var{function}'Mechanism_Code} yields an integer code for the
6278 mechanism used for the result of function, and
6279 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6280 used for formal parameter number @var{n} (a static integer value with 1
6281 meaning the first parameter) of @var{subprogram}. The code returned is:
6289 by descriptor (default descriptor class)
6291 by descriptor (UBS: unaligned bit string)
6293 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6295 by descriptor (UBA: unaligned bit array)
6297 by descriptor (S: string, also scalar access type parameter)
6299 by descriptor (SB: string with arbitrary bounds)
6301 by descriptor (A: contiguous array)
6303 by descriptor (NCA: non-contiguous array)
6307 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6310 @node Null_Parameter
6311 @unnumberedsec Null_Parameter
6312 @cindex Zero address, passing
6313 @findex Null_Parameter
6315 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6316 type or subtype @var{T} allocated at machine address zero. The attribute
6317 is allowed only as the default expression of a formal parameter, or as
6318 an actual expression of a subprogram call. In either case, the
6319 subprogram must be imported.
6321 The identity of the object is represented by the address zero in the
6322 argument list, independent of the passing mechanism (explicit or
6325 This capability is needed to specify that a zero address should be
6326 passed for a record or other composite object passed by reference.
6327 There is no way of indicating this without the @code{Null_Parameter}
6331 @unnumberedsec Object_Size
6332 @cindex Size, used for objects
6335 The size of an object is not necessarily the same as the size of the type
6336 of an object. This is because by default object sizes are increased to be
6337 a multiple of the alignment of the object. For example,
6338 @code{Natural'Size} is
6339 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6340 Similarly, a record containing an integer and a character:
6342 @smallexample @c ada
6350 will have a size of 40 (that is @code{Rec'Size} will be 40). The
6351 alignment will be 4, because of the
6352 integer field, and so the default size of record objects for this type
6353 will be 64 (8 bytes).
6357 @cindex Capturing Old values
6358 @cindex Postconditions
6360 The attribute Prefix'Old can be used within a
6361 subprogram body or within a precondition or
6362 postcondition pragma. The effect is to
6363 refer to the value of the prefix on entry. So for
6364 example if you have an argument of a record type X called Arg1,
6365 you can refer to Arg1.Field'Old which yields the value of
6366 Arg1.Field on entry. The implementation simply involves generating
6367 an object declaration which captures the value on entry. Any
6368 prefix is allowed except one of a limited type (since limited
6369 types cannot be copied to capture their values) or an expression
6370 which references a local variable
6371 (since local variables do not exist at subprogram entry time).
6373 The following example shows the use of 'Old to implement
6374 a test of a postcondition:
6376 @smallexample @c ada
6387 package body Old_Pkg is
6388 Count : Natural := 0;
6392 ... code manipulating the value of Count
6394 pragma Assert (Count = Count'Old + 1);
6400 Note that it is allowed to apply 'Old to a constant entity, but this will
6401 result in a warning, since the old and new values will always be the same.
6403 @node Passed_By_Reference
6404 @unnumberedsec Passed_By_Reference
6405 @cindex Parameters, when passed by reference
6406 @findex Passed_By_Reference
6408 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6409 a value of type @code{Boolean} value that is @code{True} if the type is
6410 normally passed by reference and @code{False} if the type is normally
6411 passed by copy in calls. For scalar types, the result is always @code{False}
6412 and is static. For non-scalar types, the result is non-static.
6415 @unnumberedsec Pool_Address
6416 @cindex Parameters, when passed by reference
6417 @findex Pool_Address
6419 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6420 of X within its storage pool. This is the same as
6421 @code{@var{X}'Address}, except that for an unconstrained array whose
6422 bounds are allocated just before the first component,
6423 @code{@var{X}'Pool_Address} returns the address of those bounds,
6424 whereas @code{@var{X}'Address} returns the address of the first
6427 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6428 the object is allocated'', which could be a user-defined storage pool,
6429 the global heap, on the stack, or in a static memory area. For an
6430 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6431 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6434 @unnumberedsec Range_Length
6435 @findex Range_Length
6437 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6438 the number of values represented by the subtype (zero for a null
6439 range). The result is static for static subtypes. @code{Range_Length}
6440 applied to the index subtype of a one dimensional array always gives the
6441 same result as @code{Range} applied to the array itself.
6447 The @code{System.Address'Ref}
6448 (@code{System.Address} is the only permissible prefix)
6449 denotes a function identical to
6450 @code{System.Storage_Elements.To_Address} except that
6451 it is a static attribute. See @ref{To_Address} for more details.
6454 @unnumberedsec Result
6457 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6458 for a function. The prefix must be the name of the corresponding function. This
6459 is used to refer to the result of the function in the postcondition expression.
6460 For a further discussion of the use of this attribute and examples of its use,
6461 see the description of pragma Postcondition.
6464 @unnumberedsec Safe_Emax
6465 @cindex Ada 83 attributes
6468 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6469 the Ada 83 reference manual for an exact description of the semantics of
6473 @unnumberedsec Safe_Large
6474 @cindex Ada 83 attributes
6477 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6478 the Ada 83 reference manual for an exact description of the semantics of
6482 @unnumberedsec Small
6483 @cindex Ada 83 attributes
6486 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6488 GNAT also allows this attribute to be applied to floating-point types
6489 for compatibility with Ada 83. See
6490 the Ada 83 reference manual for an exact description of the semantics of
6491 this attribute when applied to floating-point types.
6494 @unnumberedsec Storage_Unit
6495 @findex Storage_Unit
6497 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6498 prefix) provides the same value as @code{System.Storage_Unit}.
6501 @unnumberedsec Stub_Type
6504 The GNAT implementation of remote access-to-classwide types is
6505 organized as described in AARM section E.4 (20.t): a value of an RACW type
6506 (designating a remote object) is represented as a normal access
6507 value, pointing to a "stub" object which in turn contains the
6508 necessary information to contact the designated remote object. A
6509 call on any dispatching operation of such a stub object does the
6510 remote call, if necessary, using the information in the stub object
6511 to locate the target partition, etc.
6513 For a prefix @code{T} that denotes a remote access-to-classwide type,
6514 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6516 By construction, the layout of @code{T'Stub_Type} is identical to that of
6517 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6518 unit @code{System.Partition_Interface}. Use of this attribute will create
6519 an implicit dependency on this unit.
6521 @node System_Allocator_Alignment
6522 @unnumberedsec System_Allocator_Alignment
6523 @cindex Alignment, allocator
6524 @findex System_Allocator_Alignment
6526 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
6527 permissible prefix) provides the observable guaranted to be honored by
6528 the system allocator (malloc). This is a static value that can be used
6529 in user storage pools based on malloc either to reject allocation
6530 with alignment too large or to enable a realignment circuitry if the
6531 alignment request is larger than this value.
6534 @unnumberedsec Target_Name
6537 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6538 prefix) provides a static string value that identifies the target
6539 for the current compilation. For GCC implementations, this is the
6540 standard gcc target name without the terminating slash (for
6541 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6547 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6548 provides the same value as @code{System.Tick},
6551 @unnumberedsec To_Address
6554 The @code{System'To_Address}
6555 (@code{System} is the only permissible prefix)
6556 denotes a function identical to
6557 @code{System.Storage_Elements.To_Address} except that
6558 it is a static attribute. This means that if its argument is
6559 a static expression, then the result of the attribute is a
6560 static expression. The result is that such an expression can be
6561 used in contexts (e.g.@: preelaborable packages) which require a
6562 static expression and where the function call could not be used
6563 (since the function call is always non-static, even if its
6564 argument is static).
6567 @unnumberedsec Type_Class
6570 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6571 the value of the type class for the full type of @var{type}. If
6572 @var{type} is a generic formal type, the value is the value for the
6573 corresponding actual subtype. The value of this attribute is of type
6574 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6576 @smallexample @c ada
6578 (Type_Class_Enumeration,
6580 Type_Class_Fixed_Point,
6581 Type_Class_Floating_Point,
6586 Type_Class_Address);
6590 Protected types yield the value @code{Type_Class_Task}, which thus
6591 applies to all concurrent types. This attribute is designed to
6592 be compatible with the DEC Ada 83 attribute of the same name.
6595 @unnumberedsec UET_Address
6598 The @code{UET_Address} attribute can only be used for a prefix which
6599 denotes a library package. It yields the address of the unit exception
6600 table when zero cost exception handling is used. This attribute is
6601 intended only for use within the GNAT implementation. See the unit
6602 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6603 for details on how this attribute is used in the implementation.
6605 @node Unconstrained_Array
6606 @unnumberedsec Unconstrained_Array
6607 @findex Unconstrained_Array
6609 The @code{Unconstrained_Array} attribute can be used with a prefix that
6610 denotes any type or subtype. It is a static attribute that yields
6611 @code{True} if the prefix designates an unconstrained array,
6612 and @code{False} otherwise. In a generic instance, the result is
6613 still static, and yields the result of applying this test to the
6616 @node Universal_Literal_String
6617 @unnumberedsec Universal_Literal_String
6618 @cindex Named numbers, representation of
6619 @findex Universal_Literal_String
6621 The prefix of @code{Universal_Literal_String} must be a named
6622 number. The static result is the string consisting of the characters of
6623 the number as defined in the original source. This allows the user
6624 program to access the actual text of named numbers without intermediate
6625 conversions and without the need to enclose the strings in quotes (which
6626 would preclude their use as numbers).
6628 For example, the following program prints the first 50 digits of pi:
6630 @smallexample @c ada
6631 with Text_IO; use Text_IO;
6635 Put (Ada.Numerics.Pi'Universal_Literal_String);
6639 @node Unrestricted_Access
6640 @unnumberedsec Unrestricted_Access
6641 @cindex @code{Access}, unrestricted
6642 @findex Unrestricted_Access
6644 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6645 except that all accessibility and aliased view checks are omitted. This
6646 is a user-beware attribute. It is similar to
6647 @code{Address}, for which it is a desirable replacement where the value
6648 desired is an access type. In other words, its effect is identical to
6649 first applying the @code{Address} attribute and then doing an unchecked
6650 conversion to a desired access type. In GNAT, but not necessarily in
6651 other implementations, the use of static chains for inner level
6652 subprograms means that @code{Unrestricted_Access} applied to a
6653 subprogram yields a value that can be called as long as the subprogram
6654 is in scope (normal Ada accessibility rules restrict this usage).
6656 It is possible to use @code{Unrestricted_Access} for any type, but care
6657 must be exercised if it is used to create pointers to unconstrained
6658 objects. In this case, the resulting pointer has the same scope as the
6659 context of the attribute, and may not be returned to some enclosing
6660 scope. For instance, a function cannot use @code{Unrestricted_Access}
6661 to create a unconstrained pointer and then return that value to the
6665 @unnumberedsec VADS_Size
6666 @cindex @code{Size}, VADS compatibility
6669 The @code{'VADS_Size} attribute is intended to make it easier to port
6670 legacy code which relies on the semantics of @code{'Size} as implemented
6671 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6672 same semantic interpretation. In particular, @code{'VADS_Size} applied
6673 to a predefined or other primitive type with no Size clause yields the
6674 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6675 typical machines). In addition @code{'VADS_Size} applied to an object
6676 gives the result that would be obtained by applying the attribute to
6677 the corresponding type.
6680 @unnumberedsec Value_Size
6681 @cindex @code{Size}, setting for not-first subtype
6683 @code{@var{type}'Value_Size} is the number of bits required to represent
6684 a value of the given subtype. It is the same as @code{@var{type}'Size},
6685 but, unlike @code{Size}, may be set for non-first subtypes.
6688 @unnumberedsec Wchar_T_Size
6689 @findex Wchar_T_Size
6690 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6691 prefix) provides the size in bits of the C @code{wchar_t} type
6692 primarily for constructing the definition of this type in
6693 package @code{Interfaces.C}.
6696 @unnumberedsec Word_Size
6698 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6699 prefix) provides the value @code{System.Word_Size}.
6701 @c ------------------------
6702 @node Implementation Advice
6703 @chapter Implementation Advice
6705 The main text of the Ada Reference Manual describes the required
6706 behavior of all Ada compilers, and the GNAT compiler conforms to
6709 In addition, there are sections throughout the Ada Reference Manual headed
6710 by the phrase ``Implementation advice''. These sections are not normative,
6711 i.e., they do not specify requirements that all compilers must
6712 follow. Rather they provide advice on generally desirable behavior. You
6713 may wonder why they are not requirements. The most typical answer is
6714 that they describe behavior that seems generally desirable, but cannot
6715 be provided on all systems, or which may be undesirable on some systems.
6717 As far as practical, GNAT follows the implementation advice sections in
6718 the Ada Reference Manual. This chapter contains a table giving the
6719 reference manual section number, paragraph number and several keywords
6720 for each advice. Each entry consists of the text of the advice followed
6721 by the GNAT interpretation of this advice. Most often, this simply says
6722 ``followed'', which means that GNAT follows the advice. However, in a
6723 number of cases, GNAT deliberately deviates from this advice, in which
6724 case the text describes what GNAT does and why.
6726 @cindex Error detection
6727 @unnumberedsec 1.1.3(20): Error Detection
6730 If an implementation detects the use of an unsupported Specialized Needs
6731 Annex feature at run time, it should raise @code{Program_Error} if
6734 Not relevant. All specialized needs annex features are either supported,
6735 or diagnosed at compile time.
6738 @unnumberedsec 1.1.3(31): Child Units
6741 If an implementation wishes to provide implementation-defined
6742 extensions to the functionality of a language-defined library unit, it
6743 should normally do so by adding children to the library unit.
6747 @cindex Bounded errors
6748 @unnumberedsec 1.1.5(12): Bounded Errors
6751 If an implementation detects a bounded error or erroneous
6752 execution, it should raise @code{Program_Error}.
6754 Followed in all cases in which the implementation detects a bounded
6755 error or erroneous execution. Not all such situations are detected at
6759 @unnumberedsec 2.8(16): Pragmas
6762 Normally, implementation-defined pragmas should have no semantic effect
6763 for error-free programs; that is, if the implementation-defined pragmas
6764 are removed from a working program, the program should still be legal,
6765 and should still have the same semantics.
6767 The following implementation defined pragmas are exceptions to this
6779 @item CPP_Constructor
6783 @item Interface_Name
6785 @item Machine_Attribute
6787 @item Unimplemented_Unit
6789 @item Unchecked_Union
6794 In each of the above cases, it is essential to the purpose of the pragma
6795 that this advice not be followed. For details see the separate section
6796 on implementation defined pragmas.
6798 @unnumberedsec 2.8(17-19): Pragmas
6801 Normally, an implementation should not define pragmas that can
6802 make an illegal program legal, except as follows:
6806 A pragma used to complete a declaration, such as a pragma @code{Import};
6810 A pragma used to configure the environment by adding, removing, or
6811 replacing @code{library_items}.
6813 See response to paragraph 16 of this same section.
6815 @cindex Character Sets
6816 @cindex Alternative Character Sets
6817 @unnumberedsec 3.5.2(5): Alternative Character Sets
6820 If an implementation supports a mode with alternative interpretations
6821 for @code{Character} and @code{Wide_Character}, the set of graphic
6822 characters of @code{Character} should nevertheless remain a proper
6823 subset of the set of graphic characters of @code{Wide_Character}. Any
6824 character set ``localizations'' should be reflected in the results of
6825 the subprograms defined in the language-defined package
6826 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6827 an alternative interpretation of @code{Character}, the implementation should
6828 also support a corresponding change in what is a legal
6829 @code{identifier_letter}.
6831 Not all wide character modes follow this advice, in particular the JIS
6832 and IEC modes reflect standard usage in Japan, and in these encoding,
6833 the upper half of the Latin-1 set is not part of the wide-character
6834 subset, since the most significant bit is used for wide character
6835 encoding. However, this only applies to the external forms. Internally
6836 there is no such restriction.
6838 @cindex Integer types
6839 @unnumberedsec 3.5.4(28): Integer Types
6843 An implementation should support @code{Long_Integer} in addition to
6844 @code{Integer} if the target machine supports 32-bit (or longer)
6845 arithmetic. No other named integer subtypes are recommended for package
6846 @code{Standard}. Instead, appropriate named integer subtypes should be
6847 provided in the library package @code{Interfaces} (see B.2).
6849 @code{Long_Integer} is supported. Other standard integer types are supported
6850 so this advice is not fully followed. These types
6851 are supported for convenient interface to C, and so that all hardware
6852 types of the machine are easily available.
6853 @unnumberedsec 3.5.4(29): Integer Types
6857 An implementation for a two's complement machine should support
6858 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6859 implementation should support a non-binary modules up to @code{Integer'Last}.
6863 @cindex Enumeration values
6864 @unnumberedsec 3.5.5(8): Enumeration Values
6867 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6868 subtype, if the value of the operand does not correspond to the internal
6869 code for any enumeration literal of its type (perhaps due to an
6870 un-initialized variable), then the implementation should raise
6871 @code{Program_Error}. This is particularly important for enumeration
6872 types with noncontiguous internal codes specified by an
6873 enumeration_representation_clause.
6878 @unnumberedsec 3.5.7(17): Float Types
6881 An implementation should support @code{Long_Float} in addition to
6882 @code{Float} if the target machine supports 11 or more digits of
6883 precision. No other named floating point subtypes are recommended for
6884 package @code{Standard}. Instead, appropriate named floating point subtypes
6885 should be provided in the library package @code{Interfaces} (see B.2).
6887 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6888 former provides improved compatibility with other implementations
6889 supporting this type. The latter corresponds to the highest precision
6890 floating-point type supported by the hardware. On most machines, this
6891 will be the same as @code{Long_Float}, but on some machines, it will
6892 correspond to the IEEE extended form. The notable case is all ia32
6893 (x86) implementations, where @code{Long_Long_Float} corresponds to
6894 the 80-bit extended precision format supported in hardware on this
6895 processor. Note that the 128-bit format on SPARC is not supported,
6896 since this is a software rather than a hardware format.
6898 @cindex Multidimensional arrays
6899 @cindex Arrays, multidimensional
6900 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6903 An implementation should normally represent multidimensional arrays in
6904 row-major order, consistent with the notation used for multidimensional
6905 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6906 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6907 column-major order should be used instead (see B.5, ``Interfacing with
6912 @findex Duration'Small
6913 @unnumberedsec 9.6(30-31): Duration'Small
6916 Whenever possible in an implementation, the value of @code{Duration'Small}
6917 should be no greater than 100 microseconds.
6919 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6923 The time base for @code{delay_relative_statements} should be monotonic;
6924 it need not be the same time base as used for @code{Calendar.Clock}.
6928 @unnumberedsec 10.2.1(12): Consistent Representation
6931 In an implementation, a type declared in a pre-elaborated package should
6932 have the same representation in every elaboration of a given version of
6933 the package, whether the elaborations occur in distinct executions of
6934 the same program, or in executions of distinct programs or partitions
6935 that include the given version.
6937 Followed, except in the case of tagged types. Tagged types involve
6938 implicit pointers to a local copy of a dispatch table, and these pointers
6939 have representations which thus depend on a particular elaboration of the
6940 package. It is not easy to see how it would be possible to follow this
6941 advice without severely impacting efficiency of execution.
6943 @cindex Exception information
6944 @unnumberedsec 11.4.1(19): Exception Information
6947 @code{Exception_Message} by default and @code{Exception_Information}
6948 should produce information useful for
6949 debugging. @code{Exception_Message} should be short, about one
6950 line. @code{Exception_Information} can be long. @code{Exception_Message}
6951 should not include the
6952 @code{Exception_Name}. @code{Exception_Information} should include both
6953 the @code{Exception_Name} and the @code{Exception_Message}.
6955 Followed. For each exception that doesn't have a specified
6956 @code{Exception_Message}, the compiler generates one containing the location
6957 of the raise statement. This location has the form ``file:line'', where
6958 file is the short file name (without path information) and line is the line
6959 number in the file. Note that in the case of the Zero Cost Exception
6960 mechanism, these messages become redundant with the Exception_Information that
6961 contains a full backtrace of the calling sequence, so they are disabled.
6962 To disable explicitly the generation of the source location message, use the
6963 Pragma @code{Discard_Names}.
6965 @cindex Suppression of checks
6966 @cindex Checks, suppression of
6967 @unnumberedsec 11.5(28): Suppression of Checks
6970 The implementation should minimize the code executed for checks that
6971 have been suppressed.
6975 @cindex Representation clauses
6976 @unnumberedsec 13.1 (21-24): Representation Clauses
6979 The recommended level of support for all representation items is
6980 qualified as follows:
6984 An implementation need not support representation items containing
6985 non-static expressions, except that an implementation should support a
6986 representation item for a given entity if each non-static expression in
6987 the representation item is a name that statically denotes a constant
6988 declared before the entity.
6990 Followed. In fact, GNAT goes beyond the recommended level of support
6991 by allowing nonstatic expressions in some representation clauses even
6992 without the need to declare constants initialized with the values of
6996 @smallexample @c ada
6999 for Y'Address use X'Address;>>
7004 An implementation need not support a specification for the @code{Size}
7005 for a given composite subtype, nor the size or storage place for an
7006 object (including a component) of a given composite subtype, unless the
7007 constraints on the subtype and its composite subcomponents (if any) are
7008 all static constraints.
7010 Followed. Size Clauses are not permitted on non-static components, as
7015 An aliased component, or a component whose type is by-reference, should
7016 always be allocated at an addressable location.
7020 @cindex Packed types
7021 @unnumberedsec 13.2(6-8): Packed Types
7024 If a type is packed, then the implementation should try to minimize
7025 storage allocated to objects of the type, possibly at the expense of
7026 speed of accessing components, subject to reasonable complexity in
7027 addressing calculations.
7031 The recommended level of support pragma @code{Pack} is:
7033 For a packed record type, the components should be packed as tightly as
7034 possible subject to the Sizes of the component subtypes, and subject to
7035 any @code{record_representation_clause} that applies to the type; the
7036 implementation may, but need not, reorder components or cross aligned
7037 word boundaries to improve the packing. A component whose @code{Size} is
7038 greater than the word size may be allocated an integral number of words.
7040 Followed. Tight packing of arrays is supported for all component sizes
7041 up to 64-bits. If the array component size is 1 (that is to say, if
7042 the component is a boolean type or an enumeration type with two values)
7043 then values of the type are implicitly initialized to zero. This
7044 happens both for objects of the packed type, and for objects that have a
7045 subcomponent of the packed type.
7049 An implementation should support Address clauses for imported
7053 @cindex @code{Address} clauses
7054 @unnumberedsec 13.3(14-19): Address Clauses
7058 For an array @var{X}, @code{@var{X}'Address} should point at the first
7059 component of the array, and not at the array bounds.
7065 The recommended level of support for the @code{Address} attribute is:
7067 @code{@var{X}'Address} should produce a useful result if @var{X} is an
7068 object that is aliased or of a by-reference type, or is an entity whose
7069 @code{Address} has been specified.
7071 Followed. A valid address will be produced even if none of those
7072 conditions have been met. If necessary, the object is forced into
7073 memory to ensure the address is valid.
7077 An implementation should support @code{Address} clauses for imported
7084 Objects (including subcomponents) that are aliased or of a by-reference
7085 type should be allocated on storage element boundaries.
7091 If the @code{Address} of an object is specified, or it is imported or exported,
7092 then the implementation should not perform optimizations based on
7093 assumptions of no aliases.
7097 @cindex @code{Alignment} clauses
7098 @unnumberedsec 13.3(29-35): Alignment Clauses
7101 The recommended level of support for the @code{Alignment} attribute for
7104 An implementation should support specified Alignments that are factors
7105 and multiples of the number of storage elements per word, subject to the
7112 An implementation need not support specified @code{Alignment}s for
7113 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
7114 loaded and stored by available machine instructions.
7120 An implementation need not support specified @code{Alignment}s that are
7121 greater than the maximum @code{Alignment} the implementation ever returns by
7128 The recommended level of support for the @code{Alignment} attribute for
7131 Same as above, for subtypes, but in addition:
7137 For stand-alone library-level objects of statically constrained
7138 subtypes, the implementation should support all @code{Alignment}s
7139 supported by the target linker. For example, page alignment is likely to
7140 be supported for such objects, but not for subtypes.
7144 @cindex @code{Size} clauses
7145 @unnumberedsec 13.3(42-43): Size Clauses
7148 The recommended level of support for the @code{Size} attribute of
7151 A @code{Size} clause should be supported for an object if the specified
7152 @code{Size} is at least as large as its subtype's @code{Size}, and
7153 corresponds to a size in storage elements that is a multiple of the
7154 object's @code{Alignment} (if the @code{Alignment} is nonzero).
7158 @unnumberedsec 13.3(50-56): Size Clauses
7161 If the @code{Size} of a subtype is specified, and allows for efficient
7162 independent addressability (see 9.10) on the target architecture, then
7163 the @code{Size} of the following objects of the subtype should equal the
7164 @code{Size} of the subtype:
7166 Aliased objects (including components).
7172 @code{Size} clause on a composite subtype should not affect the
7173 internal layout of components.
7175 Followed. But note that this can be overridden by use of the implementation
7176 pragma Implicit_Packing in the case of packed arrays.
7180 The recommended level of support for the @code{Size} attribute of subtypes is:
7184 The @code{Size} (if not specified) of a static discrete or fixed point
7185 subtype should be the number of bits needed to represent each value
7186 belonging to the subtype using an unbiased representation, leaving space
7187 for a sign bit only if the subtype contains negative values. If such a
7188 subtype is a first subtype, then an implementation should support a
7189 specified @code{Size} for it that reflects this representation.
7195 For a subtype implemented with levels of indirection, the @code{Size}
7196 should include the size of the pointers, but not the size of what they
7201 @cindex @code{Component_Size} clauses
7202 @unnumberedsec 13.3(71-73): Component Size Clauses
7205 The recommended level of support for the @code{Component_Size}
7210 An implementation need not support specified @code{Component_Sizes} that are
7211 less than the @code{Size} of the component subtype.
7217 An implementation should support specified @code{Component_Size}s that
7218 are factors and multiples of the word size. For such
7219 @code{Component_Size}s, the array should contain no gaps between
7220 components. For other @code{Component_Size}s (if supported), the array
7221 should contain no gaps between components when packing is also
7222 specified; the implementation should forbid this combination in cases
7223 where it cannot support a no-gaps representation.
7227 @cindex Enumeration representation clauses
7228 @cindex Representation clauses, enumeration
7229 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
7232 The recommended level of support for enumeration representation clauses
7235 An implementation need not support enumeration representation clauses
7236 for boolean types, but should at minimum support the internal codes in
7237 the range @code{System.Min_Int.System.Max_Int}.
7241 @cindex Record representation clauses
7242 @cindex Representation clauses, records
7243 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
7246 The recommended level of support for
7247 @*@code{record_representation_clauses} is:
7249 An implementation should support storage places that can be extracted
7250 with a load, mask, shift sequence of machine code, and set with a load,
7251 shift, mask, store sequence, given the available machine instructions
7258 A storage place should be supported if its size is equal to the
7259 @code{Size} of the component subtype, and it starts and ends on a
7260 boundary that obeys the @code{Alignment} of the component subtype.
7266 If the default bit ordering applies to the declaration of a given type,
7267 then for a component whose subtype's @code{Size} is less than the word
7268 size, any storage place that does not cross an aligned word boundary
7269 should be supported.
7275 An implementation may reserve a storage place for the tag field of a
7276 tagged type, and disallow other components from overlapping that place.
7278 Followed. The storage place for the tag field is the beginning of the tagged
7279 record, and its size is Address'Size. GNAT will reject an explicit component
7280 clause for the tag field.
7284 An implementation need not support a @code{component_clause} for a
7285 component of an extension part if the storage place is not after the
7286 storage places of all components of the parent type, whether or not
7287 those storage places had been specified.
7289 Followed. The above advice on record representation clauses is followed,
7290 and all mentioned features are implemented.
7292 @cindex Storage place attributes
7293 @unnumberedsec 13.5.2(5): Storage Place Attributes
7296 If a component is represented using some form of pointer (such as an
7297 offset) to the actual data of the component, and this data is contiguous
7298 with the rest of the object, then the storage place attributes should
7299 reflect the place of the actual data, not the pointer. If a component is
7300 allocated discontinuously from the rest of the object, then a warning
7301 should be generated upon reference to one of its storage place
7304 Followed. There are no such components in GNAT@.
7306 @cindex Bit ordering
7307 @unnumberedsec 13.5.3(7-8): Bit Ordering
7310 The recommended level of support for the non-default bit ordering is:
7314 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
7315 should support the non-default bit ordering in addition to the default
7318 Followed. Word size does not equal storage size in this implementation.
7319 Thus non-default bit ordering is not supported.
7321 @cindex @code{Address}, as private type
7322 @unnumberedsec 13.7(37): Address as Private
7325 @code{Address} should be of a private type.
7329 @cindex Operations, on @code{Address}
7330 @cindex @code{Address}, operations of
7331 @unnumberedsec 13.7.1(16): Address Operations
7334 Operations in @code{System} and its children should reflect the target
7335 environment semantics as closely as is reasonable. For example, on most
7336 machines, it makes sense for address arithmetic to ``wrap around''.
7337 Operations that do not make sense should raise @code{Program_Error}.
7339 Followed. Address arithmetic is modular arithmetic that wraps around. No
7340 operation raises @code{Program_Error}, since all operations make sense.
7342 @cindex Unchecked conversion
7343 @unnumberedsec 13.9(14-17): Unchecked Conversion
7346 The @code{Size} of an array object should not include its bounds; hence,
7347 the bounds should not be part of the converted data.
7353 The implementation should not generate unnecessary run-time checks to
7354 ensure that the representation of @var{S} is a representation of the
7355 target type. It should take advantage of the permission to return by
7356 reference when possible. Restrictions on unchecked conversions should be
7357 avoided unless required by the target environment.
7359 Followed. There are no restrictions on unchecked conversion. A warning is
7360 generated if the source and target types do not have the same size since
7361 the semantics in this case may be target dependent.
7365 The recommended level of support for unchecked conversions is:
7369 Unchecked conversions should be supported and should be reversible in
7370 the cases where this clause defines the result. To enable meaningful use
7371 of unchecked conversion, a contiguous representation should be used for
7372 elementary subtypes, for statically constrained array subtypes whose
7373 component subtype is one of the subtypes described in this paragraph,
7374 and for record subtypes without discriminants whose component subtypes
7375 are described in this paragraph.
7379 @cindex Heap usage, implicit
7380 @unnumberedsec 13.11(23-25): Implicit Heap Usage
7383 An implementation should document any cases in which it dynamically
7384 allocates heap storage for a purpose other than the evaluation of an
7387 Followed, the only other points at which heap storage is dynamically
7388 allocated are as follows:
7392 At initial elaboration time, to allocate dynamically sized global
7396 To allocate space for a task when a task is created.
7399 To extend the secondary stack dynamically when needed. The secondary
7400 stack is used for returning variable length results.
7405 A default (implementation-provided) storage pool for an
7406 access-to-constant type should not have overhead to support deallocation of
7413 A storage pool for an anonymous access type should be created at the
7414 point of an allocator for the type, and be reclaimed when the designated
7415 object becomes inaccessible.
7419 @cindex Unchecked deallocation
7420 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7423 For a standard storage pool, @code{Free} should actually reclaim the
7428 @cindex Stream oriented attributes
7429 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7432 If a stream element is the same size as a storage element, then the
7433 normal in-memory representation should be used by @code{Read} and
7434 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
7435 should use the smallest number of stream elements needed to represent
7436 all values in the base range of the scalar type.
7439 Followed. By default, GNAT uses the interpretation suggested by AI-195,
7440 which specifies using the size of the first subtype.
7441 However, such an implementation is based on direct binary
7442 representations and is therefore target- and endianness-dependent.
7443 To address this issue, GNAT also supplies an alternate implementation
7444 of the stream attributes @code{Read} and @code{Write},
7445 which uses the target-independent XDR standard representation
7447 @cindex XDR representation
7448 @cindex @code{Read} attribute
7449 @cindex @code{Write} attribute
7450 @cindex Stream oriented attributes
7451 The XDR implementation is provided as an alternative body of the
7452 @code{System.Stream_Attributes} package, in the file
7453 @file{s-stratt-xdr.adb} in the GNAT library.
7454 There is no @file{s-stratt-xdr.ads} file.
7455 In order to install the XDR implementation, do the following:
7457 @item Replace the default implementation of the
7458 @code{System.Stream_Attributes} package with the XDR implementation.
7459 For example on a Unix platform issue the commands:
7461 $ mv s-stratt.adb s-stratt-default.adb
7462 $ mv s-stratt-xdr.adb s-stratt.adb
7466 Rebuild the GNAT run-time library as documented in
7467 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7470 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7473 If an implementation provides additional named predefined integer types,
7474 then the names should end with @samp{Integer} as in
7475 @samp{Long_Integer}. If an implementation provides additional named
7476 predefined floating point types, then the names should end with
7477 @samp{Float} as in @samp{Long_Float}.
7481 @findex Ada.Characters.Handling
7482 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7485 If an implementation provides a localized definition of @code{Character}
7486 or @code{Wide_Character}, then the effects of the subprograms in
7487 @code{Characters.Handling} should reflect the localizations. See also
7490 Followed. GNAT provides no such localized definitions.
7492 @cindex Bounded-length strings
7493 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7496 Bounded string objects should not be implemented by implicit pointers
7497 and dynamic allocation.
7499 Followed. No implicit pointers or dynamic allocation are used.
7501 @cindex Random number generation
7502 @unnumberedsec A.5.2(46-47): Random Number Generation
7505 Any storage associated with an object of type @code{Generator} should be
7506 reclaimed on exit from the scope of the object.
7512 If the generator period is sufficiently long in relation to the number
7513 of distinct initiator values, then each possible value of
7514 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7515 random numbers that does not, in a practical sense, overlap the sequence
7516 initiated by any other value. If this is not possible, then the mapping
7517 between initiator values and generator states should be a rapidly
7518 varying function of the initiator value.
7520 Followed. The generator period is sufficiently long for the first
7521 condition here to hold true.
7523 @findex Get_Immediate
7524 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7527 The @code{Get_Immediate} procedures should be implemented with
7528 unbuffered input. For a device such as a keyboard, input should be
7529 @dfn{available} if a key has already been typed, whereas for a disk
7530 file, input should always be available except at end of file. For a file
7531 associated with a keyboard-like device, any line-editing features of the
7532 underlying operating system should be disabled during the execution of
7533 @code{Get_Immediate}.
7535 Followed on all targets except VxWorks. For VxWorks, there is no way to
7536 provide this functionality that does not result in the input buffer being
7537 flushed before the @code{Get_Immediate} call. A special unit
7538 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7542 @unnumberedsec B.1(39-41): Pragma @code{Export}
7545 If an implementation supports pragma @code{Export} to a given language,
7546 then it should also allow the main subprogram to be written in that
7547 language. It should support some mechanism for invoking the elaboration
7548 of the Ada library units included in the system, and for invoking the
7549 finalization of the environment task. On typical systems, the
7550 recommended mechanism is to provide two subprograms whose link names are
7551 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
7552 elaboration code for library units. @code{adafinal} should contain the
7553 finalization code. These subprograms should have no effect the second
7554 and subsequent time they are called.
7560 Automatic elaboration of pre-elaborated packages should be
7561 provided when pragma @code{Export} is supported.
7563 Followed when the main program is in Ada. If the main program is in a
7564 foreign language, then
7565 @code{adainit} must be called to elaborate pre-elaborated
7570 For each supported convention @var{L} other than @code{Intrinsic}, an
7571 implementation should support @code{Import} and @code{Export} pragmas
7572 for objects of @var{L}-compatible types and for subprograms, and pragma
7573 @code{Convention} for @var{L}-eligible types and for subprograms,
7574 presuming the other language has corresponding features. Pragma
7575 @code{Convention} need not be supported for scalar types.
7579 @cindex Package @code{Interfaces}
7581 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7584 For each implementation-defined convention identifier, there should be a
7585 child package of package Interfaces with the corresponding name. This
7586 package should contain any declarations that would be useful for
7587 interfacing to the language (implementation) represented by the
7588 convention. Any declarations useful for interfacing to any language on
7589 the given hardware architecture should be provided directly in
7592 Followed. An additional package not defined
7593 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7594 for interfacing to C++.
7598 An implementation supporting an interface to C, COBOL, or Fortran should
7599 provide the corresponding package or packages described in the following
7602 Followed. GNAT provides all the packages described in this section.
7604 @cindex C, interfacing with
7605 @unnumberedsec B.3(63-71): Interfacing with C
7608 An implementation should support the following interface correspondences
7615 An Ada procedure corresponds to a void-returning C function.
7621 An Ada function corresponds to a non-void C function.
7627 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7634 An Ada @code{in} parameter of an access-to-object type with designated
7635 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7636 where @var{t} is the C type corresponding to the Ada type @var{T}.
7642 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7643 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7644 argument to a C function, where @var{t} is the C type corresponding to
7645 the Ada type @var{T}. In the case of an elementary @code{out} or
7646 @code{in out} parameter, a pointer to a temporary copy is used to
7647 preserve by-copy semantics.
7653 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7654 @code{@var{t}*} argument to a C function, where @var{t} is the C
7655 structure corresponding to the Ada type @var{T}.
7657 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7658 pragma, or Convention, or by explicitly specifying the mechanism for a given
7659 call using an extended import or export pragma.
7663 An Ada parameter of an array type with component type @var{T}, of any
7664 mode, is passed as a @code{@var{t}*} argument to a C function, where
7665 @var{t} is the C type corresponding to the Ada type @var{T}.
7671 An Ada parameter of an access-to-subprogram type is passed as a pointer
7672 to a C function whose prototype corresponds to the designated
7673 subprogram's specification.
7677 @cindex COBOL, interfacing with
7678 @unnumberedsec B.4(95-98): Interfacing with COBOL
7681 An Ada implementation should support the following interface
7682 correspondences between Ada and COBOL@.
7688 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7689 the COBOL type corresponding to @var{T}.
7695 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7696 the corresponding COBOL type.
7702 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7703 COBOL type corresponding to the Ada parameter type; for scalars, a local
7704 copy is used if necessary to ensure by-copy semantics.
7708 @cindex Fortran, interfacing with
7709 @unnumberedsec B.5(22-26): Interfacing with Fortran
7712 An Ada implementation should support the following interface
7713 correspondences between Ada and Fortran:
7719 An Ada procedure corresponds to a Fortran subroutine.
7725 An Ada function corresponds to a Fortran function.
7731 An Ada parameter of an elementary, array, or record type @var{T} is
7732 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7733 the Fortran type corresponding to the Ada type @var{T}, and where the
7734 INTENT attribute of the corresponding dummy argument matches the Ada
7735 formal parameter mode; the Fortran implementation's parameter passing
7736 conventions are used. For elementary types, a local copy is used if
7737 necessary to ensure by-copy semantics.
7743 An Ada parameter of an access-to-subprogram type is passed as a
7744 reference to a Fortran procedure whose interface corresponds to the
7745 designated subprogram's specification.
7749 @cindex Machine operations
7750 @unnumberedsec C.1(3-5): Access to Machine Operations
7753 The machine code or intrinsic support should allow access to all
7754 operations normally available to assembly language programmers for the
7755 target environment, including privileged instructions, if any.
7761 The interfacing pragmas (see Annex B) should support interface to
7762 assembler; the default assembler should be associated with the
7763 convention identifier @code{Assembler}.
7769 If an entity is exported to assembly language, then the implementation
7770 should allocate it at an addressable location, and should ensure that it
7771 is retained by the linking process, even if not otherwise referenced
7772 from the Ada code. The implementation should assume that any call to a
7773 machine code or assembler subprogram is allowed to read or update every
7774 object that is specified as exported.
7778 @unnumberedsec C.1(10-16): Access to Machine Operations
7781 The implementation should ensure that little or no overhead is
7782 associated with calling intrinsic and machine-code subprograms.
7784 Followed for both intrinsics and machine-code subprograms.
7788 It is recommended that intrinsic subprograms be provided for convenient
7789 access to any machine operations that provide special capabilities or
7790 efficiency and that are not otherwise available through the language
7793 Followed. A full set of machine operation intrinsic subprograms is provided.
7797 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7798 swap, decrement and test, enqueue/dequeue.
7800 Followed on any target supporting such operations.
7804 Standard numeric functions---e.g.@:, sin, log.
7806 Followed on any target supporting such operations.
7810 String manipulation operations---e.g.@:, translate and test.
7812 Followed on any target supporting such operations.
7816 Vector operations---e.g.@:, compare vector against thresholds.
7818 Followed on any target supporting such operations.
7822 Direct operations on I/O ports.
7824 Followed on any target supporting such operations.
7826 @cindex Interrupt support
7827 @unnumberedsec C.3(28): Interrupt Support
7830 If the @code{Ceiling_Locking} policy is not in effect, the
7831 implementation should provide means for the application to specify which
7832 interrupts are to be blocked during protected actions, if the underlying
7833 system allows for a finer-grain control of interrupt blocking.
7835 Followed. The underlying system does not allow for finer-grain control
7836 of interrupt blocking.
7838 @cindex Protected procedure handlers
7839 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7842 Whenever possible, the implementation should allow interrupt handlers to
7843 be called directly by the hardware.
7847 This is never possible under IRIX, so this is followed by default.
7849 Followed on any target where the underlying operating system permits
7854 Whenever practical, violations of any
7855 implementation-defined restrictions should be detected before run time.
7857 Followed. Compile time warnings are given when possible.
7859 @cindex Package @code{Interrupts}
7861 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7865 If implementation-defined forms of interrupt handler procedures are
7866 supported, such as protected procedures with parameters, then for each
7867 such form of a handler, a type analogous to @code{Parameterless_Handler}
7868 should be specified in a child package of @code{Interrupts}, with the
7869 same operations as in the predefined package Interrupts.
7873 @cindex Pre-elaboration requirements
7874 @unnumberedsec C.4(14): Pre-elaboration Requirements
7877 It is recommended that pre-elaborated packages be implemented in such a
7878 way that there should be little or no code executed at run time for the
7879 elaboration of entities not already covered by the Implementation
7882 Followed. Executable code is generated in some cases, e.g.@: loops
7883 to initialize large arrays.
7885 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7888 If the pragma applies to an entity, then the implementation should
7889 reduce the amount of storage used for storing names associated with that
7894 @cindex Package @code{Task_Attributes}
7895 @findex Task_Attributes
7896 @unnumberedsec C.7.2(30): The Package Task_Attributes
7899 Some implementations are targeted to domains in which memory use at run
7900 time must be completely deterministic. For such implementations, it is
7901 recommended that the storage for task attributes will be pre-allocated
7902 statically and not from the heap. This can be accomplished by either
7903 placing restrictions on the number and the size of the task's
7904 attributes, or by using the pre-allocated storage for the first @var{N}
7905 attribute objects, and the heap for the others. In the latter case,
7906 @var{N} should be documented.
7908 Not followed. This implementation is not targeted to such a domain.
7910 @cindex Locking Policies
7911 @unnumberedsec D.3(17): Locking Policies
7915 The implementation should use names that end with @samp{_Locking} for
7916 locking policies defined by the implementation.
7918 Followed. A single implementation-defined locking policy is defined,
7919 whose name (@code{Inheritance_Locking}) follows this suggestion.
7921 @cindex Entry queuing policies
7922 @unnumberedsec D.4(16): Entry Queuing Policies
7925 Names that end with @samp{_Queuing} should be used
7926 for all implementation-defined queuing policies.
7928 Followed. No such implementation-defined queuing policies exist.
7930 @cindex Preemptive abort
7931 @unnumberedsec D.6(9-10): Preemptive Abort
7934 Even though the @code{abort_statement} is included in the list of
7935 potentially blocking operations (see 9.5.1), it is recommended that this
7936 statement be implemented in a way that never requires the task executing
7937 the @code{abort_statement} to block.
7943 On a multi-processor, the delay associated with aborting a task on
7944 another processor should be bounded; the implementation should use
7945 periodic polling, if necessary, to achieve this.
7949 @cindex Tasking restrictions
7950 @unnumberedsec D.7(21): Tasking Restrictions
7953 When feasible, the implementation should take advantage of the specified
7954 restrictions to produce a more efficient implementation.
7956 GNAT currently takes advantage of these restrictions by providing an optimized
7957 run time when the Ravenscar profile and the GNAT restricted run time set
7958 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7959 pragma @code{Profile (Restricted)} for more details.
7961 @cindex Time, monotonic
7962 @unnumberedsec D.8(47-49): Monotonic Time
7965 When appropriate, implementations should provide configuration
7966 mechanisms to change the value of @code{Tick}.
7968 Such configuration mechanisms are not appropriate to this implementation
7969 and are thus not supported.
7973 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7974 be implemented as transformations of the same time base.
7980 It is recommended that the @dfn{best} time base which exists in
7981 the underlying system be available to the application through
7982 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7986 @cindex Partition communication subsystem
7988 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7991 Whenever possible, the PCS on the called partition should allow for
7992 multiple tasks to call the RPC-receiver with different messages and
7993 should allow them to block until the corresponding subprogram body
7996 Followed by GLADE, a separately supplied PCS that can be used with
8001 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
8002 should raise @code{Storage_Error} if it runs out of space trying to
8003 write the @code{Item} into the stream.
8005 Followed by GLADE, a separately supplied PCS that can be used with
8008 @cindex COBOL support
8009 @unnumberedsec F(7): COBOL Support
8012 If COBOL (respectively, C) is widely supported in the target
8013 environment, implementations supporting the Information Systems Annex
8014 should provide the child package @code{Interfaces.COBOL} (respectively,
8015 @code{Interfaces.C}) specified in Annex B and should support a
8016 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
8017 pragmas (see Annex B), thus allowing Ada programs to interface with
8018 programs written in that language.
8022 @cindex Decimal radix support
8023 @unnumberedsec F.1(2): Decimal Radix Support
8026 Packed decimal should be used as the internal representation for objects
8027 of subtype @var{S} when @var{S}'Machine_Radix = 10.
8029 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
8033 @unnumberedsec G: Numerics
8036 If Fortran (respectively, C) is widely supported in the target
8037 environment, implementations supporting the Numerics Annex
8038 should provide the child package @code{Interfaces.Fortran} (respectively,
8039 @code{Interfaces.C}) specified in Annex B and should support a
8040 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
8041 pragmas (see Annex B), thus allowing Ada programs to interface with
8042 programs written in that language.
8046 @cindex Complex types
8047 @unnumberedsec G.1.1(56-58): Complex Types
8050 Because the usual mathematical meaning of multiplication of a complex
8051 operand and a real operand is that of the scaling of both components of
8052 the former by the latter, an implementation should not perform this
8053 operation by first promoting the real operand to complex type and then
8054 performing a full complex multiplication. In systems that, in the
8055 future, support an Ada binding to IEC 559:1989, the latter technique
8056 will not generate the required result when one of the components of the
8057 complex operand is infinite. (Explicit multiplication of the infinite
8058 component by the zero component obtained during promotion yields a NaN
8059 that propagates into the final result.) Analogous advice applies in the
8060 case of multiplication of a complex operand and a pure-imaginary
8061 operand, and in the case of division of a complex operand by a real or
8062 pure-imaginary operand.
8068 Similarly, because the usual mathematical meaning of addition of a
8069 complex operand and a real operand is that the imaginary operand remains
8070 unchanged, an implementation should not perform this operation by first
8071 promoting the real operand to complex type and then performing a full
8072 complex addition. In implementations in which the @code{Signed_Zeros}
8073 attribute of the component type is @code{True} (and which therefore
8074 conform to IEC 559:1989 in regard to the handling of the sign of zero in
8075 predefined arithmetic operations), the latter technique will not
8076 generate the required result when the imaginary component of the complex
8077 operand is a negatively signed zero. (Explicit addition of the negative
8078 zero to the zero obtained during promotion yields a positive zero.)
8079 Analogous advice applies in the case of addition of a complex operand
8080 and a pure-imaginary operand, and in the case of subtraction of a
8081 complex operand and a real or pure-imaginary operand.
8087 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
8088 attempt to provide a rational treatment of the signs of zero results and
8089 result components. As one example, the result of the @code{Argument}
8090 function should have the sign of the imaginary component of the
8091 parameter @code{X} when the point represented by that parameter lies on
8092 the positive real axis; as another, the sign of the imaginary component
8093 of the @code{Compose_From_Polar} function should be the same as
8094 (respectively, the opposite of) that of the @code{Argument} parameter when that
8095 parameter has a value of zero and the @code{Modulus} parameter has a
8096 nonnegative (respectively, negative) value.
8100 @cindex Complex elementary functions
8101 @unnumberedsec G.1.2(49): Complex Elementary Functions
8104 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
8105 @code{True} should attempt to provide a rational treatment of the signs
8106 of zero results and result components. For example, many of the complex
8107 elementary functions have components that are odd functions of one of
8108 the parameter components; in these cases, the result component should
8109 have the sign of the parameter component at the origin. Other complex
8110 elementary functions have zero components whose sign is opposite that of
8111 a parameter component at the origin, or is always positive or always
8116 @cindex Accuracy requirements
8117 @unnumberedsec G.2.4(19): Accuracy Requirements
8120 The versions of the forward trigonometric functions without a
8121 @code{Cycle} parameter should not be implemented by calling the
8122 corresponding version with a @code{Cycle} parameter of
8123 @code{2.0*Numerics.Pi}, since this will not provide the required
8124 accuracy in some portions of the domain. For the same reason, the
8125 version of @code{Log} without a @code{Base} parameter should not be
8126 implemented by calling the corresponding version with a @code{Base}
8127 parameter of @code{Numerics.e}.
8131 @cindex Complex arithmetic accuracy
8132 @cindex Accuracy, complex arithmetic
8133 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
8137 The version of the @code{Compose_From_Polar} function without a
8138 @code{Cycle} parameter should not be implemented by calling the
8139 corresponding version with a @code{Cycle} parameter of
8140 @code{2.0*Numerics.Pi}, since this will not provide the required
8141 accuracy in some portions of the domain.
8145 @c -----------------------------------------
8146 @node Implementation Defined Characteristics
8147 @chapter Implementation Defined Characteristics
8150 In addition to the implementation dependent pragmas and attributes, and the
8151 implementation advice, there are a number of other Ada features that are
8152 potentially implementation dependent and are designated as
8153 implementation-defined. These are mentioned throughout the Ada Reference
8154 Manual, and are summarized in Annex M@.
8156 A requirement for conforming Ada compilers is that they provide
8157 documentation describing how the implementation deals with each of these
8158 issues. In this chapter, you will find each point in Annex M listed
8159 followed by a description in italic font of how GNAT
8163 implementation on IRIX 5.3 operating system or greater
8165 handles the implementation dependence.
8167 You can use this chapter as a guide to minimizing implementation
8168 dependent features in your programs if portability to other compilers
8169 and other operating systems is an important consideration. The numbers
8170 in each section below correspond to the paragraph number in the Ada
8176 @strong{2}. Whether or not each recommendation given in Implementation
8177 Advice is followed. See 1.1.2(37).
8180 @xref{Implementation Advice}.
8185 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
8188 The complexity of programs that can be processed is limited only by the
8189 total amount of available virtual memory, and disk space for the
8190 generated object files.
8195 @strong{4}. Variations from the standard that are impractical to avoid
8196 given the implementation's execution environment. See 1.1.3(6).
8199 There are no variations from the standard.
8204 @strong{5}. Which @code{code_statement}s cause external
8205 interactions. See 1.1.3(10).
8208 Any @code{code_statement} can potentially cause external interactions.
8213 @strong{6}. The coded representation for the text of an Ada
8214 program. See 2.1(4).
8217 See separate section on source representation.
8222 @strong{7}. The control functions allowed in comments. See 2.1(14).
8225 See separate section on source representation.
8230 @strong{8}. The representation for an end of line. See 2.2(2).
8233 See separate section on source representation.
8238 @strong{9}. Maximum supported line length and lexical element
8239 length. See 2.2(15).
8242 The maximum line length is 255 characters and the maximum length of a
8243 lexical element is also 255 characters.
8248 @strong{10}. Implementation defined pragmas. See 2.8(14).
8252 @xref{Implementation Defined Pragmas}.
8257 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
8260 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
8261 parameter, checks that the optimization flag is set, and aborts if it is
8267 @strong{12}. The sequence of characters of the value returned by
8268 @code{@var{S}'Image} when some of the graphic characters of
8269 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
8273 The sequence of characters is as defined by the wide character encoding
8274 method used for the source. See section on source representation for
8280 @strong{13}. The predefined integer types declared in
8281 @code{Standard}. See 3.5.4(25).
8285 @item Short_Short_Integer
8288 (Short) 16 bit signed
8292 64 bit signed (on most 64 bit targets, depending on the C definition of long).
8293 32 bit signed (all other targets)
8294 @item Long_Long_Integer
8301 @strong{14}. Any nonstandard integer types and the operators defined
8302 for them. See 3.5.4(26).
8305 There are no nonstandard integer types.
8310 @strong{15}. Any nonstandard real types and the operators defined for
8314 There are no nonstandard real types.
8319 @strong{16}. What combinations of requested decimal precision and range
8320 are supported for floating point types. See 3.5.7(7).
8323 The precision and range is as defined by the IEEE standard.
8328 @strong{17}. The predefined floating point types declared in
8329 @code{Standard}. See 3.5.7(16).
8336 (Short) 32 bit IEEE short
8339 @item Long_Long_Float
8340 64 bit IEEE long (80 bit IEEE long on x86 processors)
8346 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
8349 @code{Fine_Delta} is 2**(@minus{}63)
8354 @strong{19}. What combinations of small, range, and digits are
8355 supported for fixed point types. See 3.5.9(10).
8358 Any combinations are permitted that do not result in a small less than
8359 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
8360 If the mantissa is larger than 53 bits on machines where Long_Long_Float
8361 is 64 bits (true of all architectures except ia32), then the output from
8362 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
8363 is because floating-point conversions are used to convert fixed point.
8368 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
8369 within an unnamed @code{block_statement}. See 3.9(10).
8372 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
8373 decimal integer are allocated.
8378 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
8381 @xref{Implementation Defined Attributes}.
8386 @strong{22}. Any implementation-defined time types. See 9.6(6).
8389 There are no implementation-defined time types.
8394 @strong{23}. The time base associated with relative delays.
8397 See 9.6(20). The time base used is that provided by the C library
8398 function @code{gettimeofday}.
8403 @strong{24}. The time base of the type @code{Calendar.Time}. See
8407 The time base used is that provided by the C library function
8408 @code{gettimeofday}.
8413 @strong{25}. The time zone used for package @code{Calendar}
8414 operations. See 9.6(24).
8417 The time zone used by package @code{Calendar} is the current system time zone
8418 setting for local time, as accessed by the C library function
8424 @strong{26}. Any limit on @code{delay_until_statements} of
8425 @code{select_statements}. See 9.6(29).
8428 There are no such limits.
8433 @strong{27}. Whether or not two non-overlapping parts of a composite
8434 object are independently addressable, in the case where packing, record
8435 layout, or @code{Component_Size} is specified for the object. See
8439 Separate components are independently addressable if they do not share
8440 overlapping storage units.
8445 @strong{28}. The representation for a compilation. See 10.1(2).
8448 A compilation is represented by a sequence of files presented to the
8449 compiler in a single invocation of the @command{gcc} command.
8454 @strong{29}. Any restrictions on compilations that contain multiple
8455 compilation_units. See 10.1(4).
8458 No single file can contain more than one compilation unit, but any
8459 sequence of files can be presented to the compiler as a single
8465 @strong{30}. The mechanisms for creating an environment and for adding
8466 and replacing compilation units. See 10.1.4(3).
8469 See separate section on compilation model.
8474 @strong{31}. The manner of explicitly assigning library units to a
8475 partition. See 10.2(2).
8478 If a unit contains an Ada main program, then the Ada units for the partition
8479 are determined by recursive application of the rules in the Ada Reference
8480 Manual section 10.2(2-6). In other words, the Ada units will be those that
8481 are needed by the main program, and then this definition of need is applied
8482 recursively to those units, and the partition contains the transitive
8483 closure determined by this relationship. In short, all the necessary units
8484 are included, with no need to explicitly specify the list. If additional
8485 units are required, e.g.@: by foreign language units, then all units must be
8486 mentioned in the context clause of one of the needed Ada units.
8488 If the partition contains no main program, or if the main program is in
8489 a language other than Ada, then GNAT
8490 provides the binder options @option{-z} and @option{-n} respectively, and in
8491 this case a list of units can be explicitly supplied to the binder for
8492 inclusion in the partition (all units needed by these units will also
8493 be included automatically). For full details on the use of these
8494 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8495 @value{EDITION} User's Guide}.
8500 @strong{32}. The implementation-defined means, if any, of specifying
8501 which compilation units are needed by a given compilation unit. See
8505 The units needed by a given compilation unit are as defined in
8506 the Ada Reference Manual section 10.2(2-6). There are no
8507 implementation-defined pragmas or other implementation-defined
8508 means for specifying needed units.
8513 @strong{33}. The manner of designating the main subprogram of a
8514 partition. See 10.2(7).
8517 The main program is designated by providing the name of the
8518 corresponding @file{ALI} file as the input parameter to the binder.
8523 @strong{34}. The order of elaboration of @code{library_items}. See
8527 The first constraint on ordering is that it meets the requirements of
8528 Chapter 10 of the Ada Reference Manual. This still leaves some
8529 implementation dependent choices, which are resolved by first
8530 elaborating bodies as early as possible (i.e., in preference to specs
8531 where there is a choice), and second by evaluating the immediate with
8532 clauses of a unit to determine the probably best choice, and
8533 third by elaborating in alphabetical order of unit names
8534 where a choice still remains.
8539 @strong{35}. Parameter passing and function return for the main
8540 subprogram. See 10.2(21).
8543 The main program has no parameters. It may be a procedure, or a function
8544 returning an integer type. In the latter case, the returned integer
8545 value is the return code of the program (overriding any value that
8546 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8551 @strong{36}. The mechanisms for building and running partitions. See
8555 GNAT itself supports programs with only a single partition. The GNATDIST
8556 tool provided with the GLADE package (which also includes an implementation
8557 of the PCS) provides a completely flexible method for building and running
8558 programs consisting of multiple partitions. See the separate GLADE manual
8564 @strong{37}. The details of program execution, including program
8565 termination. See 10.2(25).
8568 See separate section on compilation model.
8573 @strong{38}. The semantics of any non-active partitions supported by the
8574 implementation. See 10.2(28).
8577 Passive partitions are supported on targets where shared memory is
8578 provided by the operating system. See the GLADE reference manual for
8584 @strong{39}. The information returned by @code{Exception_Message}. See
8588 Exception message returns the null string unless a specific message has
8589 been passed by the program.
8594 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
8595 declared within an unnamed @code{block_statement}. See 11.4.1(12).
8598 Blocks have implementation defined names of the form @code{B@var{nnn}}
8599 where @var{nnn} is an integer.
8604 @strong{41}. The information returned by
8605 @code{Exception_Information}. See 11.4.1(13).
8608 @code{Exception_Information} returns a string in the following format:
8611 @emph{Exception_Name:} nnnnn
8612 @emph{Message:} mmmmm
8614 @emph{Call stack traceback locations:}
8615 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8623 @code{nnnn} is the fully qualified name of the exception in all upper
8624 case letters. This line is always present.
8627 @code{mmmm} is the message (this line present only if message is non-null)
8630 @code{ppp} is the Process Id value as a decimal integer (this line is
8631 present only if the Process Id is nonzero). Currently we are
8632 not making use of this field.
8635 The Call stack traceback locations line and the following values
8636 are present only if at least one traceback location was recorded.
8637 The values are given in C style format, with lower case letters
8638 for a-f, and only as many digits present as are necessary.
8642 The line terminator sequence at the end of each line, including
8643 the last line is a single @code{LF} character (@code{16#0A#}).
8648 @strong{42}. Implementation-defined check names. See 11.5(27).
8651 The implementation defined check name Alignment_Check controls checking of
8652 address clause values for proper alignment (that is, the address supplied
8653 must be consistent with the alignment of the type).
8655 In addition, a user program can add implementation-defined check names
8656 by means of the pragma Check_Name.
8661 @strong{43}. The interpretation of each aspect of representation. See
8665 See separate section on data representations.
8670 @strong{44}. Any restrictions placed upon representation items. See
8674 See separate section on data representations.
8679 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8683 Size for an indefinite subtype is the maximum possible size, except that
8684 for the case of a subprogram parameter, the size of the parameter object
8690 @strong{46}. The default external representation for a type tag. See
8694 The default external representation for a type tag is the fully expanded
8695 name of the type in upper case letters.
8700 @strong{47}. What determines whether a compilation unit is the same in
8701 two different partitions. See 13.3(76).
8704 A compilation unit is the same in two different partitions if and only
8705 if it derives from the same source file.
8710 @strong{48}. Implementation-defined components. See 13.5.1(15).
8713 The only implementation defined component is the tag for a tagged type,
8714 which contains a pointer to the dispatching table.
8719 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8720 ordering. See 13.5.3(5).
8723 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8724 implementation, so no non-default bit ordering is supported. The default
8725 bit ordering corresponds to the natural endianness of the target architecture.
8730 @strong{50}. The contents of the visible part of package @code{System}
8731 and its language-defined children. See 13.7(2).
8734 See the definition of these packages in files @file{system.ads} and
8735 @file{s-stoele.ads}.
8740 @strong{51}. The contents of the visible part of package
8741 @code{System.Machine_Code}, and the meaning of
8742 @code{code_statements}. See 13.8(7).
8745 See the definition and documentation in file @file{s-maccod.ads}.
8750 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8753 Unchecked conversion between types of the same size
8754 results in an uninterpreted transmission of the bits from one type
8755 to the other. If the types are of unequal sizes, then in the case of
8756 discrete types, a shorter source is first zero or sign extended as
8757 necessary, and a shorter target is simply truncated on the left.
8758 For all non-discrete types, the source is first copied if necessary
8759 to ensure that the alignment requirements of the target are met, then
8760 a pointer is constructed to the source value, and the result is obtained
8761 by dereferencing this pointer after converting it to be a pointer to the
8762 target type. Unchecked conversions where the target subtype is an
8763 unconstrained array are not permitted. If the target alignment is
8764 greater than the source alignment, then a copy of the result is
8765 made with appropriate alignment
8770 @strong{53}. The semantics of operations on invalid representations.
8774 For assignments and other operations where the use of invalid values cannot
8775 result in erroneous behavior, the compiler ignores the possibility of invalid
8776 values. An exception is raised at the point where an invalid value would
8777 result in erroneous behavior. For example executing:
8779 @smallexample @c ada
8780 procedure invalidvals is
8782 Y : Natural range 1 .. 10;
8783 for Y'Address use X'Address;
8784 Z : Natural range 1 .. 10;
8785 A : array (Natural range 1 .. 10) of Integer;
8787 Z := Y; -- no exception
8788 A (Z) := 3; -- exception raised;
8793 As indicated, an exception is raised on the array assignment, but not
8794 on the simple assignment of the invalid negative value from Y to Z.
8799 @strong{53}. The manner of choosing a storage pool for an access type
8800 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8803 There are 3 different standard pools used by the compiler when
8804 @code{Storage_Pool} is not specified depending whether the type is local
8805 to a subprogram or defined at the library level and whether
8806 @code{Storage_Size}is specified or not. See documentation in the runtime
8807 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8808 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8809 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8815 @strong{54}. Whether or not the implementation provides user-accessible
8816 names for the standard pool type(s). See 13.11(17).
8820 See documentation in the sources of the run time mentioned in paragraph
8821 @strong{53} . All these pools are accessible by means of @code{with}'ing
8827 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8830 @code{Storage_Size} is measured in storage units, and refers to the
8831 total space available for an access type collection, or to the primary
8832 stack space for a task.
8837 @strong{56}. Implementation-defined aspects of storage pools. See
8841 See documentation in the sources of the run time mentioned in paragraph
8842 @strong{53} for details on GNAT-defined aspects of storage pools.
8847 @strong{57}. The set of restrictions allowed in a pragma
8848 @code{Restrictions}. See 13.12(7).
8851 All RM defined Restriction identifiers are implemented. The following
8852 additional restriction identifiers are provided. There are two separate
8853 lists of implementation dependent restriction identifiers. The first
8854 set requires consistency throughout a partition (in other words, if the
8855 restriction identifier is used for any compilation unit in the partition,
8856 then all compilation units in the partition must obey the restriction.
8860 @item Simple_Barriers
8861 @findex Simple_Barriers
8862 This restriction ensures at compile time that barriers in entry declarations
8863 for protected types are restricted to either static boolean expressions or
8864 references to simple boolean variables defined in the private part of the
8865 protected type. No other form of entry barriers is permitted. This is one
8866 of the restrictions of the Ravenscar profile for limited tasking (see also
8867 pragma @code{Profile (Ravenscar)}).
8869 @item Max_Entry_Queue_Length => Expr
8870 @findex Max_Entry_Queue_Length
8871 This restriction is a declaration that any protected entry compiled in
8872 the scope of the restriction has at most the specified number of
8873 tasks waiting on the entry
8874 at any one time, and so no queue is required. This restriction is not
8875 checked at compile time. A program execution is erroneous if an attempt
8876 is made to queue more than the specified number of tasks on such an entry.
8880 This restriction ensures at compile time that there is no implicit or
8881 explicit dependence on the package @code{Ada.Calendar}.
8883 @item No_Default_Initialization
8884 @findex No_Default_Initialization
8886 This restriction prohibits any instance of default initialization of variables.
8887 The binder implements a consistency rule which prevents any unit compiled
8888 without the restriction from with'ing a unit with the restriction (this allows
8889 the generation of initialization procedures to be skipped, since you can be
8890 sure that no call is ever generated to an initialization procedure in a unit
8891 with the restriction active). If used in conjunction with Initialize_Scalars or
8892 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8893 without a specific initializer (including the case of OUT scalar parameters).
8895 @item No_Direct_Boolean_Operators
8896 @findex No_Direct_Boolean_Operators
8897 This restriction ensures that no logical (and/or/xor) are used on
8898 operands of type Boolean (or any type derived
8899 from Boolean). This is intended for use in safety critical programs
8900 where the certification protocol requires the use of short-circuit
8901 (and then, or else) forms for all composite boolean operations.
8903 @item No_Dispatching_Calls
8904 @findex No_Dispatching_Calls
8905 This restriction ensures at compile time that the code generated by the
8906 compiler involves no dispatching calls. The use of this restriction allows the
8907 safe use of record extensions, classwide membership tests and other classwide
8908 features not involving implicit dispatching. This restriction ensures that
8909 the code contains no indirect calls through a dispatching mechanism. Note that
8910 this includes internally-generated calls created by the compiler, for example
8911 in the implementation of class-wide objects assignments. The
8912 membership test is allowed in the presence of this restriction, because its
8913 implementation requires no dispatching.
8914 This restriction is comparable to the official Ada restriction
8915 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8916 all classwide constructs that do not imply dispatching.
8917 The following example indicates constructs that violate this restriction.
8921 type T is tagged record
8924 procedure P (X : T);
8926 type DT is new T with record
8927 More_Data : Natural;
8929 procedure Q (X : DT);
8933 procedure Example is
8934 procedure Test (O : T'Class) is
8935 N : Natural := O'Size;-- Error: Dispatching call
8936 C : T'Class := O; -- Error: implicit Dispatching Call
8938 if O in DT'Class then -- OK : Membership test
8939 Q (DT (O)); -- OK : Type conversion plus direct call
8941 P (O); -- Error: Dispatching call
8947 P (Obj); -- OK : Direct call
8948 P (T (Obj)); -- OK : Type conversion plus direct call
8949 P (T'Class (Obj)); -- Error: Dispatching call
8951 Test (Obj); -- OK : Type conversion
8953 if Obj in T'Class then -- OK : Membership test
8959 @item No_Dynamic_Attachment
8960 @findex No_Dynamic_Attachment
8961 This restriction ensures that there is no call to any of the operations
8962 defined in package Ada.Interrupts.
8964 @item No_Enumeration_Maps
8965 @findex No_Enumeration_Maps
8966 This restriction ensures at compile time that no operations requiring
8967 enumeration maps are used (that is Image and Value attributes applied
8968 to enumeration types).
8970 @item No_Entry_Calls_In_Elaboration_Code
8971 @findex No_Entry_Calls_In_Elaboration_Code
8972 This restriction ensures at compile time that no task or protected entry
8973 calls are made during elaboration code. As a result of the use of this
8974 restriction, the compiler can assume that no code past an accept statement
8975 in a task can be executed at elaboration time.
8977 @item No_Exception_Handlers
8978 @findex No_Exception_Handlers
8979 This restriction ensures at compile time that there are no explicit
8980 exception handlers. It also indicates that no exception propagation will
8981 be provided. In this mode, exceptions may be raised but will result in
8982 an immediate call to the last chance handler, a routine that the user
8983 must define with the following profile:
8985 @smallexample @c ada
8986 procedure Last_Chance_Handler
8987 (Source_Location : System.Address; Line : Integer);
8988 pragma Export (C, Last_Chance_Handler,
8989 "__gnat_last_chance_handler");
8992 The parameter is a C null-terminated string representing a message to be
8993 associated with the exception (typically the source location of the raise
8994 statement generated by the compiler). The Line parameter when nonzero
8995 represents the line number in the source program where the raise occurs.
8997 @item No_Exception_Propagation
8998 @findex No_Exception_Propagation
8999 This restriction guarantees that exceptions are never propagated to an outer
9000 subprogram scope). The only case in which an exception may be raised is when
9001 the handler is statically in the same subprogram, so that the effect of a raise
9002 is essentially like a goto statement. Any other raise statement (implicit or
9003 explicit) will be considered unhandled. Exception handlers are allowed, but may
9004 not contain an exception occurrence identifier (exception choice). In addition
9005 use of the package GNAT.Current_Exception is not permitted, and reraise
9006 statements (raise with no operand) are not permitted.
9008 @item No_Exception_Registration
9009 @findex No_Exception_Registration
9010 This restriction ensures at compile time that no stream operations for
9011 types Exception_Id or Exception_Occurrence are used. This also makes it
9012 impossible to pass exceptions to or from a partition with this restriction
9013 in a distributed environment. If this exception is active, then the generated
9014 code is simplified by omitting the otherwise-required global registration
9015 of exceptions when they are declared.
9017 @item No_Implicit_Aliasing
9018 @findex No_Implicit_Aliasing
9020 This restriction, which is not required to be partition-wide consistent,
9021 requires an explicit aliased keyword for an object to which 'Access,
9022 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
9023 the 'Unrestricted_Access attribute for objects. Note: the reason that
9024 Unrestricted_Access is forbidden is that it would require the prefix
9025 to be aliased, and in such cases, it can always be replaced by
9026 the standard attribute Unchecked_Access which is preferable.
9028 @item No_Implicit_Conditionals
9029 @findex No_Implicit_Conditionals
9030 This restriction ensures that the generated code does not contain any
9031 implicit conditionals, either by modifying the generated code where possible,
9032 or by rejecting any construct that would otherwise generate an implicit
9033 conditional. Note that this check does not include run time constraint
9034 checks, which on some targets may generate implicit conditionals as
9035 well. To control the latter, constraint checks can be suppressed in the
9036 normal manner. Constructs generating implicit conditionals include comparisons
9037 of composite objects and the Max/Min attributes.
9039 @item No_Implicit_Dynamic_Code
9040 @findex No_Implicit_Dynamic_Code
9042 This restriction prevents the compiler from building ``trampolines''.
9043 This is a structure that is built on the stack and contains dynamic
9044 code to be executed at run time. On some targets, a trampoline is
9045 built for the following features: @code{Access},
9046 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
9047 nested task bodies; primitive operations of nested tagged types.
9048 Trampolines do not work on machines that prevent execution of stack
9049 data. For example, on windows systems, enabling DEP (data execution
9050 protection) will cause trampolines to raise an exception.
9051 Trampolines are also quite slow at run time.
9053 On many targets, trampolines have been largely eliminated. Look at the
9054 version of system.ads for your target --- if it has
9055 Always_Compatible_Rep equal to False, then trampolines are largely
9056 eliminated. In particular, a trampoline is built for the following
9057 features: @code{Address} of a nested subprogram;
9058 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
9059 but only if pragma Favor_Top_Level applies, or the access type has a
9060 foreign-language convention; primitive operations of nested tagged
9063 @item No_Implicit_Loops
9064 @findex No_Implicit_Loops
9065 This restriction ensures that the generated code does not contain any
9066 implicit @code{for} loops, either by modifying
9067 the generated code where possible,
9068 or by rejecting any construct that would otherwise generate an implicit
9069 @code{for} loop. If this restriction is active, it is possible to build
9070 large array aggregates with all static components without generating an
9071 intermediate temporary, and without generating a loop to initialize individual
9072 components. Otherwise, a loop is created for arrays larger than about 5000
9075 @item No_Initialize_Scalars
9076 @findex No_Initialize_Scalars
9077 This restriction ensures that no unit in the partition is compiled with
9078 pragma Initialize_Scalars. This allows the generation of more efficient
9079 code, and in particular eliminates dummy null initialization routines that
9080 are otherwise generated for some record and array types.
9082 @item No_Local_Protected_Objects
9083 @findex No_Local_Protected_Objects
9084 This restriction ensures at compile time that protected objects are
9085 only declared at the library level.
9087 @item No_Protected_Type_Allocators
9088 @findex No_Protected_Type_Allocators
9089 This restriction ensures at compile time that there are no allocator
9090 expressions that attempt to allocate protected objects.
9092 @item No_Secondary_Stack
9093 @findex No_Secondary_Stack
9094 This restriction ensures at compile time that the generated code does not
9095 contain any reference to the secondary stack. The secondary stack is used
9096 to implement functions returning unconstrained objects (arrays or records)
9099 @item No_Select_Statements
9100 @findex No_Select_Statements
9101 This restriction ensures at compile time no select statements of any kind
9102 are permitted, that is the keyword @code{select} may not appear.
9103 This is one of the restrictions of the Ravenscar
9104 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
9106 @item No_Standard_Storage_Pools
9107 @findex No_Standard_Storage_Pools
9108 This restriction ensures at compile time that no access types
9109 use the standard default storage pool. Any access type declared must
9110 have an explicit Storage_Pool attribute defined specifying a
9111 user-defined storage pool.
9115 This restriction ensures at compile/bind time that there are no
9116 stream objects created and no use of stream attributes.
9117 This restriction does not forbid dependences on the package
9118 @code{Ada.Streams}. So it is permissible to with
9119 @code{Ada.Streams} (or another package that does so itself)
9120 as long as no actual stream objects are created and no
9121 stream attributes are used.
9123 Note that the use of restriction allows optimization of tagged types,
9124 since they do not need to worry about dispatching stream operations.
9125 To take maximum advantage of this space-saving optimization, any
9126 unit declaring a tagged type should be compiled with the restriction,
9127 though this is not required.
9129 @item No_Task_Attributes_Package
9130 @findex No_Task_Attributes_Package
9131 This restriction ensures at compile time that there are no implicit or
9132 explicit dependencies on the package @code{Ada.Task_Attributes}.
9134 @item No_Task_Termination
9135 @findex No_Task_Termination
9136 This restriction ensures at compile time that no terminate alternatives
9137 appear in any task body.
9141 This restriction prevents the declaration of tasks or task types throughout
9142 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
9143 except that violations are caught at compile time and cause an error message
9144 to be output either by the compiler or binder.
9146 @item Static_Priorities
9147 @findex Static_Priorities
9148 This restriction ensures at compile time that all priority expressions
9149 are static, and that there are no dependencies on the package
9150 @code{Ada.Dynamic_Priorities}.
9152 @item Static_Storage_Size
9153 @findex Static_Storage_Size
9154 This restriction ensures at compile time that any expression appearing
9155 in a Storage_Size pragma or attribute definition clause is static.
9160 The second set of implementation dependent restriction identifiers
9161 does not require partition-wide consistency.
9162 The restriction may be enforced for a single
9163 compilation unit without any effect on any of the
9164 other compilation units in the partition.
9168 @item No_Elaboration_Code
9169 @findex No_Elaboration_Code
9170 This restriction ensures at compile time that no elaboration code is
9171 generated. Note that this is not the same condition as is enforced
9172 by pragma @code{Preelaborate}. There are cases in which pragma
9173 @code{Preelaborate} still permits code to be generated (e.g.@: code
9174 to initialize a large array to all zeroes), and there are cases of units
9175 which do not meet the requirements for pragma @code{Preelaborate},
9176 but for which no elaboration code is generated. Generally, it is
9177 the case that preelaborable units will meet the restrictions, with
9178 the exception of large aggregates initialized with an others_clause,
9179 and exception declarations (which generate calls to a run-time
9180 registry procedure). This restriction is enforced on
9181 a unit by unit basis, it need not be obeyed consistently
9182 throughout a partition.
9184 In the case of aggregates with others, if the aggregate has a dynamic
9185 size, there is no way to eliminate the elaboration code (such dynamic
9186 bounds would be incompatible with @code{Preelaborate} in any case). If
9187 the bounds are static, then use of this restriction actually modifies
9188 the code choice of the compiler to avoid generating a loop, and instead
9189 generate the aggregate statically if possible, no matter how many times
9190 the data for the others clause must be repeatedly generated.
9192 It is not possible to precisely document
9193 the constructs which are compatible with this restriction, since,
9194 unlike most other restrictions, this is not a restriction on the
9195 source code, but a restriction on the generated object code. For
9196 example, if the source contains a declaration:
9199 Val : constant Integer := X;
9203 where X is not a static constant, it may be possible, depending
9204 on complex optimization circuitry, for the compiler to figure
9205 out the value of X at compile time, in which case this initialization
9206 can be done by the loader, and requires no initialization code. It
9207 is not possible to document the precise conditions under which the
9208 optimizer can figure this out.
9210 Note that this the implementation of this restriction requires full
9211 code generation. If it is used in conjunction with "semantics only"
9212 checking, then some cases of violations may be missed.
9214 @item No_Entry_Queue
9215 @findex No_Entry_Queue
9216 This restriction is a declaration that any protected entry compiled in
9217 the scope of the restriction has at most one task waiting on the entry
9218 at any one time, and so no queue is required. This restriction is not
9219 checked at compile time. A program execution is erroneous if an attempt
9220 is made to queue a second task on such an entry.
9222 @item No_Implementation_Attributes
9223 @findex No_Implementation_Attributes
9224 This restriction checks at compile time that no GNAT-defined attributes
9225 are present. With this restriction, the only attributes that can be used
9226 are those defined in the Ada Reference Manual.
9228 @item No_Implementation_Pragmas
9229 @findex No_Implementation_Pragmas
9230 This restriction checks at compile time that no GNAT-defined pragmas
9231 are present. With this restriction, the only pragmas that can be used
9232 are those defined in the Ada Reference Manual.
9234 @item No_Implementation_Restrictions
9235 @findex No_Implementation_Restrictions
9236 This restriction checks at compile time that no GNAT-defined restriction
9237 identifiers (other than @code{No_Implementation_Restrictions} itself)
9238 are present. With this restriction, the only other restriction identifiers
9239 that can be used are those defined in the Ada Reference Manual.
9241 @item No_Wide_Characters
9242 @findex No_Wide_Characters
9243 This restriction ensures at compile time that no uses of the types
9244 @code{Wide_Character} or @code{Wide_String} or corresponding wide
9246 appear, and that no wide or wide wide string or character literals
9247 appear in the program (that is literals representing characters not in
9248 type @code{Character}.
9252 This restriction checks at compile time that some constructs forbidden in
9253 SPARK are not present. The SPARK version used as a reference is the same as
9254 the Ada mode for the unit, so a unit compiled in Ada 95 mode with SPARK
9255 restrictions will be checked for constructs forbidden in SPARK 95.
9256 Error messages related to SPARK restriction have the form:
9259 violation of restriction "Spark" at <file>
9263 This is not a replacement for the semantic checks performed by the
9264 SPARK Examiner tool, as the compiler only deals currently with code,
9265 not at all with SPARK annotations and does not guarantee catching all
9266 cases of constructs forbidden by SPARK.
9268 Thus it may well be the case that code which
9269 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
9270 e.g. due to the different visibility rules of the Examiner based on
9271 SPARK @code{inherit} annotations.
9273 This restriction can be useful in providing an initial filter for
9274 code developed using SPARK, or in examining legacy code to see how far
9275 it is from meeting SPARK restrictions.
9282 @strong{58}. The consequences of violating limitations on
9283 @code{Restrictions} pragmas. See 13.12(9).
9286 Restrictions that can be checked at compile time result in illegalities
9287 if violated. Currently there are no other consequences of violating
9293 @strong{59}. The representation used by the @code{Read} and
9294 @code{Write} attributes of elementary types in terms of stream
9295 elements. See 13.13.2(9).
9298 The representation is the in-memory representation of the base type of
9299 the type, using the number of bits corresponding to the
9300 @code{@var{type}'Size} value, and the natural ordering of the machine.
9305 @strong{60}. The names and characteristics of the numeric subtypes
9306 declared in the visible part of package @code{Standard}. See A.1(3).
9309 See items describing the integer and floating-point types supported.
9314 @strong{61}. The accuracy actually achieved by the elementary
9315 functions. See A.5.1(1).
9318 The elementary functions correspond to the functions available in the C
9319 library. Only fast math mode is implemented.
9324 @strong{62}. The sign of a zero result from some of the operators or
9325 functions in @code{Numerics.Generic_Elementary_Functions}, when
9326 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
9329 The sign of zeroes follows the requirements of the IEEE 754 standard on
9335 @strong{63}. The value of
9336 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
9339 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9344 @strong{64}. The value of
9345 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
9348 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9353 @strong{65}. The algorithms for random number generation. See
9357 The algorithm is the Mersenne Twister, as documented in the source file
9358 @file{s-rannum.adb}. This version of the algorithm has a period of
9364 @strong{66}. The string representation of a random number generator's
9365 state. See A.5.2(38).
9368 The value returned by the Image function is the concatenation of
9369 the fixed-width decimal representations of the 624 32-bit integers
9370 of the state vector.
9375 @strong{67}. The minimum time interval between calls to the
9376 time-dependent Reset procedure that are guaranteed to initiate different
9377 random number sequences. See A.5.2(45).
9380 The minimum period between reset calls to guarantee distinct series of
9381 random numbers is one microsecond.
9386 @strong{68}. The values of the @code{Model_Mantissa},
9387 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
9388 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
9389 Annex is not supported. See A.5.3(72).
9392 Run the compiler with @option{-gnatS} to produce a listing of package
9393 @code{Standard}, has the values of all numeric attributes.
9398 @strong{69}. Any implementation-defined characteristics of the
9399 input-output packages. See A.7(14).
9402 There are no special implementation defined characteristics for these
9408 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
9412 All type representations are contiguous, and the @code{Buffer_Size} is
9413 the value of @code{@var{type}'Size} rounded up to the next storage unit
9419 @strong{71}. External files for standard input, standard output, and
9420 standard error See A.10(5).
9423 These files are mapped onto the files provided by the C streams
9424 libraries. See source file @file{i-cstrea.ads} for further details.
9429 @strong{72}. The accuracy of the value produced by @code{Put}. See
9433 If more digits are requested in the output than are represented by the
9434 precision of the value, zeroes are output in the corresponding least
9435 significant digit positions.
9440 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
9441 @code{Command_Name}. See A.15(1).
9444 These are mapped onto the @code{argv} and @code{argc} parameters of the
9445 main program in the natural manner.
9450 @strong{74}. The interpretation of the @code{Form} parameter in procedure
9451 @code{Create_Directory}. See A.16(56).
9454 The @code{Form} parameter is not used.
9459 @strong{75}. The interpretation of the @code{Form} parameter in procedure
9460 @code{Create_Path}. See A.16(60).
9463 The @code{Form} parameter is not used.
9468 @strong{76}. The interpretation of the @code{Form} parameter in procedure
9469 @code{Copy_File}. See A.16(68).
9472 The @code{Form} parameter is case-insensitive.
9474 Two fields are recognized in the @code{Form} parameter:
9478 @item preserve=<value>
9485 <value> starts immediately after the character '=' and ends with the
9486 character immediately preceding the next comma (',') or with the last
9487 character of the parameter.
9489 The only possible values for preserve= are:
9494 Do not try to preserve any file attributes. This is the default if no
9495 preserve= is found in Form.
9497 @item all_attributes
9498 Try to preserve all file attributes (timestamps, access rights).
9501 Preserve the timestamp of the copied file, but not the other file attributes.
9506 The only possible values for mode= are:
9511 Only do the copy if the destination file does not already exist. If it already
9512 exists, Copy_File fails.
9515 Copy the file in all cases. Overwrite an already existing destination file.
9518 Append the original file to the destination file. If the destination file does
9519 not exist, the destination file is a copy of the source file. When mode=append,
9520 the field preserve=, if it exists, is not taken into account.
9525 If the Form parameter includes one or both of the fields and the value or
9526 values are incorrect, Copy_file fails with Use_Error.
9528 Examples of correct Forms:
9531 Form => "preserve=no_attributes,mode=overwrite" (the default)
9532 Form => "mode=append"
9533 Form => "mode=copy, preserve=all_attributes"
9537 Examples of incorrect Forms
9540 Form => "preserve=junk"
9541 Form => "mode=internal, preserve=timestamps"
9547 @strong{77}. Implementation-defined convention names. See B.1(11).
9550 The following convention names are supported
9558 Synonym for Assembler
9560 Synonym for Assembler
9563 @item C_Pass_By_Copy
9564 Allowed only for record types, like C, but also notes that record
9565 is to be passed by copy rather than reference.
9568 @item C_Plus_Plus (or CPP)
9571 Treated the same as C
9573 Treated the same as C
9577 For support of pragma @code{Import} with convention Intrinsic, see
9578 separate section on Intrinsic Subprograms.
9580 Stdcall (used for Windows implementations only). This convention correspond
9581 to the WINAPI (previously called Pascal convention) C/C++ convention under
9582 Windows. A function with this convention cleans the stack before exit.
9588 Stubbed is a special convention used to indicate that the body of the
9589 subprogram will be entirely ignored. Any call to the subprogram
9590 is converted into a raise of the @code{Program_Error} exception. If a
9591 pragma @code{Import} specifies convention @code{stubbed} then no body need
9592 be present at all. This convention is useful during development for the
9593 inclusion of subprograms whose body has not yet been written.
9597 In addition, all otherwise unrecognized convention names are also
9598 treated as being synonymous with convention C@. In all implementations
9599 except for VMS, use of such other names results in a warning. In VMS
9600 implementations, these names are accepted silently.
9605 @strong{78}. The meaning of link names. See B.1(36).
9608 Link names are the actual names used by the linker.
9613 @strong{79}. The manner of choosing link names when neither the link
9614 name nor the address of an imported or exported entity is specified. See
9618 The default linker name is that which would be assigned by the relevant
9619 external language, interpreting the Ada name as being in all lower case
9625 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
9628 The string passed to @code{Linker_Options} is presented uninterpreted as
9629 an argument to the link command, unless it contains ASCII.NUL characters.
9630 NUL characters if they appear act as argument separators, so for example
9632 @smallexample @c ada
9633 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9637 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9638 linker. The order of linker options is preserved for a given unit. The final
9639 list of options passed to the linker is in reverse order of the elaboration
9640 order. For example, linker options for a body always appear before the options
9641 from the corresponding package spec.
9646 @strong{81}. The contents of the visible part of package
9647 @code{Interfaces} and its language-defined descendants. See B.2(1).
9650 See files with prefix @file{i-} in the distributed library.
9655 @strong{82}. Implementation-defined children of package
9656 @code{Interfaces}. The contents of the visible part of package
9657 @code{Interfaces}. See B.2(11).
9660 See files with prefix @file{i-} in the distributed library.
9665 @strong{83}. The types @code{Floating}, @code{Long_Floating},
9666 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9667 @code{COBOL_Character}; and the initialization of the variables
9668 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9669 @code{Interfaces.COBOL}. See B.4(50).
9676 (Floating) Long_Float
9681 @item Decimal_Element
9683 @item COBOL_Character
9688 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9693 @strong{84}. Support for access to machine instructions. See C.1(1).
9696 See documentation in file @file{s-maccod.ads} in the distributed library.
9701 @strong{85}. Implementation-defined aspects of access to machine
9702 operations. See C.1(9).
9705 See documentation in file @file{s-maccod.ads} in the distributed library.
9710 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
9713 Interrupts are mapped to signals or conditions as appropriate. See
9715 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9716 on the interrupts supported on a particular target.
9721 @strong{87}. Implementation-defined aspects of pre-elaboration. See
9725 GNAT does not permit a partition to be restarted without reloading,
9726 except under control of the debugger.
9731 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
9734 Pragma @code{Discard_Names} causes names of enumeration literals to
9735 be suppressed. In the presence of this pragma, the Image attribute
9736 provides the image of the Pos of the literal, and Value accepts
9742 @strong{89}. The result of the @code{Task_Identification.Image}
9743 attribute. See C.7.1(7).
9746 The result of this attribute is a string that identifies
9747 the object or component that denotes a given task. If a variable @code{Var}
9748 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9750 is the hexadecimal representation of the virtual address of the corresponding
9751 task control block. If the variable is an array of tasks, the image of each
9752 task will have the form of an indexed component indicating the position of a
9753 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9754 component of a record, the image of the task will have the form of a selected
9755 component. These rules are fully recursive, so that the image of a task that
9756 is a subcomponent of a composite object corresponds to the expression that
9757 designates this task.
9759 If a task is created by an allocator, its image depends on the context. If the
9760 allocator is part of an object declaration, the rules described above are used
9761 to construct its image, and this image is not affected by subsequent
9762 assignments. If the allocator appears within an expression, the image
9763 includes only the name of the task type.
9765 If the configuration pragma Discard_Names is present, or if the restriction
9766 No_Implicit_Heap_Allocation is in effect, the image reduces to
9767 the numeric suffix, that is to say the hexadecimal representation of the
9768 virtual address of the control block of the task.
9772 @strong{90}. The value of @code{Current_Task} when in a protected entry
9773 or interrupt handler. See C.7.1(17).
9776 Protected entries or interrupt handlers can be executed by any
9777 convenient thread, so the value of @code{Current_Task} is undefined.
9782 @strong{91}. The effect of calling @code{Current_Task} from an entry
9783 body or interrupt handler. See C.7.1(19).
9786 The effect of calling @code{Current_Task} from an entry body or
9787 interrupt handler is to return the identification of the task currently
9793 @strong{92}. Implementation-defined aspects of
9794 @code{Task_Attributes}. See C.7.2(19).
9797 There are no implementation-defined aspects of @code{Task_Attributes}.
9802 @strong{93}. Values of all @code{Metrics}. See D(2).
9805 The metrics information for GNAT depends on the performance of the
9806 underlying operating system. The sources of the run-time for tasking
9807 implementation, together with the output from @option{-gnatG} can be
9808 used to determine the exact sequence of operating systems calls made
9809 to implement various tasking constructs. Together with appropriate
9810 information on the performance of the underlying operating system,
9811 on the exact target in use, this information can be used to determine
9812 the required metrics.
9817 @strong{94}. The declarations of @code{Any_Priority} and
9818 @code{Priority}. See D.1(11).
9821 See declarations in file @file{system.ads}.
9826 @strong{95}. Implementation-defined execution resources. See D.1(15).
9829 There are no implementation-defined execution resources.
9834 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
9835 access to a protected object keeps its processor busy. See D.2.1(3).
9838 On a multi-processor, a task that is waiting for access to a protected
9839 object does not keep its processor busy.
9844 @strong{97}. The affect of implementation defined execution resources
9845 on task dispatching. See D.2.1(9).
9850 Tasks map to IRIX threads, and the dispatching policy is as defined by
9851 the IRIX implementation of threads.
9853 Tasks map to threads in the threads package used by GNAT@. Where possible
9854 and appropriate, these threads correspond to native threads of the
9855 underlying operating system.
9860 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9861 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9864 There are no implementation-defined policy-identifiers allowed in this
9870 @strong{99}. Implementation-defined aspects of priority inversion. See
9874 Execution of a task cannot be preempted by the implementation processing
9875 of delay expirations for lower priority tasks.
9880 @strong{100}. Implementation defined task dispatching. See D.2.2(18).
9885 Tasks map to IRIX threads, and the dispatching policy is as defined by
9886 the IRIX implementation of threads.
9888 The policy is the same as that of the underlying threads implementation.
9893 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
9894 in a pragma @code{Locking_Policy}. See D.3(4).
9897 The only implementation defined policy permitted in GNAT is
9898 @code{Inheritance_Locking}. On targets that support this policy, locking
9899 is implemented by inheritance, i.e.@: the task owning the lock operates
9900 at a priority equal to the highest priority of any task currently
9901 requesting the lock.
9906 @strong{102}. Default ceiling priorities. See D.3(10).
9909 The ceiling priority of protected objects of the type
9910 @code{System.Interrupt_Priority'Last} as described in the Ada
9911 Reference Manual D.3(10),
9916 @strong{103}. The ceiling of any protected object used internally by
9917 the implementation. See D.3(16).
9920 The ceiling priority of internal protected objects is
9921 @code{System.Priority'Last}.
9926 @strong{104}. Implementation-defined queuing policies. See D.4(1).
9929 There are no implementation-defined queuing policies.
9934 @strong{105}. On a multiprocessor, any conditions that cause the
9935 completion of an aborted construct to be delayed later than what is
9936 specified for a single processor. See D.6(3).
9939 The semantics for abort on a multi-processor is the same as on a single
9940 processor, there are no further delays.
9945 @strong{106}. Any operations that implicitly require heap storage
9946 allocation. See D.7(8).
9949 The only operation that implicitly requires heap storage allocation is
9955 @strong{107}. Implementation-defined aspects of pragma
9956 @code{Restrictions}. See D.7(20).
9959 There are no such implementation-defined aspects.
9964 @strong{108}. Implementation-defined aspects of package
9965 @code{Real_Time}. See D.8(17).
9968 There are no implementation defined aspects of package @code{Real_Time}.
9973 @strong{109}. Implementation-defined aspects of
9974 @code{delay_statements}. See D.9(8).
9977 Any difference greater than one microsecond will cause the task to be
9978 delayed (see D.9(7)).
9983 @strong{110}. The upper bound on the duration of interrupt blocking
9984 caused by the implementation. See D.12(5).
9987 The upper bound is determined by the underlying operating system. In
9988 no cases is it more than 10 milliseconds.
9993 @strong{111}. The means for creating and executing distributed
9997 The GLADE package provides a utility GNATDIST for creating and executing
9998 distributed programs. See the GLADE reference manual for further details.
10003 @strong{112}. Any events that can result in a partition becoming
10004 inaccessible. See E.1(7).
10007 See the GLADE reference manual for full details on such events.
10012 @strong{113}. The scheduling policies, treatment of priorities, and
10013 management of shared resources between partitions in certain cases. See
10017 See the GLADE reference manual for full details on these aspects of
10018 multi-partition execution.
10023 @strong{114}. Events that cause the version of a compilation unit to
10024 change. See E.3(5).
10027 Editing the source file of a compilation unit, or the source files of
10028 any units on which it is dependent in a significant way cause the version
10029 to change. No other actions cause the version number to change. All changes
10030 are significant except those which affect only layout, capitalization or
10036 @strong{115}. Whether the execution of the remote subprogram is
10037 immediately aborted as a result of cancellation. See E.4(13).
10040 See the GLADE reference manual for details on the effect of abort in
10041 a distributed application.
10046 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
10049 See the GLADE reference manual for a full description of all implementation
10050 defined aspects of the PCS@.
10055 @strong{117}. Implementation-defined interfaces in the PCS@. See
10059 See the GLADE reference manual for a full description of all
10060 implementation defined interfaces.
10065 @strong{118}. The values of named numbers in the package
10066 @code{Decimal}. See F.2(7).
10078 @item Max_Decimal_Digits
10085 @strong{119}. The value of @code{Max_Picture_Length} in the package
10086 @code{Text_IO.Editing}. See F.3.3(16).
10094 @strong{120}. The value of @code{Max_Picture_Length} in the package
10095 @code{Wide_Text_IO.Editing}. See F.3.4(5).
10103 @strong{121}. The accuracy actually achieved by the complex elementary
10104 functions and by other complex arithmetic operations. See G.1(1).
10107 Standard library functions are used for the complex arithmetic
10108 operations. Only fast math mode is currently supported.
10113 @strong{122}. The sign of a zero result (or a component thereof) from
10114 any operator or function in @code{Numerics.Generic_Complex_Types}, when
10115 @code{Real'Signed_Zeros} is True. See G.1.1(53).
10118 The signs of zero values are as recommended by the relevant
10119 implementation advice.
10124 @strong{123}. The sign of a zero result (or a component thereof) from
10125 any operator or function in
10126 @code{Numerics.Generic_Complex_Elementary_Functions}, when
10127 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
10130 The signs of zero values are as recommended by the relevant
10131 implementation advice.
10136 @strong{124}. Whether the strict mode or the relaxed mode is the
10137 default. See G.2(2).
10140 The strict mode is the default. There is no separate relaxed mode. GNAT
10141 provides a highly efficient implementation of strict mode.
10146 @strong{125}. The result interval in certain cases of fixed-to-float
10147 conversion. See G.2.1(10).
10150 For cases where the result interval is implementation dependent, the
10151 accuracy is that provided by performing all operations in 64-bit IEEE
10152 floating-point format.
10157 @strong{126}. The result of a floating point arithmetic operation in
10158 overflow situations, when the @code{Machine_Overflows} attribute of the
10159 result type is @code{False}. See G.2.1(13).
10162 Infinite and NaN values are produced as dictated by the IEEE
10163 floating-point standard.
10165 Note that on machines that are not fully compliant with the IEEE
10166 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
10167 must be used for achieving IEEE confirming behavior (although at the cost
10168 of a significant performance penalty), so infinite and NaN values are
10169 properly generated.
10174 @strong{127}. The result interval for division (or exponentiation by a
10175 negative exponent), when the floating point hardware implements division
10176 as multiplication by a reciprocal. See G.2.1(16).
10179 Not relevant, division is IEEE exact.
10184 @strong{128}. The definition of close result set, which determines the
10185 accuracy of certain fixed point multiplications and divisions. See
10189 Operations in the close result set are performed using IEEE long format
10190 floating-point arithmetic. The input operands are converted to
10191 floating-point, the operation is done in floating-point, and the result
10192 is converted to the target type.
10197 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
10198 point multiplication or division for which the result shall be in the
10199 perfect result set. See G.2.3(22).
10202 The result is only defined to be in the perfect result set if the result
10203 can be computed by a single scaling operation involving a scale factor
10204 representable in 64-bits.
10209 @strong{130}. The result of a fixed point arithmetic operation in
10210 overflow situations, when the @code{Machine_Overflows} attribute of the
10211 result type is @code{False}. See G.2.3(27).
10214 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
10220 @strong{131}. The result of an elementary function reference in
10221 overflow situations, when the @code{Machine_Overflows} attribute of the
10222 result type is @code{False}. See G.2.4(4).
10225 IEEE infinite and Nan values are produced as appropriate.
10230 @strong{132}. The value of the angle threshold, within which certain
10231 elementary functions, complex arithmetic operations, and complex
10232 elementary functions yield results conforming to a maximum relative
10233 error bound. See G.2.4(10).
10236 Information on this subject is not yet available.
10241 @strong{133}. The accuracy of certain elementary functions for
10242 parameters beyond the angle threshold. See G.2.4(10).
10245 Information on this subject is not yet available.
10250 @strong{134}. The result of a complex arithmetic operation or complex
10251 elementary function reference in overflow situations, when the
10252 @code{Machine_Overflows} attribute of the corresponding real type is
10253 @code{False}. See G.2.6(5).
10256 IEEE infinite and Nan values are produced as appropriate.
10261 @strong{135}. The accuracy of certain complex arithmetic operations and
10262 certain complex elementary functions for parameters (or components
10263 thereof) beyond the angle threshold. See G.2.6(8).
10266 Information on those subjects is not yet available.
10271 @strong{136}. Information regarding bounded errors and erroneous
10272 execution. See H.2(1).
10275 Information on this subject is not yet available.
10280 @strong{137}. Implementation-defined aspects of pragma
10281 @code{Inspection_Point}. See H.3.2(8).
10284 Pragma @code{Inspection_Point} ensures that the variable is live and can
10285 be examined by the debugger at the inspection point.
10290 @strong{138}. Implementation-defined aspects of pragma
10291 @code{Restrictions}. See H.4(25).
10294 There are no implementation-defined aspects of pragma @code{Restrictions}. The
10295 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
10296 generated code. Checks must suppressed by use of pragma @code{Suppress}.
10301 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
10305 There are no restrictions on pragma @code{Restrictions}.
10307 @node Intrinsic Subprograms
10308 @chapter Intrinsic Subprograms
10309 @cindex Intrinsic Subprograms
10312 * Intrinsic Operators::
10313 * Enclosing_Entity::
10314 * Exception_Information::
10315 * Exception_Message::
10323 * Shift_Right_Arithmetic::
10324 * Source_Location::
10328 GNAT allows a user application program to write the declaration:
10330 @smallexample @c ada
10331 pragma Import (Intrinsic, name);
10335 providing that the name corresponds to one of the implemented intrinsic
10336 subprograms in GNAT, and that the parameter profile of the referenced
10337 subprogram meets the requirements. This chapter describes the set of
10338 implemented intrinsic subprograms, and the requirements on parameter profiles.
10339 Note that no body is supplied; as with other uses of pragma Import, the
10340 body is supplied elsewhere (in this case by the compiler itself). Note
10341 that any use of this feature is potentially non-portable, since the
10342 Ada standard does not require Ada compilers to implement this feature.
10344 @node Intrinsic Operators
10345 @section Intrinsic Operators
10346 @cindex Intrinsic operator
10349 All the predefined numeric operators in package Standard
10350 in @code{pragma Import (Intrinsic,..)}
10351 declarations. In the binary operator case, the operands must have the same
10352 size. The operand or operands must also be appropriate for
10353 the operator. For example, for addition, the operands must
10354 both be floating-point or both be fixed-point, and the
10355 right operand for @code{"**"} must have a root type of
10356 @code{Standard.Integer'Base}.
10357 You can use an intrinsic operator declaration as in the following example:
10359 @smallexample @c ada
10360 type Int1 is new Integer;
10361 type Int2 is new Integer;
10363 function "+" (X1 : Int1; X2 : Int2) return Int1;
10364 function "+" (X1 : Int1; X2 : Int2) return Int2;
10365 pragma Import (Intrinsic, "+");
10369 This declaration would permit ``mixed mode'' arithmetic on items
10370 of the differing types @code{Int1} and @code{Int2}.
10371 It is also possible to specify such operators for private types, if the
10372 full views are appropriate arithmetic types.
10374 @node Enclosing_Entity
10375 @section Enclosing_Entity
10376 @cindex Enclosing_Entity
10378 This intrinsic subprogram is used in the implementation of the
10379 library routine @code{GNAT.Source_Info}. The only useful use of the
10380 intrinsic import in this case is the one in this unit, so an
10381 application program should simply call the function
10382 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
10383 the current subprogram, package, task, entry, or protected subprogram.
10385 @node Exception_Information
10386 @section Exception_Information
10387 @cindex Exception_Information'
10389 This intrinsic subprogram is used in the implementation of the
10390 library routine @code{GNAT.Current_Exception}. The only useful
10391 use of the intrinsic import in this case is the one in this unit,
10392 so an application program should simply call the function
10393 @code{GNAT.Current_Exception.Exception_Information} to obtain
10394 the exception information associated with the current exception.
10396 @node Exception_Message
10397 @section Exception_Message
10398 @cindex Exception_Message
10400 This intrinsic subprogram is used in the implementation of the
10401 library routine @code{GNAT.Current_Exception}. The only useful
10402 use of the intrinsic import in this case is the one in this unit,
10403 so an application program should simply call the function
10404 @code{GNAT.Current_Exception.Exception_Message} to obtain
10405 the message associated with the current exception.
10407 @node Exception_Name
10408 @section Exception_Name
10409 @cindex Exception_Name
10411 This intrinsic subprogram is used in the implementation of the
10412 library routine @code{GNAT.Current_Exception}. The only useful
10413 use of the intrinsic import in this case is the one in this unit,
10414 so an application program should simply call the function
10415 @code{GNAT.Current_Exception.Exception_Name} to obtain
10416 the name of the current exception.
10422 This intrinsic subprogram is used in the implementation of the
10423 library routine @code{GNAT.Source_Info}. The only useful use of the
10424 intrinsic import in this case is the one in this unit, so an
10425 application program should simply call the function
10426 @code{GNAT.Source_Info.File} to obtain the name of the current
10433 This intrinsic subprogram is used in the implementation of the
10434 library routine @code{GNAT.Source_Info}. The only useful use of the
10435 intrinsic import in this case is the one in this unit, so an
10436 application program should simply call the function
10437 @code{GNAT.Source_Info.Line} to obtain the number of the current
10441 @section Rotate_Left
10442 @cindex Rotate_Left
10444 In standard Ada, the @code{Rotate_Left} function is available only
10445 for the predefined modular types in package @code{Interfaces}. However, in
10446 GNAT it is possible to define a Rotate_Left function for a user
10447 defined modular type or any signed integer type as in this example:
10449 @smallexample @c ada
10450 function Shift_Left
10451 (Value : My_Modular_Type;
10453 return My_Modular_Type;
10457 The requirements are that the profile be exactly as in the example
10458 above. The only modifications allowed are in the formal parameter
10459 names, and in the type of @code{Value} and the return type, which
10460 must be the same, and must be either a signed integer type, or
10461 a modular integer type with a binary modulus, and the size must
10462 be 8. 16, 32 or 64 bits.
10465 @section Rotate_Right
10466 @cindex Rotate_Right
10468 A @code{Rotate_Right} function can be defined for any user defined
10469 binary modular integer type, or signed integer type, as described
10470 above for @code{Rotate_Left}.
10473 @section Shift_Left
10476 A @code{Shift_Left} function can be defined for any user defined
10477 binary modular integer type, or signed integer type, as described
10478 above for @code{Rotate_Left}.
10481 @section Shift_Right
10482 @cindex Shift_Right
10484 A @code{Shift_Right} function can be defined for any user defined
10485 binary modular integer type, or signed integer type, as described
10486 above for @code{Rotate_Left}.
10488 @node Shift_Right_Arithmetic
10489 @section Shift_Right_Arithmetic
10490 @cindex Shift_Right_Arithmetic
10492 A @code{Shift_Right_Arithmetic} function can be defined for any user
10493 defined binary modular integer type, or signed integer type, as described
10494 above for @code{Rotate_Left}.
10496 @node Source_Location
10497 @section Source_Location
10498 @cindex Source_Location
10500 This intrinsic subprogram is used in the implementation of the
10501 library routine @code{GNAT.Source_Info}. The only useful use of the
10502 intrinsic import in this case is the one in this unit, so an
10503 application program should simply call the function
10504 @code{GNAT.Source_Info.Source_Location} to obtain the current
10505 source file location.
10507 @node Representation Clauses and Pragmas
10508 @chapter Representation Clauses and Pragmas
10509 @cindex Representation Clauses
10512 * Alignment Clauses::
10514 * Storage_Size Clauses::
10515 * Size of Variant Record Objects::
10516 * Biased Representation ::
10517 * Value_Size and Object_Size Clauses::
10518 * Component_Size Clauses::
10519 * Bit_Order Clauses::
10520 * Effect of Bit_Order on Byte Ordering::
10521 * Pragma Pack for Arrays::
10522 * Pragma Pack for Records::
10523 * Record Representation Clauses::
10524 * Enumeration Clauses::
10525 * Address Clauses::
10526 * Effect of Convention on Representation::
10527 * Determining the Representations chosen by GNAT::
10531 @cindex Representation Clause
10532 @cindex Representation Pragma
10533 @cindex Pragma, representation
10534 This section describes the representation clauses accepted by GNAT, and
10535 their effect on the representation of corresponding data objects.
10537 GNAT fully implements Annex C (Systems Programming). This means that all
10538 the implementation advice sections in chapter 13 are fully implemented.
10539 However, these sections only require a minimal level of support for
10540 representation clauses. GNAT provides much more extensive capabilities,
10541 and this section describes the additional capabilities provided.
10543 @node Alignment Clauses
10544 @section Alignment Clauses
10545 @cindex Alignment Clause
10548 GNAT requires that all alignment clauses specify a power of 2, and all
10549 default alignments are always a power of 2. The default alignment
10550 values are as follows:
10553 @item @emph{Primitive Types}.
10554 For primitive types, the alignment is the minimum of the actual size of
10555 objects of the type divided by @code{Storage_Unit},
10556 and the maximum alignment supported by the target.
10557 (This maximum alignment is given by the GNAT-specific attribute
10558 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
10559 @cindex @code{Maximum_Alignment} attribute
10560 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
10561 default alignment will be 8 on any target that supports alignments
10562 this large, but on some targets, the maximum alignment may be smaller
10563 than 8, in which case objects of type @code{Long_Float} will be maximally
10566 @item @emph{Arrays}.
10567 For arrays, the alignment is equal to the alignment of the component type
10568 for the normal case where no packing or component size is given. If the
10569 array is packed, and the packing is effective (see separate section on
10570 packed arrays), then the alignment will be one for long packed arrays,
10571 or arrays whose length is not known at compile time. For short packed
10572 arrays, which are handled internally as modular types, the alignment
10573 will be as described for primitive types, e.g.@: a packed array of length
10574 31 bits will have an object size of four bytes, and an alignment of 4.
10576 @item @emph{Records}.
10577 For the normal non-packed case, the alignment of a record is equal to
10578 the maximum alignment of any of its components. For tagged records, this
10579 includes the implicit access type used for the tag. If a pragma @code{Pack}
10580 is used and all components are packable (see separate section on pragma
10581 @code{Pack}), then the resulting alignment is 1, unless the layout of the
10582 record makes it profitable to increase it.
10584 A special case is when:
10587 the size of the record is given explicitly, or a
10588 full record representation clause is given, and
10590 the size of the record is 2, 4, or 8 bytes.
10593 In this case, an alignment is chosen to match the
10594 size of the record. For example, if we have:
10596 @smallexample @c ada
10597 type Small is record
10600 for Small'Size use 16;
10604 then the default alignment of the record type @code{Small} is 2, not 1. This
10605 leads to more efficient code when the record is treated as a unit, and also
10606 allows the type to specified as @code{Atomic} on architectures requiring
10612 An alignment clause may specify a larger alignment than the default value
10613 up to some maximum value dependent on the target (obtainable by using the
10614 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10615 a smaller alignment than the default value for enumeration, integer and
10616 fixed point types, as well as for record types, for example
10618 @smallexample @c ada
10623 for V'alignment use 1;
10627 @cindex Alignment, default
10628 The default alignment for the type @code{V} is 4, as a result of the
10629 Integer field in the record, but it is permissible, as shown, to
10630 override the default alignment of the record with a smaller value.
10633 @section Size Clauses
10634 @cindex Size Clause
10637 The default size for a type @code{T} is obtainable through the
10638 language-defined attribute @code{T'Size} and also through the
10639 equivalent GNAT-defined attribute @code{T'Value_Size}.
10640 For objects of type @code{T}, GNAT will generally increase the type size
10641 so that the object size (obtainable through the GNAT-defined attribute
10642 @code{T'Object_Size})
10643 is a multiple of @code{T'Alignment * Storage_Unit}.
10646 @smallexample @c ada
10647 type Smallint is range 1 .. 6;
10656 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10657 as specified by the RM rules,
10658 but objects of this type will have a size of 8
10659 (@code{Smallint'Object_Size} = 8),
10660 since objects by default occupy an integral number
10661 of storage units. On some targets, notably older
10662 versions of the Digital Alpha, the size of stand
10663 alone objects of this type may be 32, reflecting
10664 the inability of the hardware to do byte load/stores.
10666 Similarly, the size of type @code{Rec} is 40 bits
10667 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10668 the alignment is 4, so objects of this type will have
10669 their size increased to 64 bits so that it is a multiple
10670 of the alignment (in bits). This decision is
10671 in accordance with the specific Implementation Advice in RM 13.3(43):
10674 A @code{Size} clause should be supported for an object if the specified
10675 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10676 to a size in storage elements that is a multiple of the object's
10677 @code{Alignment} (if the @code{Alignment} is nonzero).
10681 An explicit size clause may be used to override the default size by
10682 increasing it. For example, if we have:
10684 @smallexample @c ada
10685 type My_Boolean is new Boolean;
10686 for My_Boolean'Size use 32;
10690 then values of this type will always be 32 bits long. In the case of
10691 discrete types, the size can be increased up to 64 bits, with the effect
10692 that the entire specified field is used to hold the value, sign- or
10693 zero-extended as appropriate. If more than 64 bits is specified, then
10694 padding space is allocated after the value, and a warning is issued that
10695 there are unused bits.
10697 Similarly the size of records and arrays may be increased, and the effect
10698 is to add padding bits after the value. This also causes a warning message
10701 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
10702 Size in bits, this corresponds to an object of size 256 megabytes (minus
10703 one). This limitation is true on all targets. The reason for this
10704 limitation is that it improves the quality of the code in many cases
10705 if it is known that a Size value can be accommodated in an object of
10708 @node Storage_Size Clauses
10709 @section Storage_Size Clauses
10710 @cindex Storage_Size Clause
10713 For tasks, the @code{Storage_Size} clause specifies the amount of space
10714 to be allocated for the task stack. This cannot be extended, and if the
10715 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10716 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
10717 or a @code{Storage_Size} pragma in the task definition to set the
10718 appropriate required size. A useful technique is to include in every
10719 task definition a pragma of the form:
10721 @smallexample @c ada
10722 pragma Storage_Size (Default_Stack_Size);
10726 Then @code{Default_Stack_Size} can be defined in a global package, and
10727 modified as required. Any tasks requiring stack sizes different from the
10728 default can have an appropriate alternative reference in the pragma.
10730 You can also use the @option{-d} binder switch to modify the default stack
10733 For access types, the @code{Storage_Size} clause specifies the maximum
10734 space available for allocation of objects of the type. If this space is
10735 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10736 In the case where the access type is declared local to a subprogram, the
10737 use of a @code{Storage_Size} clause triggers automatic use of a special
10738 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10739 space for the pool is automatically reclaimed on exit from the scope in
10740 which the type is declared.
10742 A special case recognized by the compiler is the specification of a
10743 @code{Storage_Size} of zero for an access type. This means that no
10744 items can be allocated from the pool, and this is recognized at compile
10745 time, and all the overhead normally associated with maintaining a fixed
10746 size storage pool is eliminated. Consider the following example:
10748 @smallexample @c ada
10750 type R is array (Natural) of Character;
10751 type P is access all R;
10752 for P'Storage_Size use 0;
10753 -- Above access type intended only for interfacing purposes
10757 procedure g (m : P);
10758 pragma Import (C, g);
10769 As indicated in this example, these dummy storage pools are often useful in
10770 connection with interfacing where no object will ever be allocated. If you
10771 compile the above example, you get the warning:
10774 p.adb:16:09: warning: allocation from empty storage pool
10775 p.adb:16:09: warning: Storage_Error will be raised at run time
10779 Of course in practice, there will not be any explicit allocators in the
10780 case of such an access declaration.
10782 @node Size of Variant Record Objects
10783 @section Size of Variant Record Objects
10784 @cindex Size, variant record objects
10785 @cindex Variant record objects, size
10788 In the case of variant record objects, there is a question whether Size gives
10789 information about a particular variant, or the maximum size required
10790 for any variant. Consider the following program
10792 @smallexample @c ada
10793 with Text_IO; use Text_IO;
10795 type R1 (A : Boolean := False) is record
10797 when True => X : Character;
10798 when False => null;
10806 Put_Line (Integer'Image (V1'Size));
10807 Put_Line (Integer'Image (V2'Size));
10812 Here we are dealing with a variant record, where the True variant
10813 requires 16 bits, and the False variant requires 8 bits.
10814 In the above example, both V1 and V2 contain the False variant,
10815 which is only 8 bits long. However, the result of running the
10824 The reason for the difference here is that the discriminant value of
10825 V1 is fixed, and will always be False. It is not possible to assign
10826 a True variant value to V1, therefore 8 bits is sufficient. On the
10827 other hand, in the case of V2, the initial discriminant value is
10828 False (from the default), but it is possible to assign a True
10829 variant value to V2, therefore 16 bits must be allocated for V2
10830 in the general case, even fewer bits may be needed at any particular
10831 point during the program execution.
10833 As can be seen from the output of this program, the @code{'Size}
10834 attribute applied to such an object in GNAT gives the actual allocated
10835 size of the variable, which is the largest size of any of the variants.
10836 The Ada Reference Manual is not completely clear on what choice should
10837 be made here, but the GNAT behavior seems most consistent with the
10838 language in the RM@.
10840 In some cases, it may be desirable to obtain the size of the current
10841 variant, rather than the size of the largest variant. This can be
10842 achieved in GNAT by making use of the fact that in the case of a
10843 subprogram parameter, GNAT does indeed return the size of the current
10844 variant (because a subprogram has no way of knowing how much space
10845 is actually allocated for the actual).
10847 Consider the following modified version of the above program:
10849 @smallexample @c ada
10850 with Text_IO; use Text_IO;
10852 type R1 (A : Boolean := False) is record
10854 when True => X : Character;
10855 when False => null;
10861 function Size (V : R1) return Integer is
10867 Put_Line (Integer'Image (V2'Size));
10868 Put_Line (Integer'IMage (Size (V2)));
10870 Put_Line (Integer'Image (V2'Size));
10871 Put_Line (Integer'IMage (Size (V2)));
10876 The output from this program is
10886 Here we see that while the @code{'Size} attribute always returns
10887 the maximum size, regardless of the current variant value, the
10888 @code{Size} function does indeed return the size of the current
10891 @node Biased Representation
10892 @section Biased Representation
10893 @cindex Size for biased representation
10894 @cindex Biased representation
10897 In the case of scalars with a range starting at other than zero, it is
10898 possible in some cases to specify a size smaller than the default minimum
10899 value, and in such cases, GNAT uses an unsigned biased representation,
10900 in which zero is used to represent the lower bound, and successive values
10901 represent successive values of the type.
10903 For example, suppose we have the declaration:
10905 @smallexample @c ada
10906 type Small is range -7 .. -4;
10907 for Small'Size use 2;
10911 Although the default size of type @code{Small} is 4, the @code{Size}
10912 clause is accepted by GNAT and results in the following representation
10916 -7 is represented as 2#00#
10917 -6 is represented as 2#01#
10918 -5 is represented as 2#10#
10919 -4 is represented as 2#11#
10923 Biased representation is only used if the specified @code{Size} clause
10924 cannot be accepted in any other manner. These reduced sizes that force
10925 biased representation can be used for all discrete types except for
10926 enumeration types for which a representation clause is given.
10928 @node Value_Size and Object_Size Clauses
10929 @section Value_Size and Object_Size Clauses
10931 @findex Object_Size
10932 @cindex Size, of objects
10935 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10936 number of bits required to hold values of type @code{T}.
10937 Although this interpretation was allowed in Ada 83, it was not required,
10938 and this requirement in practice can cause some significant difficulties.
10939 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10940 However, in Ada 95 and Ada 2005,
10941 @code{Natural'Size} is
10942 typically 31. This means that code may change in behavior when moving
10943 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10945 @smallexample @c ada
10946 type Rec is record;
10952 at 0 range 0 .. Natural'Size - 1;
10953 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10958 In the above code, since the typical size of @code{Natural} objects
10959 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10960 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10961 there are cases where the fact that the object size can exceed the
10962 size of the type causes surprises.
10964 To help get around this problem GNAT provides two implementation
10965 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10966 applied to a type, these attributes yield the size of the type
10967 (corresponding to the RM defined size attribute), and the size of
10968 objects of the type respectively.
10970 The @code{Object_Size} is used for determining the default size of
10971 objects and components. This size value can be referred to using the
10972 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10973 the basis of the determination of the size. The backend is free to
10974 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10975 character might be stored in 32 bits on a machine with no efficient
10976 byte access instructions such as the Alpha.
10978 The default rules for the value of @code{Object_Size} for
10979 discrete types are as follows:
10983 The @code{Object_Size} for base subtypes reflect the natural hardware
10984 size in bits (run the compiler with @option{-gnatS} to find those values
10985 for numeric types). Enumeration types and fixed-point base subtypes have
10986 8, 16, 32 or 64 bits for this size, depending on the range of values
10990 The @code{Object_Size} of a subtype is the same as the
10991 @code{Object_Size} of
10992 the type from which it is obtained.
10995 The @code{Object_Size} of a derived base type is copied from the parent
10996 base type, and the @code{Object_Size} of a derived first subtype is copied
10997 from the parent first subtype.
11001 The @code{Value_Size} attribute
11002 is the (minimum) number of bits required to store a value
11004 This value is used to determine how tightly to pack
11005 records or arrays with components of this type, and also affects
11006 the semantics of unchecked conversion (unchecked conversions where
11007 the @code{Value_Size} values differ generate a warning, and are potentially
11010 The default rules for the value of @code{Value_Size} are as follows:
11014 The @code{Value_Size} for a base subtype is the minimum number of bits
11015 required to store all values of the type (including the sign bit
11016 only if negative values are possible).
11019 If a subtype statically matches the first subtype of a given type, then it has
11020 by default the same @code{Value_Size} as the first subtype. This is a
11021 consequence of RM 13.1(14) (``if two subtypes statically match,
11022 then their subtype-specific aspects are the same''.)
11025 All other subtypes have a @code{Value_Size} corresponding to the minimum
11026 number of bits required to store all values of the subtype. For
11027 dynamic bounds, it is assumed that the value can range down or up
11028 to the corresponding bound of the ancestor
11032 The RM defined attribute @code{Size} corresponds to the
11033 @code{Value_Size} attribute.
11035 The @code{Size} attribute may be defined for a first-named subtype. This sets
11036 the @code{Value_Size} of
11037 the first-named subtype to the given value, and the
11038 @code{Object_Size} of this first-named subtype to the given value padded up
11039 to an appropriate boundary. It is a consequence of the default rules
11040 above that this @code{Object_Size} will apply to all further subtypes. On the
11041 other hand, @code{Value_Size} is affected only for the first subtype, any
11042 dynamic subtypes obtained from it directly, and any statically matching
11043 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
11045 @code{Value_Size} and
11046 @code{Object_Size} may be explicitly set for any subtype using
11047 an attribute definition clause. Note that the use of these attributes
11048 can cause the RM 13.1(14) rule to be violated. If two access types
11049 reference aliased objects whose subtypes have differing @code{Object_Size}
11050 values as a result of explicit attribute definition clauses, then it
11051 is erroneous to convert from one access subtype to the other.
11053 At the implementation level, Esize stores the Object_Size and the
11054 RM_Size field stores the @code{Value_Size} (and hence the value of the
11055 @code{Size} attribute,
11056 which, as noted above, is equivalent to @code{Value_Size}).
11058 To get a feel for the difference, consider the following examples (note
11059 that in each case the base is @code{Short_Short_Integer} with a size of 8):
11062 Object_Size Value_Size
11064 type x1 is range 0 .. 5; 8 3
11066 type x2 is range 0 .. 5;
11067 for x2'size use 12; 16 12
11069 subtype x3 is x2 range 0 .. 3; 16 2
11071 subtype x4 is x2'base range 0 .. 10; 8 4
11073 subtype x5 is x2 range 0 .. dynamic; 16 3*
11075 subtype x6 is x2'base range 0 .. dynamic; 8 3*
11080 Note: the entries marked ``3*'' are not actually specified by the Ada
11081 Reference Manual, but it seems in the spirit of the RM rules to allocate
11082 the minimum number of bits (here 3, given the range for @code{x2})
11083 known to be large enough to hold the given range of values.
11085 So far, so good, but GNAT has to obey the RM rules, so the question is
11086 under what conditions must the RM @code{Size} be used.
11087 The following is a list
11088 of the occasions on which the RM @code{Size} must be used:
11092 Component size for packed arrays or records
11095 Value of the attribute @code{Size} for a type
11098 Warning about sizes not matching for unchecked conversion
11102 For record types, the @code{Object_Size} is always a multiple of the
11103 alignment of the type (this is true for all types). In some cases the
11104 @code{Value_Size} can be smaller. Consider:
11114 On a typical 32-bit architecture, the X component will be four bytes, and
11115 require four-byte alignment, and the Y component will be one byte. In this
11116 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
11117 required to store a value of this type, and for example, it is permissible
11118 to have a component of type R in an outer array whose component size is
11119 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
11120 since it must be rounded up so that this value is a multiple of the
11121 alignment (4 bytes = 32 bits).
11124 For all other types, the @code{Object_Size}
11125 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
11126 Only @code{Size} may be specified for such types.
11128 @node Component_Size Clauses
11129 @section Component_Size Clauses
11130 @cindex Component_Size Clause
11133 Normally, the value specified in a component size clause must be consistent
11134 with the subtype of the array component with regard to size and alignment.
11135 In other words, the value specified must be at least equal to the size
11136 of this subtype, and must be a multiple of the alignment value.
11138 In addition, component size clauses are allowed which cause the array
11139 to be packed, by specifying a smaller value. A first case is for
11140 component size values in the range 1 through 63. The value specified
11141 must not be smaller than the Size of the subtype. GNAT will accurately
11142 honor all packing requests in this range. For example, if we have:
11144 @smallexample @c ada
11145 type r is array (1 .. 8) of Natural;
11146 for r'Component_Size use 31;
11150 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
11151 Of course access to the components of such an array is considerably
11152 less efficient than if the natural component size of 32 is used.
11153 A second case is when the subtype of the component is a record type
11154 padded because of its default alignment. For example, if we have:
11156 @smallexample @c ada
11163 type a is array (1 .. 8) of r;
11164 for a'Component_Size use 72;
11168 then the resulting array has a length of 72 bytes, instead of 96 bytes
11169 if the alignment of the record (4) was obeyed.
11171 Note that there is no point in giving both a component size clause
11172 and a pragma Pack for the same array type. if such duplicate
11173 clauses are given, the pragma Pack will be ignored.
11175 @node Bit_Order Clauses
11176 @section Bit_Order Clauses
11177 @cindex Bit_Order Clause
11178 @cindex bit ordering
11179 @cindex ordering, of bits
11182 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
11183 attribute. The specification may either correspond to the default bit
11184 order for the target, in which case the specification has no effect and
11185 places no additional restrictions, or it may be for the non-standard
11186 setting (that is the opposite of the default).
11188 In the case where the non-standard value is specified, the effect is
11189 to renumber bits within each byte, but the ordering of bytes is not
11190 affected. There are certain
11191 restrictions placed on component clauses as follows:
11195 @item Components fitting within a single storage unit.
11197 These are unrestricted, and the effect is merely to renumber bits. For
11198 example if we are on a little-endian machine with @code{Low_Order_First}
11199 being the default, then the following two declarations have exactly
11202 @smallexample @c ada
11205 B : Integer range 1 .. 120;
11209 A at 0 range 0 .. 0;
11210 B at 0 range 1 .. 7;
11215 B : Integer range 1 .. 120;
11218 for R2'Bit_Order use High_Order_First;
11221 A at 0 range 7 .. 7;
11222 B at 0 range 0 .. 6;
11227 The useful application here is to write the second declaration with the
11228 @code{Bit_Order} attribute definition clause, and know that it will be treated
11229 the same, regardless of whether the target is little-endian or big-endian.
11231 @item Components occupying an integral number of bytes.
11233 These are components that exactly fit in two or more bytes. Such component
11234 declarations are allowed, but have no effect, since it is important to realize
11235 that the @code{Bit_Order} specification does not affect the ordering of bytes.
11236 In particular, the following attempt at getting an endian-independent integer
11239 @smallexample @c ada
11244 for R2'Bit_Order use High_Order_First;
11247 A at 0 range 0 .. 31;
11252 This declaration will result in a little-endian integer on a
11253 little-endian machine, and a big-endian integer on a big-endian machine.
11254 If byte flipping is required for interoperability between big- and
11255 little-endian machines, this must be explicitly programmed. This capability
11256 is not provided by @code{Bit_Order}.
11258 @item Components that are positioned across byte boundaries
11260 but do not occupy an integral number of bytes. Given that bytes are not
11261 reordered, such fields would occupy a non-contiguous sequence of bits
11262 in memory, requiring non-trivial code to reassemble. They are for this
11263 reason not permitted, and any component clause specifying such a layout
11264 will be flagged as illegal by GNAT@.
11269 Since the misconception that Bit_Order automatically deals with all
11270 endian-related incompatibilities is a common one, the specification of
11271 a component field that is an integral number of bytes will always
11272 generate a warning. This warning may be suppressed using @code{pragma
11273 Warnings (Off)} if desired. The following section contains additional
11274 details regarding the issue of byte ordering.
11276 @node Effect of Bit_Order on Byte Ordering
11277 @section Effect of Bit_Order on Byte Ordering
11278 @cindex byte ordering
11279 @cindex ordering, of bytes
11282 In this section we will review the effect of the @code{Bit_Order} attribute
11283 definition clause on byte ordering. Briefly, it has no effect at all, but
11284 a detailed example will be helpful. Before giving this
11285 example, let us review the precise
11286 definition of the effect of defining @code{Bit_Order}. The effect of a
11287 non-standard bit order is described in section 15.5.3 of the Ada
11291 2 A bit ordering is a method of interpreting the meaning of
11292 the storage place attributes.
11296 To understand the precise definition of storage place attributes in
11297 this context, we visit section 13.5.1 of the manual:
11300 13 A record_representation_clause (without the mod_clause)
11301 specifies the layout. The storage place attributes (see 13.5.2)
11302 are taken from the values of the position, first_bit, and last_bit
11303 expressions after normalizing those values so that first_bit is
11304 less than Storage_Unit.
11308 The critical point here is that storage places are taken from
11309 the values after normalization, not before. So the @code{Bit_Order}
11310 interpretation applies to normalized values. The interpretation
11311 is described in the later part of the 15.5.3 paragraph:
11314 2 A bit ordering is a method of interpreting the meaning of
11315 the storage place attributes. High_Order_First (known in the
11316 vernacular as ``big endian'') means that the first bit of a
11317 storage element (bit 0) is the most significant bit (interpreting
11318 the sequence of bits that represent a component as an unsigned
11319 integer value). Low_Order_First (known in the vernacular as
11320 ``little endian'') means the opposite: the first bit is the
11325 Note that the numbering is with respect to the bits of a storage
11326 unit. In other words, the specification affects only the numbering
11327 of bits within a single storage unit.
11329 We can make the effect clearer by giving an example.
11331 Suppose that we have an external device which presents two bytes, the first
11332 byte presented, which is the first (low addressed byte) of the two byte
11333 record is called Master, and the second byte is called Slave.
11335 The left most (most significant bit is called Control for each byte, and
11336 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
11337 (least significant) bit.
11339 On a big-endian machine, we can write the following representation clause
11341 @smallexample @c ada
11342 type Data is record
11343 Master_Control : Bit;
11351 Slave_Control : Bit;
11361 for Data use record
11362 Master_Control at 0 range 0 .. 0;
11363 Master_V1 at 0 range 1 .. 1;
11364 Master_V2 at 0 range 2 .. 2;
11365 Master_V3 at 0 range 3 .. 3;
11366 Master_V4 at 0 range 4 .. 4;
11367 Master_V5 at 0 range 5 .. 5;
11368 Master_V6 at 0 range 6 .. 6;
11369 Master_V7 at 0 range 7 .. 7;
11370 Slave_Control at 1 range 0 .. 0;
11371 Slave_V1 at 1 range 1 .. 1;
11372 Slave_V2 at 1 range 2 .. 2;
11373 Slave_V3 at 1 range 3 .. 3;
11374 Slave_V4 at 1 range 4 .. 4;
11375 Slave_V5 at 1 range 5 .. 5;
11376 Slave_V6 at 1 range 6 .. 6;
11377 Slave_V7 at 1 range 7 .. 7;
11382 Now if we move this to a little endian machine, then the bit ordering within
11383 the byte is backwards, so we have to rewrite the record rep clause as:
11385 @smallexample @c ada
11386 for Data use record
11387 Master_Control at 0 range 7 .. 7;
11388 Master_V1 at 0 range 6 .. 6;
11389 Master_V2 at 0 range 5 .. 5;
11390 Master_V3 at 0 range 4 .. 4;
11391 Master_V4 at 0 range 3 .. 3;
11392 Master_V5 at 0 range 2 .. 2;
11393 Master_V6 at 0 range 1 .. 1;
11394 Master_V7 at 0 range 0 .. 0;
11395 Slave_Control at 1 range 7 .. 7;
11396 Slave_V1 at 1 range 6 .. 6;
11397 Slave_V2 at 1 range 5 .. 5;
11398 Slave_V3 at 1 range 4 .. 4;
11399 Slave_V4 at 1 range 3 .. 3;
11400 Slave_V5 at 1 range 2 .. 2;
11401 Slave_V6 at 1 range 1 .. 1;
11402 Slave_V7 at 1 range 0 .. 0;
11407 It is a nuisance to have to rewrite the clause, especially if
11408 the code has to be maintained on both machines. However,
11409 this is a case that we can handle with the
11410 @code{Bit_Order} attribute if it is implemented.
11411 Note that the implementation is not required on byte addressed
11412 machines, but it is indeed implemented in GNAT.
11413 This means that we can simply use the
11414 first record clause, together with the declaration
11416 @smallexample @c ada
11417 for Data'Bit_Order use High_Order_First;
11421 and the effect is what is desired, namely the layout is exactly the same,
11422 independent of whether the code is compiled on a big-endian or little-endian
11425 The important point to understand is that byte ordering is not affected.
11426 A @code{Bit_Order} attribute definition never affects which byte a field
11427 ends up in, only where it ends up in that byte.
11428 To make this clear, let us rewrite the record rep clause of the previous
11431 @smallexample @c ada
11432 for Data'Bit_Order use High_Order_First;
11433 for Data use record
11434 Master_Control at 0 range 0 .. 0;
11435 Master_V1 at 0 range 1 .. 1;
11436 Master_V2 at 0 range 2 .. 2;
11437 Master_V3 at 0 range 3 .. 3;
11438 Master_V4 at 0 range 4 .. 4;
11439 Master_V5 at 0 range 5 .. 5;
11440 Master_V6 at 0 range 6 .. 6;
11441 Master_V7 at 0 range 7 .. 7;
11442 Slave_Control at 0 range 8 .. 8;
11443 Slave_V1 at 0 range 9 .. 9;
11444 Slave_V2 at 0 range 10 .. 10;
11445 Slave_V3 at 0 range 11 .. 11;
11446 Slave_V4 at 0 range 12 .. 12;
11447 Slave_V5 at 0 range 13 .. 13;
11448 Slave_V6 at 0 range 14 .. 14;
11449 Slave_V7 at 0 range 15 .. 15;
11454 This is exactly equivalent to saying (a repeat of the first example):
11456 @smallexample @c ada
11457 for Data'Bit_Order use High_Order_First;
11458 for Data use record
11459 Master_Control at 0 range 0 .. 0;
11460 Master_V1 at 0 range 1 .. 1;
11461 Master_V2 at 0 range 2 .. 2;
11462 Master_V3 at 0 range 3 .. 3;
11463 Master_V4 at 0 range 4 .. 4;
11464 Master_V5 at 0 range 5 .. 5;
11465 Master_V6 at 0 range 6 .. 6;
11466 Master_V7 at 0 range 7 .. 7;
11467 Slave_Control at 1 range 0 .. 0;
11468 Slave_V1 at 1 range 1 .. 1;
11469 Slave_V2 at 1 range 2 .. 2;
11470 Slave_V3 at 1 range 3 .. 3;
11471 Slave_V4 at 1 range 4 .. 4;
11472 Slave_V5 at 1 range 5 .. 5;
11473 Slave_V6 at 1 range 6 .. 6;
11474 Slave_V7 at 1 range 7 .. 7;
11479 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
11480 field. The storage place attributes are obtained by normalizing the
11481 values given so that the @code{First_Bit} value is less than 8. After
11482 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
11483 we specified in the other case.
11485 Now one might expect that the @code{Bit_Order} attribute might affect
11486 bit numbering within the entire record component (two bytes in this
11487 case, thus affecting which byte fields end up in), but that is not
11488 the way this feature is defined, it only affects numbering of bits,
11489 not which byte they end up in.
11491 Consequently it never makes sense to specify a starting bit number
11492 greater than 7 (for a byte addressable field) if an attribute
11493 definition for @code{Bit_Order} has been given, and indeed it
11494 may be actively confusing to specify such a value, so the compiler
11495 generates a warning for such usage.
11497 If you do need to control byte ordering then appropriate conditional
11498 values must be used. If in our example, the slave byte came first on
11499 some machines we might write:
11501 @smallexample @c ada
11502 Master_Byte_First constant Boolean := @dots{};
11504 Master_Byte : constant Natural :=
11505 1 - Boolean'Pos (Master_Byte_First);
11506 Slave_Byte : constant Natural :=
11507 Boolean'Pos (Master_Byte_First);
11509 for Data'Bit_Order use High_Order_First;
11510 for Data use record
11511 Master_Control at Master_Byte range 0 .. 0;
11512 Master_V1 at Master_Byte range 1 .. 1;
11513 Master_V2 at Master_Byte range 2 .. 2;
11514 Master_V3 at Master_Byte range 3 .. 3;
11515 Master_V4 at Master_Byte range 4 .. 4;
11516 Master_V5 at Master_Byte range 5 .. 5;
11517 Master_V6 at Master_Byte range 6 .. 6;
11518 Master_V7 at Master_Byte range 7 .. 7;
11519 Slave_Control at Slave_Byte range 0 .. 0;
11520 Slave_V1 at Slave_Byte range 1 .. 1;
11521 Slave_V2 at Slave_Byte range 2 .. 2;
11522 Slave_V3 at Slave_Byte range 3 .. 3;
11523 Slave_V4 at Slave_Byte range 4 .. 4;
11524 Slave_V5 at Slave_Byte range 5 .. 5;
11525 Slave_V6 at Slave_Byte range 6 .. 6;
11526 Slave_V7 at Slave_Byte range 7 .. 7;
11531 Now to switch between machines, all that is necessary is
11532 to set the boolean constant @code{Master_Byte_First} in
11533 an appropriate manner.
11535 @node Pragma Pack for Arrays
11536 @section Pragma Pack for Arrays
11537 @cindex Pragma Pack (for arrays)
11540 Pragma @code{Pack} applied to an array has no effect unless the component type
11541 is packable. For a component type to be packable, it must be one of the
11548 Any type whose size is specified with a size clause
11550 Any packed array type with a static size
11552 Any record type padded because of its default alignment
11556 For all these cases, if the component subtype size is in the range
11557 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
11558 component size were specified giving the component subtype size.
11559 For example if we have:
11561 @smallexample @c ada
11562 type r is range 0 .. 17;
11564 type ar is array (1 .. 8) of r;
11569 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
11570 and the size of the array @code{ar} will be exactly 40 bits.
11572 Note that in some cases this rather fierce approach to packing can produce
11573 unexpected effects. For example, in Ada 95 and Ada 2005,
11574 subtype @code{Natural} typically has a size of 31, meaning that if you
11575 pack an array of @code{Natural}, you get 31-bit
11576 close packing, which saves a few bits, but results in far less efficient
11577 access. Since many other Ada compilers will ignore such a packing request,
11578 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
11579 might not be what is intended. You can easily remove this warning by
11580 using an explicit @code{Component_Size} setting instead, which never generates
11581 a warning, since the intention of the programmer is clear in this case.
11583 GNAT treats packed arrays in one of two ways. If the size of the array is
11584 known at compile time and is less than 64 bits, then internally the array
11585 is represented as a single modular type, of exactly the appropriate number
11586 of bits. If the length is greater than 63 bits, or is not known at compile
11587 time, then the packed array is represented as an array of bytes, and the
11588 length is always a multiple of 8 bits.
11590 Note that to represent a packed array as a modular type, the alignment must
11591 be suitable for the modular type involved. For example, on typical machines
11592 a 32-bit packed array will be represented by a 32-bit modular integer with
11593 an alignment of four bytes. If you explicitly override the default alignment
11594 with an alignment clause that is too small, the modular representation
11595 cannot be used. For example, consider the following set of declarations:
11597 @smallexample @c ada
11598 type R is range 1 .. 3;
11599 type S is array (1 .. 31) of R;
11600 for S'Component_Size use 2;
11602 for S'Alignment use 1;
11606 If the alignment clause were not present, then a 62-bit modular
11607 representation would be chosen (typically with an alignment of 4 or 8
11608 bytes depending on the target). But the default alignment is overridden
11609 with the explicit alignment clause. This means that the modular
11610 representation cannot be used, and instead the array of bytes
11611 representation must be used, meaning that the length must be a multiple
11612 of 8. Thus the above set of declarations will result in a diagnostic
11613 rejecting the size clause and noting that the minimum size allowed is 64.
11615 @cindex Pragma Pack (for type Natural)
11616 @cindex Pragma Pack warning
11618 One special case that is worth noting occurs when the base type of the
11619 component size is 8/16/32 and the subtype is one bit less. Notably this
11620 occurs with subtype @code{Natural}. Consider:
11622 @smallexample @c ada
11623 type Arr is array (1 .. 32) of Natural;
11628 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11629 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11630 Ada 83 compilers did not attempt 31 bit packing.
11632 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11633 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11634 substantial unintended performance penalty when porting legacy Ada 83 code.
11635 To help prevent this, GNAT generates a warning in such cases. If you really
11636 want 31 bit packing in a case like this, you can set the component size
11639 @smallexample @c ada
11640 type Arr is array (1 .. 32) of Natural;
11641 for Arr'Component_Size use 31;
11645 Here 31-bit packing is achieved as required, and no warning is generated,
11646 since in this case the programmer intention is clear.
11648 @node Pragma Pack for Records
11649 @section Pragma Pack for Records
11650 @cindex Pragma Pack (for records)
11653 Pragma @code{Pack} applied to a record will pack the components to reduce
11654 wasted space from alignment gaps and by reducing the amount of space
11655 taken by components. We distinguish between @emph{packable} components and
11656 @emph{non-packable} components.
11657 Components of the following types are considered packable:
11660 All primitive types are packable.
11663 Small packed arrays, whose size does not exceed 64 bits, and where the
11664 size is statically known at compile time, are represented internally
11665 as modular integers, and so they are also packable.
11670 All packable components occupy the exact number of bits corresponding to
11671 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11672 can start on an arbitrary bit boundary.
11674 All other types are non-packable, they occupy an integral number of
11676 are placed at a boundary corresponding to their alignment requirements.
11678 For example, consider the record
11680 @smallexample @c ada
11681 type Rb1 is array (1 .. 13) of Boolean;
11684 type Rb2 is array (1 .. 65) of Boolean;
11699 The representation for the record x2 is as follows:
11701 @smallexample @c ada
11702 for x2'Size use 224;
11704 l1 at 0 range 0 .. 0;
11705 l2 at 0 range 1 .. 64;
11706 l3 at 12 range 0 .. 31;
11707 l4 at 16 range 0 .. 0;
11708 l5 at 16 range 1 .. 13;
11709 l6 at 18 range 0 .. 71;
11714 Studying this example, we see that the packable fields @code{l1}
11716 of length equal to their sizes, and placed at specific bit boundaries (and
11717 not byte boundaries) to
11718 eliminate padding. But @code{l3} is of a non-packable float type, so
11719 it is on the next appropriate alignment boundary.
11721 The next two fields are fully packable, so @code{l4} and @code{l5} are
11722 minimally packed with no gaps. However, type @code{Rb2} is a packed
11723 array that is longer than 64 bits, so it is itself non-packable. Thus
11724 the @code{l6} field is aligned to the next byte boundary, and takes an
11725 integral number of bytes, i.e.@: 72 bits.
11727 @node Record Representation Clauses
11728 @section Record Representation Clauses
11729 @cindex Record Representation Clause
11732 Record representation clauses may be given for all record types, including
11733 types obtained by record extension. Component clauses are allowed for any
11734 static component. The restrictions on component clauses depend on the type
11737 @cindex Component Clause
11738 For all components of an elementary type, the only restriction on component
11739 clauses is that the size must be at least the 'Size value of the type
11740 (actually the Value_Size). There are no restrictions due to alignment,
11741 and such components may freely cross storage boundaries.
11743 Packed arrays with a size up to and including 64 bits are represented
11744 internally using a modular type with the appropriate number of bits, and
11745 thus the same lack of restriction applies. For example, if you declare:
11747 @smallexample @c ada
11748 type R is array (1 .. 49) of Boolean;
11754 then a component clause for a component of type R may start on any
11755 specified bit boundary, and may specify a value of 49 bits or greater.
11757 For packed bit arrays that are longer than 64 bits, there are two
11758 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11759 including the important case of single bits or boolean values, then
11760 there are no limitations on placement of such components, and they
11761 may start and end at arbitrary bit boundaries.
11763 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11764 an array of this type longer than 64 bits must always be placed on
11765 on a storage unit (byte) boundary and occupy an integral number
11766 of storage units (bytes). Any component clause that does not
11767 meet this requirement will be rejected.
11769 Any aliased component, or component of an aliased type, must
11770 have its normal alignment and size. A component clause that
11771 does not meet this requirement will be rejected.
11773 The tag field of a tagged type always occupies an address sized field at
11774 the start of the record. No component clause may attempt to overlay this
11775 tag. When a tagged type appears as a component, the tag field must have
11778 In the case of a record extension T1, of a type T, no component clause applied
11779 to the type T1 can specify a storage location that would overlap the first
11780 T'Size bytes of the record.
11782 For all other component types, including non-bit-packed arrays,
11783 the component can be placed at an arbitrary bit boundary,
11784 so for example, the following is permitted:
11786 @smallexample @c ada
11787 type R is array (1 .. 10) of Boolean;
11796 G at 0 range 0 .. 0;
11797 H at 0 range 1 .. 1;
11798 L at 0 range 2 .. 81;
11799 R at 0 range 82 .. 161;
11804 Note: the above rules apply to recent releases of GNAT 5.
11805 In GNAT 3, there are more severe restrictions on larger components.
11806 For non-primitive types, including packed arrays with a size greater than
11807 64 bits, component clauses must respect the alignment requirement of the
11808 type, in particular, always starting on a byte boundary, and the length
11809 must be a multiple of the storage unit.
11811 @node Enumeration Clauses
11812 @section Enumeration Clauses
11814 The only restriction on enumeration clauses is that the range of values
11815 must be representable. For the signed case, if one or more of the
11816 representation values are negative, all values must be in the range:
11818 @smallexample @c ada
11819 System.Min_Int .. System.Max_Int
11823 For the unsigned case, where all values are nonnegative, the values must
11826 @smallexample @c ada
11827 0 .. System.Max_Binary_Modulus;
11831 A @emph{confirming} representation clause is one in which the values range
11832 from 0 in sequence, i.e.@: a clause that confirms the default representation
11833 for an enumeration type.
11834 Such a confirming representation
11835 is permitted by these rules, and is specially recognized by the compiler so
11836 that no extra overhead results from the use of such a clause.
11838 If an array has an index type which is an enumeration type to which an
11839 enumeration clause has been applied, then the array is stored in a compact
11840 manner. Consider the declarations:
11842 @smallexample @c ada
11843 type r is (A, B, C);
11844 for r use (A => 1, B => 5, C => 10);
11845 type t is array (r) of Character;
11849 The array type t corresponds to a vector with exactly three elements and
11850 has a default size equal to @code{3*Character'Size}. This ensures efficient
11851 use of space, but means that accesses to elements of the array will incur
11852 the overhead of converting representation values to the corresponding
11853 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11855 @node Address Clauses
11856 @section Address Clauses
11857 @cindex Address Clause
11859 The reference manual allows a general restriction on representation clauses,
11860 as found in RM 13.1(22):
11863 An implementation need not support representation
11864 items containing nonstatic expressions, except that
11865 an implementation should support a representation item
11866 for a given entity if each nonstatic expression in the
11867 representation item is a name that statically denotes
11868 a constant declared before the entity.
11872 In practice this is applicable only to address clauses, since this is the
11873 only case in which a non-static expression is permitted by the syntax. As
11874 the AARM notes in sections 13.1 (22.a-22.h):
11877 22.a Reason: This is to avoid the following sort of thing:
11879 22.b X : Integer := F(@dots{});
11880 Y : Address := G(@dots{});
11881 for X'Address use Y;
11883 22.c In the above, we have to evaluate the
11884 initialization expression for X before we
11885 know where to put the result. This seems
11886 like an unreasonable implementation burden.
11888 22.d The above code should instead be written
11891 22.e Y : constant Address := G(@dots{});
11892 X : Integer := F(@dots{});
11893 for X'Address use Y;
11895 22.f This allows the expression ``Y'' to be safely
11896 evaluated before X is created.
11898 22.g The constant could be a formal parameter of mode in.
11900 22.h An implementation can support other nonstatic
11901 expressions if it wants to. Expressions of type
11902 Address are hardly ever static, but their value
11903 might be known at compile time anyway in many
11908 GNAT does indeed permit many additional cases of non-static expressions. In
11909 particular, if the type involved is elementary there are no restrictions
11910 (since in this case, holding a temporary copy of the initialization value,
11911 if one is present, is inexpensive). In addition, if there is no implicit or
11912 explicit initialization, then there are no restrictions. GNAT will reject
11913 only the case where all three of these conditions hold:
11918 The type of the item is non-elementary (e.g.@: a record or array).
11921 There is explicit or implicit initialization required for the object.
11922 Note that access values are always implicitly initialized, and also
11923 in GNAT, certain bit-packed arrays (those having a dynamic length or
11924 a length greater than 64) will also be implicitly initialized to zero.
11927 The address value is non-static. Here GNAT is more permissive than the
11928 RM, and allows the address value to be the address of a previously declared
11929 stand-alone variable, as long as it does not itself have an address clause.
11931 @smallexample @c ada
11932 Anchor : Some_Initialized_Type;
11933 Overlay : Some_Initialized_Type;
11934 for Overlay'Address use Anchor'Address;
11938 However, the prefix of the address clause cannot be an array component, or
11939 a component of a discriminated record.
11944 As noted above in section 22.h, address values are typically non-static. In
11945 particular the To_Address function, even if applied to a literal value, is
11946 a non-static function call. To avoid this minor annoyance, GNAT provides
11947 the implementation defined attribute 'To_Address. The following two
11948 expressions have identical values:
11952 @smallexample @c ada
11953 To_Address (16#1234_0000#)
11954 System'To_Address (16#1234_0000#);
11958 except that the second form is considered to be a static expression, and
11959 thus when used as an address clause value is always permitted.
11962 Additionally, GNAT treats as static an address clause that is an
11963 unchecked_conversion of a static integer value. This simplifies the porting
11964 of legacy code, and provides a portable equivalent to the GNAT attribute
11967 Another issue with address clauses is the interaction with alignment
11968 requirements. When an address clause is given for an object, the address
11969 value must be consistent with the alignment of the object (which is usually
11970 the same as the alignment of the type of the object). If an address clause
11971 is given that specifies an inappropriately aligned address value, then the
11972 program execution is erroneous.
11974 Since this source of erroneous behavior can have unfortunate effects, GNAT
11975 checks (at compile time if possible, generating a warning, or at execution
11976 time with a run-time check) that the alignment is appropriate. If the
11977 run-time check fails, then @code{Program_Error} is raised. This run-time
11978 check is suppressed if range checks are suppressed, or if the special GNAT
11979 check Alignment_Check is suppressed, or if
11980 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11982 Finally, GNAT does not permit overlaying of objects of controlled types or
11983 composite types containing a controlled component. In most cases, the compiler
11984 can detect an attempt at such overlays and will generate a warning at compile
11985 time and a Program_Error exception at run time.
11988 An address clause cannot be given for an exported object. More
11989 understandably the real restriction is that objects with an address
11990 clause cannot be exported. This is because such variables are not
11991 defined by the Ada program, so there is no external object to export.
11994 It is permissible to give an address clause and a pragma Import for the
11995 same object. In this case, the variable is not really defined by the
11996 Ada program, so there is no external symbol to be linked. The link name
11997 and the external name are ignored in this case. The reason that we allow this
11998 combination is that it provides a useful idiom to avoid unwanted
11999 initializations on objects with address clauses.
12001 When an address clause is given for an object that has implicit or
12002 explicit initialization, then by default initialization takes place. This
12003 means that the effect of the object declaration is to overwrite the
12004 memory at the specified address. This is almost always not what the
12005 programmer wants, so GNAT will output a warning:
12015 for Ext'Address use System'To_Address (16#1234_1234#);
12017 >>> warning: implicit initialization of "Ext" may
12018 modify overlaid storage
12019 >>> warning: use pragma Import for "Ext" to suppress
12020 initialization (RM B(24))
12026 As indicated by the warning message, the solution is to use a (dummy) pragma
12027 Import to suppress this initialization. The pragma tell the compiler that the
12028 object is declared and initialized elsewhere. The following package compiles
12029 without warnings (and the initialization is suppressed):
12031 @smallexample @c ada
12039 for Ext'Address use System'To_Address (16#1234_1234#);
12040 pragma Import (Ada, Ext);
12045 A final issue with address clauses involves their use for overlaying
12046 variables, as in the following example:
12047 @cindex Overlaying of objects
12049 @smallexample @c ada
12052 for B'Address use A'Address;
12056 or alternatively, using the form recommended by the RM:
12058 @smallexample @c ada
12060 Addr : constant Address := A'Address;
12062 for B'Address use Addr;
12066 In both of these cases, @code{A}
12067 and @code{B} become aliased to one another via the
12068 address clause. This use of address clauses to overlay
12069 variables, achieving an effect similar to unchecked
12070 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
12071 the effect is implementation defined. Furthermore, the
12072 Ada RM specifically recommends that in a situation
12073 like this, @code{B} should be subject to the following
12074 implementation advice (RM 13.3(19)):
12077 19 If the Address of an object is specified, or it is imported
12078 or exported, then the implementation should not perform
12079 optimizations based on assumptions of no aliases.
12083 GNAT follows this recommendation, and goes further by also applying
12084 this recommendation to the overlaid variable (@code{A}
12085 in the above example) in this case. This means that the overlay
12086 works "as expected", in that a modification to one of the variables
12087 will affect the value of the other.
12089 @node Effect of Convention on Representation
12090 @section Effect of Convention on Representation
12091 @cindex Convention, effect on representation
12094 Normally the specification of a foreign language convention for a type or
12095 an object has no effect on the chosen representation. In particular, the
12096 representation chosen for data in GNAT generally meets the standard system
12097 conventions, and for example records are laid out in a manner that is
12098 consistent with C@. This means that specifying convention C (for example)
12101 There are four exceptions to this general rule:
12105 @item Convention Fortran and array subtypes
12106 If pragma Convention Fortran is specified for an array subtype, then in
12107 accordance with the implementation advice in section 3.6.2(11) of the
12108 Ada Reference Manual, the array will be stored in a Fortran-compatible
12109 column-major manner, instead of the normal default row-major order.
12111 @item Convention C and enumeration types
12112 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
12113 to accommodate all values of the type. For example, for the enumeration
12116 @smallexample @c ada
12117 type Color is (Red, Green, Blue);
12121 8 bits is sufficient to store all values of the type, so by default, objects
12122 of type @code{Color} will be represented using 8 bits. However, normal C
12123 convention is to use 32 bits for all enum values in C, since enum values
12124 are essentially of type int. If pragma @code{Convention C} is specified for an
12125 Ada enumeration type, then the size is modified as necessary (usually to
12126 32 bits) to be consistent with the C convention for enum values.
12128 Note that this treatment applies only to types. If Convention C is given for
12129 an enumeration object, where the enumeration type is not Convention C, then
12130 Object_Size bits are allocated. For example, for a normal enumeration type,
12131 with less than 256 elements, only 8 bits will be allocated for the object.
12132 Since this may be a surprise in terms of what C expects, GNAT will issue a
12133 warning in this situation. The warning can be suppressed by giving an explicit
12134 size clause specifying the desired size.
12136 @item Convention C/Fortran and Boolean types
12137 In C, the usual convention for boolean values, that is values used for
12138 conditions, is that zero represents false, and nonzero values represent
12139 true. In Ada, the normal convention is that two specific values, typically
12140 0/1, are used to represent false/true respectively.
12142 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
12143 value represents true).
12145 To accommodate the Fortran and C conventions, if a pragma Convention specifies
12146 C or Fortran convention for a derived Boolean, as in the following example:
12148 @smallexample @c ada
12149 type C_Switch is new Boolean;
12150 pragma Convention (C, C_Switch);
12154 then the GNAT generated code will treat any nonzero value as true. For truth
12155 values generated by GNAT, the conventional value 1 will be used for True, but
12156 when one of these values is read, any nonzero value is treated as True.
12158 @item Access types on OpenVMS
12159 For 64-bit OpenVMS systems, access types (other than those for unconstrained
12160 arrays) are 64-bits long. An exception to this rule is for the case of
12161 C-convention access types where there is no explicit size clause present (or
12162 inherited for derived types). In this case, GNAT chooses to make these
12163 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
12164 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
12168 @node Determining the Representations chosen by GNAT
12169 @section Determining the Representations chosen by GNAT
12170 @cindex Representation, determination of
12171 @cindex @option{-gnatR} switch
12174 Although the descriptions in this section are intended to be complete, it is
12175 often easier to simply experiment to see what GNAT accepts and what the
12176 effect is on the layout of types and objects.
12178 As required by the Ada RM, if a representation clause is not accepted, then
12179 it must be rejected as illegal by the compiler. However, when a
12180 representation clause or pragma is accepted, there can still be questions
12181 of what the compiler actually does. For example, if a partial record
12182 representation clause specifies the location of some components and not
12183 others, then where are the non-specified components placed? Or if pragma
12184 @code{Pack} is used on a record, then exactly where are the resulting
12185 fields placed? The section on pragma @code{Pack} in this chapter can be
12186 used to answer the second question, but it is often easier to just see
12187 what the compiler does.
12189 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
12190 with this option, then the compiler will output information on the actual
12191 representations chosen, in a format similar to source representation
12192 clauses. For example, if we compile the package:
12194 @smallexample @c ada
12196 type r (x : boolean) is tagged record
12198 when True => S : String (1 .. 100);
12199 when False => null;
12203 type r2 is new r (false) with record
12208 y2 at 16 range 0 .. 31;
12215 type x1 is array (1 .. 10) of x;
12216 for x1'component_size use 11;
12218 type ia is access integer;
12220 type Rb1 is array (1 .. 13) of Boolean;
12223 type Rb2 is array (1 .. 65) of Boolean;
12239 using the switch @option{-gnatR} we obtain the following output:
12242 Representation information for unit q
12243 -------------------------------------
12246 for r'Alignment use 4;
12248 x at 4 range 0 .. 7;
12249 _tag at 0 range 0 .. 31;
12250 s at 5 range 0 .. 799;
12253 for r2'Size use 160;
12254 for r2'Alignment use 4;
12256 x at 4 range 0 .. 7;
12257 _tag at 0 range 0 .. 31;
12258 _parent at 0 range 0 .. 63;
12259 y2 at 16 range 0 .. 31;
12263 for x'Alignment use 1;
12265 y at 0 range 0 .. 7;
12268 for x1'Size use 112;
12269 for x1'Alignment use 1;
12270 for x1'Component_Size use 11;
12272 for rb1'Size use 13;
12273 for rb1'Alignment use 2;
12274 for rb1'Component_Size use 1;
12276 for rb2'Size use 72;
12277 for rb2'Alignment use 1;
12278 for rb2'Component_Size use 1;
12280 for x2'Size use 224;
12281 for x2'Alignment use 4;
12283 l1 at 0 range 0 .. 0;
12284 l2 at 0 range 1 .. 64;
12285 l3 at 12 range 0 .. 31;
12286 l4 at 16 range 0 .. 0;
12287 l5 at 16 range 1 .. 13;
12288 l6 at 18 range 0 .. 71;
12293 The Size values are actually the Object_Size, i.e.@: the default size that
12294 will be allocated for objects of the type.
12295 The ?? size for type r indicates that we have a variant record, and the
12296 actual size of objects will depend on the discriminant value.
12298 The Alignment values show the actual alignment chosen by the compiler
12299 for each record or array type.
12301 The record representation clause for type r shows where all fields
12302 are placed, including the compiler generated tag field (whose location
12303 cannot be controlled by the programmer).
12305 The record representation clause for the type extension r2 shows all the
12306 fields present, including the parent field, which is a copy of the fields
12307 of the parent type of r2, i.e.@: r1.
12309 The component size and size clauses for types rb1 and rb2 show
12310 the exact effect of pragma @code{Pack} on these arrays, and the record
12311 representation clause for type x2 shows how pragma @code{Pack} affects
12314 In some cases, it may be useful to cut and paste the representation clauses
12315 generated by the compiler into the original source to fix and guarantee
12316 the actual representation to be used.
12318 @node Standard Library Routines
12319 @chapter Standard Library Routines
12322 The Ada Reference Manual contains in Annex A a full description of an
12323 extensive set of standard library routines that can be used in any Ada
12324 program, and which must be provided by all Ada compilers. They are
12325 analogous to the standard C library used by C programs.
12327 GNAT implements all of the facilities described in annex A, and for most
12328 purposes the description in the Ada Reference Manual, or appropriate Ada
12329 text book, will be sufficient for making use of these facilities.
12331 In the case of the input-output facilities,
12332 @xref{The Implementation of Standard I/O},
12333 gives details on exactly how GNAT interfaces to the
12334 file system. For the remaining packages, the Ada Reference Manual
12335 should be sufficient. The following is a list of the packages included,
12336 together with a brief description of the functionality that is provided.
12338 For completeness, references are included to other predefined library
12339 routines defined in other sections of the Ada Reference Manual (these are
12340 cross-indexed from Annex A).
12344 This is a parent package for all the standard library packages. It is
12345 usually included implicitly in your program, and itself contains no
12346 useful data or routines.
12348 @item Ada.Calendar (9.6)
12349 @code{Calendar} provides time of day access, and routines for
12350 manipulating times and durations.
12352 @item Ada.Characters (A.3.1)
12353 This is a dummy parent package that contains no useful entities
12355 @item Ada.Characters.Handling (A.3.2)
12356 This package provides some basic character handling capabilities,
12357 including classification functions for classes of characters (e.g.@: test
12358 for letters, or digits).
12360 @item Ada.Characters.Latin_1 (A.3.3)
12361 This package includes a complete set of definitions of the characters
12362 that appear in type CHARACTER@. It is useful for writing programs that
12363 will run in international environments. For example, if you want an
12364 upper case E with an acute accent in a string, it is often better to use
12365 the definition of @code{UC_E_Acute} in this package. Then your program
12366 will print in an understandable manner even if your environment does not
12367 support these extended characters.
12369 @item Ada.Command_Line (A.15)
12370 This package provides access to the command line parameters and the name
12371 of the current program (analogous to the use of @code{argc} and @code{argv}
12372 in C), and also allows the exit status for the program to be set in a
12373 system-independent manner.
12375 @item Ada.Decimal (F.2)
12376 This package provides constants describing the range of decimal numbers
12377 implemented, and also a decimal divide routine (analogous to the COBOL
12378 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
12380 @item Ada.Direct_IO (A.8.4)
12381 This package provides input-output using a model of a set of records of
12382 fixed-length, containing an arbitrary definite Ada type, indexed by an
12383 integer record number.
12385 @item Ada.Dynamic_Priorities (D.5)
12386 This package allows the priorities of a task to be adjusted dynamically
12387 as the task is running.
12389 @item Ada.Exceptions (11.4.1)
12390 This package provides additional information on exceptions, and also
12391 contains facilities for treating exceptions as data objects, and raising
12392 exceptions with associated messages.
12394 @item Ada.Finalization (7.6)
12395 This package contains the declarations and subprograms to support the
12396 use of controlled types, providing for automatic initialization and
12397 finalization (analogous to the constructors and destructors of C++)
12399 @item Ada.Interrupts (C.3.2)
12400 This package provides facilities for interfacing to interrupts, which
12401 includes the set of signals or conditions that can be raised and
12402 recognized as interrupts.
12404 @item Ada.Interrupts.Names (C.3.2)
12405 This package provides the set of interrupt names (actually signal
12406 or condition names) that can be handled by GNAT@.
12408 @item Ada.IO_Exceptions (A.13)
12409 This package defines the set of exceptions that can be raised by use of
12410 the standard IO packages.
12413 This package contains some standard constants and exceptions used
12414 throughout the numerics packages. Note that the constants pi and e are
12415 defined here, and it is better to use these definitions than rolling
12418 @item Ada.Numerics.Complex_Elementary_Functions
12419 Provides the implementation of standard elementary functions (such as
12420 log and trigonometric functions) operating on complex numbers using the
12421 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
12422 created by the package @code{Numerics.Complex_Types}.
12424 @item Ada.Numerics.Complex_Types
12425 This is a predefined instantiation of
12426 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
12427 build the type @code{Complex} and @code{Imaginary}.
12429 @item Ada.Numerics.Discrete_Random
12430 This generic package provides a random number generator suitable for generating
12431 uniformly distributed values of a specified discrete subtype.
12433 @item Ada.Numerics.Float_Random
12434 This package provides a random number generator suitable for generating
12435 uniformly distributed floating point values in the unit interval.
12437 @item Ada.Numerics.Generic_Complex_Elementary_Functions
12438 This is a generic version of the package that provides the
12439 implementation of standard elementary functions (such as log and
12440 trigonometric functions) for an arbitrary complex type.
12442 The following predefined instantiations of this package are provided:
12446 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
12448 @code{Ada.Numerics.Complex_Elementary_Functions}
12450 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
12453 @item Ada.Numerics.Generic_Complex_Types
12454 This is a generic package that allows the creation of complex types,
12455 with associated complex arithmetic operations.
12457 The following predefined instantiations of this package exist
12460 @code{Ada.Numerics.Short_Complex_Complex_Types}
12462 @code{Ada.Numerics.Complex_Complex_Types}
12464 @code{Ada.Numerics.Long_Complex_Complex_Types}
12467 @item Ada.Numerics.Generic_Elementary_Functions
12468 This is a generic package that provides the implementation of standard
12469 elementary functions (such as log an trigonometric functions) for an
12470 arbitrary float type.
12472 The following predefined instantiations of this package exist
12476 @code{Ada.Numerics.Short_Elementary_Functions}
12478 @code{Ada.Numerics.Elementary_Functions}
12480 @code{Ada.Numerics.Long_Elementary_Functions}
12483 @item Ada.Real_Time (D.8)
12484 This package provides facilities similar to those of @code{Calendar}, but
12485 operating with a finer clock suitable for real time control. Note that
12486 annex D requires that there be no backward clock jumps, and GNAT generally
12487 guarantees this behavior, but of course if the external clock on which
12488 the GNAT runtime depends is deliberately reset by some external event,
12489 then such a backward jump may occur.
12491 @item Ada.Sequential_IO (A.8.1)
12492 This package provides input-output facilities for sequential files,
12493 which can contain a sequence of values of a single type, which can be
12494 any Ada type, including indefinite (unconstrained) types.
12496 @item Ada.Storage_IO (A.9)
12497 This package provides a facility for mapping arbitrary Ada types to and
12498 from a storage buffer. It is primarily intended for the creation of new
12501 @item Ada.Streams (13.13.1)
12502 This is a generic package that provides the basic support for the
12503 concept of streams as used by the stream attributes (@code{Input},
12504 @code{Output}, @code{Read} and @code{Write}).
12506 @item Ada.Streams.Stream_IO (A.12.1)
12507 This package is a specialization of the type @code{Streams} defined in
12508 package @code{Streams} together with a set of operations providing
12509 Stream_IO capability. The Stream_IO model permits both random and
12510 sequential access to a file which can contain an arbitrary set of values
12511 of one or more Ada types.
12513 @item Ada.Strings (A.4.1)
12514 This package provides some basic constants used by the string handling
12517 @item Ada.Strings.Bounded (A.4.4)
12518 This package provides facilities for handling variable length
12519 strings. The bounded model requires a maximum length. It is thus
12520 somewhat more limited than the unbounded model, but avoids the use of
12521 dynamic allocation or finalization.
12523 @item Ada.Strings.Fixed (A.4.3)
12524 This package provides facilities for handling fixed length strings.
12526 @item Ada.Strings.Maps (A.4.2)
12527 This package provides facilities for handling character mappings and
12528 arbitrarily defined subsets of characters. For instance it is useful in
12529 defining specialized translation tables.
12531 @item Ada.Strings.Maps.Constants (A.4.6)
12532 This package provides a standard set of predefined mappings and
12533 predefined character sets. For example, the standard upper to lower case
12534 conversion table is found in this package. Note that upper to lower case
12535 conversion is non-trivial if you want to take the entire set of
12536 characters, including extended characters like E with an acute accent,
12537 into account. You should use the mappings in this package (rather than
12538 adding 32 yourself) to do case mappings.
12540 @item Ada.Strings.Unbounded (A.4.5)
12541 This package provides facilities for handling variable length
12542 strings. The unbounded model allows arbitrary length strings, but
12543 requires the use of dynamic allocation and finalization.
12545 @item Ada.Strings.Wide_Bounded (A.4.7)
12546 @itemx Ada.Strings.Wide_Fixed (A.4.7)
12547 @itemx Ada.Strings.Wide_Maps (A.4.7)
12548 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
12549 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
12550 These packages provide analogous capabilities to the corresponding
12551 packages without @samp{Wide_} in the name, but operate with the types
12552 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
12553 and @code{Character}.
12555 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
12556 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
12557 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
12558 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
12559 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
12560 These packages provide analogous capabilities to the corresponding
12561 packages without @samp{Wide_} in the name, but operate with the types
12562 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
12563 of @code{String} and @code{Character}.
12565 @item Ada.Synchronous_Task_Control (D.10)
12566 This package provides some standard facilities for controlling task
12567 communication in a synchronous manner.
12570 This package contains definitions for manipulation of the tags of tagged
12573 @item Ada.Task_Attributes
12574 This package provides the capability of associating arbitrary
12575 task-specific data with separate tasks.
12578 This package provides basic text input-output capabilities for
12579 character, string and numeric data. The subpackages of this
12580 package are listed next.
12582 @item Ada.Text_IO.Decimal_IO
12583 Provides input-output facilities for decimal fixed-point types
12585 @item Ada.Text_IO.Enumeration_IO
12586 Provides input-output facilities for enumeration types.
12588 @item Ada.Text_IO.Fixed_IO
12589 Provides input-output facilities for ordinary fixed-point types.
12591 @item Ada.Text_IO.Float_IO
12592 Provides input-output facilities for float types. The following
12593 predefined instantiations of this generic package are available:
12597 @code{Short_Float_Text_IO}
12599 @code{Float_Text_IO}
12601 @code{Long_Float_Text_IO}
12604 @item Ada.Text_IO.Integer_IO
12605 Provides input-output facilities for integer types. The following
12606 predefined instantiations of this generic package are available:
12609 @item Short_Short_Integer
12610 @code{Ada.Short_Short_Integer_Text_IO}
12611 @item Short_Integer
12612 @code{Ada.Short_Integer_Text_IO}
12614 @code{Ada.Integer_Text_IO}
12616 @code{Ada.Long_Integer_Text_IO}
12617 @item Long_Long_Integer
12618 @code{Ada.Long_Long_Integer_Text_IO}
12621 @item Ada.Text_IO.Modular_IO
12622 Provides input-output facilities for modular (unsigned) types
12624 @item Ada.Text_IO.Complex_IO (G.1.3)
12625 This package provides basic text input-output capabilities for complex
12628 @item Ada.Text_IO.Editing (F.3.3)
12629 This package contains routines for edited output, analogous to the use
12630 of pictures in COBOL@. The picture formats used by this package are a
12631 close copy of the facility in COBOL@.
12633 @item Ada.Text_IO.Text_Streams (A.12.2)
12634 This package provides a facility that allows Text_IO files to be treated
12635 as streams, so that the stream attributes can be used for writing
12636 arbitrary data, including binary data, to Text_IO files.
12638 @item Ada.Unchecked_Conversion (13.9)
12639 This generic package allows arbitrary conversion from one type to
12640 another of the same size, providing for breaking the type safety in
12641 special circumstances.
12643 If the types have the same Size (more accurately the same Value_Size),
12644 then the effect is simply to transfer the bits from the source to the
12645 target type without any modification. This usage is well defined, and
12646 for simple types whose representation is typically the same across
12647 all implementations, gives a portable method of performing such
12650 If the types do not have the same size, then the result is implementation
12651 defined, and thus may be non-portable. The following describes how GNAT
12652 handles such unchecked conversion cases.
12654 If the types are of different sizes, and are both discrete types, then
12655 the effect is of a normal type conversion without any constraint checking.
12656 In particular if the result type has a larger size, the result will be
12657 zero or sign extended. If the result type has a smaller size, the result
12658 will be truncated by ignoring high order bits.
12660 If the types are of different sizes, and are not both discrete types,
12661 then the conversion works as though pointers were created to the source
12662 and target, and the pointer value is converted. The effect is that bits
12663 are copied from successive low order storage units and bits of the source
12664 up to the length of the target type.
12666 A warning is issued if the lengths differ, since the effect in this
12667 case is implementation dependent, and the above behavior may not match
12668 that of some other compiler.
12670 A pointer to one type may be converted to a pointer to another type using
12671 unchecked conversion. The only case in which the effect is undefined is
12672 when one or both pointers are pointers to unconstrained array types. In
12673 this case, the bounds information may get incorrectly transferred, and in
12674 particular, GNAT uses double size pointers for such types, and it is
12675 meaningless to convert between such pointer types. GNAT will issue a
12676 warning if the alignment of the target designated type is more strict
12677 than the alignment of the source designated type (since the result may
12678 be unaligned in this case).
12680 A pointer other than a pointer to an unconstrained array type may be
12681 converted to and from System.Address. Such usage is common in Ada 83
12682 programs, but note that Ada.Address_To_Access_Conversions is the
12683 preferred method of performing such conversions in Ada 95 and Ada 2005.
12685 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12686 used in conjunction with pointers to unconstrained objects, since
12687 the bounds information cannot be handled correctly in this case.
12689 @item Ada.Unchecked_Deallocation (13.11.2)
12690 This generic package allows explicit freeing of storage previously
12691 allocated by use of an allocator.
12693 @item Ada.Wide_Text_IO (A.11)
12694 This package is similar to @code{Ada.Text_IO}, except that the external
12695 file supports wide character representations, and the internal types are
12696 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12697 and @code{String}. It contains generic subpackages listed next.
12699 @item Ada.Wide_Text_IO.Decimal_IO
12700 Provides input-output facilities for decimal fixed-point types
12702 @item Ada.Wide_Text_IO.Enumeration_IO
12703 Provides input-output facilities for enumeration types.
12705 @item Ada.Wide_Text_IO.Fixed_IO
12706 Provides input-output facilities for ordinary fixed-point types.
12708 @item Ada.Wide_Text_IO.Float_IO
12709 Provides input-output facilities for float types. The following
12710 predefined instantiations of this generic package are available:
12714 @code{Short_Float_Wide_Text_IO}
12716 @code{Float_Wide_Text_IO}
12718 @code{Long_Float_Wide_Text_IO}
12721 @item Ada.Wide_Text_IO.Integer_IO
12722 Provides input-output facilities for integer types. The following
12723 predefined instantiations of this generic package are available:
12726 @item Short_Short_Integer
12727 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12728 @item Short_Integer
12729 @code{Ada.Short_Integer_Wide_Text_IO}
12731 @code{Ada.Integer_Wide_Text_IO}
12733 @code{Ada.Long_Integer_Wide_Text_IO}
12734 @item Long_Long_Integer
12735 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12738 @item Ada.Wide_Text_IO.Modular_IO
12739 Provides input-output facilities for modular (unsigned) types
12741 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12742 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12743 external file supports wide character representations.
12745 @item Ada.Wide_Text_IO.Editing (F.3.4)
12746 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12747 types are @code{Wide_Character} and @code{Wide_String} instead of
12748 @code{Character} and @code{String}.
12750 @item Ada.Wide_Text_IO.Streams (A.12.3)
12751 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12752 types are @code{Wide_Character} and @code{Wide_String} instead of
12753 @code{Character} and @code{String}.
12755 @item Ada.Wide_Wide_Text_IO (A.11)
12756 This package is similar to @code{Ada.Text_IO}, except that the external
12757 file supports wide character representations, and the internal types are
12758 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12759 and @code{String}. It contains generic subpackages listed next.
12761 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12762 Provides input-output facilities for decimal fixed-point types
12764 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12765 Provides input-output facilities for enumeration types.
12767 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12768 Provides input-output facilities for ordinary fixed-point types.
12770 @item Ada.Wide_Wide_Text_IO.Float_IO
12771 Provides input-output facilities for float types. The following
12772 predefined instantiations of this generic package are available:
12776 @code{Short_Float_Wide_Wide_Text_IO}
12778 @code{Float_Wide_Wide_Text_IO}
12780 @code{Long_Float_Wide_Wide_Text_IO}
12783 @item Ada.Wide_Wide_Text_IO.Integer_IO
12784 Provides input-output facilities for integer types. The following
12785 predefined instantiations of this generic package are available:
12788 @item Short_Short_Integer
12789 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12790 @item Short_Integer
12791 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12793 @code{Ada.Integer_Wide_Wide_Text_IO}
12795 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12796 @item Long_Long_Integer
12797 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12800 @item Ada.Wide_Wide_Text_IO.Modular_IO
12801 Provides input-output facilities for modular (unsigned) types
12803 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12804 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12805 external file supports wide character representations.
12807 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12808 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12809 types are @code{Wide_Character} and @code{Wide_String} instead of
12810 @code{Character} and @code{String}.
12812 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12813 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12814 types are @code{Wide_Character} and @code{Wide_String} instead of
12815 @code{Character} and @code{String}.
12818 @node The Implementation of Standard I/O
12819 @chapter The Implementation of Standard I/O
12822 GNAT implements all the required input-output facilities described in
12823 A.6 through A.14. These sections of the Ada Reference Manual describe the
12824 required behavior of these packages from the Ada point of view, and if
12825 you are writing a portable Ada program that does not need to know the
12826 exact manner in which Ada maps to the outside world when it comes to
12827 reading or writing external files, then you do not need to read this
12828 chapter. As long as your files are all regular files (not pipes or
12829 devices), and as long as you write and read the files only from Ada, the
12830 description in the Ada Reference Manual is sufficient.
12832 However, if you want to do input-output to pipes or other devices, such
12833 as the keyboard or screen, or if the files you are dealing with are
12834 either generated by some other language, or to be read by some other
12835 language, then you need to know more about the details of how the GNAT
12836 implementation of these input-output facilities behaves.
12838 In this chapter we give a detailed description of exactly how GNAT
12839 interfaces to the file system. As always, the sources of the system are
12840 available to you for answering questions at an even more detailed level,
12841 but for most purposes the information in this chapter will suffice.
12843 Another reason that you may need to know more about how input-output is
12844 implemented arises when you have a program written in mixed languages
12845 where, for example, files are shared between the C and Ada sections of
12846 the same program. GNAT provides some additional facilities, in the form
12847 of additional child library packages, that facilitate this sharing, and
12848 these additional facilities are also described in this chapter.
12851 * Standard I/O Packages::
12857 * Wide_Wide_Text_IO::
12859 * Text Translation::
12861 * Filenames encoding::
12863 * Operations on C Streams::
12864 * Interfacing to C Streams::
12867 @node Standard I/O Packages
12868 @section Standard I/O Packages
12871 The Standard I/O packages described in Annex A for
12877 Ada.Text_IO.Complex_IO
12879 Ada.Text_IO.Text_Streams
12883 Ada.Wide_Text_IO.Complex_IO
12885 Ada.Wide_Text_IO.Text_Streams
12887 Ada.Wide_Wide_Text_IO
12889 Ada.Wide_Wide_Text_IO.Complex_IO
12891 Ada.Wide_Wide_Text_IO.Text_Streams
12901 are implemented using the C
12902 library streams facility; where
12906 All files are opened using @code{fopen}.
12908 All input/output operations use @code{fread}/@code{fwrite}.
12912 There is no internal buffering of any kind at the Ada library level. The only
12913 buffering is that provided at the system level in the implementation of the
12914 library routines that support streams. This facilitates shared use of these
12915 streams by mixed language programs. Note though that system level buffering is
12916 explicitly enabled at elaboration of the standard I/O packages and that can
12917 have an impact on mixed language programs, in particular those using I/O before
12918 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12919 the Ada elaboration routine before performing any I/O or when impractical,
12920 flush the common I/O streams and in particular Standard_Output before
12921 elaborating the Ada code.
12924 @section FORM Strings
12927 The format of a FORM string in GNAT is:
12930 "keyword=value,keyword=value,@dots{},keyword=value"
12934 where letters may be in upper or lower case, and there are no spaces
12935 between values. The order of the entries is not important. Currently
12936 the following keywords defined.
12939 TEXT_TRANSLATION=[YES|NO]
12941 WCEM=[n|h|u|s|e|8|b]
12942 ENCODING=[UTF8|8BITS]
12946 The use of these parameters is described later in this section.
12952 Direct_IO can only be instantiated for definite types. This is a
12953 restriction of the Ada language, which means that the records are fixed
12954 length (the length being determined by @code{@var{type}'Size}, rounded
12955 up to the next storage unit boundary if necessary).
12957 The records of a Direct_IO file are simply written to the file in index
12958 sequence, with the first record starting at offset zero, and subsequent
12959 records following. There is no control information of any kind. For
12960 example, if 32-bit integers are being written, each record takes
12961 4-bytes, so the record at index @var{K} starts at offset
12962 (@var{K}@minus{}1)*4.
12964 There is no limit on the size of Direct_IO files, they are expanded as
12965 necessary to accommodate whatever records are written to the file.
12967 @node Sequential_IO
12968 @section Sequential_IO
12971 Sequential_IO may be instantiated with either a definite (constrained)
12972 or indefinite (unconstrained) type.
12974 For the definite type case, the elements written to the file are simply
12975 the memory images of the data values with no control information of any
12976 kind. The resulting file should be read using the same type, no validity
12977 checking is performed on input.
12979 For the indefinite type case, the elements written consist of two
12980 parts. First is the size of the data item, written as the memory image
12981 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12982 the data value. The resulting file can only be read using the same
12983 (unconstrained) type. Normal assignment checks are performed on these
12984 read operations, and if these checks fail, @code{Data_Error} is
12985 raised. In particular, in the array case, the lengths must match, and in
12986 the variant record case, if the variable for a particular read operation
12987 is constrained, the discriminants must match.
12989 Note that it is not possible to use Sequential_IO to write variable
12990 length array items, and then read the data back into different length
12991 arrays. For example, the following will raise @code{Data_Error}:
12993 @smallexample @c ada
12994 package IO is new Sequential_IO (String);
12999 IO.Write (F, "hello!")
13000 IO.Reset (F, Mode=>In_File);
13007 On some Ada implementations, this will print @code{hell}, but the program is
13008 clearly incorrect, since there is only one element in the file, and that
13009 element is the string @code{hello!}.
13011 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
13012 using Stream_IO, and this is the preferred mechanism. In particular, the
13013 above program fragment rewritten to use Stream_IO will work correctly.
13019 Text_IO files consist of a stream of characters containing the following
13020 special control characters:
13023 LF (line feed, 16#0A#) Line Mark
13024 FF (form feed, 16#0C#) Page Mark
13028 A canonical Text_IO file is defined as one in which the following
13029 conditions are met:
13033 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
13037 The character @code{FF} is used only as a page mark, i.e.@: to mark the
13038 end of a page and consequently can appear only immediately following a
13039 @code{LF} (line mark) character.
13042 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
13043 (line mark, page mark). In the former case, the page mark is implicitly
13044 assumed to be present.
13048 A file written using Text_IO will be in canonical form provided that no
13049 explicit @code{LF} or @code{FF} characters are written using @code{Put}
13050 or @code{Put_Line}. There will be no @code{FF} character at the end of
13051 the file unless an explicit @code{New_Page} operation was performed
13052 before closing the file.
13054 A canonical Text_IO file that is a regular file (i.e., not a device or a
13055 pipe) can be read using any of the routines in Text_IO@. The
13056 semantics in this case will be exactly as defined in the Ada Reference
13057 Manual, and all the routines in Text_IO are fully implemented.
13059 A text file that does not meet the requirements for a canonical Text_IO
13060 file has one of the following:
13064 The file contains @code{FF} characters not immediately following a
13065 @code{LF} character.
13068 The file contains @code{LF} or @code{FF} characters written by
13069 @code{Put} or @code{Put_Line}, which are not logically considered to be
13070 line marks or page marks.
13073 The file ends in a character other than @code{LF} or @code{FF},
13074 i.e.@: there is no explicit line mark or page mark at the end of the file.
13078 Text_IO can be used to read such non-standard text files but subprograms
13079 to do with line or page numbers do not have defined meanings. In
13080 particular, a @code{FF} character that does not follow a @code{LF}
13081 character may or may not be treated as a page mark from the point of
13082 view of page and line numbering. Every @code{LF} character is considered
13083 to end a line, and there is an implied @code{LF} character at the end of
13087 * Text_IO Stream Pointer Positioning::
13088 * Text_IO Reading and Writing Non-Regular Files::
13090 * Treating Text_IO Files as Streams::
13091 * Text_IO Extensions::
13092 * Text_IO Facilities for Unbounded Strings::
13095 @node Text_IO Stream Pointer Positioning
13096 @subsection Stream Pointer Positioning
13099 @code{Ada.Text_IO} has a definition of current position for a file that
13100 is being read. No internal buffering occurs in Text_IO, and usually the
13101 physical position in the stream used to implement the file corresponds
13102 to this logical position defined by Text_IO@. There are two exceptions:
13106 After a call to @code{End_Of_Page} that returns @code{True}, the stream
13107 is positioned past the @code{LF} (line mark) that precedes the page
13108 mark. Text_IO maintains an internal flag so that subsequent read
13109 operations properly handle the logical position which is unchanged by
13110 the @code{End_Of_Page} call.
13113 After a call to @code{End_Of_File} that returns @code{True}, if the
13114 Text_IO file was positioned before the line mark at the end of file
13115 before the call, then the logical position is unchanged, but the stream
13116 is physically positioned right at the end of file (past the line mark,
13117 and past a possible page mark following the line mark. Again Text_IO
13118 maintains internal flags so that subsequent read operations properly
13119 handle the logical position.
13123 These discrepancies have no effect on the observable behavior of
13124 Text_IO, but if a single Ada stream is shared between a C program and
13125 Ada program, or shared (using @samp{shared=yes} in the form string)
13126 between two Ada files, then the difference may be observable in some
13129 @node Text_IO Reading and Writing Non-Regular Files
13130 @subsection Reading and Writing Non-Regular Files
13133 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
13134 can be used for reading and writing. Writing is not affected and the
13135 sequence of characters output is identical to the normal file case, but
13136 for reading, the behavior of Text_IO is modified to avoid undesirable
13137 look-ahead as follows:
13139 An input file that is not a regular file is considered to have no page
13140 marks. Any @code{Ascii.FF} characters (the character normally used for a
13141 page mark) appearing in the file are considered to be data
13142 characters. In particular:
13146 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
13147 following a line mark. If a page mark appears, it will be treated as a
13151 This avoids the need to wait for an extra character to be typed or
13152 entered from the pipe to complete one of these operations.
13155 @code{End_Of_Page} always returns @code{False}
13158 @code{End_Of_File} will return @code{False} if there is a page mark at
13159 the end of the file.
13163 Output to non-regular files is the same as for regular files. Page marks
13164 may be written to non-regular files using @code{New_Page}, but as noted
13165 above they will not be treated as page marks on input if the output is
13166 piped to another Ada program.
13168 Another important discrepancy when reading non-regular files is that the end
13169 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
13170 pressing the @key{EOT} key,
13172 is signaled once (i.e.@: the test @code{End_Of_File}
13173 will yield @code{True}, or a read will
13174 raise @code{End_Error}), but then reading can resume
13175 to read data past that end of
13176 file indication, until another end of file indication is entered.
13178 @node Get_Immediate
13179 @subsection Get_Immediate
13180 @cindex Get_Immediate
13183 Get_Immediate returns the next character (including control characters)
13184 from the input file. In particular, Get_Immediate will return LF or FF
13185 characters used as line marks or page marks. Such operations leave the
13186 file positioned past the control character, and it is thus not treated
13187 as having its normal function. This means that page, line and column
13188 counts after this kind of Get_Immediate call are set as though the mark
13189 did not occur. In the case where a Get_Immediate leaves the file
13190 positioned between the line mark and page mark (which is not normally
13191 possible), it is undefined whether the FF character will be treated as a
13194 @node Treating Text_IO Files as Streams
13195 @subsection Treating Text_IO Files as Streams
13196 @cindex Stream files
13199 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
13200 as a stream. Data written to a Text_IO file in this stream mode is
13201 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
13202 16#0C# (@code{FF}), the resulting file may have non-standard
13203 format. Similarly if read operations are used to read from a Text_IO
13204 file treated as a stream, then @code{LF} and @code{FF} characters may be
13205 skipped and the effect is similar to that described above for
13206 @code{Get_Immediate}.
13208 @node Text_IO Extensions
13209 @subsection Text_IO Extensions
13210 @cindex Text_IO extensions
13213 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
13214 to the standard @code{Text_IO} package:
13217 @item function File_Exists (Name : String) return Boolean;
13218 Determines if a file of the given name exists.
13220 @item function Get_Line return String;
13221 Reads a string from the standard input file. The value returned is exactly
13222 the length of the line that was read.
13224 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
13225 Similar, except that the parameter File specifies the file from which
13226 the string is to be read.
13230 @node Text_IO Facilities for Unbounded Strings
13231 @subsection Text_IO Facilities for Unbounded Strings
13232 @cindex Text_IO for unbounded strings
13233 @cindex Unbounded_String, Text_IO operations
13236 The package @code{Ada.Strings.Unbounded.Text_IO}
13237 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
13238 subprograms useful for Text_IO operations on unbounded strings:
13242 @item function Get_Line (File : File_Type) return Unbounded_String;
13243 Reads a line from the specified file
13244 and returns the result as an unbounded string.
13246 @item procedure Put (File : File_Type; U : Unbounded_String);
13247 Writes the value of the given unbounded string to the specified file
13248 Similar to the effect of
13249 @code{Put (To_String (U))} except that an extra copy is avoided.
13251 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
13252 Writes the value of the given unbounded string to the specified file,
13253 followed by a @code{New_Line}.
13254 Similar to the effect of @code{Put_Line (To_String (U))} except
13255 that an extra copy is avoided.
13259 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
13260 and is optional. If the parameter is omitted, then the standard input or
13261 output file is referenced as appropriate.
13263 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
13264 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
13265 @code{Wide_Text_IO} functionality for unbounded wide strings.
13267 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
13268 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
13269 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
13272 @section Wide_Text_IO
13275 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
13276 both input and output files may contain special sequences that represent
13277 wide character values. The encoding scheme for a given file may be
13278 specified using a FORM parameter:
13285 as part of the FORM string (WCEM = wide character encoding method),
13286 where @var{x} is one of the following characters
13292 Upper half encoding
13304 The encoding methods match those that
13305 can be used in a source
13306 program, but there is no requirement that the encoding method used for
13307 the source program be the same as the encoding method used for files,
13308 and different files may use different encoding methods.
13310 The default encoding method for the standard files, and for opened files
13311 for which no WCEM parameter is given in the FORM string matches the
13312 wide character encoding specified for the main program (the default
13313 being brackets encoding if no coding method was specified with -gnatW).
13317 In this encoding, a wide character is represented by a five character
13325 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
13326 characters (using upper case letters) of the wide character code. For
13327 example, ESC A345 is used to represent the wide character with code
13328 16#A345#. This scheme is compatible with use of the full
13329 @code{Wide_Character} set.
13331 @item Upper Half Coding
13332 The wide character with encoding 16#abcd#, where the upper bit is on
13333 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
13334 16#cd#. The second byte may never be a format control character, but is
13335 not required to be in the upper half. This method can be also used for
13336 shift-JIS or EUC where the internal coding matches the external coding.
13338 @item Shift JIS Coding
13339 A wide character is represented by a two character sequence 16#ab# and
13340 16#cd#, with the restrictions described for upper half encoding as
13341 described above. The internal character code is the corresponding JIS
13342 character according to the standard algorithm for Shift-JIS
13343 conversion. Only characters defined in the JIS code set table can be
13344 used with this encoding method.
13347 A wide character is represented by a two character sequence 16#ab# and
13348 16#cd#, with both characters being in the upper half. The internal
13349 character code is the corresponding JIS character according to the EUC
13350 encoding algorithm. Only characters defined in the JIS code set table
13351 can be used with this encoding method.
13354 A wide character is represented using
13355 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13356 10646-1/Am.2. Depending on the character value, the representation
13357 is a one, two, or three byte sequence:
13360 16#0000#-16#007f#: 2#0xxxxxxx#
13361 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
13362 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13366 where the @var{xxx} bits correspond to the left-padded bits of the
13367 16-bit character value. Note that all lower half ASCII characters
13368 are represented as ASCII bytes and all upper half characters and
13369 other wide characters are represented as sequences of upper-half
13370 (The full UTF-8 scheme allows for encoding 31-bit characters as
13371 6-byte sequences, but in this implementation, all UTF-8 sequences
13372 of four or more bytes length will raise a Constraint_Error, as
13373 will all invalid UTF-8 sequences.)
13375 @item Brackets Coding
13376 In this encoding, a wide character is represented by the following eight
13377 character sequence:
13384 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
13385 characters (using uppercase letters) of the wide character code. For
13386 example, @code{["A345"]} is used to represent the wide character with code
13388 This scheme is compatible with use of the full Wide_Character set.
13389 On input, brackets coding can also be used for upper half characters,
13390 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
13391 is only used for wide characters with a code greater than @code{16#FF#}.
13393 Note that brackets coding is not normally used in the context of
13394 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
13395 a portable way of encoding source files. In the context of Wide_Text_IO
13396 or Wide_Wide_Text_IO, it can only be used if the file does not contain
13397 any instance of the left bracket character other than to encode wide
13398 character values using the brackets encoding method. In practice it is
13399 expected that some standard wide character encoding method such
13400 as UTF-8 will be used for text input output.
13402 If brackets notation is used, then any occurrence of a left bracket
13403 in the input file which is not the start of a valid wide character
13404 sequence will cause Constraint_Error to be raised. It is possible to
13405 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
13406 input will interpret this as a left bracket.
13408 However, when a left bracket is output, it will be output as a left bracket
13409 and not as ["5B"]. We make this decision because for normal use of
13410 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
13411 brackets. For example, if we write:
13414 Put_Line ("Start of output [first run]");
13418 we really do not want to have the left bracket in this message clobbered so
13419 that the output reads:
13422 Start of output ["5B"]first run]
13426 In practice brackets encoding is reasonably useful for normal Put_Line use
13427 since we won't get confused between left brackets and wide character
13428 sequences in the output. But for input, or when files are written out
13429 and read back in, it really makes better sense to use one of the standard
13430 encoding methods such as UTF-8.
13435 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
13436 not all wide character
13437 values can be represented. An attempt to output a character that cannot
13438 be represented using the encoding scheme for the file causes
13439 Constraint_Error to be raised. An invalid wide character sequence on
13440 input also causes Constraint_Error to be raised.
13443 * Wide_Text_IO Stream Pointer Positioning::
13444 * Wide_Text_IO Reading and Writing Non-Regular Files::
13447 @node Wide_Text_IO Stream Pointer Positioning
13448 @subsection Stream Pointer Positioning
13451 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13452 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13455 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
13456 normal lower ASCII set (i.e.@: a character in the range:
13458 @smallexample @c ada
13459 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
13463 then although the logical position of the file pointer is unchanged by
13464 the @code{Look_Ahead} call, the stream is physically positioned past the
13465 wide character sequence. Again this is to avoid the need for buffering
13466 or backup, and all @code{Wide_Text_IO} routines check the internal
13467 indication that this situation has occurred so that this is not visible
13468 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
13469 can be observed if the wide text file shares a stream with another file.
13471 @node Wide_Text_IO Reading and Writing Non-Regular Files
13472 @subsection Reading and Writing Non-Regular Files
13475 As in the case of Text_IO, when a non-regular file is read, it is
13476 assumed that the file contains no page marks (any form characters are
13477 treated as data characters), and @code{End_Of_Page} always returns
13478 @code{False}. Similarly, the end of file indication is not sticky, so
13479 it is possible to read beyond an end of file.
13481 @node Wide_Wide_Text_IO
13482 @section Wide_Wide_Text_IO
13485 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
13486 both input and output files may contain special sequences that represent
13487 wide wide character values. The encoding scheme for a given file may be
13488 specified using a FORM parameter:
13495 as part of the FORM string (WCEM = wide character encoding method),
13496 where @var{x} is one of the following characters
13502 Upper half encoding
13514 The encoding methods match those that
13515 can be used in a source
13516 program, but there is no requirement that the encoding method used for
13517 the source program be the same as the encoding method used for files,
13518 and different files may use different encoding methods.
13520 The default encoding method for the standard files, and for opened files
13521 for which no WCEM parameter is given in the FORM string matches the
13522 wide character encoding specified for the main program (the default
13523 being brackets encoding if no coding method was specified with -gnatW).
13528 A wide character is represented using
13529 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13530 10646-1/Am.2. Depending on the character value, the representation
13531 is a one, two, three, or four byte sequence:
13534 16#000000#-16#00007f#: 2#0xxxxxxx#
13535 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
13536 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13537 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
13541 where the @var{xxx} bits correspond to the left-padded bits of the
13542 21-bit character value. Note that all lower half ASCII characters
13543 are represented as ASCII bytes and all upper half characters and
13544 other wide characters are represented as sequences of upper-half
13547 @item Brackets Coding
13548 In this encoding, a wide wide character is represented by the following eight
13549 character sequence if is in wide character range
13555 and by the following ten character sequence if not
13558 [ " a b c d e f " ]
13562 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
13563 are the four or six hexadecimal
13564 characters (using uppercase letters) of the wide wide character code. For
13565 example, @code{["01A345"]} is used to represent the wide wide character
13566 with code @code{16#01A345#}.
13568 This scheme is compatible with use of the full Wide_Wide_Character set.
13569 On input, brackets coding can also be used for upper half characters,
13570 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
13571 is only used for wide characters with a code greater than @code{16#FF#}.
13576 If is also possible to use the other Wide_Character encoding methods,
13577 such as Shift-JIS, but the other schemes cannot support the full range
13578 of wide wide characters.
13579 An attempt to output a character that cannot
13580 be represented using the encoding scheme for the file causes
13581 Constraint_Error to be raised. An invalid wide character sequence on
13582 input also causes Constraint_Error to be raised.
13585 * Wide_Wide_Text_IO Stream Pointer Positioning::
13586 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13589 @node Wide_Wide_Text_IO Stream Pointer Positioning
13590 @subsection Stream Pointer Positioning
13593 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13594 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13597 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13598 normal lower ASCII set (i.e.@: a character in the range:
13600 @smallexample @c ada
13601 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13605 then although the logical position of the file pointer is unchanged by
13606 the @code{Look_Ahead} call, the stream is physically positioned past the
13607 wide character sequence. Again this is to avoid the need for buffering
13608 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13609 indication that this situation has occurred so that this is not visible
13610 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
13611 can be observed if the wide text file shares a stream with another file.
13613 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13614 @subsection Reading and Writing Non-Regular Files
13617 As in the case of Text_IO, when a non-regular file is read, it is
13618 assumed that the file contains no page marks (any form characters are
13619 treated as data characters), and @code{End_Of_Page} always returns
13620 @code{False}. Similarly, the end of file indication is not sticky, so
13621 it is possible to read beyond an end of file.
13627 A stream file is a sequence of bytes, where individual elements are
13628 written to the file as described in the Ada Reference Manual. The type
13629 @code{Stream_Element} is simply a byte. There are two ways to read or
13630 write a stream file.
13634 The operations @code{Read} and @code{Write} directly read or write a
13635 sequence of stream elements with no control information.
13638 The stream attributes applied to a stream file transfer data in the
13639 manner described for stream attributes.
13642 @node Text Translation
13643 @section Text Translation
13646 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13647 passed to Text_IO.Create and Text_IO.Open:
13648 @samp{Text_Translation=@var{Yes}} is the default, which means to
13649 translate LF to/from CR/LF on Windows systems.
13650 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13651 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13652 may be used to create Unix-style files on
13653 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13657 @section Shared Files
13660 Section A.14 of the Ada Reference Manual allows implementations to
13661 provide a wide variety of behavior if an attempt is made to access the
13662 same external file with two or more internal files.
13664 To provide a full range of functionality, while at the same time
13665 minimizing the problems of portability caused by this implementation
13666 dependence, GNAT handles file sharing as follows:
13670 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13671 to open two or more files with the same full name is considered an error
13672 and is not supported. The exception @code{Use_Error} will be
13673 raised. Note that a file that is not explicitly closed by the program
13674 remains open until the program terminates.
13677 If the form parameter @samp{shared=no} appears in the form string, the
13678 file can be opened or created with its own separate stream identifier,
13679 regardless of whether other files sharing the same external file are
13680 opened. The exact effect depends on how the C stream routines handle
13681 multiple accesses to the same external files using separate streams.
13684 If the form parameter @samp{shared=yes} appears in the form string for
13685 each of two or more files opened using the same full name, the same
13686 stream is shared between these files, and the semantics are as described
13687 in Ada Reference Manual, Section A.14.
13691 When a program that opens multiple files with the same name is ported
13692 from another Ada compiler to GNAT, the effect will be that
13693 @code{Use_Error} is raised.
13695 The documentation of the original compiler and the documentation of the
13696 program should then be examined to determine if file sharing was
13697 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13698 and @code{Create} calls as required.
13700 When a program is ported from GNAT to some other Ada compiler, no
13701 special attention is required unless the @samp{shared=@var{xxx}} form
13702 parameter is used in the program. In this case, you must examine the
13703 documentation of the new compiler to see if it supports the required
13704 file sharing semantics, and form strings modified appropriately. Of
13705 course it may be the case that the program cannot be ported if the
13706 target compiler does not support the required functionality. The best
13707 approach in writing portable code is to avoid file sharing (and hence
13708 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13711 One common use of file sharing in Ada 83 is the use of instantiations of
13712 Sequential_IO on the same file with different types, to achieve
13713 heterogeneous input-output. Although this approach will work in GNAT if
13714 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13715 for this purpose (using the stream attributes)
13717 @node Filenames encoding
13718 @section Filenames encoding
13721 An encoding form parameter can be used to specify the filename
13722 encoding @samp{encoding=@var{xxx}}.
13726 If the form parameter @samp{encoding=utf8} appears in the form string, the
13727 filename must be encoded in UTF-8.
13730 If the form parameter @samp{encoding=8bits} appears in the form
13731 string, the filename must be a standard 8bits string.
13734 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13735 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13736 variable. And if not set @samp{utf8} is assumed.
13740 The current system Windows ANSI code page.
13745 This encoding form parameter is only supported on the Windows
13746 platform. On the other Operating Systems the run-time is supporting
13750 @section Open Modes
13753 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13754 using the mode shown in the following table:
13757 @center @code{Open} and @code{Create} Call Modes
13759 @b{OPEN } @b{CREATE}
13760 Append_File "r+" "w+"
13762 Out_File (Direct_IO) "r+" "w"
13763 Out_File (all other cases) "w" "w"
13764 Inout_File "r+" "w+"
13768 If text file translation is required, then either @samp{b} or @samp{t}
13769 is added to the mode, depending on the setting of Text. Text file
13770 translation refers to the mapping of CR/LF sequences in an external file
13771 to LF characters internally. This mapping only occurs in DOS and
13772 DOS-like systems, and is not relevant to other systems.
13774 A special case occurs with Stream_IO@. As shown in the above table, the
13775 file is initially opened in @samp{r} or @samp{w} mode for the
13776 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
13777 subsequently requires switching from reading to writing or vice-versa,
13778 then the file is reopened in @samp{r+} mode to permit the required operation.
13780 @node Operations on C Streams
13781 @section Operations on C Streams
13782 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13783 access to the C library functions for operations on C streams:
13785 @smallexample @c adanocomment
13786 package Interfaces.C_Streams is
13787 -- Note: the reason we do not use the types that are in
13788 -- Interfaces.C is that we want to avoid dragging in the
13789 -- code in this unit if possible.
13790 subtype chars is System.Address;
13791 -- Pointer to null-terminated array of characters
13792 subtype FILEs is System.Address;
13793 -- Corresponds to the C type FILE*
13794 subtype voids is System.Address;
13795 -- Corresponds to the C type void*
13796 subtype int is Integer;
13797 subtype long is Long_Integer;
13798 -- Note: the above types are subtypes deliberately, and it
13799 -- is part of this spec that the above correspondences are
13800 -- guaranteed. This means that it is legitimate to, for
13801 -- example, use Integer instead of int. We provide these
13802 -- synonyms for clarity, but in some cases it may be
13803 -- convenient to use the underlying types (for example to
13804 -- avoid an unnecessary dependency of a spec on the spec
13806 type size_t is mod 2 ** Standard'Address_Size;
13807 NULL_Stream : constant FILEs;
13808 -- Value returned (NULL in C) to indicate an
13809 -- fdopen/fopen/tmpfile error
13810 ----------------------------------
13811 -- Constants Defined in stdio.h --
13812 ----------------------------------
13813 EOF : constant int;
13814 -- Used by a number of routines to indicate error or
13816 IOFBF : constant int;
13817 IOLBF : constant int;
13818 IONBF : constant int;
13819 -- Used to indicate buffering mode for setvbuf call
13820 SEEK_CUR : constant int;
13821 SEEK_END : constant int;
13822 SEEK_SET : constant int;
13823 -- Used to indicate origin for fseek call
13824 function stdin return FILEs;
13825 function stdout return FILEs;
13826 function stderr return FILEs;
13827 -- Streams associated with standard files
13828 --------------------------
13829 -- Standard C functions --
13830 --------------------------
13831 -- The functions selected below are ones that are
13832 -- available in UNIX (but not necessarily in ANSI C).
13833 -- These are very thin interfaces
13834 -- which copy exactly the C headers. For more
13835 -- documentation on these functions, see the Microsoft C
13836 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13837 -- ISBN 1-55615-225-6), which includes useful information
13838 -- on system compatibility.
13839 procedure clearerr (stream : FILEs);
13840 function fclose (stream : FILEs) return int;
13841 function fdopen (handle : int; mode : chars) return FILEs;
13842 function feof (stream : FILEs) return int;
13843 function ferror (stream : FILEs) return int;
13844 function fflush (stream : FILEs) return int;
13845 function fgetc (stream : FILEs) return int;
13846 function fgets (strng : chars; n : int; stream : FILEs)
13848 function fileno (stream : FILEs) return int;
13849 function fopen (filename : chars; Mode : chars)
13851 -- Note: to maintain target independence, use
13852 -- text_translation_required, a boolean variable defined in
13853 -- a-sysdep.c to deal with the target dependent text
13854 -- translation requirement. If this variable is set,
13855 -- then b/t should be appended to the standard mode
13856 -- argument to set the text translation mode off or on
13858 function fputc (C : int; stream : FILEs) return int;
13859 function fputs (Strng : chars; Stream : FILEs) return int;
13876 function ftell (stream : FILEs) return long;
13883 function isatty (handle : int) return int;
13884 procedure mktemp (template : chars);
13885 -- The return value (which is just a pointer to template)
13887 procedure rewind (stream : FILEs);
13888 function rmtmp return int;
13896 function tmpfile return FILEs;
13897 function ungetc (c : int; stream : FILEs) return int;
13898 function unlink (filename : chars) return int;
13899 ---------------------
13900 -- Extra functions --
13901 ---------------------
13902 -- These functions supply slightly thicker bindings than
13903 -- those above. They are derived from functions in the
13904 -- C Run-Time Library, but may do a bit more work than
13905 -- just directly calling one of the Library functions.
13906 function is_regular_file (handle : int) return int;
13907 -- Tests if given handle is for a regular file (result 1)
13908 -- or for a non-regular file (pipe or device, result 0).
13909 ---------------------------------
13910 -- Control of Text/Binary Mode --
13911 ---------------------------------
13912 -- If text_translation_required is true, then the following
13913 -- functions may be used to dynamically switch a file from
13914 -- binary to text mode or vice versa. These functions have
13915 -- no effect if text_translation_required is false (i.e.@: in
13916 -- normal UNIX mode). Use fileno to get a stream handle.
13917 procedure set_binary_mode (handle : int);
13918 procedure set_text_mode (handle : int);
13919 ----------------------------
13920 -- Full Path Name support --
13921 ----------------------------
13922 procedure full_name (nam : chars; buffer : chars);
13923 -- Given a NUL terminated string representing a file
13924 -- name, returns in buffer a NUL terminated string
13925 -- representing the full path name for the file name.
13926 -- On systems where it is relevant the drive is also
13927 -- part of the full path name. It is the responsibility
13928 -- of the caller to pass an actual parameter for buffer
13929 -- that is big enough for any full path name. Use
13930 -- max_path_len given below as the size of buffer.
13931 max_path_len : integer;
13932 -- Maximum length of an allowable full path name on the
13933 -- system, including a terminating NUL character.
13934 end Interfaces.C_Streams;
13937 @node Interfacing to C Streams
13938 @section Interfacing to C Streams
13941 The packages in this section permit interfacing Ada files to C Stream
13944 @smallexample @c ada
13945 with Interfaces.C_Streams;
13946 package Ada.Sequential_IO.C_Streams is
13947 function C_Stream (F : File_Type)
13948 return Interfaces.C_Streams.FILEs;
13950 (File : in out File_Type;
13951 Mode : in File_Mode;
13952 C_Stream : in Interfaces.C_Streams.FILEs;
13953 Form : in String := "");
13954 end Ada.Sequential_IO.C_Streams;
13956 with Interfaces.C_Streams;
13957 package Ada.Direct_IO.C_Streams is
13958 function C_Stream (F : File_Type)
13959 return Interfaces.C_Streams.FILEs;
13961 (File : in out File_Type;
13962 Mode : in File_Mode;
13963 C_Stream : in Interfaces.C_Streams.FILEs;
13964 Form : in String := "");
13965 end Ada.Direct_IO.C_Streams;
13967 with Interfaces.C_Streams;
13968 package Ada.Text_IO.C_Streams is
13969 function C_Stream (F : File_Type)
13970 return Interfaces.C_Streams.FILEs;
13972 (File : in out File_Type;
13973 Mode : in File_Mode;
13974 C_Stream : in Interfaces.C_Streams.FILEs;
13975 Form : in String := "");
13976 end Ada.Text_IO.C_Streams;
13978 with Interfaces.C_Streams;
13979 package Ada.Wide_Text_IO.C_Streams is
13980 function C_Stream (F : File_Type)
13981 return Interfaces.C_Streams.FILEs;
13983 (File : in out File_Type;
13984 Mode : in File_Mode;
13985 C_Stream : in Interfaces.C_Streams.FILEs;
13986 Form : in String := "");
13987 end Ada.Wide_Text_IO.C_Streams;
13989 with Interfaces.C_Streams;
13990 package Ada.Wide_Wide_Text_IO.C_Streams is
13991 function C_Stream (F : File_Type)
13992 return Interfaces.C_Streams.FILEs;
13994 (File : in out File_Type;
13995 Mode : in File_Mode;
13996 C_Stream : in Interfaces.C_Streams.FILEs;
13997 Form : in String := "");
13998 end Ada.Wide_Wide_Text_IO.C_Streams;
14000 with Interfaces.C_Streams;
14001 package Ada.Stream_IO.C_Streams is
14002 function C_Stream (F : File_Type)
14003 return Interfaces.C_Streams.FILEs;
14005 (File : in out File_Type;
14006 Mode : in File_Mode;
14007 C_Stream : in Interfaces.C_Streams.FILEs;
14008 Form : in String := "");
14009 end Ada.Stream_IO.C_Streams;
14013 In each of these six packages, the @code{C_Stream} function obtains the
14014 @code{FILE} pointer from a currently opened Ada file. It is then
14015 possible to use the @code{Interfaces.C_Streams} package to operate on
14016 this stream, or the stream can be passed to a C program which can
14017 operate on it directly. Of course the program is responsible for
14018 ensuring that only appropriate sequences of operations are executed.
14020 One particular use of relevance to an Ada program is that the
14021 @code{setvbuf} function can be used to control the buffering of the
14022 stream used by an Ada file. In the absence of such a call the standard
14023 default buffering is used.
14025 The @code{Open} procedures in these packages open a file giving an
14026 existing C Stream instead of a file name. Typically this stream is
14027 imported from a C program, allowing an Ada file to operate on an
14030 @node The GNAT Library
14031 @chapter The GNAT Library
14034 The GNAT library contains a number of general and special purpose packages.
14035 It represents functionality that the GNAT developers have found useful, and
14036 which is made available to GNAT users. The packages described here are fully
14037 supported, and upwards compatibility will be maintained in future releases,
14038 so you can use these facilities with the confidence that the same functionality
14039 will be available in future releases.
14041 The chapter here simply gives a brief summary of the facilities available.
14042 The full documentation is found in the spec file for the package. The full
14043 sources of these library packages, including both spec and body, are provided
14044 with all GNAT releases. For example, to find out the full specifications of
14045 the SPITBOL pattern matching capability, including a full tutorial and
14046 extensive examples, look in the @file{g-spipat.ads} file in the library.
14048 For each entry here, the package name (as it would appear in a @code{with}
14049 clause) is given, followed by the name of the corresponding spec file in
14050 parentheses. The packages are children in four hierarchies, @code{Ada},
14051 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
14052 GNAT-specific hierarchy.
14054 Note that an application program should only use packages in one of these
14055 four hierarchies if the package is defined in the Ada Reference Manual,
14056 or is listed in this section of the GNAT Programmers Reference Manual.
14057 All other units should be considered internal implementation units and
14058 should not be directly @code{with}'ed by application code. The use of
14059 a @code{with} statement that references one of these internal implementation
14060 units makes an application potentially dependent on changes in versions
14061 of GNAT, and will generate a warning message.
14064 * Ada.Characters.Latin_9 (a-chlat9.ads)::
14065 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
14066 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
14067 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
14068 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
14069 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
14070 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
14071 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
14072 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
14073 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
14074 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
14075 * Ada.Command_Line.Environment (a-colien.ads)::
14076 * Ada.Command_Line.Remove (a-colire.ads)::
14077 * Ada.Command_Line.Response_File (a-clrefi.ads)::
14078 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
14079 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
14080 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
14081 * Ada.Exceptions.Traceback (a-exctra.ads)::
14082 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
14083 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
14084 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
14085 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
14086 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
14087 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
14088 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
14089 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
14090 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
14091 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
14092 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
14093 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
14094 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
14095 * GNAT.Altivec (g-altive.ads)::
14096 * GNAT.Altivec.Conversions (g-altcon.ads)::
14097 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
14098 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
14099 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
14100 * GNAT.Array_Split (g-arrspl.ads)::
14101 * GNAT.AWK (g-awk.ads)::
14102 * GNAT.Bounded_Buffers (g-boubuf.ads)::
14103 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
14104 * GNAT.Bubble_Sort (g-bubsor.ads)::
14105 * GNAT.Bubble_Sort_A (g-busora.ads)::
14106 * GNAT.Bubble_Sort_G (g-busorg.ads)::
14107 * GNAT.Byte_Order_Mark (g-byorma.ads)::
14108 * GNAT.Byte_Swapping (g-bytswa.ads)::
14109 * GNAT.Calendar (g-calend.ads)::
14110 * GNAT.Calendar.Time_IO (g-catiio.ads)::
14111 * GNAT.Case_Util (g-casuti.ads)::
14112 * GNAT.CGI (g-cgi.ads)::
14113 * GNAT.CGI.Cookie (g-cgicoo.ads)::
14114 * GNAT.CGI.Debug (g-cgideb.ads)::
14115 * GNAT.Command_Line (g-comlin.ads)::
14116 * GNAT.Compiler_Version (g-comver.ads)::
14117 * GNAT.Ctrl_C (g-ctrl_c.ads)::
14118 * GNAT.CRC32 (g-crc32.ads)::
14119 * GNAT.Current_Exception (g-curexc.ads)::
14120 * GNAT.Debug_Pools (g-debpoo.ads)::
14121 * GNAT.Debug_Utilities (g-debuti.ads)::
14122 * GNAT.Decode_String (g-decstr.ads)::
14123 * GNAT.Decode_UTF8_String (g-deutst.ads)::
14124 * GNAT.Directory_Operations (g-dirope.ads)::
14125 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
14126 * GNAT.Dynamic_HTables (g-dynhta.ads)::
14127 * GNAT.Dynamic_Tables (g-dyntab.ads)::
14128 * GNAT.Encode_String (g-encstr.ads)::
14129 * GNAT.Encode_UTF8_String (g-enutst.ads)::
14130 * GNAT.Exception_Actions (g-excact.ads)::
14131 * GNAT.Exception_Traces (g-exctra.ads)::
14132 * GNAT.Exceptions (g-except.ads)::
14133 * GNAT.Expect (g-expect.ads)::
14134 * GNAT.Float_Control (g-flocon.ads)::
14135 * GNAT.Heap_Sort (g-heasor.ads)::
14136 * GNAT.Heap_Sort_A (g-hesora.ads)::
14137 * GNAT.Heap_Sort_G (g-hesorg.ads)::
14138 * GNAT.HTable (g-htable.ads)::
14139 * GNAT.IO (g-io.ads)::
14140 * GNAT.IO_Aux (g-io_aux.ads)::
14141 * GNAT.Lock_Files (g-locfil.ads)::
14142 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
14143 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
14144 * GNAT.MD5 (g-md5.ads)::
14145 * GNAT.Memory_Dump (g-memdum.ads)::
14146 * GNAT.Most_Recent_Exception (g-moreex.ads)::
14147 * GNAT.OS_Lib (g-os_lib.ads)::
14148 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
14149 * GNAT.Random_Numbers (g-rannum.ads)::
14150 * GNAT.Regexp (g-regexp.ads)::
14151 * GNAT.Registry (g-regist.ads)::
14152 * GNAT.Regpat (g-regpat.ads)::
14153 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
14154 * GNAT.Semaphores (g-semaph.ads)::
14155 * GNAT.Serial_Communications (g-sercom.ads)::
14156 * GNAT.SHA1 (g-sha1.ads)::
14157 * GNAT.SHA224 (g-sha224.ads)::
14158 * GNAT.SHA256 (g-sha256.ads)::
14159 * GNAT.SHA384 (g-sha384.ads)::
14160 * GNAT.SHA512 (g-sha512.ads)::
14161 * GNAT.Signals (g-signal.ads)::
14162 * GNAT.Sockets (g-socket.ads)::
14163 * GNAT.Source_Info (g-souinf.ads)::
14164 * GNAT.Spelling_Checker (g-speche.ads)::
14165 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
14166 * GNAT.Spitbol.Patterns (g-spipat.ads)::
14167 * GNAT.Spitbol (g-spitbo.ads)::
14168 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
14169 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
14170 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
14171 * GNAT.SSE (g-sse.ads)::
14172 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
14173 * GNAT.Strings (g-string.ads)::
14174 * GNAT.String_Split (g-strspl.ads)::
14175 * GNAT.Table (g-table.ads)::
14176 * GNAT.Task_Lock (g-tasloc.ads)::
14177 * GNAT.Threads (g-thread.ads)::
14178 * GNAT.Time_Stamp (g-timsta.ads)::
14179 * GNAT.Traceback (g-traceb.ads)::
14180 * GNAT.Traceback.Symbolic (g-trasym.ads)::
14181 * GNAT.UTF_32 (g-utf_32.ads)::
14182 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
14183 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
14184 * GNAT.Wide_String_Split (g-wistsp.ads)::
14185 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
14186 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
14187 * Interfaces.C.Extensions (i-cexten.ads)::
14188 * Interfaces.C.Streams (i-cstrea.ads)::
14189 * Interfaces.CPP (i-cpp.ads)::
14190 * Interfaces.Packed_Decimal (i-pacdec.ads)::
14191 * Interfaces.VxWorks (i-vxwork.ads)::
14192 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
14193 * System.Address_Image (s-addima.ads)::
14194 * System.Assertions (s-assert.ads)::
14195 * System.Memory (s-memory.ads)::
14196 * System.Partition_Interface (s-parint.ads)::
14197 * System.Pool_Global (s-pooglo.ads)::
14198 * System.Pool_Local (s-pooloc.ads)::
14199 * System.Restrictions (s-restri.ads)::
14200 * System.Rident (s-rident.ads)::
14201 * System.Strings.Stream_Ops (s-ststop.ads)::
14202 * System.Task_Info (s-tasinf.ads)::
14203 * System.Wch_Cnv (s-wchcnv.ads)::
14204 * System.Wch_Con (s-wchcon.ads)::
14207 @node Ada.Characters.Latin_9 (a-chlat9.ads)
14208 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14209 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14210 @cindex Latin_9 constants for Character
14213 This child of @code{Ada.Characters}
14214 provides a set of definitions corresponding to those in the
14215 RM-defined package @code{Ada.Characters.Latin_1} but with the
14216 few modifications required for @code{Latin-9}
14217 The provision of such a package
14218 is specifically authorized by the Ada Reference Manual
14221 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
14222 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14223 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14224 @cindex Latin_1 constants for Wide_Character
14227 This child of @code{Ada.Characters}
14228 provides a set of definitions corresponding to those in the
14229 RM-defined package @code{Ada.Characters.Latin_1} but with the
14230 types of the constants being @code{Wide_Character}
14231 instead of @code{Character}. The provision of such a package
14232 is specifically authorized by the Ada Reference Manual
14235 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
14236 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14237 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14238 @cindex Latin_9 constants for Wide_Character
14241 This child of @code{Ada.Characters}
14242 provides a set of definitions corresponding to those in the
14243 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14244 types of the constants being @code{Wide_Character}
14245 instead of @code{Character}. The provision of such a package
14246 is specifically authorized by the Ada Reference Manual
14249 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
14250 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14251 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14252 @cindex Latin_1 constants for Wide_Wide_Character
14255 This child of @code{Ada.Characters}
14256 provides a set of definitions corresponding to those in the
14257 RM-defined package @code{Ada.Characters.Latin_1} but with the
14258 types of the constants being @code{Wide_Wide_Character}
14259 instead of @code{Character}. The provision of such a package
14260 is specifically authorized by the Ada Reference Manual
14263 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
14264 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14265 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14266 @cindex Latin_9 constants for Wide_Wide_Character
14269 This child of @code{Ada.Characters}
14270 provides a set of definitions corresponding to those in the
14271 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14272 types of the constants being @code{Wide_Wide_Character}
14273 instead of @code{Character}. The provision of such a package
14274 is specifically authorized by the Ada Reference Manual
14277 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
14278 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14279 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14280 @cindex Formal container for doubly linked lists
14283 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14284 container for doubly linked lists, meant to facilitate formal verification of
14285 code using such containers.
14287 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
14288 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14289 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14290 @cindex Formal container for hashed maps
14293 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14294 container for hashed maps, meant to facilitate formal verification of
14295 code using such containers.
14297 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
14298 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14299 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14300 @cindex Formal container for hashed sets
14303 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14304 container for hashed sets, meant to facilitate formal verification of
14305 code using such containers.
14307 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
14308 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14309 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14310 @cindex Formal container for ordered maps
14313 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14314 container for ordered maps, meant to facilitate formal verification of
14315 code using such containers.
14317 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
14318 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14319 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14320 @cindex Formal container for ordered sets
14323 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14324 container for ordered sets, meant to facilitate formal verification of
14325 code using such containers.
14327 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
14328 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14329 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14330 @cindex Formal container for vectors
14333 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14334 container for vectors, meant to facilitate formal verification of
14335 code using such containers.
14337 @node Ada.Command_Line.Environment (a-colien.ads)
14338 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14339 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14340 @cindex Environment entries
14343 This child of @code{Ada.Command_Line}
14344 provides a mechanism for obtaining environment values on systems
14345 where this concept makes sense.
14347 @node Ada.Command_Line.Remove (a-colire.ads)
14348 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14349 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14350 @cindex Removing command line arguments
14351 @cindex Command line, argument removal
14354 This child of @code{Ada.Command_Line}
14355 provides a mechanism for logically removing
14356 arguments from the argument list. Once removed, an argument is not visible
14357 to further calls on the subprograms in @code{Ada.Command_Line} will not
14358 see the removed argument.
14360 @node Ada.Command_Line.Response_File (a-clrefi.ads)
14361 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14362 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14363 @cindex Response file for command line
14364 @cindex Command line, response file
14365 @cindex Command line, handling long command lines
14368 This child of @code{Ada.Command_Line} provides a mechanism facilities for
14369 getting command line arguments from a text file, called a "response file".
14370 Using a response file allow passing a set of arguments to an executable longer
14371 than the maximum allowed by the system on the command line.
14373 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
14374 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14375 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14376 @cindex C Streams, Interfacing with Direct_IO
14379 This package provides subprograms that allow interfacing between
14380 C streams and @code{Direct_IO}. The stream identifier can be
14381 extracted from a file opened on the Ada side, and an Ada file
14382 can be constructed from a stream opened on the C side.
14384 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
14385 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14386 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14387 @cindex Null_Occurrence, testing for
14390 This child subprogram provides a way of testing for the null
14391 exception occurrence (@code{Null_Occurrence}) without raising
14394 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
14395 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14396 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14397 @cindex Null_Occurrence, testing for
14400 This child subprogram is used for handling otherwise unhandled
14401 exceptions (hence the name last chance), and perform clean ups before
14402 terminating the program. Note that this subprogram never returns.
14404 @node Ada.Exceptions.Traceback (a-exctra.ads)
14405 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14406 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14407 @cindex Traceback for Exception Occurrence
14410 This child package provides the subprogram (@code{Tracebacks}) to
14411 give a traceback array of addresses based on an exception
14414 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
14415 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14416 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14417 @cindex C Streams, Interfacing with Sequential_IO
14420 This package provides subprograms that allow interfacing between
14421 C streams and @code{Sequential_IO}. The stream identifier can be
14422 extracted from a file opened on the Ada side, and an Ada file
14423 can be constructed from a stream opened on the C side.
14425 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
14426 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14427 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14428 @cindex C Streams, Interfacing with Stream_IO
14431 This package provides subprograms that allow interfacing between
14432 C streams and @code{Stream_IO}. The stream identifier can be
14433 extracted from a file opened on the Ada side, and an Ada file
14434 can be constructed from a stream opened on the C side.
14436 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
14437 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14438 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14439 @cindex @code{Unbounded_String}, IO support
14440 @cindex @code{Text_IO}, extensions for unbounded strings
14443 This package provides subprograms for Text_IO for unbounded
14444 strings, avoiding the necessity for an intermediate operation
14445 with ordinary strings.
14447 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
14448 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14449 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14450 @cindex @code{Unbounded_Wide_String}, IO support
14451 @cindex @code{Text_IO}, extensions for unbounded wide strings
14454 This package provides subprograms for Text_IO for unbounded
14455 wide strings, avoiding the necessity for an intermediate operation
14456 with ordinary wide strings.
14458 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
14459 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14460 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14461 @cindex @code{Unbounded_Wide_Wide_String}, IO support
14462 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
14465 This package provides subprograms for Text_IO for unbounded
14466 wide wide strings, avoiding the necessity for an intermediate operation
14467 with ordinary wide wide strings.
14469 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
14470 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14471 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14472 @cindex C Streams, Interfacing with @code{Text_IO}
14475 This package provides subprograms that allow interfacing between
14476 C streams and @code{Text_IO}. The stream identifier can be
14477 extracted from a file opened on the Ada side, and an Ada file
14478 can be constructed from a stream opened on the C side.
14480 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
14481 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14482 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14483 @cindex @code{Text_IO} resetting standard files
14486 This procedure is used to reset the status of the standard files used
14487 by Ada.Text_IO. This is useful in a situation (such as a restart in an
14488 embedded application) where the status of the files may change during
14489 execution (for example a standard input file may be redefined to be
14492 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
14493 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14494 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14495 @cindex Unicode categorization, Wide_Character
14498 This package provides subprograms that allow categorization of
14499 Wide_Character values according to Unicode categories.
14501 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
14502 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14503 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14504 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
14507 This package provides subprograms that allow interfacing between
14508 C streams and @code{Wide_Text_IO}. The stream identifier can be
14509 extracted from a file opened on the Ada side, and an Ada file
14510 can be constructed from a stream opened on the C side.
14512 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
14513 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14514 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14515 @cindex @code{Wide_Text_IO} resetting standard files
14518 This procedure is used to reset the status of the standard files used
14519 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
14520 embedded application) where the status of the files may change during
14521 execution (for example a standard input file may be redefined to be
14524 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
14525 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14526 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14527 @cindex Unicode categorization, Wide_Wide_Character
14530 This package provides subprograms that allow categorization of
14531 Wide_Wide_Character values according to Unicode categories.
14533 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
14534 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14535 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14536 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
14539 This package provides subprograms that allow interfacing between
14540 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
14541 extracted from a file opened on the Ada side, and an Ada file
14542 can be constructed from a stream opened on the C side.
14544 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
14545 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14546 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14547 @cindex @code{Wide_Wide_Text_IO} resetting standard files
14550 This procedure is used to reset the status of the standard files used
14551 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
14552 restart in an embedded application) where the status of the files may
14553 change during execution (for example a standard input file may be
14554 redefined to be interactive).
14556 @node GNAT.Altivec (g-altive.ads)
14557 @section @code{GNAT.Altivec} (@file{g-altive.ads})
14558 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
14562 This is the root package of the GNAT AltiVec binding. It provides
14563 definitions of constants and types common to all the versions of the
14566 @node GNAT.Altivec.Conversions (g-altcon.ads)
14567 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14568 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14572 This package provides the Vector/View conversion routines.
14574 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
14575 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14576 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14580 This package exposes the Ada interface to the AltiVec operations on
14581 vector objects. A soft emulation is included by default in the GNAT
14582 library. The hard binding is provided as a separate package. This unit
14583 is common to both bindings.
14585 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
14586 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14587 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14591 This package exposes the various vector types part of the Ada binding
14592 to AltiVec facilities.
14594 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
14595 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14596 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14600 This package provides public 'View' data types from/to which private
14601 vector representations can be converted via
14602 GNAT.Altivec.Conversions. This allows convenient access to individual
14603 vector elements and provides a simple way to initialize vector
14606 @node GNAT.Array_Split (g-arrspl.ads)
14607 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14608 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14609 @cindex Array splitter
14612 Useful array-manipulation routines: given a set of separators, split
14613 an array wherever the separators appear, and provide direct access
14614 to the resulting slices.
14616 @node GNAT.AWK (g-awk.ads)
14617 @section @code{GNAT.AWK} (@file{g-awk.ads})
14618 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
14623 Provides AWK-like parsing functions, with an easy interface for parsing one
14624 or more files containing formatted data. The file is viewed as a database
14625 where each record is a line and a field is a data element in this line.
14627 @node GNAT.Bounded_Buffers (g-boubuf.ads)
14628 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14629 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14631 @cindex Bounded Buffers
14634 Provides a concurrent generic bounded buffer abstraction. Instances are
14635 useful directly or as parts of the implementations of other abstractions,
14638 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
14639 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14640 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14645 Provides a thread-safe asynchronous intertask mailbox communication facility.
14647 @node GNAT.Bubble_Sort (g-bubsor.ads)
14648 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14649 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14651 @cindex Bubble sort
14654 Provides a general implementation of bubble sort usable for sorting arbitrary
14655 data items. Exchange and comparison procedures are provided by passing
14656 access-to-procedure values.
14658 @node GNAT.Bubble_Sort_A (g-busora.ads)
14659 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14660 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14662 @cindex Bubble sort
14665 Provides a general implementation of bubble sort usable for sorting arbitrary
14666 data items. Move and comparison procedures are provided by passing
14667 access-to-procedure values. This is an older version, retained for
14668 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14670 @node GNAT.Bubble_Sort_G (g-busorg.ads)
14671 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14672 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14674 @cindex Bubble sort
14677 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14678 are provided as generic parameters, this improves efficiency, especially
14679 if the procedures can be inlined, at the expense of duplicating code for
14680 multiple instantiations.
14682 @node GNAT.Byte_Order_Mark (g-byorma.ads)
14683 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14684 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14685 @cindex UTF-8 representation
14686 @cindex Wide characte representations
14689 Provides a routine which given a string, reads the start of the string to
14690 see whether it is one of the standard byte order marks (BOM's) which signal
14691 the encoding of the string. The routine includes detection of special XML
14692 sequences for various UCS input formats.
14694 @node GNAT.Byte_Swapping (g-bytswa.ads)
14695 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14696 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14697 @cindex Byte swapping
14701 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14702 Machine-specific implementations are available in some cases.
14704 @node GNAT.Calendar (g-calend.ads)
14705 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14706 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14707 @cindex @code{Calendar}
14710 Extends the facilities provided by @code{Ada.Calendar} to include handling
14711 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14712 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14713 C @code{timeval} format.
14715 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14716 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14717 @cindex @code{Calendar}
14719 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14721 @node GNAT.CRC32 (g-crc32.ads)
14722 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14723 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14725 @cindex Cyclic Redundancy Check
14728 This package implements the CRC-32 algorithm. For a full description
14729 of this algorithm see
14730 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14731 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14732 Aug.@: 1988. Sarwate, D.V@.
14734 @node GNAT.Case_Util (g-casuti.ads)
14735 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14736 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14737 @cindex Casing utilities
14738 @cindex Character handling (@code{GNAT.Case_Util})
14741 A set of simple routines for handling upper and lower casing of strings
14742 without the overhead of the full casing tables
14743 in @code{Ada.Characters.Handling}.
14745 @node GNAT.CGI (g-cgi.ads)
14746 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14747 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14748 @cindex CGI (Common Gateway Interface)
14751 This is a package for interfacing a GNAT program with a Web server via the
14752 Common Gateway Interface (CGI)@. Basically this package parses the CGI
14753 parameters, which are a set of key/value pairs sent by the Web server. It
14754 builds a table whose index is the key and provides some services to deal
14757 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14758 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14759 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14760 @cindex CGI (Common Gateway Interface) cookie support
14761 @cindex Cookie support in CGI
14764 This is a package to interface a GNAT program with a Web server via the
14765 Common Gateway Interface (CGI). It exports services to deal with Web
14766 cookies (piece of information kept in the Web client software).
14768 @node GNAT.CGI.Debug (g-cgideb.ads)
14769 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14770 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14771 @cindex CGI (Common Gateway Interface) debugging
14774 This is a package to help debugging CGI (Common Gateway Interface)
14775 programs written in Ada.
14777 @node GNAT.Command_Line (g-comlin.ads)
14778 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14779 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14780 @cindex Command line
14783 Provides a high level interface to @code{Ada.Command_Line} facilities,
14784 including the ability to scan for named switches with optional parameters
14785 and expand file names using wild card notations.
14787 @node GNAT.Compiler_Version (g-comver.ads)
14788 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14789 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14790 @cindex Compiler Version
14791 @cindex Version, of compiler
14794 Provides a routine for obtaining the version of the compiler used to
14795 compile the program. More accurately this is the version of the binder
14796 used to bind the program (this will normally be the same as the version
14797 of the compiler if a consistent tool set is used to compile all units
14800 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14801 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14802 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14806 Provides a simple interface to handle Ctrl-C keyboard events.
14808 @node GNAT.Current_Exception (g-curexc.ads)
14809 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14810 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14811 @cindex Current exception
14812 @cindex Exception retrieval
14815 Provides access to information on the current exception that has been raised
14816 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14817 specification syntax.
14818 This is particularly useful in simulating typical facilities for
14819 obtaining information about exceptions provided by Ada 83 compilers.
14821 @node GNAT.Debug_Pools (g-debpoo.ads)
14822 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14823 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14825 @cindex Debug pools
14826 @cindex Memory corruption debugging
14829 Provide a debugging storage pools that helps tracking memory corruption
14830 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14831 @value{EDITION} User's Guide}.
14833 @node GNAT.Debug_Utilities (g-debuti.ads)
14834 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14835 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14839 Provides a few useful utilities for debugging purposes, including conversion
14840 to and from string images of address values. Supports both C and Ada formats
14841 for hexadecimal literals.
14843 @node GNAT.Decode_String (g-decstr.ads)
14844 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14845 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14846 @cindex Decoding strings
14847 @cindex String decoding
14848 @cindex Wide character encoding
14853 A generic package providing routines for decoding wide character and wide wide
14854 character strings encoded as sequences of 8-bit characters using a specified
14855 encoding method. Includes validation routines, and also routines for stepping
14856 to next or previous encoded character in an encoded string.
14857 Useful in conjunction with Unicode character coding. Note there is a
14858 preinstantiation for UTF-8. See next entry.
14860 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14861 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14862 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14863 @cindex Decoding strings
14864 @cindex Decoding UTF-8 strings
14865 @cindex UTF-8 string decoding
14866 @cindex Wide character decoding
14871 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14873 @node GNAT.Directory_Operations (g-dirope.ads)
14874 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14875 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14876 @cindex Directory operations
14879 Provides a set of routines for manipulating directories, including changing
14880 the current directory, making new directories, and scanning the files in a
14883 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14884 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14885 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14886 @cindex Directory operations iteration
14889 A child unit of GNAT.Directory_Operations providing additional operations
14890 for iterating through directories.
14892 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14893 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14894 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14895 @cindex Hash tables
14898 A generic implementation of hash tables that can be used to hash arbitrary
14899 data. Provided in two forms, a simple form with built in hash functions,
14900 and a more complex form in which the hash function is supplied.
14903 This package provides a facility similar to that of @code{GNAT.HTable},
14904 except that this package declares a type that can be used to define
14905 dynamic instances of the hash table, while an instantiation of
14906 @code{GNAT.HTable} creates a single instance of the hash table.
14908 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14909 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14910 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14911 @cindex Table implementation
14912 @cindex Arrays, extendable
14915 A generic package providing a single dimension array abstraction where the
14916 length of the array can be dynamically modified.
14919 This package provides a facility similar to that of @code{GNAT.Table},
14920 except that this package declares a type that can be used to define
14921 dynamic instances of the table, while an instantiation of
14922 @code{GNAT.Table} creates a single instance of the table type.
14924 @node GNAT.Encode_String (g-encstr.ads)
14925 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14926 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14927 @cindex Encoding strings
14928 @cindex String encoding
14929 @cindex Wide character encoding
14934 A generic package providing routines for encoding wide character and wide
14935 wide character strings as sequences of 8-bit characters using a specified
14936 encoding method. Useful in conjunction with Unicode character coding.
14937 Note there is a preinstantiation for UTF-8. See next entry.
14939 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14940 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14941 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14942 @cindex Encoding strings
14943 @cindex Encoding UTF-8 strings
14944 @cindex UTF-8 string encoding
14945 @cindex Wide character encoding
14950 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14952 @node GNAT.Exception_Actions (g-excact.ads)
14953 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14954 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14955 @cindex Exception actions
14958 Provides callbacks when an exception is raised. Callbacks can be registered
14959 for specific exceptions, or when any exception is raised. This
14960 can be used for instance to force a core dump to ease debugging.
14962 @node GNAT.Exception_Traces (g-exctra.ads)
14963 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14964 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14965 @cindex Exception traces
14969 Provides an interface allowing to control automatic output upon exception
14972 @node GNAT.Exceptions (g-except.ads)
14973 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14974 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14975 @cindex Exceptions, Pure
14976 @cindex Pure packages, exceptions
14979 Normally it is not possible to raise an exception with
14980 a message from a subprogram in a pure package, since the
14981 necessary types and subprograms are in @code{Ada.Exceptions}
14982 which is not a pure unit. @code{GNAT.Exceptions} provides a
14983 facility for getting around this limitation for a few
14984 predefined exceptions, and for example allow raising
14985 @code{Constraint_Error} with a message from a pure subprogram.
14987 @node GNAT.Expect (g-expect.ads)
14988 @section @code{GNAT.Expect} (@file{g-expect.ads})
14989 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14992 Provides a set of subprograms similar to what is available
14993 with the standard Tcl Expect tool.
14994 It allows you to easily spawn and communicate with an external process.
14995 You can send commands or inputs to the process, and compare the output
14996 with some expected regular expression. Currently @code{GNAT.Expect}
14997 is implemented on all native GNAT ports except for OpenVMS@.
14998 It is not implemented for cross ports, and in particular is not
14999 implemented for VxWorks or LynxOS@.
15001 @node GNAT.Float_Control (g-flocon.ads)
15002 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
15003 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
15004 @cindex Floating-Point Processor
15007 Provides an interface for resetting the floating-point processor into the
15008 mode required for correct semantic operation in Ada. Some third party
15009 library calls may cause this mode to be modified, and the Reset procedure
15010 in this package can be used to reestablish the required mode.
15012 @node GNAT.Heap_Sort (g-heasor.ads)
15013 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15014 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15018 Provides a general implementation of heap sort usable for sorting arbitrary
15019 data items. Exchange and comparison procedures are provided by passing
15020 access-to-procedure values. The algorithm used is a modified heap sort
15021 that performs approximately N*log(N) comparisons in the worst case.
15023 @node GNAT.Heap_Sort_A (g-hesora.ads)
15024 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15025 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15029 Provides a general implementation of heap sort usable for sorting arbitrary
15030 data items. Move and comparison procedures are provided by passing
15031 access-to-procedure values. The algorithm used is a modified heap sort
15032 that performs approximately N*log(N) comparisons in the worst case.
15033 This differs from @code{GNAT.Heap_Sort} in having a less convenient
15034 interface, but may be slightly more efficient.
15036 @node GNAT.Heap_Sort_G (g-hesorg.ads)
15037 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15038 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15042 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
15043 are provided as generic parameters, this improves efficiency, especially
15044 if the procedures can be inlined, at the expense of duplicating code for
15045 multiple instantiations.
15047 @node GNAT.HTable (g-htable.ads)
15048 @section @code{GNAT.HTable} (@file{g-htable.ads})
15049 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
15050 @cindex Hash tables
15053 A generic implementation of hash tables that can be used to hash arbitrary
15054 data. Provides two approaches, one a simple static approach, and the other
15055 allowing arbitrary dynamic hash tables.
15057 @node GNAT.IO (g-io.ads)
15058 @section @code{GNAT.IO} (@file{g-io.ads})
15059 @cindex @code{GNAT.IO} (@file{g-io.ads})
15061 @cindex Input/Output facilities
15064 A simple preelaborable input-output package that provides a subset of
15065 simple Text_IO functions for reading characters and strings from
15066 Standard_Input, and writing characters, strings and integers to either
15067 Standard_Output or Standard_Error.
15069 @node GNAT.IO_Aux (g-io_aux.ads)
15070 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15071 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15073 @cindex Input/Output facilities
15075 Provides some auxiliary functions for use with Text_IO, including a test
15076 for whether a file exists, and functions for reading a line of text.
15078 @node GNAT.Lock_Files (g-locfil.ads)
15079 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15080 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15081 @cindex File locking
15082 @cindex Locking using files
15085 Provides a general interface for using files as locks. Can be used for
15086 providing program level synchronization.
15088 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
15089 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15090 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15091 @cindex Random number generation
15094 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
15095 a modified version of the Blum-Blum-Shub generator.
15097 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
15098 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15099 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15100 @cindex Random number generation
15103 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
15104 a modified version of the Blum-Blum-Shub generator.
15106 @node GNAT.MD5 (g-md5.ads)
15107 @section @code{GNAT.MD5} (@file{g-md5.ads})
15108 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
15109 @cindex Message Digest MD5
15112 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
15114 @node GNAT.Memory_Dump (g-memdum.ads)
15115 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15116 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15117 @cindex Dump Memory
15120 Provides a convenient routine for dumping raw memory to either the
15121 standard output or standard error files. Uses GNAT.IO for actual
15124 @node GNAT.Most_Recent_Exception (g-moreex.ads)
15125 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15126 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15127 @cindex Exception, obtaining most recent
15130 Provides access to the most recently raised exception. Can be used for
15131 various logging purposes, including duplicating functionality of some
15132 Ada 83 implementation dependent extensions.
15134 @node GNAT.OS_Lib (g-os_lib.ads)
15135 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15136 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15137 @cindex Operating System interface
15138 @cindex Spawn capability
15141 Provides a range of target independent operating system interface functions,
15142 including time/date management, file operations, subprocess management,
15143 including a portable spawn procedure, and access to environment variables
15144 and error return codes.
15146 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
15147 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15148 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15149 @cindex Hash functions
15152 Provides a generator of static minimal perfect hash functions. No
15153 collisions occur and each item can be retrieved from the table in one
15154 probe (perfect property). The hash table size corresponds to the exact
15155 size of the key set and no larger (minimal property). The key set has to
15156 be know in advance (static property). The hash functions are also order
15157 preserving. If w2 is inserted after w1 in the generator, their
15158 hashcode are in the same order. These hashing functions are very
15159 convenient for use with realtime applications.
15161 @node GNAT.Random_Numbers (g-rannum.ads)
15162 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15163 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15164 @cindex Random number generation
15167 Provides random number capabilities which extend those available in the
15168 standard Ada library and are more convenient to use.
15170 @node GNAT.Regexp (g-regexp.ads)
15171 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
15172 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
15173 @cindex Regular expressions
15174 @cindex Pattern matching
15177 A simple implementation of regular expressions, using a subset of regular
15178 expression syntax copied from familiar Unix style utilities. This is the
15179 simples of the three pattern matching packages provided, and is particularly
15180 suitable for ``file globbing'' applications.
15182 @node GNAT.Registry (g-regist.ads)
15183 @section @code{GNAT.Registry} (@file{g-regist.ads})
15184 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
15185 @cindex Windows Registry
15188 This is a high level binding to the Windows registry. It is possible to
15189 do simple things like reading a key value, creating a new key. For full
15190 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
15191 package provided with the Win32Ada binding
15193 @node GNAT.Regpat (g-regpat.ads)
15194 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
15195 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
15196 @cindex Regular expressions
15197 @cindex Pattern matching
15200 A complete implementation of Unix-style regular expression matching, copied
15201 from the original V7 style regular expression library written in C by
15202 Henry Spencer (and binary compatible with this C library).
15204 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
15205 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15206 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15207 @cindex Secondary Stack Info
15210 Provide the capability to query the high water mark of the current task's
15213 @node GNAT.Semaphores (g-semaph.ads)
15214 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
15215 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
15219 Provides classic counting and binary semaphores using protected types.
15221 @node GNAT.Serial_Communications (g-sercom.ads)
15222 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15223 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15224 @cindex Serial_Communications
15227 Provides a simple interface to send and receive data over a serial
15228 port. This is only supported on GNU/Linux and Windows.
15230 @node GNAT.SHA1 (g-sha1.ads)
15231 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
15232 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
15233 @cindex Secure Hash Algorithm SHA-1
15236 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
15239 @node GNAT.SHA224 (g-sha224.ads)
15240 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
15241 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
15242 @cindex Secure Hash Algorithm SHA-224
15245 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
15247 @node GNAT.SHA256 (g-sha256.ads)
15248 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
15249 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
15250 @cindex Secure Hash Algorithm SHA-256
15253 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
15255 @node GNAT.SHA384 (g-sha384.ads)
15256 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
15257 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
15258 @cindex Secure Hash Algorithm SHA-384
15261 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
15263 @node GNAT.SHA512 (g-sha512.ads)
15264 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
15265 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
15266 @cindex Secure Hash Algorithm SHA-512
15269 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
15271 @node GNAT.Signals (g-signal.ads)
15272 @section @code{GNAT.Signals} (@file{g-signal.ads})
15273 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
15277 Provides the ability to manipulate the blocked status of signals on supported
15280 @node GNAT.Sockets (g-socket.ads)
15281 @section @code{GNAT.Sockets} (@file{g-socket.ads})
15282 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
15286 A high level and portable interface to develop sockets based applications.
15287 This package is based on the sockets thin binding found in
15288 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
15289 on all native GNAT ports except for OpenVMS@. It is not implemented
15290 for the LynxOS@ cross port.
15292 @node GNAT.Source_Info (g-souinf.ads)
15293 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
15294 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
15295 @cindex Source Information
15298 Provides subprograms that give access to source code information known at
15299 compile time, such as the current file name and line number.
15301 @node GNAT.Spelling_Checker (g-speche.ads)
15302 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15303 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15304 @cindex Spell checking
15307 Provides a function for determining whether one string is a plausible
15308 near misspelling of another string.
15310 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
15311 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15312 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15313 @cindex Spell checking
15316 Provides a generic function that can be instantiated with a string type for
15317 determining whether one string is a plausible near misspelling of another
15320 @node GNAT.Spitbol.Patterns (g-spipat.ads)
15321 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15322 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15323 @cindex SPITBOL pattern matching
15324 @cindex Pattern matching
15327 A complete implementation of SNOBOL4 style pattern matching. This is the
15328 most elaborate of the pattern matching packages provided. It fully duplicates
15329 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
15330 efficient algorithm developed by Robert Dewar for the SPITBOL system.
15332 @node GNAT.Spitbol (g-spitbo.ads)
15333 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15334 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15335 @cindex SPITBOL interface
15338 The top level package of the collection of SPITBOL-style functionality, this
15339 package provides basic SNOBOL4 string manipulation functions, such as
15340 Pad, Reverse, Trim, Substr capability, as well as a generic table function
15341 useful for constructing arbitrary mappings from strings in the style of
15342 the SNOBOL4 TABLE function.
15344 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
15345 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15346 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15347 @cindex Sets of strings
15348 @cindex SPITBOL Tables
15351 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15352 for type @code{Standard.Boolean}, giving an implementation of sets of
15355 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
15356 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15357 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15358 @cindex Integer maps
15360 @cindex SPITBOL Tables
15363 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15364 for type @code{Standard.Integer}, giving an implementation of maps
15365 from string to integer values.
15367 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
15368 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15369 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15370 @cindex String maps
15372 @cindex SPITBOL Tables
15375 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
15376 a variable length string type, giving an implementation of general
15377 maps from strings to strings.
15379 @node GNAT.SSE (g-sse.ads)
15380 @section @code{GNAT.SSE} (@file{g-sse.ads})
15381 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
15384 Root of a set of units aimed at offering Ada bindings to a subset of
15385 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
15386 targets. It exposes vector component types together with a general
15387 introduction to the binding contents and use.
15389 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
15390 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15391 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15394 SSE vector types for use with SSE related intrinsics.
15396 @node GNAT.Strings (g-string.ads)
15397 @section @code{GNAT.Strings} (@file{g-string.ads})
15398 @cindex @code{GNAT.Strings} (@file{g-string.ads})
15401 Common String access types and related subprograms. Basically it
15402 defines a string access and an array of string access types.
15404 @node GNAT.String_Split (g-strspl.ads)
15405 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
15406 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
15407 @cindex String splitter
15410 Useful string manipulation routines: given a set of separators, split
15411 a string wherever the separators appear, and provide direct access
15412 to the resulting slices. This package is instantiated from
15413 @code{GNAT.Array_Split}.
15415 @node GNAT.Table (g-table.ads)
15416 @section @code{GNAT.Table} (@file{g-table.ads})
15417 @cindex @code{GNAT.Table} (@file{g-table.ads})
15418 @cindex Table implementation
15419 @cindex Arrays, extendable
15422 A generic package providing a single dimension array abstraction where the
15423 length of the array can be dynamically modified.
15426 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
15427 except that this package declares a single instance of the table type,
15428 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
15429 used to define dynamic instances of the table.
15431 @node GNAT.Task_Lock (g-tasloc.ads)
15432 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15433 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15434 @cindex Task synchronization
15435 @cindex Task locking
15439 A very simple facility for locking and unlocking sections of code using a
15440 single global task lock. Appropriate for use in situations where contention
15441 between tasks is very rarely expected.
15443 @node GNAT.Time_Stamp (g-timsta.ads)
15444 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15445 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15447 @cindex Current time
15450 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
15451 represents the current date and time in ISO 8601 format. This is a very simple
15452 routine with minimal code and there are no dependencies on any other unit.
15454 @node GNAT.Threads (g-thread.ads)
15455 @section @code{GNAT.Threads} (@file{g-thread.ads})
15456 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
15457 @cindex Foreign threads
15458 @cindex Threads, foreign
15461 Provides facilities for dealing with foreign threads which need to be known
15462 by the GNAT run-time system. Consult the documentation of this package for
15463 further details if your program has threads that are created by a non-Ada
15464 environment which then accesses Ada code.
15466 @node GNAT.Traceback (g-traceb.ads)
15467 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
15468 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
15469 @cindex Trace back facilities
15472 Provides a facility for obtaining non-symbolic traceback information, useful
15473 in various debugging situations.
15475 @node GNAT.Traceback.Symbolic (g-trasym.ads)
15476 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15477 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15478 @cindex Trace back facilities
15480 @node GNAT.UTF_32 (g-utf_32.ads)
15481 @section @code{GNAT.UTF_32} (@file{g-table.ads})
15482 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
15483 @cindex Wide character codes
15486 This is a package intended to be used in conjunction with the
15487 @code{Wide_Character} type in Ada 95 and the
15488 @code{Wide_Wide_Character} type in Ada 2005 (available
15489 in @code{GNAT} in Ada 2005 mode). This package contains
15490 Unicode categorization routines, as well as lexical
15491 categorization routines corresponding to the Ada 2005
15492 lexical rules for identifiers and strings, and also a
15493 lower case to upper case fold routine corresponding to
15494 the Ada 2005 rules for identifier equivalence.
15496 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
15497 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15498 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15499 @cindex Spell checking
15502 Provides a function for determining whether one wide wide string is a plausible
15503 near misspelling of another wide wide string, where the strings are represented
15504 using the UTF_32_String type defined in System.Wch_Cnv.
15506 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
15507 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15508 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15509 @cindex Spell checking
15512 Provides a function for determining whether one wide string is a plausible
15513 near misspelling of another wide string.
15515 @node GNAT.Wide_String_Split (g-wistsp.ads)
15516 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15517 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15518 @cindex Wide_String splitter
15521 Useful wide string manipulation routines: given a set of separators, split
15522 a wide string wherever the separators appear, and provide direct access
15523 to the resulting slices. This package is instantiated from
15524 @code{GNAT.Array_Split}.
15526 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
15527 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15528 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15529 @cindex Spell checking
15532 Provides a function for determining whether one wide wide string is a plausible
15533 near misspelling of another wide wide string.
15535 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
15536 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15537 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15538 @cindex Wide_Wide_String splitter
15541 Useful wide wide string manipulation routines: given a set of separators, split
15542 a wide wide string wherever the separators appear, and provide direct access
15543 to the resulting slices. This package is instantiated from
15544 @code{GNAT.Array_Split}.
15546 @node Interfaces.C.Extensions (i-cexten.ads)
15547 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15548 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15551 This package contains additional C-related definitions, intended
15552 for use with either manually or automatically generated bindings
15555 @node Interfaces.C.Streams (i-cstrea.ads)
15556 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15557 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15558 @cindex C streams, interfacing
15561 This package is a binding for the most commonly used operations
15564 @node Interfaces.CPP (i-cpp.ads)
15565 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
15566 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
15567 @cindex C++ interfacing
15568 @cindex Interfacing, to C++
15571 This package provides facilities for use in interfacing to C++. It
15572 is primarily intended to be used in connection with automated tools
15573 for the generation of C++ interfaces.
15575 @node Interfaces.Packed_Decimal (i-pacdec.ads)
15576 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15577 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15578 @cindex IBM Packed Format
15579 @cindex Packed Decimal
15582 This package provides a set of routines for conversions to and
15583 from a packed decimal format compatible with that used on IBM
15586 @node Interfaces.VxWorks (i-vxwork.ads)
15587 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15588 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15589 @cindex Interfacing to VxWorks
15590 @cindex VxWorks, interfacing
15593 This package provides a limited binding to the VxWorks API.
15594 In particular, it interfaces with the
15595 VxWorks hardware interrupt facilities.
15597 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
15598 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15599 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15600 @cindex Interfacing to VxWorks' I/O
15601 @cindex VxWorks, I/O interfacing
15602 @cindex VxWorks, Get_Immediate
15603 @cindex Get_Immediate, VxWorks
15606 This package provides a binding to the ioctl (IO/Control)
15607 function of VxWorks, defining a set of option values and
15608 function codes. A particular use of this package is
15609 to enable the use of Get_Immediate under VxWorks.
15611 @node System.Address_Image (s-addima.ads)
15612 @section @code{System.Address_Image} (@file{s-addima.ads})
15613 @cindex @code{System.Address_Image} (@file{s-addima.ads})
15614 @cindex Address image
15615 @cindex Image, of an address
15618 This function provides a useful debugging
15619 function that gives an (implementation dependent)
15620 string which identifies an address.
15622 @node System.Assertions (s-assert.ads)
15623 @section @code{System.Assertions} (@file{s-assert.ads})
15624 @cindex @code{System.Assertions} (@file{s-assert.ads})
15626 @cindex Assert_Failure, exception
15629 This package provides the declaration of the exception raised
15630 by an run-time assertion failure, as well as the routine that
15631 is used internally to raise this assertion.
15633 @node System.Memory (s-memory.ads)
15634 @section @code{System.Memory} (@file{s-memory.ads})
15635 @cindex @code{System.Memory} (@file{s-memory.ads})
15636 @cindex Memory allocation
15639 This package provides the interface to the low level routines used
15640 by the generated code for allocation and freeing storage for the
15641 default storage pool (analogous to the C routines malloc and free.
15642 It also provides a reallocation interface analogous to the C routine
15643 realloc. The body of this unit may be modified to provide alternative
15644 allocation mechanisms for the default pool, and in addition, direct
15645 calls to this unit may be made for low level allocation uses (for
15646 example see the body of @code{GNAT.Tables}).
15648 @node System.Partition_Interface (s-parint.ads)
15649 @section @code{System.Partition_Interface} (@file{s-parint.ads})
15650 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
15651 @cindex Partition interfacing functions
15654 This package provides facilities for partition interfacing. It
15655 is used primarily in a distribution context when using Annex E
15658 @node System.Pool_Global (s-pooglo.ads)
15659 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
15660 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
15661 @cindex Storage pool, global
15662 @cindex Global storage pool
15665 This package provides a storage pool that is equivalent to the default
15666 storage pool used for access types for which no pool is specifically
15667 declared. It uses malloc/free to allocate/free and does not attempt to
15668 do any automatic reclamation.
15670 @node System.Pool_Local (s-pooloc.ads)
15671 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
15672 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
15673 @cindex Storage pool, local
15674 @cindex Local storage pool
15677 This package provides a storage pool that is intended for use with locally
15678 defined access types. It uses malloc/free for allocate/free, and maintains
15679 a list of allocated blocks, so that all storage allocated for the pool can
15680 be freed automatically when the pool is finalized.
15682 @node System.Restrictions (s-restri.ads)
15683 @section @code{System.Restrictions} (@file{s-restri.ads})
15684 @cindex @code{System.Restrictions} (@file{s-restri.ads})
15685 @cindex Run-time restrictions access
15688 This package provides facilities for accessing at run time
15689 the status of restrictions specified at compile time for
15690 the partition. Information is available both with regard
15691 to actual restrictions specified, and with regard to
15692 compiler determined information on which restrictions
15693 are violated by one or more packages in the partition.
15695 @node System.Rident (s-rident.ads)
15696 @section @code{System.Rident} (@file{s-rident.ads})
15697 @cindex @code{System.Rident} (@file{s-rident.ads})
15698 @cindex Restrictions definitions
15701 This package provides definitions of the restrictions
15702 identifiers supported by GNAT, and also the format of
15703 the restrictions provided in package System.Restrictions.
15704 It is not normally necessary to @code{with} this generic package
15705 since the necessary instantiation is included in
15706 package System.Restrictions.
15708 @node System.Strings.Stream_Ops (s-ststop.ads)
15709 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15710 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15711 @cindex Stream operations
15712 @cindex String stream operations
15715 This package provides a set of stream subprograms for standard string types.
15716 It is intended primarily to support implicit use of such subprograms when
15717 stream attributes are applied to string types, but the subprograms in this
15718 package can be used directly by application programs.
15720 @node System.Task_Info (s-tasinf.ads)
15721 @section @code{System.Task_Info} (@file{s-tasinf.ads})
15722 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15723 @cindex Task_Info pragma
15726 This package provides target dependent functionality that is used
15727 to support the @code{Task_Info} pragma
15729 @node System.Wch_Cnv (s-wchcnv.ads)
15730 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15731 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15732 @cindex Wide Character, Representation
15733 @cindex Wide String, Conversion
15734 @cindex Representation of wide characters
15737 This package provides routines for converting between
15738 wide and wide wide characters and a representation as a value of type
15739 @code{Standard.String}, using a specified wide character
15740 encoding method. It uses definitions in
15741 package @code{System.Wch_Con}.
15743 @node System.Wch_Con (s-wchcon.ads)
15744 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15745 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15748 This package provides definitions and descriptions of
15749 the various methods used for encoding wide characters
15750 in ordinary strings. These definitions are used by
15751 the package @code{System.Wch_Cnv}.
15753 @node Interfacing to Other Languages
15754 @chapter Interfacing to Other Languages
15756 The facilities in annex B of the Ada Reference Manual are fully
15757 implemented in GNAT, and in addition, a full interface to C++ is
15761 * Interfacing to C::
15762 * Interfacing to C++::
15763 * Interfacing to COBOL::
15764 * Interfacing to Fortran::
15765 * Interfacing to non-GNAT Ada code::
15768 @node Interfacing to C
15769 @section Interfacing to C
15772 Interfacing to C with GNAT can use one of two approaches:
15776 The types in the package @code{Interfaces.C} may be used.
15778 Standard Ada types may be used directly. This may be less portable to
15779 other compilers, but will work on all GNAT compilers, which guarantee
15780 correspondence between the C and Ada types.
15784 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15785 effect, since this is the default. The following table shows the
15786 correspondence between Ada scalar types and the corresponding C types.
15791 @item Short_Integer
15793 @item Short_Short_Integer
15797 @item Long_Long_Integer
15805 @item Long_Long_Float
15806 This is the longest floating-point type supported by the hardware.
15810 Additionally, there are the following general correspondences between Ada
15814 Ada enumeration types map to C enumeration types directly if pragma
15815 @code{Convention C} is specified, which causes them to have int
15816 length. Without pragma @code{Convention C}, Ada enumeration types map to
15817 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15818 @code{int}, respectively) depending on the number of values passed.
15819 This is the only case in which pragma @code{Convention C} affects the
15820 representation of an Ada type.
15823 Ada access types map to C pointers, except for the case of pointers to
15824 unconstrained types in Ada, which have no direct C equivalent.
15827 Ada arrays map directly to C arrays.
15830 Ada records map directly to C structures.
15833 Packed Ada records map to C structures where all members are bit fields
15834 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15837 @node Interfacing to C++
15838 @section Interfacing to C++
15841 The interface to C++ makes use of the following pragmas, which are
15842 primarily intended to be constructed automatically using a binding generator
15843 tool, although it is possible to construct them by hand. No suitable binding
15844 generator tool is supplied with GNAT though.
15846 Using these pragmas it is possible to achieve complete
15847 inter-operability between Ada tagged types and C++ class definitions.
15848 See @ref{Implementation Defined Pragmas}, for more details.
15851 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15852 The argument denotes an entity in the current declarative region that is
15853 declared as a tagged or untagged record type. It indicates that the type
15854 corresponds to an externally declared C++ class type, and is to be laid
15855 out the same way that C++ would lay out the type.
15857 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15858 for backward compatibility but its functionality is available
15859 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15861 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15862 This pragma identifies an imported function (imported in the usual way
15863 with pragma @code{Import}) as corresponding to a C++ constructor.
15866 @node Interfacing to COBOL
15867 @section Interfacing to COBOL
15870 Interfacing to COBOL is achieved as described in section B.4 of
15871 the Ada Reference Manual.
15873 @node Interfacing to Fortran
15874 @section Interfacing to Fortran
15877 Interfacing to Fortran is achieved as described in section B.5 of the
15878 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
15879 multi-dimensional array causes the array to be stored in column-major
15880 order as required for convenient interface to Fortran.
15882 @node Interfacing to non-GNAT Ada code
15883 @section Interfacing to non-GNAT Ada code
15885 It is possible to specify the convention @code{Ada} in a pragma
15886 @code{Import} or pragma @code{Export}. However this refers to
15887 the calling conventions used by GNAT, which may or may not be
15888 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15889 compiler to allow interoperation.
15891 If arguments types are kept simple, and if the foreign compiler generally
15892 follows system calling conventions, then it may be possible to integrate
15893 files compiled by other Ada compilers, provided that the elaboration
15894 issues are adequately addressed (for example by eliminating the
15895 need for any load time elaboration).
15897 In particular, GNAT running on VMS is designed to
15898 be highly compatible with the DEC Ada 83 compiler, so this is one
15899 case in which it is possible to import foreign units of this type,
15900 provided that the data items passed are restricted to simple scalar
15901 values or simple record types without variants, or simple array
15902 types with fixed bounds.
15904 @node Specialized Needs Annexes
15905 @chapter Specialized Needs Annexes
15908 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15909 required in all implementations. However, as described in this chapter,
15910 GNAT implements all of these annexes:
15913 @item Systems Programming (Annex C)
15914 The Systems Programming Annex is fully implemented.
15916 @item Real-Time Systems (Annex D)
15917 The Real-Time Systems Annex is fully implemented.
15919 @item Distributed Systems (Annex E)
15920 Stub generation is fully implemented in the GNAT compiler. In addition,
15921 a complete compatible PCS is available as part of the GLADE system,
15922 a separate product. When the two
15923 products are used in conjunction, this annex is fully implemented.
15925 @item Information Systems (Annex F)
15926 The Information Systems annex is fully implemented.
15928 @item Numerics (Annex G)
15929 The Numerics Annex is fully implemented.
15931 @item Safety and Security / High-Integrity Systems (Annex H)
15932 The Safety and Security Annex (termed the High-Integrity Systems Annex
15933 in Ada 2005) is fully implemented.
15936 @node Implementation of Specific Ada Features
15937 @chapter Implementation of Specific Ada Features
15940 This chapter describes the GNAT implementation of several Ada language
15944 * Machine Code Insertions::
15945 * GNAT Implementation of Tasking::
15946 * GNAT Implementation of Shared Passive Packages::
15947 * Code Generation for Array Aggregates::
15948 * The Size of Discriminated Records with Default Discriminants::
15949 * Strict Conformance to the Ada Reference Manual::
15952 @node Machine Code Insertions
15953 @section Machine Code Insertions
15954 @cindex Machine Code insertions
15957 Package @code{Machine_Code} provides machine code support as described
15958 in the Ada Reference Manual in two separate forms:
15961 Machine code statements, consisting of qualified expressions that
15962 fit the requirements of RM section 13.8.
15964 An intrinsic callable procedure, providing an alternative mechanism of
15965 including machine instructions in a subprogram.
15969 The two features are similar, and both are closely related to the mechanism
15970 provided by the asm instruction in the GNU C compiler. Full understanding
15971 and use of the facilities in this package requires understanding the asm
15972 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15973 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15975 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15976 semantic restrictions and effects as described below. Both are provided so
15977 that the procedure call can be used as a statement, and the function call
15978 can be used to form a code_statement.
15980 The first example given in the GCC documentation is the C @code{asm}
15983 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15987 The equivalent can be written for GNAT as:
15989 @smallexample @c ada
15990 Asm ("fsinx %1 %0",
15991 My_Float'Asm_Output ("=f", result),
15992 My_Float'Asm_Input ("f", angle));
15996 The first argument to @code{Asm} is the assembler template, and is
15997 identical to what is used in GNU C@. This string must be a static
15998 expression. The second argument is the output operand list. It is
15999 either a single @code{Asm_Output} attribute reference, or a list of such
16000 references enclosed in parentheses (technically an array aggregate of
16003 The @code{Asm_Output} attribute denotes a function that takes two
16004 parameters. The first is a string, the second is the name of a variable
16005 of the type designated by the attribute prefix. The first (string)
16006 argument is required to be a static expression and designates the
16007 constraint for the parameter (e.g.@: what kind of register is
16008 required). The second argument is the variable to be updated with the
16009 result. The possible values for constraint are the same as those used in
16010 the RTL, and are dependent on the configuration file used to build the
16011 GCC back end. If there are no output operands, then this argument may
16012 either be omitted, or explicitly given as @code{No_Output_Operands}.
16014 The second argument of @code{@var{my_float}'Asm_Output} functions as
16015 though it were an @code{out} parameter, which is a little curious, but
16016 all names have the form of expressions, so there is no syntactic
16017 irregularity, even though normally functions would not be permitted
16018 @code{out} parameters. The third argument is the list of input
16019 operands. It is either a single @code{Asm_Input} attribute reference, or
16020 a list of such references enclosed in parentheses (technically an array
16021 aggregate of such references).
16023 The @code{Asm_Input} attribute denotes a function that takes two
16024 parameters. The first is a string, the second is an expression of the
16025 type designated by the prefix. The first (string) argument is required
16026 to be a static expression, and is the constraint for the parameter,
16027 (e.g.@: what kind of register is required). The second argument is the
16028 value to be used as the input argument. The possible values for the
16029 constant are the same as those used in the RTL, and are dependent on
16030 the configuration file used to built the GCC back end.
16032 If there are no input operands, this argument may either be omitted, or
16033 explicitly given as @code{No_Input_Operands}. The fourth argument, not
16034 present in the above example, is a list of register names, called the
16035 @dfn{clobber} argument. This argument, if given, must be a static string
16036 expression, and is a space or comma separated list of names of registers
16037 that must be considered destroyed as a result of the @code{Asm} call. If
16038 this argument is the null string (the default value), then the code
16039 generator assumes that no additional registers are destroyed.
16041 The fifth argument, not present in the above example, called the
16042 @dfn{volatile} argument, is by default @code{False}. It can be set to
16043 the literal value @code{True} to indicate to the code generator that all
16044 optimizations with respect to the instruction specified should be
16045 suppressed, and that in particular, for an instruction that has outputs,
16046 the instruction will still be generated, even if none of the outputs are
16047 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
16048 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
16049 Generally it is strongly advisable to use Volatile for any ASM statement
16050 that is missing either input or output operands, or when two or more ASM
16051 statements appear in sequence, to avoid unwanted optimizations. A warning
16052 is generated if this advice is not followed.
16054 The @code{Asm} subprograms may be used in two ways. First the procedure
16055 forms can be used anywhere a procedure call would be valid, and
16056 correspond to what the RM calls ``intrinsic'' routines. Such calls can
16057 be used to intersperse machine instructions with other Ada statements.
16058 Second, the function forms, which return a dummy value of the limited
16059 private type @code{Asm_Insn}, can be used in code statements, and indeed
16060 this is the only context where such calls are allowed. Code statements
16061 appear as aggregates of the form:
16063 @smallexample @c ada
16064 Asm_Insn'(Asm (@dots{}));
16065 Asm_Insn'(Asm_Volatile (@dots{}));
16069 In accordance with RM rules, such code statements are allowed only
16070 within subprograms whose entire body consists of such statements. It is
16071 not permissible to intermix such statements with other Ada statements.
16073 Typically the form using intrinsic procedure calls is more convenient
16074 and more flexible. The code statement form is provided to meet the RM
16075 suggestion that such a facility should be made available. The following
16076 is the exact syntax of the call to @code{Asm}. As usual, if named notation
16077 is used, the arguments may be given in arbitrary order, following the
16078 normal rules for use of positional and named arguments)
16082 [Template =>] static_string_EXPRESSION
16083 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
16084 [,[Inputs =>] INPUT_OPERAND_LIST ]
16085 [,[Clobber =>] static_string_EXPRESSION ]
16086 [,[Volatile =>] static_boolean_EXPRESSION] )
16088 OUTPUT_OPERAND_LIST ::=
16089 [PREFIX.]No_Output_Operands
16090 | OUTPUT_OPERAND_ATTRIBUTE
16091 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
16093 OUTPUT_OPERAND_ATTRIBUTE ::=
16094 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
16096 INPUT_OPERAND_LIST ::=
16097 [PREFIX.]No_Input_Operands
16098 | INPUT_OPERAND_ATTRIBUTE
16099 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
16101 INPUT_OPERAND_ATTRIBUTE ::=
16102 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
16106 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
16107 are declared in the package @code{Machine_Code} and must be referenced
16108 according to normal visibility rules. In particular if there is no
16109 @code{use} clause for this package, then appropriate package name
16110 qualification is required.
16112 @node GNAT Implementation of Tasking
16113 @section GNAT Implementation of Tasking
16116 This chapter outlines the basic GNAT approach to tasking (in particular,
16117 a multi-layered library for portability) and discusses issues related
16118 to compliance with the Real-Time Systems Annex.
16121 * Mapping Ada Tasks onto the Underlying Kernel Threads::
16122 * Ensuring Compliance with the Real-Time Annex::
16125 @node Mapping Ada Tasks onto the Underlying Kernel Threads
16126 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
16129 GNAT's run-time support comprises two layers:
16132 @item GNARL (GNAT Run-time Layer)
16133 @item GNULL (GNAT Low-level Library)
16137 In GNAT, Ada's tasking services rely on a platform and OS independent
16138 layer known as GNARL@. This code is responsible for implementing the
16139 correct semantics of Ada's task creation, rendezvous, protected
16142 GNARL decomposes Ada's tasking semantics into simpler lower level
16143 operations such as create a thread, set the priority of a thread,
16144 yield, create a lock, lock/unlock, etc. The spec for these low-level
16145 operations constitutes GNULLI, the GNULL Interface. This interface is
16146 directly inspired from the POSIX real-time API@.
16148 If the underlying executive or OS implements the POSIX standard
16149 faithfully, the GNULL Interface maps as is to the services offered by
16150 the underlying kernel. Otherwise, some target dependent glue code maps
16151 the services offered by the underlying kernel to the semantics expected
16154 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
16155 key point is that each Ada task is mapped on a thread in the underlying
16156 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
16158 In addition Ada task priorities map onto the underlying thread priorities.
16159 Mapping Ada tasks onto the underlying kernel threads has several advantages:
16163 The underlying scheduler is used to schedule the Ada tasks. This
16164 makes Ada tasks as efficient as kernel threads from a scheduling
16168 Interaction with code written in C containing threads is eased
16169 since at the lowest level Ada tasks and C threads map onto the same
16170 underlying kernel concept.
16173 When an Ada task is blocked during I/O the remaining Ada tasks are
16177 On multiprocessor systems Ada tasks can execute in parallel.
16181 Some threads libraries offer a mechanism to fork a new process, with the
16182 child process duplicating the threads from the parent.
16184 support this functionality when the parent contains more than one task.
16185 @cindex Forking a new process
16187 @node Ensuring Compliance with the Real-Time Annex
16188 @subsection Ensuring Compliance with the Real-Time Annex
16189 @cindex Real-Time Systems Annex compliance
16192 Although mapping Ada tasks onto
16193 the underlying threads has significant advantages, it does create some
16194 complications when it comes to respecting the scheduling semantics
16195 specified in the real-time annex (Annex D).
16197 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
16198 scheduling policy states:
16201 @emph{When the active priority of a ready task that is not running
16202 changes, or the setting of its base priority takes effect, the
16203 task is removed from the ready queue for its old active priority
16204 and is added at the tail of the ready queue for its new active
16205 priority, except in the case where the active priority is lowered
16206 due to the loss of inherited priority, in which case the task is
16207 added at the head of the ready queue for its new active priority.}
16211 While most kernels do put tasks at the end of the priority queue when
16212 a task changes its priority, (which respects the main
16213 FIFO_Within_Priorities requirement), almost none keep a thread at the
16214 beginning of its priority queue when its priority drops from the loss
16215 of inherited priority.
16217 As a result most vendors have provided incomplete Annex D implementations.
16219 The GNAT run-time, has a nice cooperative solution to this problem
16220 which ensures that accurate FIFO_Within_Priorities semantics are
16223 The principle is as follows. When an Ada task T is about to start
16224 running, it checks whether some other Ada task R with the same
16225 priority as T has been suspended due to the loss of priority
16226 inheritance. If this is the case, T yields and is placed at the end of
16227 its priority queue. When R arrives at the front of the queue it
16230 Note that this simple scheme preserves the relative order of the tasks
16231 that were ready to execute in the priority queue where R has been
16234 @node GNAT Implementation of Shared Passive Packages
16235 @section GNAT Implementation of Shared Passive Packages
16236 @cindex Shared passive packages
16239 GNAT fully implements the pragma @code{Shared_Passive} for
16240 @cindex pragma @code{Shared_Passive}
16241 the purpose of designating shared passive packages.
16242 This allows the use of passive partitions in the
16243 context described in the Ada Reference Manual; i.e., for communication
16244 between separate partitions of a distributed application using the
16245 features in Annex E.
16247 @cindex Distribution Systems Annex
16249 However, the implementation approach used by GNAT provides for more
16250 extensive usage as follows:
16253 @item Communication between separate programs
16255 This allows separate programs to access the data in passive
16256 partitions, using protected objects for synchronization where
16257 needed. The only requirement is that the two programs have a
16258 common shared file system. It is even possible for programs
16259 running on different machines with different architectures
16260 (e.g.@: different endianness) to communicate via the data in
16261 a passive partition.
16263 @item Persistence between program runs
16265 The data in a passive package can persist from one run of a
16266 program to another, so that a later program sees the final
16267 values stored by a previous run of the same program.
16272 The implementation approach used is to store the data in files. A
16273 separate stream file is created for each object in the package, and
16274 an access to an object causes the corresponding file to be read or
16277 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
16278 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
16279 set to the directory to be used for these files.
16280 The files in this directory
16281 have names that correspond to their fully qualified names. For
16282 example, if we have the package
16284 @smallexample @c ada
16286 pragma Shared_Passive (X);
16293 and the environment variable is set to @code{/stemp/}, then the files created
16294 will have the names:
16302 These files are created when a value is initially written to the object, and
16303 the files are retained until manually deleted. This provides the persistence
16304 semantics. If no file exists, it means that no partition has assigned a value
16305 to the variable; in this case the initial value declared in the package
16306 will be used. This model ensures that there are no issues in synchronizing
16307 the elaboration process, since elaboration of passive packages elaborates the
16308 initial values, but does not create the files.
16310 The files are written using normal @code{Stream_IO} access.
16311 If you want to be able
16312 to communicate between programs or partitions running on different
16313 architectures, then you should use the XDR versions of the stream attribute
16314 routines, since these are architecture independent.
16316 If active synchronization is required for access to the variables in the
16317 shared passive package, then as described in the Ada Reference Manual, the
16318 package may contain protected objects used for this purpose. In this case
16319 a lock file (whose name is @file{___lock} (three underscores)
16320 is created in the shared memory directory.
16321 @cindex @file{___lock} file (for shared passive packages)
16322 This is used to provide the required locking
16323 semantics for proper protected object synchronization.
16325 As of January 2003, GNAT supports shared passive packages on all platforms
16326 except for OpenVMS.
16328 @node Code Generation for Array Aggregates
16329 @section Code Generation for Array Aggregates
16332 * Static constant aggregates with static bounds::
16333 * Constant aggregates with unconstrained nominal types::
16334 * Aggregates with static bounds::
16335 * Aggregates with non-static bounds::
16336 * Aggregates in assignment statements::
16340 Aggregates have a rich syntax and allow the user to specify the values of
16341 complex data structures by means of a single construct. As a result, the
16342 code generated for aggregates can be quite complex and involve loops, case
16343 statements and multiple assignments. In the simplest cases, however, the
16344 compiler will recognize aggregates whose components and constraints are
16345 fully static, and in those cases the compiler will generate little or no
16346 executable code. The following is an outline of the code that GNAT generates
16347 for various aggregate constructs. For further details, you will find it
16348 useful to examine the output produced by the -gnatG flag to see the expanded
16349 source that is input to the code generator. You may also want to examine
16350 the assembly code generated at various levels of optimization.
16352 The code generated for aggregates depends on the context, the component values,
16353 and the type. In the context of an object declaration the code generated is
16354 generally simpler than in the case of an assignment. As a general rule, static
16355 component values and static subtypes also lead to simpler code.
16357 @node Static constant aggregates with static bounds
16358 @subsection Static constant aggregates with static bounds
16361 For the declarations:
16362 @smallexample @c ada
16363 type One_Dim is array (1..10) of integer;
16364 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
16368 GNAT generates no executable code: the constant ar0 is placed in static memory.
16369 The same is true for constant aggregates with named associations:
16371 @smallexample @c ada
16372 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
16373 Cr3 : constant One_Dim := (others => 7777);
16377 The same is true for multidimensional constant arrays such as:
16379 @smallexample @c ada
16380 type two_dim is array (1..3, 1..3) of integer;
16381 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
16385 The same is true for arrays of one-dimensional arrays: the following are
16388 @smallexample @c ada
16389 type ar1b is array (1..3) of boolean;
16390 type ar_ar is array (1..3) of ar1b;
16391 None : constant ar1b := (others => false); -- fully static
16392 None2 : constant ar_ar := (1..3 => None); -- fully static
16396 However, for multidimensional aggregates with named associations, GNAT will
16397 generate assignments and loops, even if all associations are static. The
16398 following two declarations generate a loop for the first dimension, and
16399 individual component assignments for the second dimension:
16401 @smallexample @c ada
16402 Zero1: constant two_dim := (1..3 => (1..3 => 0));
16403 Zero2: constant two_dim := (others => (others => 0));
16406 @node Constant aggregates with unconstrained nominal types
16407 @subsection Constant aggregates with unconstrained nominal types
16410 In such cases the aggregate itself establishes the subtype, so that
16411 associations with @code{others} cannot be used. GNAT determines the
16412 bounds for the actual subtype of the aggregate, and allocates the
16413 aggregate statically as well. No code is generated for the following:
16415 @smallexample @c ada
16416 type One_Unc is array (natural range <>) of integer;
16417 Cr_Unc : constant One_Unc := (12,24,36);
16420 @node Aggregates with static bounds
16421 @subsection Aggregates with static bounds
16424 In all previous examples the aggregate was the initial (and immutable) value
16425 of a constant. If the aggregate initializes a variable, then code is generated
16426 for it as a combination of individual assignments and loops over the target
16427 object. The declarations
16429 @smallexample @c ada
16430 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
16431 Cr_Var2 : One_Dim := (others > -1);
16435 generate the equivalent of
16437 @smallexample @c ada
16443 for I in Cr_Var2'range loop
16448 @node Aggregates with non-static bounds
16449 @subsection Aggregates with non-static bounds
16452 If the bounds of the aggregate are not statically compatible with the bounds
16453 of the nominal subtype of the target, then constraint checks have to be
16454 generated on the bounds. For a multidimensional array, constraint checks may
16455 have to be applied to sub-arrays individually, if they do not have statically
16456 compatible subtypes.
16458 @node Aggregates in assignment statements
16459 @subsection Aggregates in assignment statements
16462 In general, aggregate assignment requires the construction of a temporary,
16463 and a copy from the temporary to the target of the assignment. This is because
16464 it is not always possible to convert the assignment into a series of individual
16465 component assignments. For example, consider the simple case:
16467 @smallexample @c ada
16472 This cannot be converted into:
16474 @smallexample @c ada
16480 So the aggregate has to be built first in a separate location, and then
16481 copied into the target. GNAT recognizes simple cases where this intermediate
16482 step is not required, and the assignments can be performed in place, directly
16483 into the target. The following sufficient criteria are applied:
16487 The bounds of the aggregate are static, and the associations are static.
16489 The components of the aggregate are static constants, names of
16490 simple variables that are not renamings, or expressions not involving
16491 indexed components whose operands obey these rules.
16495 If any of these conditions are violated, the aggregate will be built in
16496 a temporary (created either by the front-end or the code generator) and then
16497 that temporary will be copied onto the target.
16499 @node The Size of Discriminated Records with Default Discriminants
16500 @section The Size of Discriminated Records with Default Discriminants
16503 If a discriminated type @code{T} has discriminants with default values, it is
16504 possible to declare an object of this type without providing an explicit
16507 @smallexample @c ada
16509 type Size is range 1..100;
16511 type Rec (D : Size := 15) is record
16512 Name : String (1..D);
16520 Such an object is said to be @emph{unconstrained}.
16521 The discriminant of the object
16522 can be modified by a full assignment to the object, as long as it preserves the
16523 relation between the value of the discriminant, and the value of the components
16526 @smallexample @c ada
16528 Word := (3, "yes");
16530 Word := (5, "maybe");
16532 Word := (5, "no"); -- raises Constraint_Error
16537 In order to support this behavior efficiently, an unconstrained object is
16538 given the maximum size that any value of the type requires. In the case
16539 above, @code{Word} has storage for the discriminant and for
16540 a @code{String} of length 100.
16541 It is important to note that unconstrained objects do not require dynamic
16542 allocation. It would be an improper implementation to place on the heap those
16543 components whose size depends on discriminants. (This improper implementation
16544 was used by some Ada83 compilers, where the @code{Name} component above
16546 been stored as a pointer to a dynamic string). Following the principle that
16547 dynamic storage management should never be introduced implicitly,
16548 an Ada compiler should reserve the full size for an unconstrained declared
16549 object, and place it on the stack.
16551 This maximum size approach
16552 has been a source of surprise to some users, who expect the default
16553 values of the discriminants to determine the size reserved for an
16554 unconstrained object: ``If the default is 15, why should the object occupy
16556 The answer, of course, is that the discriminant may be later modified,
16557 and its full range of values must be taken into account. This is why the
16562 type Rec (D : Positive := 15) is record
16563 Name : String (1..D);
16571 is flagged by the compiler with a warning:
16572 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
16573 because the required size includes @code{Positive'Last}
16574 bytes. As the first example indicates, the proper approach is to declare an
16575 index type of ``reasonable'' range so that unconstrained objects are not too
16578 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
16579 created in the heap by means of an allocator, then it is @emph{not}
16581 it is constrained by the default values of the discriminants, and those values
16582 cannot be modified by full assignment. This is because in the presence of
16583 aliasing all views of the object (which may be manipulated by different tasks,
16584 say) must be consistent, so it is imperative that the object, once created,
16587 @node Strict Conformance to the Ada Reference Manual
16588 @section Strict Conformance to the Ada Reference Manual
16591 The dynamic semantics defined by the Ada Reference Manual impose a set of
16592 run-time checks to be generated. By default, the GNAT compiler will insert many
16593 run-time checks into the compiled code, including most of those required by the
16594 Ada Reference Manual. However, there are three checks that are not enabled
16595 in the default mode for efficiency reasons: arithmetic overflow checking for
16596 integer operations (including division by zero), checks for access before
16597 elaboration on subprogram calls, and stack overflow checking (most operating
16598 systems do not perform this check by default).
16600 Strict conformance to the Ada Reference Manual can be achieved by adding
16601 three compiler options for overflow checking for integer operations
16602 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
16603 calls and generic instantiations (@option{-gnatE}), and stack overflow
16604 checking (@option{-fstack-check}).
16606 Note that the result of a floating point arithmetic operation in overflow and
16607 invalid situations, when the @code{Machine_Overflows} attribute of the result
16608 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
16609 case for machines compliant with the IEEE floating-point standard, but on
16610 machines that are not fully compliant with this standard, such as Alpha, the
16611 @option{-mieee} compiler flag must be used for achieving IEEE confirming
16612 behavior (although at the cost of a significant performance penalty), so
16613 infinite and NaN values are properly generated.
16616 @node Implementation of Ada 2012 Features
16617 @chapter Implementation of Ada 2012 Features
16618 @cindex Ada 2012 implementation status
16620 This chapter contains a complete list of Ada 2012 features that have been
16621 implemented as of GNAT version 6.4. Generally, these features are only
16622 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
16623 @cindex @option{-gnat12} option
16624 or if the configuration pragma @code{Ada_2012} is used.
16625 @cindex pragma @code{Ada_2012}
16626 @cindex configuration pragma @code{Ada_2012}
16627 @cindex @code{Ada_2012} configuration pragma
16628 However, new pragmas, attributes, and restrictions are
16629 unconditionally available, since the Ada 95 standard allows the addition of
16630 new pragmas, attributes, and restrictions (there are exceptions, which are
16631 documented in the individual descriptions), and also certain packages
16632 were made available in earlier versions of Ada.
16634 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
16635 This date shows the implementation date of the feature. Any wavefront
16636 subsequent to this date will contain the indicated feature, as will any
16637 subsequent releases. A date of 0000-00-00 means that GNAT has always
16638 implemented the feature, or implemented it as soon as it appeared as a
16639 binding interpretation.
16641 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
16642 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
16643 The features are ordered based on the relevant sections of the Ada
16644 Reference Manual (``RM''). When a given AI relates to multiple points
16645 in the RM, the earliest is used.
16647 A complete description of the AIs may be found in
16648 @url{www.ada-auth.org/ai05-summary.html}.
16653 @emph{AI-0176 Quantified expressions (2010-09-29)}
16654 @cindex AI-0176 (Ada 2012 feature)
16657 Both universally and existentially quantified expressions are implemented.
16658 They use the new syntax for iterators proposed in AI05-139-2, as well as
16659 the standard Ada loop syntax.
16662 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
16665 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
16666 @cindex AI-0079 (Ada 2012 feature)
16669 Wide characters in the unicode category @i{other_format} are now allowed in
16670 source programs between tokens, but not within a token such as an identifier.
16673 RM References: 2.01 (4/2) 2.02 (7)
16676 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
16677 @cindex AI-0091 (Ada 2012 feature)
16680 Wide characters in the unicode category @i{other_format} are not permitted
16681 within an identifier, since this can be a security problem. The error
16682 message for this case has been improved to be more specific, but GNAT has
16683 never allowed such characters to appear in identifiers.
16686 RM References: 2.03 (3.1/2) 2.03 (4/2) 2.03 (5/2) 2.03 (5.1/2) 2.03 (5.2/2) 2.03 (5.3/2) 2.09 (2/2)
16689 @emph{AI-0100 Placement of pragmas (2010-07-01)}
16690 @cindex AI-0100 (Ada 2012 feature)
16693 This AI is an earlier version of AI-163. It simplifies the rules
16694 for legal placement of pragmas. In the case of lists that allow pragmas, if
16695 the list may have no elements, then the list may consist solely of pragmas.
16698 RM References: 2.08 (7)
16701 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
16702 @cindex AI-0163 (Ada 2012 feature)
16705 A statement sequence may be composed entirely of pragmas. It is no longer
16706 necessary to add a dummy @code{null} statement to make the sequence legal.
16709 RM References: 2.08 (7) 2.08 (16)
16713 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
16714 @cindex AI-0080 (Ada 2012 feature)
16717 This is an editorial change only, described as non-testable in the AI.
16720 RM References: 3.01 (7)
16724 @emph{AI-0183 Aspect specifications (2010-08-16)}
16725 @cindex AI-0183 (Ada 2012 feature)
16728 Aspect specifications have been fully implemented except for pre and post-
16729 conditions, and type invariants, which have their own separate AI's. All
16730 forms of declarations listed in the AI are supported. The following is a
16731 list of the aspects supported (with GNAT implementation aspects marked)
16733 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
16734 @item @code{Ada_2005} @tab -- GNAT
16735 @item @code{Ada_2012} @tab -- GNAT
16736 @item @code{Address} @tab
16737 @item @code{Alignment} @tab
16738 @item @code{Atomic} @tab
16739 @item @code{Atomic_Components} @tab
16740 @item @code{Bit_Order} @tab
16741 @item @code{Component_Size} @tab
16742 @item @code{Discard_Names} @tab
16743 @item @code{External_Tag} @tab
16744 @item @code{Favor_Top_Level} @tab -- GNAT
16745 @item @code{Inline} @tab
16746 @item @code{Inline_Always} @tab -- GNAT
16747 @item @code{Invariant} @tab
16748 @item @code{Machine_Radix} @tab
16749 @item @code{No_Return} @tab
16750 @item @code{Object_Size} @tab -- GNAT
16751 @item @code{Pack} @tab
16752 @item @code{Persistent_BSS} @tab -- GNAT
16753 @item @code{Post} @tab
16754 @item @code{Pre} @tab
16755 @item @code{Predicate} @tab
16756 @item @code{Preelaborable_Initialization} @tab
16757 @item @code{Pure_Function} @tab -- GNAT
16758 @item @code{Shared} @tab -- GNAT
16759 @item @code{Size} @tab
16760 @item @code{Storage_Pool} @tab
16761 @item @code{Storage_Size} @tab
16762 @item @code{Stream_Size} @tab
16763 @item @code{Suppress} @tab
16764 @item @code{Suppress_Debug_Info} @tab -- GNAT
16765 @item @code{Test_Case} @tab -- GNAT
16766 @item @code{Unchecked_Union} @tab
16767 @item @code{Universal_Aliasing} @tab -- GNAT
16768 @item @code{Unmodified} @tab -- GNAT
16769 @item @code{Unreferenced} @tab -- GNAT
16770 @item @code{Unreferenced_Objects} @tab -- GNAT
16771 @item @code{Unsuppress} @tab
16772 @item @code{Value_Size} @tab -- GNAT
16773 @item @code{Volatile} @tab
16774 @item @code{Volatile_Components}
16775 @item @code{Warnings} @tab -- GNAT
16779 Note that for aspects with an expression, e.g. @code{Size}, the expression is
16780 treated like a default expression (visibility is analyzed at the point of
16781 occurrence of the aspect, but evaluation of the expression occurs at the
16782 freeze point of the entity involved.
16785 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
16786 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
16787 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
16788 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
16789 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
16794 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
16795 @cindex AI-0128 (Ada 2012 feature)
16798 If an equality operator ("=") is declared for a type, then the implicitly
16799 declared inequality operator ("/=") is a primitive operation of the type.
16800 This is the only reasonable interpretation, and is the one always implemented
16801 by GNAT, but the RM was not entirely clear in making this point.
16804 RM References: 3.02.03 (6) 6.06 (6)
16807 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
16808 @cindex AI-0003 (Ada 2012 feature)
16811 In Ada 2012, a qualified expression is considered to be syntactically a name,
16812 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
16813 useful in disambiguating some cases of overloading.
16816 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
16820 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
16821 @cindex AI-0120 (Ada 2012 feature)
16824 This is an RM editorial change only. The section that lists objects that are
16825 constant failed to include the current instance of a protected object
16826 within a protected function. This has always been treated as a constant
16830 RM References: 3.03 (21)
16833 @emph{AI-0008 General access to constrained objects (0000-00-00)}
16834 @cindex AI-0008 (Ada 2012 feature)
16837 The wording in the RM implied that if you have a general access to a
16838 constrained object, it could be used to modify the discriminants. This was
16839 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
16840 has always done so in this situation.
16843 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
16847 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
16848 @cindex AI-0093 (Ada 2012 feature)
16851 This is an editorial change only, to make more widespread use of the Ada 2012
16852 ``immutably limited''.
16855 RM References: 3.03 (23.4/3)
16860 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
16861 @cindex AI-0096 (Ada 2012 feature)
16864 In general it is illegal for a type derived from a formal limited type to be
16865 nonlimited. This AI makes an exception to this rule: derivation is legal
16866 if it appears in the private part of the generic, and the formal type is not
16867 tagged. If the type is tagged, the legality check must be applied to the
16868 private part of the package.
16871 RM References: 3.04 (5.1/2) 6.02 (7)
16875 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
16876 @cindex AI-0181 (Ada 2012 feature)
16879 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
16880 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
16881 @code{Image} and @code{Value} attributes for the character types. Strictly
16882 speaking this is an inconsistency with Ada 95, but in practice the use of
16883 these attributes is so obscure that it will not cause problems.
16886 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
16890 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
16891 @cindex AI-0182 (Ada 2012 feature)
16894 This AI allows @code{Character'Value} to accept the string @code{'?'} where
16895 @code{?} is any character including non-graphic control characters. GNAT has
16896 always accepted such strings. It also allows strings such as
16897 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
16898 permission and raises @code{Constraint_Error}, as is certainly still
16902 RM References: 3.05 (56/2)
16906 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
16907 @cindex AI-0214 (Ada 2012 feature)
16910 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
16911 to have default expressions by allowing them when the type is limited. It
16912 is often useful to define a default value for a discriminant even though
16913 it can't be changed by assignment.
16916 RM References: 3.07 (9.1/2) 3.07.02 (3)
16920 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
16921 @cindex AI-0102 (Ada 2012 feature)
16924 It is illegal to assign an anonymous access constant to an anonymous access
16925 variable. The RM did not have a clear rule to prevent this, but GNAT has
16926 always generated an error for this usage.
16929 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
16933 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
16934 @cindex AI-0158 (Ada 2012 feature)
16937 This AI extends the syntax of membership tests to simplify complex conditions
16938 that can be expressed as membership in a subset of values of any type. It
16939 introduces syntax for a list of expressions that may be used in loop contexts
16943 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
16947 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
16948 @cindex AI-0173 (Ada 2012 feature)
16951 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
16952 with the tag of an abstract type, and @code{False} otherwise.
16955 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
16960 @emph{AI-0076 function with controlling result (0000-00-00)}
16961 @cindex AI-0076 (Ada 2012 feature)
16964 This is an editorial change only. The RM defines calls with controlling
16965 results, but uses the term ``function with controlling result'' without an
16966 explicit definition.
16969 RM References: 3.09.02 (2/2)
16973 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
16974 @cindex AI-0126 (Ada 2012 feature)
16977 This AI clarifies dispatching rules, and simply confirms that dispatching
16978 executes the operation of the parent type when there is no explicitly or
16979 implicitly declared operation for the descendant type. This has always been
16980 the case in all versions of GNAT.
16983 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
16987 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
16988 @cindex AI-0097 (Ada 2012 feature)
16991 The RM as written implied that in some cases it was possible to create an
16992 object of an abstract type, by having an abstract extension inherit a non-
16993 abstract constructor from its parent type. This mistake has been corrected
16994 in GNAT and in the RM, and this construct is now illegal.
16997 RM References: 3.09.03 (4/2)
17001 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
17002 @cindex AI-0203 (Ada 2012 feature)
17005 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
17006 permitted such usage.
17009 RM References: 3.09.03 (8/3)
17013 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
17014 @cindex AI-0198 (Ada 2012 feature)
17017 This AI resolves a conflict between two rules involving inherited abstract
17018 operations and predefined operators. If a derived numeric type inherits
17019 an abstract operator, it overrides the predefined one. This interpretation
17020 was always the one implemented in GNAT.
17023 RM References: 3.09.03 (4/3)
17026 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
17027 @cindex AI-0073 (Ada 2012 feature)
17030 This AI covers a number of issues regarding returning abstract types. In
17031 particular generic functions cannot have abstract result types or access
17032 result types designated an abstract type. There are some other cases which
17033 are detailed in the AI. Note that this binding interpretation has not been
17034 retrofitted to operate before Ada 2012 mode, since it caused a significant
17035 number of regressions.
17038 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
17042 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
17043 @cindex AI-0070 (Ada 2012 feature)
17046 This is an editorial change only, there are no testable consequences short of
17047 checking for the absence of generated code for an interface declaration.
17050 RM References: 3.09.04 (18/2)
17054 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
17055 @cindex AI-0208 (Ada 2012 feature)
17058 The wording in the Ada 2005 RM concerning characteristics of incomplete views
17059 was incorrect and implied that some programs intended to be legal were now
17060 illegal. GNAT had never considered such programs illegal, so it has always
17061 implemented the intent of this AI.
17064 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
17068 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
17069 @cindex AI-0162 (Ada 2012 feature)
17072 Incomplete types are made more useful by allowing them to be completed by
17073 private types and private extensions.
17076 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
17081 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
17082 @cindex AI-0098 (Ada 2012 feature)
17085 An unintentional omission in the RM implied some inconsistent restrictions on
17086 the use of anonymous access to subprogram values. These restrictions were not
17087 intentional, and have never been enforced by GNAT.
17090 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
17094 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
17095 @cindex AI-0199 (Ada 2012 feature)
17098 A choice list in a record aggregate can include several components of
17099 (distinct) anonymous access types as long as they have matching designated
17103 RM References: 4.03.01 (16)
17107 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
17108 @cindex AI-0220 (Ada 2012 feature)
17111 This AI addresses a wording problem in the RM that appears to permit some
17112 complex cases of aggregates with non-static discriminants. GNAT has always
17113 implemented the intended semantics.
17116 RM References: 4.03.01 (17)
17119 @emph{AI-0147 Conditional expressions (2009-03-29)}
17120 @cindex AI-0147 (Ada 2012 feature)
17123 Conditional expressions are permitted. The form of such an expression is:
17126 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
17129 The parentheses can be omitted in contexts where parentheses are present
17130 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
17131 clause is omitted, @b{else True} is assumed;
17132 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
17133 @emph{(A implies B)} in standard logic.
17136 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
17137 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
17141 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
17142 @cindex AI-0037 (Ada 2012 feature)
17145 This AI confirms that an association of the form @code{Indx => <>} in an
17146 array aggregate must raise @code{Constraint_Error} if @code{Indx}
17147 is out of range. The RM specified a range check on other associations, but
17148 not when the value of the association was defaulted. GNAT has always inserted
17149 a constraint check on the index value.
17152 RM References: 4.03.03 (29)
17156 @emph{AI-0123 Composability of equality (2010-04-13)}
17157 @cindex AI-0123 (Ada 2012 feature)
17160 Equality of untagged record composes, so that the predefined equality for a
17161 composite type that includes a component of some untagged record type
17162 @code{R} uses the equality operation of @code{R} (which may be user-defined
17163 or predefined). This makes the behavior of untagged records identical to that
17164 of tagged types in this respect.
17166 This change is an incompatibility with previous versions of Ada, but it
17167 corrects a non-uniformity that was often a source of confusion. Analysis of
17168 a large number of industrial programs indicates that in those rare cases
17169 where a composite type had an untagged record component with a user-defined
17170 equality, either there was no use of the composite equality, or else the code
17171 expected the same composability as for tagged types, and thus had a bug that
17172 would be fixed by this change.
17175 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
17180 @emph{AI-0088 The value of exponentiation (0000-00-00)}
17181 @cindex AI-0088 (Ada 2012 feature)
17184 This AI clarifies the equivalence rule given for the dynamic semantics of
17185 exponentiation: the value of the operation can be obtained by repeated
17186 multiplication, but the operation can be implemented otherwise (for example
17187 using the familiar divide-by-two-and-square algorithm, even if this is less
17188 accurate), and does not imply repeated reads of a volatile base.
17191 RM References: 4.05.06 (11)
17194 @emph{AI-0188 Case expressions (2010-01-09)}
17195 @cindex AI-0188 (Ada 2012 feature)
17198 Case expressions are permitted. This allows use of constructs such as:
17200 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
17204 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
17207 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
17208 @cindex AI-0104 (Ada 2012 feature)
17211 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
17212 @code{Constraint_Error} because the default value of the allocated object is
17213 @b{null}. This useless construct is illegal in Ada 2012.
17216 RM References: 4.08 (2)
17219 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
17220 @cindex AI-0157 (Ada 2012 feature)
17223 Allocation and Deallocation from an empty storage pool (i.e. allocation or
17224 deallocation of a pointer for which a static storage size clause of zero
17225 has been given) is now illegal and is detected as such. GNAT
17226 previously gave a warning but not an error.
17229 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
17232 @emph{AI-0179 Statement not required after label (2010-04-10)}
17233 @cindex AI-0179 (Ada 2012 feature)
17236 It is not necessary to have a statement following a label, so a label
17237 can appear at the end of a statement sequence without the need for putting a
17238 null statement afterwards, but it is not allowable to have only labels and
17239 no real statements in a statement sequence.
17242 RM References: 5.01 (2)
17246 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
17247 @cindex AI-139-2 (Ada 2012 feature)
17250 The new syntax for iterating over arrays and containers is now implemented.
17251 Iteration over containers is for now limited to read-only iterators. Only
17252 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
17255 RM References: 5.05
17258 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
17259 @cindex AI-0134 (Ada 2012 feature)
17262 For full conformance, the profiles of anonymous-access-to-subprogram
17263 parameters must match. GNAT has always enforced this rule.
17266 RM References: 6.03.01 (18)
17269 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
17270 @cindex AI-0207 (Ada 2012 feature)
17273 This AI confirms that access_to_constant indication must match for mode
17274 conformance. This was implemented in GNAT when the qualifier was originally
17275 introduced in Ada 2005.
17278 RM References: 6.03.01 (16/2)
17282 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
17283 @cindex AI-0046 (Ada 2012 feature)
17286 For full conformance, in the case of access parameters, the null exclusion
17287 must match (either both or neither must have @code{@b{not null}}).
17290 RM References: 6.03.02 (18)
17294 @emph{AI-0118 The association of parameter associations (0000-00-00)}
17295 @cindex AI-0118 (Ada 2012 feature)
17298 This AI clarifies the rules for named associations in subprogram calls and
17299 generic instantiations. The rules have been in place since Ada 83.
17302 RM References: 6.04.01 (2) 12.03 (9)
17306 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
17307 @cindex AI-0196 (Ada 2012 feature)
17310 Null exclusion checks are not made for @code{@b{out}} parameters when
17311 evaluating the actual parameters. GNAT has never generated these checks.
17314 RM References: 6.04.01 (13)
17317 @emph{AI-0015 Constant return objects (0000-00-00)}
17318 @cindex AI-0015 (Ada 2012 feature)
17321 The return object declared in an @i{extended_return_statement} may be
17322 declared constant. This was always intended, and GNAT has always allowed it.
17325 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
17330 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
17331 @cindex AI-0032 (Ada 2012 feature)
17334 If a function returns a class-wide type, the object of an extended return
17335 statement can be declared with a specific type that is covered by the class-
17336 wide type. This has been implemented in GNAT since the introduction of
17337 extended returns. Note AI-0103 complements this AI by imposing matching
17338 rules for constrained return types.
17341 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
17345 @emph{AI-0103 Static matching for extended return (2010-07-23)}
17346 @cindex AI-0103 (Ada 2012 feature)
17349 If the return subtype of a function is an elementary type or a constrained
17350 type, the subtype indication in an extended return statement must match
17351 statically this return subtype.
17354 RM References: 6.05 (5.2/2)
17358 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
17359 @cindex AI-0058 (Ada 2012 feature)
17362 The RM had some incorrect wording implying wrong treatment of abnormal
17363 completion in an extended return. GNAT has always implemented the intended
17364 correct semantics as described by this AI.
17367 RM References: 6.05 (22/2)
17371 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
17372 @cindex AI-0050 (Ada 2012 feature)
17375 The implementation permissions for raising @code{Constraint_Error} early on a function call when it was clear an exception would be raised were over-permissive and allowed mishandling of discriminants in some cases. GNAT did
17376 not take advantage of these incorrect permissions in any case.
17379 RM References: 6.05 (24/2)
17383 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
17384 @cindex AI-0125 (Ada 2012 feature)
17387 In Ada 2012, the declaration of a primitive operation of a type extension
17388 or private extension can also override an inherited primitive that is not
17389 visible at the point of this declaration.
17392 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
17395 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
17396 @cindex AI-0062 (Ada 2012 feature)
17399 A full constant may have a null exclusion even if its associated deferred
17400 constant does not. GNAT has always allowed this.
17403 RM References: 7.04 (6/2) 7.04 (7.1/2)
17407 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
17408 @cindex AI-0178 (Ada 2012 feature)
17411 This AI clarifies the role of incomplete views and plugs an omission in the
17412 RM. GNAT always correctly restricted the use of incomplete views and types.
17415 RM References: 7.05 (3/2) 7.05 (6/2)
17418 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
17419 @cindex AI-0087 (Ada 2012 feature)
17422 The actual for a formal nonlimited derived type cannot be limited. In
17423 particular, a formal derived type that extends a limited interface but which
17424 is not explicitly limited cannot be instantiated with a limited type.
17427 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
17430 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
17431 @cindex AI-0099 (Ada 2012 feature)
17434 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
17435 and therefore depends on the run-time characteristics of an object (i.e. its
17436 tag) and not on its nominal type. As the AI indicates: ``we do not expect
17437 this to affect any implementation''.
17440 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
17445 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
17446 @cindex AI-0064 (Ada 2012 feature)
17449 This is an editorial change only. The intended behavior is already checked
17450 by an existing ACATS test, which GNAT has always executed correctly.
17453 RM References: 7.06.01 (17.1/1)
17456 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
17457 @cindex AI-0026 (Ada 2012 feature)
17460 Record representation clauses concerning Unchecked_Union types cannot mention
17461 the discriminant of the type. The type of a component declared in the variant
17462 part of an Unchecked_Union cannot be controlled, have controlled components,
17463 nor have protected or task parts. If an Unchecked_Union type is declared
17464 within the body of a generic unit or its descendants, then the type of a
17465 component declared in the variant part cannot be a formal private type or a
17466 formal private extension declared within the same generic unit.
17469 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
17473 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
17474 @cindex AI-0205 (Ada 2012 feature)
17477 This AI corrects a simple omission in the RM. Return objects have always
17478 been visible within an extended return statement.
17481 RM References: 8.03 (17)
17485 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
17486 @cindex AI-0042 (Ada 2012 feature)
17489 This AI fixes a wording gap in the RM. An operation of a synchronized
17490 interface can be implemented by a protected or task entry, but the abstract
17491 operation is not being overridden in the usual sense, and it must be stated
17492 separately that this implementation is legal. This has always been the case
17496 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
17499 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
17500 @cindex AI-0030 (Ada 2012 feature)
17503 Requeue is permitted to a protected, synchronized or task interface primitive
17504 providing it is known that the overriding operation is an entry. Otherwise
17505 the requeue statement has the same effect as a procedure call. Use of pragma
17506 @code{Implemented} provides a way to impose a static requirement on the
17507 overriding operation by adhering to one of the implementation kinds: entry,
17508 protected procedure or any of the above.
17511 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
17512 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
17516 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
17517 @cindex AI-0201 (Ada 2012 feature)
17520 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
17521 attribute, then individual components may not be addressable by independent
17522 tasks. However, if the representation clause has no effect (is confirming),
17523 then independence is not compromised. Furthermore, in GNAT, specification of
17524 other appropriately addressable component sizes (e.g. 16 for 8-bit
17525 characters) also preserves independence. GNAT now gives very clear warnings
17526 both for the declaration of such a type, and for any assignment to its components.
17529 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
17532 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
17533 @cindex AI-0009 (Ada 2012 feature)
17536 This AI introduces the new pragmas @code{Independent} and
17537 @code{Independent_Components},
17538 which control guaranteeing independence of access to objects and components.
17539 The AI also requires independence not unaffected by confirming rep clauses.
17542 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
17543 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
17547 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
17548 @cindex AI-0072 (Ada 2012 feature)
17551 This AI clarifies that task signalling for reading @code{'Terminated} only
17552 occurs if the result is True. GNAT semantics has always been consistent with
17553 this notion of task signalling.
17556 RM References: 9.10 (6.1/1)
17559 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
17560 @cindex AI-0108 (Ada 2012 feature)
17563 This AI confirms that an incomplete type from a limited view does not have
17564 discriminants. This has always been the case in GNAT.
17567 RM References: 10.01.01 (12.3/2)
17570 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
17571 @cindex AI-0129 (Ada 2012 feature)
17574 This AI clarifies the description of limited views: a limited view of a
17575 package includes only one view of a type that has an incomplete declaration
17576 and a full declaration (there is no possible ambiguity in a client package).
17577 This AI also fixes an omission: a nested package in the private part has no
17578 limited view. GNAT always implemented this correctly.
17581 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
17586 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
17587 @cindex AI-0077 (Ada 2012 feature)
17590 This AI clarifies that a declaration does not include a context clause,
17591 and confirms that it is illegal to have a context in which both a limited
17592 and a nonlimited view of a package are accessible. Such double visibility
17593 was always rejected by GNAT.
17596 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
17599 @emph{AI-0122 Private with and children of generics (0000-00-00)}
17600 @cindex AI-0122 (Ada 2012 feature)
17603 This AI clarifies the visibility of private children of generic units within
17604 instantiations of a parent. GNAT has always handled this correctly.
17607 RM References: 10.01.02 (12/2)
17612 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
17613 @cindex AI-0040 (Ada 2012 feature)
17616 This AI confirms that a limited with clause in a child unit cannot name
17617 an ancestor of the unit. This has always been checked in GNAT.
17620 RM References: 10.01.02 (20/2)
17623 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
17624 @cindex AI-0132 (Ada 2012 feature)
17627 This AI fills a gap in the description of library unit pragmas. The pragma
17628 clearly must apply to a library unit, even if it does not carry the name
17629 of the enclosing unit. GNAT has always enforced the required check.
17632 RM References: 10.01.05 (7)
17636 @emph{AI-0034 Categorization of limited views (0000-00-00)}
17637 @cindex AI-0034 (Ada 2012 feature)
17640 The RM makes certain limited with clauses illegal because of categorization
17641 considerations, when the corresponding normal with would be legal. This is
17642 not intended, and GNAT has always implemented the recommended behavior.
17645 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
17649 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
17650 @cindex AI-0035 (Ada 2012 feature)
17653 This AI remedies some inconsistencies in the legality rules for Pure units.
17654 Derived access types are legal in a pure unit (on the assumption that the
17655 rule for a zero storage pool size has been enforced on the ancestor type).
17656 The rules are enforced in generic instances and in subunits. GNAT has always
17657 implemented the recommended behavior.
17660 RM References: 10.02.01 (15.1/2) 10.02.01 (15.4/2) 10.02.01 (15.5/2) 10.02.01 (17/2)
17664 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
17665 @cindex AI-0219 (Ada 2012 feature)
17668 This AI refines the rules for the cases with limited parameters which do not
17669 allow the implementations to omit ``redundant''. GNAT now properly conforms
17670 to the requirements of this binding interpretation.
17673 RM References: 10.02.01 (18/2)
17676 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
17677 @cindex AI-0043 (Ada 2012 feature)
17680 This AI covers various omissions in the RM regarding the raising of
17681 exceptions. GNAT has always implemented the intended semantics.
17684 RM References: 11.04.01 (10.1/2) 11 (2)
17688 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
17689 @cindex AI-0200 (Ada 2012 feature)
17692 This AI plugs a gap in the RM which appeared to allow some obviously intended
17693 illegal instantiations. GNAT has never allowed these instantiations.
17696 RM References: 12.07 (16)
17700 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
17701 @cindex AI-0112 (Ada 2012 feature)
17704 This AI concerns giving names to various representation aspects, but the
17705 practical effect is simply to make the use of duplicate
17706 @code{Atomic}[@code{_Components}],
17707 @code{Volatile}[@code{_Components}] and
17708 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
17709 now performs this required check.
17712 RM References: 13.01 (8)
17715 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
17716 @cindex AI-0106 (Ada 2012 feature)
17719 The RM appeared to allow representation pragmas on generic formal parameters,
17720 but this was not intended, and GNAT has never permitted this usage.
17723 RM References: 13.01 (9.1/1)
17727 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
17728 @cindex AI-0012 (Ada 2012 feature)
17731 It is now illegal to give an inappropriate component size or a pragma
17732 @code{Pack} that attempts to change the component size in the case of atomic
17733 or aliased components. Previously GNAT ignored such an attempt with a
17737 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
17741 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
17742 @cindex AI-0039 (Ada 2012 feature)
17745 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
17746 for stream attributes, but these were never useful and are now illegal. GNAT
17747 has always regarded such expressions as illegal.
17750 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
17754 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
17755 @cindex AI-0095 (Ada 2012 feature)
17758 The prefix of @code{'Address} cannot statically denote a subprogram with
17759 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
17760 @code{Program_Error} if the prefix denotes a subprogram with convention
17764 RM References: 13.03 (11/1)
17768 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
17769 @cindex AI-0116 (Ada 2012 feature)
17772 This AI requires that the alignment of a class-wide object be no greater
17773 than the alignment of any type in the class. GNAT has always followed this
17777 RM References: 13.03 (29) 13.11 (16)
17781 @emph{AI-0146 Type invariants (2009-09-21)}
17782 @cindex AI-0146 (Ada 2012 feature)
17785 Type invariants may be specified for private types using the aspect notation.
17786 Aspect @code{Invariant} may be specified for any private type,
17787 @code{Invariant'Class} can
17788 only be specified for tagged types, and is inherited by any descendent of the
17789 tagged types. The invariant is a boolean expression that is tested for being
17790 true in the following situations: conversions to the private type, object
17791 declarations for the private type that are default initialized, and
17793 parameters and returned result on return from any primitive operation for
17794 the type that is visible to a client.
17797 RM References: 13.03.03 (00)
17800 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
17801 @cindex AI-0078 (Ada 2012 feature)
17804 In Ada 2012, compilers are required to support unchecked conversion where the
17805 target alignment is a multiple of the source alignment. GNAT always supported
17806 this case (and indeed all cases of differing alignments, doing copies where
17807 required if the alignment was reduced).
17810 RM References: 13.09 (7)
17814 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
17815 @cindex AI-0195 (Ada 2012 feature)
17818 The handling of invalid values is now designated to be implementation
17819 defined. This is a documentation change only, requiring Annex M in the GNAT
17820 Reference Manual to document this handling.
17821 In GNAT, checks for invalid values are made
17822 only when necessary to avoid erroneous behavior. Operations like assignments
17823 which cannot cause erroneous behavior ignore the possibility of invalid
17824 values and do not do a check. The date given above applies only to the
17825 documentation change, this behavior has always been implemented by GNAT.
17828 RM References: 13.09.01 (10)
17831 @emph{AI-0193 Alignment of allocators (2010-09-16)}
17832 @cindex AI-0193 (Ada 2012 feature)
17835 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
17836 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
17840 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
17841 13.11.01 (2) 13.11.01 (3)
17845 @emph{AI-0177 Parameterized expressions (2010-07-10)}
17846 @cindex AI-0177 (Ada 2012 feature)
17849 The new Ada 2012 notion of parameterized expressions is implemented. The form
17852 @i{function specification} @b{is} (@i{expression})
17856 This is exactly equivalent to the
17857 corresponding function body that returns the expression, but it can appear
17858 in a package spec. Note that the expression must be parenthesized.
17861 RM References: 13.11.01 (3/2)
17864 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
17865 @cindex AI-0033 (Ada 2012 feature)
17868 Neither of these two pragmas may appear within a generic template, because
17869 the generic might be instantiated at other than the library level.
17872 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
17876 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
17877 @cindex AI-0161 (Ada 2012 feature)
17880 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
17881 of the default stream attributes for elementary types. If this restriction is
17882 in force, then it is necessary to provide explicit subprograms for any
17883 stream attributes used.
17886 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
17889 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
17890 @cindex AI-0194 (Ada 2012 feature)
17893 The @code{Stream_Size} attribute returns the default number of bits in the
17894 stream representation of the given type.
17895 This value is not affected by the presence
17896 of stream subprogram attributes for the type. GNAT has always implemented
17897 this interpretation.
17900 RM References: 13.13.02 (1.2/2)
17903 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
17904 @cindex AI-0109 (Ada 2012 feature)
17907 This AI is an editorial change only. It removes the need for a tag check
17908 that can never fail.
17911 RM References: 13.13.02 (34/2)
17914 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
17915 @cindex AI-0007 (Ada 2012 feature)
17918 The RM as written appeared to limit the possibilities of declaring read
17919 attribute procedures for private scalar types. This limitation was not
17920 intended, and has never been enforced by GNAT.
17923 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
17927 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
17928 @cindex AI-0065 (Ada 2012 feature)
17931 This AI clarifies the fact that all remote access types support external
17932 streaming. This fixes an obvious oversight in the definition of the
17933 language, and GNAT always implemented the intended correct rules.
17936 RM References: 13.13.02 (52/2)
17939 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
17940 @cindex AI-0019 (Ada 2012 feature)
17943 The RM suggests that primitive subprograms of a specific tagged type are
17944 frozen when the tagged type is frozen. This would be an incompatible change
17945 and is not intended. GNAT has never attempted this kind of freezing and its
17946 behavior is consistent with the recommendation of this AI.
17949 RM References: 13.14 (2) 13.14 (3/1) 13.14 (8.1/1) 13.14 (10) 13.14 (14) 13.14 (15.1/2)
17952 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
17953 @cindex AI-0017 (Ada 2012 feature)
17956 So-called ``Taft-amendment types'' (i.e., types that are completed in package
17957 bodies) are not frozen by the occurrence of bodies in the
17958 enclosing declarative part. GNAT always implemented this properly.
17961 RM References: 13.14 (3/1)
17965 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
17966 @cindex AI-0060 (Ada 2012 feature)
17969 This AI extends the definition of remote access types to include access
17970 to limited, synchronized, protected or task class-wide interface types.
17971 GNAT already implemented this extension.
17974 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
17977 @emph{AI-0114 Classification of letters (0000-00-00)}
17978 @cindex AI-0114 (Ada 2012 feature)
17981 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
17982 181 (@code{MICRO SIGN}), and
17983 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
17984 lower case letters by Unicode.
17985 However, they are not allowed in identifiers, and they
17986 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
17987 This behavior is consistent with that defined in Ada 95.
17990 RM References: A.03.02 (59) A.04.06 (7)
17994 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
17995 @cindex AI-0185 (Ada 2012 feature)
17998 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
17999 classification functions for @code{Wide_Character} and
18000 @code{Wide_Wide_Character}, as well as providing
18001 case folding routines for @code{Wide_[Wide_]Character} and
18002 @code{Wide_[Wide_]String}.
18005 RM References: A.03.05 (0) A.03.06 (0)
18009 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
18010 @cindex AI-0031 (Ada 2012 feature)
18013 A new version of @code{Find_Token} is added to all relevant string packages,
18014 with an extra parameter @code{From}. Instead of starting at the first
18015 character of the string, the search for a matching Token starts at the
18016 character indexed by the value of @code{From}.
18017 These procedures are available in all versions of Ada
18018 but if used in versions earlier than Ada 2012 they will generate a warning
18019 that an Ada 2012 subprogram is being used.
18022 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
18027 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
18028 @cindex AI-0056 (Ada 2012 feature)
18031 The wording in the Ada 2005 RM implied an incompatible handling of the
18032 @code{Index} functions, resulting in raising an exception instead of
18033 returning zero in some situations.
18034 This was not intended and has been corrected.
18035 GNAT always returned zero, and is thus consistent with this AI.
18038 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
18042 @emph{AI-0137 String encoding package (2010-03-25)}
18043 @cindex AI-0137 (Ada 2012 feature)
18046 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
18047 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
18048 and @code{Wide_Wide_Strings} have been
18049 implemented. These packages (whose documentation can be found in the spec
18050 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
18051 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
18052 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
18053 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
18054 UTF-16), as well as conversions between the different UTF encodings. With
18055 the exception of @code{Wide_Wide_Strings}, these packages are available in
18056 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
18057 The @code{Wide_Wide_Strings package}
18058 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
18059 mode since it uses @code{Wide_Wide_Character}).
18062 RM References: A.04.11
18065 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
18066 @cindex AI-0038 (Ada 2012 feature)
18069 These are minor errors in the description on three points. The intent on
18070 all these points has always been clear, and GNAT has always implemented the
18071 correct intended semantics.
18074 RM References: A.10.05 (37) A.10.07 (8/1) A.10.07 (10) A.10.07 (12) A.10.08 (10) A.10.08 (24)
18077 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
18078 @cindex AI-0044 (Ada 2012 feature)
18081 This AI places restrictions on allowed instantiations of generic containers.
18082 These restrictions are not checked by the compiler, so there is nothing to
18083 change in the implementation. This affects only the RM documentation.
18086 RM References: A.18 (4/2) A.18.02 (231/2) A.18.03 (145/2) A.18.06 (56/2) A.18.08 (66/2) A.18.09 (79/2) A.18.26 (5/2) A.18.26 (9/2)
18089 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
18090 @cindex AI-0127 (Ada 2012 feature)
18093 This package provides an interface for identifying the current locale.
18096 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
18097 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
18102 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
18103 @cindex AI-0002 (Ada 2012 feature)
18106 The compiler is not required to support exporting an Ada subprogram with
18107 convention C if there are parameters or a return type of an unconstrained
18108 array type (such as @code{String}). GNAT allows such declarations but
18109 generates warnings. It is possible, but complicated, to write the
18110 corresponding C code and certainly such code would be specific to GNAT and
18114 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
18118 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
18119 @cindex AI05-0216 (Ada 2012 feature)
18122 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
18123 forbid tasks declared locally within subprograms, or functions returning task
18124 objects, and that is the implementation that GNAT has always provided.
18125 However the language in the RM was not sufficiently clear on this point.
18126 Thus this is a documentation change in the RM only.
18129 RM References: D.07 (3/3)
18132 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
18133 @cindex AI-0211 (Ada 2012 feature)
18136 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
18137 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
18140 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
18143 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
18144 @cindex AI-0190 (Ada 2012 feature)
18147 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
18148 used to control storage pools globally.
18149 In particular, you can force every access
18150 type that is used for allocation (@b{new}) to have an explicit storage pool,
18151 or you can declare a pool globally to be used for all access types that lack
18155 RM References: D.07 (8)
18158 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
18159 @cindex AI-0189 (Ada 2012 feature)
18162 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
18163 which says that no dynamic allocation will occur once elaboration is
18165 In general this requires a run-time check, which is not required, and which
18166 GNAT does not attempt. But the static cases of allocators in a task body or
18167 in the body of the main program are detected and flagged at compile or bind
18171 RM References: D.07 (19.1/2) H.04 (23.3/2)
18174 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
18175 @cindex AI-0171 (Ada 2012 feature)
18178 A new package @code{System.Multiprocessors} is added, together with the
18179 definition of pragma @code{CPU} for controlling task affinity. A new no
18180 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
18181 is added to the Ravenscar profile.
18184 RM References: D.13.01 (4/2) D.16
18188 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
18189 @cindex AI-0210 (Ada 2012 feature)
18192 This is a documentation only issue regarding wording of metric requirements,
18193 that does not affect the implementation of the compiler.
18196 RM References: D.15 (24/2)
18200 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
18201 @cindex AI-0206 (Ada 2012 feature)
18204 Remote types packages are now allowed to depend on preelaborated packages.
18205 This was formerly considered illegal.
18208 RM References: E.02.02 (6)
18213 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
18214 @cindex AI-0152 (Ada 2012 feature)
18217 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
18218 where the type of the returned value is an anonymous access type.
18221 RM References: H.04 (8/1)
18225 @node Obsolescent Features
18226 @chapter Obsolescent Features
18229 This chapter describes features that are provided by GNAT, but are
18230 considered obsolescent since there are preferred ways of achieving
18231 the same effect. These features are provided solely for historical
18232 compatibility purposes.
18235 * pragma No_Run_Time::
18236 * pragma Ravenscar::
18237 * pragma Restricted_Run_Time::
18240 @node pragma No_Run_Time
18241 @section pragma No_Run_Time
18243 The pragma @code{No_Run_Time} is used to achieve an affect similar
18244 to the use of the "Zero Foot Print" configurable run time, but without
18245 requiring a specially configured run time. The result of using this
18246 pragma, which must be used for all units in a partition, is to restrict
18247 the use of any language features requiring run-time support code. The
18248 preferred usage is to use an appropriately configured run-time that
18249 includes just those features that are to be made accessible.
18251 @node pragma Ravenscar
18252 @section pragma Ravenscar
18254 The pragma @code{Ravenscar} has exactly the same effect as pragma
18255 @code{Profile (Ravenscar)}. The latter usage is preferred since it
18256 is part of the new Ada 2005 standard.
18258 @node pragma Restricted_Run_Time
18259 @section pragma Restricted_Run_Time
18261 The pragma @code{Restricted_Run_Time} has exactly the same effect as
18262 pragma @code{Profile (Restricted)}. The latter usage is
18263 preferred since the Ada 2005 pragma @code{Profile} is intended for
18264 this kind of implementation dependent addition.
18267 @c GNU Free Documentation License
18269 @node Index,,GNU Free Documentation License, Top