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. This pragma may be used as
1018 a configuration pragma.
1021 @unnumberedsec Pragma Assert
1025 @smallexample @c ada
1028 [, string_EXPRESSION]);
1032 The effect of this pragma depends on whether the corresponding command
1033 line switch is set to activate assertions. The pragma expands into code
1034 equivalent to the following:
1036 @smallexample @c ada
1037 if assertions-enabled then
1038 if not boolean_EXPRESSION then
1039 System.Assertions.Raise_Assert_Failure
1040 (string_EXPRESSION);
1046 The string argument, if given, is the message that will be associated
1047 with the exception occurrence if the exception is raised. If no second
1048 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1049 where @var{file} is the name of the source file containing the assert,
1050 and @var{nnn} is the line number of the assert. A pragma is not a
1051 statement, so if a statement sequence contains nothing but a pragma
1052 assert, then a null statement is required in addition, as in:
1054 @smallexample @c ada
1057 pragma Assert (K > 3, "Bad value for K");
1063 Note that, as with the @code{if} statement to which it is equivalent, the
1064 type of the expression is either @code{Standard.Boolean}, or any type derived
1065 from this standard type.
1067 If assertions are disabled (switch @option{-gnata} not used), then there
1068 is no run-time effect (and in particular, any side effects from the
1069 expression will not occur at run time). (The expression is still
1070 analyzed at compile time, and may cause types to be frozen if they are
1071 mentioned here for the first time).
1073 If assertions are enabled, then the given expression is tested, and if
1074 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1075 which results in the raising of @code{Assert_Failure} with the given message.
1077 You should generally avoid side effects in the expression arguments of
1078 this pragma, because these side effects will turn on and off with the
1079 setting of the assertions mode, resulting in assertions that have an
1080 effect on the program. However, the expressions are analyzed for
1081 semantic correctness whether or not assertions are enabled, so turning
1082 assertions on and off cannot affect the legality of a program.
1084 Note that the implementation defined policy @code{DISABLE}, given in a
1085 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1087 Note: this is a standard language-defined pragma in versions
1088 of Ada from 2005 on. In GNAT, it is implemented in all versions
1089 of Ada, and the DISABLE policy is an implementation-defined
1093 @node Pragma Assertion_Policy
1094 @unnumberedsec Pragma Assertion_Policy
1095 @findex Debug_Policy
1099 @smallexample @c ada
1100 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1104 If the argument is @code{CHECK}, then pragma @code{Assert} is enabled.
1105 If the argument is @code{IGNORE}, then pragma @code{Assert} is ignored.
1106 This pragma overrides the effect of the @option{-gnata} switch on the
1109 The implementation defined policy @code{DISABLE} is like
1110 @code{IGNORE} except that it completely disables semantic
1111 checking of the argument to @code{pragma Assert}. This may
1112 be useful when the pragma argument references subprograms
1113 in a with'ed package which is replaced by a dummy package
1114 for the final build.
1116 Note: this is a standard language-defined pragma in versions
1117 of Ada from 2005 on. In GNAT, it is implemented in all versions
1118 of Ada, and the DISABLE policy is an implementation-defined
1121 @node Pragma Assume_No_Invalid_Values
1122 @unnumberedsec Pragma Assume_No_Invalid_Values
1123 @findex Assume_No_Invalid_Values
1124 @cindex Invalid representations
1125 @cindex Invalid values
1128 @smallexample @c ada
1129 pragma Assume_No_Invalid_Values (On | Off);
1133 This is a configuration pragma that controls the assumptions made by the
1134 compiler about the occurrence of invalid representations (invalid values)
1137 The default behavior (corresponding to an Off argument for this pragma), is
1138 to assume that values may in general be invalid unless the compiler can
1139 prove they are valid. Consider the following example:
1141 @smallexample @c ada
1142 V1 : Integer range 1 .. 10;
1143 V2 : Integer range 11 .. 20;
1145 for J in V2 .. V1 loop
1151 if V1 and V2 have valid values, then the loop is known at compile
1152 time not to execute since the lower bound must be greater than the
1153 upper bound. However in default mode, no such assumption is made,
1154 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1155 is given, the compiler will assume that any occurrence of a variable
1156 other than in an explicit @code{'Valid} test always has a valid
1157 value, and the loop above will be optimized away.
1159 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1160 you know your code is free of uninitialized variables and other
1161 possible sources of invalid representations, and may result in
1162 more efficient code. A program that accesses an invalid representation
1163 with this pragma in effect is erroneous, so no guarantees can be made
1166 It is peculiar though permissible to use this pragma in conjunction
1167 with validity checking (-gnatVa). In such cases, accessing invalid
1168 values will generally give an exception, though formally the program
1169 is erroneous so there are no guarantees that this will always be the
1170 case, and it is recommended that these two options not be used together.
1172 @node Pragma Ast_Entry
1173 @unnumberedsec Pragma Ast_Entry
1178 @smallexample @c ada
1179 pragma AST_Entry (entry_IDENTIFIER);
1183 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1184 argument is the simple name of a single entry; at most one @code{AST_Entry}
1185 pragma is allowed for any given entry. This pragma must be used in
1186 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1187 the entry declaration and in the same task type specification or single task
1188 as the entry to which it applies. This pragma specifies that the given entry
1189 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1190 resulting from an OpenVMS system service call. The pragma does not affect
1191 normal use of the entry. For further details on this pragma, see the
1192 DEC Ada Language Reference Manual, section 9.12a.
1194 @node Pragma C_Pass_By_Copy
1195 @unnumberedsec Pragma C_Pass_By_Copy
1196 @cindex Passing by copy
1197 @findex C_Pass_By_Copy
1200 @smallexample @c ada
1201 pragma C_Pass_By_Copy
1202 ([Max_Size =>] static_integer_EXPRESSION);
1206 Normally the default mechanism for passing C convention records to C
1207 convention subprograms is to pass them by reference, as suggested by RM
1208 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1209 this default, by requiring that record formal parameters be passed by
1210 copy if all of the following conditions are met:
1214 The size of the record type does not exceed the value specified for
1217 The record type has @code{Convention C}.
1219 The formal parameter has this record type, and the subprogram has a
1220 foreign (non-Ada) convention.
1224 If these conditions are met the argument is passed by copy, i.e.@: in a
1225 manner consistent with what C expects if the corresponding formal in the
1226 C prototype is a struct (rather than a pointer to a struct).
1228 You can also pass records by copy by specifying the convention
1229 @code{C_Pass_By_Copy} for the record type, or by using the extended
1230 @code{Import} and @code{Export} pragmas, which allow specification of
1231 passing mechanisms on a parameter by parameter basis.
1234 @unnumberedsec Pragma Check
1236 @cindex Named assertions
1240 @smallexample @c ada
1242 [Name =>] Identifier,
1243 [Check =>] Boolean_EXPRESSION
1244 [, [Message =>] string_EXPRESSION] );
1248 This pragma is similar to the predefined pragma @code{Assert} except that an
1249 extra identifier argument is present. In conjunction with pragma
1250 @code{Check_Policy}, this can be used to define groups of assertions that can
1251 be independently controlled. The identifier @code{Assertion} is special, it
1252 refers to the normal set of pragma @code{Assert} statements. The identifiers
1253 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1254 names, so these three names would normally not be used directly in a pragma
1257 Checks introduced by this pragma are normally deactivated by default. They can
1258 be activated either by the command line option @option{-gnata}, which turns on
1259 all checks, or individually controlled using pragma @code{Check_Policy}.
1261 @node Pragma Check_Name
1262 @unnumberedsec Pragma Check_Name
1263 @cindex Defining check names
1264 @cindex Check names, defining
1268 @smallexample @c ada
1269 pragma Check_Name (check_name_IDENTIFIER);
1273 This is a configuration pragma that defines a new implementation
1274 defined check name (unless IDENTIFIER matches one of the predefined
1275 check names, in which case the pragma has no effect). Check names
1276 are global to a partition, so if two or more configuration pragmas
1277 are present in a partition mentioning the same name, only one new
1278 check name is introduced.
1280 An implementation defined check name introduced with this pragma may
1281 be used in only three contexts: @code{pragma Suppress},
1282 @code{pragma Unsuppress},
1283 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1284 any of these three cases, the check name must be visible. A check
1285 name is visible if it is in the configuration pragmas applying to
1286 the current unit, or if it appears at the start of any unit that
1287 is part of the dependency set of the current unit (e.g., units that
1288 are mentioned in @code{with} clauses).
1290 @node Pragma Check_Policy
1291 @unnumberedsec Pragma Check_Policy
1292 @cindex Controlling assertions
1293 @cindex Assertions, control
1294 @cindex Check pragma control
1295 @cindex Named assertions
1299 @smallexample @c ada
1301 ([Name =>] Identifier,
1302 [Policy =>] POLICY_IDENTIFIER);
1304 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1308 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1309 except that it controls sets of named assertions introduced using the
1310 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1311 @code{Assertion_Policy}) can be used within a declarative part, in which case
1312 it controls the status to the end of the corresponding construct (in a manner
1313 identical to pragma @code{Suppress)}.
1315 The identifier given as the first argument corresponds to a name used in
1316 associated @code{Check} pragmas. For example, if the pragma:
1318 @smallexample @c ada
1319 pragma Check_Policy (Critical_Error, OFF);
1323 is given, then subsequent @code{Check} pragmas whose first argument is also
1324 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1325 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1326 @code{Check_Policy} with this identifier is similar to the normal
1327 @code{Assertion_Policy} pragma except that it can appear within a
1330 The special identifiers @code{Precondition} and @code{Postcondition} control
1331 the status of preconditions and postconditions. If a @code{Precondition} pragma
1332 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1333 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1334 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1337 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1338 to turn on corresponding checks. The default for a set of checks for which no
1339 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1340 @option{-gnata} is given, which turns on all checks by default.
1342 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1343 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1344 compatibility with the standard @code{Assertion_Policy} pragma.
1346 The implementation defined policy @code{DISABLE} is like
1347 @code{OFF} except that it completely disables semantic
1348 checking of the argument to the corresponding class of
1349 pragmas. This may be useful when the pragma arguments reference
1350 subprograms in a with'ed package which is replaced by a dummy package
1351 for the final build.
1353 @node Pragma Comment
1354 @unnumberedsec Pragma Comment
1359 @smallexample @c ada
1360 pragma Comment (static_string_EXPRESSION);
1364 This is almost identical in effect to pragma @code{Ident}. It allows the
1365 placement of a comment into the object file and hence into the
1366 executable file if the operating system permits such usage. The
1367 difference is that @code{Comment}, unlike @code{Ident}, has
1368 no limitations on placement of the pragma (it can be placed
1369 anywhere in the main source unit), and if more than one pragma
1370 is used, all comments are retained.
1372 @node Pragma Common_Object
1373 @unnumberedsec Pragma Common_Object
1374 @findex Common_Object
1378 @smallexample @c ada
1379 pragma Common_Object (
1380 [Internal =>] LOCAL_NAME
1381 [, [External =>] EXTERNAL_SYMBOL]
1382 [, [Size =>] EXTERNAL_SYMBOL] );
1386 | static_string_EXPRESSION
1390 This pragma enables the shared use of variables stored in overlaid
1391 linker areas corresponding to the use of @code{COMMON}
1392 in Fortran. The single
1393 object @var{LOCAL_NAME} is assigned to the area designated by
1394 the @var{External} argument.
1395 You may define a record to correspond to a series
1396 of fields. The @var{Size} argument
1397 is syntax checked in GNAT, but otherwise ignored.
1399 @code{Common_Object} is not supported on all platforms. If no
1400 support is available, then the code generator will issue a message
1401 indicating that the necessary attribute for implementation of this
1402 pragma is not available.
1404 @node Pragma Compile_Time_Error
1405 @unnumberedsec Pragma Compile_Time_Error
1406 @findex Compile_Time_Error
1410 @smallexample @c ada
1411 pragma Compile_Time_Error
1412 (boolean_EXPRESSION, static_string_EXPRESSION);
1416 This pragma can be used to generate additional compile time
1418 is particularly useful in generics, where errors can be issued for
1419 specific problematic instantiations. The first parameter is a boolean
1420 expression. The pragma is effective only if the value of this expression
1421 is known at compile time, and has the value True. The set of expressions
1422 whose values are known at compile time includes all static boolean
1423 expressions, and also other values which the compiler can determine
1424 at compile time (e.g., the size of a record type set by an explicit
1425 size representation clause, or the value of a variable which was
1426 initialized to a constant and is known not to have been modified).
1427 If these conditions are met, an error message is generated using
1428 the value given as the second argument. This string value may contain
1429 embedded ASCII.LF characters to break the message into multiple lines.
1431 @node Pragma Compile_Time_Warning
1432 @unnumberedsec Pragma Compile_Time_Warning
1433 @findex Compile_Time_Warning
1437 @smallexample @c ada
1438 pragma Compile_Time_Warning
1439 (boolean_EXPRESSION, static_string_EXPRESSION);
1443 Same as pragma Compile_Time_Error, except a warning is issued instead
1444 of an error message. Note that if this pragma is used in a package that
1445 is with'ed by a client, the client will get the warning even though it
1446 is issued by a with'ed package (normally warnings in with'ed units are
1447 suppressed, but this is a special exception to that rule).
1449 One typical use is within a generic where compile time known characteristics
1450 of formal parameters are tested, and warnings given appropriately. Another use
1451 with a first parameter of True is to warn a client about use of a package,
1452 for example that it is not fully implemented.
1454 @node Pragma Compiler_Unit
1455 @unnumberedsec Pragma Compiler_Unit
1456 @findex Compiler_Unit
1460 @smallexample @c ada
1461 pragma Compiler_Unit;
1465 This pragma is intended only for internal use in the GNAT run-time library.
1466 It indicates that the unit is used as part of the compiler build. The effect
1467 is to disallow constructs (raise with message, conditional expressions etc)
1468 that would cause trouble when bootstrapping using an older version of GNAT.
1469 For the exact list of restrictions, see the compiler sources and references
1470 to Is_Compiler_Unit.
1472 @node Pragma Complete_Representation
1473 @unnumberedsec Pragma Complete_Representation
1474 @findex Complete_Representation
1478 @smallexample @c ada
1479 pragma Complete_Representation;
1483 This pragma must appear immediately within a record representation
1484 clause. Typical placements are before the first component clause
1485 or after the last component clause. The effect is to give an error
1486 message if any component is missing a component clause. This pragma
1487 may be used to ensure that a record representation clause is
1488 complete, and that this invariant is maintained if fields are
1489 added to the record in the future.
1491 @node Pragma Complex_Representation
1492 @unnumberedsec Pragma Complex_Representation
1493 @findex Complex_Representation
1497 @smallexample @c ada
1498 pragma Complex_Representation
1499 ([Entity =>] LOCAL_NAME);
1503 The @var{Entity} argument must be the name of a record type which has
1504 two fields of the same floating-point type. The effect of this pragma is
1505 to force gcc to use the special internal complex representation form for
1506 this record, which may be more efficient. Note that this may result in
1507 the code for this type not conforming to standard ABI (application
1508 binary interface) requirements for the handling of record types. For
1509 example, in some environments, there is a requirement for passing
1510 records by pointer, and the use of this pragma may result in passing
1511 this type in floating-point registers.
1513 @node Pragma Component_Alignment
1514 @unnumberedsec Pragma Component_Alignment
1515 @cindex Alignments of components
1516 @findex Component_Alignment
1520 @smallexample @c ada
1521 pragma Component_Alignment (
1522 [Form =>] ALIGNMENT_CHOICE
1523 [, [Name =>] type_LOCAL_NAME]);
1525 ALIGNMENT_CHOICE ::=
1533 Specifies the alignment of components in array or record types.
1534 The meaning of the @var{Form} argument is as follows:
1537 @findex Component_Size
1538 @item Component_Size
1539 Aligns scalar components and subcomponents of the array or record type
1540 on boundaries appropriate to their inherent size (naturally
1541 aligned). For example, 1-byte components are aligned on byte boundaries,
1542 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1543 integer components are aligned on 4-byte boundaries and so on. These
1544 alignment rules correspond to the normal rules for C compilers on all
1545 machines except the VAX@.
1547 @findex Component_Size_4
1548 @item Component_Size_4
1549 Naturally aligns components with a size of four or fewer
1550 bytes. Components that are larger than 4 bytes are placed on the next
1553 @findex Storage_Unit
1555 Specifies that array or record components are byte aligned, i.e.@:
1556 aligned on boundaries determined by the value of the constant
1557 @code{System.Storage_Unit}.
1561 Specifies that array or record components are aligned on default
1562 boundaries, appropriate to the underlying hardware or operating system or
1563 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1564 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1565 the @code{Default} choice is the same as @code{Component_Size} (natural
1570 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1571 refer to a local record or array type, and the specified alignment
1572 choice applies to the specified type. The use of
1573 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1574 @code{Component_Alignment} pragma to be ignored. The use of
1575 @code{Component_Alignment} together with a record representation clause
1576 is only effective for fields not specified by the representation clause.
1578 If the @code{Name} parameter is absent, the pragma can be used as either
1579 a configuration pragma, in which case it applies to one or more units in
1580 accordance with the normal rules for configuration pragmas, or it can be
1581 used within a declarative part, in which case it applies to types that
1582 are declared within this declarative part, or within any nested scope
1583 within this declarative part. In either case it specifies the alignment
1584 to be applied to any record or array type which has otherwise standard
1587 If the alignment for a record or array type is not specified (using
1588 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1589 clause), the GNAT uses the default alignment as described previously.
1591 @node Pragma Convention_Identifier
1592 @unnumberedsec Pragma Convention_Identifier
1593 @findex Convention_Identifier
1594 @cindex Conventions, synonyms
1598 @smallexample @c ada
1599 pragma Convention_Identifier (
1600 [Name =>] IDENTIFIER,
1601 [Convention =>] convention_IDENTIFIER);
1605 This pragma provides a mechanism for supplying synonyms for existing
1606 convention identifiers. The @code{Name} identifier can subsequently
1607 be used as a synonym for the given convention in other pragmas (including
1608 for example pragma @code{Import} or another @code{Convention_Identifier}
1609 pragma). As an example of the use of this, suppose you had legacy code
1610 which used Fortran77 as the identifier for Fortran. Then the pragma:
1612 @smallexample @c ada
1613 pragma Convention_Identifier (Fortran77, Fortran);
1617 would allow the use of the convention identifier @code{Fortran77} in
1618 subsequent code, avoiding the need to modify the sources. As another
1619 example, you could use this to parameterize convention requirements
1620 according to systems. Suppose you needed to use @code{Stdcall} on
1621 windows systems, and @code{C} on some other system, then you could
1622 define a convention identifier @code{Library} and use a single
1623 @code{Convention_Identifier} pragma to specify which convention
1624 would be used system-wide.
1626 @node Pragma CPP_Class
1627 @unnumberedsec Pragma CPP_Class
1629 @cindex Interfacing with C++
1633 @smallexample @c ada
1634 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1638 The argument denotes an entity in the current declarative region that is
1639 declared as a record type. It indicates that the type corresponds to an
1640 externally declared C++ class type, and is to be laid out the same way
1641 that C++ would lay out the type. If the C++ class has virtual primitives
1642 then the record must be declared as a tagged record type.
1644 Types for which @code{CPP_Class} is specified do not have assignment or
1645 equality operators defined (such operations can be imported or declared
1646 as subprograms as required). Initialization is allowed only by constructor
1647 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1648 limited if not explicitly declared as limited or derived from a limited
1649 type, and an error is issued in that case.
1651 Pragma @code{CPP_Class} is intended primarily for automatic generation
1652 using an automatic binding generator tool.
1653 See @ref{Interfacing to C++} for related information.
1655 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1656 for backward compatibility but its functionality is available
1657 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1659 @node Pragma CPP_Constructor
1660 @unnumberedsec Pragma CPP_Constructor
1661 @cindex Interfacing with C++
1662 @findex CPP_Constructor
1666 @smallexample @c ada
1667 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1668 [, [External_Name =>] static_string_EXPRESSION ]
1669 [, [Link_Name =>] static_string_EXPRESSION ]);
1673 This pragma identifies an imported function (imported in the usual way
1674 with pragma @code{Import}) as corresponding to a C++ constructor. If
1675 @code{External_Name} and @code{Link_Name} are not specified then the
1676 @code{Entity} argument is a name that must have been previously mentioned
1677 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1678 must be of one of the following forms:
1682 @code{function @var{Fname} return @var{T}}
1686 @code{function @var{Fname} return @var{T}'Class}
1689 @code{function @var{Fname} (@dots{}) return @var{T}}
1693 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1697 where @var{T} is a limited record type imported from C++ with pragma
1698 @code{Import} and @code{Convention} = @code{CPP}.
1700 The first two forms import the default constructor, used when an object
1701 of type @var{T} is created on the Ada side with no explicit constructor.
1702 The latter two forms cover all the non-default constructors of the type.
1703 See the GNAT users guide for details.
1705 If no constructors are imported, it is impossible to create any objects
1706 on the Ada side and the type is implicitly declared abstract.
1708 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1709 using an automatic binding generator tool.
1710 See @ref{Interfacing to C++} for more related information.
1712 Note: The use of functions returning class-wide types for constructors is
1713 currently obsolete. They are supported for backward compatibility. The
1714 use of functions returning the type T leave the Ada sources more clear
1715 because the imported C++ constructors always return an object of type T;
1716 that is, they never return an object whose type is a descendant of type T.
1718 @node Pragma CPP_Virtual
1719 @unnumberedsec Pragma CPP_Virtual
1720 @cindex Interfacing to C++
1723 This pragma is now obsolete has has no effect because GNAT generates
1724 the same object layout than the G++ compiler.
1726 See @ref{Interfacing to C++} for related information.
1728 @node Pragma CPP_Vtable
1729 @unnumberedsec Pragma CPP_Vtable
1730 @cindex Interfacing with C++
1733 This pragma is now obsolete has has no effect because GNAT generates
1734 the same object layout than the G++ compiler.
1736 See @ref{Interfacing to C++} for related information.
1739 @unnumberedsec Pragma Debug
1744 @smallexample @c ada
1745 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1747 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1749 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1753 The procedure call argument has the syntactic form of an expression, meeting
1754 the syntactic requirements for pragmas.
1756 If debug pragmas are not enabled or if the condition is present and evaluates
1757 to False, this pragma has no effect. If debug pragmas are enabled, the
1758 semantics of the pragma is exactly equivalent to the procedure call statement
1759 corresponding to the argument with a terminating semicolon. Pragmas are
1760 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1761 intersperse calls to debug procedures in the middle of declarations. Debug
1762 pragmas can be enabled either by use of the command line switch @option{-gnata}
1763 or by use of the configuration pragma @code{Debug_Policy}.
1765 @node Pragma Debug_Policy
1766 @unnumberedsec Pragma Debug_Policy
1767 @findex Debug_Policy
1771 @smallexample @c ada
1772 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
1776 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1777 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1778 This pragma overrides the effect of the @option{-gnata} switch on the
1781 The implementation defined policy @code{DISABLE} is like
1782 @code{IGNORE} except that it completely disables semantic
1783 checking of the argument to @code{pragma Debug}. This may
1784 be useful when the pragma argument references subprograms
1785 in a with'ed package which is replaced by a dummy package
1786 for the final build.
1788 @node Pragma Detect_Blocking
1789 @unnumberedsec Pragma Detect_Blocking
1790 @findex Detect_Blocking
1794 @smallexample @c ada
1795 pragma Detect_Blocking;
1799 This is a configuration pragma that forces the detection of potentially
1800 blocking operations within a protected operation, and to raise Program_Error
1803 @node Pragma Elaboration_Checks
1804 @unnumberedsec Pragma Elaboration_Checks
1805 @cindex Elaboration control
1806 @findex Elaboration_Checks
1810 @smallexample @c ada
1811 pragma Elaboration_Checks (Dynamic | Static);
1815 This is a configuration pragma that provides control over the
1816 elaboration model used by the compilation affected by the
1817 pragma. If the parameter is @code{Dynamic},
1818 then the dynamic elaboration
1819 model described in the Ada Reference Manual is used, as though
1820 the @option{-gnatE} switch had been specified on the command
1821 line. If the parameter is @code{Static}, then the default GNAT static
1822 model is used. This configuration pragma overrides the setting
1823 of the command line. For full details on the elaboration models
1824 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1825 gnat_ugn, @value{EDITION} User's Guide}.
1827 @node Pragma Eliminate
1828 @unnumberedsec Pragma Eliminate
1829 @cindex Elimination of unused subprograms
1834 @smallexample @c ada
1835 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
1836 [Source_Location =>] STRING_LITERAL);
1840 The string literal given for the source location is a string which
1841 specifies the line number of the occurrence of the entity, using
1842 the syntax for SOURCE_TRACE given below:
1844 @smallexample @c ada
1845 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
1850 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
1852 LINE_NUMBER ::= DIGIT @{DIGIT@}
1856 Spaces around the colon in a @code{Source_Reference} are optional.
1858 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
1859 explicit subprogram declaration, where the @code{entity} name in this
1860 designator appears on the source line specified by the source location.
1862 The source trace that is given as the @code{Source_Location} shall obey the
1863 following rules. The @code{FILE_NAME} is the short name (with no directory
1864 information) of an Ada source file, given using exactly the required syntax
1865 for the underlying file system (e.g. case is important if the underlying
1866 operating system is case sensitive). @code{LINE_NUMBER} gives the line
1867 number of the occurrence of the @code{entity}
1868 as a decimal literal without an exponent or point. If an @code{entity} is not
1869 declared in a generic instantiation (this includes generic subprogram
1870 instances), the source trace includes only one source reference. If an entity
1871 is declared inside a generic instantiation, its source trace (when parsing
1872 from left to right) starts with the source location of the declaration of the
1873 entity in the generic unit and ends with the source location of the
1874 instantiation (it is given in square brackets). This approach is recursively
1875 used in case of nested instantiations: the rightmost (nested most deeply in
1876 square brackets) element of the source trace is the location of the outermost
1877 instantiation, the next to left element is the location of the next (first
1878 nested) instantiation in the code of the corresponding generic unit, and so
1879 on, and the leftmost element (that is out of any square brackets) is the
1880 location of the declaration of the entity to eliminate in a generic unit.
1882 Note that the @code{Source_Location} argument specifies which of a set of
1883 similarly named entities is being eliminated, dealing both with overloading,
1884 and also appearence of the same entity name in different scopes.
1886 This pragma indicates that the given entity is not used in the program to be
1887 compiled and built. The effect of the pragma is to allow the compiler to
1888 eliminate the code or data associated with the named entity. Any reference to
1889 an eliminated entity causes a compile-time or link-time error.
1891 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1892 in a system-independent manner, with unused entities eliminated, without
1893 needing to modify the source text. Normally the required set of
1894 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
1896 Any source file change that removes, splits, or
1897 adds lines may make the set of Eliminate pragmas invalid because their
1898 @code{Source_Location} argument values may get out of date.
1900 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
1901 operation. In this case all the subprograms to which the given operation can
1902 dispatch are considered to be unused (are never called as a result of a direct
1903 or a dispatching call).
1905 @node Pragma Export_Exception
1906 @unnumberedsec Pragma Export_Exception
1908 @findex Export_Exception
1912 @smallexample @c ada
1913 pragma Export_Exception (
1914 [Internal =>] LOCAL_NAME
1915 [, [External =>] EXTERNAL_SYMBOL]
1916 [, [Form =>] Ada | VMS]
1917 [, [Code =>] static_integer_EXPRESSION]);
1921 | static_string_EXPRESSION
1925 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1926 causes the specified exception to be propagated outside of the Ada program,
1927 so that it can be handled by programs written in other OpenVMS languages.
1928 This pragma establishes an external name for an Ada exception and makes the
1929 name available to the OpenVMS Linker as a global symbol. For further details
1930 on this pragma, see the
1931 DEC Ada Language Reference Manual, section 13.9a3.2.
1933 @node Pragma Export_Function
1934 @unnumberedsec Pragma Export_Function
1935 @cindex Argument passing mechanisms
1936 @findex Export_Function
1941 @smallexample @c ada
1942 pragma Export_Function (
1943 [Internal =>] LOCAL_NAME
1944 [, [External =>] EXTERNAL_SYMBOL]
1945 [, [Parameter_Types =>] PARAMETER_TYPES]
1946 [, [Result_Type =>] result_SUBTYPE_MARK]
1947 [, [Mechanism =>] MECHANISM]
1948 [, [Result_Mechanism =>] MECHANISM_NAME]);
1952 | static_string_EXPRESSION
1957 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1961 | subtype_Name ' Access
1965 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1967 MECHANISM_ASSOCIATION ::=
1968 [formal_parameter_NAME =>] MECHANISM_NAME
1973 | Descriptor [([Class =>] CLASS_NAME)]
1974 | Short_Descriptor [([Class =>] CLASS_NAME)]
1976 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1980 Use this pragma to make a function externally callable and optionally
1981 provide information on mechanisms to be used for passing parameter and
1982 result values. We recommend, for the purposes of improving portability,
1983 this pragma always be used in conjunction with a separate pragma
1984 @code{Export}, which must precede the pragma @code{Export_Function}.
1985 GNAT does not require a separate pragma @code{Export}, but if none is
1986 present, @code{Convention Ada} is assumed, which is usually
1987 not what is wanted, so it is usually appropriate to use this
1988 pragma in conjunction with a @code{Export} or @code{Convention}
1989 pragma that specifies the desired foreign convention.
1990 Pragma @code{Export_Function}
1991 (and @code{Export}, if present) must appear in the same declarative
1992 region as the function to which they apply.
1994 @var{internal_name} must uniquely designate the function to which the
1995 pragma applies. If more than one function name exists of this name in
1996 the declarative part you must use the @code{Parameter_Types} and
1997 @code{Result_Type} parameters is mandatory to achieve the required
1998 unique designation. @var{subtype_mark}s in these parameters must
1999 exactly match the subtypes in the corresponding function specification,
2000 using positional notation to match parameters with subtype marks.
2001 The form with an @code{'Access} attribute can be used to match an
2002 anonymous access parameter.
2005 @cindex Passing by descriptor
2006 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2007 The default behavior for Export_Function is to accept either 64bit or
2008 32bit descriptors unless short_descriptor is specified, then only 32bit
2009 descriptors are accepted.
2011 @cindex Suppressing external name
2012 Special treatment is given if the EXTERNAL is an explicit null
2013 string or a static string expressions that evaluates to the null
2014 string. In this case, no external name is generated. This form
2015 still allows the specification of parameter mechanisms.
2017 @node Pragma Export_Object
2018 @unnumberedsec Pragma Export_Object
2019 @findex Export_Object
2023 @smallexample @c ada
2024 pragma Export_Object
2025 [Internal =>] LOCAL_NAME
2026 [, [External =>] EXTERNAL_SYMBOL]
2027 [, [Size =>] EXTERNAL_SYMBOL]
2031 | static_string_EXPRESSION
2035 This pragma designates an object as exported, and apart from the
2036 extended rules for external symbols, is identical in effect to the use of
2037 the normal @code{Export} pragma applied to an object. You may use a
2038 separate Export pragma (and you probably should from the point of view
2039 of portability), but it is not required. @var{Size} is syntax checked,
2040 but otherwise ignored by GNAT@.
2042 @node Pragma Export_Procedure
2043 @unnumberedsec Pragma Export_Procedure
2044 @findex Export_Procedure
2048 @smallexample @c ada
2049 pragma Export_Procedure (
2050 [Internal =>] LOCAL_NAME
2051 [, [External =>] EXTERNAL_SYMBOL]
2052 [, [Parameter_Types =>] PARAMETER_TYPES]
2053 [, [Mechanism =>] MECHANISM]);
2057 | static_string_EXPRESSION
2062 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2066 | subtype_Name ' Access
2070 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2072 MECHANISM_ASSOCIATION ::=
2073 [formal_parameter_NAME =>] MECHANISM_NAME
2078 | Descriptor [([Class =>] CLASS_NAME)]
2079 | Short_Descriptor [([Class =>] CLASS_NAME)]
2081 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2085 This pragma is identical to @code{Export_Function} except that it
2086 applies to a procedure rather than a function and the parameters
2087 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2088 GNAT does not require a separate pragma @code{Export}, but if none is
2089 present, @code{Convention Ada} is assumed, which is usually
2090 not what is wanted, so it is usually appropriate to use this
2091 pragma in conjunction with a @code{Export} or @code{Convention}
2092 pragma that specifies the desired foreign convention.
2095 @cindex Passing by descriptor
2096 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2097 The default behavior for Export_Procedure is to accept either 64bit or
2098 32bit descriptors unless short_descriptor is specified, then only 32bit
2099 descriptors are accepted.
2101 @cindex Suppressing external name
2102 Special treatment is given if the EXTERNAL is an explicit null
2103 string or a static string expressions that evaluates to the null
2104 string. In this case, no external name is generated. This form
2105 still allows the specification of parameter mechanisms.
2107 @node Pragma Export_Value
2108 @unnumberedsec Pragma Export_Value
2109 @findex Export_Value
2113 @smallexample @c ada
2114 pragma Export_Value (
2115 [Value =>] static_integer_EXPRESSION,
2116 [Link_Name =>] static_string_EXPRESSION);
2120 This pragma serves to export a static integer value for external use.
2121 The first argument specifies the value to be exported. The Link_Name
2122 argument specifies the symbolic name to be associated with the integer
2123 value. This pragma is useful for defining a named static value in Ada
2124 that can be referenced in assembly language units to be linked with
2125 the application. This pragma is currently supported only for the
2126 AAMP target and is ignored for other targets.
2128 @node Pragma Export_Valued_Procedure
2129 @unnumberedsec Pragma Export_Valued_Procedure
2130 @findex Export_Valued_Procedure
2134 @smallexample @c ada
2135 pragma Export_Valued_Procedure (
2136 [Internal =>] LOCAL_NAME
2137 [, [External =>] EXTERNAL_SYMBOL]
2138 [, [Parameter_Types =>] PARAMETER_TYPES]
2139 [, [Mechanism =>] MECHANISM]);
2143 | static_string_EXPRESSION
2148 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2152 | subtype_Name ' Access
2156 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2158 MECHANISM_ASSOCIATION ::=
2159 [formal_parameter_NAME =>] MECHANISM_NAME
2164 | Descriptor [([Class =>] CLASS_NAME)]
2165 | Short_Descriptor [([Class =>] CLASS_NAME)]
2167 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2171 This pragma is identical to @code{Export_Procedure} except that the
2172 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2173 mode @code{OUT}, and externally the subprogram is treated as a function
2174 with this parameter as the result of the function. GNAT provides for
2175 this capability to allow the use of @code{OUT} and @code{IN OUT}
2176 parameters in interfacing to external functions (which are not permitted
2178 GNAT does not require a separate pragma @code{Export}, but if none is
2179 present, @code{Convention Ada} is assumed, which is almost certainly
2180 not what is wanted since the whole point of this pragma is to interface
2181 with foreign language functions, so it is usually appropriate to use this
2182 pragma in conjunction with a @code{Export} or @code{Convention}
2183 pragma that specifies the desired foreign convention.
2186 @cindex Passing by descriptor
2187 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2188 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2189 32bit descriptors unless short_descriptor is specified, then only 32bit
2190 descriptors are accepted.
2192 @cindex Suppressing external name
2193 Special treatment is given if the EXTERNAL is an explicit null
2194 string or a static string expressions that evaluates to the null
2195 string. In this case, no external name is generated. This form
2196 still allows the specification of parameter mechanisms.
2198 @node Pragma Extend_System
2199 @unnumberedsec Pragma Extend_System
2200 @cindex @code{system}, extending
2202 @findex Extend_System
2206 @smallexample @c ada
2207 pragma Extend_System ([Name =>] IDENTIFIER);
2211 This pragma is used to provide backwards compatibility with other
2212 implementations that extend the facilities of package @code{System}. In
2213 GNAT, @code{System} contains only the definitions that are present in
2214 the Ada RM@. However, other implementations, notably the DEC Ada 83
2215 implementation, provide many extensions to package @code{System}.
2217 For each such implementation accommodated by this pragma, GNAT provides a
2218 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2219 implementation, which provides the required additional definitions. You
2220 can use this package in two ways. You can @code{with} it in the normal
2221 way and access entities either by selection or using a @code{use}
2222 clause. In this case no special processing is required.
2224 However, if existing code contains references such as
2225 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2226 definitions provided in package @code{System}, you may use this pragma
2227 to extend visibility in @code{System} in a non-standard way that
2228 provides greater compatibility with the existing code. Pragma
2229 @code{Extend_System} is a configuration pragma whose single argument is
2230 the name of the package containing the extended definition
2231 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2232 control of this pragma will be processed using special visibility
2233 processing that looks in package @code{System.Aux_@var{xxx}} where
2234 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2235 package @code{System}, but not found in package @code{System}.
2237 You can use this pragma either to access a predefined @code{System}
2238 extension supplied with the compiler, for example @code{Aux_DEC} or
2239 you can construct your own extension unit following the above
2240 definition. Note that such a package is a child of @code{System}
2241 and thus is considered part of the implementation. To compile
2242 it you will have to use the appropriate switch for compiling
2244 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2247 @node Pragma Extensions_Allowed
2248 @unnumberedsec Pragma Extensions_Allowed
2249 @cindex Ada Extensions
2250 @cindex GNAT Extensions
2251 @findex Extensions_Allowed
2255 @smallexample @c ada
2256 pragma Extensions_Allowed (On | Off);
2260 This configuration pragma enables or disables the implementation
2261 extension mode (the use of Off as a parameter cancels the effect
2262 of the @option{-gnatX} command switch).
2264 In extension mode, the latest version of the Ada language is
2265 implemented (currently Ada 2012), and in addition a small number
2266 of GNAT specific extensions are recognized as follows:
2269 @item Constrained attribute for generic objects
2270 The @code{Constrained} attribute is permitted for objects of
2271 generic types. The result indicates if the corresponding actual
2276 @node Pragma External
2277 @unnumberedsec Pragma External
2282 @smallexample @c ada
2284 [ Convention =>] convention_IDENTIFIER,
2285 [ Entity =>] LOCAL_NAME
2286 [, [External_Name =>] static_string_EXPRESSION ]
2287 [, [Link_Name =>] static_string_EXPRESSION ]);
2291 This pragma is identical in syntax and semantics to pragma
2292 @code{Export} as defined in the Ada Reference Manual. It is
2293 provided for compatibility with some Ada 83 compilers that
2294 used this pragma for exactly the same purposes as pragma
2295 @code{Export} before the latter was standardized.
2297 @node Pragma External_Name_Casing
2298 @unnumberedsec Pragma External_Name_Casing
2299 @cindex Dec Ada 83 casing compatibility
2300 @cindex External Names, casing
2301 @cindex Casing of External names
2302 @findex External_Name_Casing
2306 @smallexample @c ada
2307 pragma External_Name_Casing (
2308 Uppercase | Lowercase
2309 [, Uppercase | Lowercase | As_Is]);
2313 This pragma provides control over the casing of external names associated
2314 with Import and Export pragmas. There are two cases to consider:
2317 @item Implicit external names
2318 Implicit external names are derived from identifiers. The most common case
2319 arises when a standard Ada Import or Export pragma is used with only two
2322 @smallexample @c ada
2323 pragma Import (C, C_Routine);
2327 Since Ada is a case-insensitive language, the spelling of the identifier in
2328 the Ada source program does not provide any information on the desired
2329 casing of the external name, and so a convention is needed. In GNAT the
2330 default treatment is that such names are converted to all lower case
2331 letters. This corresponds to the normal C style in many environments.
2332 The first argument of pragma @code{External_Name_Casing} can be used to
2333 control this treatment. If @code{Uppercase} is specified, then the name
2334 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2335 then the normal default of all lower case letters will be used.
2337 This same implicit treatment is also used in the case of extended DEC Ada 83
2338 compatible Import and Export pragmas where an external name is explicitly
2339 specified using an identifier rather than a string.
2341 @item Explicit external names
2342 Explicit external names are given as string literals. The most common case
2343 arises when a standard Ada Import or Export pragma is used with three
2346 @smallexample @c ada
2347 pragma Import (C, C_Routine, "C_routine");
2351 In this case, the string literal normally provides the exact casing required
2352 for the external name. The second argument of pragma
2353 @code{External_Name_Casing} may be used to modify this behavior.
2354 If @code{Uppercase} is specified, then the name
2355 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2356 then the name will be forced to all lowercase letters. A specification of
2357 @code{As_Is} provides the normal default behavior in which the casing is
2358 taken from the string provided.
2362 This pragma may appear anywhere that a pragma is valid. In particular, it
2363 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2364 case it applies to all subsequent compilations, or it can be used as a program
2365 unit pragma, in which case it only applies to the current unit, or it can
2366 be used more locally to control individual Import/Export pragmas.
2368 It is primarily intended for use with OpenVMS systems, where many
2369 compilers convert all symbols to upper case by default. For interfacing to
2370 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2373 @smallexample @c ada
2374 pragma External_Name_Casing (Uppercase, Uppercase);
2378 to enforce the upper casing of all external symbols.
2380 @node Pragma Fast_Math
2381 @unnumberedsec Pragma Fast_Math
2386 @smallexample @c ada
2391 This is a configuration pragma which activates a mode in which speed is
2392 considered more important for floating-point operations than absolutely
2393 accurate adherence to the requirements of the standard. Currently the
2394 following operations are affected:
2397 @item Complex Multiplication
2398 The normal simple formula for complex multiplication can result in intermediate
2399 overflows for numbers near the end of the range. The Ada standard requires that
2400 this situation be detected and corrected by scaling, but in Fast_Math mode such
2401 cases will simply result in overflow. Note that to take advantage of this you
2402 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2403 under control of the pragma, rather than use the preinstantiated versions.
2406 @node Pragma Favor_Top_Level
2407 @unnumberedsec Pragma Favor_Top_Level
2408 @findex Favor_Top_Level
2412 @smallexample @c ada
2413 pragma Favor_Top_Level (type_NAME);
2417 The named type must be an access-to-subprogram type. This pragma is an
2418 efficiency hint to the compiler, regarding the use of 'Access or
2419 'Unrestricted_Access on nested (non-library-level) subprograms. The
2420 pragma means that nested subprograms are not used with this type, or
2421 are rare, so that the generated code should be efficient in the
2422 top-level case. When this pragma is used, dynamically generated
2423 trampolines may be used on some targets for nested subprograms.
2424 See also the No_Implicit_Dynamic_Code restriction.
2426 @node Pragma Finalize_Storage_Only
2427 @unnumberedsec Pragma Finalize_Storage_Only
2428 @findex Finalize_Storage_Only
2432 @smallexample @c ada
2433 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2437 This pragma allows the compiler not to emit a Finalize call for objects
2438 defined at the library level. This is mostly useful for types where
2439 finalization is only used to deal with storage reclamation since in most
2440 environments it is not necessary to reclaim memory just before terminating
2441 execution, hence the name.
2443 @node Pragma Float_Representation
2444 @unnumberedsec Pragma Float_Representation
2446 @findex Float_Representation
2450 @smallexample @c ada
2451 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2453 FLOAT_REP ::= VAX_Float | IEEE_Float
2457 In the one argument form, this pragma is a configuration pragma which
2458 allows control over the internal representation chosen for the predefined
2459 floating point types declared in the packages @code{Standard} and
2460 @code{System}. On all systems other than OpenVMS, the argument must
2461 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2462 argument may be @code{VAX_Float} to specify the use of the VAX float
2463 format for the floating-point types in Standard. This requires that
2464 the standard runtime libraries be recompiled.
2466 The two argument form specifies the representation to be used for
2467 the specified floating-point type. On all systems other than OpenVMS,
2469 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2470 argument may be @code{VAX_Float} to specify the use of the VAX float
2475 For digits values up to 6, F float format will be used.
2477 For digits values from 7 to 9, D float format will be used.
2479 For digits values from 10 to 15, G float format will be used.
2481 Digits values above 15 are not allowed.
2485 @unnumberedsec Pragma Ident
2490 @smallexample @c ada
2491 pragma Ident (static_string_EXPRESSION);
2495 This pragma provides a string identification in the generated object file,
2496 if the system supports the concept of this kind of identification string.
2497 This pragma is allowed only in the outermost declarative part or
2498 declarative items of a compilation unit. If more than one @code{Ident}
2499 pragma is given, only the last one processed is effective.
2501 On OpenVMS systems, the effect of the pragma is identical to the effect of
2502 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2503 maximum allowed length is 31 characters, so if it is important to
2504 maintain compatibility with this compiler, you should obey this length
2507 @node Pragma Implemented
2508 @unnumberedsec Pragma Implemented
2513 @smallexample @c ada
2514 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2516 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2520 This is an Ada 2012 representation pragma which applies to protected, task
2521 and synchronized interface primitives. The use of pragma Implemented provides
2522 a way to impose a static requirement on the overriding operation by adhering
2523 to one of the three implementation kids: entry, protected procedure or any of
2526 @smallexample @c ada
2527 type Synch_Iface is synchronized interface;
2528 procedure Prim_Op (Obj : in out Iface) is abstract;
2529 pragma Implemented (Prim_Op, By_Protected_Procedure);
2531 protected type Prot_1 is new Synch_Iface with
2532 procedure Prim_Op; -- Legal
2535 protected type Prot_2 is new Synch_Iface with
2536 entry Prim_Op; -- Illegal
2539 task type Task_Typ is new Synch_Iface with
2540 entry Prim_Op; -- Illegal
2545 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2546 Implemented determines the runtime behavior of the requeue. Implementation kind
2547 By_Entry guarantees that the action of requeueing will proceed from an entry to
2548 another entry. Implementation kind By_Protected_Procedure transforms the
2549 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2550 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2551 the target's overriding subprogram kind.
2553 @node Pragma Implicit_Packing
2554 @unnumberedsec Pragma Implicit_Packing
2555 @findex Implicit_Packing
2559 @smallexample @c ada
2560 pragma Implicit_Packing;
2564 This is a configuration pragma that requests implicit packing for packed
2565 arrays for which a size clause is given but no explicit pragma Pack or
2566 specification of Component_Size is present. It also applies to records
2567 where no record representation clause is present. Consider this example:
2569 @smallexample @c ada
2570 type R is array (0 .. 7) of Boolean;
2575 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2576 does not change the layout of a composite object. So the Size clause in the
2577 above example is normally rejected, since the default layout of the array uses
2578 8-bit components, and thus the array requires a minimum of 64 bits.
2580 If this declaration is compiled in a region of code covered by an occurrence
2581 of the configuration pragma Implicit_Packing, then the Size clause in this
2582 and similar examples will cause implicit packing and thus be accepted. For
2583 this implicit packing to occur, the type in question must be an array of small
2584 components whose size is known at compile time, and the Size clause must
2585 specify the exact size that corresponds to the length of the array multiplied
2586 by the size in bits of the component type.
2587 @cindex Array packing
2589 Similarly, the following example shows the use in the record case
2591 @smallexample @c ada
2593 a, b, c, d, e, f, g, h : boolean;
2600 Without a pragma Pack, each Boolean field requires 8 bits, so the
2601 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2602 sufficient. The use of pragma Implicit_Packing allows this record
2603 declaration to compile without an explicit pragma Pack.
2604 @node Pragma Import_Exception
2605 @unnumberedsec Pragma Import_Exception
2607 @findex Import_Exception
2611 @smallexample @c ada
2612 pragma Import_Exception (
2613 [Internal =>] LOCAL_NAME
2614 [, [External =>] EXTERNAL_SYMBOL]
2615 [, [Form =>] Ada | VMS]
2616 [, [Code =>] static_integer_EXPRESSION]);
2620 | static_string_EXPRESSION
2624 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2625 It allows OpenVMS conditions (for example, from OpenVMS system services or
2626 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2627 The pragma specifies that the exception associated with an exception
2628 declaration in an Ada program be defined externally (in non-Ada code).
2629 For further details on this pragma, see the
2630 DEC Ada Language Reference Manual, section 13.9a.3.1.
2632 @node Pragma Import_Function
2633 @unnumberedsec Pragma Import_Function
2634 @findex Import_Function
2638 @smallexample @c ada
2639 pragma Import_Function (
2640 [Internal =>] LOCAL_NAME,
2641 [, [External =>] EXTERNAL_SYMBOL]
2642 [, [Parameter_Types =>] PARAMETER_TYPES]
2643 [, [Result_Type =>] SUBTYPE_MARK]
2644 [, [Mechanism =>] MECHANISM]
2645 [, [Result_Mechanism =>] MECHANISM_NAME]
2646 [, [First_Optional_Parameter =>] IDENTIFIER]);
2650 | static_string_EXPRESSION
2654 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2658 | subtype_Name ' Access
2662 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2664 MECHANISM_ASSOCIATION ::=
2665 [formal_parameter_NAME =>] MECHANISM_NAME
2670 | Descriptor [([Class =>] CLASS_NAME)]
2671 | Short_Descriptor [([Class =>] CLASS_NAME)]
2673 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2677 This pragma is used in conjunction with a pragma @code{Import} to
2678 specify additional information for an imported function. The pragma
2679 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2680 @code{Import_Function} pragma and both must appear in the same
2681 declarative part as the function specification.
2683 The @var{Internal} argument must uniquely designate
2684 the function to which the
2685 pragma applies. If more than one function name exists of this name in
2686 the declarative part you must use the @code{Parameter_Types} and
2687 @var{Result_Type} parameters to achieve the required unique
2688 designation. Subtype marks in these parameters must exactly match the
2689 subtypes in the corresponding function specification, using positional
2690 notation to match parameters with subtype marks.
2691 The form with an @code{'Access} attribute can be used to match an
2692 anonymous access parameter.
2694 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2695 parameters to specify passing mechanisms for the
2696 parameters and result. If you specify a single mechanism name, it
2697 applies to all parameters. Otherwise you may specify a mechanism on a
2698 parameter by parameter basis using either positional or named
2699 notation. If the mechanism is not specified, the default mechanism
2703 @cindex Passing by descriptor
2704 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2705 The default behavior for Import_Function is to pass a 64bit descriptor
2706 unless short_descriptor is specified, then a 32bit descriptor is passed.
2708 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2709 It specifies that the designated parameter and all following parameters
2710 are optional, meaning that they are not passed at the generated code
2711 level (this is distinct from the notion of optional parameters in Ada
2712 where the parameters are passed anyway with the designated optional
2713 parameters). All optional parameters must be of mode @code{IN} and have
2714 default parameter values that are either known at compile time
2715 expressions, or uses of the @code{'Null_Parameter} attribute.
2717 @node Pragma Import_Object
2718 @unnumberedsec Pragma Import_Object
2719 @findex Import_Object
2723 @smallexample @c ada
2724 pragma Import_Object
2725 [Internal =>] LOCAL_NAME
2726 [, [External =>] EXTERNAL_SYMBOL]
2727 [, [Size =>] EXTERNAL_SYMBOL]);
2731 | static_string_EXPRESSION
2735 This pragma designates an object as imported, and apart from the
2736 extended rules for external symbols, is identical in effect to the use of
2737 the normal @code{Import} pragma applied to an object. Unlike the
2738 subprogram case, you need not use a separate @code{Import} pragma,
2739 although you may do so (and probably should do so from a portability
2740 point of view). @var{size} is syntax checked, but otherwise ignored by
2743 @node Pragma Import_Procedure
2744 @unnumberedsec Pragma Import_Procedure
2745 @findex Import_Procedure
2749 @smallexample @c ada
2750 pragma Import_Procedure (
2751 [Internal =>] LOCAL_NAME
2752 [, [External =>] EXTERNAL_SYMBOL]
2753 [, [Parameter_Types =>] PARAMETER_TYPES]
2754 [, [Mechanism =>] MECHANISM]
2755 [, [First_Optional_Parameter =>] IDENTIFIER]);
2759 | static_string_EXPRESSION
2763 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2767 | subtype_Name ' Access
2771 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2773 MECHANISM_ASSOCIATION ::=
2774 [formal_parameter_NAME =>] MECHANISM_NAME
2779 | Descriptor [([Class =>] CLASS_NAME)]
2780 | Short_Descriptor [([Class =>] CLASS_NAME)]
2782 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2786 This pragma is identical to @code{Import_Function} except that it
2787 applies to a procedure rather than a function and the parameters
2788 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2790 @node Pragma Import_Valued_Procedure
2791 @unnumberedsec Pragma Import_Valued_Procedure
2792 @findex Import_Valued_Procedure
2796 @smallexample @c ada
2797 pragma Import_Valued_Procedure (
2798 [Internal =>] LOCAL_NAME
2799 [, [External =>] EXTERNAL_SYMBOL]
2800 [, [Parameter_Types =>] PARAMETER_TYPES]
2801 [, [Mechanism =>] MECHANISM]
2802 [, [First_Optional_Parameter =>] IDENTIFIER]);
2806 | static_string_EXPRESSION
2810 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2814 | subtype_Name ' Access
2818 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2820 MECHANISM_ASSOCIATION ::=
2821 [formal_parameter_NAME =>] MECHANISM_NAME
2826 | Descriptor [([Class =>] CLASS_NAME)]
2827 | Short_Descriptor [([Class =>] CLASS_NAME)]
2829 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2833 This pragma is identical to @code{Import_Procedure} except that the
2834 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2835 mode @code{OUT}, and externally the subprogram is treated as a function
2836 with this parameter as the result of the function. The purpose of this
2837 capability is to allow the use of @code{OUT} and @code{IN OUT}
2838 parameters in interfacing to external functions (which are not permitted
2839 in Ada functions). You may optionally use the @code{Mechanism}
2840 parameters to specify passing mechanisms for the parameters.
2841 If you specify a single mechanism name, it applies to all parameters.
2842 Otherwise you may specify a mechanism on a parameter by parameter
2843 basis using either positional or named notation. If the mechanism is not
2844 specified, the default mechanism is used.
2846 Note that it is important to use this pragma in conjunction with a separate
2847 pragma Import that specifies the desired convention, since otherwise the
2848 default convention is Ada, which is almost certainly not what is required.
2850 @node Pragma Initialize_Scalars
2851 @unnumberedsec Pragma Initialize_Scalars
2852 @findex Initialize_Scalars
2853 @cindex debugging with Initialize_Scalars
2857 @smallexample @c ada
2858 pragma Initialize_Scalars;
2862 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2863 two important differences. First, there is no requirement for the pragma
2864 to be used uniformly in all units of a partition, in particular, it is fine
2865 to use this just for some or all of the application units of a partition,
2866 without needing to recompile the run-time library.
2868 In the case where some units are compiled with the pragma, and some without,
2869 then a declaration of a variable where the type is defined in package
2870 Standard or is locally declared will always be subject to initialization,
2871 as will any declaration of a scalar variable. For composite variables,
2872 whether the variable is initialized may also depend on whether the package
2873 in which the type of the variable is declared is compiled with the pragma.
2875 The other important difference is that you can control the value used
2876 for initializing scalar objects. At bind time, you can select several
2877 options for initialization. You can
2878 initialize with invalid values (similar to Normalize_Scalars, though for
2879 Initialize_Scalars it is not always possible to determine the invalid
2880 values in complex cases like signed component fields with non-standard
2881 sizes). You can also initialize with high or
2882 low values, or with a specified bit pattern. See the users guide for binder
2883 options for specifying these cases.
2885 This means that you can compile a program, and then without having to
2886 recompile the program, you can run it with different values being used
2887 for initializing otherwise uninitialized values, to test if your program
2888 behavior depends on the choice. Of course the behavior should not change,
2889 and if it does, then most likely you have an erroneous reference to an
2890 uninitialized value.
2892 It is even possible to change the value at execution time eliminating even
2893 the need to rebind with a different switch using an environment variable.
2894 See the GNAT users guide for details.
2896 Note that pragma @code{Initialize_Scalars} is particularly useful in
2897 conjunction with the enhanced validity checking that is now provided
2898 in GNAT, which checks for invalid values under more conditions.
2899 Using this feature (see description of the @option{-gnatV} flag in the
2900 users guide) in conjunction with pragma @code{Initialize_Scalars}
2901 provides a powerful new tool to assist in the detection of problems
2902 caused by uninitialized variables.
2904 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2905 effect on the generated code. This may cause your code to be
2906 substantially larger. It may also cause an increase in the amount
2907 of stack required, so it is probably a good idea to turn on stack
2908 checking (see description of stack checking in the GNAT users guide)
2909 when using this pragma.
2911 @node Pragma Inline_Always
2912 @unnumberedsec Pragma Inline_Always
2913 @findex Inline_Always
2917 @smallexample @c ada
2918 pragma Inline_Always (NAME [, NAME]);
2922 Similar to pragma @code{Inline} except that inlining is not subject to
2923 the use of option @option{-gnatn} and the inlining happens regardless of
2924 whether this option is used.
2926 @node Pragma Inline_Generic
2927 @unnumberedsec Pragma Inline_Generic
2928 @findex Inline_Generic
2932 @smallexample @c ada
2933 pragma Inline_Generic (generic_package_NAME);
2937 This is implemented for compatibility with DEC Ada 83 and is recognized,
2938 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2939 by default when using GNAT@.
2941 @node Pragma Interface
2942 @unnumberedsec Pragma Interface
2947 @smallexample @c ada
2949 [Convention =>] convention_identifier,
2950 [Entity =>] local_NAME
2951 [, [External_Name =>] static_string_expression]
2952 [, [Link_Name =>] static_string_expression]);
2956 This pragma is identical in syntax and semantics to
2957 the standard Ada pragma @code{Import}. It is provided for compatibility
2958 with Ada 83. The definition is upwards compatible both with pragma
2959 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2960 with some extended implementations of this pragma in certain Ada 83
2961 implementations. The only difference between pragma @code{Interface}
2962 and pragma @code{Import} is that there is special circuitry to allow
2963 both pragmas to appear for the same subprogram entity (normally it
2964 is illegal to have multiple @code{Import} pragmas. This is useful in
2965 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2968 @node Pragma Interface_Name
2969 @unnumberedsec Pragma Interface_Name
2970 @findex Interface_Name
2974 @smallexample @c ada
2975 pragma Interface_Name (
2976 [Entity =>] LOCAL_NAME
2977 [, [External_Name =>] static_string_EXPRESSION]
2978 [, [Link_Name =>] static_string_EXPRESSION]);
2982 This pragma provides an alternative way of specifying the interface name
2983 for an interfaced subprogram, and is provided for compatibility with Ada
2984 83 compilers that use the pragma for this purpose. You must provide at
2985 least one of @var{External_Name} or @var{Link_Name}.
2987 @node Pragma Interrupt_Handler
2988 @unnumberedsec Pragma Interrupt_Handler
2989 @findex Interrupt_Handler
2993 @smallexample @c ada
2994 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2998 This program unit pragma is supported for parameterless protected procedures
2999 as described in Annex C of the Ada Reference Manual. On the AAMP target
3000 the pragma can also be specified for nonprotected parameterless procedures
3001 that are declared at the library level (which includes procedures
3002 declared at the top level of a library package). In the case of AAMP,
3003 when this pragma is applied to a nonprotected procedure, the instruction
3004 @code{IERET} is generated for returns from the procedure, enabling
3005 maskable interrupts, in place of the normal return instruction.
3007 @node Pragma Interrupt_State
3008 @unnumberedsec Pragma Interrupt_State
3009 @findex Interrupt_State
3013 @smallexample @c ada
3014 pragma Interrupt_State
3016 [State =>] SYSTEM | RUNTIME | USER);
3020 Normally certain interrupts are reserved to the implementation. Any attempt
3021 to attach an interrupt causes Program_Error to be raised, as described in
3022 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3023 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3024 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3025 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3026 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3027 Ada exceptions, or used to implement run-time functions such as the
3028 @code{abort} statement and stack overflow checking.
3030 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3031 such uses of interrupts. It subsumes the functionality of pragma
3032 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3033 available on Windows or VMS. On all other platforms than VxWorks,
3034 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3035 and may be used to mark interrupts required by the board support package
3038 Interrupts can be in one of three states:
3042 The interrupt is reserved (no Ada handler can be installed), and the
3043 Ada run-time may not install a handler. As a result you are guaranteed
3044 standard system default action if this interrupt is raised.
3048 The interrupt is reserved (no Ada handler can be installed). The run time
3049 is allowed to install a handler for internal control purposes, but is
3050 not required to do so.
3054 The interrupt is unreserved. The user may install a handler to provide
3059 These states are the allowed values of the @code{State} parameter of the
3060 pragma. The @code{Name} parameter is a value of the type
3061 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3062 @code{Ada.Interrupts.Names}.
3064 This is a configuration pragma, and the binder will check that there
3065 are no inconsistencies between different units in a partition in how a
3066 given interrupt is specified. It may appear anywhere a pragma is legal.
3068 The effect is to move the interrupt to the specified state.
3070 By declaring interrupts to be SYSTEM, you guarantee the standard system
3071 action, such as a core dump.
3073 By declaring interrupts to be USER, you guarantee that you can install
3076 Note that certain signals on many operating systems cannot be caught and
3077 handled by applications. In such cases, the pragma is ignored. See the
3078 operating system documentation, or the value of the array @code{Reserved}
3079 declared in the spec of package @code{System.OS_Interface}.
3081 Overriding the default state of signals used by the Ada runtime may interfere
3082 with an application's runtime behavior in the cases of the synchronous signals,
3083 and in the case of the signal used to implement the @code{abort} statement.
3085 @node Pragma Invariant
3086 @unnumberedsec Pragma Invariant
3091 @smallexample @c ada
3093 ([Entity =>] private_type_LOCAL_NAME,
3094 [Check =>] EXPRESSION
3095 [,[Message =>] String_Expression]);
3099 This pragma provides exactly the same capabilities as the Invariant aspect
3100 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The Invariant
3101 aspect is fully implemented in Ada 2012 mode, but since it requires the use
3102 of the aspect syntax, which is not available exception in 2012 mode, it is
3103 not possible to use the Invariant aspect in earlier versions of Ada. However
3104 the Invariant pragma may be used in any version of Ada.
3106 The pragma must appear within the visible part of the package specification,
3107 after the type to which its Entity argument appears. As with the Invariant
3108 aspect, the Check expression is not analyzed until the end of the visible
3109 part of the package, so it may contain forward references. The Message
3110 argument, if present, provides the exception message used if the invariant
3111 is violated. If no Message parameter is provided, a default message that
3112 identifies the line on which the pragma appears is used.
3114 It is permissible to have multiple Invariants for the same type entity, in
3115 which case they are and'ed together. It is permissible to use this pragma
3116 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3117 invariant pragma for the same entity.
3119 For further details on the use of this pragma, see the Ada 2012 documentation
3120 of the Invariant aspect.
3122 @node Pragma Keep_Names
3123 @unnumberedsec Pragma Keep_Names
3128 @smallexample @c ada
3129 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3133 The @var{LOCAL_NAME} argument
3134 must refer to an enumeration first subtype
3135 in the current declarative part. The effect is to retain the enumeration
3136 literal names for use by @code{Image} and @code{Value} even if a global
3137 @code{Discard_Names} pragma applies. This is useful when you want to
3138 generally suppress enumeration literal names and for example you therefore
3139 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3140 want to retain the names for specific enumeration types.
3142 @node Pragma License
3143 @unnumberedsec Pragma License
3145 @cindex License checking
3149 @smallexample @c ada
3150 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3154 This pragma is provided to allow automated checking for appropriate license
3155 conditions with respect to the standard and modified GPL@. A pragma
3156 @code{License}, which is a configuration pragma that typically appears at
3157 the start of a source file or in a separate @file{gnat.adc} file, specifies
3158 the licensing conditions of a unit as follows:
3162 This is used for a unit that can be freely used with no license restrictions.
3163 Examples of such units are public domain units, and units from the Ada
3167 This is used for a unit that is licensed under the unmodified GPL, and which
3168 therefore cannot be @code{with}'ed by a restricted unit.
3171 This is used for a unit licensed under the GNAT modified GPL that includes
3172 a special exception paragraph that specifically permits the inclusion of
3173 the unit in programs without requiring the entire program to be released
3177 This is used for a unit that is restricted in that it is not permitted to
3178 depend on units that are licensed under the GPL@. Typical examples are
3179 proprietary code that is to be released under more restrictive license
3180 conditions. Note that restricted units are permitted to @code{with} units
3181 which are licensed under the modified GPL (this is the whole point of the
3187 Normally a unit with no @code{License} pragma is considered to have an
3188 unknown license, and no checking is done. However, standard GNAT headers
3189 are recognized, and license information is derived from them as follows.
3193 A GNAT license header starts with a line containing 78 hyphens. The following
3194 comment text is searched for the appearance of any of the following strings.
3196 If the string ``GNU General Public License'' is found, then the unit is assumed
3197 to have GPL license, unless the string ``As a special exception'' follows, in
3198 which case the license is assumed to be modified GPL@.
3200 If one of the strings
3201 ``This specification is adapted from the Ada Semantic Interface'' or
3202 ``This specification is derived from the Ada Reference Manual'' is found
3203 then the unit is assumed to be unrestricted.
3207 These default actions means that a program with a restricted license pragma
3208 will automatically get warnings if a GPL unit is inappropriately
3209 @code{with}'ed. For example, the program:
3211 @smallexample @c ada
3214 procedure Secret_Stuff is
3220 if compiled with pragma @code{License} (@code{Restricted}) in a
3221 @file{gnat.adc} file will generate the warning:
3226 >>> license of withed unit "Sem_Ch3" is incompatible
3228 2. with GNAT.Sockets;
3229 3. procedure Secret_Stuff is
3233 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3234 compiler and is licensed under the
3235 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3236 run time, and is therefore licensed under the modified GPL@.
3238 @node Pragma Link_With
3239 @unnumberedsec Pragma Link_With
3244 @smallexample @c ada
3245 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3249 This pragma is provided for compatibility with certain Ada 83 compilers.
3250 It has exactly the same effect as pragma @code{Linker_Options} except
3251 that spaces occurring within one of the string expressions are treated
3252 as separators. For example, in the following case:
3254 @smallexample @c ada
3255 pragma Link_With ("-labc -ldef");
3259 results in passing the strings @code{-labc} and @code{-ldef} as two
3260 separate arguments to the linker. In addition pragma Link_With allows
3261 multiple arguments, with the same effect as successive pragmas.
3263 @node Pragma Linker_Alias
3264 @unnumberedsec Pragma Linker_Alias
3265 @findex Linker_Alias
3269 @smallexample @c ada
3270 pragma Linker_Alias (
3271 [Entity =>] LOCAL_NAME,
3272 [Target =>] static_string_EXPRESSION);
3276 @var{LOCAL_NAME} must refer to an object that is declared at the library
3277 level. This pragma establishes the given entity as a linker alias for the
3278 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3279 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3280 @var{static_string_EXPRESSION} in the object file, that is to say no space
3281 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3282 to the same address as @var{static_string_EXPRESSION} by the linker.
3284 The actual linker name for the target must be used (e.g.@: the fully
3285 encoded name with qualification in Ada, or the mangled name in C++),
3286 or it must be declared using the C convention with @code{pragma Import}
3287 or @code{pragma Export}.
3289 Not all target machines support this pragma. On some of them it is accepted
3290 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3292 @smallexample @c ada
3293 -- Example of the use of pragma Linker_Alias
3297 pragma Export (C, i);
3299 new_name_for_i : Integer;
3300 pragma Linker_Alias (new_name_for_i, "i");
3304 @node Pragma Linker_Constructor
3305 @unnumberedsec Pragma Linker_Constructor
3306 @findex Linker_Constructor
3310 @smallexample @c ada
3311 pragma Linker_Constructor (procedure_LOCAL_NAME);
3315 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3316 is declared at the library level. A procedure to which this pragma is
3317 applied will be treated as an initialization routine by the linker.
3318 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3319 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3320 of the executable is called (or immediately after the shared library is
3321 loaded if the procedure is linked in a shared library), in particular
3322 before the Ada run-time environment is set up.
3324 Because of these specific contexts, the set of operations such a procedure
3325 can perform is very limited and the type of objects it can manipulate is
3326 essentially restricted to the elementary types. In particular, it must only
3327 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3329 This pragma is used by GNAT to implement auto-initialization of shared Stand
3330 Alone Libraries, which provides a related capability without the restrictions
3331 listed above. Where possible, the use of Stand Alone Libraries is preferable
3332 to the use of this pragma.
3334 @node Pragma Linker_Destructor
3335 @unnumberedsec Pragma Linker_Destructor
3336 @findex Linker_Destructor
3340 @smallexample @c ada
3341 pragma Linker_Destructor (procedure_LOCAL_NAME);
3345 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3346 is declared at the library level. A procedure to which this pragma is
3347 applied will be treated as a finalization routine by the linker.
3348 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3349 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3350 of the executable has exited (or immediately before the shared library
3351 is unloaded if the procedure is linked in a shared library), in particular
3352 after the Ada run-time environment is shut down.
3354 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3355 because of these specific contexts.
3357 @node Pragma Linker_Section
3358 @unnumberedsec Pragma Linker_Section
3359 @findex Linker_Section
3363 @smallexample @c ada
3364 pragma Linker_Section (
3365 [Entity =>] LOCAL_NAME,
3366 [Section =>] static_string_EXPRESSION);
3370 @var{LOCAL_NAME} must refer to an object that is declared at the library
3371 level. This pragma specifies the name of the linker section for the given
3372 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3373 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3374 section of the executable (assuming the linker doesn't rename the section).
3376 The compiler normally places library-level objects in standard sections
3377 depending on their type: procedures and functions generally go in the
3378 @code{.text} section, initialized variables in the @code{.data} section
3379 and uninitialized variables in the @code{.bss} section.
3381 Other, special sections may exist on given target machines to map special
3382 hardware, for example I/O ports or flash memory. This pragma is a means to
3383 defer the final layout of the executable to the linker, thus fully working
3384 at the symbolic level with the compiler.
3386 Some file formats do not support arbitrary sections so not all target
3387 machines support this pragma. The use of this pragma may cause a program
3388 execution to be erroneous if it is used to place an entity into an
3389 inappropriate section (e.g.@: a modified variable into the @code{.text}
3390 section). See also @code{pragma Persistent_BSS}.
3392 @smallexample @c ada
3393 -- Example of the use of pragma Linker_Section
3397 pragma Volatile (Port_A);
3398 pragma Linker_Section (Port_A, ".bss.port_a");
3401 pragma Volatile (Port_B);
3402 pragma Linker_Section (Port_B, ".bss.port_b");
3406 @node Pragma Long_Float
3407 @unnumberedsec Pragma Long_Float
3413 @smallexample @c ada
3414 pragma Long_Float (FLOAT_FORMAT);
3416 FLOAT_FORMAT ::= D_Float | G_Float
3420 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3421 It allows control over the internal representation chosen for the predefined
3422 type @code{Long_Float} and for floating point type representations with
3423 @code{digits} specified in the range 7 through 15.
3424 For further details on this pragma, see the
3425 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3426 this pragma, the standard runtime libraries must be recompiled.
3428 @node Pragma Machine_Attribute
3429 @unnumberedsec Pragma Machine_Attribute
3430 @findex Machine_Attribute
3434 @smallexample @c ada
3435 pragma Machine_Attribute (
3436 [Entity =>] LOCAL_NAME,
3437 [Attribute_Name =>] static_string_EXPRESSION
3438 [, [Info =>] static_EXPRESSION] );
3442 Machine-dependent attributes can be specified for types and/or
3443 declarations. This pragma is semantically equivalent to
3444 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3445 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3446 in GNU C, where @code{@var{attribute_name}} is recognized by the
3447 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3448 specific macro. A string literal for the optional parameter @var{info}
3449 is transformed into an identifier, which may make this pragma unusable
3450 for some attributes. @xref{Target Attributes,, Defining target-specific
3451 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3452 Internals}, further information.
3455 @unnumberedsec Pragma Main
3461 @smallexample @c ada
3463 (MAIN_OPTION [, MAIN_OPTION]);
3466 [Stack_Size =>] static_integer_EXPRESSION
3467 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3468 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3472 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3473 no effect in GNAT, other than being syntax checked.
3475 @node Pragma Main_Storage
3476 @unnumberedsec Pragma Main_Storage
3478 @findex Main_Storage
3482 @smallexample @c ada
3484 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3486 MAIN_STORAGE_OPTION ::=
3487 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3488 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3492 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3493 no effect in GNAT, other than being syntax checked. Note that the pragma
3494 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3496 @node Pragma No_Body
3497 @unnumberedsec Pragma No_Body
3502 @smallexample @c ada
3507 There are a number of cases in which a package spec does not require a body,
3508 and in fact a body is not permitted. GNAT will not permit the spec to be
3509 compiled if there is a body around. The pragma No_Body allows you to provide
3510 a body file, even in a case where no body is allowed. The body file must
3511 contain only comments and a single No_Body pragma. This is recognized by
3512 the compiler as indicating that no body is logically present.
3514 This is particularly useful during maintenance when a package is modified in
3515 such a way that a body needed before is no longer needed. The provision of a
3516 dummy body with a No_Body pragma ensures that there is no interference from
3517 earlier versions of the package body.
3519 @node Pragma No_Return
3520 @unnumberedsec Pragma No_Return
3525 @smallexample @c ada
3526 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3530 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3531 declarations in the current declarative part. A procedure to which this
3532 pragma is applied may not contain any explicit @code{return} statements.
3533 In addition, if the procedure contains any implicit returns from falling
3534 off the end of a statement sequence, then execution of that implicit
3535 return will cause Program_Error to be raised.
3537 One use of this pragma is to identify procedures whose only purpose is to raise
3538 an exception. Another use of this pragma is to suppress incorrect warnings
3539 about missing returns in functions, where the last statement of a function
3540 statement sequence is a call to such a procedure.
3542 Note that in Ada 2005 mode, this pragma is part of the language, and is
3543 identical in effect to the pragma as implemented in Ada 95 mode.
3545 @node Pragma No_Strict_Aliasing
3546 @unnumberedsec Pragma No_Strict_Aliasing
3547 @findex No_Strict_Aliasing
3551 @smallexample @c ada
3552 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3556 @var{type_LOCAL_NAME} must refer to an access type
3557 declaration in the current declarative part. The effect is to inhibit
3558 strict aliasing optimization for the given type. The form with no
3559 arguments is a configuration pragma which applies to all access types
3560 declared in units to which the pragma applies. For a detailed
3561 description of the strict aliasing optimization, and the situations
3562 in which it must be suppressed, see @ref{Optimization and Strict
3563 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3565 This pragma currently has no effects on access to unconstrained array types.
3567 @node Pragma Normalize_Scalars
3568 @unnumberedsec Pragma Normalize_Scalars
3569 @findex Normalize_Scalars
3573 @smallexample @c ada
3574 pragma Normalize_Scalars;
3578 This is a language defined pragma which is fully implemented in GNAT@. The
3579 effect is to cause all scalar objects that are not otherwise initialized
3580 to be initialized. The initial values are implementation dependent and
3584 @item Standard.Character
3586 Objects whose root type is Standard.Character are initialized to
3587 Character'Last unless the subtype range excludes NUL (in which case
3588 NUL is used). This choice will always generate an invalid value if
3591 @item Standard.Wide_Character
3593 Objects whose root type is Standard.Wide_Character are initialized to
3594 Wide_Character'Last unless the subtype range excludes NUL (in which case
3595 NUL is used). This choice will always generate an invalid value if
3598 @item Standard.Wide_Wide_Character
3600 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3601 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3602 which case NUL is used). This choice will always generate an invalid value if
3607 Objects of an integer type are treated differently depending on whether
3608 negative values are present in the subtype. If no negative values are
3609 present, then all one bits is used as the initial value except in the
3610 special case where zero is excluded from the subtype, in which case
3611 all zero bits are used. This choice will always generate an invalid
3612 value if one exists.
3614 For subtypes with negative values present, the largest negative number
3615 is used, except in the unusual case where this largest negative number
3616 is in the subtype, and the largest positive number is not, in which case
3617 the largest positive value is used. This choice will always generate
3618 an invalid value if one exists.
3620 @item Floating-Point Types
3621 Objects of all floating-point types are initialized to all 1-bits. For
3622 standard IEEE format, this corresponds to a NaN (not a number) which is
3623 indeed an invalid value.
3625 @item Fixed-Point Types
3626 Objects of all fixed-point types are treated as described above for integers,
3627 with the rules applying to the underlying integer value used to represent
3628 the fixed-point value.
3631 Objects of a modular type are initialized to all one bits, except in
3632 the special case where zero is excluded from the subtype, in which
3633 case all zero bits are used. This choice will always generate an
3634 invalid value if one exists.
3636 @item Enumeration types
3637 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3638 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3639 whose Pos value is zero, in which case a code of zero is used. This choice
3640 will always generate an invalid value if one exists.
3644 @node Pragma Obsolescent
3645 @unnumberedsec Pragma Obsolescent
3650 @smallexample @c ada
3653 pragma Obsolescent (
3654 [Message =>] static_string_EXPRESSION
3655 [,[Version =>] Ada_05]]);
3657 pragma Obsolescent (
3659 [,[Message =>] static_string_EXPRESSION
3660 [,[Version =>] Ada_05]] );
3664 This pragma can occur immediately following a declaration of an entity,
3665 including the case of a record component. If no Entity argument is present,
3666 then this declaration is the one to which the pragma applies. If an Entity
3667 parameter is present, it must either match the name of the entity in this
3668 declaration, or alternatively, the pragma can immediately follow an enumeration
3669 type declaration, where the Entity argument names one of the enumeration
3672 This pragma is used to indicate that the named entity
3673 is considered obsolescent and should not be used. Typically this is
3674 used when an API must be modified by eventually removing or modifying
3675 existing subprograms or other entities. The pragma can be used at an
3676 intermediate stage when the entity is still present, but will be
3679 The effect of this pragma is to output a warning message on a reference to
3680 an entity thus marked that the subprogram is obsolescent if the appropriate
3681 warning option in the compiler is activated. If the Message parameter is
3682 present, then a second warning message is given containing this text. In
3683 addition, a reference to the entity is considered to be a violation of pragma
3684 Restrictions (No_Obsolescent_Features).
3686 This pragma can also be used as a program unit pragma for a package,
3687 in which case the entity name is the name of the package, and the
3688 pragma indicates that the entire package is considered
3689 obsolescent. In this case a client @code{with}'ing such a package
3690 violates the restriction, and the @code{with} statement is
3691 flagged with warnings if the warning option is set.
3693 If the Version parameter is present (which must be exactly
3694 the identifier Ada_05, no other argument is allowed), then the
3695 indication of obsolescence applies only when compiling in Ada 2005
3696 mode. This is primarily intended for dealing with the situations
3697 in the predefined library where subprograms or packages
3698 have become defined as obsolescent in Ada 2005
3699 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3701 The following examples show typical uses of this pragma:
3703 @smallexample @c ada
3705 pragma Obsolescent (p, Message => "use pp instead of p");
3710 pragma Obsolescent ("use q2new instead");
3712 type R is new integer;
3715 Message => "use RR in Ada 2005",
3725 type E is (a, bc, 'd', quack);
3726 pragma Obsolescent (Entity => bc)
3727 pragma Obsolescent (Entity => 'd')
3730 (a, b : character) return character;
3731 pragma Obsolescent (Entity => "+");
3736 Note that, as for all pragmas, if you use a pragma argument identifier,
3737 then all subsequent parameters must also use a pragma argument identifier.
3738 So if you specify "Entity =>" for the Entity argument, and a Message
3739 argument is present, it must be preceded by "Message =>".
3741 @node Pragma Optimize_Alignment
3742 @unnumberedsec Pragma Optimize_Alignment
3743 @findex Optimize_Alignment
3744 @cindex Alignment, default settings
3748 @smallexample @c ada
3749 pragma Optimize_Alignment (TIME | SPACE | OFF);
3753 This is a configuration pragma which affects the choice of default alignments
3754 for types where no alignment is explicitly specified. There is a time/space
3755 trade-off in the selection of these values. Large alignments result in more
3756 efficient code, at the expense of larger data space, since sizes have to be
3757 increased to match these alignments. Smaller alignments save space, but the
3758 access code is slower. The normal choice of default alignments (which is what
3759 you get if you do not use this pragma, or if you use an argument of OFF),
3760 tries to balance these two requirements.
3762 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3763 First any packed record is given an alignment of 1. Second, if a size is given
3764 for the type, then the alignment is chosen to avoid increasing this size. For
3767 @smallexample @c ada
3777 In the default mode, this type gets an alignment of 4, so that access to the
3778 Integer field X are efficient. But this means that objects of the type end up
3779 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3780 allowed to be bigger than the size of the type, but it can waste space if for
3781 example fields of type R appear in an enclosing record. If the above type is
3782 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3784 Specifying TIME causes larger default alignments to be chosen in the case of
3785 small types with sizes that are not a power of 2. For example, consider:
3787 @smallexample @c ada
3799 The default alignment for this record is normally 1, but if this type is
3800 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3801 to 4, which wastes space for objects of the type, since they are now 4 bytes
3802 long, but results in more efficient access when the whole record is referenced.
3804 As noted above, this is a configuration pragma, and there is a requirement
3805 that all units in a partition be compiled with a consistent setting of the
3806 optimization setting. This would normally be achieved by use of a configuration
3807 pragma file containing the appropriate setting. The exception to this rule is
3808 that units with an explicit configuration pragma in the same file as the source
3809 unit are excluded from the consistency check, as are all predefined units. The
3810 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3811 pragma appears at the start of the file.
3813 @node Pragma Ordered
3814 @unnumberedsec Pragma Ordered
3816 @findex pragma @code{Ordered}
3820 @smallexample @c ada
3821 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3825 Most enumeration types are from a conceptual point of view unordered.
3826 For example, consider:
3828 @smallexample @c ada
3829 type Color is (Red, Blue, Green, Yellow);
3833 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
3834 but really these relations make no sense; the enumeration type merely
3835 specifies a set of possible colors, and the order is unimportant.
3837 For unordered enumeration types, it is generally a good idea if
3838 clients avoid comparisons (other than equality or inequality) and
3839 explicit ranges. (A @emph{client} is a unit where the type is referenced,
3840 other than the unit where the type is declared, its body, and its subunits.)
3841 For example, if code buried in some client says:
3843 @smallexample @c ada
3844 if Current_Color < Yellow then ...
3845 if Current_Color in Blue .. Green then ...
3849 then the client code is relying on the order, which is undesirable.
3850 It makes the code hard to read and creates maintenance difficulties if
3851 entries have to be added to the enumeration type. Instead,
3852 the code in the client should list the possibilities, or an
3853 appropriate subtype should be declared in the unit that declares
3854 the original enumeration type. E.g., the following subtype could
3855 be declared along with the type @code{Color}:
3857 @smallexample @c ada
3858 subtype RBG is Color range Red .. Green;
3862 and then the client could write:
3864 @smallexample @c ada
3865 if Current_Color in RBG then ...
3866 if Current_Color = Blue or Current_Color = Green then ...
3870 However, some enumeration types are legitimately ordered from a conceptual
3871 point of view. For example, if you declare:
3873 @smallexample @c ada
3874 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3878 then the ordering imposed by the language is reasonable, and
3879 clients can depend on it, writing for example:
3881 @smallexample @c ada
3882 if D in Mon .. Fri then ...
3887 The pragma @option{Ordered} is provided to mark enumeration types that
3888 are conceptually ordered, alerting the reader that clients may depend
3889 on the ordering. GNAT provides a pragma to mark enumerations as ordered
3890 rather than one to mark them as unordered, since in our experience,
3891 the great majority of enumeration types are conceptually unordered.
3893 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
3894 and @code{Wide_Wide_Character}
3895 are considered to be ordered types, so each is declared with a
3896 pragma @code{Ordered} in package @code{Standard}.
3898 Normally pragma @code{Ordered} serves only as documentation and a guide for
3899 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
3900 requests warnings for inappropriate uses (comparisons and explicit
3901 subranges) for unordered types. If this switch is used, then any
3902 enumeration type not marked with pragma @code{Ordered} will be considered
3903 as unordered, and will generate warnings for inappropriate uses.
3905 For additional information please refer to the description of the
3906 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
3908 @node Pragma Passive
3909 @unnumberedsec Pragma Passive
3914 @smallexample @c ada
3915 pragma Passive [(Semaphore | No)];
3919 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3920 compatibility with DEC Ada 83 implementations, where it is used within a
3921 task definition to request that a task be made passive. If the argument
3922 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3923 treats the pragma as an assertion that the containing task is passive
3924 and that optimization of context switch with this task is permitted and
3925 desired. If the argument @code{No} is present, the task must not be
3926 optimized. GNAT does not attempt to optimize any tasks in this manner
3927 (since protected objects are available in place of passive tasks).
3929 @node Pragma Persistent_BSS
3930 @unnumberedsec Pragma Persistent_BSS
3931 @findex Persistent_BSS
3935 @smallexample @c ada
3936 pragma Persistent_BSS [(LOCAL_NAME)]
3940 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3941 section. On some targets the linker and loader provide for special
3942 treatment of this section, allowing a program to be reloaded without
3943 affecting the contents of this data (hence the name persistent).
3945 There are two forms of usage. If an argument is given, it must be the
3946 local name of a library level object, with no explicit initialization
3947 and whose type is potentially persistent. If no argument is given, then
3948 the pragma is a configuration pragma, and applies to all library level
3949 objects with no explicit initialization of potentially persistent types.
3951 A potentially persistent type is a scalar type, or a non-tagged,
3952 non-discriminated record, all of whose components have no explicit
3953 initialization and are themselves of a potentially persistent type,
3954 or an array, all of whose constraints are static, and whose component
3955 type is potentially persistent.
3957 If this pragma is used on a target where this feature is not supported,
3958 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3960 @node Pragma Polling
3961 @unnumberedsec Pragma Polling
3966 @smallexample @c ada
3967 pragma Polling (ON | OFF);
3971 This pragma controls the generation of polling code. This is normally off.
3972 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3973 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3974 runtime library, and can be found in file @file{a-excpol.adb}.
3976 Pragma @code{Polling} can appear as a configuration pragma (for example it
3977 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3978 can be used in the statement or declaration sequence to control polling
3981 A call to the polling routine is generated at the start of every loop and
3982 at the start of every subprogram call. This guarantees that the @code{Poll}
3983 routine is called frequently, and places an upper bound (determined by
3984 the complexity of the code) on the period between two @code{Poll} calls.
3986 The primary purpose of the polling interface is to enable asynchronous
3987 aborts on targets that cannot otherwise support it (for example Windows
3988 NT), but it may be used for any other purpose requiring periodic polling.
3989 The standard version is null, and can be replaced by a user program. This
3990 will require re-compilation of the @code{Ada.Exceptions} package that can
3991 be found in files @file{a-except.ads} and @file{a-except.adb}.
3993 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3994 distribution) is used to enable the asynchronous abort capability on
3995 targets that do not normally support the capability. The version of
3996 @code{Poll} in this file makes a call to the appropriate runtime routine
3997 to test for an abort condition.
3999 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4000 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4003 @node Pragma Postcondition
4004 @unnumberedsec Pragma Postcondition
4005 @cindex Postconditions
4006 @cindex Checks, postconditions
4007 @findex Postconditions
4011 @smallexample @c ada
4012 pragma Postcondition (
4013 [Check =>] Boolean_Expression
4014 [,[Message =>] String_Expression]);
4018 The @code{Postcondition} pragma allows specification of automatic
4019 postcondition checks for subprograms. These checks are similar to
4020 assertions, but are automatically inserted just prior to the return
4021 statements of the subprogram with which they are associated (including
4022 implicit returns at the end of procedure bodies and associated
4023 exception handlers).
4025 In addition, the boolean expression which is the condition which
4026 must be true may contain references to function'Result in the case
4027 of a function to refer to the returned value.
4029 @code{Postcondition} pragmas may appear either immediately following the
4030 (separate) declaration of a subprogram, or at the start of the
4031 declarations of a subprogram body. Only other pragmas may intervene
4032 (that is appear between the subprogram declaration and its
4033 postconditions, or appear before the postcondition in the
4034 declaration sequence in a subprogram body). In the case of a
4035 postcondition appearing after a subprogram declaration, the
4036 formal arguments of the subprogram are visible, and can be
4037 referenced in the postcondition expressions.
4039 The postconditions are collected and automatically tested just
4040 before any return (implicit or explicit) in the subprogram body.
4041 A postcondition is only recognized if postconditions are active
4042 at the time the pragma is encountered. The compiler switch @option{gnata}
4043 turns on all postconditions by default, and pragma @code{Check_Policy}
4044 with an identifier of @code{Postcondition} can also be used to
4045 control whether postconditions are active.
4047 The general approach is that postconditions are placed in the spec
4048 if they represent functional aspects which make sense to the client.
4049 For example we might have:
4051 @smallexample @c ada
4052 function Direction return Integer;
4053 pragma Postcondition
4054 (Direction'Result = +1
4056 Direction'Result = -1);
4060 which serves to document that the result must be +1 or -1, and
4061 will test that this is the case at run time if postcondition
4064 Postconditions within the subprogram body can be used to
4065 check that some internal aspect of the implementation,
4066 not visible to the client, is operating as expected.
4067 For instance if a square root routine keeps an internal
4068 counter of the number of times it is called, then we
4069 might have the following postcondition:
4071 @smallexample @c ada
4072 Sqrt_Calls : Natural := 0;
4074 function Sqrt (Arg : Float) return Float is
4075 pragma Postcondition
4076 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4082 As this example, shows, the use of the @code{Old} attribute
4083 is often useful in postconditions to refer to the state on
4084 entry to the subprogram.
4086 Note that postconditions are only checked on normal returns
4087 from the subprogram. If an abnormal return results from
4088 raising an exception, then the postconditions are not checked.
4090 If a postcondition fails, then the exception
4091 @code{System.Assertions.Assert_Failure} is raised. If
4092 a message argument was supplied, then the given string
4093 will be used as the exception message. If no message
4094 argument was supplied, then the default message has
4095 the form "Postcondition failed at file:line". The
4096 exception is raised in the context of the subprogram
4097 body, so it is possible to catch postcondition failures
4098 within the subprogram body itself.
4100 Within a package spec, normal visibility rules
4101 in Ada would prevent forward references within a
4102 postcondition pragma to functions defined later in
4103 the same package. This would introduce undesirable
4104 ordering constraints. To avoid this problem, all
4105 postcondition pragmas are analyzed at the end of
4106 the package spec, allowing forward references.
4108 The following example shows that this even allows
4109 mutually recursive postconditions as in:
4111 @smallexample @c ada
4112 package Parity_Functions is
4113 function Odd (X : Natural) return Boolean;
4114 pragma Postcondition
4118 (x /= 0 and then Even (X - 1))));
4120 function Even (X : Natural) return Boolean;
4121 pragma Postcondition
4125 (x /= 1 and then Odd (X - 1))));
4127 end Parity_Functions;
4131 There are no restrictions on the complexity or form of
4132 conditions used within @code{Postcondition} pragmas.
4133 The following example shows that it is even possible
4134 to verify performance behavior.
4136 @smallexample @c ada
4139 Performance : constant Float;
4140 -- Performance constant set by implementation
4141 -- to match target architecture behavior.
4143 procedure Treesort (Arg : String);
4144 -- Sorts characters of argument using N*logN sort
4145 pragma Postcondition
4146 (Float (Clock - Clock'Old) <=
4147 Float (Arg'Length) *
4148 log (Float (Arg'Length)) *
4154 Note: postcondition pragmas associated with subprograms that are
4155 marked as Inline_Always, or those marked as Inline with front-end
4156 inlining (-gnatN option set) are accepted and legality-checked
4157 by the compiler, but are ignored at run-time even if postcondition
4158 checking is enabled.
4160 @node Pragma Precondition
4161 @unnumberedsec Pragma Precondition
4162 @cindex Preconditions
4163 @cindex Checks, preconditions
4164 @findex Preconditions
4168 @smallexample @c ada
4169 pragma Precondition (
4170 [Check =>] Boolean_Expression
4171 [,[Message =>] String_Expression]);
4175 The @code{Precondition} pragma is similar to @code{Postcondition}
4176 except that the corresponding checks take place immediately upon
4177 entry to the subprogram, and if a precondition fails, the exception
4178 is raised in the context of the caller, and the attribute 'Result
4179 cannot be used within the precondition expression.
4181 Otherwise, the placement and visibility rules are identical to those
4182 described for postconditions. The following is an example of use
4183 within a package spec:
4185 @smallexample @c ada
4186 package Math_Functions is
4188 function Sqrt (Arg : Float) return Float;
4189 pragma Precondition (Arg >= 0.0)
4195 @code{Precondition} pragmas may appear either immediately following the
4196 (separate) declaration of a subprogram, or at the start of the
4197 declarations of a subprogram body. Only other pragmas may intervene
4198 (that is appear between the subprogram declaration and its
4199 postconditions, or appear before the postcondition in the
4200 declaration sequence in a subprogram body).
4202 Note: postcondition pragmas associated with subprograms that are
4203 marked as Inline_Always, or those marked as Inline with front-end
4204 inlining (-gnatN option set) are accepted and legality-checked
4205 by the compiler, but are ignored at run-time even if postcondition
4206 checking is enabled.
4208 @node Pragma Profile (Ravenscar)
4209 @unnumberedsec Pragma Profile (Ravenscar)
4214 @smallexample @c ada
4215 pragma Profile (Ravenscar);
4219 A configuration pragma that establishes the following set of configuration
4223 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4224 [RM D.2.2] Tasks are dispatched following a preemptive
4225 priority-ordered scheduling policy.
4227 @item Locking_Policy (Ceiling_Locking)
4228 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4229 the ceiling priority of the corresponding protected object.
4231 @c @item Detect_Blocking
4232 @c This pragma forces the detection of potentially blocking operations within a
4233 @c protected operation, and to raise Program_Error if that happens.
4237 plus the following set of restrictions:
4240 @item Max_Entry_Queue_Length => 1
4241 Defines the maximum number of calls that are queued on a (protected) entry.
4242 Note that this restrictions is checked at run time. Violation of this
4243 restriction results in the raising of Program_Error exception at the point of
4244 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4245 always 1 and hence no task can be queued on a protected entry.
4247 @item Max_Protected_Entries => 1
4248 [RM D.7] Specifies the maximum number of entries per protected type. The
4249 bounds of every entry family of a protected unit shall be static, or shall be
4250 defined by a discriminant of a subtype whose corresponding bound is static.
4251 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4253 @item Max_Task_Entries => 0
4254 [RM D.7] Specifies the maximum number of entries
4255 per task. The bounds of every entry family
4256 of a task unit shall be static, or shall be
4257 defined by a discriminant of a subtype whose
4258 corresponding bound is static. A value of zero
4259 indicates that no rendezvous are possible. For
4260 the Profile (Ravenscar), the value of Max_Task_Entries is always
4263 @item No_Abort_Statements
4264 [RM D.7] There are no abort_statements, and there are
4265 no calls to Task_Identification.Abort_Task.
4267 @item No_Dynamic_Attachment
4268 There is no call to any of the operations defined in package Ada.Interrupts
4269 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4270 Detach_Handler, and Reference).
4272 @item No_Dynamic_Priorities
4273 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4275 @item No_Implicit_Heap_Allocations
4276 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4278 @item No_Local_Protected_Objects
4279 Protected objects and access types that designate
4280 such objects shall be declared only at library level.
4282 @item No_Local_Timing_Events
4283 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4284 declared at the library level.
4286 @item No_Protected_Type_Allocators
4287 There are no allocators for protected types or
4288 types containing protected subcomponents.
4290 @item No_Relative_Delay
4291 There are no delay_relative statements.
4293 @item No_Requeue_Statements
4294 Requeue statements are not allowed.
4296 @item No_Select_Statements
4297 There are no select_statements.
4299 @item No_Specific_Termination_Handlers
4300 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4301 or to Ada.Task_Termination.Specific_Handler.
4303 @item No_Task_Allocators
4304 [RM D.7] There are no allocators for task types
4305 or types containing task subcomponents.
4307 @item No_Task_Hierarchy
4308 [RM D.7] All (non-environment) tasks depend
4309 directly on the environment task of the partition.
4311 @item No_Task_Termination
4312 Tasks which terminate are erroneous.
4314 @item Simple_Barriers
4315 Entry barrier condition expressions shall be either static
4316 boolean expressions or boolean objects which are declared in
4317 the protected type which contains the entry.
4321 The Ravenscar profile also includes the following restrictions that specify
4322 that there are no semantic dependences on the corresponding predefined
4326 @item No_Dependence => Ada.Asynchronous_Task_Control
4327 @item No_Dependence => Ada.Calendar
4328 @item No_Dependence => Ada.Execution_Time.Group_Budget
4329 @item No_Dependence => Ada.Execution_Time.Timers
4330 @item No_Dependence => Ada.Task_Attributes
4331 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4336 This set of configuration pragmas and restrictions correspond to the
4337 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4338 published by the @cite{International Real-Time Ada Workshop}, 1997,
4339 and whose most recent description is available at
4340 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4342 The original definition of the profile was revised at subsequent IRTAW
4343 meetings. It has been included in the ISO
4344 @cite{Guide for the Use of the Ada Programming Language in High
4345 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4346 the next revision of the standard. The formal definition given by
4347 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4348 AI-305) available at
4349 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4350 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4352 The above set is a superset of the restrictions provided by pragma
4353 @code{Profile (Restricted)}, it includes six additional restrictions
4354 (@code{Simple_Barriers}, @code{No_Select_Statements},
4355 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4356 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4357 that pragma @code{Profile (Ravenscar)}, like the pragma
4358 @code{Profile (Restricted)},
4359 automatically causes the use of a simplified,
4360 more efficient version of the tasking run-time system.
4362 @node Pragma Profile (Restricted)
4363 @unnumberedsec Pragma Profile (Restricted)
4364 @findex Restricted Run Time
4368 @smallexample @c ada
4369 pragma Profile (Restricted);
4373 A configuration pragma that establishes the following set of restrictions:
4376 @item No_Abort_Statements
4377 @item No_Entry_Queue
4378 @item No_Task_Hierarchy
4379 @item No_Task_Allocators
4380 @item No_Dynamic_Priorities
4381 @item No_Terminate_Alternatives
4382 @item No_Dynamic_Attachment
4383 @item No_Protected_Type_Allocators
4384 @item No_Local_Protected_Objects
4385 @item No_Requeue_Statements
4386 @item No_Task_Attributes_Package
4387 @item Max_Asynchronous_Select_Nesting = 0
4388 @item Max_Task_Entries = 0
4389 @item Max_Protected_Entries = 1
4390 @item Max_Select_Alternatives = 0
4394 This set of restrictions causes the automatic selection of a simplified
4395 version of the run time that provides improved performance for the
4396 limited set of tasking functionality permitted by this set of restrictions.
4398 @node Pragma Psect_Object
4399 @unnumberedsec Pragma Psect_Object
4400 @findex Psect_Object
4404 @smallexample @c ada
4405 pragma Psect_Object (
4406 [Internal =>] LOCAL_NAME,
4407 [, [External =>] EXTERNAL_SYMBOL]
4408 [, [Size =>] EXTERNAL_SYMBOL]);
4412 | static_string_EXPRESSION
4416 This pragma is identical in effect to pragma @code{Common_Object}.
4418 @node Pragma Pure_Function
4419 @unnumberedsec Pragma Pure_Function
4420 @findex Pure_Function
4424 @smallexample @c ada
4425 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4429 This pragma appears in the same declarative part as a function
4430 declaration (or a set of function declarations if more than one
4431 overloaded declaration exists, in which case the pragma applies
4432 to all entities). It specifies that the function @code{Entity} is
4433 to be considered pure for the purposes of code generation. This means
4434 that the compiler can assume that there are no side effects, and
4435 in particular that two calls with identical arguments produce the
4436 same result. It also means that the function can be used in an
4439 Note that, quite deliberately, there are no static checks to try
4440 to ensure that this promise is met, so @code{Pure_Function} can be used
4441 with functions that are conceptually pure, even if they do modify
4442 global variables. For example, a square root function that is
4443 instrumented to count the number of times it is called is still
4444 conceptually pure, and can still be optimized, even though it
4445 modifies a global variable (the count). Memo functions are another
4446 example (where a table of previous calls is kept and consulted to
4447 avoid re-computation).
4449 Note also that the normal rules excluding optimization of subprograms
4450 in pure units (when parameter types are descended from System.Address,
4451 or when the full view of a parameter type is limited), do not apply
4452 for the Pure_Function case. If you explicitly specify Pure_Function,
4453 the compiler may optimize away calls with identical arguments, and
4454 if that results in unexpected behavior, the proper action is not to
4455 use the pragma for subprograms that are not (conceptually) pure.
4458 Note: Most functions in a @code{Pure} package are automatically pure, and
4459 there is no need to use pragma @code{Pure_Function} for such functions. One
4460 exception is any function that has at least one formal of type
4461 @code{System.Address} or a type derived from it. Such functions are not
4462 considered pure by default, since the compiler assumes that the
4463 @code{Address} parameter may be functioning as a pointer and that the
4464 referenced data may change even if the address value does not.
4465 Similarly, imported functions are not considered to be pure by default,
4466 since there is no way of checking that they are in fact pure. The use
4467 of pragma @code{Pure_Function} for such a function will override these default
4468 assumption, and cause the compiler to treat a designated subprogram as pure
4471 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4472 applies to the underlying renamed function. This can be used to
4473 disambiguate cases of overloading where some but not all functions
4474 in a set of overloaded functions are to be designated as pure.
4476 If pragma @code{Pure_Function} is applied to a library level function, the
4477 function is also considered pure from an optimization point of view, but the
4478 unit is not a Pure unit in the categorization sense. So for example, a function
4479 thus marked is free to @code{with} non-pure units.
4481 @node Pragma Restriction_Warnings
4482 @unnumberedsec Pragma Restriction_Warnings
4483 @findex Restriction_Warnings
4487 @smallexample @c ada
4488 pragma Restriction_Warnings
4489 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4493 This pragma allows a series of restriction identifiers to be
4494 specified (the list of allowed identifiers is the same as for
4495 pragma @code{Restrictions}). For each of these identifiers
4496 the compiler checks for violations of the restriction, but
4497 generates a warning message rather than an error message
4498 if the restriction is violated.
4501 @unnumberedsec Pragma Shared
4505 This pragma is provided for compatibility with Ada 83. The syntax and
4506 semantics are identical to pragma Atomic.
4508 @node Pragma Short_Circuit_And_Or
4509 @unnumberedsec Pragma Short_Circuit_And_Or
4510 @findex Short_Circuit_And_Or
4513 This configuration pragma causes any occurrence of the AND operator applied to
4514 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4515 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4516 may be useful in the context of certification protocols requiring the use of
4517 short-circuited logical operators. If this configuration pragma occurs locally
4518 within the file being compiled, it applies only to the file being compiled.
4519 There is no requirement that all units in a partition use this option.
4521 @node Pragma Short_Descriptors
4522 @unnumberedsec Pragma Short_Descriptors
4523 @findex Short_Descriptors
4527 @smallexample @c ada
4528 pragma Short_Descriptors
4532 In VMS versions of the compiler, this configuration pragma causes all
4533 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4534 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4535 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4538 @node Pragma Source_File_Name
4539 @unnumberedsec Pragma Source_File_Name
4540 @findex Source_File_Name
4544 @smallexample @c ada
4545 pragma Source_File_Name (
4546 [Unit_Name =>] unit_NAME,
4547 Spec_File_Name => STRING_LITERAL,
4548 [Index => INTEGER_LITERAL]);
4550 pragma Source_File_Name (
4551 [Unit_Name =>] unit_NAME,
4552 Body_File_Name => STRING_LITERAL,
4553 [Index => INTEGER_LITERAL]);
4557 Use this to override the normal naming convention. It is a configuration
4558 pragma, and so has the usual applicability of configuration pragmas
4559 (i.e.@: it applies to either an entire partition, or to all units in a
4560 compilation, or to a single unit, depending on how it is used.
4561 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4562 the second argument is required, and indicates whether this is the file
4563 name for the spec or for the body.
4565 The optional Index argument should be used when a file contains multiple
4566 units, and when you do not want to use @code{gnatchop} to separate then
4567 into multiple files (which is the recommended procedure to limit the
4568 number of recompilations that are needed when some sources change).
4569 For instance, if the source file @file{source.ada} contains
4571 @smallexample @c ada
4583 you could use the following configuration pragmas:
4585 @smallexample @c ada
4586 pragma Source_File_Name
4587 (B, Spec_File_Name => "source.ada", Index => 1);
4588 pragma Source_File_Name
4589 (A, Body_File_Name => "source.ada", Index => 2);
4592 Note that the @code{gnatname} utility can also be used to generate those
4593 configuration pragmas.
4595 Another form of the @code{Source_File_Name} pragma allows
4596 the specification of patterns defining alternative file naming schemes
4597 to apply to all files.
4599 @smallexample @c ada
4600 pragma Source_File_Name
4601 ( [Spec_File_Name =>] STRING_LITERAL
4602 [,[Casing =>] CASING_SPEC]
4603 [,[Dot_Replacement =>] STRING_LITERAL]);
4605 pragma Source_File_Name
4606 ( [Body_File_Name =>] STRING_LITERAL
4607 [,[Casing =>] CASING_SPEC]
4608 [,[Dot_Replacement =>] STRING_LITERAL]);
4610 pragma Source_File_Name
4611 ( [Subunit_File_Name =>] STRING_LITERAL
4612 [,[Casing =>] CASING_SPEC]
4613 [,[Dot_Replacement =>] STRING_LITERAL]);
4615 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4619 The first argument is a pattern that contains a single asterisk indicating
4620 the point at which the unit name is to be inserted in the pattern string
4621 to form the file name. The second argument is optional. If present it
4622 specifies the casing of the unit name in the resulting file name string.
4623 The default is lower case. Finally the third argument allows for systematic
4624 replacement of any dots in the unit name by the specified string literal.
4626 Note that Source_File_Name pragmas should not be used if you are using
4627 project files. The reason for this rule is that the project manager is not
4628 aware of these pragmas, and so other tools that use the projet file would not
4629 be aware of the intended naming conventions. If you are using project files,
4630 file naming is controlled by Source_File_Name_Project pragmas, which are
4631 usually supplied automatically by the project manager. A pragma
4632 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
4634 For more details on the use of the @code{Source_File_Name} pragma,
4635 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4636 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4639 @node Pragma Source_File_Name_Project
4640 @unnumberedsec Pragma Source_File_Name_Project
4641 @findex Source_File_Name_Project
4644 This pragma has the same syntax and semantics as pragma Source_File_Name.
4645 It is only allowed as a stand alone configuration pragma.
4646 It cannot appear after a @ref{Pragma Source_File_Name}, and
4647 most importantly, once pragma Source_File_Name_Project appears,
4648 no further Source_File_Name pragmas are allowed.
4650 The intention is that Source_File_Name_Project pragmas are always
4651 generated by the Project Manager in a manner consistent with the naming
4652 specified in a project file, and when naming is controlled in this manner,
4653 it is not permissible to attempt to modify this naming scheme using
4654 Source_File_Name or Source_File_Name_Project pragmas (which would not be
4655 known to the project manager).
4657 @node Pragma Source_Reference
4658 @unnumberedsec Pragma Source_Reference
4659 @findex Source_Reference
4663 @smallexample @c ada
4664 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4668 This pragma must appear as the first line of a source file.
4669 @var{integer_literal} is the logical line number of the line following
4670 the pragma line (for use in error messages and debugging
4671 information). @var{string_literal} is a static string constant that
4672 specifies the file name to be used in error messages and debugging
4673 information. This is most notably used for the output of @code{gnatchop}
4674 with the @option{-r} switch, to make sure that the original unchopped
4675 source file is the one referred to.
4677 The second argument must be a string literal, it cannot be a static
4678 string expression other than a string literal. This is because its value
4679 is needed for error messages issued by all phases of the compiler.
4681 @node Pragma Static_Elaboration_Desired
4682 @unnumberedsec Pragma Static_Elaboration_Desired
4683 @findex Static_Elaboration_Desired
4687 @smallexample @c ada
4688 pragma Static_Elaboration_Desired;
4692 This pragma is used to indicate that the compiler should attempt to initialize
4693 statically the objects declared in the library unit to which the pragma applies,
4694 when these objects are initialized (explicitly or implicitly) by an aggregate.
4695 In the absence of this pragma, aggregates in object declarations are expanded
4696 into assignments and loops, even when the aggregate components are static
4697 constants. When the aggregate is present the compiler builds a static expression
4698 that requires no run-time code, so that the initialized object can be placed in
4699 read-only data space. If the components are not static, or the aggregate has
4700 more that 100 components, the compiler emits a warning that the pragma cannot
4701 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
4702 construction of larger aggregates with static components that include an others
4705 @node Pragma Stream_Convert
4706 @unnumberedsec Pragma Stream_Convert
4707 @findex Stream_Convert
4711 @smallexample @c ada
4712 pragma Stream_Convert (
4713 [Entity =>] type_LOCAL_NAME,
4714 [Read =>] function_NAME,
4715 [Write =>] function_NAME);
4719 This pragma provides an efficient way of providing stream functions for
4720 types defined in packages. Not only is it simpler to use than declaring
4721 the necessary functions with attribute representation clauses, but more
4722 significantly, it allows the declaration to made in such a way that the
4723 stream packages are not loaded unless they are needed. The use of
4724 the Stream_Convert pragma adds no overhead at all, unless the stream
4725 attributes are actually used on the designated type.
4727 The first argument specifies the type for which stream functions are
4728 provided. The second parameter provides a function used to read values
4729 of this type. It must name a function whose argument type may be any
4730 subtype, and whose returned type must be the type given as the first
4731 argument to the pragma.
4733 The meaning of the @var{Read}
4734 parameter is that if a stream attribute directly
4735 or indirectly specifies reading of the type given as the first parameter,
4736 then a value of the type given as the argument to the Read function is
4737 read from the stream, and then the Read function is used to convert this
4738 to the required target type.
4740 Similarly the @var{Write} parameter specifies how to treat write attributes
4741 that directly or indirectly apply to the type given as the first parameter.
4742 It must have an input parameter of the type specified by the first parameter,
4743 and the return type must be the same as the input type of the Read function.
4744 The effect is to first call the Write function to convert to the given stream
4745 type, and then write the result type to the stream.
4747 The Read and Write functions must not be overloaded subprograms. If necessary
4748 renamings can be supplied to meet this requirement.
4749 The usage of this attribute is best illustrated by a simple example, taken
4750 from the GNAT implementation of package Ada.Strings.Unbounded:
4752 @smallexample @c ada
4753 function To_Unbounded (S : String)
4754 return Unbounded_String
4755 renames To_Unbounded_String;
4757 pragma Stream_Convert
4758 (Unbounded_String, To_Unbounded, To_String);
4762 The specifications of the referenced functions, as given in the Ada
4763 Reference Manual are:
4765 @smallexample @c ada
4766 function To_Unbounded_String (Source : String)
4767 return Unbounded_String;
4769 function To_String (Source : Unbounded_String)
4774 The effect is that if the value of an unbounded string is written to a stream,
4775 then the representation of the item in the stream is in the same format that
4776 would be used for @code{Standard.String'Output}, and this same representation
4777 is expected when a value of this type is read from the stream. Note that the
4778 value written always includes the bounds, even for Unbounded_String'Write,
4779 since Unbounded_String is not an array type.
4781 @node Pragma Style_Checks
4782 @unnumberedsec Pragma Style_Checks
4783 @findex Style_Checks
4787 @smallexample @c ada
4788 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4789 On | Off [, LOCAL_NAME]);
4793 This pragma is used in conjunction with compiler switches to control the
4794 built in style checking provided by GNAT@. The compiler switches, if set,
4795 provide an initial setting for the switches, and this pragma may be used
4796 to modify these settings, or the settings may be provided entirely by
4797 the use of the pragma. This pragma can be used anywhere that a pragma
4798 is legal, including use as a configuration pragma (including use in
4799 the @file{gnat.adc} file).
4801 The form with a string literal specifies which style options are to be
4802 activated. These are additive, so they apply in addition to any previously
4803 set style check options. The codes for the options are the same as those
4804 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4805 For example the following two methods can be used to enable
4810 @smallexample @c ada
4811 pragma Style_Checks ("l");
4816 gcc -c -gnatyl @dots{}
4821 The form ALL_CHECKS activates all standard checks (its use is equivalent
4822 to the use of the @code{gnaty} switch with no options. @xref{Top,
4823 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4824 @value{EDITION} User's Guide}, for details.)
4826 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4827 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4828 options (i.e. equivalent to -gnatyg).
4830 The forms with @code{Off} and @code{On}
4831 can be used to temporarily disable style checks
4832 as shown in the following example:
4834 @smallexample @c ada
4838 pragma Style_Checks ("k"); -- requires keywords in lower case
4839 pragma Style_Checks (Off); -- turn off style checks
4840 NULL; -- this will not generate an error message
4841 pragma Style_Checks (On); -- turn style checks back on
4842 NULL; -- this will generate an error message
4846 Finally the two argument form is allowed only if the first argument is
4847 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4848 for the specified entity, as shown in the following example:
4850 @smallexample @c ada
4854 pragma Style_Checks ("r"); -- require consistency of identifier casing
4856 Rf1 : Integer := ARG; -- incorrect, wrong case
4857 pragma Style_Checks (Off, Arg);
4858 Rf2 : Integer := ARG; -- OK, no error
4861 @node Pragma Subtitle
4862 @unnumberedsec Pragma Subtitle
4867 @smallexample @c ada
4868 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4872 This pragma is recognized for compatibility with other Ada compilers
4873 but is ignored by GNAT@.
4875 @node Pragma Suppress
4876 @unnumberedsec Pragma Suppress
4881 @smallexample @c ada
4882 pragma Suppress (Identifier [, [On =>] Name]);
4886 This is a standard pragma, and supports all the check names required in
4887 the RM. It is included here because GNAT recognizes one additional check
4888 name: @code{Alignment_Check} which can be used to suppress alignment checks
4889 on addresses used in address clauses. Such checks can also be suppressed
4890 by suppressing range checks, but the specific use of @code{Alignment_Check}
4891 allows suppression of alignment checks without suppressing other range checks.
4893 Note that pragma Suppress gives the compiler permission to omit
4894 checks, but does not require the compiler to omit checks. The compiler
4895 will generate checks if they are essentially free, even when they are
4896 suppressed. In particular, if the compiler can prove that a certain
4897 check will necessarily fail, it will generate code to do an
4898 unconditional ``raise'', even if checks are suppressed. The compiler
4901 Of course, run-time checks are omitted whenever the compiler can prove
4902 that they will not fail, whether or not checks are suppressed.
4904 @node Pragma Suppress_All
4905 @unnumberedsec Pragma Suppress_All
4906 @findex Suppress_All
4910 @smallexample @c ada
4911 pragma Suppress_All;
4915 This pragma can appear anywhere within a unit.
4916 The effect is to apply @code{Suppress (All_Checks)} to the unit
4917 in which it appears. This pragma is implemented for compatibility with DEC
4918 Ada 83 usage where it appears at the end of a unit, and for compatibility
4919 with Rational Ada, where it appears as a program unit pragma.
4920 The use of the standard Ada pragma @code{Suppress (All_Checks)}
4921 as a normal configuration pragma is the preferred usage in GNAT@.
4923 @node Pragma Suppress_Exception_Locations
4924 @unnumberedsec Pragma Suppress_Exception_Locations
4925 @findex Suppress_Exception_Locations
4929 @smallexample @c ada
4930 pragma Suppress_Exception_Locations;
4934 In normal mode, a raise statement for an exception by default generates
4935 an exception message giving the file name and line number for the location
4936 of the raise. This is useful for debugging and logging purposes, but this
4937 entails extra space for the strings for the messages. The configuration
4938 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4939 generation of these strings, with the result that space is saved, but the
4940 exception message for such raises is null. This configuration pragma may
4941 appear in a global configuration pragma file, or in a specific unit as
4942 usual. It is not required that this pragma be used consistently within
4943 a partition, so it is fine to have some units within a partition compiled
4944 with this pragma and others compiled in normal mode without it.
4946 @node Pragma Suppress_Initialization
4947 @unnumberedsec Pragma Suppress_Initialization
4948 @findex Suppress_Initialization
4949 @cindex Suppressing initialization
4950 @cindex Initialization, suppression of
4954 @smallexample @c ada
4955 pragma Suppress_Initialization ([Entity =>] type_Name);
4959 This pragma suppresses any implicit or explicit initialization
4960 associated with the given type name for all variables of this type,
4961 including initialization resulting from the use of pragmas
4962 Normalize_Scalars or Initialize_Scalars.
4964 This is considered a representation item, so it cannot be given after
4965 the type is frozen. It applies to all subsequent object declarations,
4966 and also any allocator that creates objects of the type.
4968 If the pragma is given for the first subtype, then it is considered
4969 to apply to the base type and all its subtypes. If the pragma is given
4970 for other than a first subtype, then it applies only to the given subtype.
4971 The pragma may not be given after the type is frozen.
4973 @node Pragma Task_Info
4974 @unnumberedsec Pragma Task_Info
4979 @smallexample @c ada
4980 pragma Task_Info (EXPRESSION);
4984 This pragma appears within a task definition (like pragma
4985 @code{Priority}) and applies to the task in which it appears. The
4986 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4987 The @code{Task_Info} pragma provides system dependent control over
4988 aspects of tasking implementation, for example, the ability to map
4989 tasks to specific processors. For details on the facilities available
4990 for the version of GNAT that you are using, see the documentation
4991 in the spec of package System.Task_Info in the runtime
4994 @node Pragma Task_Name
4995 @unnumberedsec Pragma Task_Name
5000 @smallexample @c ada
5001 pragma Task_Name (string_EXPRESSION);
5005 This pragma appears within a task definition (like pragma
5006 @code{Priority}) and applies to the task in which it appears. The
5007 argument must be of type String, and provides a name to be used for
5008 the task instance when the task is created. Note that this expression
5009 is not required to be static, and in particular, it can contain
5010 references to task discriminants. This facility can be used to
5011 provide different names for different tasks as they are created,
5012 as illustrated in the example below.
5014 The task name is recorded internally in the run-time structures
5015 and is accessible to tools like the debugger. In addition the
5016 routine @code{Ada.Task_Identification.Image} will return this
5017 string, with a unique task address appended.
5019 @smallexample @c ada
5020 -- Example of the use of pragma Task_Name
5022 with Ada.Task_Identification;
5023 use Ada.Task_Identification;
5024 with Text_IO; use Text_IO;
5027 type Astring is access String;
5029 task type Task_Typ (Name : access String) is
5030 pragma Task_Name (Name.all);
5033 task body Task_Typ is
5034 Nam : constant String := Image (Current_Task);
5036 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5039 type Ptr_Task is access Task_Typ;
5040 Task_Var : Ptr_Task;
5044 new Task_Typ (new String'("This is task 1"));
5046 new Task_Typ (new String'("This is task 2"));
5050 @node Pragma Task_Storage
5051 @unnumberedsec Pragma Task_Storage
5052 @findex Task_Storage
5055 @smallexample @c ada
5056 pragma Task_Storage (
5057 [Task_Type =>] LOCAL_NAME,
5058 [Top_Guard =>] static_integer_EXPRESSION);
5062 This pragma specifies the length of the guard area for tasks. The guard
5063 area is an additional storage area allocated to a task. A value of zero
5064 means that either no guard area is created or a minimal guard area is
5065 created, depending on the target. This pragma can appear anywhere a
5066 @code{Storage_Size} attribute definition clause is allowed for a task
5069 @node Pragma Test_Case
5070 @unnumberedsec Pragma Test_Case
5076 @smallexample @c ada
5078 [Name =>] static_string_Expression
5079 ,[Mode =>] (Nominal | Robustness)
5080 [, Requires => Boolean_Expression]
5081 [, Ensures => Boolean_Expression]);
5085 The @code{Test_Case} pragma allows defining fine-grain specifications
5086 for use by testing and verification tools. The compiler checks its
5087 validity but the presence of pragma @code{Test_Case} does not lead to
5088 any modification of the code generated by the compiler.
5090 @code{Test_Case} pragmas may only appear immediately following the
5091 (separate) declaration of a subprogram in a package declaration, inside
5092 a package spec unit. Only other pragmas may intervene (that is appear
5093 between the subprogram declaration and a test case).
5095 The compiler checks that boolean expressions given in @code{Requires} and
5096 @code{Ensures} are valid, where the rules for @code{Requires} are the
5097 same as the rule for an expression in @code{Precondition} and the rules
5098 for @code{Ensures} are the same as the rule for an expression in
5099 @code{Postcondition}. In particular, attributes @code{'Old} and
5100 @code{'Result} can only be used within the @code{Ensures}
5101 expression. The following is an example of use within a package spec:
5103 @smallexample @c ada
5104 package Math_Functions is
5106 function Sqrt (Arg : Float) return Float;
5107 pragma Test_Case (Name => "Test 1",
5109 Requires => Arg < 100,
5110 Ensures => Sqrt'Result < 10);
5116 The meaning of a test case is that, if the associated subprogram is
5117 executed in a context where @code{Requires} holds, then @code{Ensures}
5118 should hold when the subprogram returns. Mode @code{Nominal} indicates
5119 that the input context should satisfy the precondition of the
5120 subprogram, and the output context should then satisfy its
5121 postcondition. More @code{Robustness} indicates that the pre- and
5122 postcondition of the subprogram should be ignored for this test case.
5124 @node Pragma Thread_Local_Storage
5125 @unnumberedsec Pragma Thread_Local_Storage
5126 @findex Thread_Local_Storage
5127 @cindex Task specific storage
5128 @cindex TLS (Thread Local Storage)
5131 @smallexample @c ada
5132 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5136 This pragma specifies that the specified entity, which must be
5137 a variable declared in a library level package, is to be marked as
5138 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5139 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5140 (and hence each Ada task) to see a distinct copy of the variable.
5142 The variable may not have default initialization, and if there is
5143 an explicit initialization, it must be either @code{null} for an
5144 access variable, or a static expression for a scalar variable.
5145 This provides a low level mechanism similar to that provided by
5146 the @code{Ada.Task_Attributes} package, but much more efficient
5147 and is also useful in writing interface code that will interact
5148 with foreign threads.
5150 If this pragma is used on a system where @code{TLS} is not supported,
5151 then an error message will be generated and the program will be rejected.
5153 @node Pragma Time_Slice
5154 @unnumberedsec Pragma Time_Slice
5159 @smallexample @c ada
5160 pragma Time_Slice (static_duration_EXPRESSION);
5164 For implementations of GNAT on operating systems where it is possible
5165 to supply a time slice value, this pragma may be used for this purpose.
5166 It is ignored if it is used in a system that does not allow this control,
5167 or if it appears in other than the main program unit.
5169 Note that the effect of this pragma is identical to the effect of the
5170 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5173 @unnumberedsec Pragma Title
5178 @smallexample @c ada
5179 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5182 [Title =>] STRING_LITERAL,
5183 | [Subtitle =>] STRING_LITERAL
5187 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5188 pragma used in DEC Ada 83 implementations to provide a title and/or
5189 subtitle for the program listing. The program listing generated by GNAT
5190 does not have titles or subtitles.
5192 Unlike other pragmas, the full flexibility of named notation is allowed
5193 for this pragma, i.e.@: the parameters may be given in any order if named
5194 notation is used, and named and positional notation can be mixed
5195 following the normal rules for procedure calls in Ada.
5197 @node Pragma Unchecked_Union
5198 @unnumberedsec Pragma Unchecked_Union
5200 @findex Unchecked_Union
5204 @smallexample @c ada
5205 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5209 This pragma is used to specify a representation of a record type that is
5210 equivalent to a C union. It was introduced as a GNAT implementation defined
5211 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5212 pragma, making it language defined, and GNAT fully implements this extended
5213 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5214 details, consult the Ada 2005 Reference Manual, section B.3.3.
5216 @node Pragma Unimplemented_Unit
5217 @unnumberedsec Pragma Unimplemented_Unit
5218 @findex Unimplemented_Unit
5222 @smallexample @c ada
5223 pragma Unimplemented_Unit;
5227 If this pragma occurs in a unit that is processed by the compiler, GNAT
5228 aborts with the message @samp{@var{xxx} not implemented}, where
5229 @var{xxx} is the name of the current compilation unit. This pragma is
5230 intended to allow the compiler to handle unimplemented library units in
5233 The abort only happens if code is being generated. Thus you can use
5234 specs of unimplemented packages in syntax or semantic checking mode.
5236 @node Pragma Universal_Aliasing
5237 @unnumberedsec Pragma Universal_Aliasing
5238 @findex Universal_Aliasing
5242 @smallexample @c ada
5243 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5247 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5248 declarative part. The effect is to inhibit strict type-based aliasing
5249 optimization for the given type. In other words, the effect is as though
5250 access types designating this type were subject to pragma No_Strict_Aliasing.
5251 For a detailed description of the strict aliasing optimization, and the
5252 situations in which it must be suppressed, @xref{Optimization and Strict
5253 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5255 @node Pragma Universal_Data
5256 @unnumberedsec Pragma Universal_Data
5257 @findex Universal_Data
5261 @smallexample @c ada
5262 pragma Universal_Data [(library_unit_Name)];
5266 This pragma is supported only for the AAMP target and is ignored for
5267 other targets. The pragma specifies that all library-level objects
5268 (Counter 0 data) associated with the library unit are to be accessed
5269 and updated using universal addressing (24-bit addresses for AAMP5)
5270 rather than the default of 16-bit Data Environment (DENV) addressing.
5271 Use of this pragma will generally result in less efficient code for
5272 references to global data associated with the library unit, but
5273 allows such data to be located anywhere in memory. This pragma is
5274 a library unit pragma, but can also be used as a configuration pragma
5275 (including use in the @file{gnat.adc} file). The functionality
5276 of this pragma is also available by applying the -univ switch on the
5277 compilations of units where universal addressing of the data is desired.
5279 @node Pragma Unmodified
5280 @unnumberedsec Pragma Unmodified
5282 @cindex Warnings, unmodified
5286 @smallexample @c ada
5287 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5291 This pragma signals that the assignable entities (variables,
5292 @code{out} parameters, @code{in out} parameters) whose names are listed are
5293 deliberately not assigned in the current source unit. This
5294 suppresses warnings about the
5295 entities being referenced but not assigned, and in addition a warning will be
5296 generated if one of these entities is in fact assigned in the
5297 same unit as the pragma (or in the corresponding body, or one
5300 This is particularly useful for clearly signaling that a particular
5301 parameter is not modified, even though the spec suggests that it might
5304 @node Pragma Unreferenced
5305 @unnumberedsec Pragma Unreferenced
5306 @findex Unreferenced
5307 @cindex Warnings, unreferenced
5311 @smallexample @c ada
5312 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5313 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5317 This pragma signals that the entities whose names are listed are
5318 deliberately not referenced in the current source unit. This
5319 suppresses warnings about the
5320 entities being unreferenced, and in addition a warning will be
5321 generated if one of these entities is in fact referenced in the
5322 same unit as the pragma (or in the corresponding body, or one
5325 This is particularly useful for clearly signaling that a particular
5326 parameter is not referenced in some particular subprogram implementation
5327 and that this is deliberate. It can also be useful in the case of
5328 objects declared only for their initialization or finalization side
5331 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5332 current scope, then the entity most recently declared is the one to which
5333 the pragma applies. Note that in the case of accept formals, the pragma
5334 Unreferenced may appear immediately after the keyword @code{do} which
5335 allows the indication of whether or not accept formals are referenced
5336 or not to be given individually for each accept statement.
5338 The left hand side of an assignment does not count as a reference for the
5339 purpose of this pragma. Thus it is fine to assign to an entity for which
5340 pragma Unreferenced is given.
5342 Note that if a warning is desired for all calls to a given subprogram,
5343 regardless of whether they occur in the same unit as the subprogram
5344 declaration, then this pragma should not be used (calls from another
5345 unit would not be flagged); pragma Obsolescent can be used instead
5346 for this purpose, see @xref{Pragma Obsolescent}.
5348 The second form of pragma @code{Unreferenced} is used within a context
5349 clause. In this case the arguments must be unit names of units previously
5350 mentioned in @code{with} clauses (similar to the usage of pragma
5351 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5352 units and unreferenced entities within these units.
5354 @node Pragma Unreferenced_Objects
5355 @unnumberedsec Pragma Unreferenced_Objects
5356 @findex Unreferenced_Objects
5357 @cindex Warnings, unreferenced
5361 @smallexample @c ada
5362 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5366 This pragma signals that for the types or subtypes whose names are
5367 listed, objects which are declared with one of these types or subtypes may
5368 not be referenced, and if no references appear, no warnings are given.
5370 This is particularly useful for objects which are declared solely for their
5371 initialization and finalization effect. Such variables are sometimes referred
5372 to as RAII variables (Resource Acquisition Is Initialization). Using this
5373 pragma on the relevant type (most typically a limited controlled type), the
5374 compiler will automatically suppress unwanted warnings about these variables
5375 not being referenced.
5377 @node Pragma Unreserve_All_Interrupts
5378 @unnumberedsec Pragma Unreserve_All_Interrupts
5379 @findex Unreserve_All_Interrupts
5383 @smallexample @c ada
5384 pragma Unreserve_All_Interrupts;
5388 Normally certain interrupts are reserved to the implementation. Any attempt
5389 to attach an interrupt causes Program_Error to be raised, as described in
5390 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5391 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5392 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5393 interrupt execution.
5395 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5396 a program, then all such interrupts are unreserved. This allows the
5397 program to handle these interrupts, but disables their standard
5398 functions. For example, if this pragma is used, then pressing
5399 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5400 a program can then handle the @code{SIGINT} interrupt as it chooses.
5402 For a full list of the interrupts handled in a specific implementation,
5403 see the source code for the spec of @code{Ada.Interrupts.Names} in
5404 file @file{a-intnam.ads}. This is a target dependent file that contains the
5405 list of interrupts recognized for a given target. The documentation in
5406 this file also specifies what interrupts are affected by the use of
5407 the @code{Unreserve_All_Interrupts} pragma.
5409 For a more general facility for controlling what interrupts can be
5410 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5411 of the @code{Unreserve_All_Interrupts} pragma.
5413 @node Pragma Unsuppress
5414 @unnumberedsec Pragma Unsuppress
5419 @smallexample @c ada
5420 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5424 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5425 there is no corresponding pragma @code{Suppress} in effect, it has no
5426 effect. The range of the effect is the same as for pragma
5427 @code{Suppress}. The meaning of the arguments is identical to that used
5428 in pragma @code{Suppress}.
5430 One important application is to ensure that checks are on in cases where
5431 code depends on the checks for its correct functioning, so that the code
5432 will compile correctly even if the compiler switches are set to suppress
5435 @node Pragma Use_VADS_Size
5436 @unnumberedsec Pragma Use_VADS_Size
5437 @cindex @code{Size}, VADS compatibility
5438 @findex Use_VADS_Size
5442 @smallexample @c ada
5443 pragma Use_VADS_Size;
5447 This is a configuration pragma. In a unit to which it applies, any use
5448 of the 'Size attribute is automatically interpreted as a use of the
5449 'VADS_Size attribute. Note that this may result in incorrect semantic
5450 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5451 the handling of existing code which depends on the interpretation of Size
5452 as implemented in the VADS compiler. See description of the VADS_Size
5453 attribute for further details.
5455 @node Pragma Validity_Checks
5456 @unnumberedsec Pragma Validity_Checks
5457 @findex Validity_Checks
5461 @smallexample @c ada
5462 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5466 This pragma is used in conjunction with compiler switches to control the
5467 built-in validity checking provided by GNAT@. The compiler switches, if set
5468 provide an initial setting for the switches, and this pragma may be used
5469 to modify these settings, or the settings may be provided entirely by
5470 the use of the pragma. This pragma can be used anywhere that a pragma
5471 is legal, including use as a configuration pragma (including use in
5472 the @file{gnat.adc} file).
5474 The form with a string literal specifies which validity options are to be
5475 activated. The validity checks are first set to include only the default
5476 reference manual settings, and then a string of letters in the string
5477 specifies the exact set of options required. The form of this string
5478 is exactly as described for the @option{-gnatVx} compiler switch (see the
5479 GNAT users guide for details). For example the following two methods
5480 can be used to enable validity checking for mode @code{in} and
5481 @code{in out} subprogram parameters:
5485 @smallexample @c ada
5486 pragma Validity_Checks ("im");
5491 gcc -c -gnatVim @dots{}
5496 The form ALL_CHECKS activates all standard checks (its use is equivalent
5497 to the use of the @code{gnatva} switch.
5499 The forms with @code{Off} and @code{On}
5500 can be used to temporarily disable validity checks
5501 as shown in the following example:
5503 @smallexample @c ada
5507 pragma Validity_Checks ("c"); -- validity checks for copies
5508 pragma Validity_Checks (Off); -- turn off validity checks
5509 A := B; -- B will not be validity checked
5510 pragma Validity_Checks (On); -- turn validity checks back on
5511 A := C; -- C will be validity checked
5514 @node Pragma Volatile
5515 @unnumberedsec Pragma Volatile
5520 @smallexample @c ada
5521 pragma Volatile (LOCAL_NAME);
5525 This pragma is defined by the Ada Reference Manual, and the GNAT
5526 implementation is fully conformant with this definition. The reason it
5527 is mentioned in this section is that a pragma of the same name was supplied
5528 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5529 implementation of pragma Volatile is upwards compatible with the
5530 implementation in DEC Ada 83.
5532 @node Pragma Warnings
5533 @unnumberedsec Pragma Warnings
5538 @smallexample @c ada
5539 pragma Warnings (On | Off);
5540 pragma Warnings (On | Off, LOCAL_NAME);
5541 pragma Warnings (static_string_EXPRESSION);
5542 pragma Warnings (On | Off, static_string_EXPRESSION);
5546 Normally warnings are enabled, with the output being controlled by
5547 the command line switch. Warnings (@code{Off}) turns off generation of
5548 warnings until a Warnings (@code{On}) is encountered or the end of the
5549 current unit. If generation of warnings is turned off using this
5550 pragma, then no warning messages are output, regardless of the
5551 setting of the command line switches.
5553 The form with a single argument may be used as a configuration pragma.
5555 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5556 the specified entity. This suppression is effective from the point where
5557 it occurs till the end of the extended scope of the variable (similar to
5558 the scope of @code{Suppress}).
5560 The form with a single static_string_EXPRESSION argument provides more precise
5561 control over which warnings are active. The string is a list of letters
5562 specifying which warnings are to be activated and which deactivated. The
5563 code for these letters is the same as the string used in the command
5564 line switch controlling warnings. For a brief summary, use the gnatmake
5565 command with no arguments, which will generate usage information containing
5566 the list of warnings switches supported. For
5567 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5571 The specified warnings will be in effect until the end of the program
5572 or another pragma Warnings is encountered. The effect of the pragma is
5573 cumulative. Initially the set of warnings is the standard default set
5574 as possibly modified by compiler switches. Then each pragma Warning
5575 modifies this set of warnings as specified. This form of the pragma may
5576 also be used as a configuration pragma.
5578 The fourth form, with an On|Off parameter and a string, is used to
5579 control individual messages, based on their text. The string argument
5580 is a pattern that is used to match against the text of individual
5581 warning messages (not including the initial "warning: " tag).
5583 The pattern may contain asterisks, which match zero or more characters in
5584 the message. For example, you can use
5585 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5586 message @code{warning: 960 bits of "a" unused}. No other regular
5587 expression notations are permitted. All characters other than asterisk in
5588 these three specific cases are treated as literal characters in the match.
5590 There are two ways to use this pragma. The OFF form can be used as a
5591 configuration pragma. The effect is to suppress all warnings (if any)
5592 that match the pattern string throughout the compilation.
5594 The second usage is to suppress a warning locally, and in this case, two
5595 pragmas must appear in sequence:
5597 @smallexample @c ada
5598 pragma Warnings (Off, Pattern);
5599 @dots{} code where given warning is to be suppressed
5600 pragma Warnings (On, Pattern);
5604 In this usage, the pattern string must match in the Off and On pragmas,
5605 and at least one matching warning must be suppressed.
5607 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5608 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5609 be useful in checking whether obsolete pragmas in existing programs are hiding
5612 Note: pragma Warnings does not affect the processing of style messages. See
5613 separate entry for pragma Style_Checks for control of style messages.
5615 @node Pragma Weak_External
5616 @unnumberedsec Pragma Weak_External
5617 @findex Weak_External
5621 @smallexample @c ada
5622 pragma Weak_External ([Entity =>] LOCAL_NAME);
5626 @var{LOCAL_NAME} must refer to an object that is declared at the library
5627 level. This pragma specifies that the given entity should be marked as a
5628 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5629 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5630 of a regular symbol, that is to say a symbol that does not have to be
5631 resolved by the linker if used in conjunction with a pragma Import.
5633 When a weak symbol is not resolved by the linker, its address is set to
5634 zero. This is useful in writing interfaces to external modules that may
5635 or may not be linked in the final executable, for example depending on
5636 configuration settings.
5638 If a program references at run time an entity to which this pragma has been
5639 applied, and the corresponding symbol was not resolved at link time, then
5640 the execution of the program is erroneous. It is not erroneous to take the
5641 Address of such an entity, for example to guard potential references,
5642 as shown in the example below.
5644 Some file formats do not support weak symbols so not all target machines
5645 support this pragma.
5647 @smallexample @c ada
5648 -- Example of the use of pragma Weak_External
5650 package External_Module is
5652 pragma Import (C, key);
5653 pragma Weak_External (key);
5654 function Present return boolean;
5655 end External_Module;
5657 with System; use System;
5658 package body External_Module is
5659 function Present return boolean is
5661 return key'Address /= System.Null_Address;
5663 end External_Module;
5666 @node Pragma Wide_Character_Encoding
5667 @unnumberedsec Pragma Wide_Character_Encoding
5668 @findex Wide_Character_Encoding
5672 @smallexample @c ada
5673 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5677 This pragma specifies the wide character encoding to be used in program
5678 source text appearing subsequently. It is a configuration pragma, but may
5679 also be used at any point that a pragma is allowed, and it is permissible
5680 to have more than one such pragma in a file, allowing multiple encodings
5681 to appear within the same file.
5683 The argument can be an identifier or a character literal. In the identifier
5684 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5685 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5686 case it is correspondingly one of the characters @samp{h}, @samp{u},
5687 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5689 Note that when the pragma is used within a file, it affects only the
5690 encoding within that file, and does not affect withed units, specs,
5693 @node Implementation Defined Attributes
5694 @chapter Implementation Defined Attributes
5695 Ada defines (throughout the Ada reference manual,
5696 summarized in Annex K),
5697 a set of attributes that provide useful additional functionality in all
5698 areas of the language. These language defined attributes are implemented
5699 in GNAT and work as described in the Ada Reference Manual.
5701 In addition, Ada allows implementations to define additional
5702 attributes whose meaning is defined by the implementation. GNAT provides
5703 a number of these implementation-dependent attributes which can be used
5704 to extend and enhance the functionality of the compiler. This section of
5705 the GNAT reference manual describes these additional attributes.
5707 Note that any program using these attributes may not be portable to
5708 other compilers (although GNAT implements this set of attributes on all
5709 platforms). Therefore if portability to other compilers is an important
5710 consideration, you should minimize the use of these attributes.
5720 * Compiler_Version::
5722 * Default_Bit_Order::
5734 * Has_Access_Values::
5735 * Has_Discriminants::
5742 * Max_Interrupt_Priority::
5744 * Maximum_Alignment::
5749 * Passed_By_Reference::
5759 * System_Allocator_Alignment::
5765 * Unconstrained_Array::
5766 * Universal_Literal_String::
5767 * Unrestricted_Access::
5775 @unnumberedsec Abort_Signal
5776 @findex Abort_Signal
5778 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5779 prefix) provides the entity for the special exception used to signal
5780 task abort or asynchronous transfer of control. Normally this attribute
5781 should only be used in the tasking runtime (it is highly peculiar, and
5782 completely outside the normal semantics of Ada, for a user program to
5783 intercept the abort exception).
5786 @unnumberedsec Address_Size
5787 @cindex Size of @code{Address}
5788 @findex Address_Size
5790 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5791 prefix) is a static constant giving the number of bits in an
5792 @code{Address}. It is the same value as System.Address'Size,
5793 but has the advantage of being static, while a direct
5794 reference to System.Address'Size is non-static because Address
5798 @unnumberedsec Asm_Input
5801 The @code{Asm_Input} attribute denotes a function that takes two
5802 parameters. The first is a string, the second is an expression of the
5803 type designated by the prefix. The first (string) argument is required
5804 to be a static expression, and is the constraint for the parameter,
5805 (e.g.@: what kind of register is required). The second argument is the
5806 value to be used as the input argument. The possible values for the
5807 constant are the same as those used in the RTL, and are dependent on
5808 the configuration file used to built the GCC back end.
5809 @ref{Machine Code Insertions}
5812 @unnumberedsec Asm_Output
5815 The @code{Asm_Output} attribute denotes a function that takes two
5816 parameters. The first is a string, the second is the name of a variable
5817 of the type designated by the attribute prefix. The first (string)
5818 argument is required to be a static expression and designates the
5819 constraint for the parameter (e.g.@: what kind of register is
5820 required). The second argument is the variable to be updated with the
5821 result. The possible values for constraint are the same as those used in
5822 the RTL, and are dependent on the configuration file used to build the
5823 GCC back end. If there are no output operands, then this argument may
5824 either be omitted, or explicitly given as @code{No_Output_Operands}.
5825 @ref{Machine Code Insertions}
5828 @unnumberedsec AST_Entry
5832 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5833 the name of an entry, it yields a value of the predefined type AST_Handler
5834 (declared in the predefined package System, as extended by the use of
5835 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5836 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5837 Language Reference Manual}, section 9.12a.
5842 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5843 offset within the storage unit (byte) that contains the first bit of
5844 storage allocated for the object. The value of this attribute is of the
5845 type @code{Universal_Integer}, and is always a non-negative number not
5846 exceeding the value of @code{System.Storage_Unit}.
5848 For an object that is a variable or a constant allocated in a register,
5849 the value is zero. (The use of this attribute does not force the
5850 allocation of a variable to memory).
5852 For an object that is a formal parameter, this attribute applies
5853 to either the matching actual parameter or to a copy of the
5854 matching actual parameter.
5856 For an access object the value is zero. Note that
5857 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5858 designated object. Similarly for a record component
5859 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5860 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5861 are subject to index checks.
5863 This attribute is designed to be compatible with the DEC Ada 83 definition
5864 and implementation of the @code{Bit} attribute.
5867 @unnumberedsec Bit_Position
5868 @findex Bit_Position
5870 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
5871 of the fields of the record type, yields the bit
5872 offset within the record contains the first bit of
5873 storage allocated for the object. The value of this attribute is of the
5874 type @code{Universal_Integer}. The value depends only on the field
5875 @var{C} and is independent of the alignment of
5876 the containing record @var{R}.
5878 @node Compiler_Version
5879 @unnumberedsec Compiler_Version
5880 @findex Compiler_Version
5882 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5883 prefix) yields a static string identifying the version of the compiler
5884 being used to compile the unit containing the attribute reference. A
5885 typical result would be something like "@value{EDITION} @i{version} (20090221)".
5888 @unnumberedsec Code_Address
5889 @findex Code_Address
5890 @cindex Subprogram address
5891 @cindex Address of subprogram code
5894 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5895 intended effect seems to be to provide
5896 an address value which can be used to call the subprogram by means of
5897 an address clause as in the following example:
5899 @smallexample @c ada
5900 procedure K is @dots{}
5903 for L'Address use K'Address;
5904 pragma Import (Ada, L);
5908 A call to @code{L} is then expected to result in a call to @code{K}@.
5909 In Ada 83, where there were no access-to-subprogram values, this was
5910 a common work-around for getting the effect of an indirect call.
5911 GNAT implements the above use of @code{Address} and the technique
5912 illustrated by the example code works correctly.
5914 However, for some purposes, it is useful to have the address of the start
5915 of the generated code for the subprogram. On some architectures, this is
5916 not necessarily the same as the @code{Address} value described above.
5917 For example, the @code{Address} value may reference a subprogram
5918 descriptor rather than the subprogram itself.
5920 The @code{'Code_Address} attribute, which can only be applied to
5921 subprogram entities, always returns the address of the start of the
5922 generated code of the specified subprogram, which may or may not be
5923 the same value as is returned by the corresponding @code{'Address}
5926 @node Default_Bit_Order
5927 @unnumberedsec Default_Bit_Order
5929 @cindex Little endian
5930 @findex Default_Bit_Order
5932 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5933 permissible prefix), provides the value @code{System.Default_Bit_Order}
5934 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5935 @code{Low_Order_First}). This is used to construct the definition of
5936 @code{Default_Bit_Order} in package @code{System}.
5938 @node Descriptor_Size
5939 @unnumberedsec Descriptor_Size
5942 @findex Descriptor_Size
5944 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
5945 descriptor allocated for a type. The result is non-zero only for unconstrained
5946 array types and the returned value is of type universal integer. In GNAT, an
5947 array descriptor contains bounds information and is located immediately before
5948 the first element of the array.
5950 @smallexample @c ada
5951 type Unconstr_Array is array (Positive range <>) of Boolean;
5952 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
5956 The attribute takes into account any additional padding due to type alignment.
5957 In the example above, the descriptor contains two values of type
5958 @code{Positive} representing the low and high bound. Since @code{Positive} has
5959 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
5960 Positive'Size + 2} or 64 bits.
5963 @unnumberedsec Elaborated
5966 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5967 value is a Boolean which indicates whether or not the given unit has been
5968 elaborated. This attribute is primarily intended for internal use by the
5969 generated code for dynamic elaboration checking, but it can also be used
5970 in user programs. The value will always be True once elaboration of all
5971 units has been completed. An exception is for units which need no
5972 elaboration, the value is always False for such units.
5975 @unnumberedsec Elab_Body
5978 This attribute can only be applied to a program unit name. It returns
5979 the entity for the corresponding elaboration procedure for elaborating
5980 the body of the referenced unit. This is used in the main generated
5981 elaboration procedure by the binder and is not normally used in any
5982 other context. However, there may be specialized situations in which it
5983 is useful to be able to call this elaboration procedure from Ada code,
5984 e.g.@: if it is necessary to do selective re-elaboration to fix some
5988 @unnumberedsec Elab_Spec
5991 This attribute can only be applied to a program unit name. It returns
5992 the entity for the corresponding elaboration procedure for elaborating
5993 the spec of the referenced unit. This is used in the main
5994 generated elaboration procedure by the binder and is not normally used
5995 in any other context. However, there may be specialized situations in
5996 which it is useful to be able to call this elaboration procedure from
5997 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6000 @node Elab_Subp_Body
6001 @unnumberedsec Elab_Subp_Body
6002 @findex Elab_Subp_Body
6004 This attribute can only be applied to a library level subprogram
6005 name and is only allowed in CodePeer mode. It returns the entity
6006 for the corresponding elaboration procedure for elaborating the body
6007 of the referenced subprogram unit. This is used in the main generated
6008 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6013 @cindex Ada 83 attributes
6016 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6017 the Ada 83 reference manual for an exact description of the semantics of
6021 @unnumberedsec Enabled
6024 The @code{Enabled} attribute allows an application program to check at compile
6025 time to see if the designated check is currently enabled. The prefix is a
6026 simple identifier, referencing any predefined check name (other than
6027 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6028 no argument is given for the attribute, the check is for the general state
6029 of the check, if an argument is given, then it is an entity name, and the
6030 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6031 given naming the entity (if not, then the argument is ignored).
6033 Note that instantiations inherit the check status at the point of the
6034 instantiation, so a useful idiom is to have a library package that
6035 introduces a check name with @code{pragma Check_Name}, and then contains
6036 generic packages or subprograms which use the @code{Enabled} attribute
6037 to see if the check is enabled. A user of this package can then issue
6038 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6039 the package or subprogram, controlling whether the check will be present.
6042 @unnumberedsec Enum_Rep
6043 @cindex Representation of enums
6046 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6047 function with the following spec:
6049 @smallexample @c ada
6050 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6051 return @i{Universal_Integer};
6055 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6056 enumeration type or to a non-overloaded enumeration
6057 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6058 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6059 enumeration literal or object.
6061 The function returns the representation value for the given enumeration
6062 value. This will be equal to value of the @code{Pos} attribute in the
6063 absence of an enumeration representation clause. This is a static
6064 attribute (i.e.@: the result is static if the argument is static).
6066 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6067 in which case it simply returns the integer value. The reason for this
6068 is to allow it to be used for @code{(<>)} discrete formal arguments in
6069 a generic unit that can be instantiated with either enumeration types
6070 or integer types. Note that if @code{Enum_Rep} is used on a modular
6071 type whose upper bound exceeds the upper bound of the largest signed
6072 integer type, and the argument is a variable, so that the universal
6073 integer calculation is done at run time, then the call to @code{Enum_Rep}
6074 may raise @code{Constraint_Error}.
6077 @unnumberedsec Enum_Val
6078 @cindex Representation of enums
6081 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6082 function with the following spec:
6084 @smallexample @c ada
6085 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6086 return @var{S}'Base};
6090 The function returns the enumeration value whose representation matches the
6091 argument, or raises Constraint_Error if no enumeration literal of the type
6092 has the matching value.
6093 This will be equal to value of the @code{Val} attribute in the
6094 absence of an enumeration representation clause. This is a static
6095 attribute (i.e.@: the result is static if the argument is static).
6098 @unnumberedsec Epsilon
6099 @cindex Ada 83 attributes
6102 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6103 the Ada 83 reference manual for an exact description of the semantics of
6107 @unnumberedsec Fixed_Value
6110 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6111 function with the following specification:
6113 @smallexample @c ada
6114 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6119 The value returned is the fixed-point value @var{V} such that
6121 @smallexample @c ada
6122 @var{V} = Arg * @var{S}'Small
6126 The effect is thus similar to first converting the argument to the
6127 integer type used to represent @var{S}, and then doing an unchecked
6128 conversion to the fixed-point type. The difference is
6129 that there are full range checks, to ensure that the result is in range.
6130 This attribute is primarily intended for use in implementation of the
6131 input-output functions for fixed-point values.
6133 @node Has_Access_Values
6134 @unnumberedsec Has_Access_Values
6135 @cindex Access values, testing for
6136 @findex Has_Access_Values
6138 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6139 is a Boolean value which is True if the is an access type, or is a composite
6140 type with a component (at any nesting depth) that is an access type, and is
6142 The intended use of this attribute is in conjunction with generic
6143 definitions. If the attribute is applied to a generic private type, it
6144 indicates whether or not the corresponding actual type has access values.
6146 @node Has_Discriminants
6147 @unnumberedsec Has_Discriminants
6148 @cindex Discriminants, testing for
6149 @findex Has_Discriminants
6151 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6152 is a Boolean value which is True if the type has discriminants, and False
6153 otherwise. The intended use of this attribute is in conjunction with generic
6154 definitions. If the attribute is applied to a generic private type, it
6155 indicates whether or not the corresponding actual type has discriminants.
6161 The @code{Img} attribute differs from @code{Image} in that it may be
6162 applied to objects as well as types, in which case it gives the
6163 @code{Image} for the subtype of the object. This is convenient for
6166 @smallexample @c ada
6167 Put_Line ("X = " & X'Img);
6171 has the same meaning as the more verbose:
6173 @smallexample @c ada
6174 Put_Line ("X = " & @var{T}'Image (X));
6178 where @var{T} is the (sub)type of the object @code{X}.
6181 @unnumberedsec Integer_Value
6182 @findex Integer_Value
6184 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6185 function with the following spec:
6187 @smallexample @c ada
6188 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6193 The value returned is the integer value @var{V}, such that
6195 @smallexample @c ada
6196 Arg = @var{V} * @var{T}'Small
6200 where @var{T} is the type of @code{Arg}.
6201 The effect is thus similar to first doing an unchecked conversion from
6202 the fixed-point type to its corresponding implementation type, and then
6203 converting the result to the target integer type. The difference is
6204 that there are full range checks, to ensure that the result is in range.
6205 This attribute is primarily intended for use in implementation of the
6206 standard input-output functions for fixed-point values.
6209 @unnumberedsec Invalid_Value
6210 @findex Invalid_Value
6212 For every scalar type S, S'Invalid_Value returns an undefined value of the
6213 type. If possible this value is an invalid representation for the type. The
6214 value returned is identical to the value used to initialize an otherwise
6215 uninitialized value of the type if pragma Initialize_Scalars is used,
6216 including the ability to modify the value with the binder -Sxx flag and
6217 relevant environment variables at run time.
6220 @unnumberedsec Large
6221 @cindex Ada 83 attributes
6224 The @code{Large} attribute is provided for compatibility with Ada 83. See
6225 the Ada 83 reference manual for an exact description of the semantics of
6229 @unnumberedsec Machine_Size
6230 @findex Machine_Size
6232 This attribute is identical to the @code{Object_Size} attribute. It is
6233 provided for compatibility with the DEC Ada 83 attribute of this name.
6236 @unnumberedsec Mantissa
6237 @cindex Ada 83 attributes
6240 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6241 the Ada 83 reference manual for an exact description of the semantics of
6244 @node Max_Interrupt_Priority
6245 @unnumberedsec Max_Interrupt_Priority
6246 @cindex Interrupt priority, maximum
6247 @findex Max_Interrupt_Priority
6249 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6250 permissible prefix), provides the same value as
6251 @code{System.Max_Interrupt_Priority}.
6254 @unnumberedsec Max_Priority
6255 @cindex Priority, maximum
6256 @findex Max_Priority
6258 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6259 prefix) provides the same value as @code{System.Max_Priority}.
6261 @node Maximum_Alignment
6262 @unnumberedsec Maximum_Alignment
6263 @cindex Alignment, maximum
6264 @findex Maximum_Alignment
6266 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6267 permissible prefix) provides the maximum useful alignment value for the
6268 target. This is a static value that can be used to specify the alignment
6269 for an object, guaranteeing that it is properly aligned in all
6272 @node Mechanism_Code
6273 @unnumberedsec Mechanism_Code
6274 @cindex Return values, passing mechanism
6275 @cindex Parameters, passing mechanism
6276 @findex Mechanism_Code
6278 @code{@var{function}'Mechanism_Code} yields an integer code for the
6279 mechanism used for the result of function, and
6280 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6281 used for formal parameter number @var{n} (a static integer value with 1
6282 meaning the first parameter) of @var{subprogram}. The code returned is:
6290 by descriptor (default descriptor class)
6292 by descriptor (UBS: unaligned bit string)
6294 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6296 by descriptor (UBA: unaligned bit array)
6298 by descriptor (S: string, also scalar access type parameter)
6300 by descriptor (SB: string with arbitrary bounds)
6302 by descriptor (A: contiguous array)
6304 by descriptor (NCA: non-contiguous array)
6308 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6311 @node Null_Parameter
6312 @unnumberedsec Null_Parameter
6313 @cindex Zero address, passing
6314 @findex Null_Parameter
6316 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6317 type or subtype @var{T} allocated at machine address zero. The attribute
6318 is allowed only as the default expression of a formal parameter, or as
6319 an actual expression of a subprogram call. In either case, the
6320 subprogram must be imported.
6322 The identity of the object is represented by the address zero in the
6323 argument list, independent of the passing mechanism (explicit or
6326 This capability is needed to specify that a zero address should be
6327 passed for a record or other composite object passed by reference.
6328 There is no way of indicating this without the @code{Null_Parameter}
6332 @unnumberedsec Object_Size
6333 @cindex Size, used for objects
6336 The size of an object is not necessarily the same as the size of the type
6337 of an object. This is because by default object sizes are increased to be
6338 a multiple of the alignment of the object. For example,
6339 @code{Natural'Size} is
6340 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6341 Similarly, a record containing an integer and a character:
6343 @smallexample @c ada
6351 will have a size of 40 (that is @code{Rec'Size} will be 40). The
6352 alignment will be 4, because of the
6353 integer field, and so the default size of record objects for this type
6354 will be 64 (8 bytes).
6358 @cindex Capturing Old values
6359 @cindex Postconditions
6361 The attribute Prefix'Old can be used within a
6362 subprogram body or within a precondition or
6363 postcondition pragma. The effect is to
6364 refer to the value of the prefix on entry. So for
6365 example if you have an argument of a record type X called Arg1,
6366 you can refer to Arg1.Field'Old which yields the value of
6367 Arg1.Field on entry. The implementation simply involves generating
6368 an object declaration which captures the value on entry. Any
6369 prefix is allowed except one of a limited type (since limited
6370 types cannot be copied to capture their values) or an expression
6371 which references a local variable
6372 (since local variables do not exist at subprogram entry time).
6374 The following example shows the use of 'Old to implement
6375 a test of a postcondition:
6377 @smallexample @c ada
6388 package body Old_Pkg is
6389 Count : Natural := 0;
6393 ... code manipulating the value of Count
6395 pragma Assert (Count = Count'Old + 1);
6401 Note that it is allowed to apply 'Old to a constant entity, but this will
6402 result in a warning, since the old and new values will always be the same.
6404 @node Passed_By_Reference
6405 @unnumberedsec Passed_By_Reference
6406 @cindex Parameters, when passed by reference
6407 @findex Passed_By_Reference
6409 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6410 a value of type @code{Boolean} value that is @code{True} if the type is
6411 normally passed by reference and @code{False} if the type is normally
6412 passed by copy in calls. For scalar types, the result is always @code{False}
6413 and is static. For non-scalar types, the result is non-static.
6416 @unnumberedsec Pool_Address
6417 @cindex Parameters, when passed by reference
6418 @findex Pool_Address
6420 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6421 of X within its storage pool. This is the same as
6422 @code{@var{X}'Address}, except that for an unconstrained array whose
6423 bounds are allocated just before the first component,
6424 @code{@var{X}'Pool_Address} returns the address of those bounds,
6425 whereas @code{@var{X}'Address} returns the address of the first
6428 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6429 the object is allocated'', which could be a user-defined storage pool,
6430 the global heap, on the stack, or in a static memory area. For an
6431 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6432 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6435 @unnumberedsec Range_Length
6436 @findex Range_Length
6438 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6439 the number of values represented by the subtype (zero for a null
6440 range). The result is static for static subtypes. @code{Range_Length}
6441 applied to the index subtype of a one dimensional array always gives the
6442 same result as @code{Range} applied to the array itself.
6448 The @code{System.Address'Ref}
6449 (@code{System.Address} is the only permissible prefix)
6450 denotes a function identical to
6451 @code{System.Storage_Elements.To_Address} except that
6452 it is a static attribute. See @ref{To_Address} for more details.
6455 @unnumberedsec Result
6458 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6459 for a function. The prefix must be the name of the corresponding function. This
6460 is used to refer to the result of the function in the postcondition expression.
6461 For a further discussion of the use of this attribute and examples of its use,
6462 see the description of pragma Postcondition.
6465 @unnumberedsec Safe_Emax
6466 @cindex Ada 83 attributes
6469 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6470 the Ada 83 reference manual for an exact description of the semantics of
6474 @unnumberedsec Safe_Large
6475 @cindex Ada 83 attributes
6478 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6479 the Ada 83 reference manual for an exact description of the semantics of
6483 @unnumberedsec Small
6484 @cindex Ada 83 attributes
6487 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6489 GNAT also allows this attribute to be applied to floating-point types
6490 for compatibility with Ada 83. See
6491 the Ada 83 reference manual for an exact description of the semantics of
6492 this attribute when applied to floating-point types.
6495 @unnumberedsec Storage_Unit
6496 @findex Storage_Unit
6498 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6499 prefix) provides the same value as @code{System.Storage_Unit}.
6502 @unnumberedsec Stub_Type
6505 The GNAT implementation of remote access-to-classwide types is
6506 organized as described in AARM section E.4 (20.t): a value of an RACW type
6507 (designating a remote object) is represented as a normal access
6508 value, pointing to a "stub" object which in turn contains the
6509 necessary information to contact the designated remote object. A
6510 call on any dispatching operation of such a stub object does the
6511 remote call, if necessary, using the information in the stub object
6512 to locate the target partition, etc.
6514 For a prefix @code{T} that denotes a remote access-to-classwide type,
6515 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6517 By construction, the layout of @code{T'Stub_Type} is identical to that of
6518 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6519 unit @code{System.Partition_Interface}. Use of this attribute will create
6520 an implicit dependency on this unit.
6522 @node System_Allocator_Alignment
6523 @unnumberedsec System_Allocator_Alignment
6524 @cindex Alignment, allocator
6525 @findex System_Allocator_Alignment
6527 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
6528 permissible prefix) provides the observable guaranted to be honored by
6529 the system allocator (malloc). This is a static value that can be used
6530 in user storage pools based on malloc either to reject allocation
6531 with alignment too large or to enable a realignment circuitry if the
6532 alignment request is larger than this value.
6535 @unnumberedsec Target_Name
6538 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6539 prefix) provides a static string value that identifies the target
6540 for the current compilation. For GCC implementations, this is the
6541 standard gcc target name without the terminating slash (for
6542 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6548 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6549 provides the same value as @code{System.Tick},
6552 @unnumberedsec To_Address
6555 The @code{System'To_Address}
6556 (@code{System} is the only permissible prefix)
6557 denotes a function identical to
6558 @code{System.Storage_Elements.To_Address} except that
6559 it is a static attribute. This means that if its argument is
6560 a static expression, then the result of the attribute is a
6561 static expression. The result is that such an expression can be
6562 used in contexts (e.g.@: preelaborable packages) which require a
6563 static expression and where the function call could not be used
6564 (since the function call is always non-static, even if its
6565 argument is static).
6568 @unnumberedsec Type_Class
6571 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6572 the value of the type class for the full type of @var{type}. If
6573 @var{type} is a generic formal type, the value is the value for the
6574 corresponding actual subtype. The value of this attribute is of type
6575 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6577 @smallexample @c ada
6579 (Type_Class_Enumeration,
6581 Type_Class_Fixed_Point,
6582 Type_Class_Floating_Point,
6587 Type_Class_Address);
6591 Protected types yield the value @code{Type_Class_Task}, which thus
6592 applies to all concurrent types. This attribute is designed to
6593 be compatible with the DEC Ada 83 attribute of the same name.
6596 @unnumberedsec UET_Address
6599 The @code{UET_Address} attribute can only be used for a prefix which
6600 denotes a library package. It yields the address of the unit exception
6601 table when zero cost exception handling is used. This attribute is
6602 intended only for use within the GNAT implementation. See the unit
6603 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6604 for details on how this attribute is used in the implementation.
6606 @node Unconstrained_Array
6607 @unnumberedsec Unconstrained_Array
6608 @findex Unconstrained_Array
6610 The @code{Unconstrained_Array} attribute can be used with a prefix that
6611 denotes any type or subtype. It is a static attribute that yields
6612 @code{True} if the prefix designates an unconstrained array,
6613 and @code{False} otherwise. In a generic instance, the result is
6614 still static, and yields the result of applying this test to the
6617 @node Universal_Literal_String
6618 @unnumberedsec Universal_Literal_String
6619 @cindex Named numbers, representation of
6620 @findex Universal_Literal_String
6622 The prefix of @code{Universal_Literal_String} must be a named
6623 number. The static result is the string consisting of the characters of
6624 the number as defined in the original source. This allows the user
6625 program to access the actual text of named numbers without intermediate
6626 conversions and without the need to enclose the strings in quotes (which
6627 would preclude their use as numbers).
6629 For example, the following program prints the first 50 digits of pi:
6631 @smallexample @c ada
6632 with Text_IO; use Text_IO;
6636 Put (Ada.Numerics.Pi'Universal_Literal_String);
6640 @node Unrestricted_Access
6641 @unnumberedsec Unrestricted_Access
6642 @cindex @code{Access}, unrestricted
6643 @findex Unrestricted_Access
6645 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6646 except that all accessibility and aliased view checks are omitted. This
6647 is a user-beware attribute. It is similar to
6648 @code{Address}, for which it is a desirable replacement where the value
6649 desired is an access type. In other words, its effect is identical to
6650 first applying the @code{Address} attribute and then doing an unchecked
6651 conversion to a desired access type. In GNAT, but not necessarily in
6652 other implementations, the use of static chains for inner level
6653 subprograms means that @code{Unrestricted_Access} applied to a
6654 subprogram yields a value that can be called as long as the subprogram
6655 is in scope (normal Ada accessibility rules restrict this usage).
6657 It is possible to use @code{Unrestricted_Access} for any type, but care
6658 must be exercised if it is used to create pointers to unconstrained
6659 objects. In this case, the resulting pointer has the same scope as the
6660 context of the attribute, and may not be returned to some enclosing
6661 scope. For instance, a function cannot use @code{Unrestricted_Access}
6662 to create a unconstrained pointer and then return that value to the
6666 @unnumberedsec VADS_Size
6667 @cindex @code{Size}, VADS compatibility
6670 The @code{'VADS_Size} attribute is intended to make it easier to port
6671 legacy code which relies on the semantics of @code{'Size} as implemented
6672 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6673 same semantic interpretation. In particular, @code{'VADS_Size} applied
6674 to a predefined or other primitive type with no Size clause yields the
6675 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6676 typical machines). In addition @code{'VADS_Size} applied to an object
6677 gives the result that would be obtained by applying the attribute to
6678 the corresponding type.
6681 @unnumberedsec Value_Size
6682 @cindex @code{Size}, setting for not-first subtype
6684 @code{@var{type}'Value_Size} is the number of bits required to represent
6685 a value of the given subtype. It is the same as @code{@var{type}'Size},
6686 but, unlike @code{Size}, may be set for non-first subtypes.
6689 @unnumberedsec Wchar_T_Size
6690 @findex Wchar_T_Size
6691 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6692 prefix) provides the size in bits of the C @code{wchar_t} type
6693 primarily for constructing the definition of this type in
6694 package @code{Interfaces.C}.
6697 @unnumberedsec Word_Size
6699 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6700 prefix) provides the value @code{System.Word_Size}.
6702 @c ------------------------
6703 @node Implementation Advice
6704 @chapter Implementation Advice
6706 The main text of the Ada Reference Manual describes the required
6707 behavior of all Ada compilers, and the GNAT compiler conforms to
6710 In addition, there are sections throughout the Ada Reference Manual headed
6711 by the phrase ``Implementation advice''. These sections are not normative,
6712 i.e., they do not specify requirements that all compilers must
6713 follow. Rather they provide advice on generally desirable behavior. You
6714 may wonder why they are not requirements. The most typical answer is
6715 that they describe behavior that seems generally desirable, but cannot
6716 be provided on all systems, or which may be undesirable on some systems.
6718 As far as practical, GNAT follows the implementation advice sections in
6719 the Ada Reference Manual. This chapter contains a table giving the
6720 reference manual section number, paragraph number and several keywords
6721 for each advice. Each entry consists of the text of the advice followed
6722 by the GNAT interpretation of this advice. Most often, this simply says
6723 ``followed'', which means that GNAT follows the advice. However, in a
6724 number of cases, GNAT deliberately deviates from this advice, in which
6725 case the text describes what GNAT does and why.
6727 @cindex Error detection
6728 @unnumberedsec 1.1.3(20): Error Detection
6731 If an implementation detects the use of an unsupported Specialized Needs
6732 Annex feature at run time, it should raise @code{Program_Error} if
6735 Not relevant. All specialized needs annex features are either supported,
6736 or diagnosed at compile time.
6739 @unnumberedsec 1.1.3(31): Child Units
6742 If an implementation wishes to provide implementation-defined
6743 extensions to the functionality of a language-defined library unit, it
6744 should normally do so by adding children to the library unit.
6748 @cindex Bounded errors
6749 @unnumberedsec 1.1.5(12): Bounded Errors
6752 If an implementation detects a bounded error or erroneous
6753 execution, it should raise @code{Program_Error}.
6755 Followed in all cases in which the implementation detects a bounded
6756 error or erroneous execution. Not all such situations are detected at
6760 @unnumberedsec 2.8(16): Pragmas
6763 Normally, implementation-defined pragmas should have no semantic effect
6764 for error-free programs; that is, if the implementation-defined pragmas
6765 are removed from a working program, the program should still be legal,
6766 and should still have the same semantics.
6768 The following implementation defined pragmas are exceptions to this
6780 @item CPP_Constructor
6784 @item Interface_Name
6786 @item Machine_Attribute
6788 @item Unimplemented_Unit
6790 @item Unchecked_Union
6795 In each of the above cases, it is essential to the purpose of the pragma
6796 that this advice not be followed. For details see the separate section
6797 on implementation defined pragmas.
6799 @unnumberedsec 2.8(17-19): Pragmas
6802 Normally, an implementation should not define pragmas that can
6803 make an illegal program legal, except as follows:
6807 A pragma used to complete a declaration, such as a pragma @code{Import};
6811 A pragma used to configure the environment by adding, removing, or
6812 replacing @code{library_items}.
6814 See response to paragraph 16 of this same section.
6816 @cindex Character Sets
6817 @cindex Alternative Character Sets
6818 @unnumberedsec 3.5.2(5): Alternative Character Sets
6821 If an implementation supports a mode with alternative interpretations
6822 for @code{Character} and @code{Wide_Character}, the set of graphic
6823 characters of @code{Character} should nevertheless remain a proper
6824 subset of the set of graphic characters of @code{Wide_Character}. Any
6825 character set ``localizations'' should be reflected in the results of
6826 the subprograms defined in the language-defined package
6827 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6828 an alternative interpretation of @code{Character}, the implementation should
6829 also support a corresponding change in what is a legal
6830 @code{identifier_letter}.
6832 Not all wide character modes follow this advice, in particular the JIS
6833 and IEC modes reflect standard usage in Japan, and in these encoding,
6834 the upper half of the Latin-1 set is not part of the wide-character
6835 subset, since the most significant bit is used for wide character
6836 encoding. However, this only applies to the external forms. Internally
6837 there is no such restriction.
6839 @cindex Integer types
6840 @unnumberedsec 3.5.4(28): Integer Types
6844 An implementation should support @code{Long_Integer} in addition to
6845 @code{Integer} if the target machine supports 32-bit (or longer)
6846 arithmetic. No other named integer subtypes are recommended for package
6847 @code{Standard}. Instead, appropriate named integer subtypes should be
6848 provided in the library package @code{Interfaces} (see B.2).
6850 @code{Long_Integer} is supported. Other standard integer types are supported
6851 so this advice is not fully followed. These types
6852 are supported for convenient interface to C, and so that all hardware
6853 types of the machine are easily available.
6854 @unnumberedsec 3.5.4(29): Integer Types
6858 An implementation for a two's complement machine should support
6859 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6860 implementation should support a non-binary modules up to @code{Integer'Last}.
6864 @cindex Enumeration values
6865 @unnumberedsec 3.5.5(8): Enumeration Values
6868 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6869 subtype, if the value of the operand does not correspond to the internal
6870 code for any enumeration literal of its type (perhaps due to an
6871 un-initialized variable), then the implementation should raise
6872 @code{Program_Error}. This is particularly important for enumeration
6873 types with noncontiguous internal codes specified by an
6874 enumeration_representation_clause.
6879 @unnumberedsec 3.5.7(17): Float Types
6882 An implementation should support @code{Long_Float} in addition to
6883 @code{Float} if the target machine supports 11 or more digits of
6884 precision. No other named floating point subtypes are recommended for
6885 package @code{Standard}. Instead, appropriate named floating point subtypes
6886 should be provided in the library package @code{Interfaces} (see B.2).
6888 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6889 former provides improved compatibility with other implementations
6890 supporting this type. The latter corresponds to the highest precision
6891 floating-point type supported by the hardware. On most machines, this
6892 will be the same as @code{Long_Float}, but on some machines, it will
6893 correspond to the IEEE extended form. The notable case is all ia32
6894 (x86) implementations, where @code{Long_Long_Float} corresponds to
6895 the 80-bit extended precision format supported in hardware on this
6896 processor. Note that the 128-bit format on SPARC is not supported,
6897 since this is a software rather than a hardware format.
6899 @cindex Multidimensional arrays
6900 @cindex Arrays, multidimensional
6901 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6904 An implementation should normally represent multidimensional arrays in
6905 row-major order, consistent with the notation used for multidimensional
6906 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6907 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6908 column-major order should be used instead (see B.5, ``Interfacing with
6913 @findex Duration'Small
6914 @unnumberedsec 9.6(30-31): Duration'Small
6917 Whenever possible in an implementation, the value of @code{Duration'Small}
6918 should be no greater than 100 microseconds.
6920 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6924 The time base for @code{delay_relative_statements} should be monotonic;
6925 it need not be the same time base as used for @code{Calendar.Clock}.
6929 @unnumberedsec 10.2.1(12): Consistent Representation
6932 In an implementation, a type declared in a pre-elaborated package should
6933 have the same representation in every elaboration of a given version of
6934 the package, whether the elaborations occur in distinct executions of
6935 the same program, or in executions of distinct programs or partitions
6936 that include the given version.
6938 Followed, except in the case of tagged types. Tagged types involve
6939 implicit pointers to a local copy of a dispatch table, and these pointers
6940 have representations which thus depend on a particular elaboration of the
6941 package. It is not easy to see how it would be possible to follow this
6942 advice without severely impacting efficiency of execution.
6944 @cindex Exception information
6945 @unnumberedsec 11.4.1(19): Exception Information
6948 @code{Exception_Message} by default and @code{Exception_Information}
6949 should produce information useful for
6950 debugging. @code{Exception_Message} should be short, about one
6951 line. @code{Exception_Information} can be long. @code{Exception_Message}
6952 should not include the
6953 @code{Exception_Name}. @code{Exception_Information} should include both
6954 the @code{Exception_Name} and the @code{Exception_Message}.
6956 Followed. For each exception that doesn't have a specified
6957 @code{Exception_Message}, the compiler generates one containing the location
6958 of the raise statement. This location has the form ``file:line'', where
6959 file is the short file name (without path information) and line is the line
6960 number in the file. Note that in the case of the Zero Cost Exception
6961 mechanism, these messages become redundant with the Exception_Information that
6962 contains a full backtrace of the calling sequence, so they are disabled.
6963 To disable explicitly the generation of the source location message, use the
6964 Pragma @code{Discard_Names}.
6966 @cindex Suppression of checks
6967 @cindex Checks, suppression of
6968 @unnumberedsec 11.5(28): Suppression of Checks
6971 The implementation should minimize the code executed for checks that
6972 have been suppressed.
6976 @cindex Representation clauses
6977 @unnumberedsec 13.1 (21-24): Representation Clauses
6980 The recommended level of support for all representation items is
6981 qualified as follows:
6985 An implementation need not support representation items containing
6986 non-static expressions, except that an implementation should support a
6987 representation item for a given entity if each non-static expression in
6988 the representation item is a name that statically denotes a constant
6989 declared before the entity.
6991 Followed. In fact, GNAT goes beyond the recommended level of support
6992 by allowing nonstatic expressions in some representation clauses even
6993 without the need to declare constants initialized with the values of
6997 @smallexample @c ada
7000 for Y'Address use X'Address;>>
7005 An implementation need not support a specification for the @code{Size}
7006 for a given composite subtype, nor the size or storage place for an
7007 object (including a component) of a given composite subtype, unless the
7008 constraints on the subtype and its composite subcomponents (if any) are
7009 all static constraints.
7011 Followed. Size Clauses are not permitted on non-static components, as
7016 An aliased component, or a component whose type is by-reference, should
7017 always be allocated at an addressable location.
7021 @cindex Packed types
7022 @unnumberedsec 13.2(6-8): Packed Types
7025 If a type is packed, then the implementation should try to minimize
7026 storage allocated to objects of the type, possibly at the expense of
7027 speed of accessing components, subject to reasonable complexity in
7028 addressing calculations.
7032 The recommended level of support pragma @code{Pack} is:
7034 For a packed record type, the components should be packed as tightly as
7035 possible subject to the Sizes of the component subtypes, and subject to
7036 any @code{record_representation_clause} that applies to the type; the
7037 implementation may, but need not, reorder components or cross aligned
7038 word boundaries to improve the packing. A component whose @code{Size} is
7039 greater than the word size may be allocated an integral number of words.
7041 Followed. Tight packing of arrays is supported for all component sizes
7042 up to 64-bits. If the array component size is 1 (that is to say, if
7043 the component is a boolean type or an enumeration type with two values)
7044 then values of the type are implicitly initialized to zero. This
7045 happens both for objects of the packed type, and for objects that have a
7046 subcomponent of the packed type.
7050 An implementation should support Address clauses for imported
7054 @cindex @code{Address} clauses
7055 @unnumberedsec 13.3(14-19): Address Clauses
7059 For an array @var{X}, @code{@var{X}'Address} should point at the first
7060 component of the array, and not at the array bounds.
7066 The recommended level of support for the @code{Address} attribute is:
7068 @code{@var{X}'Address} should produce a useful result if @var{X} is an
7069 object that is aliased or of a by-reference type, or is an entity whose
7070 @code{Address} has been specified.
7072 Followed. A valid address will be produced even if none of those
7073 conditions have been met. If necessary, the object is forced into
7074 memory to ensure the address is valid.
7078 An implementation should support @code{Address} clauses for imported
7085 Objects (including subcomponents) that are aliased or of a by-reference
7086 type should be allocated on storage element boundaries.
7092 If the @code{Address} of an object is specified, or it is imported or exported,
7093 then the implementation should not perform optimizations based on
7094 assumptions of no aliases.
7098 @cindex @code{Alignment} clauses
7099 @unnumberedsec 13.3(29-35): Alignment Clauses
7102 The recommended level of support for the @code{Alignment} attribute for
7105 An implementation should support specified Alignments that are factors
7106 and multiples of the number of storage elements per word, subject to the
7113 An implementation need not support specified @code{Alignment}s for
7114 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
7115 loaded and stored by available machine instructions.
7121 An implementation need not support specified @code{Alignment}s that are
7122 greater than the maximum @code{Alignment} the implementation ever returns by
7129 The recommended level of support for the @code{Alignment} attribute for
7132 Same as above, for subtypes, but in addition:
7138 For stand-alone library-level objects of statically constrained
7139 subtypes, the implementation should support all @code{Alignment}s
7140 supported by the target linker. For example, page alignment is likely to
7141 be supported for such objects, but not for subtypes.
7145 @cindex @code{Size} clauses
7146 @unnumberedsec 13.3(42-43): Size Clauses
7149 The recommended level of support for the @code{Size} attribute of
7152 A @code{Size} clause should be supported for an object if the specified
7153 @code{Size} is at least as large as its subtype's @code{Size}, and
7154 corresponds to a size in storage elements that is a multiple of the
7155 object's @code{Alignment} (if the @code{Alignment} is nonzero).
7159 @unnumberedsec 13.3(50-56): Size Clauses
7162 If the @code{Size} of a subtype is specified, and allows for efficient
7163 independent addressability (see 9.10) on the target architecture, then
7164 the @code{Size} of the following objects of the subtype should equal the
7165 @code{Size} of the subtype:
7167 Aliased objects (including components).
7173 @code{Size} clause on a composite subtype should not affect the
7174 internal layout of components.
7176 Followed. But note that this can be overridden by use of the implementation
7177 pragma Implicit_Packing in the case of packed arrays.
7181 The recommended level of support for the @code{Size} attribute of subtypes is:
7185 The @code{Size} (if not specified) of a static discrete or fixed point
7186 subtype should be the number of bits needed to represent each value
7187 belonging to the subtype using an unbiased representation, leaving space
7188 for a sign bit only if the subtype contains negative values. If such a
7189 subtype is a first subtype, then an implementation should support a
7190 specified @code{Size} for it that reflects this representation.
7196 For a subtype implemented with levels of indirection, the @code{Size}
7197 should include the size of the pointers, but not the size of what they
7202 @cindex @code{Component_Size} clauses
7203 @unnumberedsec 13.3(71-73): Component Size Clauses
7206 The recommended level of support for the @code{Component_Size}
7211 An implementation need not support specified @code{Component_Sizes} that are
7212 less than the @code{Size} of the component subtype.
7218 An implementation should support specified @code{Component_Size}s that
7219 are factors and multiples of the word size. For such
7220 @code{Component_Size}s, the array should contain no gaps between
7221 components. For other @code{Component_Size}s (if supported), the array
7222 should contain no gaps between components when packing is also
7223 specified; the implementation should forbid this combination in cases
7224 where it cannot support a no-gaps representation.
7228 @cindex Enumeration representation clauses
7229 @cindex Representation clauses, enumeration
7230 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
7233 The recommended level of support for enumeration representation clauses
7236 An implementation need not support enumeration representation clauses
7237 for boolean types, but should at minimum support the internal codes in
7238 the range @code{System.Min_Int.System.Max_Int}.
7242 @cindex Record representation clauses
7243 @cindex Representation clauses, records
7244 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
7247 The recommended level of support for
7248 @*@code{record_representation_clauses} is:
7250 An implementation should support storage places that can be extracted
7251 with a load, mask, shift sequence of machine code, and set with a load,
7252 shift, mask, store sequence, given the available machine instructions
7259 A storage place should be supported if its size is equal to the
7260 @code{Size} of the component subtype, and it starts and ends on a
7261 boundary that obeys the @code{Alignment} of the component subtype.
7267 If the default bit ordering applies to the declaration of a given type,
7268 then for a component whose subtype's @code{Size} is less than the word
7269 size, any storage place that does not cross an aligned word boundary
7270 should be supported.
7276 An implementation may reserve a storage place for the tag field of a
7277 tagged type, and disallow other components from overlapping that place.
7279 Followed. The storage place for the tag field is the beginning of the tagged
7280 record, and its size is Address'Size. GNAT will reject an explicit component
7281 clause for the tag field.
7285 An implementation need not support a @code{component_clause} for a
7286 component of an extension part if the storage place is not after the
7287 storage places of all components of the parent type, whether or not
7288 those storage places had been specified.
7290 Followed. The above advice on record representation clauses is followed,
7291 and all mentioned features are implemented.
7293 @cindex Storage place attributes
7294 @unnumberedsec 13.5.2(5): Storage Place Attributes
7297 If a component is represented using some form of pointer (such as an
7298 offset) to the actual data of the component, and this data is contiguous
7299 with the rest of the object, then the storage place attributes should
7300 reflect the place of the actual data, not the pointer. If a component is
7301 allocated discontinuously from the rest of the object, then a warning
7302 should be generated upon reference to one of its storage place
7305 Followed. There are no such components in GNAT@.
7307 @cindex Bit ordering
7308 @unnumberedsec 13.5.3(7-8): Bit Ordering
7311 The recommended level of support for the non-default bit ordering is:
7315 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
7316 should support the non-default bit ordering in addition to the default
7319 Followed. Word size does not equal storage size in this implementation.
7320 Thus non-default bit ordering is not supported.
7322 @cindex @code{Address}, as private type
7323 @unnumberedsec 13.7(37): Address as Private
7326 @code{Address} should be of a private type.
7330 @cindex Operations, on @code{Address}
7331 @cindex @code{Address}, operations of
7332 @unnumberedsec 13.7.1(16): Address Operations
7335 Operations in @code{System} and its children should reflect the target
7336 environment semantics as closely as is reasonable. For example, on most
7337 machines, it makes sense for address arithmetic to ``wrap around''.
7338 Operations that do not make sense should raise @code{Program_Error}.
7340 Followed. Address arithmetic is modular arithmetic that wraps around. No
7341 operation raises @code{Program_Error}, since all operations make sense.
7343 @cindex Unchecked conversion
7344 @unnumberedsec 13.9(14-17): Unchecked Conversion
7347 The @code{Size} of an array object should not include its bounds; hence,
7348 the bounds should not be part of the converted data.
7354 The implementation should not generate unnecessary run-time checks to
7355 ensure that the representation of @var{S} is a representation of the
7356 target type. It should take advantage of the permission to return by
7357 reference when possible. Restrictions on unchecked conversions should be
7358 avoided unless required by the target environment.
7360 Followed. There are no restrictions on unchecked conversion. A warning is
7361 generated if the source and target types do not have the same size since
7362 the semantics in this case may be target dependent.
7366 The recommended level of support for unchecked conversions is:
7370 Unchecked conversions should be supported and should be reversible in
7371 the cases where this clause defines the result. To enable meaningful use
7372 of unchecked conversion, a contiguous representation should be used for
7373 elementary subtypes, for statically constrained array subtypes whose
7374 component subtype is one of the subtypes described in this paragraph,
7375 and for record subtypes without discriminants whose component subtypes
7376 are described in this paragraph.
7380 @cindex Heap usage, implicit
7381 @unnumberedsec 13.11(23-25): Implicit Heap Usage
7384 An implementation should document any cases in which it dynamically
7385 allocates heap storage for a purpose other than the evaluation of an
7388 Followed, the only other points at which heap storage is dynamically
7389 allocated are as follows:
7393 At initial elaboration time, to allocate dynamically sized global
7397 To allocate space for a task when a task is created.
7400 To extend the secondary stack dynamically when needed. The secondary
7401 stack is used for returning variable length results.
7406 A default (implementation-provided) storage pool for an
7407 access-to-constant type should not have overhead to support deallocation of
7414 A storage pool for an anonymous access type should be created at the
7415 point of an allocator for the type, and be reclaimed when the designated
7416 object becomes inaccessible.
7420 @cindex Unchecked deallocation
7421 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7424 For a standard storage pool, @code{Free} should actually reclaim the
7429 @cindex Stream oriented attributes
7430 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7433 If a stream element is the same size as a storage element, then the
7434 normal in-memory representation should be used by @code{Read} and
7435 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
7436 should use the smallest number of stream elements needed to represent
7437 all values in the base range of the scalar type.
7440 Followed. By default, GNAT uses the interpretation suggested by AI-195,
7441 which specifies using the size of the first subtype.
7442 However, such an implementation is based on direct binary
7443 representations and is therefore target- and endianness-dependent.
7444 To address this issue, GNAT also supplies an alternate implementation
7445 of the stream attributes @code{Read} and @code{Write},
7446 which uses the target-independent XDR standard representation
7448 @cindex XDR representation
7449 @cindex @code{Read} attribute
7450 @cindex @code{Write} attribute
7451 @cindex Stream oriented attributes
7452 The XDR implementation is provided as an alternative body of the
7453 @code{System.Stream_Attributes} package, in the file
7454 @file{s-stratt-xdr.adb} in the GNAT library.
7455 There is no @file{s-stratt-xdr.ads} file.
7456 In order to install the XDR implementation, do the following:
7458 @item Replace the default implementation of the
7459 @code{System.Stream_Attributes} package with the XDR implementation.
7460 For example on a Unix platform issue the commands:
7462 $ mv s-stratt.adb s-stratt-default.adb
7463 $ mv s-stratt-xdr.adb s-stratt.adb
7467 Rebuild the GNAT run-time library as documented in
7468 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7471 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7474 If an implementation provides additional named predefined integer types,
7475 then the names should end with @samp{Integer} as in
7476 @samp{Long_Integer}. If an implementation provides additional named
7477 predefined floating point types, then the names should end with
7478 @samp{Float} as in @samp{Long_Float}.
7482 @findex Ada.Characters.Handling
7483 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7486 If an implementation provides a localized definition of @code{Character}
7487 or @code{Wide_Character}, then the effects of the subprograms in
7488 @code{Characters.Handling} should reflect the localizations. See also
7491 Followed. GNAT provides no such localized definitions.
7493 @cindex Bounded-length strings
7494 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7497 Bounded string objects should not be implemented by implicit pointers
7498 and dynamic allocation.
7500 Followed. No implicit pointers or dynamic allocation are used.
7502 @cindex Random number generation
7503 @unnumberedsec A.5.2(46-47): Random Number Generation
7506 Any storage associated with an object of type @code{Generator} should be
7507 reclaimed on exit from the scope of the object.
7513 If the generator period is sufficiently long in relation to the number
7514 of distinct initiator values, then each possible value of
7515 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7516 random numbers that does not, in a practical sense, overlap the sequence
7517 initiated by any other value. If this is not possible, then the mapping
7518 between initiator values and generator states should be a rapidly
7519 varying function of the initiator value.
7521 Followed. The generator period is sufficiently long for the first
7522 condition here to hold true.
7524 @findex Get_Immediate
7525 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7528 The @code{Get_Immediate} procedures should be implemented with
7529 unbuffered input. For a device such as a keyboard, input should be
7530 @dfn{available} if a key has already been typed, whereas for a disk
7531 file, input should always be available except at end of file. For a file
7532 associated with a keyboard-like device, any line-editing features of the
7533 underlying operating system should be disabled during the execution of
7534 @code{Get_Immediate}.
7536 Followed on all targets except VxWorks. For VxWorks, there is no way to
7537 provide this functionality that does not result in the input buffer being
7538 flushed before the @code{Get_Immediate} call. A special unit
7539 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7543 @unnumberedsec B.1(39-41): Pragma @code{Export}
7546 If an implementation supports pragma @code{Export} to a given language,
7547 then it should also allow the main subprogram to be written in that
7548 language. It should support some mechanism for invoking the elaboration
7549 of the Ada library units included in the system, and for invoking the
7550 finalization of the environment task. On typical systems, the
7551 recommended mechanism is to provide two subprograms whose link names are
7552 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
7553 elaboration code for library units. @code{adafinal} should contain the
7554 finalization code. These subprograms should have no effect the second
7555 and subsequent time they are called.
7561 Automatic elaboration of pre-elaborated packages should be
7562 provided when pragma @code{Export} is supported.
7564 Followed when the main program is in Ada. If the main program is in a
7565 foreign language, then
7566 @code{adainit} must be called to elaborate pre-elaborated
7571 For each supported convention @var{L} other than @code{Intrinsic}, an
7572 implementation should support @code{Import} and @code{Export} pragmas
7573 for objects of @var{L}-compatible types and for subprograms, and pragma
7574 @code{Convention} for @var{L}-eligible types and for subprograms,
7575 presuming the other language has corresponding features. Pragma
7576 @code{Convention} need not be supported for scalar types.
7580 @cindex Package @code{Interfaces}
7582 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7585 For each implementation-defined convention identifier, there should be a
7586 child package of package Interfaces with the corresponding name. This
7587 package should contain any declarations that would be useful for
7588 interfacing to the language (implementation) represented by the
7589 convention. Any declarations useful for interfacing to any language on
7590 the given hardware architecture should be provided directly in
7593 Followed. An additional package not defined
7594 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7595 for interfacing to C++.
7599 An implementation supporting an interface to C, COBOL, or Fortran should
7600 provide the corresponding package or packages described in the following
7603 Followed. GNAT provides all the packages described in this section.
7605 @cindex C, interfacing with
7606 @unnumberedsec B.3(63-71): Interfacing with C
7609 An implementation should support the following interface correspondences
7616 An Ada procedure corresponds to a void-returning C function.
7622 An Ada function corresponds to a non-void C function.
7628 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7635 An Ada @code{in} parameter of an access-to-object type with designated
7636 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7637 where @var{t} is the C type corresponding to the Ada type @var{T}.
7643 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7644 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7645 argument to a C function, where @var{t} is the C type corresponding to
7646 the Ada type @var{T}. In the case of an elementary @code{out} or
7647 @code{in out} parameter, a pointer to a temporary copy is used to
7648 preserve by-copy semantics.
7654 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7655 @code{@var{t}*} argument to a C function, where @var{t} is the C
7656 structure corresponding to the Ada type @var{T}.
7658 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7659 pragma, or Convention, or by explicitly specifying the mechanism for a given
7660 call using an extended import or export pragma.
7664 An Ada parameter of an array type with component type @var{T}, of any
7665 mode, is passed as a @code{@var{t}*} argument to a C function, where
7666 @var{t} is the C type corresponding to the Ada type @var{T}.
7672 An Ada parameter of an access-to-subprogram type is passed as a pointer
7673 to a C function whose prototype corresponds to the designated
7674 subprogram's specification.
7678 @cindex COBOL, interfacing with
7679 @unnumberedsec B.4(95-98): Interfacing with COBOL
7682 An Ada implementation should support the following interface
7683 correspondences between Ada and COBOL@.
7689 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7690 the COBOL type corresponding to @var{T}.
7696 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7697 the corresponding COBOL type.
7703 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7704 COBOL type corresponding to the Ada parameter type; for scalars, a local
7705 copy is used if necessary to ensure by-copy semantics.
7709 @cindex Fortran, interfacing with
7710 @unnumberedsec B.5(22-26): Interfacing with Fortran
7713 An Ada implementation should support the following interface
7714 correspondences between Ada and Fortran:
7720 An Ada procedure corresponds to a Fortran subroutine.
7726 An Ada function corresponds to a Fortran function.
7732 An Ada parameter of an elementary, array, or record type @var{T} is
7733 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7734 the Fortran type corresponding to the Ada type @var{T}, and where the
7735 INTENT attribute of the corresponding dummy argument matches the Ada
7736 formal parameter mode; the Fortran implementation's parameter passing
7737 conventions are used. For elementary types, a local copy is used if
7738 necessary to ensure by-copy semantics.
7744 An Ada parameter of an access-to-subprogram type is passed as a
7745 reference to a Fortran procedure whose interface corresponds to the
7746 designated subprogram's specification.
7750 @cindex Machine operations
7751 @unnumberedsec C.1(3-5): Access to Machine Operations
7754 The machine code or intrinsic support should allow access to all
7755 operations normally available to assembly language programmers for the
7756 target environment, including privileged instructions, if any.
7762 The interfacing pragmas (see Annex B) should support interface to
7763 assembler; the default assembler should be associated with the
7764 convention identifier @code{Assembler}.
7770 If an entity is exported to assembly language, then the implementation
7771 should allocate it at an addressable location, and should ensure that it
7772 is retained by the linking process, even if not otherwise referenced
7773 from the Ada code. The implementation should assume that any call to a
7774 machine code or assembler subprogram is allowed to read or update every
7775 object that is specified as exported.
7779 @unnumberedsec C.1(10-16): Access to Machine Operations
7782 The implementation should ensure that little or no overhead is
7783 associated with calling intrinsic and machine-code subprograms.
7785 Followed for both intrinsics and machine-code subprograms.
7789 It is recommended that intrinsic subprograms be provided for convenient
7790 access to any machine operations that provide special capabilities or
7791 efficiency and that are not otherwise available through the language
7794 Followed. A full set of machine operation intrinsic subprograms is provided.
7798 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7799 swap, decrement and test, enqueue/dequeue.
7801 Followed on any target supporting such operations.
7805 Standard numeric functions---e.g.@:, sin, log.
7807 Followed on any target supporting such operations.
7811 String manipulation operations---e.g.@:, translate and test.
7813 Followed on any target supporting such operations.
7817 Vector operations---e.g.@:, compare vector against thresholds.
7819 Followed on any target supporting such operations.
7823 Direct operations on I/O ports.
7825 Followed on any target supporting such operations.
7827 @cindex Interrupt support
7828 @unnumberedsec C.3(28): Interrupt Support
7831 If the @code{Ceiling_Locking} policy is not in effect, the
7832 implementation should provide means for the application to specify which
7833 interrupts are to be blocked during protected actions, if the underlying
7834 system allows for a finer-grain control of interrupt blocking.
7836 Followed. The underlying system does not allow for finer-grain control
7837 of interrupt blocking.
7839 @cindex Protected procedure handlers
7840 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7843 Whenever possible, the implementation should allow interrupt handlers to
7844 be called directly by the hardware.
7848 This is never possible under IRIX, so this is followed by default.
7850 Followed on any target where the underlying operating system permits
7855 Whenever practical, violations of any
7856 implementation-defined restrictions should be detected before run time.
7858 Followed. Compile time warnings are given when possible.
7860 @cindex Package @code{Interrupts}
7862 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7866 If implementation-defined forms of interrupt handler procedures are
7867 supported, such as protected procedures with parameters, then for each
7868 such form of a handler, a type analogous to @code{Parameterless_Handler}
7869 should be specified in a child package of @code{Interrupts}, with the
7870 same operations as in the predefined package Interrupts.
7874 @cindex Pre-elaboration requirements
7875 @unnumberedsec C.4(14): Pre-elaboration Requirements
7878 It is recommended that pre-elaborated packages be implemented in such a
7879 way that there should be little or no code executed at run time for the
7880 elaboration of entities not already covered by the Implementation
7883 Followed. Executable code is generated in some cases, e.g.@: loops
7884 to initialize large arrays.
7886 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7889 If the pragma applies to an entity, then the implementation should
7890 reduce the amount of storage used for storing names associated with that
7895 @cindex Package @code{Task_Attributes}
7896 @findex Task_Attributes
7897 @unnumberedsec C.7.2(30): The Package Task_Attributes
7900 Some implementations are targeted to domains in which memory use at run
7901 time must be completely deterministic. For such implementations, it is
7902 recommended that the storage for task attributes will be pre-allocated
7903 statically and not from the heap. This can be accomplished by either
7904 placing restrictions on the number and the size of the task's
7905 attributes, or by using the pre-allocated storage for the first @var{N}
7906 attribute objects, and the heap for the others. In the latter case,
7907 @var{N} should be documented.
7909 Not followed. This implementation is not targeted to such a domain.
7911 @cindex Locking Policies
7912 @unnumberedsec D.3(17): Locking Policies
7916 The implementation should use names that end with @samp{_Locking} for
7917 locking policies defined by the implementation.
7919 Followed. A single implementation-defined locking policy is defined,
7920 whose name (@code{Inheritance_Locking}) follows this suggestion.
7922 @cindex Entry queuing policies
7923 @unnumberedsec D.4(16): Entry Queuing Policies
7926 Names that end with @samp{_Queuing} should be used
7927 for all implementation-defined queuing policies.
7929 Followed. No such implementation-defined queuing policies exist.
7931 @cindex Preemptive abort
7932 @unnumberedsec D.6(9-10): Preemptive Abort
7935 Even though the @code{abort_statement} is included in the list of
7936 potentially blocking operations (see 9.5.1), it is recommended that this
7937 statement be implemented in a way that never requires the task executing
7938 the @code{abort_statement} to block.
7944 On a multi-processor, the delay associated with aborting a task on
7945 another processor should be bounded; the implementation should use
7946 periodic polling, if necessary, to achieve this.
7950 @cindex Tasking restrictions
7951 @unnumberedsec D.7(21): Tasking Restrictions
7954 When feasible, the implementation should take advantage of the specified
7955 restrictions to produce a more efficient implementation.
7957 GNAT currently takes advantage of these restrictions by providing an optimized
7958 run time when the Ravenscar profile and the GNAT restricted run time set
7959 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7960 pragma @code{Profile (Restricted)} for more details.
7962 @cindex Time, monotonic
7963 @unnumberedsec D.8(47-49): Monotonic Time
7966 When appropriate, implementations should provide configuration
7967 mechanisms to change the value of @code{Tick}.
7969 Such configuration mechanisms are not appropriate to this implementation
7970 and are thus not supported.
7974 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7975 be implemented as transformations of the same time base.
7981 It is recommended that the @dfn{best} time base which exists in
7982 the underlying system be available to the application through
7983 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7987 @cindex Partition communication subsystem
7989 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7992 Whenever possible, the PCS on the called partition should allow for
7993 multiple tasks to call the RPC-receiver with different messages and
7994 should allow them to block until the corresponding subprogram body
7997 Followed by GLADE, a separately supplied PCS that can be used with
8002 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
8003 should raise @code{Storage_Error} if it runs out of space trying to
8004 write the @code{Item} into the stream.
8006 Followed by GLADE, a separately supplied PCS that can be used with
8009 @cindex COBOL support
8010 @unnumberedsec F(7): COBOL Support
8013 If COBOL (respectively, C) is widely supported in the target
8014 environment, implementations supporting the Information Systems Annex
8015 should provide the child package @code{Interfaces.COBOL} (respectively,
8016 @code{Interfaces.C}) specified in Annex B and should support a
8017 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
8018 pragmas (see Annex B), thus allowing Ada programs to interface with
8019 programs written in that language.
8023 @cindex Decimal radix support
8024 @unnumberedsec F.1(2): Decimal Radix Support
8027 Packed decimal should be used as the internal representation for objects
8028 of subtype @var{S} when @var{S}'Machine_Radix = 10.
8030 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
8034 @unnumberedsec G: Numerics
8037 If Fortran (respectively, C) is widely supported in the target
8038 environment, implementations supporting the Numerics Annex
8039 should provide the child package @code{Interfaces.Fortran} (respectively,
8040 @code{Interfaces.C}) specified in Annex B and should support a
8041 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
8042 pragmas (see Annex B), thus allowing Ada programs to interface with
8043 programs written in that language.
8047 @cindex Complex types
8048 @unnumberedsec G.1.1(56-58): Complex Types
8051 Because the usual mathematical meaning of multiplication of a complex
8052 operand and a real operand is that of the scaling of both components of
8053 the former by the latter, an implementation should not perform this
8054 operation by first promoting the real operand to complex type and then
8055 performing a full complex multiplication. In systems that, in the
8056 future, support an Ada binding to IEC 559:1989, the latter technique
8057 will not generate the required result when one of the components of the
8058 complex operand is infinite. (Explicit multiplication of the infinite
8059 component by the zero component obtained during promotion yields a NaN
8060 that propagates into the final result.) Analogous advice applies in the
8061 case of multiplication of a complex operand and a pure-imaginary
8062 operand, and in the case of division of a complex operand by a real or
8063 pure-imaginary operand.
8069 Similarly, because the usual mathematical meaning of addition of a
8070 complex operand and a real operand is that the imaginary operand remains
8071 unchanged, an implementation should not perform this operation by first
8072 promoting the real operand to complex type and then performing a full
8073 complex addition. In implementations in which the @code{Signed_Zeros}
8074 attribute of the component type is @code{True} (and which therefore
8075 conform to IEC 559:1989 in regard to the handling of the sign of zero in
8076 predefined arithmetic operations), the latter technique will not
8077 generate the required result when the imaginary component of the complex
8078 operand is a negatively signed zero. (Explicit addition of the negative
8079 zero to the zero obtained during promotion yields a positive zero.)
8080 Analogous advice applies in the case of addition of a complex operand
8081 and a pure-imaginary operand, and in the case of subtraction of a
8082 complex operand and a real or pure-imaginary operand.
8088 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
8089 attempt to provide a rational treatment of the signs of zero results and
8090 result components. As one example, the result of the @code{Argument}
8091 function should have the sign of the imaginary component of the
8092 parameter @code{X} when the point represented by that parameter lies on
8093 the positive real axis; as another, the sign of the imaginary component
8094 of the @code{Compose_From_Polar} function should be the same as
8095 (respectively, the opposite of) that of the @code{Argument} parameter when that
8096 parameter has a value of zero and the @code{Modulus} parameter has a
8097 nonnegative (respectively, negative) value.
8101 @cindex Complex elementary functions
8102 @unnumberedsec G.1.2(49): Complex Elementary Functions
8105 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
8106 @code{True} should attempt to provide a rational treatment of the signs
8107 of zero results and result components. For example, many of the complex
8108 elementary functions have components that are odd functions of one of
8109 the parameter components; in these cases, the result component should
8110 have the sign of the parameter component at the origin. Other complex
8111 elementary functions have zero components whose sign is opposite that of
8112 a parameter component at the origin, or is always positive or always
8117 @cindex Accuracy requirements
8118 @unnumberedsec G.2.4(19): Accuracy Requirements
8121 The versions of the forward trigonometric functions without a
8122 @code{Cycle} parameter should not be implemented by calling the
8123 corresponding version with a @code{Cycle} parameter of
8124 @code{2.0*Numerics.Pi}, since this will not provide the required
8125 accuracy in some portions of the domain. For the same reason, the
8126 version of @code{Log} without a @code{Base} parameter should not be
8127 implemented by calling the corresponding version with a @code{Base}
8128 parameter of @code{Numerics.e}.
8132 @cindex Complex arithmetic accuracy
8133 @cindex Accuracy, complex arithmetic
8134 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
8138 The version of the @code{Compose_From_Polar} function without a
8139 @code{Cycle} parameter should not be implemented by calling the
8140 corresponding version with a @code{Cycle} parameter of
8141 @code{2.0*Numerics.Pi}, since this will not provide the required
8142 accuracy in some portions of the domain.
8146 @c -----------------------------------------
8147 @node Implementation Defined Characteristics
8148 @chapter Implementation Defined Characteristics
8151 In addition to the implementation dependent pragmas and attributes, and the
8152 implementation advice, there are a number of other Ada features that are
8153 potentially implementation dependent and are designated as
8154 implementation-defined. These are mentioned throughout the Ada Reference
8155 Manual, and are summarized in Annex M@.
8157 A requirement for conforming Ada compilers is that they provide
8158 documentation describing how the implementation deals with each of these
8159 issues. In this chapter, you will find each point in Annex M listed
8160 followed by a description in italic font of how GNAT
8164 implementation on IRIX 5.3 operating system or greater
8166 handles the implementation dependence.
8168 You can use this chapter as a guide to minimizing implementation
8169 dependent features in your programs if portability to other compilers
8170 and other operating systems is an important consideration. The numbers
8171 in each section below correspond to the paragraph number in the Ada
8177 @strong{2}. Whether or not each recommendation given in Implementation
8178 Advice is followed. See 1.1.2(37).
8181 @xref{Implementation Advice}.
8186 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
8189 The complexity of programs that can be processed is limited only by the
8190 total amount of available virtual memory, and disk space for the
8191 generated object files.
8196 @strong{4}. Variations from the standard that are impractical to avoid
8197 given the implementation's execution environment. See 1.1.3(6).
8200 There are no variations from the standard.
8205 @strong{5}. Which @code{code_statement}s cause external
8206 interactions. See 1.1.3(10).
8209 Any @code{code_statement} can potentially cause external interactions.
8214 @strong{6}. The coded representation for the text of an Ada
8215 program. See 2.1(4).
8218 See separate section on source representation.
8223 @strong{7}. The control functions allowed in comments. See 2.1(14).
8226 See separate section on source representation.
8231 @strong{8}. The representation for an end of line. See 2.2(2).
8234 See separate section on source representation.
8239 @strong{9}. Maximum supported line length and lexical element
8240 length. See 2.2(15).
8243 The maximum line length is 255 characters and the maximum length of a
8244 lexical element is also 255 characters.
8249 @strong{10}. Implementation defined pragmas. See 2.8(14).
8253 @xref{Implementation Defined Pragmas}.
8258 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
8261 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
8262 parameter, checks that the optimization flag is set, and aborts if it is
8268 @strong{12}. The sequence of characters of the value returned by
8269 @code{@var{S}'Image} when some of the graphic characters of
8270 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
8274 The sequence of characters is as defined by the wide character encoding
8275 method used for the source. See section on source representation for
8281 @strong{13}. The predefined integer types declared in
8282 @code{Standard}. See 3.5.4(25).
8286 @item Short_Short_Integer
8289 (Short) 16 bit signed
8293 64 bit signed (on most 64 bit targets, depending on the C definition of long).
8294 32 bit signed (all other targets)
8295 @item Long_Long_Integer
8302 @strong{14}. Any nonstandard integer types and the operators defined
8303 for them. See 3.5.4(26).
8306 There are no nonstandard integer types.
8311 @strong{15}. Any nonstandard real types and the operators defined for
8315 There are no nonstandard real types.
8320 @strong{16}. What combinations of requested decimal precision and range
8321 are supported for floating point types. See 3.5.7(7).
8324 The precision and range is as defined by the IEEE standard.
8329 @strong{17}. The predefined floating point types declared in
8330 @code{Standard}. See 3.5.7(16).
8337 (Short) 32 bit IEEE short
8340 @item Long_Long_Float
8341 64 bit IEEE long (80 bit IEEE long on x86 processors)
8347 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
8350 @code{Fine_Delta} is 2**(@minus{}63)
8355 @strong{19}. What combinations of small, range, and digits are
8356 supported for fixed point types. See 3.5.9(10).
8359 Any combinations are permitted that do not result in a small less than
8360 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
8361 If the mantissa is larger than 53 bits on machines where Long_Long_Float
8362 is 64 bits (true of all architectures except ia32), then the output from
8363 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
8364 is because floating-point conversions are used to convert fixed point.
8369 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
8370 within an unnamed @code{block_statement}. See 3.9(10).
8373 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
8374 decimal integer are allocated.
8379 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
8382 @xref{Implementation Defined Attributes}.
8387 @strong{22}. Any implementation-defined time types. See 9.6(6).
8390 There are no implementation-defined time types.
8395 @strong{23}. The time base associated with relative delays.
8398 See 9.6(20). The time base used is that provided by the C library
8399 function @code{gettimeofday}.
8404 @strong{24}. The time base of the type @code{Calendar.Time}. See
8408 The time base used is that provided by the C library function
8409 @code{gettimeofday}.
8414 @strong{25}. The time zone used for package @code{Calendar}
8415 operations. See 9.6(24).
8418 The time zone used by package @code{Calendar} is the current system time zone
8419 setting for local time, as accessed by the C library function
8425 @strong{26}. Any limit on @code{delay_until_statements} of
8426 @code{select_statements}. See 9.6(29).
8429 There are no such limits.
8434 @strong{27}. Whether or not two non-overlapping parts of a composite
8435 object are independently addressable, in the case where packing, record
8436 layout, or @code{Component_Size} is specified for the object. See
8440 Separate components are independently addressable if they do not share
8441 overlapping storage units.
8446 @strong{28}. The representation for a compilation. See 10.1(2).
8449 A compilation is represented by a sequence of files presented to the
8450 compiler in a single invocation of the @command{gcc} command.
8455 @strong{29}. Any restrictions on compilations that contain multiple
8456 compilation_units. See 10.1(4).
8459 No single file can contain more than one compilation unit, but any
8460 sequence of files can be presented to the compiler as a single
8466 @strong{30}. The mechanisms for creating an environment and for adding
8467 and replacing compilation units. See 10.1.4(3).
8470 See separate section on compilation model.
8475 @strong{31}. The manner of explicitly assigning library units to a
8476 partition. See 10.2(2).
8479 If a unit contains an Ada main program, then the Ada units for the partition
8480 are determined by recursive application of the rules in the Ada Reference
8481 Manual section 10.2(2-6). In other words, the Ada units will be those that
8482 are needed by the main program, and then this definition of need is applied
8483 recursively to those units, and the partition contains the transitive
8484 closure determined by this relationship. In short, all the necessary units
8485 are included, with no need to explicitly specify the list. If additional
8486 units are required, e.g.@: by foreign language units, then all units must be
8487 mentioned in the context clause of one of the needed Ada units.
8489 If the partition contains no main program, or if the main program is in
8490 a language other than Ada, then GNAT
8491 provides the binder options @option{-z} and @option{-n} respectively, and in
8492 this case a list of units can be explicitly supplied to the binder for
8493 inclusion in the partition (all units needed by these units will also
8494 be included automatically). For full details on the use of these
8495 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8496 @value{EDITION} User's Guide}.
8501 @strong{32}. The implementation-defined means, if any, of specifying
8502 which compilation units are needed by a given compilation unit. See
8506 The units needed by a given compilation unit are as defined in
8507 the Ada Reference Manual section 10.2(2-6). There are no
8508 implementation-defined pragmas or other implementation-defined
8509 means for specifying needed units.
8514 @strong{33}. The manner of designating the main subprogram of a
8515 partition. See 10.2(7).
8518 The main program is designated by providing the name of the
8519 corresponding @file{ALI} file as the input parameter to the binder.
8524 @strong{34}. The order of elaboration of @code{library_items}. See
8528 The first constraint on ordering is that it meets the requirements of
8529 Chapter 10 of the Ada Reference Manual. This still leaves some
8530 implementation dependent choices, which are resolved by first
8531 elaborating bodies as early as possible (i.e., in preference to specs
8532 where there is a choice), and second by evaluating the immediate with
8533 clauses of a unit to determine the probably best choice, and
8534 third by elaborating in alphabetical order of unit names
8535 where a choice still remains.
8540 @strong{35}. Parameter passing and function return for the main
8541 subprogram. See 10.2(21).
8544 The main program has no parameters. It may be a procedure, or a function
8545 returning an integer type. In the latter case, the returned integer
8546 value is the return code of the program (overriding any value that
8547 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8552 @strong{36}. The mechanisms for building and running partitions. See
8556 GNAT itself supports programs with only a single partition. The GNATDIST
8557 tool provided with the GLADE package (which also includes an implementation
8558 of the PCS) provides a completely flexible method for building and running
8559 programs consisting of multiple partitions. See the separate GLADE manual
8565 @strong{37}. The details of program execution, including program
8566 termination. See 10.2(25).
8569 See separate section on compilation model.
8574 @strong{38}. The semantics of any non-active partitions supported by the
8575 implementation. See 10.2(28).
8578 Passive partitions are supported on targets where shared memory is
8579 provided by the operating system. See the GLADE reference manual for
8585 @strong{39}. The information returned by @code{Exception_Message}. See
8589 Exception message returns the null string unless a specific message has
8590 been passed by the program.
8595 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
8596 declared within an unnamed @code{block_statement}. See 11.4.1(12).
8599 Blocks have implementation defined names of the form @code{B@var{nnn}}
8600 where @var{nnn} is an integer.
8605 @strong{41}. The information returned by
8606 @code{Exception_Information}. See 11.4.1(13).
8609 @code{Exception_Information} returns a string in the following format:
8612 @emph{Exception_Name:} nnnnn
8613 @emph{Message:} mmmmm
8615 @emph{Call stack traceback locations:}
8616 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8624 @code{nnnn} is the fully qualified name of the exception in all upper
8625 case letters. This line is always present.
8628 @code{mmmm} is the message (this line present only if message is non-null)
8631 @code{ppp} is the Process Id value as a decimal integer (this line is
8632 present only if the Process Id is nonzero). Currently we are
8633 not making use of this field.
8636 The Call stack traceback locations line and the following values
8637 are present only if at least one traceback location was recorded.
8638 The values are given in C style format, with lower case letters
8639 for a-f, and only as many digits present as are necessary.
8643 The line terminator sequence at the end of each line, including
8644 the last line is a single @code{LF} character (@code{16#0A#}).
8649 @strong{42}. Implementation-defined check names. See 11.5(27).
8652 The implementation defined check name Alignment_Check controls checking of
8653 address clause values for proper alignment (that is, the address supplied
8654 must be consistent with the alignment of the type).
8656 In addition, a user program can add implementation-defined check names
8657 by means of the pragma Check_Name.
8662 @strong{43}. The interpretation of each aspect of representation. See
8666 See separate section on data representations.
8671 @strong{44}. Any restrictions placed upon representation items. See
8675 See separate section on data representations.
8680 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8684 Size for an indefinite subtype is the maximum possible size, except that
8685 for the case of a subprogram parameter, the size of the parameter object
8691 @strong{46}. The default external representation for a type tag. See
8695 The default external representation for a type tag is the fully expanded
8696 name of the type in upper case letters.
8701 @strong{47}. What determines whether a compilation unit is the same in
8702 two different partitions. See 13.3(76).
8705 A compilation unit is the same in two different partitions if and only
8706 if it derives from the same source file.
8711 @strong{48}. Implementation-defined components. See 13.5.1(15).
8714 The only implementation defined component is the tag for a tagged type,
8715 which contains a pointer to the dispatching table.
8720 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8721 ordering. See 13.5.3(5).
8724 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8725 implementation, so no non-default bit ordering is supported. The default
8726 bit ordering corresponds to the natural endianness of the target architecture.
8731 @strong{50}. The contents of the visible part of package @code{System}
8732 and its language-defined children. See 13.7(2).
8735 See the definition of these packages in files @file{system.ads} and
8736 @file{s-stoele.ads}.
8741 @strong{51}. The contents of the visible part of package
8742 @code{System.Machine_Code}, and the meaning of
8743 @code{code_statements}. See 13.8(7).
8746 See the definition and documentation in file @file{s-maccod.ads}.
8751 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8754 Unchecked conversion between types of the same size
8755 results in an uninterpreted transmission of the bits from one type
8756 to the other. If the types are of unequal sizes, then in the case of
8757 discrete types, a shorter source is first zero or sign extended as
8758 necessary, and a shorter target is simply truncated on the left.
8759 For all non-discrete types, the source is first copied if necessary
8760 to ensure that the alignment requirements of the target are met, then
8761 a pointer is constructed to the source value, and the result is obtained
8762 by dereferencing this pointer after converting it to be a pointer to the
8763 target type. Unchecked conversions where the target subtype is an
8764 unconstrained array are not permitted. If the target alignment is
8765 greater than the source alignment, then a copy of the result is
8766 made with appropriate alignment
8771 @strong{53}. The semantics of operations on invalid representations.
8775 For assignments and other operations where the use of invalid values cannot
8776 result in erroneous behavior, the compiler ignores the possibility of invalid
8777 values. An exception is raised at the point where an invalid value would
8778 result in erroneous behavior. For example executing:
8780 @smallexample @c ada
8781 procedure invalidvals is
8783 Y : Natural range 1 .. 10;
8784 for Y'Address use X'Address;
8785 Z : Natural range 1 .. 10;
8786 A : array (Natural range 1 .. 10) of Integer;
8788 Z := Y; -- no exception
8789 A (Z) := 3; -- exception raised;
8794 As indicated, an exception is raised on the array assignment, but not
8795 on the simple assignment of the invalid negative value from Y to Z.
8800 @strong{53}. The manner of choosing a storage pool for an access type
8801 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8804 There are 3 different standard pools used by the compiler when
8805 @code{Storage_Pool} is not specified depending whether the type is local
8806 to a subprogram or defined at the library level and whether
8807 @code{Storage_Size}is specified or not. See documentation in the runtime
8808 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8809 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8810 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8816 @strong{54}. Whether or not the implementation provides user-accessible
8817 names for the standard pool type(s). See 13.11(17).
8821 See documentation in the sources of the run time mentioned in paragraph
8822 @strong{53} . All these pools are accessible by means of @code{with}'ing
8828 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8831 @code{Storage_Size} is measured in storage units, and refers to the
8832 total space available for an access type collection, or to the primary
8833 stack space for a task.
8838 @strong{56}. Implementation-defined aspects of storage pools. See
8842 See documentation in the sources of the run time mentioned in paragraph
8843 @strong{53} for details on GNAT-defined aspects of storage pools.
8848 @strong{57}. The set of restrictions allowed in a pragma
8849 @code{Restrictions}. See 13.12(7).
8852 All RM defined Restriction identifiers are implemented. The following
8853 additional restriction identifiers are provided. There are two separate
8854 lists of implementation dependent restriction identifiers. The first
8855 set requires consistency throughout a partition (in other words, if the
8856 restriction identifier is used for any compilation unit in the partition,
8857 then all compilation units in the partition must obey the restriction.
8861 @item Simple_Barriers
8862 @findex Simple_Barriers
8863 This restriction ensures at compile time that barriers in entry declarations
8864 for protected types are restricted to either static boolean expressions or
8865 references to simple boolean variables defined in the private part of the
8866 protected type. No other form of entry barriers is permitted. This is one
8867 of the restrictions of the Ravenscar profile for limited tasking (see also
8868 pragma @code{Profile (Ravenscar)}).
8870 @item Max_Entry_Queue_Length => Expr
8871 @findex Max_Entry_Queue_Length
8872 This restriction is a declaration that any protected entry compiled in
8873 the scope of the restriction has at most the specified number of
8874 tasks waiting on the entry
8875 at any one time, and so no queue is required. This restriction is not
8876 checked at compile time. A program execution is erroneous if an attempt
8877 is made to queue more than the specified number of tasks on such an entry.
8881 This restriction ensures at compile time that there is no implicit or
8882 explicit dependence on the package @code{Ada.Calendar}.
8884 @item No_Default_Initialization
8885 @findex No_Default_Initialization
8887 This restriction prohibits any instance of default initialization of variables.
8888 The binder implements a consistency rule which prevents any unit compiled
8889 without the restriction from with'ing a unit with the restriction (this allows
8890 the generation of initialization procedures to be skipped, since you can be
8891 sure that no call is ever generated to an initialization procedure in a unit
8892 with the restriction active). If used in conjunction with Initialize_Scalars or
8893 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8894 without a specific initializer (including the case of OUT scalar parameters).
8896 @item No_Direct_Boolean_Operators
8897 @findex No_Direct_Boolean_Operators
8898 This restriction ensures that no logical (and/or/xor) are used on
8899 operands of type Boolean (or any type derived
8900 from Boolean). This is intended for use in safety critical programs
8901 where the certification protocol requires the use of short-circuit
8902 (and then, or else) forms for all composite boolean operations.
8904 @item No_Dispatching_Calls
8905 @findex No_Dispatching_Calls
8906 This restriction ensures at compile time that the code generated by the
8907 compiler involves no dispatching calls. The use of this restriction allows the
8908 safe use of record extensions, classwide membership tests and other classwide
8909 features not involving implicit dispatching. This restriction ensures that
8910 the code contains no indirect calls through a dispatching mechanism. Note that
8911 this includes internally-generated calls created by the compiler, for example
8912 in the implementation of class-wide objects assignments. The
8913 membership test is allowed in the presence of this restriction, because its
8914 implementation requires no dispatching.
8915 This restriction is comparable to the official Ada restriction
8916 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8917 all classwide constructs that do not imply dispatching.
8918 The following example indicates constructs that violate this restriction.
8922 type T is tagged record
8925 procedure P (X : T);
8927 type DT is new T with record
8928 More_Data : Natural;
8930 procedure Q (X : DT);
8934 procedure Example is
8935 procedure Test (O : T'Class) is
8936 N : Natural := O'Size;-- Error: Dispatching call
8937 C : T'Class := O; -- Error: implicit Dispatching Call
8939 if O in DT'Class then -- OK : Membership test
8940 Q (DT (O)); -- OK : Type conversion plus direct call
8942 P (O); -- Error: Dispatching call
8948 P (Obj); -- OK : Direct call
8949 P (T (Obj)); -- OK : Type conversion plus direct call
8950 P (T'Class (Obj)); -- Error: Dispatching call
8952 Test (Obj); -- OK : Type conversion
8954 if Obj in T'Class then -- OK : Membership test
8960 @item No_Dynamic_Attachment
8961 @findex No_Dynamic_Attachment
8962 This restriction ensures that there is no call to any of the operations
8963 defined in package Ada.Interrupts.
8965 @item No_Enumeration_Maps
8966 @findex No_Enumeration_Maps
8967 This restriction ensures at compile time that no operations requiring
8968 enumeration maps are used (that is Image and Value attributes applied
8969 to enumeration types).
8971 @item No_Entry_Calls_In_Elaboration_Code
8972 @findex No_Entry_Calls_In_Elaboration_Code
8973 This restriction ensures at compile time that no task or protected entry
8974 calls are made during elaboration code. As a result of the use of this
8975 restriction, the compiler can assume that no code past an accept statement
8976 in a task can be executed at elaboration time.
8978 @item No_Exception_Handlers
8979 @findex No_Exception_Handlers
8980 This restriction ensures at compile time that there are no explicit
8981 exception handlers. It also indicates that no exception propagation will
8982 be provided. In this mode, exceptions may be raised but will result in
8983 an immediate call to the last chance handler, a routine that the user
8984 must define with the following profile:
8986 @smallexample @c ada
8987 procedure Last_Chance_Handler
8988 (Source_Location : System.Address; Line : Integer);
8989 pragma Export (C, Last_Chance_Handler,
8990 "__gnat_last_chance_handler");
8993 The parameter is a C null-terminated string representing a message to be
8994 associated with the exception (typically the source location of the raise
8995 statement generated by the compiler). The Line parameter when nonzero
8996 represents the line number in the source program where the raise occurs.
8998 @item No_Exception_Propagation
8999 @findex No_Exception_Propagation
9000 This restriction guarantees that exceptions are never propagated to an outer
9001 subprogram scope). The only case in which an exception may be raised is when
9002 the handler is statically in the same subprogram, so that the effect of a raise
9003 is essentially like a goto statement. Any other raise statement (implicit or
9004 explicit) will be considered unhandled. Exception handlers are allowed, but may
9005 not contain an exception occurrence identifier (exception choice). In addition
9006 use of the package GNAT.Current_Exception is not permitted, and reraise
9007 statements (raise with no operand) are not permitted.
9009 @item No_Exception_Registration
9010 @findex No_Exception_Registration
9011 This restriction ensures at compile time that no stream operations for
9012 types Exception_Id or Exception_Occurrence are used. This also makes it
9013 impossible to pass exceptions to or from a partition with this restriction
9014 in a distributed environment. If this exception is active, then the generated
9015 code is simplified by omitting the otherwise-required global registration
9016 of exceptions when they are declared.
9018 @item No_Implicit_Aliasing
9019 @findex No_Implicit_Aliasing
9021 This restriction, which is not required to be partition-wide consistent,
9022 requires an explicit aliased keyword for an object to which 'Access,
9023 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
9024 the 'Unrestricted_Access attribute for objects. Note: the reason that
9025 Unrestricted_Access is forbidden is that it would require the prefix
9026 to be aliased, and in such cases, it can always be replaced by
9027 the standard attribute Unchecked_Access which is preferable.
9029 @item No_Implicit_Conditionals
9030 @findex No_Implicit_Conditionals
9031 This restriction ensures that the generated code does not contain any
9032 implicit conditionals, either by modifying the generated code where possible,
9033 or by rejecting any construct that would otherwise generate an implicit
9034 conditional. Note that this check does not include run time constraint
9035 checks, which on some targets may generate implicit conditionals as
9036 well. To control the latter, constraint checks can be suppressed in the
9037 normal manner. Constructs generating implicit conditionals include comparisons
9038 of composite objects and the Max/Min attributes.
9040 @item No_Implicit_Dynamic_Code
9041 @findex No_Implicit_Dynamic_Code
9043 This restriction prevents the compiler from building ``trampolines''.
9044 This is a structure that is built on the stack and contains dynamic
9045 code to be executed at run time. On some targets, a trampoline is
9046 built for the following features: @code{Access},
9047 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
9048 nested task bodies; primitive operations of nested tagged types.
9049 Trampolines do not work on machines that prevent execution of stack
9050 data. For example, on windows systems, enabling DEP (data execution
9051 protection) will cause trampolines to raise an exception.
9052 Trampolines are also quite slow at run time.
9054 On many targets, trampolines have been largely eliminated. Look at the
9055 version of system.ads for your target --- if it has
9056 Always_Compatible_Rep equal to False, then trampolines are largely
9057 eliminated. In particular, a trampoline is built for the following
9058 features: @code{Address} of a nested subprogram;
9059 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
9060 but only if pragma Favor_Top_Level applies, or the access type has a
9061 foreign-language convention; primitive operations of nested tagged
9064 @item No_Implicit_Loops
9065 @findex No_Implicit_Loops
9066 This restriction ensures that the generated code does not contain any
9067 implicit @code{for} loops, either by modifying
9068 the generated code where possible,
9069 or by rejecting any construct that would otherwise generate an implicit
9070 @code{for} loop. If this restriction is active, it is possible to build
9071 large array aggregates with all static components without generating an
9072 intermediate temporary, and without generating a loop to initialize individual
9073 components. Otherwise, a loop is created for arrays larger than about 5000
9076 @item No_Initialize_Scalars
9077 @findex No_Initialize_Scalars
9078 This restriction ensures that no unit in the partition is compiled with
9079 pragma Initialize_Scalars. This allows the generation of more efficient
9080 code, and in particular eliminates dummy null initialization routines that
9081 are otherwise generated for some record and array types.
9083 @item No_Local_Protected_Objects
9084 @findex No_Local_Protected_Objects
9085 This restriction ensures at compile time that protected objects are
9086 only declared at the library level.
9088 @item No_Protected_Type_Allocators
9089 @findex No_Protected_Type_Allocators
9090 This restriction ensures at compile time that there are no allocator
9091 expressions that attempt to allocate protected objects.
9093 @item No_Secondary_Stack
9094 @findex No_Secondary_Stack
9095 This restriction ensures at compile time that the generated code does not
9096 contain any reference to the secondary stack. The secondary stack is used
9097 to implement functions returning unconstrained objects (arrays or records)
9100 @item No_Select_Statements
9101 @findex No_Select_Statements
9102 This restriction ensures at compile time no select statements of any kind
9103 are permitted, that is the keyword @code{select} may not appear.
9104 This is one of the restrictions of the Ravenscar
9105 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
9107 @item No_Standard_Storage_Pools
9108 @findex No_Standard_Storage_Pools
9109 This restriction ensures at compile time that no access types
9110 use the standard default storage pool. Any access type declared must
9111 have an explicit Storage_Pool attribute defined specifying a
9112 user-defined storage pool.
9116 This restriction ensures at compile/bind time that there are no
9117 stream objects created and no use of stream attributes.
9118 This restriction does not forbid dependences on the package
9119 @code{Ada.Streams}. So it is permissible to with
9120 @code{Ada.Streams} (or another package that does so itself)
9121 as long as no actual stream objects are created and no
9122 stream attributes are used.
9124 Note that the use of restriction allows optimization of tagged types,
9125 since they do not need to worry about dispatching stream operations.
9126 To take maximum advantage of this space-saving optimization, any
9127 unit declaring a tagged type should be compiled with the restriction,
9128 though this is not required.
9130 @item No_Task_Attributes_Package
9131 @findex No_Task_Attributes_Package
9132 This restriction ensures at compile time that there are no implicit or
9133 explicit dependencies on the package @code{Ada.Task_Attributes}.
9135 @item No_Task_Termination
9136 @findex No_Task_Termination
9137 This restriction ensures at compile time that no terminate alternatives
9138 appear in any task body.
9142 This restriction prevents the declaration of tasks or task types throughout
9143 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
9144 except that violations are caught at compile time and cause an error message
9145 to be output either by the compiler or binder.
9147 @item Static_Priorities
9148 @findex Static_Priorities
9149 This restriction ensures at compile time that all priority expressions
9150 are static, and that there are no dependencies on the package
9151 @code{Ada.Dynamic_Priorities}.
9153 @item Static_Storage_Size
9154 @findex Static_Storage_Size
9155 This restriction ensures at compile time that any expression appearing
9156 in a Storage_Size pragma or attribute definition clause is static.
9161 The second set of implementation dependent restriction identifiers
9162 does not require partition-wide consistency.
9163 The restriction may be enforced for a single
9164 compilation unit without any effect on any of the
9165 other compilation units in the partition.
9169 @item No_Elaboration_Code
9170 @findex No_Elaboration_Code
9171 This restriction ensures at compile time that no elaboration code is
9172 generated. Note that this is not the same condition as is enforced
9173 by pragma @code{Preelaborate}. There are cases in which pragma
9174 @code{Preelaborate} still permits code to be generated (e.g.@: code
9175 to initialize a large array to all zeroes), and there are cases of units
9176 which do not meet the requirements for pragma @code{Preelaborate},
9177 but for which no elaboration code is generated. Generally, it is
9178 the case that preelaborable units will meet the restrictions, with
9179 the exception of large aggregates initialized with an others_clause,
9180 and exception declarations (which generate calls to a run-time
9181 registry procedure). This restriction is enforced on
9182 a unit by unit basis, it need not be obeyed consistently
9183 throughout a partition.
9185 In the case of aggregates with others, if the aggregate has a dynamic
9186 size, there is no way to eliminate the elaboration code (such dynamic
9187 bounds would be incompatible with @code{Preelaborate} in any case). If
9188 the bounds are static, then use of this restriction actually modifies
9189 the code choice of the compiler to avoid generating a loop, and instead
9190 generate the aggregate statically if possible, no matter how many times
9191 the data for the others clause must be repeatedly generated.
9193 It is not possible to precisely document
9194 the constructs which are compatible with this restriction, since,
9195 unlike most other restrictions, this is not a restriction on the
9196 source code, but a restriction on the generated object code. For
9197 example, if the source contains a declaration:
9200 Val : constant Integer := X;
9204 where X is not a static constant, it may be possible, depending
9205 on complex optimization circuitry, for the compiler to figure
9206 out the value of X at compile time, in which case this initialization
9207 can be done by the loader, and requires no initialization code. It
9208 is not possible to document the precise conditions under which the
9209 optimizer can figure this out.
9211 Note that this the implementation of this restriction requires full
9212 code generation. If it is used in conjunction with "semantics only"
9213 checking, then some cases of violations may be missed.
9215 @item No_Entry_Queue
9216 @findex No_Entry_Queue
9217 This restriction is a declaration that any protected entry compiled in
9218 the scope of the restriction has at most one task waiting on the entry
9219 at any one time, and so no queue is required. This restriction is not
9220 checked at compile time. A program execution is erroneous if an attempt
9221 is made to queue a second task on such an entry.
9223 @item No_Implementation_Attributes
9224 @findex No_Implementation_Attributes
9225 This restriction checks at compile time that no GNAT-defined attributes
9226 are present. With this restriction, the only attributes that can be used
9227 are those defined in the Ada Reference Manual.
9229 @item No_Implementation_Pragmas
9230 @findex No_Implementation_Pragmas
9231 This restriction checks at compile time that no GNAT-defined pragmas
9232 are present. With this restriction, the only pragmas that can be used
9233 are those defined in the Ada Reference Manual.
9235 @item No_Implementation_Restrictions
9236 @findex No_Implementation_Restrictions
9237 This restriction checks at compile time that no GNAT-defined restriction
9238 identifiers (other than @code{No_Implementation_Restrictions} itself)
9239 are present. With this restriction, the only other restriction identifiers
9240 that can be used are those defined in the Ada Reference Manual.
9242 @item No_Wide_Characters
9243 @findex No_Wide_Characters
9244 This restriction ensures at compile time that no uses of the types
9245 @code{Wide_Character} or @code{Wide_String} or corresponding wide
9247 appear, and that no wide or wide wide string or character literals
9248 appear in the program (that is literals representing characters not in
9249 type @code{Character}.
9253 This restriction checks at compile time that some constructs forbidden in
9254 SPARK are not present. The SPARK version used as a reference is the same as
9255 the Ada mode for the unit, so a unit compiled in Ada 95 mode with SPARK
9256 restrictions will be checked for constructs forbidden in SPARK 95.
9257 Error messages related to SPARK restriction have the form:
9260 violation of restriction "Spark" at <file>
9264 This is not a replacement for the semantic checks performed by the
9265 SPARK Examiner tool, as the compiler only deals currently with code,
9266 not at all with SPARK annotations and does not guarantee catching all
9267 cases of constructs forbidden by SPARK.
9269 Thus it may well be the case that code which
9270 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
9271 e.g. due to the different visibility rules of the Examiner based on
9272 SPARK @code{inherit} annotations.
9274 This restriction can be useful in providing an initial filter for
9275 code developed using SPARK, or in examining legacy code to see how far
9276 it is from meeting SPARK restrictions.
9283 @strong{58}. The consequences of violating limitations on
9284 @code{Restrictions} pragmas. See 13.12(9).
9287 Restrictions that can be checked at compile time result in illegalities
9288 if violated. Currently there are no other consequences of violating
9294 @strong{59}. The representation used by the @code{Read} and
9295 @code{Write} attributes of elementary types in terms of stream
9296 elements. See 13.13.2(9).
9299 The representation is the in-memory representation of the base type of
9300 the type, using the number of bits corresponding to the
9301 @code{@var{type}'Size} value, and the natural ordering of the machine.
9306 @strong{60}. The names and characteristics of the numeric subtypes
9307 declared in the visible part of package @code{Standard}. See A.1(3).
9310 See items describing the integer and floating-point types supported.
9315 @strong{61}. The accuracy actually achieved by the elementary
9316 functions. See A.5.1(1).
9319 The elementary functions correspond to the functions available in the C
9320 library. Only fast math mode is implemented.
9325 @strong{62}. The sign of a zero result from some of the operators or
9326 functions in @code{Numerics.Generic_Elementary_Functions}, when
9327 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
9330 The sign of zeroes follows the requirements of the IEEE 754 standard on
9336 @strong{63}. The value of
9337 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
9340 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9345 @strong{64}. The value of
9346 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
9349 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9354 @strong{65}. The algorithms for random number generation. See
9358 The algorithm is the Mersenne Twister, as documented in the source file
9359 @file{s-rannum.adb}. This version of the algorithm has a period of
9365 @strong{66}. The string representation of a random number generator's
9366 state. See A.5.2(38).
9369 The value returned by the Image function is the concatenation of
9370 the fixed-width decimal representations of the 624 32-bit integers
9371 of the state vector.
9376 @strong{67}. The minimum time interval between calls to the
9377 time-dependent Reset procedure that are guaranteed to initiate different
9378 random number sequences. See A.5.2(45).
9381 The minimum period between reset calls to guarantee distinct series of
9382 random numbers is one microsecond.
9387 @strong{68}. The values of the @code{Model_Mantissa},
9388 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
9389 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
9390 Annex is not supported. See A.5.3(72).
9393 Run the compiler with @option{-gnatS} to produce a listing of package
9394 @code{Standard}, has the values of all numeric attributes.
9399 @strong{69}. Any implementation-defined characteristics of the
9400 input-output packages. See A.7(14).
9403 There are no special implementation defined characteristics for these
9409 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
9413 All type representations are contiguous, and the @code{Buffer_Size} is
9414 the value of @code{@var{type}'Size} rounded up to the next storage unit
9420 @strong{71}. External files for standard input, standard output, and
9421 standard error See A.10(5).
9424 These files are mapped onto the files provided by the C streams
9425 libraries. See source file @file{i-cstrea.ads} for further details.
9430 @strong{72}. The accuracy of the value produced by @code{Put}. See
9434 If more digits are requested in the output than are represented by the
9435 precision of the value, zeroes are output in the corresponding least
9436 significant digit positions.
9441 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
9442 @code{Command_Name}. See A.15(1).
9445 These are mapped onto the @code{argv} and @code{argc} parameters of the
9446 main program in the natural manner.
9451 @strong{74}. The interpretation of the @code{Form} parameter in procedure
9452 @code{Create_Directory}. See A.16(56).
9455 The @code{Form} parameter is not used.
9460 @strong{75}. The interpretation of the @code{Form} parameter in procedure
9461 @code{Create_Path}. See A.16(60).
9464 The @code{Form} parameter is not used.
9469 @strong{76}. The interpretation of the @code{Form} parameter in procedure
9470 @code{Copy_File}. See A.16(68).
9473 The @code{Form} parameter is case-insensitive.
9475 Two fields are recognized in the @code{Form} parameter:
9479 @item preserve=<value>
9486 <value> starts immediately after the character '=' and ends with the
9487 character immediately preceding the next comma (',') or with the last
9488 character of the parameter.
9490 The only possible values for preserve= are:
9495 Do not try to preserve any file attributes. This is the default if no
9496 preserve= is found in Form.
9498 @item all_attributes
9499 Try to preserve all file attributes (timestamps, access rights).
9502 Preserve the timestamp of the copied file, but not the other file attributes.
9507 The only possible values for mode= are:
9512 Only do the copy if the destination file does not already exist. If it already
9513 exists, Copy_File fails.
9516 Copy the file in all cases. Overwrite an already existing destination file.
9519 Append the original file to the destination file. If the destination file does
9520 not exist, the destination file is a copy of the source file. When mode=append,
9521 the field preserve=, if it exists, is not taken into account.
9526 If the Form parameter includes one or both of the fields and the value or
9527 values are incorrect, Copy_file fails with Use_Error.
9529 Examples of correct Forms:
9532 Form => "preserve=no_attributes,mode=overwrite" (the default)
9533 Form => "mode=append"
9534 Form => "mode=copy, preserve=all_attributes"
9538 Examples of incorrect Forms
9541 Form => "preserve=junk"
9542 Form => "mode=internal, preserve=timestamps"
9548 @strong{77}. Implementation-defined convention names. See B.1(11).
9551 The following convention names are supported
9559 Synonym for Assembler
9561 Synonym for Assembler
9564 @item C_Pass_By_Copy
9565 Allowed only for record types, like C, but also notes that record
9566 is to be passed by copy rather than reference.
9569 @item C_Plus_Plus (or CPP)
9572 Treated the same as C
9574 Treated the same as C
9578 For support of pragma @code{Import} with convention Intrinsic, see
9579 separate section on Intrinsic Subprograms.
9581 Stdcall (used for Windows implementations only). This convention correspond
9582 to the WINAPI (previously called Pascal convention) C/C++ convention under
9583 Windows. A function with this convention cleans the stack before exit.
9589 Stubbed is a special convention used to indicate that the body of the
9590 subprogram will be entirely ignored. Any call to the subprogram
9591 is converted into a raise of the @code{Program_Error} exception. If a
9592 pragma @code{Import} specifies convention @code{stubbed} then no body need
9593 be present at all. This convention is useful during development for the
9594 inclusion of subprograms whose body has not yet been written.
9598 In addition, all otherwise unrecognized convention names are also
9599 treated as being synonymous with convention C@. In all implementations
9600 except for VMS, use of such other names results in a warning. In VMS
9601 implementations, these names are accepted silently.
9606 @strong{78}. The meaning of link names. See B.1(36).
9609 Link names are the actual names used by the linker.
9614 @strong{79}. The manner of choosing link names when neither the link
9615 name nor the address of an imported or exported entity is specified. See
9619 The default linker name is that which would be assigned by the relevant
9620 external language, interpreting the Ada name as being in all lower case
9626 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
9629 The string passed to @code{Linker_Options} is presented uninterpreted as
9630 an argument to the link command, unless it contains ASCII.NUL characters.
9631 NUL characters if they appear act as argument separators, so for example
9633 @smallexample @c ada
9634 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9638 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9639 linker. The order of linker options is preserved for a given unit. The final
9640 list of options passed to the linker is in reverse order of the elaboration
9641 order. For example, linker options for a body always appear before the options
9642 from the corresponding package spec.
9647 @strong{81}. The contents of the visible part of package
9648 @code{Interfaces} and its language-defined descendants. See B.2(1).
9651 See files with prefix @file{i-} in the distributed library.
9656 @strong{82}. Implementation-defined children of package
9657 @code{Interfaces}. The contents of the visible part of package
9658 @code{Interfaces}. See B.2(11).
9661 See files with prefix @file{i-} in the distributed library.
9666 @strong{83}. The types @code{Floating}, @code{Long_Floating},
9667 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9668 @code{COBOL_Character}; and the initialization of the variables
9669 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9670 @code{Interfaces.COBOL}. See B.4(50).
9677 (Floating) Long_Float
9682 @item Decimal_Element
9684 @item COBOL_Character
9689 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9694 @strong{84}. Support for access to machine instructions. See C.1(1).
9697 See documentation in file @file{s-maccod.ads} in the distributed library.
9702 @strong{85}. Implementation-defined aspects of access to machine
9703 operations. See C.1(9).
9706 See documentation in file @file{s-maccod.ads} in the distributed library.
9711 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
9714 Interrupts are mapped to signals or conditions as appropriate. See
9716 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9717 on the interrupts supported on a particular target.
9722 @strong{87}. Implementation-defined aspects of pre-elaboration. See
9726 GNAT does not permit a partition to be restarted without reloading,
9727 except under control of the debugger.
9732 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
9735 Pragma @code{Discard_Names} causes names of enumeration literals to
9736 be suppressed. In the presence of this pragma, the Image attribute
9737 provides the image of the Pos of the literal, and Value accepts
9743 @strong{89}. The result of the @code{Task_Identification.Image}
9744 attribute. See C.7.1(7).
9747 The result of this attribute is a string that identifies
9748 the object or component that denotes a given task. If a variable @code{Var}
9749 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9751 is the hexadecimal representation of the virtual address of the corresponding
9752 task control block. If the variable is an array of tasks, the image of each
9753 task will have the form of an indexed component indicating the position of a
9754 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9755 component of a record, the image of the task will have the form of a selected
9756 component. These rules are fully recursive, so that the image of a task that
9757 is a subcomponent of a composite object corresponds to the expression that
9758 designates this task.
9760 If a task is created by an allocator, its image depends on the context. If the
9761 allocator is part of an object declaration, the rules described above are used
9762 to construct its image, and this image is not affected by subsequent
9763 assignments. If the allocator appears within an expression, the image
9764 includes only the name of the task type.
9766 If the configuration pragma Discard_Names is present, or if the restriction
9767 No_Implicit_Heap_Allocation is in effect, the image reduces to
9768 the numeric suffix, that is to say the hexadecimal representation of the
9769 virtual address of the control block of the task.
9773 @strong{90}. The value of @code{Current_Task} when in a protected entry
9774 or interrupt handler. See C.7.1(17).
9777 Protected entries or interrupt handlers can be executed by any
9778 convenient thread, so the value of @code{Current_Task} is undefined.
9783 @strong{91}. The effect of calling @code{Current_Task} from an entry
9784 body or interrupt handler. See C.7.1(19).
9787 The effect of calling @code{Current_Task} from an entry body or
9788 interrupt handler is to return the identification of the task currently
9794 @strong{92}. Implementation-defined aspects of
9795 @code{Task_Attributes}. See C.7.2(19).
9798 There are no implementation-defined aspects of @code{Task_Attributes}.
9803 @strong{93}. Values of all @code{Metrics}. See D(2).
9806 The metrics information for GNAT depends on the performance of the
9807 underlying operating system. The sources of the run-time for tasking
9808 implementation, together with the output from @option{-gnatG} can be
9809 used to determine the exact sequence of operating systems calls made
9810 to implement various tasking constructs. Together with appropriate
9811 information on the performance of the underlying operating system,
9812 on the exact target in use, this information can be used to determine
9813 the required metrics.
9818 @strong{94}. The declarations of @code{Any_Priority} and
9819 @code{Priority}. See D.1(11).
9822 See declarations in file @file{system.ads}.
9827 @strong{95}. Implementation-defined execution resources. See D.1(15).
9830 There are no implementation-defined execution resources.
9835 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
9836 access to a protected object keeps its processor busy. See D.2.1(3).
9839 On a multi-processor, a task that is waiting for access to a protected
9840 object does not keep its processor busy.
9845 @strong{97}. The affect of implementation defined execution resources
9846 on task dispatching. See D.2.1(9).
9851 Tasks map to IRIX threads, and the dispatching policy is as defined by
9852 the IRIX implementation of threads.
9854 Tasks map to threads in the threads package used by GNAT@. Where possible
9855 and appropriate, these threads correspond to native threads of the
9856 underlying operating system.
9861 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9862 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9865 There are no implementation-defined policy-identifiers allowed in this
9871 @strong{99}. Implementation-defined aspects of priority inversion. See
9875 Execution of a task cannot be preempted by the implementation processing
9876 of delay expirations for lower priority tasks.
9881 @strong{100}. Implementation defined task dispatching. See D.2.2(18).
9886 Tasks map to IRIX threads, and the dispatching policy is as defined by
9887 the IRIX implementation of threads.
9889 The policy is the same as that of the underlying threads implementation.
9894 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
9895 in a pragma @code{Locking_Policy}. See D.3(4).
9898 The only implementation defined policy permitted in GNAT is
9899 @code{Inheritance_Locking}. On targets that support this policy, locking
9900 is implemented by inheritance, i.e.@: the task owning the lock operates
9901 at a priority equal to the highest priority of any task currently
9902 requesting the lock.
9907 @strong{102}. Default ceiling priorities. See D.3(10).
9910 The ceiling priority of protected objects of the type
9911 @code{System.Interrupt_Priority'Last} as described in the Ada
9912 Reference Manual D.3(10),
9917 @strong{103}. The ceiling of any protected object used internally by
9918 the implementation. See D.3(16).
9921 The ceiling priority of internal protected objects is
9922 @code{System.Priority'Last}.
9927 @strong{104}. Implementation-defined queuing policies. See D.4(1).
9930 There are no implementation-defined queuing policies.
9935 @strong{105}. On a multiprocessor, any conditions that cause the
9936 completion of an aborted construct to be delayed later than what is
9937 specified for a single processor. See D.6(3).
9940 The semantics for abort on a multi-processor is the same as on a single
9941 processor, there are no further delays.
9946 @strong{106}. Any operations that implicitly require heap storage
9947 allocation. See D.7(8).
9950 The only operation that implicitly requires heap storage allocation is
9956 @strong{107}. Implementation-defined aspects of pragma
9957 @code{Restrictions}. See D.7(20).
9960 There are no such implementation-defined aspects.
9965 @strong{108}. Implementation-defined aspects of package
9966 @code{Real_Time}. See D.8(17).
9969 There are no implementation defined aspects of package @code{Real_Time}.
9974 @strong{109}. Implementation-defined aspects of
9975 @code{delay_statements}. See D.9(8).
9978 Any difference greater than one microsecond will cause the task to be
9979 delayed (see D.9(7)).
9984 @strong{110}. The upper bound on the duration of interrupt blocking
9985 caused by the implementation. See D.12(5).
9988 The upper bound is determined by the underlying operating system. In
9989 no cases is it more than 10 milliseconds.
9994 @strong{111}. The means for creating and executing distributed
9998 The GLADE package provides a utility GNATDIST for creating and executing
9999 distributed programs. See the GLADE reference manual for further details.
10004 @strong{112}. Any events that can result in a partition becoming
10005 inaccessible. See E.1(7).
10008 See the GLADE reference manual for full details on such events.
10013 @strong{113}. The scheduling policies, treatment of priorities, and
10014 management of shared resources between partitions in certain cases. See
10018 See the GLADE reference manual for full details on these aspects of
10019 multi-partition execution.
10024 @strong{114}. Events that cause the version of a compilation unit to
10025 change. See E.3(5).
10028 Editing the source file of a compilation unit, or the source files of
10029 any units on which it is dependent in a significant way cause the version
10030 to change. No other actions cause the version number to change. All changes
10031 are significant except those which affect only layout, capitalization or
10037 @strong{115}. Whether the execution of the remote subprogram is
10038 immediately aborted as a result of cancellation. See E.4(13).
10041 See the GLADE reference manual for details on the effect of abort in
10042 a distributed application.
10047 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
10050 See the GLADE reference manual for a full description of all implementation
10051 defined aspects of the PCS@.
10056 @strong{117}. Implementation-defined interfaces in the PCS@. See
10060 See the GLADE reference manual for a full description of all
10061 implementation defined interfaces.
10066 @strong{118}. The values of named numbers in the package
10067 @code{Decimal}. See F.2(7).
10079 @item Max_Decimal_Digits
10086 @strong{119}. The value of @code{Max_Picture_Length} in the package
10087 @code{Text_IO.Editing}. See F.3.3(16).
10095 @strong{120}. The value of @code{Max_Picture_Length} in the package
10096 @code{Wide_Text_IO.Editing}. See F.3.4(5).
10104 @strong{121}. The accuracy actually achieved by the complex elementary
10105 functions and by other complex arithmetic operations. See G.1(1).
10108 Standard library functions are used for the complex arithmetic
10109 operations. Only fast math mode is currently supported.
10114 @strong{122}. The sign of a zero result (or a component thereof) from
10115 any operator or function in @code{Numerics.Generic_Complex_Types}, when
10116 @code{Real'Signed_Zeros} is True. See G.1.1(53).
10119 The signs of zero values are as recommended by the relevant
10120 implementation advice.
10125 @strong{123}. The sign of a zero result (or a component thereof) from
10126 any operator or function in
10127 @code{Numerics.Generic_Complex_Elementary_Functions}, when
10128 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
10131 The signs of zero values are as recommended by the relevant
10132 implementation advice.
10137 @strong{124}. Whether the strict mode or the relaxed mode is the
10138 default. See G.2(2).
10141 The strict mode is the default. There is no separate relaxed mode. GNAT
10142 provides a highly efficient implementation of strict mode.
10147 @strong{125}. The result interval in certain cases of fixed-to-float
10148 conversion. See G.2.1(10).
10151 For cases where the result interval is implementation dependent, the
10152 accuracy is that provided by performing all operations in 64-bit IEEE
10153 floating-point format.
10158 @strong{126}. The result of a floating point arithmetic operation in
10159 overflow situations, when the @code{Machine_Overflows} attribute of the
10160 result type is @code{False}. See G.2.1(13).
10163 Infinite and NaN values are produced as dictated by the IEEE
10164 floating-point standard.
10166 Note that on machines that are not fully compliant with the IEEE
10167 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
10168 must be used for achieving IEEE confirming behavior (although at the cost
10169 of a significant performance penalty), so infinite and NaN values are
10170 properly generated.
10175 @strong{127}. The result interval for division (or exponentiation by a
10176 negative exponent), when the floating point hardware implements division
10177 as multiplication by a reciprocal. See G.2.1(16).
10180 Not relevant, division is IEEE exact.
10185 @strong{128}. The definition of close result set, which determines the
10186 accuracy of certain fixed point multiplications and divisions. See
10190 Operations in the close result set are performed using IEEE long format
10191 floating-point arithmetic. The input operands are converted to
10192 floating-point, the operation is done in floating-point, and the result
10193 is converted to the target type.
10198 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
10199 point multiplication or division for which the result shall be in the
10200 perfect result set. See G.2.3(22).
10203 The result is only defined to be in the perfect result set if the result
10204 can be computed by a single scaling operation involving a scale factor
10205 representable in 64-bits.
10210 @strong{130}. The result of a fixed point arithmetic operation in
10211 overflow situations, when the @code{Machine_Overflows} attribute of the
10212 result type is @code{False}. See G.2.3(27).
10215 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
10221 @strong{131}. The result of an elementary function reference in
10222 overflow situations, when the @code{Machine_Overflows} attribute of the
10223 result type is @code{False}. See G.2.4(4).
10226 IEEE infinite and Nan values are produced as appropriate.
10231 @strong{132}. The value of the angle threshold, within which certain
10232 elementary functions, complex arithmetic operations, and complex
10233 elementary functions yield results conforming to a maximum relative
10234 error bound. See G.2.4(10).
10237 Information on this subject is not yet available.
10242 @strong{133}. The accuracy of certain elementary functions for
10243 parameters beyond the angle threshold. See G.2.4(10).
10246 Information on this subject is not yet available.
10251 @strong{134}. The result of a complex arithmetic operation or complex
10252 elementary function reference in overflow situations, when the
10253 @code{Machine_Overflows} attribute of the corresponding real type is
10254 @code{False}. See G.2.6(5).
10257 IEEE infinite and Nan values are produced as appropriate.
10262 @strong{135}. The accuracy of certain complex arithmetic operations and
10263 certain complex elementary functions for parameters (or components
10264 thereof) beyond the angle threshold. See G.2.6(8).
10267 Information on those subjects is not yet available.
10272 @strong{136}. Information regarding bounded errors and erroneous
10273 execution. See H.2(1).
10276 Information on this subject is not yet available.
10281 @strong{137}. Implementation-defined aspects of pragma
10282 @code{Inspection_Point}. See H.3.2(8).
10285 Pragma @code{Inspection_Point} ensures that the variable is live and can
10286 be examined by the debugger at the inspection point.
10291 @strong{138}. Implementation-defined aspects of pragma
10292 @code{Restrictions}. See H.4(25).
10295 There are no implementation-defined aspects of pragma @code{Restrictions}. The
10296 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
10297 generated code. Checks must suppressed by use of pragma @code{Suppress}.
10302 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
10306 There are no restrictions on pragma @code{Restrictions}.
10308 @node Intrinsic Subprograms
10309 @chapter Intrinsic Subprograms
10310 @cindex Intrinsic Subprograms
10313 * Intrinsic Operators::
10314 * Enclosing_Entity::
10315 * Exception_Information::
10316 * Exception_Message::
10324 * Shift_Right_Arithmetic::
10325 * Source_Location::
10329 GNAT allows a user application program to write the declaration:
10331 @smallexample @c ada
10332 pragma Import (Intrinsic, name);
10336 providing that the name corresponds to one of the implemented intrinsic
10337 subprograms in GNAT, and that the parameter profile of the referenced
10338 subprogram meets the requirements. This chapter describes the set of
10339 implemented intrinsic subprograms, and the requirements on parameter profiles.
10340 Note that no body is supplied; as with other uses of pragma Import, the
10341 body is supplied elsewhere (in this case by the compiler itself). Note
10342 that any use of this feature is potentially non-portable, since the
10343 Ada standard does not require Ada compilers to implement this feature.
10345 @node Intrinsic Operators
10346 @section Intrinsic Operators
10347 @cindex Intrinsic operator
10350 All the predefined numeric operators in package Standard
10351 in @code{pragma Import (Intrinsic,..)}
10352 declarations. In the binary operator case, the operands must have the same
10353 size. The operand or operands must also be appropriate for
10354 the operator. For example, for addition, the operands must
10355 both be floating-point or both be fixed-point, and the
10356 right operand for @code{"**"} must have a root type of
10357 @code{Standard.Integer'Base}.
10358 You can use an intrinsic operator declaration as in the following example:
10360 @smallexample @c ada
10361 type Int1 is new Integer;
10362 type Int2 is new Integer;
10364 function "+" (X1 : Int1; X2 : Int2) return Int1;
10365 function "+" (X1 : Int1; X2 : Int2) return Int2;
10366 pragma Import (Intrinsic, "+");
10370 This declaration would permit ``mixed mode'' arithmetic on items
10371 of the differing types @code{Int1} and @code{Int2}.
10372 It is also possible to specify such operators for private types, if the
10373 full views are appropriate arithmetic types.
10375 @node Enclosing_Entity
10376 @section Enclosing_Entity
10377 @cindex Enclosing_Entity
10379 This intrinsic subprogram is used in the implementation of the
10380 library routine @code{GNAT.Source_Info}. The only useful use of the
10381 intrinsic import in this case is the one in this unit, so an
10382 application program should simply call the function
10383 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
10384 the current subprogram, package, task, entry, or protected subprogram.
10386 @node Exception_Information
10387 @section Exception_Information
10388 @cindex Exception_Information'
10390 This intrinsic subprogram is used in the implementation of the
10391 library routine @code{GNAT.Current_Exception}. The only useful
10392 use of the intrinsic import in this case is the one in this unit,
10393 so an application program should simply call the function
10394 @code{GNAT.Current_Exception.Exception_Information} to obtain
10395 the exception information associated with the current exception.
10397 @node Exception_Message
10398 @section Exception_Message
10399 @cindex Exception_Message
10401 This intrinsic subprogram is used in the implementation of the
10402 library routine @code{GNAT.Current_Exception}. The only useful
10403 use of the intrinsic import in this case is the one in this unit,
10404 so an application program should simply call the function
10405 @code{GNAT.Current_Exception.Exception_Message} to obtain
10406 the message associated with the current exception.
10408 @node Exception_Name
10409 @section Exception_Name
10410 @cindex Exception_Name
10412 This intrinsic subprogram is used in the implementation of the
10413 library routine @code{GNAT.Current_Exception}. The only useful
10414 use of the intrinsic import in this case is the one in this unit,
10415 so an application program should simply call the function
10416 @code{GNAT.Current_Exception.Exception_Name} to obtain
10417 the name of the current exception.
10423 This intrinsic subprogram is used in the implementation of the
10424 library routine @code{GNAT.Source_Info}. The only useful use of the
10425 intrinsic import in this case is the one in this unit, so an
10426 application program should simply call the function
10427 @code{GNAT.Source_Info.File} to obtain the name of the current
10434 This intrinsic subprogram is used in the implementation of the
10435 library routine @code{GNAT.Source_Info}. The only useful use of the
10436 intrinsic import in this case is the one in this unit, so an
10437 application program should simply call the function
10438 @code{GNAT.Source_Info.Line} to obtain the number of the current
10442 @section Rotate_Left
10443 @cindex Rotate_Left
10445 In standard Ada, the @code{Rotate_Left} function is available only
10446 for the predefined modular types in package @code{Interfaces}. However, in
10447 GNAT it is possible to define a Rotate_Left function for a user
10448 defined modular type or any signed integer type as in this example:
10450 @smallexample @c ada
10451 function Shift_Left
10452 (Value : My_Modular_Type;
10454 return My_Modular_Type;
10458 The requirements are that the profile be exactly as in the example
10459 above. The only modifications allowed are in the formal parameter
10460 names, and in the type of @code{Value} and the return type, which
10461 must be the same, and must be either a signed integer type, or
10462 a modular integer type with a binary modulus, and the size must
10463 be 8. 16, 32 or 64 bits.
10466 @section Rotate_Right
10467 @cindex Rotate_Right
10469 A @code{Rotate_Right} function can be defined for any user defined
10470 binary modular integer type, or signed integer type, as described
10471 above for @code{Rotate_Left}.
10474 @section Shift_Left
10477 A @code{Shift_Left} function can be defined for any user defined
10478 binary modular integer type, or signed integer type, as described
10479 above for @code{Rotate_Left}.
10482 @section Shift_Right
10483 @cindex Shift_Right
10485 A @code{Shift_Right} function can be defined for any user defined
10486 binary modular integer type, or signed integer type, as described
10487 above for @code{Rotate_Left}.
10489 @node Shift_Right_Arithmetic
10490 @section Shift_Right_Arithmetic
10491 @cindex Shift_Right_Arithmetic
10493 A @code{Shift_Right_Arithmetic} function can be defined for any user
10494 defined binary modular integer type, or signed integer type, as described
10495 above for @code{Rotate_Left}.
10497 @node Source_Location
10498 @section Source_Location
10499 @cindex Source_Location
10501 This intrinsic subprogram is used in the implementation of the
10502 library routine @code{GNAT.Source_Info}. The only useful use of the
10503 intrinsic import in this case is the one in this unit, so an
10504 application program should simply call the function
10505 @code{GNAT.Source_Info.Source_Location} to obtain the current
10506 source file location.
10508 @node Representation Clauses and Pragmas
10509 @chapter Representation Clauses and Pragmas
10510 @cindex Representation Clauses
10513 * Alignment Clauses::
10515 * Storage_Size Clauses::
10516 * Size of Variant Record Objects::
10517 * Biased Representation ::
10518 * Value_Size and Object_Size Clauses::
10519 * Component_Size Clauses::
10520 * Bit_Order Clauses::
10521 * Effect of Bit_Order on Byte Ordering::
10522 * Pragma Pack for Arrays::
10523 * Pragma Pack for Records::
10524 * Record Representation Clauses::
10525 * Enumeration Clauses::
10526 * Address Clauses::
10527 * Effect of Convention on Representation::
10528 * Determining the Representations chosen by GNAT::
10532 @cindex Representation Clause
10533 @cindex Representation Pragma
10534 @cindex Pragma, representation
10535 This section describes the representation clauses accepted by GNAT, and
10536 their effect on the representation of corresponding data objects.
10538 GNAT fully implements Annex C (Systems Programming). This means that all
10539 the implementation advice sections in chapter 13 are fully implemented.
10540 However, these sections only require a minimal level of support for
10541 representation clauses. GNAT provides much more extensive capabilities,
10542 and this section describes the additional capabilities provided.
10544 @node Alignment Clauses
10545 @section Alignment Clauses
10546 @cindex Alignment Clause
10549 GNAT requires that all alignment clauses specify a power of 2, and all
10550 default alignments are always a power of 2. The default alignment
10551 values are as follows:
10554 @item @emph{Primitive Types}.
10555 For primitive types, the alignment is the minimum of the actual size of
10556 objects of the type divided by @code{Storage_Unit},
10557 and the maximum alignment supported by the target.
10558 (This maximum alignment is given by the GNAT-specific attribute
10559 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
10560 @cindex @code{Maximum_Alignment} attribute
10561 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
10562 default alignment will be 8 on any target that supports alignments
10563 this large, but on some targets, the maximum alignment may be smaller
10564 than 8, in which case objects of type @code{Long_Float} will be maximally
10567 @item @emph{Arrays}.
10568 For arrays, the alignment is equal to the alignment of the component type
10569 for the normal case where no packing or component size is given. If the
10570 array is packed, and the packing is effective (see separate section on
10571 packed arrays), then the alignment will be one for long packed arrays,
10572 or arrays whose length is not known at compile time. For short packed
10573 arrays, which are handled internally as modular types, the alignment
10574 will be as described for primitive types, e.g.@: a packed array of length
10575 31 bits will have an object size of four bytes, and an alignment of 4.
10577 @item @emph{Records}.
10578 For the normal non-packed case, the alignment of a record is equal to
10579 the maximum alignment of any of its components. For tagged records, this
10580 includes the implicit access type used for the tag. If a pragma @code{Pack}
10581 is used and all components are packable (see separate section on pragma
10582 @code{Pack}), then the resulting alignment is 1, unless the layout of the
10583 record makes it profitable to increase it.
10585 A special case is when:
10588 the size of the record is given explicitly, or a
10589 full record representation clause is given, and
10591 the size of the record is 2, 4, or 8 bytes.
10594 In this case, an alignment is chosen to match the
10595 size of the record. For example, if we have:
10597 @smallexample @c ada
10598 type Small is record
10601 for Small'Size use 16;
10605 then the default alignment of the record type @code{Small} is 2, not 1. This
10606 leads to more efficient code when the record is treated as a unit, and also
10607 allows the type to specified as @code{Atomic} on architectures requiring
10613 An alignment clause may specify a larger alignment than the default value
10614 up to some maximum value dependent on the target (obtainable by using the
10615 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10616 a smaller alignment than the default value for enumeration, integer and
10617 fixed point types, as well as for record types, for example
10619 @smallexample @c ada
10624 for V'alignment use 1;
10628 @cindex Alignment, default
10629 The default alignment for the type @code{V} is 4, as a result of the
10630 Integer field in the record, but it is permissible, as shown, to
10631 override the default alignment of the record with a smaller value.
10634 @section Size Clauses
10635 @cindex Size Clause
10638 The default size for a type @code{T} is obtainable through the
10639 language-defined attribute @code{T'Size} and also through the
10640 equivalent GNAT-defined attribute @code{T'Value_Size}.
10641 For objects of type @code{T}, GNAT will generally increase the type size
10642 so that the object size (obtainable through the GNAT-defined attribute
10643 @code{T'Object_Size})
10644 is a multiple of @code{T'Alignment * Storage_Unit}.
10647 @smallexample @c ada
10648 type Smallint is range 1 .. 6;
10657 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10658 as specified by the RM rules,
10659 but objects of this type will have a size of 8
10660 (@code{Smallint'Object_Size} = 8),
10661 since objects by default occupy an integral number
10662 of storage units. On some targets, notably older
10663 versions of the Digital Alpha, the size of stand
10664 alone objects of this type may be 32, reflecting
10665 the inability of the hardware to do byte load/stores.
10667 Similarly, the size of type @code{Rec} is 40 bits
10668 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10669 the alignment is 4, so objects of this type will have
10670 their size increased to 64 bits so that it is a multiple
10671 of the alignment (in bits). This decision is
10672 in accordance with the specific Implementation Advice in RM 13.3(43):
10675 A @code{Size} clause should be supported for an object if the specified
10676 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10677 to a size in storage elements that is a multiple of the object's
10678 @code{Alignment} (if the @code{Alignment} is nonzero).
10682 An explicit size clause may be used to override the default size by
10683 increasing it. For example, if we have:
10685 @smallexample @c ada
10686 type My_Boolean is new Boolean;
10687 for My_Boolean'Size use 32;
10691 then values of this type will always be 32 bits long. In the case of
10692 discrete types, the size can be increased up to 64 bits, with the effect
10693 that the entire specified field is used to hold the value, sign- or
10694 zero-extended as appropriate. If more than 64 bits is specified, then
10695 padding space is allocated after the value, and a warning is issued that
10696 there are unused bits.
10698 Similarly the size of records and arrays may be increased, and the effect
10699 is to add padding bits after the value. This also causes a warning message
10702 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
10703 Size in bits, this corresponds to an object of size 256 megabytes (minus
10704 one). This limitation is true on all targets. The reason for this
10705 limitation is that it improves the quality of the code in many cases
10706 if it is known that a Size value can be accommodated in an object of
10709 @node Storage_Size Clauses
10710 @section Storage_Size Clauses
10711 @cindex Storage_Size Clause
10714 For tasks, the @code{Storage_Size} clause specifies the amount of space
10715 to be allocated for the task stack. This cannot be extended, and if the
10716 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10717 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
10718 or a @code{Storage_Size} pragma in the task definition to set the
10719 appropriate required size. A useful technique is to include in every
10720 task definition a pragma of the form:
10722 @smallexample @c ada
10723 pragma Storage_Size (Default_Stack_Size);
10727 Then @code{Default_Stack_Size} can be defined in a global package, and
10728 modified as required. Any tasks requiring stack sizes different from the
10729 default can have an appropriate alternative reference in the pragma.
10731 You can also use the @option{-d} binder switch to modify the default stack
10734 For access types, the @code{Storage_Size} clause specifies the maximum
10735 space available for allocation of objects of the type. If this space is
10736 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10737 In the case where the access type is declared local to a subprogram, the
10738 use of a @code{Storage_Size} clause triggers automatic use of a special
10739 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10740 space for the pool is automatically reclaimed on exit from the scope in
10741 which the type is declared.
10743 A special case recognized by the compiler is the specification of a
10744 @code{Storage_Size} of zero for an access type. This means that no
10745 items can be allocated from the pool, and this is recognized at compile
10746 time, and all the overhead normally associated with maintaining a fixed
10747 size storage pool is eliminated. Consider the following example:
10749 @smallexample @c ada
10751 type R is array (Natural) of Character;
10752 type P is access all R;
10753 for P'Storage_Size use 0;
10754 -- Above access type intended only for interfacing purposes
10758 procedure g (m : P);
10759 pragma Import (C, g);
10770 As indicated in this example, these dummy storage pools are often useful in
10771 connection with interfacing where no object will ever be allocated. If you
10772 compile the above example, you get the warning:
10775 p.adb:16:09: warning: allocation from empty storage pool
10776 p.adb:16:09: warning: Storage_Error will be raised at run time
10780 Of course in practice, there will not be any explicit allocators in the
10781 case of such an access declaration.
10783 @node Size of Variant Record Objects
10784 @section Size of Variant Record Objects
10785 @cindex Size, variant record objects
10786 @cindex Variant record objects, size
10789 In the case of variant record objects, there is a question whether Size gives
10790 information about a particular variant, or the maximum size required
10791 for any variant. Consider the following program
10793 @smallexample @c ada
10794 with Text_IO; use Text_IO;
10796 type R1 (A : Boolean := False) is record
10798 when True => X : Character;
10799 when False => null;
10807 Put_Line (Integer'Image (V1'Size));
10808 Put_Line (Integer'Image (V2'Size));
10813 Here we are dealing with a variant record, where the True variant
10814 requires 16 bits, and the False variant requires 8 bits.
10815 In the above example, both V1 and V2 contain the False variant,
10816 which is only 8 bits long. However, the result of running the
10825 The reason for the difference here is that the discriminant value of
10826 V1 is fixed, and will always be False. It is not possible to assign
10827 a True variant value to V1, therefore 8 bits is sufficient. On the
10828 other hand, in the case of V2, the initial discriminant value is
10829 False (from the default), but it is possible to assign a True
10830 variant value to V2, therefore 16 bits must be allocated for V2
10831 in the general case, even fewer bits may be needed at any particular
10832 point during the program execution.
10834 As can be seen from the output of this program, the @code{'Size}
10835 attribute applied to such an object in GNAT gives the actual allocated
10836 size of the variable, which is the largest size of any of the variants.
10837 The Ada Reference Manual is not completely clear on what choice should
10838 be made here, but the GNAT behavior seems most consistent with the
10839 language in the RM@.
10841 In some cases, it may be desirable to obtain the size of the current
10842 variant, rather than the size of the largest variant. This can be
10843 achieved in GNAT by making use of the fact that in the case of a
10844 subprogram parameter, GNAT does indeed return the size of the current
10845 variant (because a subprogram has no way of knowing how much space
10846 is actually allocated for the actual).
10848 Consider the following modified version of the above program:
10850 @smallexample @c ada
10851 with Text_IO; use Text_IO;
10853 type R1 (A : Boolean := False) is record
10855 when True => X : Character;
10856 when False => null;
10862 function Size (V : R1) return Integer is
10868 Put_Line (Integer'Image (V2'Size));
10869 Put_Line (Integer'IMage (Size (V2)));
10871 Put_Line (Integer'Image (V2'Size));
10872 Put_Line (Integer'IMage (Size (V2)));
10877 The output from this program is
10887 Here we see that while the @code{'Size} attribute always returns
10888 the maximum size, regardless of the current variant value, the
10889 @code{Size} function does indeed return the size of the current
10892 @node Biased Representation
10893 @section Biased Representation
10894 @cindex Size for biased representation
10895 @cindex Biased representation
10898 In the case of scalars with a range starting at other than zero, it is
10899 possible in some cases to specify a size smaller than the default minimum
10900 value, and in such cases, GNAT uses an unsigned biased representation,
10901 in which zero is used to represent the lower bound, and successive values
10902 represent successive values of the type.
10904 For example, suppose we have the declaration:
10906 @smallexample @c ada
10907 type Small is range -7 .. -4;
10908 for Small'Size use 2;
10912 Although the default size of type @code{Small} is 4, the @code{Size}
10913 clause is accepted by GNAT and results in the following representation
10917 -7 is represented as 2#00#
10918 -6 is represented as 2#01#
10919 -5 is represented as 2#10#
10920 -4 is represented as 2#11#
10924 Biased representation is only used if the specified @code{Size} clause
10925 cannot be accepted in any other manner. These reduced sizes that force
10926 biased representation can be used for all discrete types except for
10927 enumeration types for which a representation clause is given.
10929 @node Value_Size and Object_Size Clauses
10930 @section Value_Size and Object_Size Clauses
10932 @findex Object_Size
10933 @cindex Size, of objects
10936 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10937 number of bits required to hold values of type @code{T}.
10938 Although this interpretation was allowed in Ada 83, it was not required,
10939 and this requirement in practice can cause some significant difficulties.
10940 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10941 However, in Ada 95 and Ada 2005,
10942 @code{Natural'Size} is
10943 typically 31. This means that code may change in behavior when moving
10944 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10946 @smallexample @c ada
10947 type Rec is record;
10953 at 0 range 0 .. Natural'Size - 1;
10954 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10959 In the above code, since the typical size of @code{Natural} objects
10960 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10961 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10962 there are cases where the fact that the object size can exceed the
10963 size of the type causes surprises.
10965 To help get around this problem GNAT provides two implementation
10966 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10967 applied to a type, these attributes yield the size of the type
10968 (corresponding to the RM defined size attribute), and the size of
10969 objects of the type respectively.
10971 The @code{Object_Size} is used for determining the default size of
10972 objects and components. This size value can be referred to using the
10973 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10974 the basis of the determination of the size. The backend is free to
10975 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10976 character might be stored in 32 bits on a machine with no efficient
10977 byte access instructions such as the Alpha.
10979 The default rules for the value of @code{Object_Size} for
10980 discrete types are as follows:
10984 The @code{Object_Size} for base subtypes reflect the natural hardware
10985 size in bits (run the compiler with @option{-gnatS} to find those values
10986 for numeric types). Enumeration types and fixed-point base subtypes have
10987 8, 16, 32 or 64 bits for this size, depending on the range of values
10991 The @code{Object_Size} of a subtype is the same as the
10992 @code{Object_Size} of
10993 the type from which it is obtained.
10996 The @code{Object_Size} of a derived base type is copied from the parent
10997 base type, and the @code{Object_Size} of a derived first subtype is copied
10998 from the parent first subtype.
11002 The @code{Value_Size} attribute
11003 is the (minimum) number of bits required to store a value
11005 This value is used to determine how tightly to pack
11006 records or arrays with components of this type, and also affects
11007 the semantics of unchecked conversion (unchecked conversions where
11008 the @code{Value_Size} values differ generate a warning, and are potentially
11011 The default rules for the value of @code{Value_Size} are as follows:
11015 The @code{Value_Size} for a base subtype is the minimum number of bits
11016 required to store all values of the type (including the sign bit
11017 only if negative values are possible).
11020 If a subtype statically matches the first subtype of a given type, then it has
11021 by default the same @code{Value_Size} as the first subtype. This is a
11022 consequence of RM 13.1(14) (``if two subtypes statically match,
11023 then their subtype-specific aspects are the same''.)
11026 All other subtypes have a @code{Value_Size} corresponding to the minimum
11027 number of bits required to store all values of the subtype. For
11028 dynamic bounds, it is assumed that the value can range down or up
11029 to the corresponding bound of the ancestor
11033 The RM defined attribute @code{Size} corresponds to the
11034 @code{Value_Size} attribute.
11036 The @code{Size} attribute may be defined for a first-named subtype. This sets
11037 the @code{Value_Size} of
11038 the first-named subtype to the given value, and the
11039 @code{Object_Size} of this first-named subtype to the given value padded up
11040 to an appropriate boundary. It is a consequence of the default rules
11041 above that this @code{Object_Size} will apply to all further subtypes. On the
11042 other hand, @code{Value_Size} is affected only for the first subtype, any
11043 dynamic subtypes obtained from it directly, and any statically matching
11044 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
11046 @code{Value_Size} and
11047 @code{Object_Size} may be explicitly set for any subtype using
11048 an attribute definition clause. Note that the use of these attributes
11049 can cause the RM 13.1(14) rule to be violated. If two access types
11050 reference aliased objects whose subtypes have differing @code{Object_Size}
11051 values as a result of explicit attribute definition clauses, then it
11052 is erroneous to convert from one access subtype to the other.
11054 At the implementation level, Esize stores the Object_Size and the
11055 RM_Size field stores the @code{Value_Size} (and hence the value of the
11056 @code{Size} attribute,
11057 which, as noted above, is equivalent to @code{Value_Size}).
11059 To get a feel for the difference, consider the following examples (note
11060 that in each case the base is @code{Short_Short_Integer} with a size of 8):
11063 Object_Size Value_Size
11065 type x1 is range 0 .. 5; 8 3
11067 type x2 is range 0 .. 5;
11068 for x2'size use 12; 16 12
11070 subtype x3 is x2 range 0 .. 3; 16 2
11072 subtype x4 is x2'base range 0 .. 10; 8 4
11074 subtype x5 is x2 range 0 .. dynamic; 16 3*
11076 subtype x6 is x2'base range 0 .. dynamic; 8 3*
11081 Note: the entries marked ``3*'' are not actually specified by the Ada
11082 Reference Manual, but it seems in the spirit of the RM rules to allocate
11083 the minimum number of bits (here 3, given the range for @code{x2})
11084 known to be large enough to hold the given range of values.
11086 So far, so good, but GNAT has to obey the RM rules, so the question is
11087 under what conditions must the RM @code{Size} be used.
11088 The following is a list
11089 of the occasions on which the RM @code{Size} must be used:
11093 Component size for packed arrays or records
11096 Value of the attribute @code{Size} for a type
11099 Warning about sizes not matching for unchecked conversion
11103 For record types, the @code{Object_Size} is always a multiple of the
11104 alignment of the type (this is true for all types). In some cases the
11105 @code{Value_Size} can be smaller. Consider:
11115 On a typical 32-bit architecture, the X component will be four bytes, and
11116 require four-byte alignment, and the Y component will be one byte. In this
11117 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
11118 required to store a value of this type, and for example, it is permissible
11119 to have a component of type R in an outer array whose component size is
11120 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
11121 since it must be rounded up so that this value is a multiple of the
11122 alignment (4 bytes = 32 bits).
11125 For all other types, the @code{Object_Size}
11126 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
11127 Only @code{Size} may be specified for such types.
11129 @node Component_Size Clauses
11130 @section Component_Size Clauses
11131 @cindex Component_Size Clause
11134 Normally, the value specified in a component size clause must be consistent
11135 with the subtype of the array component with regard to size and alignment.
11136 In other words, the value specified must be at least equal to the size
11137 of this subtype, and must be a multiple of the alignment value.
11139 In addition, component size clauses are allowed which cause the array
11140 to be packed, by specifying a smaller value. A first case is for
11141 component size values in the range 1 through 63. The value specified
11142 must not be smaller than the Size of the subtype. GNAT will accurately
11143 honor all packing requests in this range. For example, if we have:
11145 @smallexample @c ada
11146 type r is array (1 .. 8) of Natural;
11147 for r'Component_Size use 31;
11151 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
11152 Of course access to the components of such an array is considerably
11153 less efficient than if the natural component size of 32 is used.
11154 A second case is when the subtype of the component is a record type
11155 padded because of its default alignment. For example, if we have:
11157 @smallexample @c ada
11164 type a is array (1 .. 8) of r;
11165 for a'Component_Size use 72;
11169 then the resulting array has a length of 72 bytes, instead of 96 bytes
11170 if the alignment of the record (4) was obeyed.
11172 Note that there is no point in giving both a component size clause
11173 and a pragma Pack for the same array type. if such duplicate
11174 clauses are given, the pragma Pack will be ignored.
11176 @node Bit_Order Clauses
11177 @section Bit_Order Clauses
11178 @cindex Bit_Order Clause
11179 @cindex bit ordering
11180 @cindex ordering, of bits
11183 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
11184 attribute. The specification may either correspond to the default bit
11185 order for the target, in which case the specification has no effect and
11186 places no additional restrictions, or it may be for the non-standard
11187 setting (that is the opposite of the default).
11189 In the case where the non-standard value is specified, the effect is
11190 to renumber bits within each byte, but the ordering of bytes is not
11191 affected. There are certain
11192 restrictions placed on component clauses as follows:
11196 @item Components fitting within a single storage unit.
11198 These are unrestricted, and the effect is merely to renumber bits. For
11199 example if we are on a little-endian machine with @code{Low_Order_First}
11200 being the default, then the following two declarations have exactly
11203 @smallexample @c ada
11206 B : Integer range 1 .. 120;
11210 A at 0 range 0 .. 0;
11211 B at 0 range 1 .. 7;
11216 B : Integer range 1 .. 120;
11219 for R2'Bit_Order use High_Order_First;
11222 A at 0 range 7 .. 7;
11223 B at 0 range 0 .. 6;
11228 The useful application here is to write the second declaration with the
11229 @code{Bit_Order} attribute definition clause, and know that it will be treated
11230 the same, regardless of whether the target is little-endian or big-endian.
11232 @item Components occupying an integral number of bytes.
11234 These are components that exactly fit in two or more bytes. Such component
11235 declarations are allowed, but have no effect, since it is important to realize
11236 that the @code{Bit_Order} specification does not affect the ordering of bytes.
11237 In particular, the following attempt at getting an endian-independent integer
11240 @smallexample @c ada
11245 for R2'Bit_Order use High_Order_First;
11248 A at 0 range 0 .. 31;
11253 This declaration will result in a little-endian integer on a
11254 little-endian machine, and a big-endian integer on a big-endian machine.
11255 If byte flipping is required for interoperability between big- and
11256 little-endian machines, this must be explicitly programmed. This capability
11257 is not provided by @code{Bit_Order}.
11259 @item Components that are positioned across byte boundaries
11261 but do not occupy an integral number of bytes. Given that bytes are not
11262 reordered, such fields would occupy a non-contiguous sequence of bits
11263 in memory, requiring non-trivial code to reassemble. They are for this
11264 reason not permitted, and any component clause specifying such a layout
11265 will be flagged as illegal by GNAT@.
11270 Since the misconception that Bit_Order automatically deals with all
11271 endian-related incompatibilities is a common one, the specification of
11272 a component field that is an integral number of bytes will always
11273 generate a warning. This warning may be suppressed using @code{pragma
11274 Warnings (Off)} if desired. The following section contains additional
11275 details regarding the issue of byte ordering.
11277 @node Effect of Bit_Order on Byte Ordering
11278 @section Effect of Bit_Order on Byte Ordering
11279 @cindex byte ordering
11280 @cindex ordering, of bytes
11283 In this section we will review the effect of the @code{Bit_Order} attribute
11284 definition clause on byte ordering. Briefly, it has no effect at all, but
11285 a detailed example will be helpful. Before giving this
11286 example, let us review the precise
11287 definition of the effect of defining @code{Bit_Order}. The effect of a
11288 non-standard bit order is described in section 15.5.3 of the Ada
11292 2 A bit ordering is a method of interpreting the meaning of
11293 the storage place attributes.
11297 To understand the precise definition of storage place attributes in
11298 this context, we visit section 13.5.1 of the manual:
11301 13 A record_representation_clause (without the mod_clause)
11302 specifies the layout. The storage place attributes (see 13.5.2)
11303 are taken from the values of the position, first_bit, and last_bit
11304 expressions after normalizing those values so that first_bit is
11305 less than Storage_Unit.
11309 The critical point here is that storage places are taken from
11310 the values after normalization, not before. So the @code{Bit_Order}
11311 interpretation applies to normalized values. The interpretation
11312 is described in the later part of the 15.5.3 paragraph:
11315 2 A bit ordering is a method of interpreting the meaning of
11316 the storage place attributes. High_Order_First (known in the
11317 vernacular as ``big endian'') means that the first bit of a
11318 storage element (bit 0) is the most significant bit (interpreting
11319 the sequence of bits that represent a component as an unsigned
11320 integer value). Low_Order_First (known in the vernacular as
11321 ``little endian'') means the opposite: the first bit is the
11326 Note that the numbering is with respect to the bits of a storage
11327 unit. In other words, the specification affects only the numbering
11328 of bits within a single storage unit.
11330 We can make the effect clearer by giving an example.
11332 Suppose that we have an external device which presents two bytes, the first
11333 byte presented, which is the first (low addressed byte) of the two byte
11334 record is called Master, and the second byte is called Slave.
11336 The left most (most significant bit is called Control for each byte, and
11337 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
11338 (least significant) bit.
11340 On a big-endian machine, we can write the following representation clause
11342 @smallexample @c ada
11343 type Data is record
11344 Master_Control : Bit;
11352 Slave_Control : Bit;
11362 for Data use record
11363 Master_Control at 0 range 0 .. 0;
11364 Master_V1 at 0 range 1 .. 1;
11365 Master_V2 at 0 range 2 .. 2;
11366 Master_V3 at 0 range 3 .. 3;
11367 Master_V4 at 0 range 4 .. 4;
11368 Master_V5 at 0 range 5 .. 5;
11369 Master_V6 at 0 range 6 .. 6;
11370 Master_V7 at 0 range 7 .. 7;
11371 Slave_Control at 1 range 0 .. 0;
11372 Slave_V1 at 1 range 1 .. 1;
11373 Slave_V2 at 1 range 2 .. 2;
11374 Slave_V3 at 1 range 3 .. 3;
11375 Slave_V4 at 1 range 4 .. 4;
11376 Slave_V5 at 1 range 5 .. 5;
11377 Slave_V6 at 1 range 6 .. 6;
11378 Slave_V7 at 1 range 7 .. 7;
11383 Now if we move this to a little endian machine, then the bit ordering within
11384 the byte is backwards, so we have to rewrite the record rep clause as:
11386 @smallexample @c ada
11387 for Data use record
11388 Master_Control at 0 range 7 .. 7;
11389 Master_V1 at 0 range 6 .. 6;
11390 Master_V2 at 0 range 5 .. 5;
11391 Master_V3 at 0 range 4 .. 4;
11392 Master_V4 at 0 range 3 .. 3;
11393 Master_V5 at 0 range 2 .. 2;
11394 Master_V6 at 0 range 1 .. 1;
11395 Master_V7 at 0 range 0 .. 0;
11396 Slave_Control at 1 range 7 .. 7;
11397 Slave_V1 at 1 range 6 .. 6;
11398 Slave_V2 at 1 range 5 .. 5;
11399 Slave_V3 at 1 range 4 .. 4;
11400 Slave_V4 at 1 range 3 .. 3;
11401 Slave_V5 at 1 range 2 .. 2;
11402 Slave_V6 at 1 range 1 .. 1;
11403 Slave_V7 at 1 range 0 .. 0;
11408 It is a nuisance to have to rewrite the clause, especially if
11409 the code has to be maintained on both machines. However,
11410 this is a case that we can handle with the
11411 @code{Bit_Order} attribute if it is implemented.
11412 Note that the implementation is not required on byte addressed
11413 machines, but it is indeed implemented in GNAT.
11414 This means that we can simply use the
11415 first record clause, together with the declaration
11417 @smallexample @c ada
11418 for Data'Bit_Order use High_Order_First;
11422 and the effect is what is desired, namely the layout is exactly the same,
11423 independent of whether the code is compiled on a big-endian or little-endian
11426 The important point to understand is that byte ordering is not affected.
11427 A @code{Bit_Order} attribute definition never affects which byte a field
11428 ends up in, only where it ends up in that byte.
11429 To make this clear, let us rewrite the record rep clause of the previous
11432 @smallexample @c ada
11433 for Data'Bit_Order use High_Order_First;
11434 for Data use record
11435 Master_Control at 0 range 0 .. 0;
11436 Master_V1 at 0 range 1 .. 1;
11437 Master_V2 at 0 range 2 .. 2;
11438 Master_V3 at 0 range 3 .. 3;
11439 Master_V4 at 0 range 4 .. 4;
11440 Master_V5 at 0 range 5 .. 5;
11441 Master_V6 at 0 range 6 .. 6;
11442 Master_V7 at 0 range 7 .. 7;
11443 Slave_Control at 0 range 8 .. 8;
11444 Slave_V1 at 0 range 9 .. 9;
11445 Slave_V2 at 0 range 10 .. 10;
11446 Slave_V3 at 0 range 11 .. 11;
11447 Slave_V4 at 0 range 12 .. 12;
11448 Slave_V5 at 0 range 13 .. 13;
11449 Slave_V6 at 0 range 14 .. 14;
11450 Slave_V7 at 0 range 15 .. 15;
11455 This is exactly equivalent to saying (a repeat of the first example):
11457 @smallexample @c ada
11458 for Data'Bit_Order use High_Order_First;
11459 for Data use record
11460 Master_Control at 0 range 0 .. 0;
11461 Master_V1 at 0 range 1 .. 1;
11462 Master_V2 at 0 range 2 .. 2;
11463 Master_V3 at 0 range 3 .. 3;
11464 Master_V4 at 0 range 4 .. 4;
11465 Master_V5 at 0 range 5 .. 5;
11466 Master_V6 at 0 range 6 .. 6;
11467 Master_V7 at 0 range 7 .. 7;
11468 Slave_Control at 1 range 0 .. 0;
11469 Slave_V1 at 1 range 1 .. 1;
11470 Slave_V2 at 1 range 2 .. 2;
11471 Slave_V3 at 1 range 3 .. 3;
11472 Slave_V4 at 1 range 4 .. 4;
11473 Slave_V5 at 1 range 5 .. 5;
11474 Slave_V6 at 1 range 6 .. 6;
11475 Slave_V7 at 1 range 7 .. 7;
11480 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
11481 field. The storage place attributes are obtained by normalizing the
11482 values given so that the @code{First_Bit} value is less than 8. After
11483 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
11484 we specified in the other case.
11486 Now one might expect that the @code{Bit_Order} attribute might affect
11487 bit numbering within the entire record component (two bytes in this
11488 case, thus affecting which byte fields end up in), but that is not
11489 the way this feature is defined, it only affects numbering of bits,
11490 not which byte they end up in.
11492 Consequently it never makes sense to specify a starting bit number
11493 greater than 7 (for a byte addressable field) if an attribute
11494 definition for @code{Bit_Order} has been given, and indeed it
11495 may be actively confusing to specify such a value, so the compiler
11496 generates a warning for such usage.
11498 If you do need to control byte ordering then appropriate conditional
11499 values must be used. If in our example, the slave byte came first on
11500 some machines we might write:
11502 @smallexample @c ada
11503 Master_Byte_First constant Boolean := @dots{};
11505 Master_Byte : constant Natural :=
11506 1 - Boolean'Pos (Master_Byte_First);
11507 Slave_Byte : constant Natural :=
11508 Boolean'Pos (Master_Byte_First);
11510 for Data'Bit_Order use High_Order_First;
11511 for Data use record
11512 Master_Control at Master_Byte range 0 .. 0;
11513 Master_V1 at Master_Byte range 1 .. 1;
11514 Master_V2 at Master_Byte range 2 .. 2;
11515 Master_V3 at Master_Byte range 3 .. 3;
11516 Master_V4 at Master_Byte range 4 .. 4;
11517 Master_V5 at Master_Byte range 5 .. 5;
11518 Master_V6 at Master_Byte range 6 .. 6;
11519 Master_V7 at Master_Byte range 7 .. 7;
11520 Slave_Control at Slave_Byte range 0 .. 0;
11521 Slave_V1 at Slave_Byte range 1 .. 1;
11522 Slave_V2 at Slave_Byte range 2 .. 2;
11523 Slave_V3 at Slave_Byte range 3 .. 3;
11524 Slave_V4 at Slave_Byte range 4 .. 4;
11525 Slave_V5 at Slave_Byte range 5 .. 5;
11526 Slave_V6 at Slave_Byte range 6 .. 6;
11527 Slave_V7 at Slave_Byte range 7 .. 7;
11532 Now to switch between machines, all that is necessary is
11533 to set the boolean constant @code{Master_Byte_First} in
11534 an appropriate manner.
11536 @node Pragma Pack for Arrays
11537 @section Pragma Pack for Arrays
11538 @cindex Pragma Pack (for arrays)
11541 Pragma @code{Pack} applied to an array has no effect unless the component type
11542 is packable. For a component type to be packable, it must be one of the
11549 Any type whose size is specified with a size clause
11551 Any packed array type with a static size
11553 Any record type padded because of its default alignment
11557 For all these cases, if the component subtype size is in the range
11558 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
11559 component size were specified giving the component subtype size.
11560 For example if we have:
11562 @smallexample @c ada
11563 type r is range 0 .. 17;
11565 type ar is array (1 .. 8) of r;
11570 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
11571 and the size of the array @code{ar} will be exactly 40 bits.
11573 Note that in some cases this rather fierce approach to packing can produce
11574 unexpected effects. For example, in Ada 95 and Ada 2005,
11575 subtype @code{Natural} typically has a size of 31, meaning that if you
11576 pack an array of @code{Natural}, you get 31-bit
11577 close packing, which saves a few bits, but results in far less efficient
11578 access. Since many other Ada compilers will ignore such a packing request,
11579 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
11580 might not be what is intended. You can easily remove this warning by
11581 using an explicit @code{Component_Size} setting instead, which never generates
11582 a warning, since the intention of the programmer is clear in this case.
11584 GNAT treats packed arrays in one of two ways. If the size of the array is
11585 known at compile time and is less than 64 bits, then internally the array
11586 is represented as a single modular type, of exactly the appropriate number
11587 of bits. If the length is greater than 63 bits, or is not known at compile
11588 time, then the packed array is represented as an array of bytes, and the
11589 length is always a multiple of 8 bits.
11591 Note that to represent a packed array as a modular type, the alignment must
11592 be suitable for the modular type involved. For example, on typical machines
11593 a 32-bit packed array will be represented by a 32-bit modular integer with
11594 an alignment of four bytes. If you explicitly override the default alignment
11595 with an alignment clause that is too small, the modular representation
11596 cannot be used. For example, consider the following set of declarations:
11598 @smallexample @c ada
11599 type R is range 1 .. 3;
11600 type S is array (1 .. 31) of R;
11601 for S'Component_Size use 2;
11603 for S'Alignment use 1;
11607 If the alignment clause were not present, then a 62-bit modular
11608 representation would be chosen (typically with an alignment of 4 or 8
11609 bytes depending on the target). But the default alignment is overridden
11610 with the explicit alignment clause. This means that the modular
11611 representation cannot be used, and instead the array of bytes
11612 representation must be used, meaning that the length must be a multiple
11613 of 8. Thus the above set of declarations will result in a diagnostic
11614 rejecting the size clause and noting that the minimum size allowed is 64.
11616 @cindex Pragma Pack (for type Natural)
11617 @cindex Pragma Pack warning
11619 One special case that is worth noting occurs when the base type of the
11620 component size is 8/16/32 and the subtype is one bit less. Notably this
11621 occurs with subtype @code{Natural}. Consider:
11623 @smallexample @c ada
11624 type Arr is array (1 .. 32) of Natural;
11629 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11630 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11631 Ada 83 compilers did not attempt 31 bit packing.
11633 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11634 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11635 substantial unintended performance penalty when porting legacy Ada 83 code.
11636 To help prevent this, GNAT generates a warning in such cases. If you really
11637 want 31 bit packing in a case like this, you can set the component size
11640 @smallexample @c ada
11641 type Arr is array (1 .. 32) of Natural;
11642 for Arr'Component_Size use 31;
11646 Here 31-bit packing is achieved as required, and no warning is generated,
11647 since in this case the programmer intention is clear.
11649 @node Pragma Pack for Records
11650 @section Pragma Pack for Records
11651 @cindex Pragma Pack (for records)
11654 Pragma @code{Pack} applied to a record will pack the components to reduce
11655 wasted space from alignment gaps and by reducing the amount of space
11656 taken by components. We distinguish between @emph{packable} components and
11657 @emph{non-packable} components.
11658 Components of the following types are considered packable:
11661 All primitive types are packable.
11664 Small packed arrays, whose size does not exceed 64 bits, and where the
11665 size is statically known at compile time, are represented internally
11666 as modular integers, and so they are also packable.
11671 All packable components occupy the exact number of bits corresponding to
11672 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11673 can start on an arbitrary bit boundary.
11675 All other types are non-packable, they occupy an integral number of
11677 are placed at a boundary corresponding to their alignment requirements.
11679 For example, consider the record
11681 @smallexample @c ada
11682 type Rb1 is array (1 .. 13) of Boolean;
11685 type Rb2 is array (1 .. 65) of Boolean;
11700 The representation for the record x2 is as follows:
11702 @smallexample @c ada
11703 for x2'Size use 224;
11705 l1 at 0 range 0 .. 0;
11706 l2 at 0 range 1 .. 64;
11707 l3 at 12 range 0 .. 31;
11708 l4 at 16 range 0 .. 0;
11709 l5 at 16 range 1 .. 13;
11710 l6 at 18 range 0 .. 71;
11715 Studying this example, we see that the packable fields @code{l1}
11717 of length equal to their sizes, and placed at specific bit boundaries (and
11718 not byte boundaries) to
11719 eliminate padding. But @code{l3} is of a non-packable float type, so
11720 it is on the next appropriate alignment boundary.
11722 The next two fields are fully packable, so @code{l4} and @code{l5} are
11723 minimally packed with no gaps. However, type @code{Rb2} is a packed
11724 array that is longer than 64 bits, so it is itself non-packable. Thus
11725 the @code{l6} field is aligned to the next byte boundary, and takes an
11726 integral number of bytes, i.e.@: 72 bits.
11728 @node Record Representation Clauses
11729 @section Record Representation Clauses
11730 @cindex Record Representation Clause
11733 Record representation clauses may be given for all record types, including
11734 types obtained by record extension. Component clauses are allowed for any
11735 static component. The restrictions on component clauses depend on the type
11738 @cindex Component Clause
11739 For all components of an elementary type, the only restriction on component
11740 clauses is that the size must be at least the 'Size value of the type
11741 (actually the Value_Size). There are no restrictions due to alignment,
11742 and such components may freely cross storage boundaries.
11744 Packed arrays with a size up to and including 64 bits are represented
11745 internally using a modular type with the appropriate number of bits, and
11746 thus the same lack of restriction applies. For example, if you declare:
11748 @smallexample @c ada
11749 type R is array (1 .. 49) of Boolean;
11755 then a component clause for a component of type R may start on any
11756 specified bit boundary, and may specify a value of 49 bits or greater.
11758 For packed bit arrays that are longer than 64 bits, there are two
11759 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11760 including the important case of single bits or boolean values, then
11761 there are no limitations on placement of such components, and they
11762 may start and end at arbitrary bit boundaries.
11764 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11765 an array of this type longer than 64 bits must always be placed on
11766 on a storage unit (byte) boundary and occupy an integral number
11767 of storage units (bytes). Any component clause that does not
11768 meet this requirement will be rejected.
11770 Any aliased component, or component of an aliased type, must
11771 have its normal alignment and size. A component clause that
11772 does not meet this requirement will be rejected.
11774 The tag field of a tagged type always occupies an address sized field at
11775 the start of the record. No component clause may attempt to overlay this
11776 tag. When a tagged type appears as a component, the tag field must have
11779 In the case of a record extension T1, of a type T, no component clause applied
11780 to the type T1 can specify a storage location that would overlap the first
11781 T'Size bytes of the record.
11783 For all other component types, including non-bit-packed arrays,
11784 the component can be placed at an arbitrary bit boundary,
11785 so for example, the following is permitted:
11787 @smallexample @c ada
11788 type R is array (1 .. 10) of Boolean;
11797 G at 0 range 0 .. 0;
11798 H at 0 range 1 .. 1;
11799 L at 0 range 2 .. 81;
11800 R at 0 range 82 .. 161;
11805 Note: the above rules apply to recent releases of GNAT 5.
11806 In GNAT 3, there are more severe restrictions on larger components.
11807 For non-primitive types, including packed arrays with a size greater than
11808 64 bits, component clauses must respect the alignment requirement of the
11809 type, in particular, always starting on a byte boundary, and the length
11810 must be a multiple of the storage unit.
11812 @node Enumeration Clauses
11813 @section Enumeration Clauses
11815 The only restriction on enumeration clauses is that the range of values
11816 must be representable. For the signed case, if one or more of the
11817 representation values are negative, all values must be in the range:
11819 @smallexample @c ada
11820 System.Min_Int .. System.Max_Int
11824 For the unsigned case, where all values are nonnegative, the values must
11827 @smallexample @c ada
11828 0 .. System.Max_Binary_Modulus;
11832 A @emph{confirming} representation clause is one in which the values range
11833 from 0 in sequence, i.e.@: a clause that confirms the default representation
11834 for an enumeration type.
11835 Such a confirming representation
11836 is permitted by these rules, and is specially recognized by the compiler so
11837 that no extra overhead results from the use of such a clause.
11839 If an array has an index type which is an enumeration type to which an
11840 enumeration clause has been applied, then the array is stored in a compact
11841 manner. Consider the declarations:
11843 @smallexample @c ada
11844 type r is (A, B, C);
11845 for r use (A => 1, B => 5, C => 10);
11846 type t is array (r) of Character;
11850 The array type t corresponds to a vector with exactly three elements and
11851 has a default size equal to @code{3*Character'Size}. This ensures efficient
11852 use of space, but means that accesses to elements of the array will incur
11853 the overhead of converting representation values to the corresponding
11854 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11856 @node Address Clauses
11857 @section Address Clauses
11858 @cindex Address Clause
11860 The reference manual allows a general restriction on representation clauses,
11861 as found in RM 13.1(22):
11864 An implementation need not support representation
11865 items containing nonstatic expressions, except that
11866 an implementation should support a representation item
11867 for a given entity if each nonstatic expression in the
11868 representation item is a name that statically denotes
11869 a constant declared before the entity.
11873 In practice this is applicable only to address clauses, since this is the
11874 only case in which a non-static expression is permitted by the syntax. As
11875 the AARM notes in sections 13.1 (22.a-22.h):
11878 22.a Reason: This is to avoid the following sort of thing:
11880 22.b X : Integer := F(@dots{});
11881 Y : Address := G(@dots{});
11882 for X'Address use Y;
11884 22.c In the above, we have to evaluate the
11885 initialization expression for X before we
11886 know where to put the result. This seems
11887 like an unreasonable implementation burden.
11889 22.d The above code should instead be written
11892 22.e Y : constant Address := G(@dots{});
11893 X : Integer := F(@dots{});
11894 for X'Address use Y;
11896 22.f This allows the expression ``Y'' to be safely
11897 evaluated before X is created.
11899 22.g The constant could be a formal parameter of mode in.
11901 22.h An implementation can support other nonstatic
11902 expressions if it wants to. Expressions of type
11903 Address are hardly ever static, but their value
11904 might be known at compile time anyway in many
11909 GNAT does indeed permit many additional cases of non-static expressions. In
11910 particular, if the type involved is elementary there are no restrictions
11911 (since in this case, holding a temporary copy of the initialization value,
11912 if one is present, is inexpensive). In addition, if there is no implicit or
11913 explicit initialization, then there are no restrictions. GNAT will reject
11914 only the case where all three of these conditions hold:
11919 The type of the item is non-elementary (e.g.@: a record or array).
11922 There is explicit or implicit initialization required for the object.
11923 Note that access values are always implicitly initialized, and also
11924 in GNAT, certain bit-packed arrays (those having a dynamic length or
11925 a length greater than 64) will also be implicitly initialized to zero.
11928 The address value is non-static. Here GNAT is more permissive than the
11929 RM, and allows the address value to be the address of a previously declared
11930 stand-alone variable, as long as it does not itself have an address clause.
11932 @smallexample @c ada
11933 Anchor : Some_Initialized_Type;
11934 Overlay : Some_Initialized_Type;
11935 for Overlay'Address use Anchor'Address;
11939 However, the prefix of the address clause cannot be an array component, or
11940 a component of a discriminated record.
11945 As noted above in section 22.h, address values are typically non-static. In
11946 particular the To_Address function, even if applied to a literal value, is
11947 a non-static function call. To avoid this minor annoyance, GNAT provides
11948 the implementation defined attribute 'To_Address. The following two
11949 expressions have identical values:
11953 @smallexample @c ada
11954 To_Address (16#1234_0000#)
11955 System'To_Address (16#1234_0000#);
11959 except that the second form is considered to be a static expression, and
11960 thus when used as an address clause value is always permitted.
11963 Additionally, GNAT treats as static an address clause that is an
11964 unchecked_conversion of a static integer value. This simplifies the porting
11965 of legacy code, and provides a portable equivalent to the GNAT attribute
11968 Another issue with address clauses is the interaction with alignment
11969 requirements. When an address clause is given for an object, the address
11970 value must be consistent with the alignment of the object (which is usually
11971 the same as the alignment of the type of the object). If an address clause
11972 is given that specifies an inappropriately aligned address value, then the
11973 program execution is erroneous.
11975 Since this source of erroneous behavior can have unfortunate effects, GNAT
11976 checks (at compile time if possible, generating a warning, or at execution
11977 time with a run-time check) that the alignment is appropriate. If the
11978 run-time check fails, then @code{Program_Error} is raised. This run-time
11979 check is suppressed if range checks are suppressed, or if the special GNAT
11980 check Alignment_Check is suppressed, or if
11981 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11983 Finally, GNAT does not permit overlaying of objects of controlled types or
11984 composite types containing a controlled component. In most cases, the compiler
11985 can detect an attempt at such overlays and will generate a warning at compile
11986 time and a Program_Error exception at run time.
11989 An address clause cannot be given for an exported object. More
11990 understandably the real restriction is that objects with an address
11991 clause cannot be exported. This is because such variables are not
11992 defined by the Ada program, so there is no external object to export.
11995 It is permissible to give an address clause and a pragma Import for the
11996 same object. In this case, the variable is not really defined by the
11997 Ada program, so there is no external symbol to be linked. The link name
11998 and the external name are ignored in this case. The reason that we allow this
11999 combination is that it provides a useful idiom to avoid unwanted
12000 initializations on objects with address clauses.
12002 When an address clause is given for an object that has implicit or
12003 explicit initialization, then by default initialization takes place. This
12004 means that the effect of the object declaration is to overwrite the
12005 memory at the specified address. This is almost always not what the
12006 programmer wants, so GNAT will output a warning:
12016 for Ext'Address use System'To_Address (16#1234_1234#);
12018 >>> warning: implicit initialization of "Ext" may
12019 modify overlaid storage
12020 >>> warning: use pragma Import for "Ext" to suppress
12021 initialization (RM B(24))
12027 As indicated by the warning message, the solution is to use a (dummy) pragma
12028 Import to suppress this initialization. The pragma tell the compiler that the
12029 object is declared and initialized elsewhere. The following package compiles
12030 without warnings (and the initialization is suppressed):
12032 @smallexample @c ada
12040 for Ext'Address use System'To_Address (16#1234_1234#);
12041 pragma Import (Ada, Ext);
12046 A final issue with address clauses involves their use for overlaying
12047 variables, as in the following example:
12048 @cindex Overlaying of objects
12050 @smallexample @c ada
12053 for B'Address use A'Address;
12057 or alternatively, using the form recommended by the RM:
12059 @smallexample @c ada
12061 Addr : constant Address := A'Address;
12063 for B'Address use Addr;
12067 In both of these cases, @code{A}
12068 and @code{B} become aliased to one another via the
12069 address clause. This use of address clauses to overlay
12070 variables, achieving an effect similar to unchecked
12071 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
12072 the effect is implementation defined. Furthermore, the
12073 Ada RM specifically recommends that in a situation
12074 like this, @code{B} should be subject to the following
12075 implementation advice (RM 13.3(19)):
12078 19 If the Address of an object is specified, or it is imported
12079 or exported, then the implementation should not perform
12080 optimizations based on assumptions of no aliases.
12084 GNAT follows this recommendation, and goes further by also applying
12085 this recommendation to the overlaid variable (@code{A}
12086 in the above example) in this case. This means that the overlay
12087 works "as expected", in that a modification to one of the variables
12088 will affect the value of the other.
12090 @node Effect of Convention on Representation
12091 @section Effect of Convention on Representation
12092 @cindex Convention, effect on representation
12095 Normally the specification of a foreign language convention for a type or
12096 an object has no effect on the chosen representation. In particular, the
12097 representation chosen for data in GNAT generally meets the standard system
12098 conventions, and for example records are laid out in a manner that is
12099 consistent with C@. This means that specifying convention C (for example)
12102 There are four exceptions to this general rule:
12106 @item Convention Fortran and array subtypes
12107 If pragma Convention Fortran is specified for an array subtype, then in
12108 accordance with the implementation advice in section 3.6.2(11) of the
12109 Ada Reference Manual, the array will be stored in a Fortran-compatible
12110 column-major manner, instead of the normal default row-major order.
12112 @item Convention C and enumeration types
12113 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
12114 to accommodate all values of the type. For example, for the enumeration
12117 @smallexample @c ada
12118 type Color is (Red, Green, Blue);
12122 8 bits is sufficient to store all values of the type, so by default, objects
12123 of type @code{Color} will be represented using 8 bits. However, normal C
12124 convention is to use 32 bits for all enum values in C, since enum values
12125 are essentially of type int. If pragma @code{Convention C} is specified for an
12126 Ada enumeration type, then the size is modified as necessary (usually to
12127 32 bits) to be consistent with the C convention for enum values.
12129 Note that this treatment applies only to types. If Convention C is given for
12130 an enumeration object, where the enumeration type is not Convention C, then
12131 Object_Size bits are allocated. For example, for a normal enumeration type,
12132 with less than 256 elements, only 8 bits will be allocated for the object.
12133 Since this may be a surprise in terms of what C expects, GNAT will issue a
12134 warning in this situation. The warning can be suppressed by giving an explicit
12135 size clause specifying the desired size.
12137 @item Convention C/Fortran and Boolean types
12138 In C, the usual convention for boolean values, that is values used for
12139 conditions, is that zero represents false, and nonzero values represent
12140 true. In Ada, the normal convention is that two specific values, typically
12141 0/1, are used to represent false/true respectively.
12143 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
12144 value represents true).
12146 To accommodate the Fortran and C conventions, if a pragma Convention specifies
12147 C or Fortran convention for a derived Boolean, as in the following example:
12149 @smallexample @c ada
12150 type C_Switch is new Boolean;
12151 pragma Convention (C, C_Switch);
12155 then the GNAT generated code will treat any nonzero value as true. For truth
12156 values generated by GNAT, the conventional value 1 will be used for True, but
12157 when one of these values is read, any nonzero value is treated as True.
12159 @item Access types on OpenVMS
12160 For 64-bit OpenVMS systems, access types (other than those for unconstrained
12161 arrays) are 64-bits long. An exception to this rule is for the case of
12162 C-convention access types where there is no explicit size clause present (or
12163 inherited for derived types). In this case, GNAT chooses to make these
12164 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
12165 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
12169 @node Determining the Representations chosen by GNAT
12170 @section Determining the Representations chosen by GNAT
12171 @cindex Representation, determination of
12172 @cindex @option{-gnatR} switch
12175 Although the descriptions in this section are intended to be complete, it is
12176 often easier to simply experiment to see what GNAT accepts and what the
12177 effect is on the layout of types and objects.
12179 As required by the Ada RM, if a representation clause is not accepted, then
12180 it must be rejected as illegal by the compiler. However, when a
12181 representation clause or pragma is accepted, there can still be questions
12182 of what the compiler actually does. For example, if a partial record
12183 representation clause specifies the location of some components and not
12184 others, then where are the non-specified components placed? Or if pragma
12185 @code{Pack} is used on a record, then exactly where are the resulting
12186 fields placed? The section on pragma @code{Pack} in this chapter can be
12187 used to answer the second question, but it is often easier to just see
12188 what the compiler does.
12190 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
12191 with this option, then the compiler will output information on the actual
12192 representations chosen, in a format similar to source representation
12193 clauses. For example, if we compile the package:
12195 @smallexample @c ada
12197 type r (x : boolean) is tagged record
12199 when True => S : String (1 .. 100);
12200 when False => null;
12204 type r2 is new r (false) with record
12209 y2 at 16 range 0 .. 31;
12216 type x1 is array (1 .. 10) of x;
12217 for x1'component_size use 11;
12219 type ia is access integer;
12221 type Rb1 is array (1 .. 13) of Boolean;
12224 type Rb2 is array (1 .. 65) of Boolean;
12240 using the switch @option{-gnatR} we obtain the following output:
12243 Representation information for unit q
12244 -------------------------------------
12247 for r'Alignment use 4;
12249 x at 4 range 0 .. 7;
12250 _tag at 0 range 0 .. 31;
12251 s at 5 range 0 .. 799;
12254 for r2'Size use 160;
12255 for r2'Alignment use 4;
12257 x at 4 range 0 .. 7;
12258 _tag at 0 range 0 .. 31;
12259 _parent at 0 range 0 .. 63;
12260 y2 at 16 range 0 .. 31;
12264 for x'Alignment use 1;
12266 y at 0 range 0 .. 7;
12269 for x1'Size use 112;
12270 for x1'Alignment use 1;
12271 for x1'Component_Size use 11;
12273 for rb1'Size use 13;
12274 for rb1'Alignment use 2;
12275 for rb1'Component_Size use 1;
12277 for rb2'Size use 72;
12278 for rb2'Alignment use 1;
12279 for rb2'Component_Size use 1;
12281 for x2'Size use 224;
12282 for x2'Alignment use 4;
12284 l1 at 0 range 0 .. 0;
12285 l2 at 0 range 1 .. 64;
12286 l3 at 12 range 0 .. 31;
12287 l4 at 16 range 0 .. 0;
12288 l5 at 16 range 1 .. 13;
12289 l6 at 18 range 0 .. 71;
12294 The Size values are actually the Object_Size, i.e.@: the default size that
12295 will be allocated for objects of the type.
12296 The ?? size for type r indicates that we have a variant record, and the
12297 actual size of objects will depend on the discriminant value.
12299 The Alignment values show the actual alignment chosen by the compiler
12300 for each record or array type.
12302 The record representation clause for type r shows where all fields
12303 are placed, including the compiler generated tag field (whose location
12304 cannot be controlled by the programmer).
12306 The record representation clause for the type extension r2 shows all the
12307 fields present, including the parent field, which is a copy of the fields
12308 of the parent type of r2, i.e.@: r1.
12310 The component size and size clauses for types rb1 and rb2 show
12311 the exact effect of pragma @code{Pack} on these arrays, and the record
12312 representation clause for type x2 shows how pragma @code{Pack} affects
12315 In some cases, it may be useful to cut and paste the representation clauses
12316 generated by the compiler into the original source to fix and guarantee
12317 the actual representation to be used.
12319 @node Standard Library Routines
12320 @chapter Standard Library Routines
12323 The Ada Reference Manual contains in Annex A a full description of an
12324 extensive set of standard library routines that can be used in any Ada
12325 program, and which must be provided by all Ada compilers. They are
12326 analogous to the standard C library used by C programs.
12328 GNAT implements all of the facilities described in annex A, and for most
12329 purposes the description in the Ada Reference Manual, or appropriate Ada
12330 text book, will be sufficient for making use of these facilities.
12332 In the case of the input-output facilities,
12333 @xref{The Implementation of Standard I/O},
12334 gives details on exactly how GNAT interfaces to the
12335 file system. For the remaining packages, the Ada Reference Manual
12336 should be sufficient. The following is a list of the packages included,
12337 together with a brief description of the functionality that is provided.
12339 For completeness, references are included to other predefined library
12340 routines defined in other sections of the Ada Reference Manual (these are
12341 cross-indexed from Annex A).
12345 This is a parent package for all the standard library packages. It is
12346 usually included implicitly in your program, and itself contains no
12347 useful data or routines.
12349 @item Ada.Calendar (9.6)
12350 @code{Calendar} provides time of day access, and routines for
12351 manipulating times and durations.
12353 @item Ada.Characters (A.3.1)
12354 This is a dummy parent package that contains no useful entities
12356 @item Ada.Characters.Handling (A.3.2)
12357 This package provides some basic character handling capabilities,
12358 including classification functions for classes of characters (e.g.@: test
12359 for letters, or digits).
12361 @item Ada.Characters.Latin_1 (A.3.3)
12362 This package includes a complete set of definitions of the characters
12363 that appear in type CHARACTER@. It is useful for writing programs that
12364 will run in international environments. For example, if you want an
12365 upper case E with an acute accent in a string, it is often better to use
12366 the definition of @code{UC_E_Acute} in this package. Then your program
12367 will print in an understandable manner even if your environment does not
12368 support these extended characters.
12370 @item Ada.Command_Line (A.15)
12371 This package provides access to the command line parameters and the name
12372 of the current program (analogous to the use of @code{argc} and @code{argv}
12373 in C), and also allows the exit status for the program to be set in a
12374 system-independent manner.
12376 @item Ada.Decimal (F.2)
12377 This package provides constants describing the range of decimal numbers
12378 implemented, and also a decimal divide routine (analogous to the COBOL
12379 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
12381 @item Ada.Direct_IO (A.8.4)
12382 This package provides input-output using a model of a set of records of
12383 fixed-length, containing an arbitrary definite Ada type, indexed by an
12384 integer record number.
12386 @item Ada.Dynamic_Priorities (D.5)
12387 This package allows the priorities of a task to be adjusted dynamically
12388 as the task is running.
12390 @item Ada.Exceptions (11.4.1)
12391 This package provides additional information on exceptions, and also
12392 contains facilities for treating exceptions as data objects, and raising
12393 exceptions with associated messages.
12395 @item Ada.Finalization (7.6)
12396 This package contains the declarations and subprograms to support the
12397 use of controlled types, providing for automatic initialization and
12398 finalization (analogous to the constructors and destructors of C++)
12400 @item Ada.Interrupts (C.3.2)
12401 This package provides facilities for interfacing to interrupts, which
12402 includes the set of signals or conditions that can be raised and
12403 recognized as interrupts.
12405 @item Ada.Interrupts.Names (C.3.2)
12406 This package provides the set of interrupt names (actually signal
12407 or condition names) that can be handled by GNAT@.
12409 @item Ada.IO_Exceptions (A.13)
12410 This package defines the set of exceptions that can be raised by use of
12411 the standard IO packages.
12414 This package contains some standard constants and exceptions used
12415 throughout the numerics packages. Note that the constants pi and e are
12416 defined here, and it is better to use these definitions than rolling
12419 @item Ada.Numerics.Complex_Elementary_Functions
12420 Provides the implementation of standard elementary functions (such as
12421 log and trigonometric functions) operating on complex numbers using the
12422 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
12423 created by the package @code{Numerics.Complex_Types}.
12425 @item Ada.Numerics.Complex_Types
12426 This is a predefined instantiation of
12427 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
12428 build the type @code{Complex} and @code{Imaginary}.
12430 @item Ada.Numerics.Discrete_Random
12431 This generic package provides a random number generator suitable for generating
12432 uniformly distributed values of a specified discrete subtype.
12434 @item Ada.Numerics.Float_Random
12435 This package provides a random number generator suitable for generating
12436 uniformly distributed floating point values in the unit interval.
12438 @item Ada.Numerics.Generic_Complex_Elementary_Functions
12439 This is a generic version of the package that provides the
12440 implementation of standard elementary functions (such as log and
12441 trigonometric functions) for an arbitrary complex type.
12443 The following predefined instantiations of this package are provided:
12447 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
12449 @code{Ada.Numerics.Complex_Elementary_Functions}
12451 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
12454 @item Ada.Numerics.Generic_Complex_Types
12455 This is a generic package that allows the creation of complex types,
12456 with associated complex arithmetic operations.
12458 The following predefined instantiations of this package exist
12461 @code{Ada.Numerics.Short_Complex_Complex_Types}
12463 @code{Ada.Numerics.Complex_Complex_Types}
12465 @code{Ada.Numerics.Long_Complex_Complex_Types}
12468 @item Ada.Numerics.Generic_Elementary_Functions
12469 This is a generic package that provides the implementation of standard
12470 elementary functions (such as log an trigonometric functions) for an
12471 arbitrary float type.
12473 The following predefined instantiations of this package exist
12477 @code{Ada.Numerics.Short_Elementary_Functions}
12479 @code{Ada.Numerics.Elementary_Functions}
12481 @code{Ada.Numerics.Long_Elementary_Functions}
12484 @item Ada.Real_Time (D.8)
12485 This package provides facilities similar to those of @code{Calendar}, but
12486 operating with a finer clock suitable for real time control. Note that
12487 annex D requires that there be no backward clock jumps, and GNAT generally
12488 guarantees this behavior, but of course if the external clock on which
12489 the GNAT runtime depends is deliberately reset by some external event,
12490 then such a backward jump may occur.
12492 @item Ada.Sequential_IO (A.8.1)
12493 This package provides input-output facilities for sequential files,
12494 which can contain a sequence of values of a single type, which can be
12495 any Ada type, including indefinite (unconstrained) types.
12497 @item Ada.Storage_IO (A.9)
12498 This package provides a facility for mapping arbitrary Ada types to and
12499 from a storage buffer. It is primarily intended for the creation of new
12502 @item Ada.Streams (13.13.1)
12503 This is a generic package that provides the basic support for the
12504 concept of streams as used by the stream attributes (@code{Input},
12505 @code{Output}, @code{Read} and @code{Write}).
12507 @item Ada.Streams.Stream_IO (A.12.1)
12508 This package is a specialization of the type @code{Streams} defined in
12509 package @code{Streams} together with a set of operations providing
12510 Stream_IO capability. The Stream_IO model permits both random and
12511 sequential access to a file which can contain an arbitrary set of values
12512 of one or more Ada types.
12514 @item Ada.Strings (A.4.1)
12515 This package provides some basic constants used by the string handling
12518 @item Ada.Strings.Bounded (A.4.4)
12519 This package provides facilities for handling variable length
12520 strings. The bounded model requires a maximum length. It is thus
12521 somewhat more limited than the unbounded model, but avoids the use of
12522 dynamic allocation or finalization.
12524 @item Ada.Strings.Fixed (A.4.3)
12525 This package provides facilities for handling fixed length strings.
12527 @item Ada.Strings.Maps (A.4.2)
12528 This package provides facilities for handling character mappings and
12529 arbitrarily defined subsets of characters. For instance it is useful in
12530 defining specialized translation tables.
12532 @item Ada.Strings.Maps.Constants (A.4.6)
12533 This package provides a standard set of predefined mappings and
12534 predefined character sets. For example, the standard upper to lower case
12535 conversion table is found in this package. Note that upper to lower case
12536 conversion is non-trivial if you want to take the entire set of
12537 characters, including extended characters like E with an acute accent,
12538 into account. You should use the mappings in this package (rather than
12539 adding 32 yourself) to do case mappings.
12541 @item Ada.Strings.Unbounded (A.4.5)
12542 This package provides facilities for handling variable length
12543 strings. The unbounded model allows arbitrary length strings, but
12544 requires the use of dynamic allocation and finalization.
12546 @item Ada.Strings.Wide_Bounded (A.4.7)
12547 @itemx Ada.Strings.Wide_Fixed (A.4.7)
12548 @itemx Ada.Strings.Wide_Maps (A.4.7)
12549 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
12550 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
12551 These packages provide analogous capabilities to the corresponding
12552 packages without @samp{Wide_} in the name, but operate with the types
12553 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
12554 and @code{Character}.
12556 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
12557 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
12558 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
12559 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
12560 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
12561 These packages provide analogous capabilities to the corresponding
12562 packages without @samp{Wide_} in the name, but operate with the types
12563 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
12564 of @code{String} and @code{Character}.
12566 @item Ada.Synchronous_Task_Control (D.10)
12567 This package provides some standard facilities for controlling task
12568 communication in a synchronous manner.
12571 This package contains definitions for manipulation of the tags of tagged
12574 @item Ada.Task_Attributes
12575 This package provides the capability of associating arbitrary
12576 task-specific data with separate tasks.
12579 This package provides basic text input-output capabilities for
12580 character, string and numeric data. The subpackages of this
12581 package are listed next.
12583 @item Ada.Text_IO.Decimal_IO
12584 Provides input-output facilities for decimal fixed-point types
12586 @item Ada.Text_IO.Enumeration_IO
12587 Provides input-output facilities for enumeration types.
12589 @item Ada.Text_IO.Fixed_IO
12590 Provides input-output facilities for ordinary fixed-point types.
12592 @item Ada.Text_IO.Float_IO
12593 Provides input-output facilities for float types. The following
12594 predefined instantiations of this generic package are available:
12598 @code{Short_Float_Text_IO}
12600 @code{Float_Text_IO}
12602 @code{Long_Float_Text_IO}
12605 @item Ada.Text_IO.Integer_IO
12606 Provides input-output facilities for integer types. The following
12607 predefined instantiations of this generic package are available:
12610 @item Short_Short_Integer
12611 @code{Ada.Short_Short_Integer_Text_IO}
12612 @item Short_Integer
12613 @code{Ada.Short_Integer_Text_IO}
12615 @code{Ada.Integer_Text_IO}
12617 @code{Ada.Long_Integer_Text_IO}
12618 @item Long_Long_Integer
12619 @code{Ada.Long_Long_Integer_Text_IO}
12622 @item Ada.Text_IO.Modular_IO
12623 Provides input-output facilities for modular (unsigned) types
12625 @item Ada.Text_IO.Complex_IO (G.1.3)
12626 This package provides basic text input-output capabilities for complex
12629 @item Ada.Text_IO.Editing (F.3.3)
12630 This package contains routines for edited output, analogous to the use
12631 of pictures in COBOL@. The picture formats used by this package are a
12632 close copy of the facility in COBOL@.
12634 @item Ada.Text_IO.Text_Streams (A.12.2)
12635 This package provides a facility that allows Text_IO files to be treated
12636 as streams, so that the stream attributes can be used for writing
12637 arbitrary data, including binary data, to Text_IO files.
12639 @item Ada.Unchecked_Conversion (13.9)
12640 This generic package allows arbitrary conversion from one type to
12641 another of the same size, providing for breaking the type safety in
12642 special circumstances.
12644 If the types have the same Size (more accurately the same Value_Size),
12645 then the effect is simply to transfer the bits from the source to the
12646 target type without any modification. This usage is well defined, and
12647 for simple types whose representation is typically the same across
12648 all implementations, gives a portable method of performing such
12651 If the types do not have the same size, then the result is implementation
12652 defined, and thus may be non-portable. The following describes how GNAT
12653 handles such unchecked conversion cases.
12655 If the types are of different sizes, and are both discrete types, then
12656 the effect is of a normal type conversion without any constraint checking.
12657 In particular if the result type has a larger size, the result will be
12658 zero or sign extended. If the result type has a smaller size, the result
12659 will be truncated by ignoring high order bits.
12661 If the types are of different sizes, and are not both discrete types,
12662 then the conversion works as though pointers were created to the source
12663 and target, and the pointer value is converted. The effect is that bits
12664 are copied from successive low order storage units and bits of the source
12665 up to the length of the target type.
12667 A warning is issued if the lengths differ, since the effect in this
12668 case is implementation dependent, and the above behavior may not match
12669 that of some other compiler.
12671 A pointer to one type may be converted to a pointer to another type using
12672 unchecked conversion. The only case in which the effect is undefined is
12673 when one or both pointers are pointers to unconstrained array types. In
12674 this case, the bounds information may get incorrectly transferred, and in
12675 particular, GNAT uses double size pointers for such types, and it is
12676 meaningless to convert between such pointer types. GNAT will issue a
12677 warning if the alignment of the target designated type is more strict
12678 than the alignment of the source designated type (since the result may
12679 be unaligned in this case).
12681 A pointer other than a pointer to an unconstrained array type may be
12682 converted to and from System.Address. Such usage is common in Ada 83
12683 programs, but note that Ada.Address_To_Access_Conversions is the
12684 preferred method of performing such conversions in Ada 95 and Ada 2005.
12686 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12687 used in conjunction with pointers to unconstrained objects, since
12688 the bounds information cannot be handled correctly in this case.
12690 @item Ada.Unchecked_Deallocation (13.11.2)
12691 This generic package allows explicit freeing of storage previously
12692 allocated by use of an allocator.
12694 @item Ada.Wide_Text_IO (A.11)
12695 This package is similar to @code{Ada.Text_IO}, except that the external
12696 file supports wide character representations, and the internal types are
12697 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12698 and @code{String}. It contains generic subpackages listed next.
12700 @item Ada.Wide_Text_IO.Decimal_IO
12701 Provides input-output facilities for decimal fixed-point types
12703 @item Ada.Wide_Text_IO.Enumeration_IO
12704 Provides input-output facilities for enumeration types.
12706 @item Ada.Wide_Text_IO.Fixed_IO
12707 Provides input-output facilities for ordinary fixed-point types.
12709 @item Ada.Wide_Text_IO.Float_IO
12710 Provides input-output facilities for float types. The following
12711 predefined instantiations of this generic package are available:
12715 @code{Short_Float_Wide_Text_IO}
12717 @code{Float_Wide_Text_IO}
12719 @code{Long_Float_Wide_Text_IO}
12722 @item Ada.Wide_Text_IO.Integer_IO
12723 Provides input-output facilities for integer types. The following
12724 predefined instantiations of this generic package are available:
12727 @item Short_Short_Integer
12728 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12729 @item Short_Integer
12730 @code{Ada.Short_Integer_Wide_Text_IO}
12732 @code{Ada.Integer_Wide_Text_IO}
12734 @code{Ada.Long_Integer_Wide_Text_IO}
12735 @item Long_Long_Integer
12736 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12739 @item Ada.Wide_Text_IO.Modular_IO
12740 Provides input-output facilities for modular (unsigned) types
12742 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12743 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12744 external file supports wide character representations.
12746 @item Ada.Wide_Text_IO.Editing (F.3.4)
12747 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12748 types are @code{Wide_Character} and @code{Wide_String} instead of
12749 @code{Character} and @code{String}.
12751 @item Ada.Wide_Text_IO.Streams (A.12.3)
12752 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12753 types are @code{Wide_Character} and @code{Wide_String} instead of
12754 @code{Character} and @code{String}.
12756 @item Ada.Wide_Wide_Text_IO (A.11)
12757 This package is similar to @code{Ada.Text_IO}, except that the external
12758 file supports wide character representations, and the internal types are
12759 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12760 and @code{String}. It contains generic subpackages listed next.
12762 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12763 Provides input-output facilities for decimal fixed-point types
12765 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12766 Provides input-output facilities for enumeration types.
12768 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12769 Provides input-output facilities for ordinary fixed-point types.
12771 @item Ada.Wide_Wide_Text_IO.Float_IO
12772 Provides input-output facilities for float types. The following
12773 predefined instantiations of this generic package are available:
12777 @code{Short_Float_Wide_Wide_Text_IO}
12779 @code{Float_Wide_Wide_Text_IO}
12781 @code{Long_Float_Wide_Wide_Text_IO}
12784 @item Ada.Wide_Wide_Text_IO.Integer_IO
12785 Provides input-output facilities for integer types. The following
12786 predefined instantiations of this generic package are available:
12789 @item Short_Short_Integer
12790 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12791 @item Short_Integer
12792 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12794 @code{Ada.Integer_Wide_Wide_Text_IO}
12796 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12797 @item Long_Long_Integer
12798 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12801 @item Ada.Wide_Wide_Text_IO.Modular_IO
12802 Provides input-output facilities for modular (unsigned) types
12804 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12805 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12806 external file supports wide character representations.
12808 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12809 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12810 types are @code{Wide_Character} and @code{Wide_String} instead of
12811 @code{Character} and @code{String}.
12813 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12814 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12815 types are @code{Wide_Character} and @code{Wide_String} instead of
12816 @code{Character} and @code{String}.
12819 @node The Implementation of Standard I/O
12820 @chapter The Implementation of Standard I/O
12823 GNAT implements all the required input-output facilities described in
12824 A.6 through A.14. These sections of the Ada Reference Manual describe the
12825 required behavior of these packages from the Ada point of view, and if
12826 you are writing a portable Ada program that does not need to know the
12827 exact manner in which Ada maps to the outside world when it comes to
12828 reading or writing external files, then you do not need to read this
12829 chapter. As long as your files are all regular files (not pipes or
12830 devices), and as long as you write and read the files only from Ada, the
12831 description in the Ada Reference Manual is sufficient.
12833 However, if you want to do input-output to pipes or other devices, such
12834 as the keyboard or screen, or if the files you are dealing with are
12835 either generated by some other language, or to be read by some other
12836 language, then you need to know more about the details of how the GNAT
12837 implementation of these input-output facilities behaves.
12839 In this chapter we give a detailed description of exactly how GNAT
12840 interfaces to the file system. As always, the sources of the system are
12841 available to you for answering questions at an even more detailed level,
12842 but for most purposes the information in this chapter will suffice.
12844 Another reason that you may need to know more about how input-output is
12845 implemented arises when you have a program written in mixed languages
12846 where, for example, files are shared between the C and Ada sections of
12847 the same program. GNAT provides some additional facilities, in the form
12848 of additional child library packages, that facilitate this sharing, and
12849 these additional facilities are also described in this chapter.
12852 * Standard I/O Packages::
12858 * Wide_Wide_Text_IO::
12860 * Text Translation::
12862 * Filenames encoding::
12864 * Operations on C Streams::
12865 * Interfacing to C Streams::
12868 @node Standard I/O Packages
12869 @section Standard I/O Packages
12872 The Standard I/O packages described in Annex A for
12878 Ada.Text_IO.Complex_IO
12880 Ada.Text_IO.Text_Streams
12884 Ada.Wide_Text_IO.Complex_IO
12886 Ada.Wide_Text_IO.Text_Streams
12888 Ada.Wide_Wide_Text_IO
12890 Ada.Wide_Wide_Text_IO.Complex_IO
12892 Ada.Wide_Wide_Text_IO.Text_Streams
12902 are implemented using the C
12903 library streams facility; where
12907 All files are opened using @code{fopen}.
12909 All input/output operations use @code{fread}/@code{fwrite}.
12913 There is no internal buffering of any kind at the Ada library level. The only
12914 buffering is that provided at the system level in the implementation of the
12915 library routines that support streams. This facilitates shared use of these
12916 streams by mixed language programs. Note though that system level buffering is
12917 explicitly enabled at elaboration of the standard I/O packages and that can
12918 have an impact on mixed language programs, in particular those using I/O before
12919 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12920 the Ada elaboration routine before performing any I/O or when impractical,
12921 flush the common I/O streams and in particular Standard_Output before
12922 elaborating the Ada code.
12925 @section FORM Strings
12928 The format of a FORM string in GNAT is:
12931 "keyword=value,keyword=value,@dots{},keyword=value"
12935 where letters may be in upper or lower case, and there are no spaces
12936 between values. The order of the entries is not important. Currently
12937 the following keywords defined.
12940 TEXT_TRANSLATION=[YES|NO]
12942 WCEM=[n|h|u|s|e|8|b]
12943 ENCODING=[UTF8|8BITS]
12947 The use of these parameters is described later in this section.
12953 Direct_IO can only be instantiated for definite types. This is a
12954 restriction of the Ada language, which means that the records are fixed
12955 length (the length being determined by @code{@var{type}'Size}, rounded
12956 up to the next storage unit boundary if necessary).
12958 The records of a Direct_IO file are simply written to the file in index
12959 sequence, with the first record starting at offset zero, and subsequent
12960 records following. There is no control information of any kind. For
12961 example, if 32-bit integers are being written, each record takes
12962 4-bytes, so the record at index @var{K} starts at offset
12963 (@var{K}@minus{}1)*4.
12965 There is no limit on the size of Direct_IO files, they are expanded as
12966 necessary to accommodate whatever records are written to the file.
12968 @node Sequential_IO
12969 @section Sequential_IO
12972 Sequential_IO may be instantiated with either a definite (constrained)
12973 or indefinite (unconstrained) type.
12975 For the definite type case, the elements written to the file are simply
12976 the memory images of the data values with no control information of any
12977 kind. The resulting file should be read using the same type, no validity
12978 checking is performed on input.
12980 For the indefinite type case, the elements written consist of two
12981 parts. First is the size of the data item, written as the memory image
12982 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12983 the data value. The resulting file can only be read using the same
12984 (unconstrained) type. Normal assignment checks are performed on these
12985 read operations, and if these checks fail, @code{Data_Error} is
12986 raised. In particular, in the array case, the lengths must match, and in
12987 the variant record case, if the variable for a particular read operation
12988 is constrained, the discriminants must match.
12990 Note that it is not possible to use Sequential_IO to write variable
12991 length array items, and then read the data back into different length
12992 arrays. For example, the following will raise @code{Data_Error}:
12994 @smallexample @c ada
12995 package IO is new Sequential_IO (String);
13000 IO.Write (F, "hello!")
13001 IO.Reset (F, Mode=>In_File);
13008 On some Ada implementations, this will print @code{hell}, but the program is
13009 clearly incorrect, since there is only one element in the file, and that
13010 element is the string @code{hello!}.
13012 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
13013 using Stream_IO, and this is the preferred mechanism. In particular, the
13014 above program fragment rewritten to use Stream_IO will work correctly.
13020 Text_IO files consist of a stream of characters containing the following
13021 special control characters:
13024 LF (line feed, 16#0A#) Line Mark
13025 FF (form feed, 16#0C#) Page Mark
13029 A canonical Text_IO file is defined as one in which the following
13030 conditions are met:
13034 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
13038 The character @code{FF} is used only as a page mark, i.e.@: to mark the
13039 end of a page and consequently can appear only immediately following a
13040 @code{LF} (line mark) character.
13043 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
13044 (line mark, page mark). In the former case, the page mark is implicitly
13045 assumed to be present.
13049 A file written using Text_IO will be in canonical form provided that no
13050 explicit @code{LF} or @code{FF} characters are written using @code{Put}
13051 or @code{Put_Line}. There will be no @code{FF} character at the end of
13052 the file unless an explicit @code{New_Page} operation was performed
13053 before closing the file.
13055 A canonical Text_IO file that is a regular file (i.e., not a device or a
13056 pipe) can be read using any of the routines in Text_IO@. The
13057 semantics in this case will be exactly as defined in the Ada Reference
13058 Manual, and all the routines in Text_IO are fully implemented.
13060 A text file that does not meet the requirements for a canonical Text_IO
13061 file has one of the following:
13065 The file contains @code{FF} characters not immediately following a
13066 @code{LF} character.
13069 The file contains @code{LF} or @code{FF} characters written by
13070 @code{Put} or @code{Put_Line}, which are not logically considered to be
13071 line marks or page marks.
13074 The file ends in a character other than @code{LF} or @code{FF},
13075 i.e.@: there is no explicit line mark or page mark at the end of the file.
13079 Text_IO can be used to read such non-standard text files but subprograms
13080 to do with line or page numbers do not have defined meanings. In
13081 particular, a @code{FF} character that does not follow a @code{LF}
13082 character may or may not be treated as a page mark from the point of
13083 view of page and line numbering. Every @code{LF} character is considered
13084 to end a line, and there is an implied @code{LF} character at the end of
13088 * Text_IO Stream Pointer Positioning::
13089 * Text_IO Reading and Writing Non-Regular Files::
13091 * Treating Text_IO Files as Streams::
13092 * Text_IO Extensions::
13093 * Text_IO Facilities for Unbounded Strings::
13096 @node Text_IO Stream Pointer Positioning
13097 @subsection Stream Pointer Positioning
13100 @code{Ada.Text_IO} has a definition of current position for a file that
13101 is being read. No internal buffering occurs in Text_IO, and usually the
13102 physical position in the stream used to implement the file corresponds
13103 to this logical position defined by Text_IO@. There are two exceptions:
13107 After a call to @code{End_Of_Page} that returns @code{True}, the stream
13108 is positioned past the @code{LF} (line mark) that precedes the page
13109 mark. Text_IO maintains an internal flag so that subsequent read
13110 operations properly handle the logical position which is unchanged by
13111 the @code{End_Of_Page} call.
13114 After a call to @code{End_Of_File} that returns @code{True}, if the
13115 Text_IO file was positioned before the line mark at the end of file
13116 before the call, then the logical position is unchanged, but the stream
13117 is physically positioned right at the end of file (past the line mark,
13118 and past a possible page mark following the line mark. Again Text_IO
13119 maintains internal flags so that subsequent read operations properly
13120 handle the logical position.
13124 These discrepancies have no effect on the observable behavior of
13125 Text_IO, but if a single Ada stream is shared between a C program and
13126 Ada program, or shared (using @samp{shared=yes} in the form string)
13127 between two Ada files, then the difference may be observable in some
13130 @node Text_IO Reading and Writing Non-Regular Files
13131 @subsection Reading and Writing Non-Regular Files
13134 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
13135 can be used for reading and writing. Writing is not affected and the
13136 sequence of characters output is identical to the normal file case, but
13137 for reading, the behavior of Text_IO is modified to avoid undesirable
13138 look-ahead as follows:
13140 An input file that is not a regular file is considered to have no page
13141 marks. Any @code{Ascii.FF} characters (the character normally used for a
13142 page mark) appearing in the file are considered to be data
13143 characters. In particular:
13147 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
13148 following a line mark. If a page mark appears, it will be treated as a
13152 This avoids the need to wait for an extra character to be typed or
13153 entered from the pipe to complete one of these operations.
13156 @code{End_Of_Page} always returns @code{False}
13159 @code{End_Of_File} will return @code{False} if there is a page mark at
13160 the end of the file.
13164 Output to non-regular files is the same as for regular files. Page marks
13165 may be written to non-regular files using @code{New_Page}, but as noted
13166 above they will not be treated as page marks on input if the output is
13167 piped to another Ada program.
13169 Another important discrepancy when reading non-regular files is that the end
13170 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
13171 pressing the @key{EOT} key,
13173 is signaled once (i.e.@: the test @code{End_Of_File}
13174 will yield @code{True}, or a read will
13175 raise @code{End_Error}), but then reading can resume
13176 to read data past that end of
13177 file indication, until another end of file indication is entered.
13179 @node Get_Immediate
13180 @subsection Get_Immediate
13181 @cindex Get_Immediate
13184 Get_Immediate returns the next character (including control characters)
13185 from the input file. In particular, Get_Immediate will return LF or FF
13186 characters used as line marks or page marks. Such operations leave the
13187 file positioned past the control character, and it is thus not treated
13188 as having its normal function. This means that page, line and column
13189 counts after this kind of Get_Immediate call are set as though the mark
13190 did not occur. In the case where a Get_Immediate leaves the file
13191 positioned between the line mark and page mark (which is not normally
13192 possible), it is undefined whether the FF character will be treated as a
13195 @node Treating Text_IO Files as Streams
13196 @subsection Treating Text_IO Files as Streams
13197 @cindex Stream files
13200 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
13201 as a stream. Data written to a Text_IO file in this stream mode is
13202 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
13203 16#0C# (@code{FF}), the resulting file may have non-standard
13204 format. Similarly if read operations are used to read from a Text_IO
13205 file treated as a stream, then @code{LF} and @code{FF} characters may be
13206 skipped and the effect is similar to that described above for
13207 @code{Get_Immediate}.
13209 @node Text_IO Extensions
13210 @subsection Text_IO Extensions
13211 @cindex Text_IO extensions
13214 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
13215 to the standard @code{Text_IO} package:
13218 @item function File_Exists (Name : String) return Boolean;
13219 Determines if a file of the given name exists.
13221 @item function Get_Line return String;
13222 Reads a string from the standard input file. The value returned is exactly
13223 the length of the line that was read.
13225 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
13226 Similar, except that the parameter File specifies the file from which
13227 the string is to be read.
13231 @node Text_IO Facilities for Unbounded Strings
13232 @subsection Text_IO Facilities for Unbounded Strings
13233 @cindex Text_IO for unbounded strings
13234 @cindex Unbounded_String, Text_IO operations
13237 The package @code{Ada.Strings.Unbounded.Text_IO}
13238 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
13239 subprograms useful for Text_IO operations on unbounded strings:
13243 @item function Get_Line (File : File_Type) return Unbounded_String;
13244 Reads a line from the specified file
13245 and returns the result as an unbounded string.
13247 @item procedure Put (File : File_Type; U : Unbounded_String);
13248 Writes the value of the given unbounded string to the specified file
13249 Similar to the effect of
13250 @code{Put (To_String (U))} except that an extra copy is avoided.
13252 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
13253 Writes the value of the given unbounded string to the specified file,
13254 followed by a @code{New_Line}.
13255 Similar to the effect of @code{Put_Line (To_String (U))} except
13256 that an extra copy is avoided.
13260 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
13261 and is optional. If the parameter is omitted, then the standard input or
13262 output file is referenced as appropriate.
13264 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
13265 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
13266 @code{Wide_Text_IO} functionality for unbounded wide strings.
13268 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
13269 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
13270 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
13273 @section Wide_Text_IO
13276 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
13277 both input and output files may contain special sequences that represent
13278 wide character values. The encoding scheme for a given file may be
13279 specified using a FORM parameter:
13286 as part of the FORM string (WCEM = wide character encoding method),
13287 where @var{x} is one of the following characters
13293 Upper half encoding
13305 The encoding methods match those that
13306 can be used in a source
13307 program, but there is no requirement that the encoding method used for
13308 the source program be the same as the encoding method used for files,
13309 and different files may use different encoding methods.
13311 The default encoding method for the standard files, and for opened files
13312 for which no WCEM parameter is given in the FORM string matches the
13313 wide character encoding specified for the main program (the default
13314 being brackets encoding if no coding method was specified with -gnatW).
13318 In this encoding, a wide character is represented by a five character
13326 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
13327 characters (using upper case letters) of the wide character code. For
13328 example, ESC A345 is used to represent the wide character with code
13329 16#A345#. This scheme is compatible with use of the full
13330 @code{Wide_Character} set.
13332 @item Upper Half Coding
13333 The wide character with encoding 16#abcd#, where the upper bit is on
13334 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
13335 16#cd#. The second byte may never be a format control character, but is
13336 not required to be in the upper half. This method can be also used for
13337 shift-JIS or EUC where the internal coding matches the external coding.
13339 @item Shift JIS Coding
13340 A wide character is represented by a two character sequence 16#ab# and
13341 16#cd#, with the restrictions described for upper half encoding as
13342 described above. The internal character code is the corresponding JIS
13343 character according to the standard algorithm for Shift-JIS
13344 conversion. Only characters defined in the JIS code set table can be
13345 used with this encoding method.
13348 A wide character is represented by a two character sequence 16#ab# and
13349 16#cd#, with both characters being in the upper half. The internal
13350 character code is the corresponding JIS character according to the EUC
13351 encoding algorithm. Only characters defined in the JIS code set table
13352 can be used with this encoding method.
13355 A wide character is represented using
13356 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13357 10646-1/Am.2. Depending on the character value, the representation
13358 is a one, two, or three byte sequence:
13361 16#0000#-16#007f#: 2#0xxxxxxx#
13362 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
13363 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13367 where the @var{xxx} bits correspond to the left-padded bits of the
13368 16-bit character value. Note that all lower half ASCII characters
13369 are represented as ASCII bytes and all upper half characters and
13370 other wide characters are represented as sequences of upper-half
13371 (The full UTF-8 scheme allows for encoding 31-bit characters as
13372 6-byte sequences, but in this implementation, all UTF-8 sequences
13373 of four or more bytes length will raise a Constraint_Error, as
13374 will all invalid UTF-8 sequences.)
13376 @item Brackets Coding
13377 In this encoding, a wide character is represented by the following eight
13378 character sequence:
13385 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
13386 characters (using uppercase letters) of the wide character code. For
13387 example, @code{["A345"]} is used to represent the wide character with code
13389 This scheme is compatible with use of the full Wide_Character set.
13390 On input, brackets coding can also be used for upper half characters,
13391 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
13392 is only used for wide characters with a code greater than @code{16#FF#}.
13394 Note that brackets coding is not normally used in the context of
13395 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
13396 a portable way of encoding source files. In the context of Wide_Text_IO
13397 or Wide_Wide_Text_IO, it can only be used if the file does not contain
13398 any instance of the left bracket character other than to encode wide
13399 character values using the brackets encoding method. In practice it is
13400 expected that some standard wide character encoding method such
13401 as UTF-8 will be used for text input output.
13403 If brackets notation is used, then any occurrence of a left bracket
13404 in the input file which is not the start of a valid wide character
13405 sequence will cause Constraint_Error to be raised. It is possible to
13406 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
13407 input will interpret this as a left bracket.
13409 However, when a left bracket is output, it will be output as a left bracket
13410 and not as ["5B"]. We make this decision because for normal use of
13411 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
13412 brackets. For example, if we write:
13415 Put_Line ("Start of output [first run]");
13419 we really do not want to have the left bracket in this message clobbered so
13420 that the output reads:
13423 Start of output ["5B"]first run]
13427 In practice brackets encoding is reasonably useful for normal Put_Line use
13428 since we won't get confused between left brackets and wide character
13429 sequences in the output. But for input, or when files are written out
13430 and read back in, it really makes better sense to use one of the standard
13431 encoding methods such as UTF-8.
13436 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
13437 not all wide character
13438 values can be represented. An attempt to output a character that cannot
13439 be represented using the encoding scheme for the file causes
13440 Constraint_Error to be raised. An invalid wide character sequence on
13441 input also causes Constraint_Error to be raised.
13444 * Wide_Text_IO Stream Pointer Positioning::
13445 * Wide_Text_IO Reading and Writing Non-Regular Files::
13448 @node Wide_Text_IO Stream Pointer Positioning
13449 @subsection Stream Pointer Positioning
13452 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13453 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13456 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
13457 normal lower ASCII set (i.e.@: a character in the range:
13459 @smallexample @c ada
13460 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
13464 then although the logical position of the file pointer is unchanged by
13465 the @code{Look_Ahead} call, the stream is physically positioned past the
13466 wide character sequence. Again this is to avoid the need for buffering
13467 or backup, and all @code{Wide_Text_IO} routines check the internal
13468 indication that this situation has occurred so that this is not visible
13469 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
13470 can be observed if the wide text file shares a stream with another file.
13472 @node Wide_Text_IO Reading and Writing Non-Regular Files
13473 @subsection Reading and Writing Non-Regular Files
13476 As in the case of Text_IO, when a non-regular file is read, it is
13477 assumed that the file contains no page marks (any form characters are
13478 treated as data characters), and @code{End_Of_Page} always returns
13479 @code{False}. Similarly, the end of file indication is not sticky, so
13480 it is possible to read beyond an end of file.
13482 @node Wide_Wide_Text_IO
13483 @section Wide_Wide_Text_IO
13486 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
13487 both input and output files may contain special sequences that represent
13488 wide wide character values. The encoding scheme for a given file may be
13489 specified using a FORM parameter:
13496 as part of the FORM string (WCEM = wide character encoding method),
13497 where @var{x} is one of the following characters
13503 Upper half encoding
13515 The encoding methods match those that
13516 can be used in a source
13517 program, but there is no requirement that the encoding method used for
13518 the source program be the same as the encoding method used for files,
13519 and different files may use different encoding methods.
13521 The default encoding method for the standard files, and for opened files
13522 for which no WCEM parameter is given in the FORM string matches the
13523 wide character encoding specified for the main program (the default
13524 being brackets encoding if no coding method was specified with -gnatW).
13529 A wide character is represented using
13530 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13531 10646-1/Am.2. Depending on the character value, the representation
13532 is a one, two, three, or four byte sequence:
13535 16#000000#-16#00007f#: 2#0xxxxxxx#
13536 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
13537 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13538 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
13542 where the @var{xxx} bits correspond to the left-padded bits of the
13543 21-bit character value. Note that all lower half ASCII characters
13544 are represented as ASCII bytes and all upper half characters and
13545 other wide characters are represented as sequences of upper-half
13548 @item Brackets Coding
13549 In this encoding, a wide wide character is represented by the following eight
13550 character sequence if is in wide character range
13556 and by the following ten character sequence if not
13559 [ " a b c d e f " ]
13563 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
13564 are the four or six hexadecimal
13565 characters (using uppercase letters) of the wide wide character code. For
13566 example, @code{["01A345"]} is used to represent the wide wide character
13567 with code @code{16#01A345#}.
13569 This scheme is compatible with use of the full Wide_Wide_Character set.
13570 On input, brackets coding can also be used for upper half characters,
13571 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
13572 is only used for wide characters with a code greater than @code{16#FF#}.
13577 If is also possible to use the other Wide_Character encoding methods,
13578 such as Shift-JIS, but the other schemes cannot support the full range
13579 of wide wide characters.
13580 An attempt to output a character that cannot
13581 be represented using the encoding scheme for the file causes
13582 Constraint_Error to be raised. An invalid wide character sequence on
13583 input also causes Constraint_Error to be raised.
13586 * Wide_Wide_Text_IO Stream Pointer Positioning::
13587 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13590 @node Wide_Wide_Text_IO Stream Pointer Positioning
13591 @subsection Stream Pointer Positioning
13594 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13595 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13598 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13599 normal lower ASCII set (i.e.@: a character in the range:
13601 @smallexample @c ada
13602 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13606 then although the logical position of the file pointer is unchanged by
13607 the @code{Look_Ahead} call, the stream is physically positioned past the
13608 wide character sequence. Again this is to avoid the need for buffering
13609 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13610 indication that this situation has occurred so that this is not visible
13611 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
13612 can be observed if the wide text file shares a stream with another file.
13614 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13615 @subsection Reading and Writing Non-Regular Files
13618 As in the case of Text_IO, when a non-regular file is read, it is
13619 assumed that the file contains no page marks (any form characters are
13620 treated as data characters), and @code{End_Of_Page} always returns
13621 @code{False}. Similarly, the end of file indication is not sticky, so
13622 it is possible to read beyond an end of file.
13628 A stream file is a sequence of bytes, where individual elements are
13629 written to the file as described in the Ada Reference Manual. The type
13630 @code{Stream_Element} is simply a byte. There are two ways to read or
13631 write a stream file.
13635 The operations @code{Read} and @code{Write} directly read or write a
13636 sequence of stream elements with no control information.
13639 The stream attributes applied to a stream file transfer data in the
13640 manner described for stream attributes.
13643 @node Text Translation
13644 @section Text Translation
13647 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13648 passed to Text_IO.Create and Text_IO.Open:
13649 @samp{Text_Translation=@var{Yes}} is the default, which means to
13650 translate LF to/from CR/LF on Windows systems.
13651 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13652 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13653 may be used to create Unix-style files on
13654 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13658 @section Shared Files
13661 Section A.14 of the Ada Reference Manual allows implementations to
13662 provide a wide variety of behavior if an attempt is made to access the
13663 same external file with two or more internal files.
13665 To provide a full range of functionality, while at the same time
13666 minimizing the problems of portability caused by this implementation
13667 dependence, GNAT handles file sharing as follows:
13671 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13672 to open two or more files with the same full name is considered an error
13673 and is not supported. The exception @code{Use_Error} will be
13674 raised. Note that a file that is not explicitly closed by the program
13675 remains open until the program terminates.
13678 If the form parameter @samp{shared=no} appears in the form string, the
13679 file can be opened or created with its own separate stream identifier,
13680 regardless of whether other files sharing the same external file are
13681 opened. The exact effect depends on how the C stream routines handle
13682 multiple accesses to the same external files using separate streams.
13685 If the form parameter @samp{shared=yes} appears in the form string for
13686 each of two or more files opened using the same full name, the same
13687 stream is shared between these files, and the semantics are as described
13688 in Ada Reference Manual, Section A.14.
13692 When a program that opens multiple files with the same name is ported
13693 from another Ada compiler to GNAT, the effect will be that
13694 @code{Use_Error} is raised.
13696 The documentation of the original compiler and the documentation of the
13697 program should then be examined to determine if file sharing was
13698 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13699 and @code{Create} calls as required.
13701 When a program is ported from GNAT to some other Ada compiler, no
13702 special attention is required unless the @samp{shared=@var{xxx}} form
13703 parameter is used in the program. In this case, you must examine the
13704 documentation of the new compiler to see if it supports the required
13705 file sharing semantics, and form strings modified appropriately. Of
13706 course it may be the case that the program cannot be ported if the
13707 target compiler does not support the required functionality. The best
13708 approach in writing portable code is to avoid file sharing (and hence
13709 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13712 One common use of file sharing in Ada 83 is the use of instantiations of
13713 Sequential_IO on the same file with different types, to achieve
13714 heterogeneous input-output. Although this approach will work in GNAT if
13715 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13716 for this purpose (using the stream attributes)
13718 @node Filenames encoding
13719 @section Filenames encoding
13722 An encoding form parameter can be used to specify the filename
13723 encoding @samp{encoding=@var{xxx}}.
13727 If the form parameter @samp{encoding=utf8} appears in the form string, the
13728 filename must be encoded in UTF-8.
13731 If the form parameter @samp{encoding=8bits} appears in the form
13732 string, the filename must be a standard 8bits string.
13735 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13736 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13737 variable. And if not set @samp{utf8} is assumed.
13741 The current system Windows ANSI code page.
13746 This encoding form parameter is only supported on the Windows
13747 platform. On the other Operating Systems the run-time is supporting
13751 @section Open Modes
13754 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13755 using the mode shown in the following table:
13758 @center @code{Open} and @code{Create} Call Modes
13760 @b{OPEN } @b{CREATE}
13761 Append_File "r+" "w+"
13763 Out_File (Direct_IO) "r+" "w"
13764 Out_File (all other cases) "w" "w"
13765 Inout_File "r+" "w+"
13769 If text file translation is required, then either @samp{b} or @samp{t}
13770 is added to the mode, depending on the setting of Text. Text file
13771 translation refers to the mapping of CR/LF sequences in an external file
13772 to LF characters internally. This mapping only occurs in DOS and
13773 DOS-like systems, and is not relevant to other systems.
13775 A special case occurs with Stream_IO@. As shown in the above table, the
13776 file is initially opened in @samp{r} or @samp{w} mode for the
13777 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
13778 subsequently requires switching from reading to writing or vice-versa,
13779 then the file is reopened in @samp{r+} mode to permit the required operation.
13781 @node Operations on C Streams
13782 @section Operations on C Streams
13783 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13784 access to the C library functions for operations on C streams:
13786 @smallexample @c adanocomment
13787 package Interfaces.C_Streams is
13788 -- Note: the reason we do not use the types that are in
13789 -- Interfaces.C is that we want to avoid dragging in the
13790 -- code in this unit if possible.
13791 subtype chars is System.Address;
13792 -- Pointer to null-terminated array of characters
13793 subtype FILEs is System.Address;
13794 -- Corresponds to the C type FILE*
13795 subtype voids is System.Address;
13796 -- Corresponds to the C type void*
13797 subtype int is Integer;
13798 subtype long is Long_Integer;
13799 -- Note: the above types are subtypes deliberately, and it
13800 -- is part of this spec that the above correspondences are
13801 -- guaranteed. This means that it is legitimate to, for
13802 -- example, use Integer instead of int. We provide these
13803 -- synonyms for clarity, but in some cases it may be
13804 -- convenient to use the underlying types (for example to
13805 -- avoid an unnecessary dependency of a spec on the spec
13807 type size_t is mod 2 ** Standard'Address_Size;
13808 NULL_Stream : constant FILEs;
13809 -- Value returned (NULL in C) to indicate an
13810 -- fdopen/fopen/tmpfile error
13811 ----------------------------------
13812 -- Constants Defined in stdio.h --
13813 ----------------------------------
13814 EOF : constant int;
13815 -- Used by a number of routines to indicate error or
13817 IOFBF : constant int;
13818 IOLBF : constant int;
13819 IONBF : constant int;
13820 -- Used to indicate buffering mode for setvbuf call
13821 SEEK_CUR : constant int;
13822 SEEK_END : constant int;
13823 SEEK_SET : constant int;
13824 -- Used to indicate origin for fseek call
13825 function stdin return FILEs;
13826 function stdout return FILEs;
13827 function stderr return FILEs;
13828 -- Streams associated with standard files
13829 --------------------------
13830 -- Standard C functions --
13831 --------------------------
13832 -- The functions selected below are ones that are
13833 -- available in UNIX (but not necessarily in ANSI C).
13834 -- These are very thin interfaces
13835 -- which copy exactly the C headers. For more
13836 -- documentation on these functions, see the Microsoft C
13837 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13838 -- ISBN 1-55615-225-6), which includes useful information
13839 -- on system compatibility.
13840 procedure clearerr (stream : FILEs);
13841 function fclose (stream : FILEs) return int;
13842 function fdopen (handle : int; mode : chars) return FILEs;
13843 function feof (stream : FILEs) return int;
13844 function ferror (stream : FILEs) return int;
13845 function fflush (stream : FILEs) return int;
13846 function fgetc (stream : FILEs) return int;
13847 function fgets (strng : chars; n : int; stream : FILEs)
13849 function fileno (stream : FILEs) return int;
13850 function fopen (filename : chars; Mode : chars)
13852 -- Note: to maintain target independence, use
13853 -- text_translation_required, a boolean variable defined in
13854 -- a-sysdep.c to deal with the target dependent text
13855 -- translation requirement. If this variable is set,
13856 -- then b/t should be appended to the standard mode
13857 -- argument to set the text translation mode off or on
13859 function fputc (C : int; stream : FILEs) return int;
13860 function fputs (Strng : chars; Stream : FILEs) return int;
13877 function ftell (stream : FILEs) return long;
13884 function isatty (handle : int) return int;
13885 procedure mktemp (template : chars);
13886 -- The return value (which is just a pointer to template)
13888 procedure rewind (stream : FILEs);
13889 function rmtmp return int;
13897 function tmpfile return FILEs;
13898 function ungetc (c : int; stream : FILEs) return int;
13899 function unlink (filename : chars) return int;
13900 ---------------------
13901 -- Extra functions --
13902 ---------------------
13903 -- These functions supply slightly thicker bindings than
13904 -- those above. They are derived from functions in the
13905 -- C Run-Time Library, but may do a bit more work than
13906 -- just directly calling one of the Library functions.
13907 function is_regular_file (handle : int) return int;
13908 -- Tests if given handle is for a regular file (result 1)
13909 -- or for a non-regular file (pipe or device, result 0).
13910 ---------------------------------
13911 -- Control of Text/Binary Mode --
13912 ---------------------------------
13913 -- If text_translation_required is true, then the following
13914 -- functions may be used to dynamically switch a file from
13915 -- binary to text mode or vice versa. These functions have
13916 -- no effect if text_translation_required is false (i.e.@: in
13917 -- normal UNIX mode). Use fileno to get a stream handle.
13918 procedure set_binary_mode (handle : int);
13919 procedure set_text_mode (handle : int);
13920 ----------------------------
13921 -- Full Path Name support --
13922 ----------------------------
13923 procedure full_name (nam : chars; buffer : chars);
13924 -- Given a NUL terminated string representing a file
13925 -- name, returns in buffer a NUL terminated string
13926 -- representing the full path name for the file name.
13927 -- On systems where it is relevant the drive is also
13928 -- part of the full path name. It is the responsibility
13929 -- of the caller to pass an actual parameter for buffer
13930 -- that is big enough for any full path name. Use
13931 -- max_path_len given below as the size of buffer.
13932 max_path_len : integer;
13933 -- Maximum length of an allowable full path name on the
13934 -- system, including a terminating NUL character.
13935 end Interfaces.C_Streams;
13938 @node Interfacing to C Streams
13939 @section Interfacing to C Streams
13942 The packages in this section permit interfacing Ada files to C Stream
13945 @smallexample @c ada
13946 with Interfaces.C_Streams;
13947 package Ada.Sequential_IO.C_Streams is
13948 function C_Stream (F : File_Type)
13949 return Interfaces.C_Streams.FILEs;
13951 (File : in out File_Type;
13952 Mode : in File_Mode;
13953 C_Stream : in Interfaces.C_Streams.FILEs;
13954 Form : in String := "");
13955 end Ada.Sequential_IO.C_Streams;
13957 with Interfaces.C_Streams;
13958 package Ada.Direct_IO.C_Streams is
13959 function C_Stream (F : File_Type)
13960 return Interfaces.C_Streams.FILEs;
13962 (File : in out File_Type;
13963 Mode : in File_Mode;
13964 C_Stream : in Interfaces.C_Streams.FILEs;
13965 Form : in String := "");
13966 end Ada.Direct_IO.C_Streams;
13968 with Interfaces.C_Streams;
13969 package Ada.Text_IO.C_Streams is
13970 function C_Stream (F : File_Type)
13971 return Interfaces.C_Streams.FILEs;
13973 (File : in out File_Type;
13974 Mode : in File_Mode;
13975 C_Stream : in Interfaces.C_Streams.FILEs;
13976 Form : in String := "");
13977 end Ada.Text_IO.C_Streams;
13979 with Interfaces.C_Streams;
13980 package Ada.Wide_Text_IO.C_Streams is
13981 function C_Stream (F : File_Type)
13982 return Interfaces.C_Streams.FILEs;
13984 (File : in out File_Type;
13985 Mode : in File_Mode;
13986 C_Stream : in Interfaces.C_Streams.FILEs;
13987 Form : in String := "");
13988 end Ada.Wide_Text_IO.C_Streams;
13990 with Interfaces.C_Streams;
13991 package Ada.Wide_Wide_Text_IO.C_Streams is
13992 function C_Stream (F : File_Type)
13993 return Interfaces.C_Streams.FILEs;
13995 (File : in out File_Type;
13996 Mode : in File_Mode;
13997 C_Stream : in Interfaces.C_Streams.FILEs;
13998 Form : in String := "");
13999 end Ada.Wide_Wide_Text_IO.C_Streams;
14001 with Interfaces.C_Streams;
14002 package Ada.Stream_IO.C_Streams is
14003 function C_Stream (F : File_Type)
14004 return Interfaces.C_Streams.FILEs;
14006 (File : in out File_Type;
14007 Mode : in File_Mode;
14008 C_Stream : in Interfaces.C_Streams.FILEs;
14009 Form : in String := "");
14010 end Ada.Stream_IO.C_Streams;
14014 In each of these six packages, the @code{C_Stream} function obtains the
14015 @code{FILE} pointer from a currently opened Ada file. It is then
14016 possible to use the @code{Interfaces.C_Streams} package to operate on
14017 this stream, or the stream can be passed to a C program which can
14018 operate on it directly. Of course the program is responsible for
14019 ensuring that only appropriate sequences of operations are executed.
14021 One particular use of relevance to an Ada program is that the
14022 @code{setvbuf} function can be used to control the buffering of the
14023 stream used by an Ada file. In the absence of such a call the standard
14024 default buffering is used.
14026 The @code{Open} procedures in these packages open a file giving an
14027 existing C Stream instead of a file name. Typically this stream is
14028 imported from a C program, allowing an Ada file to operate on an
14031 @node The GNAT Library
14032 @chapter The GNAT Library
14035 The GNAT library contains a number of general and special purpose packages.
14036 It represents functionality that the GNAT developers have found useful, and
14037 which is made available to GNAT users. The packages described here are fully
14038 supported, and upwards compatibility will be maintained in future releases,
14039 so you can use these facilities with the confidence that the same functionality
14040 will be available in future releases.
14042 The chapter here simply gives a brief summary of the facilities available.
14043 The full documentation is found in the spec file for the package. The full
14044 sources of these library packages, including both spec and body, are provided
14045 with all GNAT releases. For example, to find out the full specifications of
14046 the SPITBOL pattern matching capability, including a full tutorial and
14047 extensive examples, look in the @file{g-spipat.ads} file in the library.
14049 For each entry here, the package name (as it would appear in a @code{with}
14050 clause) is given, followed by the name of the corresponding spec file in
14051 parentheses. The packages are children in four hierarchies, @code{Ada},
14052 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
14053 GNAT-specific hierarchy.
14055 Note that an application program should only use packages in one of these
14056 four hierarchies if the package is defined in the Ada Reference Manual,
14057 or is listed in this section of the GNAT Programmers Reference Manual.
14058 All other units should be considered internal implementation units and
14059 should not be directly @code{with}'ed by application code. The use of
14060 a @code{with} statement that references one of these internal implementation
14061 units makes an application potentially dependent on changes in versions
14062 of GNAT, and will generate a warning message.
14065 * Ada.Characters.Latin_9 (a-chlat9.ads)::
14066 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
14067 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
14068 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
14069 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
14070 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
14071 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
14072 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
14073 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
14074 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
14075 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
14076 * Ada.Command_Line.Environment (a-colien.ads)::
14077 * Ada.Command_Line.Remove (a-colire.ads)::
14078 * Ada.Command_Line.Response_File (a-clrefi.ads)::
14079 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
14080 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
14081 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
14082 * Ada.Exceptions.Traceback (a-exctra.ads)::
14083 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
14084 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
14085 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
14086 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
14087 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
14088 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
14089 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
14090 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
14091 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
14092 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
14093 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
14094 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
14095 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
14096 * GNAT.Altivec (g-altive.ads)::
14097 * GNAT.Altivec.Conversions (g-altcon.ads)::
14098 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
14099 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
14100 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
14101 * GNAT.Array_Split (g-arrspl.ads)::
14102 * GNAT.AWK (g-awk.ads)::
14103 * GNAT.Bounded_Buffers (g-boubuf.ads)::
14104 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
14105 * GNAT.Bubble_Sort (g-bubsor.ads)::
14106 * GNAT.Bubble_Sort_A (g-busora.ads)::
14107 * GNAT.Bubble_Sort_G (g-busorg.ads)::
14108 * GNAT.Byte_Order_Mark (g-byorma.ads)::
14109 * GNAT.Byte_Swapping (g-bytswa.ads)::
14110 * GNAT.Calendar (g-calend.ads)::
14111 * GNAT.Calendar.Time_IO (g-catiio.ads)::
14112 * GNAT.Case_Util (g-casuti.ads)::
14113 * GNAT.CGI (g-cgi.ads)::
14114 * GNAT.CGI.Cookie (g-cgicoo.ads)::
14115 * GNAT.CGI.Debug (g-cgideb.ads)::
14116 * GNAT.Command_Line (g-comlin.ads)::
14117 * GNAT.Compiler_Version (g-comver.ads)::
14118 * GNAT.Ctrl_C (g-ctrl_c.ads)::
14119 * GNAT.CRC32 (g-crc32.ads)::
14120 * GNAT.Current_Exception (g-curexc.ads)::
14121 * GNAT.Debug_Pools (g-debpoo.ads)::
14122 * GNAT.Debug_Utilities (g-debuti.ads)::
14123 * GNAT.Decode_String (g-decstr.ads)::
14124 * GNAT.Decode_UTF8_String (g-deutst.ads)::
14125 * GNAT.Directory_Operations (g-dirope.ads)::
14126 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
14127 * GNAT.Dynamic_HTables (g-dynhta.ads)::
14128 * GNAT.Dynamic_Tables (g-dyntab.ads)::
14129 * GNAT.Encode_String (g-encstr.ads)::
14130 * GNAT.Encode_UTF8_String (g-enutst.ads)::
14131 * GNAT.Exception_Actions (g-excact.ads)::
14132 * GNAT.Exception_Traces (g-exctra.ads)::
14133 * GNAT.Exceptions (g-except.ads)::
14134 * GNAT.Expect (g-expect.ads)::
14135 * GNAT.Float_Control (g-flocon.ads)::
14136 * GNAT.Heap_Sort (g-heasor.ads)::
14137 * GNAT.Heap_Sort_A (g-hesora.ads)::
14138 * GNAT.Heap_Sort_G (g-hesorg.ads)::
14139 * GNAT.HTable (g-htable.ads)::
14140 * GNAT.IO (g-io.ads)::
14141 * GNAT.IO_Aux (g-io_aux.ads)::
14142 * GNAT.Lock_Files (g-locfil.ads)::
14143 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
14144 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
14145 * GNAT.MD5 (g-md5.ads)::
14146 * GNAT.Memory_Dump (g-memdum.ads)::
14147 * GNAT.Most_Recent_Exception (g-moreex.ads)::
14148 * GNAT.OS_Lib (g-os_lib.ads)::
14149 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
14150 * GNAT.Random_Numbers (g-rannum.ads)::
14151 * GNAT.Regexp (g-regexp.ads)::
14152 * GNAT.Registry (g-regist.ads)::
14153 * GNAT.Regpat (g-regpat.ads)::
14154 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
14155 * GNAT.Semaphores (g-semaph.ads)::
14156 * GNAT.Serial_Communications (g-sercom.ads)::
14157 * GNAT.SHA1 (g-sha1.ads)::
14158 * GNAT.SHA224 (g-sha224.ads)::
14159 * GNAT.SHA256 (g-sha256.ads)::
14160 * GNAT.SHA384 (g-sha384.ads)::
14161 * GNAT.SHA512 (g-sha512.ads)::
14162 * GNAT.Signals (g-signal.ads)::
14163 * GNAT.Sockets (g-socket.ads)::
14164 * GNAT.Source_Info (g-souinf.ads)::
14165 * GNAT.Spelling_Checker (g-speche.ads)::
14166 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
14167 * GNAT.Spitbol.Patterns (g-spipat.ads)::
14168 * GNAT.Spitbol (g-spitbo.ads)::
14169 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
14170 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
14171 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
14172 * GNAT.SSE (g-sse.ads)::
14173 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
14174 * GNAT.Strings (g-string.ads)::
14175 * GNAT.String_Split (g-strspl.ads)::
14176 * GNAT.Table (g-table.ads)::
14177 * GNAT.Task_Lock (g-tasloc.ads)::
14178 * GNAT.Threads (g-thread.ads)::
14179 * GNAT.Time_Stamp (g-timsta.ads)::
14180 * GNAT.Traceback (g-traceb.ads)::
14181 * GNAT.Traceback.Symbolic (g-trasym.ads)::
14182 * GNAT.UTF_32 (g-utf_32.ads)::
14183 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
14184 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
14185 * GNAT.Wide_String_Split (g-wistsp.ads)::
14186 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
14187 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
14188 * Interfaces.C.Extensions (i-cexten.ads)::
14189 * Interfaces.C.Streams (i-cstrea.ads)::
14190 * Interfaces.CPP (i-cpp.ads)::
14191 * Interfaces.Packed_Decimal (i-pacdec.ads)::
14192 * Interfaces.VxWorks (i-vxwork.ads)::
14193 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
14194 * System.Address_Image (s-addima.ads)::
14195 * System.Assertions (s-assert.ads)::
14196 * System.Memory (s-memory.ads)::
14197 * System.Partition_Interface (s-parint.ads)::
14198 * System.Pool_Global (s-pooglo.ads)::
14199 * System.Pool_Local (s-pooloc.ads)::
14200 * System.Restrictions (s-restri.ads)::
14201 * System.Rident (s-rident.ads)::
14202 * System.Strings.Stream_Ops (s-ststop.ads)::
14203 * System.Task_Info (s-tasinf.ads)::
14204 * System.Wch_Cnv (s-wchcnv.ads)::
14205 * System.Wch_Con (s-wchcon.ads)::
14208 @node Ada.Characters.Latin_9 (a-chlat9.ads)
14209 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14210 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14211 @cindex Latin_9 constants for Character
14214 This child of @code{Ada.Characters}
14215 provides a set of definitions corresponding to those in the
14216 RM-defined package @code{Ada.Characters.Latin_1} but with the
14217 few modifications required for @code{Latin-9}
14218 The provision of such a package
14219 is specifically authorized by the Ada Reference Manual
14222 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
14223 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14224 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14225 @cindex Latin_1 constants for Wide_Character
14228 This child of @code{Ada.Characters}
14229 provides a set of definitions corresponding to those in the
14230 RM-defined package @code{Ada.Characters.Latin_1} but with the
14231 types of the constants being @code{Wide_Character}
14232 instead of @code{Character}. The provision of such a package
14233 is specifically authorized by the Ada Reference Manual
14236 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
14237 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14238 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14239 @cindex Latin_9 constants for Wide_Character
14242 This child of @code{Ada.Characters}
14243 provides a set of definitions corresponding to those in the
14244 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14245 types of the constants being @code{Wide_Character}
14246 instead of @code{Character}. The provision of such a package
14247 is specifically authorized by the Ada Reference Manual
14250 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
14251 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14252 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14253 @cindex Latin_1 constants for Wide_Wide_Character
14256 This child of @code{Ada.Characters}
14257 provides a set of definitions corresponding to those in the
14258 RM-defined package @code{Ada.Characters.Latin_1} but with the
14259 types of the constants being @code{Wide_Wide_Character}
14260 instead of @code{Character}. The provision of such a package
14261 is specifically authorized by the Ada Reference Manual
14264 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
14265 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14266 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14267 @cindex Latin_9 constants for Wide_Wide_Character
14270 This child of @code{Ada.Characters}
14271 provides a set of definitions corresponding to those in the
14272 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14273 types of the constants being @code{Wide_Wide_Character}
14274 instead of @code{Character}. The provision of such a package
14275 is specifically authorized by the Ada Reference Manual
14278 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
14279 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14280 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14281 @cindex Formal container for doubly linked lists
14284 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14285 container for doubly linked lists, meant to facilitate formal verification of
14286 code using such containers.
14288 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
14289 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14290 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14291 @cindex Formal container for hashed maps
14294 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14295 container for hashed maps, meant to facilitate formal verification of
14296 code using such containers.
14298 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
14299 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14300 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14301 @cindex Formal container for hashed sets
14304 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14305 container for hashed sets, meant to facilitate formal verification of
14306 code using such containers.
14308 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
14309 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14310 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14311 @cindex Formal container for ordered maps
14314 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14315 container for ordered maps, meant to facilitate formal verification of
14316 code using such containers.
14318 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
14319 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14320 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14321 @cindex Formal container for ordered sets
14324 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14325 container for ordered sets, meant to facilitate formal verification of
14326 code using such containers.
14328 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
14329 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14330 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14331 @cindex Formal container for vectors
14334 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14335 container for vectors, meant to facilitate formal verification of
14336 code using such containers.
14338 @node Ada.Command_Line.Environment (a-colien.ads)
14339 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14340 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14341 @cindex Environment entries
14344 This child of @code{Ada.Command_Line}
14345 provides a mechanism for obtaining environment values on systems
14346 where this concept makes sense.
14348 @node Ada.Command_Line.Remove (a-colire.ads)
14349 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14350 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14351 @cindex Removing command line arguments
14352 @cindex Command line, argument removal
14355 This child of @code{Ada.Command_Line}
14356 provides a mechanism for logically removing
14357 arguments from the argument list. Once removed, an argument is not visible
14358 to further calls on the subprograms in @code{Ada.Command_Line} will not
14359 see the removed argument.
14361 @node Ada.Command_Line.Response_File (a-clrefi.ads)
14362 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14363 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14364 @cindex Response file for command line
14365 @cindex Command line, response file
14366 @cindex Command line, handling long command lines
14369 This child of @code{Ada.Command_Line} provides a mechanism facilities for
14370 getting command line arguments from a text file, called a "response file".
14371 Using a response file allow passing a set of arguments to an executable longer
14372 than the maximum allowed by the system on the command line.
14374 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
14375 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14376 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14377 @cindex C Streams, Interfacing with Direct_IO
14380 This package provides subprograms that allow interfacing between
14381 C streams and @code{Direct_IO}. The stream identifier can be
14382 extracted from a file opened on the Ada side, and an Ada file
14383 can be constructed from a stream opened on the C side.
14385 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
14386 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14387 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14388 @cindex Null_Occurrence, testing for
14391 This child subprogram provides a way of testing for the null
14392 exception occurrence (@code{Null_Occurrence}) without raising
14395 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
14396 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14397 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14398 @cindex Null_Occurrence, testing for
14401 This child subprogram is used for handling otherwise unhandled
14402 exceptions (hence the name last chance), and perform clean ups before
14403 terminating the program. Note that this subprogram never returns.
14405 @node Ada.Exceptions.Traceback (a-exctra.ads)
14406 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14407 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14408 @cindex Traceback for Exception Occurrence
14411 This child package provides the subprogram (@code{Tracebacks}) to
14412 give a traceback array of addresses based on an exception
14415 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
14416 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14417 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14418 @cindex C Streams, Interfacing with Sequential_IO
14421 This package provides subprograms that allow interfacing between
14422 C streams and @code{Sequential_IO}. The stream identifier can be
14423 extracted from a file opened on the Ada side, and an Ada file
14424 can be constructed from a stream opened on the C side.
14426 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
14427 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14428 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14429 @cindex C Streams, Interfacing with Stream_IO
14432 This package provides subprograms that allow interfacing between
14433 C streams and @code{Stream_IO}. The stream identifier can be
14434 extracted from a file opened on the Ada side, and an Ada file
14435 can be constructed from a stream opened on the C side.
14437 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
14438 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14439 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14440 @cindex @code{Unbounded_String}, IO support
14441 @cindex @code{Text_IO}, extensions for unbounded strings
14444 This package provides subprograms for Text_IO for unbounded
14445 strings, avoiding the necessity for an intermediate operation
14446 with ordinary strings.
14448 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
14449 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14450 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14451 @cindex @code{Unbounded_Wide_String}, IO support
14452 @cindex @code{Text_IO}, extensions for unbounded wide strings
14455 This package provides subprograms for Text_IO for unbounded
14456 wide strings, avoiding the necessity for an intermediate operation
14457 with ordinary wide strings.
14459 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
14460 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14461 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14462 @cindex @code{Unbounded_Wide_Wide_String}, IO support
14463 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
14466 This package provides subprograms for Text_IO for unbounded
14467 wide wide strings, avoiding the necessity for an intermediate operation
14468 with ordinary wide wide strings.
14470 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
14471 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14472 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14473 @cindex C Streams, Interfacing with @code{Text_IO}
14476 This package provides subprograms that allow interfacing between
14477 C streams and @code{Text_IO}. The stream identifier can be
14478 extracted from a file opened on the Ada side, and an Ada file
14479 can be constructed from a stream opened on the C side.
14481 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
14482 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14483 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14484 @cindex @code{Text_IO} resetting standard files
14487 This procedure is used to reset the status of the standard files used
14488 by Ada.Text_IO. This is useful in a situation (such as a restart in an
14489 embedded application) where the status of the files may change during
14490 execution (for example a standard input file may be redefined to be
14493 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
14494 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14495 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14496 @cindex Unicode categorization, Wide_Character
14499 This package provides subprograms that allow categorization of
14500 Wide_Character values according to Unicode categories.
14502 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
14503 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14504 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14505 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
14508 This package provides subprograms that allow interfacing between
14509 C streams and @code{Wide_Text_IO}. The stream identifier can be
14510 extracted from a file opened on the Ada side, and an Ada file
14511 can be constructed from a stream opened on the C side.
14513 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
14514 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14515 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14516 @cindex @code{Wide_Text_IO} resetting standard files
14519 This procedure is used to reset the status of the standard files used
14520 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
14521 embedded application) where the status of the files may change during
14522 execution (for example a standard input file may be redefined to be
14525 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
14526 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14527 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14528 @cindex Unicode categorization, Wide_Wide_Character
14531 This package provides subprograms that allow categorization of
14532 Wide_Wide_Character values according to Unicode categories.
14534 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
14535 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14536 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14537 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
14540 This package provides subprograms that allow interfacing between
14541 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
14542 extracted from a file opened on the Ada side, and an Ada file
14543 can be constructed from a stream opened on the C side.
14545 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
14546 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14547 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14548 @cindex @code{Wide_Wide_Text_IO} resetting standard files
14551 This procedure is used to reset the status of the standard files used
14552 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
14553 restart in an embedded application) where the status of the files may
14554 change during execution (for example a standard input file may be
14555 redefined to be interactive).
14557 @node GNAT.Altivec (g-altive.ads)
14558 @section @code{GNAT.Altivec} (@file{g-altive.ads})
14559 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
14563 This is the root package of the GNAT AltiVec binding. It provides
14564 definitions of constants and types common to all the versions of the
14567 @node GNAT.Altivec.Conversions (g-altcon.ads)
14568 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14569 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14573 This package provides the Vector/View conversion routines.
14575 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
14576 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14577 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14581 This package exposes the Ada interface to the AltiVec operations on
14582 vector objects. A soft emulation is included by default in the GNAT
14583 library. The hard binding is provided as a separate package. This unit
14584 is common to both bindings.
14586 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
14587 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14588 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14592 This package exposes the various vector types part of the Ada binding
14593 to AltiVec facilities.
14595 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
14596 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14597 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14601 This package provides public 'View' data types from/to which private
14602 vector representations can be converted via
14603 GNAT.Altivec.Conversions. This allows convenient access to individual
14604 vector elements and provides a simple way to initialize vector
14607 @node GNAT.Array_Split (g-arrspl.ads)
14608 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14609 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14610 @cindex Array splitter
14613 Useful array-manipulation routines: given a set of separators, split
14614 an array wherever the separators appear, and provide direct access
14615 to the resulting slices.
14617 @node GNAT.AWK (g-awk.ads)
14618 @section @code{GNAT.AWK} (@file{g-awk.ads})
14619 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
14624 Provides AWK-like parsing functions, with an easy interface for parsing one
14625 or more files containing formatted data. The file is viewed as a database
14626 where each record is a line and a field is a data element in this line.
14628 @node GNAT.Bounded_Buffers (g-boubuf.ads)
14629 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14630 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14632 @cindex Bounded Buffers
14635 Provides a concurrent generic bounded buffer abstraction. Instances are
14636 useful directly or as parts of the implementations of other abstractions,
14639 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
14640 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14641 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14646 Provides a thread-safe asynchronous intertask mailbox communication facility.
14648 @node GNAT.Bubble_Sort (g-bubsor.ads)
14649 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14650 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14652 @cindex Bubble sort
14655 Provides a general implementation of bubble sort usable for sorting arbitrary
14656 data items. Exchange and comparison procedures are provided by passing
14657 access-to-procedure values.
14659 @node GNAT.Bubble_Sort_A (g-busora.ads)
14660 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14661 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14663 @cindex Bubble sort
14666 Provides a general implementation of bubble sort usable for sorting arbitrary
14667 data items. Move and comparison procedures are provided by passing
14668 access-to-procedure values. This is an older version, retained for
14669 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14671 @node GNAT.Bubble_Sort_G (g-busorg.ads)
14672 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14673 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14675 @cindex Bubble sort
14678 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14679 are provided as generic parameters, this improves efficiency, especially
14680 if the procedures can be inlined, at the expense of duplicating code for
14681 multiple instantiations.
14683 @node GNAT.Byte_Order_Mark (g-byorma.ads)
14684 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14685 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14686 @cindex UTF-8 representation
14687 @cindex Wide characte representations
14690 Provides a routine which given a string, reads the start of the string to
14691 see whether it is one of the standard byte order marks (BOM's) which signal
14692 the encoding of the string. The routine includes detection of special XML
14693 sequences for various UCS input formats.
14695 @node GNAT.Byte_Swapping (g-bytswa.ads)
14696 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14697 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14698 @cindex Byte swapping
14702 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14703 Machine-specific implementations are available in some cases.
14705 @node GNAT.Calendar (g-calend.ads)
14706 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14707 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14708 @cindex @code{Calendar}
14711 Extends the facilities provided by @code{Ada.Calendar} to include handling
14712 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14713 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14714 C @code{timeval} format.
14716 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14717 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14718 @cindex @code{Calendar}
14720 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14722 @node GNAT.CRC32 (g-crc32.ads)
14723 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14724 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14726 @cindex Cyclic Redundancy Check
14729 This package implements the CRC-32 algorithm. For a full description
14730 of this algorithm see
14731 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14732 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14733 Aug.@: 1988. Sarwate, D.V@.
14735 @node GNAT.Case_Util (g-casuti.ads)
14736 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14737 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14738 @cindex Casing utilities
14739 @cindex Character handling (@code{GNAT.Case_Util})
14742 A set of simple routines for handling upper and lower casing of strings
14743 without the overhead of the full casing tables
14744 in @code{Ada.Characters.Handling}.
14746 @node GNAT.CGI (g-cgi.ads)
14747 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14748 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14749 @cindex CGI (Common Gateway Interface)
14752 This is a package for interfacing a GNAT program with a Web server via the
14753 Common Gateway Interface (CGI)@. Basically this package parses the CGI
14754 parameters, which are a set of key/value pairs sent by the Web server. It
14755 builds a table whose index is the key and provides some services to deal
14758 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14759 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14760 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14761 @cindex CGI (Common Gateway Interface) cookie support
14762 @cindex Cookie support in CGI
14765 This is a package to interface a GNAT program with a Web server via the
14766 Common Gateway Interface (CGI). It exports services to deal with Web
14767 cookies (piece of information kept in the Web client software).
14769 @node GNAT.CGI.Debug (g-cgideb.ads)
14770 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14771 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14772 @cindex CGI (Common Gateway Interface) debugging
14775 This is a package to help debugging CGI (Common Gateway Interface)
14776 programs written in Ada.
14778 @node GNAT.Command_Line (g-comlin.ads)
14779 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14780 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14781 @cindex Command line
14784 Provides a high level interface to @code{Ada.Command_Line} facilities,
14785 including the ability to scan for named switches with optional parameters
14786 and expand file names using wild card notations.
14788 @node GNAT.Compiler_Version (g-comver.ads)
14789 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14790 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14791 @cindex Compiler Version
14792 @cindex Version, of compiler
14795 Provides a routine for obtaining the version of the compiler used to
14796 compile the program. More accurately this is the version of the binder
14797 used to bind the program (this will normally be the same as the version
14798 of the compiler if a consistent tool set is used to compile all units
14801 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14802 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14803 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14807 Provides a simple interface to handle Ctrl-C keyboard events.
14809 @node GNAT.Current_Exception (g-curexc.ads)
14810 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14811 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14812 @cindex Current exception
14813 @cindex Exception retrieval
14816 Provides access to information on the current exception that has been raised
14817 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14818 specification syntax.
14819 This is particularly useful in simulating typical facilities for
14820 obtaining information about exceptions provided by Ada 83 compilers.
14822 @node GNAT.Debug_Pools (g-debpoo.ads)
14823 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14824 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14826 @cindex Debug pools
14827 @cindex Memory corruption debugging
14830 Provide a debugging storage pools that helps tracking memory corruption
14831 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14832 @value{EDITION} User's Guide}.
14834 @node GNAT.Debug_Utilities (g-debuti.ads)
14835 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14836 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14840 Provides a few useful utilities for debugging purposes, including conversion
14841 to and from string images of address values. Supports both C and Ada formats
14842 for hexadecimal literals.
14844 @node GNAT.Decode_String (g-decstr.ads)
14845 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14846 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14847 @cindex Decoding strings
14848 @cindex String decoding
14849 @cindex Wide character encoding
14854 A generic package providing routines for decoding wide character and wide wide
14855 character strings encoded as sequences of 8-bit characters using a specified
14856 encoding method. Includes validation routines, and also routines for stepping
14857 to next or previous encoded character in an encoded string.
14858 Useful in conjunction with Unicode character coding. Note there is a
14859 preinstantiation for UTF-8. See next entry.
14861 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14862 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14863 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14864 @cindex Decoding strings
14865 @cindex Decoding UTF-8 strings
14866 @cindex UTF-8 string decoding
14867 @cindex Wide character decoding
14872 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14874 @node GNAT.Directory_Operations (g-dirope.ads)
14875 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14876 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14877 @cindex Directory operations
14880 Provides a set of routines for manipulating directories, including changing
14881 the current directory, making new directories, and scanning the files in a
14884 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14885 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14886 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14887 @cindex Directory operations iteration
14890 A child unit of GNAT.Directory_Operations providing additional operations
14891 for iterating through directories.
14893 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14894 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14895 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14896 @cindex Hash tables
14899 A generic implementation of hash tables that can be used to hash arbitrary
14900 data. Provided in two forms, a simple form with built in hash functions,
14901 and a more complex form in which the hash function is supplied.
14904 This package provides a facility similar to that of @code{GNAT.HTable},
14905 except that this package declares a type that can be used to define
14906 dynamic instances of the hash table, while an instantiation of
14907 @code{GNAT.HTable} creates a single instance of the hash table.
14909 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14910 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14911 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14912 @cindex Table implementation
14913 @cindex Arrays, extendable
14916 A generic package providing a single dimension array abstraction where the
14917 length of the array can be dynamically modified.
14920 This package provides a facility similar to that of @code{GNAT.Table},
14921 except that this package declares a type that can be used to define
14922 dynamic instances of the table, while an instantiation of
14923 @code{GNAT.Table} creates a single instance of the table type.
14925 @node GNAT.Encode_String (g-encstr.ads)
14926 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14927 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14928 @cindex Encoding strings
14929 @cindex String encoding
14930 @cindex Wide character encoding
14935 A generic package providing routines for encoding wide character and wide
14936 wide character strings as sequences of 8-bit characters using a specified
14937 encoding method. Useful in conjunction with Unicode character coding.
14938 Note there is a preinstantiation for UTF-8. See next entry.
14940 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14941 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14942 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14943 @cindex Encoding strings
14944 @cindex Encoding UTF-8 strings
14945 @cindex UTF-8 string encoding
14946 @cindex Wide character encoding
14951 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14953 @node GNAT.Exception_Actions (g-excact.ads)
14954 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14955 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14956 @cindex Exception actions
14959 Provides callbacks when an exception is raised. Callbacks can be registered
14960 for specific exceptions, or when any exception is raised. This
14961 can be used for instance to force a core dump to ease debugging.
14963 @node GNAT.Exception_Traces (g-exctra.ads)
14964 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14965 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14966 @cindex Exception traces
14970 Provides an interface allowing to control automatic output upon exception
14973 @node GNAT.Exceptions (g-except.ads)
14974 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14975 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14976 @cindex Exceptions, Pure
14977 @cindex Pure packages, exceptions
14980 Normally it is not possible to raise an exception with
14981 a message from a subprogram in a pure package, since the
14982 necessary types and subprograms are in @code{Ada.Exceptions}
14983 which is not a pure unit. @code{GNAT.Exceptions} provides a
14984 facility for getting around this limitation for a few
14985 predefined exceptions, and for example allow raising
14986 @code{Constraint_Error} with a message from a pure subprogram.
14988 @node GNAT.Expect (g-expect.ads)
14989 @section @code{GNAT.Expect} (@file{g-expect.ads})
14990 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14993 Provides a set of subprograms similar to what is available
14994 with the standard Tcl Expect tool.
14995 It allows you to easily spawn and communicate with an external process.
14996 You can send commands or inputs to the process, and compare the output
14997 with some expected regular expression. Currently @code{GNAT.Expect}
14998 is implemented on all native GNAT ports except for OpenVMS@.
14999 It is not implemented for cross ports, and in particular is not
15000 implemented for VxWorks or LynxOS@.
15002 @node GNAT.Float_Control (g-flocon.ads)
15003 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
15004 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
15005 @cindex Floating-Point Processor
15008 Provides an interface for resetting the floating-point processor into the
15009 mode required for correct semantic operation in Ada. Some third party
15010 library calls may cause this mode to be modified, and the Reset procedure
15011 in this package can be used to reestablish the required mode.
15013 @node GNAT.Heap_Sort (g-heasor.ads)
15014 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15015 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15019 Provides a general implementation of heap sort usable for sorting arbitrary
15020 data items. Exchange and comparison procedures are provided by passing
15021 access-to-procedure values. The algorithm used is a modified heap sort
15022 that performs approximately N*log(N) comparisons in the worst case.
15024 @node GNAT.Heap_Sort_A (g-hesora.ads)
15025 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15026 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15030 Provides a general implementation of heap sort usable for sorting arbitrary
15031 data items. Move and comparison procedures are provided by passing
15032 access-to-procedure values. The algorithm used is a modified heap sort
15033 that performs approximately N*log(N) comparisons in the worst case.
15034 This differs from @code{GNAT.Heap_Sort} in having a less convenient
15035 interface, but may be slightly more efficient.
15037 @node GNAT.Heap_Sort_G (g-hesorg.ads)
15038 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15039 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15043 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
15044 are provided as generic parameters, this improves efficiency, especially
15045 if the procedures can be inlined, at the expense of duplicating code for
15046 multiple instantiations.
15048 @node GNAT.HTable (g-htable.ads)
15049 @section @code{GNAT.HTable} (@file{g-htable.ads})
15050 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
15051 @cindex Hash tables
15054 A generic implementation of hash tables that can be used to hash arbitrary
15055 data. Provides two approaches, one a simple static approach, and the other
15056 allowing arbitrary dynamic hash tables.
15058 @node GNAT.IO (g-io.ads)
15059 @section @code{GNAT.IO} (@file{g-io.ads})
15060 @cindex @code{GNAT.IO} (@file{g-io.ads})
15062 @cindex Input/Output facilities
15065 A simple preelaborable input-output package that provides a subset of
15066 simple Text_IO functions for reading characters and strings from
15067 Standard_Input, and writing characters, strings and integers to either
15068 Standard_Output or Standard_Error.
15070 @node GNAT.IO_Aux (g-io_aux.ads)
15071 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15072 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15074 @cindex Input/Output facilities
15076 Provides some auxiliary functions for use with Text_IO, including a test
15077 for whether a file exists, and functions for reading a line of text.
15079 @node GNAT.Lock_Files (g-locfil.ads)
15080 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15081 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15082 @cindex File locking
15083 @cindex Locking using files
15086 Provides a general interface for using files as locks. Can be used for
15087 providing program level synchronization.
15089 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
15090 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15091 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15092 @cindex Random number generation
15095 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
15096 a modified version of the Blum-Blum-Shub generator.
15098 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
15099 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15100 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15101 @cindex Random number generation
15104 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
15105 a modified version of the Blum-Blum-Shub generator.
15107 @node GNAT.MD5 (g-md5.ads)
15108 @section @code{GNAT.MD5} (@file{g-md5.ads})
15109 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
15110 @cindex Message Digest MD5
15113 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
15115 @node GNAT.Memory_Dump (g-memdum.ads)
15116 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15117 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15118 @cindex Dump Memory
15121 Provides a convenient routine for dumping raw memory to either the
15122 standard output or standard error files. Uses GNAT.IO for actual
15125 @node GNAT.Most_Recent_Exception (g-moreex.ads)
15126 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15127 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15128 @cindex Exception, obtaining most recent
15131 Provides access to the most recently raised exception. Can be used for
15132 various logging purposes, including duplicating functionality of some
15133 Ada 83 implementation dependent extensions.
15135 @node GNAT.OS_Lib (g-os_lib.ads)
15136 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15137 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15138 @cindex Operating System interface
15139 @cindex Spawn capability
15142 Provides a range of target independent operating system interface functions,
15143 including time/date management, file operations, subprocess management,
15144 including a portable spawn procedure, and access to environment variables
15145 and error return codes.
15147 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
15148 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15149 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15150 @cindex Hash functions
15153 Provides a generator of static minimal perfect hash functions. No
15154 collisions occur and each item can be retrieved from the table in one
15155 probe (perfect property). The hash table size corresponds to the exact
15156 size of the key set and no larger (minimal property). The key set has to
15157 be know in advance (static property). The hash functions are also order
15158 preserving. If w2 is inserted after w1 in the generator, their
15159 hashcode are in the same order. These hashing functions are very
15160 convenient for use with realtime applications.
15162 @node GNAT.Random_Numbers (g-rannum.ads)
15163 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15164 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15165 @cindex Random number generation
15168 Provides random number capabilities which extend those available in the
15169 standard Ada library and are more convenient to use.
15171 @node GNAT.Regexp (g-regexp.ads)
15172 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
15173 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
15174 @cindex Regular expressions
15175 @cindex Pattern matching
15178 A simple implementation of regular expressions, using a subset of regular
15179 expression syntax copied from familiar Unix style utilities. This is the
15180 simples of the three pattern matching packages provided, and is particularly
15181 suitable for ``file globbing'' applications.
15183 @node GNAT.Registry (g-regist.ads)
15184 @section @code{GNAT.Registry} (@file{g-regist.ads})
15185 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
15186 @cindex Windows Registry
15189 This is a high level binding to the Windows registry. It is possible to
15190 do simple things like reading a key value, creating a new key. For full
15191 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
15192 package provided with the Win32Ada binding
15194 @node GNAT.Regpat (g-regpat.ads)
15195 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
15196 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
15197 @cindex Regular expressions
15198 @cindex Pattern matching
15201 A complete implementation of Unix-style regular expression matching, copied
15202 from the original V7 style regular expression library written in C by
15203 Henry Spencer (and binary compatible with this C library).
15205 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
15206 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15207 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15208 @cindex Secondary Stack Info
15211 Provide the capability to query the high water mark of the current task's
15214 @node GNAT.Semaphores (g-semaph.ads)
15215 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
15216 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
15220 Provides classic counting and binary semaphores using protected types.
15222 @node GNAT.Serial_Communications (g-sercom.ads)
15223 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15224 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15225 @cindex Serial_Communications
15228 Provides a simple interface to send and receive data over a serial
15229 port. This is only supported on GNU/Linux and Windows.
15231 @node GNAT.SHA1 (g-sha1.ads)
15232 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
15233 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
15234 @cindex Secure Hash Algorithm SHA-1
15237 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
15240 @node GNAT.SHA224 (g-sha224.ads)
15241 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
15242 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
15243 @cindex Secure Hash Algorithm SHA-224
15246 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
15248 @node GNAT.SHA256 (g-sha256.ads)
15249 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
15250 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
15251 @cindex Secure Hash Algorithm SHA-256
15254 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
15256 @node GNAT.SHA384 (g-sha384.ads)
15257 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
15258 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
15259 @cindex Secure Hash Algorithm SHA-384
15262 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
15264 @node GNAT.SHA512 (g-sha512.ads)
15265 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
15266 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
15267 @cindex Secure Hash Algorithm SHA-512
15270 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
15272 @node GNAT.Signals (g-signal.ads)
15273 @section @code{GNAT.Signals} (@file{g-signal.ads})
15274 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
15278 Provides the ability to manipulate the blocked status of signals on supported
15281 @node GNAT.Sockets (g-socket.ads)
15282 @section @code{GNAT.Sockets} (@file{g-socket.ads})
15283 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
15287 A high level and portable interface to develop sockets based applications.
15288 This package is based on the sockets thin binding found in
15289 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
15290 on all native GNAT ports except for OpenVMS@. It is not implemented
15291 for the LynxOS@ cross port.
15293 @node GNAT.Source_Info (g-souinf.ads)
15294 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
15295 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
15296 @cindex Source Information
15299 Provides subprograms that give access to source code information known at
15300 compile time, such as the current file name and line number.
15302 @node GNAT.Spelling_Checker (g-speche.ads)
15303 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15304 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15305 @cindex Spell checking
15308 Provides a function for determining whether one string is a plausible
15309 near misspelling of another string.
15311 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
15312 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15313 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15314 @cindex Spell checking
15317 Provides a generic function that can be instantiated with a string type for
15318 determining whether one string is a plausible near misspelling of another
15321 @node GNAT.Spitbol.Patterns (g-spipat.ads)
15322 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15323 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15324 @cindex SPITBOL pattern matching
15325 @cindex Pattern matching
15328 A complete implementation of SNOBOL4 style pattern matching. This is the
15329 most elaborate of the pattern matching packages provided. It fully duplicates
15330 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
15331 efficient algorithm developed by Robert Dewar for the SPITBOL system.
15333 @node GNAT.Spitbol (g-spitbo.ads)
15334 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15335 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15336 @cindex SPITBOL interface
15339 The top level package of the collection of SPITBOL-style functionality, this
15340 package provides basic SNOBOL4 string manipulation functions, such as
15341 Pad, Reverse, Trim, Substr capability, as well as a generic table function
15342 useful for constructing arbitrary mappings from strings in the style of
15343 the SNOBOL4 TABLE function.
15345 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
15346 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15347 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15348 @cindex Sets of strings
15349 @cindex SPITBOL Tables
15352 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15353 for type @code{Standard.Boolean}, giving an implementation of sets of
15356 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
15357 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15358 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15359 @cindex Integer maps
15361 @cindex SPITBOL Tables
15364 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15365 for type @code{Standard.Integer}, giving an implementation of maps
15366 from string to integer values.
15368 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
15369 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15370 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15371 @cindex String maps
15373 @cindex SPITBOL Tables
15376 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
15377 a variable length string type, giving an implementation of general
15378 maps from strings to strings.
15380 @node GNAT.SSE (g-sse.ads)
15381 @section @code{GNAT.SSE} (@file{g-sse.ads})
15382 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
15385 Root of a set of units aimed at offering Ada bindings to a subset of
15386 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
15387 targets. It exposes vector component types together with a general
15388 introduction to the binding contents and use.
15390 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
15391 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15392 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15395 SSE vector types for use with SSE related intrinsics.
15397 @node GNAT.Strings (g-string.ads)
15398 @section @code{GNAT.Strings} (@file{g-string.ads})
15399 @cindex @code{GNAT.Strings} (@file{g-string.ads})
15402 Common String access types and related subprograms. Basically it
15403 defines a string access and an array of string access types.
15405 @node GNAT.String_Split (g-strspl.ads)
15406 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
15407 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
15408 @cindex String splitter
15411 Useful string manipulation routines: given a set of separators, split
15412 a string wherever the separators appear, and provide direct access
15413 to the resulting slices. This package is instantiated from
15414 @code{GNAT.Array_Split}.
15416 @node GNAT.Table (g-table.ads)
15417 @section @code{GNAT.Table} (@file{g-table.ads})
15418 @cindex @code{GNAT.Table} (@file{g-table.ads})
15419 @cindex Table implementation
15420 @cindex Arrays, extendable
15423 A generic package providing a single dimension array abstraction where the
15424 length of the array can be dynamically modified.
15427 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
15428 except that this package declares a single instance of the table type,
15429 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
15430 used to define dynamic instances of the table.
15432 @node GNAT.Task_Lock (g-tasloc.ads)
15433 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15434 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15435 @cindex Task synchronization
15436 @cindex Task locking
15440 A very simple facility for locking and unlocking sections of code using a
15441 single global task lock. Appropriate for use in situations where contention
15442 between tasks is very rarely expected.
15444 @node GNAT.Time_Stamp (g-timsta.ads)
15445 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15446 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15448 @cindex Current time
15451 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
15452 represents the current date and time in ISO 8601 format. This is a very simple
15453 routine with minimal code and there are no dependencies on any other unit.
15455 @node GNAT.Threads (g-thread.ads)
15456 @section @code{GNAT.Threads} (@file{g-thread.ads})
15457 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
15458 @cindex Foreign threads
15459 @cindex Threads, foreign
15462 Provides facilities for dealing with foreign threads which need to be known
15463 by the GNAT run-time system. Consult the documentation of this package for
15464 further details if your program has threads that are created by a non-Ada
15465 environment which then accesses Ada code.
15467 @node GNAT.Traceback (g-traceb.ads)
15468 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
15469 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
15470 @cindex Trace back facilities
15473 Provides a facility for obtaining non-symbolic traceback information, useful
15474 in various debugging situations.
15476 @node GNAT.Traceback.Symbolic (g-trasym.ads)
15477 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15478 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15479 @cindex Trace back facilities
15481 @node GNAT.UTF_32 (g-utf_32.ads)
15482 @section @code{GNAT.UTF_32} (@file{g-table.ads})
15483 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
15484 @cindex Wide character codes
15487 This is a package intended to be used in conjunction with the
15488 @code{Wide_Character} type in Ada 95 and the
15489 @code{Wide_Wide_Character} type in Ada 2005 (available
15490 in @code{GNAT} in Ada 2005 mode). This package contains
15491 Unicode categorization routines, as well as lexical
15492 categorization routines corresponding to the Ada 2005
15493 lexical rules for identifiers and strings, and also a
15494 lower case to upper case fold routine corresponding to
15495 the Ada 2005 rules for identifier equivalence.
15497 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
15498 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15499 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15500 @cindex Spell checking
15503 Provides a function for determining whether one wide wide string is a plausible
15504 near misspelling of another wide wide string, where the strings are represented
15505 using the UTF_32_String type defined in System.Wch_Cnv.
15507 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
15508 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15509 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15510 @cindex Spell checking
15513 Provides a function for determining whether one wide string is a plausible
15514 near misspelling of another wide string.
15516 @node GNAT.Wide_String_Split (g-wistsp.ads)
15517 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15518 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15519 @cindex Wide_String splitter
15522 Useful wide string manipulation routines: given a set of separators, split
15523 a wide string wherever the separators appear, and provide direct access
15524 to the resulting slices. This package is instantiated from
15525 @code{GNAT.Array_Split}.
15527 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
15528 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15529 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15530 @cindex Spell checking
15533 Provides a function for determining whether one wide wide string is a plausible
15534 near misspelling of another wide wide string.
15536 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
15537 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15538 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15539 @cindex Wide_Wide_String splitter
15542 Useful wide wide string manipulation routines: given a set of separators, split
15543 a wide wide string wherever the separators appear, and provide direct access
15544 to the resulting slices. This package is instantiated from
15545 @code{GNAT.Array_Split}.
15547 @node Interfaces.C.Extensions (i-cexten.ads)
15548 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15549 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15552 This package contains additional C-related definitions, intended
15553 for use with either manually or automatically generated bindings
15556 @node Interfaces.C.Streams (i-cstrea.ads)
15557 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15558 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15559 @cindex C streams, interfacing
15562 This package is a binding for the most commonly used operations
15565 @node Interfaces.CPP (i-cpp.ads)
15566 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
15567 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
15568 @cindex C++ interfacing
15569 @cindex Interfacing, to C++
15572 This package provides facilities for use in interfacing to C++. It
15573 is primarily intended to be used in connection with automated tools
15574 for the generation of C++ interfaces.
15576 @node Interfaces.Packed_Decimal (i-pacdec.ads)
15577 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15578 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15579 @cindex IBM Packed Format
15580 @cindex Packed Decimal
15583 This package provides a set of routines for conversions to and
15584 from a packed decimal format compatible with that used on IBM
15587 @node Interfaces.VxWorks (i-vxwork.ads)
15588 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15589 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15590 @cindex Interfacing to VxWorks
15591 @cindex VxWorks, interfacing
15594 This package provides a limited binding to the VxWorks API.
15595 In particular, it interfaces with the
15596 VxWorks hardware interrupt facilities.
15598 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
15599 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15600 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15601 @cindex Interfacing to VxWorks' I/O
15602 @cindex VxWorks, I/O interfacing
15603 @cindex VxWorks, Get_Immediate
15604 @cindex Get_Immediate, VxWorks
15607 This package provides a binding to the ioctl (IO/Control)
15608 function of VxWorks, defining a set of option values and
15609 function codes. A particular use of this package is
15610 to enable the use of Get_Immediate under VxWorks.
15612 @node System.Address_Image (s-addima.ads)
15613 @section @code{System.Address_Image} (@file{s-addima.ads})
15614 @cindex @code{System.Address_Image} (@file{s-addima.ads})
15615 @cindex Address image
15616 @cindex Image, of an address
15619 This function provides a useful debugging
15620 function that gives an (implementation dependent)
15621 string which identifies an address.
15623 @node System.Assertions (s-assert.ads)
15624 @section @code{System.Assertions} (@file{s-assert.ads})
15625 @cindex @code{System.Assertions} (@file{s-assert.ads})
15627 @cindex Assert_Failure, exception
15630 This package provides the declaration of the exception raised
15631 by an run-time assertion failure, as well as the routine that
15632 is used internally to raise this assertion.
15634 @node System.Memory (s-memory.ads)
15635 @section @code{System.Memory} (@file{s-memory.ads})
15636 @cindex @code{System.Memory} (@file{s-memory.ads})
15637 @cindex Memory allocation
15640 This package provides the interface to the low level routines used
15641 by the generated code for allocation and freeing storage for the
15642 default storage pool (analogous to the C routines malloc and free.
15643 It also provides a reallocation interface analogous to the C routine
15644 realloc. The body of this unit may be modified to provide alternative
15645 allocation mechanisms for the default pool, and in addition, direct
15646 calls to this unit may be made for low level allocation uses (for
15647 example see the body of @code{GNAT.Tables}).
15649 @node System.Partition_Interface (s-parint.ads)
15650 @section @code{System.Partition_Interface} (@file{s-parint.ads})
15651 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
15652 @cindex Partition interfacing functions
15655 This package provides facilities for partition interfacing. It
15656 is used primarily in a distribution context when using Annex E
15659 @node System.Pool_Global (s-pooglo.ads)
15660 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
15661 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
15662 @cindex Storage pool, global
15663 @cindex Global storage pool
15666 This package provides a storage pool that is equivalent to the default
15667 storage pool used for access types for which no pool is specifically
15668 declared. It uses malloc/free to allocate/free and does not attempt to
15669 do any automatic reclamation.
15671 @node System.Pool_Local (s-pooloc.ads)
15672 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
15673 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
15674 @cindex Storage pool, local
15675 @cindex Local storage pool
15678 This package provides a storage pool that is intended for use with locally
15679 defined access types. It uses malloc/free for allocate/free, and maintains
15680 a list of allocated blocks, so that all storage allocated for the pool can
15681 be freed automatically when the pool is finalized.
15683 @node System.Restrictions (s-restri.ads)
15684 @section @code{System.Restrictions} (@file{s-restri.ads})
15685 @cindex @code{System.Restrictions} (@file{s-restri.ads})
15686 @cindex Run-time restrictions access
15689 This package provides facilities for accessing at run time
15690 the status of restrictions specified at compile time for
15691 the partition. Information is available both with regard
15692 to actual restrictions specified, and with regard to
15693 compiler determined information on which restrictions
15694 are violated by one or more packages in the partition.
15696 @node System.Rident (s-rident.ads)
15697 @section @code{System.Rident} (@file{s-rident.ads})
15698 @cindex @code{System.Rident} (@file{s-rident.ads})
15699 @cindex Restrictions definitions
15702 This package provides definitions of the restrictions
15703 identifiers supported by GNAT, and also the format of
15704 the restrictions provided in package System.Restrictions.
15705 It is not normally necessary to @code{with} this generic package
15706 since the necessary instantiation is included in
15707 package System.Restrictions.
15709 @node System.Strings.Stream_Ops (s-ststop.ads)
15710 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15711 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15712 @cindex Stream operations
15713 @cindex String stream operations
15716 This package provides a set of stream subprograms for standard string types.
15717 It is intended primarily to support implicit use of such subprograms when
15718 stream attributes are applied to string types, but the subprograms in this
15719 package can be used directly by application programs.
15721 @node System.Task_Info (s-tasinf.ads)
15722 @section @code{System.Task_Info} (@file{s-tasinf.ads})
15723 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15724 @cindex Task_Info pragma
15727 This package provides target dependent functionality that is used
15728 to support the @code{Task_Info} pragma
15730 @node System.Wch_Cnv (s-wchcnv.ads)
15731 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15732 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15733 @cindex Wide Character, Representation
15734 @cindex Wide String, Conversion
15735 @cindex Representation of wide characters
15738 This package provides routines for converting between
15739 wide and wide wide characters and a representation as a value of type
15740 @code{Standard.String}, using a specified wide character
15741 encoding method. It uses definitions in
15742 package @code{System.Wch_Con}.
15744 @node System.Wch_Con (s-wchcon.ads)
15745 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15746 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15749 This package provides definitions and descriptions of
15750 the various methods used for encoding wide characters
15751 in ordinary strings. These definitions are used by
15752 the package @code{System.Wch_Cnv}.
15754 @node Interfacing to Other Languages
15755 @chapter Interfacing to Other Languages
15757 The facilities in annex B of the Ada Reference Manual are fully
15758 implemented in GNAT, and in addition, a full interface to C++ is
15762 * Interfacing to C::
15763 * Interfacing to C++::
15764 * Interfacing to COBOL::
15765 * Interfacing to Fortran::
15766 * Interfacing to non-GNAT Ada code::
15769 @node Interfacing to C
15770 @section Interfacing to C
15773 Interfacing to C with GNAT can use one of two approaches:
15777 The types in the package @code{Interfaces.C} may be used.
15779 Standard Ada types may be used directly. This may be less portable to
15780 other compilers, but will work on all GNAT compilers, which guarantee
15781 correspondence between the C and Ada types.
15785 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15786 effect, since this is the default. The following table shows the
15787 correspondence between Ada scalar types and the corresponding C types.
15792 @item Short_Integer
15794 @item Short_Short_Integer
15798 @item Long_Long_Integer
15806 @item Long_Long_Float
15807 This is the longest floating-point type supported by the hardware.
15811 Additionally, there are the following general correspondences between Ada
15815 Ada enumeration types map to C enumeration types directly if pragma
15816 @code{Convention C} is specified, which causes them to have int
15817 length. Without pragma @code{Convention C}, Ada enumeration types map to
15818 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15819 @code{int}, respectively) depending on the number of values passed.
15820 This is the only case in which pragma @code{Convention C} affects the
15821 representation of an Ada type.
15824 Ada access types map to C pointers, except for the case of pointers to
15825 unconstrained types in Ada, which have no direct C equivalent.
15828 Ada arrays map directly to C arrays.
15831 Ada records map directly to C structures.
15834 Packed Ada records map to C structures where all members are bit fields
15835 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15838 @node Interfacing to C++
15839 @section Interfacing to C++
15842 The interface to C++ makes use of the following pragmas, which are
15843 primarily intended to be constructed automatically using a binding generator
15844 tool, although it is possible to construct them by hand. No suitable binding
15845 generator tool is supplied with GNAT though.
15847 Using these pragmas it is possible to achieve complete
15848 inter-operability between Ada tagged types and C++ class definitions.
15849 See @ref{Implementation Defined Pragmas}, for more details.
15852 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15853 The argument denotes an entity in the current declarative region that is
15854 declared as a tagged or untagged record type. It indicates that the type
15855 corresponds to an externally declared C++ class type, and is to be laid
15856 out the same way that C++ would lay out the type.
15858 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15859 for backward compatibility but its functionality is available
15860 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15862 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15863 This pragma identifies an imported function (imported in the usual way
15864 with pragma @code{Import}) as corresponding to a C++ constructor.
15867 @node Interfacing to COBOL
15868 @section Interfacing to COBOL
15871 Interfacing to COBOL is achieved as described in section B.4 of
15872 the Ada Reference Manual.
15874 @node Interfacing to Fortran
15875 @section Interfacing to Fortran
15878 Interfacing to Fortran is achieved as described in section B.5 of the
15879 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
15880 multi-dimensional array causes the array to be stored in column-major
15881 order as required for convenient interface to Fortran.
15883 @node Interfacing to non-GNAT Ada code
15884 @section Interfacing to non-GNAT Ada code
15886 It is possible to specify the convention @code{Ada} in a pragma
15887 @code{Import} or pragma @code{Export}. However this refers to
15888 the calling conventions used by GNAT, which may or may not be
15889 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15890 compiler to allow interoperation.
15892 If arguments types are kept simple, and if the foreign compiler generally
15893 follows system calling conventions, then it may be possible to integrate
15894 files compiled by other Ada compilers, provided that the elaboration
15895 issues are adequately addressed (for example by eliminating the
15896 need for any load time elaboration).
15898 In particular, GNAT running on VMS is designed to
15899 be highly compatible with the DEC Ada 83 compiler, so this is one
15900 case in which it is possible to import foreign units of this type,
15901 provided that the data items passed are restricted to simple scalar
15902 values or simple record types without variants, or simple array
15903 types with fixed bounds.
15905 @node Specialized Needs Annexes
15906 @chapter Specialized Needs Annexes
15909 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15910 required in all implementations. However, as described in this chapter,
15911 GNAT implements all of these annexes:
15914 @item Systems Programming (Annex C)
15915 The Systems Programming Annex is fully implemented.
15917 @item Real-Time Systems (Annex D)
15918 The Real-Time Systems Annex is fully implemented.
15920 @item Distributed Systems (Annex E)
15921 Stub generation is fully implemented in the GNAT compiler. In addition,
15922 a complete compatible PCS is available as part of the GLADE system,
15923 a separate product. When the two
15924 products are used in conjunction, this annex is fully implemented.
15926 @item Information Systems (Annex F)
15927 The Information Systems annex is fully implemented.
15929 @item Numerics (Annex G)
15930 The Numerics Annex is fully implemented.
15932 @item Safety and Security / High-Integrity Systems (Annex H)
15933 The Safety and Security Annex (termed the High-Integrity Systems Annex
15934 in Ada 2005) is fully implemented.
15937 @node Implementation of Specific Ada Features
15938 @chapter Implementation of Specific Ada Features
15941 This chapter describes the GNAT implementation of several Ada language
15945 * Machine Code Insertions::
15946 * GNAT Implementation of Tasking::
15947 * GNAT Implementation of Shared Passive Packages::
15948 * Code Generation for Array Aggregates::
15949 * The Size of Discriminated Records with Default Discriminants::
15950 * Strict Conformance to the Ada Reference Manual::
15953 @node Machine Code Insertions
15954 @section Machine Code Insertions
15955 @cindex Machine Code insertions
15958 Package @code{Machine_Code} provides machine code support as described
15959 in the Ada Reference Manual in two separate forms:
15962 Machine code statements, consisting of qualified expressions that
15963 fit the requirements of RM section 13.8.
15965 An intrinsic callable procedure, providing an alternative mechanism of
15966 including machine instructions in a subprogram.
15970 The two features are similar, and both are closely related to the mechanism
15971 provided by the asm instruction in the GNU C compiler. Full understanding
15972 and use of the facilities in this package requires understanding the asm
15973 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15974 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15976 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15977 semantic restrictions and effects as described below. Both are provided so
15978 that the procedure call can be used as a statement, and the function call
15979 can be used to form a code_statement.
15981 The first example given in the GCC documentation is the C @code{asm}
15984 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15988 The equivalent can be written for GNAT as:
15990 @smallexample @c ada
15991 Asm ("fsinx %1 %0",
15992 My_Float'Asm_Output ("=f", result),
15993 My_Float'Asm_Input ("f", angle));
15997 The first argument to @code{Asm} is the assembler template, and is
15998 identical to what is used in GNU C@. This string must be a static
15999 expression. The second argument is the output operand list. It is
16000 either a single @code{Asm_Output} attribute reference, or a list of such
16001 references enclosed in parentheses (technically an array aggregate of
16004 The @code{Asm_Output} attribute denotes a function that takes two
16005 parameters. The first is a string, the second is the name of a variable
16006 of the type designated by the attribute prefix. The first (string)
16007 argument is required to be a static expression and designates the
16008 constraint for the parameter (e.g.@: what kind of register is
16009 required). The second argument is the variable to be updated with the
16010 result. The possible values for constraint are the same as those used in
16011 the RTL, and are dependent on the configuration file used to build the
16012 GCC back end. If there are no output operands, then this argument may
16013 either be omitted, or explicitly given as @code{No_Output_Operands}.
16015 The second argument of @code{@var{my_float}'Asm_Output} functions as
16016 though it were an @code{out} parameter, which is a little curious, but
16017 all names have the form of expressions, so there is no syntactic
16018 irregularity, even though normally functions would not be permitted
16019 @code{out} parameters. The third argument is the list of input
16020 operands. It is either a single @code{Asm_Input} attribute reference, or
16021 a list of such references enclosed in parentheses (technically an array
16022 aggregate of such references).
16024 The @code{Asm_Input} attribute denotes a function that takes two
16025 parameters. The first is a string, the second is an expression of the
16026 type designated by the prefix. The first (string) argument is required
16027 to be a static expression, and is the constraint for the parameter,
16028 (e.g.@: what kind of register is required). The second argument is the
16029 value to be used as the input argument. The possible values for the
16030 constant are the same as those used in the RTL, and are dependent on
16031 the configuration file used to built the GCC back end.
16033 If there are no input operands, this argument may either be omitted, or
16034 explicitly given as @code{No_Input_Operands}. The fourth argument, not
16035 present in the above example, is a list of register names, called the
16036 @dfn{clobber} argument. This argument, if given, must be a static string
16037 expression, and is a space or comma separated list of names of registers
16038 that must be considered destroyed as a result of the @code{Asm} call. If
16039 this argument is the null string (the default value), then the code
16040 generator assumes that no additional registers are destroyed.
16042 The fifth argument, not present in the above example, called the
16043 @dfn{volatile} argument, is by default @code{False}. It can be set to
16044 the literal value @code{True} to indicate to the code generator that all
16045 optimizations with respect to the instruction specified should be
16046 suppressed, and that in particular, for an instruction that has outputs,
16047 the instruction will still be generated, even if none of the outputs are
16048 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
16049 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
16050 Generally it is strongly advisable to use Volatile for any ASM statement
16051 that is missing either input or output operands, or when two or more ASM
16052 statements appear in sequence, to avoid unwanted optimizations. A warning
16053 is generated if this advice is not followed.
16055 The @code{Asm} subprograms may be used in two ways. First the procedure
16056 forms can be used anywhere a procedure call would be valid, and
16057 correspond to what the RM calls ``intrinsic'' routines. Such calls can
16058 be used to intersperse machine instructions with other Ada statements.
16059 Second, the function forms, which return a dummy value of the limited
16060 private type @code{Asm_Insn}, can be used in code statements, and indeed
16061 this is the only context where such calls are allowed. Code statements
16062 appear as aggregates of the form:
16064 @smallexample @c ada
16065 Asm_Insn'(Asm (@dots{}));
16066 Asm_Insn'(Asm_Volatile (@dots{}));
16070 In accordance with RM rules, such code statements are allowed only
16071 within subprograms whose entire body consists of such statements. It is
16072 not permissible to intermix such statements with other Ada statements.
16074 Typically the form using intrinsic procedure calls is more convenient
16075 and more flexible. The code statement form is provided to meet the RM
16076 suggestion that such a facility should be made available. The following
16077 is the exact syntax of the call to @code{Asm}. As usual, if named notation
16078 is used, the arguments may be given in arbitrary order, following the
16079 normal rules for use of positional and named arguments)
16083 [Template =>] static_string_EXPRESSION
16084 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
16085 [,[Inputs =>] INPUT_OPERAND_LIST ]
16086 [,[Clobber =>] static_string_EXPRESSION ]
16087 [,[Volatile =>] static_boolean_EXPRESSION] )
16089 OUTPUT_OPERAND_LIST ::=
16090 [PREFIX.]No_Output_Operands
16091 | OUTPUT_OPERAND_ATTRIBUTE
16092 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
16094 OUTPUT_OPERAND_ATTRIBUTE ::=
16095 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
16097 INPUT_OPERAND_LIST ::=
16098 [PREFIX.]No_Input_Operands
16099 | INPUT_OPERAND_ATTRIBUTE
16100 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
16102 INPUT_OPERAND_ATTRIBUTE ::=
16103 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
16107 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
16108 are declared in the package @code{Machine_Code} and must be referenced
16109 according to normal visibility rules. In particular if there is no
16110 @code{use} clause for this package, then appropriate package name
16111 qualification is required.
16113 @node GNAT Implementation of Tasking
16114 @section GNAT Implementation of Tasking
16117 This chapter outlines the basic GNAT approach to tasking (in particular,
16118 a multi-layered library for portability) and discusses issues related
16119 to compliance with the Real-Time Systems Annex.
16122 * Mapping Ada Tasks onto the Underlying Kernel Threads::
16123 * Ensuring Compliance with the Real-Time Annex::
16126 @node Mapping Ada Tasks onto the Underlying Kernel Threads
16127 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
16130 GNAT's run-time support comprises two layers:
16133 @item GNARL (GNAT Run-time Layer)
16134 @item GNULL (GNAT Low-level Library)
16138 In GNAT, Ada's tasking services rely on a platform and OS independent
16139 layer known as GNARL@. This code is responsible for implementing the
16140 correct semantics of Ada's task creation, rendezvous, protected
16143 GNARL decomposes Ada's tasking semantics into simpler lower level
16144 operations such as create a thread, set the priority of a thread,
16145 yield, create a lock, lock/unlock, etc. The spec for these low-level
16146 operations constitutes GNULLI, the GNULL Interface. This interface is
16147 directly inspired from the POSIX real-time API@.
16149 If the underlying executive or OS implements the POSIX standard
16150 faithfully, the GNULL Interface maps as is to the services offered by
16151 the underlying kernel. Otherwise, some target dependent glue code maps
16152 the services offered by the underlying kernel to the semantics expected
16155 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
16156 key point is that each Ada task is mapped on a thread in the underlying
16157 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
16159 In addition Ada task priorities map onto the underlying thread priorities.
16160 Mapping Ada tasks onto the underlying kernel threads has several advantages:
16164 The underlying scheduler is used to schedule the Ada tasks. This
16165 makes Ada tasks as efficient as kernel threads from a scheduling
16169 Interaction with code written in C containing threads is eased
16170 since at the lowest level Ada tasks and C threads map onto the same
16171 underlying kernel concept.
16174 When an Ada task is blocked during I/O the remaining Ada tasks are
16178 On multiprocessor systems Ada tasks can execute in parallel.
16182 Some threads libraries offer a mechanism to fork a new process, with the
16183 child process duplicating the threads from the parent.
16185 support this functionality when the parent contains more than one task.
16186 @cindex Forking a new process
16188 @node Ensuring Compliance with the Real-Time Annex
16189 @subsection Ensuring Compliance with the Real-Time Annex
16190 @cindex Real-Time Systems Annex compliance
16193 Although mapping Ada tasks onto
16194 the underlying threads has significant advantages, it does create some
16195 complications when it comes to respecting the scheduling semantics
16196 specified in the real-time annex (Annex D).
16198 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
16199 scheduling policy states:
16202 @emph{When the active priority of a ready task that is not running
16203 changes, or the setting of its base priority takes effect, the
16204 task is removed from the ready queue for its old active priority
16205 and is added at the tail of the ready queue for its new active
16206 priority, except in the case where the active priority is lowered
16207 due to the loss of inherited priority, in which case the task is
16208 added at the head of the ready queue for its new active priority.}
16212 While most kernels do put tasks at the end of the priority queue when
16213 a task changes its priority, (which respects the main
16214 FIFO_Within_Priorities requirement), almost none keep a thread at the
16215 beginning of its priority queue when its priority drops from the loss
16216 of inherited priority.
16218 As a result most vendors have provided incomplete Annex D implementations.
16220 The GNAT run-time, has a nice cooperative solution to this problem
16221 which ensures that accurate FIFO_Within_Priorities semantics are
16224 The principle is as follows. When an Ada task T is about to start
16225 running, it checks whether some other Ada task R with the same
16226 priority as T has been suspended due to the loss of priority
16227 inheritance. If this is the case, T yields and is placed at the end of
16228 its priority queue. When R arrives at the front of the queue it
16231 Note that this simple scheme preserves the relative order of the tasks
16232 that were ready to execute in the priority queue where R has been
16235 @node GNAT Implementation of Shared Passive Packages
16236 @section GNAT Implementation of Shared Passive Packages
16237 @cindex Shared passive packages
16240 GNAT fully implements the pragma @code{Shared_Passive} for
16241 @cindex pragma @code{Shared_Passive}
16242 the purpose of designating shared passive packages.
16243 This allows the use of passive partitions in the
16244 context described in the Ada Reference Manual; i.e., for communication
16245 between separate partitions of a distributed application using the
16246 features in Annex E.
16248 @cindex Distribution Systems Annex
16250 However, the implementation approach used by GNAT provides for more
16251 extensive usage as follows:
16254 @item Communication between separate programs
16256 This allows separate programs to access the data in passive
16257 partitions, using protected objects for synchronization where
16258 needed. The only requirement is that the two programs have a
16259 common shared file system. It is even possible for programs
16260 running on different machines with different architectures
16261 (e.g.@: different endianness) to communicate via the data in
16262 a passive partition.
16264 @item Persistence between program runs
16266 The data in a passive package can persist from one run of a
16267 program to another, so that a later program sees the final
16268 values stored by a previous run of the same program.
16273 The implementation approach used is to store the data in files. A
16274 separate stream file is created for each object in the package, and
16275 an access to an object causes the corresponding file to be read or
16278 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
16279 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
16280 set to the directory to be used for these files.
16281 The files in this directory
16282 have names that correspond to their fully qualified names. For
16283 example, if we have the package
16285 @smallexample @c ada
16287 pragma Shared_Passive (X);
16294 and the environment variable is set to @code{/stemp/}, then the files created
16295 will have the names:
16303 These files are created when a value is initially written to the object, and
16304 the files are retained until manually deleted. This provides the persistence
16305 semantics. If no file exists, it means that no partition has assigned a value
16306 to the variable; in this case the initial value declared in the package
16307 will be used. This model ensures that there are no issues in synchronizing
16308 the elaboration process, since elaboration of passive packages elaborates the
16309 initial values, but does not create the files.
16311 The files are written using normal @code{Stream_IO} access.
16312 If you want to be able
16313 to communicate between programs or partitions running on different
16314 architectures, then you should use the XDR versions of the stream attribute
16315 routines, since these are architecture independent.
16317 If active synchronization is required for access to the variables in the
16318 shared passive package, then as described in the Ada Reference Manual, the
16319 package may contain protected objects used for this purpose. In this case
16320 a lock file (whose name is @file{___lock} (three underscores)
16321 is created in the shared memory directory.
16322 @cindex @file{___lock} file (for shared passive packages)
16323 This is used to provide the required locking
16324 semantics for proper protected object synchronization.
16326 As of January 2003, GNAT supports shared passive packages on all platforms
16327 except for OpenVMS.
16329 @node Code Generation for Array Aggregates
16330 @section Code Generation for Array Aggregates
16333 * Static constant aggregates with static bounds::
16334 * Constant aggregates with unconstrained nominal types::
16335 * Aggregates with static bounds::
16336 * Aggregates with non-static bounds::
16337 * Aggregates in assignment statements::
16341 Aggregates have a rich syntax and allow the user to specify the values of
16342 complex data structures by means of a single construct. As a result, the
16343 code generated for aggregates can be quite complex and involve loops, case
16344 statements and multiple assignments. In the simplest cases, however, the
16345 compiler will recognize aggregates whose components and constraints are
16346 fully static, and in those cases the compiler will generate little or no
16347 executable code. The following is an outline of the code that GNAT generates
16348 for various aggregate constructs. For further details, you will find it
16349 useful to examine the output produced by the -gnatG flag to see the expanded
16350 source that is input to the code generator. You may also want to examine
16351 the assembly code generated at various levels of optimization.
16353 The code generated for aggregates depends on the context, the component values,
16354 and the type. In the context of an object declaration the code generated is
16355 generally simpler than in the case of an assignment. As a general rule, static
16356 component values and static subtypes also lead to simpler code.
16358 @node Static constant aggregates with static bounds
16359 @subsection Static constant aggregates with static bounds
16362 For the declarations:
16363 @smallexample @c ada
16364 type One_Dim is array (1..10) of integer;
16365 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
16369 GNAT generates no executable code: the constant ar0 is placed in static memory.
16370 The same is true for constant aggregates with named associations:
16372 @smallexample @c ada
16373 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
16374 Cr3 : constant One_Dim := (others => 7777);
16378 The same is true for multidimensional constant arrays such as:
16380 @smallexample @c ada
16381 type two_dim is array (1..3, 1..3) of integer;
16382 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
16386 The same is true for arrays of one-dimensional arrays: the following are
16389 @smallexample @c ada
16390 type ar1b is array (1..3) of boolean;
16391 type ar_ar is array (1..3) of ar1b;
16392 None : constant ar1b := (others => false); -- fully static
16393 None2 : constant ar_ar := (1..3 => None); -- fully static
16397 However, for multidimensional aggregates with named associations, GNAT will
16398 generate assignments and loops, even if all associations are static. The
16399 following two declarations generate a loop for the first dimension, and
16400 individual component assignments for the second dimension:
16402 @smallexample @c ada
16403 Zero1: constant two_dim := (1..3 => (1..3 => 0));
16404 Zero2: constant two_dim := (others => (others => 0));
16407 @node Constant aggregates with unconstrained nominal types
16408 @subsection Constant aggregates with unconstrained nominal types
16411 In such cases the aggregate itself establishes the subtype, so that
16412 associations with @code{others} cannot be used. GNAT determines the
16413 bounds for the actual subtype of the aggregate, and allocates the
16414 aggregate statically as well. No code is generated for the following:
16416 @smallexample @c ada
16417 type One_Unc is array (natural range <>) of integer;
16418 Cr_Unc : constant One_Unc := (12,24,36);
16421 @node Aggregates with static bounds
16422 @subsection Aggregates with static bounds
16425 In all previous examples the aggregate was the initial (and immutable) value
16426 of a constant. If the aggregate initializes a variable, then code is generated
16427 for it as a combination of individual assignments and loops over the target
16428 object. The declarations
16430 @smallexample @c ada
16431 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
16432 Cr_Var2 : One_Dim := (others > -1);
16436 generate the equivalent of
16438 @smallexample @c ada
16444 for I in Cr_Var2'range loop
16449 @node Aggregates with non-static bounds
16450 @subsection Aggregates with non-static bounds
16453 If the bounds of the aggregate are not statically compatible with the bounds
16454 of the nominal subtype of the target, then constraint checks have to be
16455 generated on the bounds. For a multidimensional array, constraint checks may
16456 have to be applied to sub-arrays individually, if they do not have statically
16457 compatible subtypes.
16459 @node Aggregates in assignment statements
16460 @subsection Aggregates in assignment statements
16463 In general, aggregate assignment requires the construction of a temporary,
16464 and a copy from the temporary to the target of the assignment. This is because
16465 it is not always possible to convert the assignment into a series of individual
16466 component assignments. For example, consider the simple case:
16468 @smallexample @c ada
16473 This cannot be converted into:
16475 @smallexample @c ada
16481 So the aggregate has to be built first in a separate location, and then
16482 copied into the target. GNAT recognizes simple cases where this intermediate
16483 step is not required, and the assignments can be performed in place, directly
16484 into the target. The following sufficient criteria are applied:
16488 The bounds of the aggregate are static, and the associations are static.
16490 The components of the aggregate are static constants, names of
16491 simple variables that are not renamings, or expressions not involving
16492 indexed components whose operands obey these rules.
16496 If any of these conditions are violated, the aggregate will be built in
16497 a temporary (created either by the front-end or the code generator) and then
16498 that temporary will be copied onto the target.
16500 @node The Size of Discriminated Records with Default Discriminants
16501 @section The Size of Discriminated Records with Default Discriminants
16504 If a discriminated type @code{T} has discriminants with default values, it is
16505 possible to declare an object of this type without providing an explicit
16508 @smallexample @c ada
16510 type Size is range 1..100;
16512 type Rec (D : Size := 15) is record
16513 Name : String (1..D);
16521 Such an object is said to be @emph{unconstrained}.
16522 The discriminant of the object
16523 can be modified by a full assignment to the object, as long as it preserves the
16524 relation between the value of the discriminant, and the value of the components
16527 @smallexample @c ada
16529 Word := (3, "yes");
16531 Word := (5, "maybe");
16533 Word := (5, "no"); -- raises Constraint_Error
16538 In order to support this behavior efficiently, an unconstrained object is
16539 given the maximum size that any value of the type requires. In the case
16540 above, @code{Word} has storage for the discriminant and for
16541 a @code{String} of length 100.
16542 It is important to note that unconstrained objects do not require dynamic
16543 allocation. It would be an improper implementation to place on the heap those
16544 components whose size depends on discriminants. (This improper implementation
16545 was used by some Ada83 compilers, where the @code{Name} component above
16547 been stored as a pointer to a dynamic string). Following the principle that
16548 dynamic storage management should never be introduced implicitly,
16549 an Ada compiler should reserve the full size for an unconstrained declared
16550 object, and place it on the stack.
16552 This maximum size approach
16553 has been a source of surprise to some users, who expect the default
16554 values of the discriminants to determine the size reserved for an
16555 unconstrained object: ``If the default is 15, why should the object occupy
16557 The answer, of course, is that the discriminant may be later modified,
16558 and its full range of values must be taken into account. This is why the
16563 type Rec (D : Positive := 15) is record
16564 Name : String (1..D);
16572 is flagged by the compiler with a warning:
16573 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
16574 because the required size includes @code{Positive'Last}
16575 bytes. As the first example indicates, the proper approach is to declare an
16576 index type of ``reasonable'' range so that unconstrained objects are not too
16579 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
16580 created in the heap by means of an allocator, then it is @emph{not}
16582 it is constrained by the default values of the discriminants, and those values
16583 cannot be modified by full assignment. This is because in the presence of
16584 aliasing all views of the object (which may be manipulated by different tasks,
16585 say) must be consistent, so it is imperative that the object, once created,
16588 @node Strict Conformance to the Ada Reference Manual
16589 @section Strict Conformance to the Ada Reference Manual
16592 The dynamic semantics defined by the Ada Reference Manual impose a set of
16593 run-time checks to be generated. By default, the GNAT compiler will insert many
16594 run-time checks into the compiled code, including most of those required by the
16595 Ada Reference Manual. However, there are three checks that are not enabled
16596 in the default mode for efficiency reasons: arithmetic overflow checking for
16597 integer operations (including division by zero), checks for access before
16598 elaboration on subprogram calls, and stack overflow checking (most operating
16599 systems do not perform this check by default).
16601 Strict conformance to the Ada Reference Manual can be achieved by adding
16602 three compiler options for overflow checking for integer operations
16603 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
16604 calls and generic instantiations (@option{-gnatE}), and stack overflow
16605 checking (@option{-fstack-check}).
16607 Note that the result of a floating point arithmetic operation in overflow and
16608 invalid situations, when the @code{Machine_Overflows} attribute of the result
16609 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
16610 case for machines compliant with the IEEE floating-point standard, but on
16611 machines that are not fully compliant with this standard, such as Alpha, the
16612 @option{-mieee} compiler flag must be used for achieving IEEE confirming
16613 behavior (although at the cost of a significant performance penalty), so
16614 infinite and NaN values are properly generated.
16617 @node Implementation of Ada 2012 Features
16618 @chapter Implementation of Ada 2012 Features
16619 @cindex Ada 2012 implementation status
16621 This chapter contains a complete list of Ada 2012 features that have been
16622 implemented as of GNAT version 6.4. Generally, these features are only
16623 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
16624 @cindex @option{-gnat12} option
16625 or if the configuration pragma @code{Ada_2012} is used.
16626 @cindex pragma @code{Ada_2012}
16627 @cindex configuration pragma @code{Ada_2012}
16628 @cindex @code{Ada_2012} configuration pragma
16629 However, new pragmas, attributes, and restrictions are
16630 unconditionally available, since the Ada 95 standard allows the addition of
16631 new pragmas, attributes, and restrictions (there are exceptions, which are
16632 documented in the individual descriptions), and also certain packages
16633 were made available in earlier versions of Ada.
16635 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
16636 This date shows the implementation date of the feature. Any wavefront
16637 subsequent to this date will contain the indicated feature, as will any
16638 subsequent releases. A date of 0000-00-00 means that GNAT has always
16639 implemented the feature, or implemented it as soon as it appeared as a
16640 binding interpretation.
16642 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
16643 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
16644 The features are ordered based on the relevant sections of the Ada
16645 Reference Manual (``RM''). When a given AI relates to multiple points
16646 in the RM, the earliest is used.
16648 A complete description of the AIs may be found in
16649 @url{www.ada-auth.org/ai05-summary.html}.
16654 @emph{AI-0176 Quantified expressions (2010-09-29)}
16655 @cindex AI-0176 (Ada 2012 feature)
16658 Both universally and existentially quantified expressions are implemented.
16659 They use the new syntax for iterators proposed in AI05-139-2, as well as
16660 the standard Ada loop syntax.
16663 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
16666 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
16667 @cindex AI-0079 (Ada 2012 feature)
16670 Wide characters in the unicode category @i{other_format} are now allowed in
16671 source programs between tokens, but not within a token such as an identifier.
16674 RM References: 2.01 (4/2) 2.02 (7)
16677 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
16678 @cindex AI-0091 (Ada 2012 feature)
16681 Wide characters in the unicode category @i{other_format} are not permitted
16682 within an identifier, since this can be a security problem. The error
16683 message for this case has been improved to be more specific, but GNAT has
16684 never allowed such characters to appear in identifiers.
16687 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)
16690 @emph{AI-0100 Placement of pragmas (2010-07-01)}
16691 @cindex AI-0100 (Ada 2012 feature)
16694 This AI is an earlier version of AI-163. It simplifies the rules
16695 for legal placement of pragmas. In the case of lists that allow pragmas, if
16696 the list may have no elements, then the list may consist solely of pragmas.
16699 RM References: 2.08 (7)
16702 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
16703 @cindex AI-0163 (Ada 2012 feature)
16706 A statement sequence may be composed entirely of pragmas. It is no longer
16707 necessary to add a dummy @code{null} statement to make the sequence legal.
16710 RM References: 2.08 (7) 2.08 (16)
16714 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
16715 @cindex AI-0080 (Ada 2012 feature)
16718 This is an editorial change only, described as non-testable in the AI.
16721 RM References: 3.01 (7)
16725 @emph{AI-0183 Aspect specifications (2010-08-16)}
16726 @cindex AI-0183 (Ada 2012 feature)
16729 Aspect specifications have been fully implemented except for pre and post-
16730 conditions, and type invariants, which have their own separate AI's. All
16731 forms of declarations listed in the AI are supported. The following is a
16732 list of the aspects supported (with GNAT implementation aspects marked)
16734 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
16735 @item @code{Ada_2005} @tab -- GNAT
16736 @item @code{Ada_2012} @tab -- GNAT
16737 @item @code{Address} @tab
16738 @item @code{Alignment} @tab
16739 @item @code{Atomic} @tab
16740 @item @code{Atomic_Components} @tab
16741 @item @code{Bit_Order} @tab
16742 @item @code{Component_Size} @tab
16743 @item @code{Discard_Names} @tab
16744 @item @code{External_Tag} @tab
16745 @item @code{Favor_Top_Level} @tab -- GNAT
16746 @item @code{Inline} @tab
16747 @item @code{Inline_Always} @tab -- GNAT
16748 @item @code{Invariant} @tab
16749 @item @code{Machine_Radix} @tab
16750 @item @code{No_Return} @tab
16751 @item @code{Object_Size} @tab -- GNAT
16752 @item @code{Pack} @tab
16753 @item @code{Persistent_BSS} @tab -- GNAT
16754 @item @code{Post} @tab
16755 @item @code{Pre} @tab
16756 @item @code{Predicate} @tab
16757 @item @code{Preelaborable_Initialization} @tab
16758 @item @code{Pure_Function} @tab -- GNAT
16759 @item @code{Shared} @tab -- GNAT
16760 @item @code{Size} @tab
16761 @item @code{Storage_Pool} @tab
16762 @item @code{Storage_Size} @tab
16763 @item @code{Stream_Size} @tab
16764 @item @code{Suppress} @tab
16765 @item @code{Suppress_Debug_Info} @tab -- GNAT
16766 @item @code{Test_Case} @tab -- GNAT
16767 @item @code{Unchecked_Union} @tab
16768 @item @code{Universal_Aliasing} @tab -- GNAT
16769 @item @code{Unmodified} @tab -- GNAT
16770 @item @code{Unreferenced} @tab -- GNAT
16771 @item @code{Unreferenced_Objects} @tab -- GNAT
16772 @item @code{Unsuppress} @tab
16773 @item @code{Value_Size} @tab -- GNAT
16774 @item @code{Volatile} @tab
16775 @item @code{Volatile_Components}
16776 @item @code{Warnings} @tab -- GNAT
16780 Note that for aspects with an expression, e.g. @code{Size}, the expression is
16781 treated like a default expression (visibility is analyzed at the point of
16782 occurrence of the aspect, but evaluation of the expression occurs at the
16783 freeze point of the entity involved.
16786 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
16787 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
16788 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
16789 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
16790 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
16795 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
16796 @cindex AI-0128 (Ada 2012 feature)
16799 If an equality operator ("=") is declared for a type, then the implicitly
16800 declared inequality operator ("/=") is a primitive operation of the type.
16801 This is the only reasonable interpretation, and is the one always implemented
16802 by GNAT, but the RM was not entirely clear in making this point.
16805 RM References: 3.02.03 (6) 6.06 (6)
16808 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
16809 @cindex AI-0003 (Ada 2012 feature)
16812 In Ada 2012, a qualified expression is considered to be syntactically a name,
16813 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
16814 useful in disambiguating some cases of overloading.
16817 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
16821 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
16822 @cindex AI-0120 (Ada 2012 feature)
16825 This is an RM editorial change only. The section that lists objects that are
16826 constant failed to include the current instance of a protected object
16827 within a protected function. This has always been treated as a constant
16831 RM References: 3.03 (21)
16834 @emph{AI-0008 General access to constrained objects (0000-00-00)}
16835 @cindex AI-0008 (Ada 2012 feature)
16838 The wording in the RM implied that if you have a general access to a
16839 constrained object, it could be used to modify the discriminants. This was
16840 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
16841 has always done so in this situation.
16844 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
16848 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
16849 @cindex AI-0093 (Ada 2012 feature)
16852 This is an editorial change only, to make more widespread use of the Ada 2012
16853 ``immutably limited''.
16856 RM References: 3.03 (23.4/3)
16861 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
16862 @cindex AI-0096 (Ada 2012 feature)
16865 In general it is illegal for a type derived from a formal limited type to be
16866 nonlimited. This AI makes an exception to this rule: derivation is legal
16867 if it appears in the private part of the generic, and the formal type is not
16868 tagged. If the type is tagged, the legality check must be applied to the
16869 private part of the package.
16872 RM References: 3.04 (5.1/2) 6.02 (7)
16876 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
16877 @cindex AI-0181 (Ada 2012 feature)
16880 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
16881 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
16882 @code{Image} and @code{Value} attributes for the character types. Strictly
16883 speaking this is an inconsistency with Ada 95, but in practice the use of
16884 these attributes is so obscure that it will not cause problems.
16887 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
16891 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
16892 @cindex AI-0182 (Ada 2012 feature)
16895 This AI allows @code{Character'Value} to accept the string @code{'?'} where
16896 @code{?} is any character including non-graphic control characters. GNAT has
16897 always accepted such strings. It also allows strings such as
16898 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
16899 permission and raises @code{Constraint_Error}, as is certainly still
16903 RM References: 3.05 (56/2)
16907 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
16908 @cindex AI-0214 (Ada 2012 feature)
16911 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
16912 to have default expressions by allowing them when the type is limited. It
16913 is often useful to define a default value for a discriminant even though
16914 it can't be changed by assignment.
16917 RM References: 3.07 (9.1/2) 3.07.02 (3)
16921 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
16922 @cindex AI-0102 (Ada 2012 feature)
16925 It is illegal to assign an anonymous access constant to an anonymous access
16926 variable. The RM did not have a clear rule to prevent this, but GNAT has
16927 always generated an error for this usage.
16930 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
16934 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
16935 @cindex AI-0158 (Ada 2012 feature)
16938 This AI extends the syntax of membership tests to simplify complex conditions
16939 that can be expressed as membership in a subset of values of any type. It
16940 introduces syntax for a list of expressions that may be used in loop contexts
16944 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
16948 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
16949 @cindex AI-0173 (Ada 2012 feature)
16952 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
16953 with the tag of an abstract type, and @code{False} otherwise.
16956 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
16961 @emph{AI-0076 function with controlling result (0000-00-00)}
16962 @cindex AI-0076 (Ada 2012 feature)
16965 This is an editorial change only. The RM defines calls with controlling
16966 results, but uses the term ``function with controlling result'' without an
16967 explicit definition.
16970 RM References: 3.09.02 (2/2)
16974 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
16975 @cindex AI-0126 (Ada 2012 feature)
16978 This AI clarifies dispatching rules, and simply confirms that dispatching
16979 executes the operation of the parent type when there is no explicitly or
16980 implicitly declared operation for the descendant type. This has always been
16981 the case in all versions of GNAT.
16984 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
16988 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
16989 @cindex AI-0097 (Ada 2012 feature)
16992 The RM as written implied that in some cases it was possible to create an
16993 object of an abstract type, by having an abstract extension inherit a non-
16994 abstract constructor from its parent type. This mistake has been corrected
16995 in GNAT and in the RM, and this construct is now illegal.
16998 RM References: 3.09.03 (4/2)
17002 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
17003 @cindex AI-0203 (Ada 2012 feature)
17006 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
17007 permitted such usage.
17010 RM References: 3.09.03 (8/3)
17014 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
17015 @cindex AI-0198 (Ada 2012 feature)
17018 This AI resolves a conflict between two rules involving inherited abstract
17019 operations and predefined operators. If a derived numeric type inherits
17020 an abstract operator, it overrides the predefined one. This interpretation
17021 was always the one implemented in GNAT.
17024 RM References: 3.09.03 (4/3)
17027 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
17028 @cindex AI-0073 (Ada 2012 feature)
17031 This AI covers a number of issues regarding returning abstract types. In
17032 particular generic functions cannot have abstract result types or access
17033 result types designated an abstract type. There are some other cases which
17034 are detailed in the AI. Note that this binding interpretation has not been
17035 retrofitted to operate before Ada 2012 mode, since it caused a significant
17036 number of regressions.
17039 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
17043 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
17044 @cindex AI-0070 (Ada 2012 feature)
17047 This is an editorial change only, there are no testable consequences short of
17048 checking for the absence of generated code for an interface declaration.
17051 RM References: 3.09.04 (18/2)
17055 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
17056 @cindex AI-0208 (Ada 2012 feature)
17059 The wording in the Ada 2005 RM concerning characteristics of incomplete views
17060 was incorrect and implied that some programs intended to be legal were now
17061 illegal. GNAT had never considered such programs illegal, so it has always
17062 implemented the intent of this AI.
17065 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
17069 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
17070 @cindex AI-0162 (Ada 2012 feature)
17073 Incomplete types are made more useful by allowing them to be completed by
17074 private types and private extensions.
17077 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
17082 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
17083 @cindex AI-0098 (Ada 2012 feature)
17086 An unintentional omission in the RM implied some inconsistent restrictions on
17087 the use of anonymous access to subprogram values. These restrictions were not
17088 intentional, and have never been enforced by GNAT.
17091 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
17095 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
17096 @cindex AI-0199 (Ada 2012 feature)
17099 A choice list in a record aggregate can include several components of
17100 (distinct) anonymous access types as long as they have matching designated
17104 RM References: 4.03.01 (16)
17108 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
17109 @cindex AI-0220 (Ada 2012 feature)
17112 This AI addresses a wording problem in the RM that appears to permit some
17113 complex cases of aggregates with non-static discriminants. GNAT has always
17114 implemented the intended semantics.
17117 RM References: 4.03.01 (17)
17120 @emph{AI-0147 Conditional expressions (2009-03-29)}
17121 @cindex AI-0147 (Ada 2012 feature)
17124 Conditional expressions are permitted. The form of such an expression is:
17127 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
17130 The parentheses can be omitted in contexts where parentheses are present
17131 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
17132 clause is omitted, @b{else True} is assumed;
17133 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
17134 @emph{(A implies B)} in standard logic.
17137 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
17138 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
17142 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
17143 @cindex AI-0037 (Ada 2012 feature)
17146 This AI confirms that an association of the form @code{Indx => <>} in an
17147 array aggregate must raise @code{Constraint_Error} if @code{Indx}
17148 is out of range. The RM specified a range check on other associations, but
17149 not when the value of the association was defaulted. GNAT has always inserted
17150 a constraint check on the index value.
17153 RM References: 4.03.03 (29)
17157 @emph{AI-0123 Composability of equality (2010-04-13)}
17158 @cindex AI-0123 (Ada 2012 feature)
17161 Equality of untagged record composes, so that the predefined equality for a
17162 composite type that includes a component of some untagged record type
17163 @code{R} uses the equality operation of @code{R} (which may be user-defined
17164 or predefined). This makes the behavior of untagged records identical to that
17165 of tagged types in this respect.
17167 This change is an incompatibility with previous versions of Ada, but it
17168 corrects a non-uniformity that was often a source of confusion. Analysis of
17169 a large number of industrial programs indicates that in those rare cases
17170 where a composite type had an untagged record component with a user-defined
17171 equality, either there was no use of the composite equality, or else the code
17172 expected the same composability as for tagged types, and thus had a bug that
17173 would be fixed by this change.
17176 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
17181 @emph{AI-0088 The value of exponentiation (0000-00-00)}
17182 @cindex AI-0088 (Ada 2012 feature)
17185 This AI clarifies the equivalence rule given for the dynamic semantics of
17186 exponentiation: the value of the operation can be obtained by repeated
17187 multiplication, but the operation can be implemented otherwise (for example
17188 using the familiar divide-by-two-and-square algorithm, even if this is less
17189 accurate), and does not imply repeated reads of a volatile base.
17192 RM References: 4.05.06 (11)
17195 @emph{AI-0188 Case expressions (2010-01-09)}
17196 @cindex AI-0188 (Ada 2012 feature)
17199 Case expressions are permitted. This allows use of constructs such as:
17201 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
17205 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
17208 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
17209 @cindex AI-0104 (Ada 2012 feature)
17212 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
17213 @code{Constraint_Error} because the default value of the allocated object is
17214 @b{null}. This useless construct is illegal in Ada 2012.
17217 RM References: 4.08 (2)
17220 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
17221 @cindex AI-0157 (Ada 2012 feature)
17224 Allocation and Deallocation from an empty storage pool (i.e. allocation or
17225 deallocation of a pointer for which a static storage size clause of zero
17226 has been given) is now illegal and is detected as such. GNAT
17227 previously gave a warning but not an error.
17230 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
17233 @emph{AI-0179 Statement not required after label (2010-04-10)}
17234 @cindex AI-0179 (Ada 2012 feature)
17237 It is not necessary to have a statement following a label, so a label
17238 can appear at the end of a statement sequence without the need for putting a
17239 null statement afterwards, but it is not allowable to have only labels and
17240 no real statements in a statement sequence.
17243 RM References: 5.01 (2)
17247 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
17248 @cindex AI-139-2 (Ada 2012 feature)
17251 The new syntax for iterating over arrays and containers is now implemented.
17252 Iteration over containers is for now limited to read-only iterators. Only
17253 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
17256 RM References: 5.05
17259 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
17260 @cindex AI-0134 (Ada 2012 feature)
17263 For full conformance, the profiles of anonymous-access-to-subprogram
17264 parameters must match. GNAT has always enforced this rule.
17267 RM References: 6.03.01 (18)
17270 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
17271 @cindex AI-0207 (Ada 2012 feature)
17274 This AI confirms that access_to_constant indication must match for mode
17275 conformance. This was implemented in GNAT when the qualifier was originally
17276 introduced in Ada 2005.
17279 RM References: 6.03.01 (16/2)
17283 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
17284 @cindex AI-0046 (Ada 2012 feature)
17287 For full conformance, in the case of access parameters, the null exclusion
17288 must match (either both or neither must have @code{@b{not null}}).
17291 RM References: 6.03.02 (18)
17295 @emph{AI-0118 The association of parameter associations (0000-00-00)}
17296 @cindex AI-0118 (Ada 2012 feature)
17299 This AI clarifies the rules for named associations in subprogram calls and
17300 generic instantiations. The rules have been in place since Ada 83.
17303 RM References: 6.04.01 (2) 12.03 (9)
17307 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
17308 @cindex AI-0196 (Ada 2012 feature)
17311 Null exclusion checks are not made for @code{@b{out}} parameters when
17312 evaluating the actual parameters. GNAT has never generated these checks.
17315 RM References: 6.04.01 (13)
17318 @emph{AI-0015 Constant return objects (0000-00-00)}
17319 @cindex AI-0015 (Ada 2012 feature)
17322 The return object declared in an @i{extended_return_statement} may be
17323 declared constant. This was always intended, and GNAT has always allowed it.
17326 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
17331 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
17332 @cindex AI-0032 (Ada 2012 feature)
17335 If a function returns a class-wide type, the object of an extended return
17336 statement can be declared with a specific type that is covered by the class-
17337 wide type. This has been implemented in GNAT since the introduction of
17338 extended returns. Note AI-0103 complements this AI by imposing matching
17339 rules for constrained return types.
17342 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
17346 @emph{AI-0103 Static matching for extended return (2010-07-23)}
17347 @cindex AI-0103 (Ada 2012 feature)
17350 If the return subtype of a function is an elementary type or a constrained
17351 type, the subtype indication in an extended return statement must match
17352 statically this return subtype.
17355 RM References: 6.05 (5.2/2)
17359 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
17360 @cindex AI-0058 (Ada 2012 feature)
17363 The RM had some incorrect wording implying wrong treatment of abnormal
17364 completion in an extended return. GNAT has always implemented the intended
17365 correct semantics as described by this AI.
17368 RM References: 6.05 (22/2)
17372 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
17373 @cindex AI-0050 (Ada 2012 feature)
17376 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
17377 not take advantage of these incorrect permissions in any case.
17380 RM References: 6.05 (24/2)
17384 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
17385 @cindex AI-0125 (Ada 2012 feature)
17388 In Ada 2012, the declaration of a primitive operation of a type extension
17389 or private extension can also override an inherited primitive that is not
17390 visible at the point of this declaration.
17393 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
17396 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
17397 @cindex AI-0062 (Ada 2012 feature)
17400 A full constant may have a null exclusion even if its associated deferred
17401 constant does not. GNAT has always allowed this.
17404 RM References: 7.04 (6/2) 7.04 (7.1/2)
17408 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
17409 @cindex AI-0178 (Ada 2012 feature)
17412 This AI clarifies the role of incomplete views and plugs an omission in the
17413 RM. GNAT always correctly restricted the use of incomplete views and types.
17416 RM References: 7.05 (3/2) 7.05 (6/2)
17419 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
17420 @cindex AI-0087 (Ada 2012 feature)
17423 The actual for a formal nonlimited derived type cannot be limited. In
17424 particular, a formal derived type that extends a limited interface but which
17425 is not explicitly limited cannot be instantiated with a limited type.
17428 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
17431 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
17432 @cindex AI-0099 (Ada 2012 feature)
17435 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
17436 and therefore depends on the run-time characteristics of an object (i.e. its
17437 tag) and not on its nominal type. As the AI indicates: ``we do not expect
17438 this to affect any implementation''.
17441 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
17446 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
17447 @cindex AI-0064 (Ada 2012 feature)
17450 This is an editorial change only. The intended behavior is already checked
17451 by an existing ACATS test, which GNAT has always executed correctly.
17454 RM References: 7.06.01 (17.1/1)
17457 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
17458 @cindex AI-0026 (Ada 2012 feature)
17461 Record representation clauses concerning Unchecked_Union types cannot mention
17462 the discriminant of the type. The type of a component declared in the variant
17463 part of an Unchecked_Union cannot be controlled, have controlled components,
17464 nor have protected or task parts. If an Unchecked_Union type is declared
17465 within the body of a generic unit or its descendants, then the type of a
17466 component declared in the variant part cannot be a formal private type or a
17467 formal private extension declared within the same generic unit.
17470 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
17474 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
17475 @cindex AI-0205 (Ada 2012 feature)
17478 This AI corrects a simple omission in the RM. Return objects have always
17479 been visible within an extended return statement.
17482 RM References: 8.03 (17)
17486 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
17487 @cindex AI-0042 (Ada 2012 feature)
17490 This AI fixes a wording gap in the RM. An operation of a synchronized
17491 interface can be implemented by a protected or task entry, but the abstract
17492 operation is not being overridden in the usual sense, and it must be stated
17493 separately that this implementation is legal. This has always been the case
17497 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
17500 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
17501 @cindex AI-0030 (Ada 2012 feature)
17504 Requeue is permitted to a protected, synchronized or task interface primitive
17505 providing it is known that the overriding operation is an entry. Otherwise
17506 the requeue statement has the same effect as a procedure call. Use of pragma
17507 @code{Implemented} provides a way to impose a static requirement on the
17508 overriding operation by adhering to one of the implementation kinds: entry,
17509 protected procedure or any of the above.
17512 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
17513 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
17517 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
17518 @cindex AI-0201 (Ada 2012 feature)
17521 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
17522 attribute, then individual components may not be addressable by independent
17523 tasks. However, if the representation clause has no effect (is confirming),
17524 then independence is not compromised. Furthermore, in GNAT, specification of
17525 other appropriately addressable component sizes (e.g. 16 for 8-bit
17526 characters) also preserves independence. GNAT now gives very clear warnings
17527 both for the declaration of such a type, and for any assignment to its components.
17530 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
17533 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
17534 @cindex AI-0009 (Ada 2012 feature)
17537 This AI introduces the new pragmas @code{Independent} and
17538 @code{Independent_Components},
17539 which control guaranteeing independence of access to objects and components.
17540 The AI also requires independence not unaffected by confirming rep clauses.
17543 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
17544 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
17548 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
17549 @cindex AI-0072 (Ada 2012 feature)
17552 This AI clarifies that task signalling for reading @code{'Terminated} only
17553 occurs if the result is True. GNAT semantics has always been consistent with
17554 this notion of task signalling.
17557 RM References: 9.10 (6.1/1)
17560 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
17561 @cindex AI-0108 (Ada 2012 feature)
17564 This AI confirms that an incomplete type from a limited view does not have
17565 discriminants. This has always been the case in GNAT.
17568 RM References: 10.01.01 (12.3/2)
17571 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
17572 @cindex AI-0129 (Ada 2012 feature)
17575 This AI clarifies the description of limited views: a limited view of a
17576 package includes only one view of a type that has an incomplete declaration
17577 and a full declaration (there is no possible ambiguity in a client package).
17578 This AI also fixes an omission: a nested package in the private part has no
17579 limited view. GNAT always implemented this correctly.
17582 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
17587 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
17588 @cindex AI-0077 (Ada 2012 feature)
17591 This AI clarifies that a declaration does not include a context clause,
17592 and confirms that it is illegal to have a context in which both a limited
17593 and a nonlimited view of a package are accessible. Such double visibility
17594 was always rejected by GNAT.
17597 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
17600 @emph{AI-0122 Private with and children of generics (0000-00-00)}
17601 @cindex AI-0122 (Ada 2012 feature)
17604 This AI clarifies the visibility of private children of generic units within
17605 instantiations of a parent. GNAT has always handled this correctly.
17608 RM References: 10.01.02 (12/2)
17613 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
17614 @cindex AI-0040 (Ada 2012 feature)
17617 This AI confirms that a limited with clause in a child unit cannot name
17618 an ancestor of the unit. This has always been checked in GNAT.
17621 RM References: 10.01.02 (20/2)
17624 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
17625 @cindex AI-0132 (Ada 2012 feature)
17628 This AI fills a gap in the description of library unit pragmas. The pragma
17629 clearly must apply to a library unit, even if it does not carry the name
17630 of the enclosing unit. GNAT has always enforced the required check.
17633 RM References: 10.01.05 (7)
17637 @emph{AI-0034 Categorization of limited views (0000-00-00)}
17638 @cindex AI-0034 (Ada 2012 feature)
17641 The RM makes certain limited with clauses illegal because of categorization
17642 considerations, when the corresponding normal with would be legal. This is
17643 not intended, and GNAT has always implemented the recommended behavior.
17646 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
17650 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
17651 @cindex AI-0035 (Ada 2012 feature)
17654 This AI remedies some inconsistencies in the legality rules for Pure units.
17655 Derived access types are legal in a pure unit (on the assumption that the
17656 rule for a zero storage pool size has been enforced on the ancestor type).
17657 The rules are enforced in generic instances and in subunits. GNAT has always
17658 implemented the recommended behavior.
17661 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)
17665 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
17666 @cindex AI-0219 (Ada 2012 feature)
17669 This AI refines the rules for the cases with limited parameters which do not
17670 allow the implementations to omit ``redundant''. GNAT now properly conforms
17671 to the requirements of this binding interpretation.
17674 RM References: 10.02.01 (18/2)
17677 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
17678 @cindex AI-0043 (Ada 2012 feature)
17681 This AI covers various omissions in the RM regarding the raising of
17682 exceptions. GNAT has always implemented the intended semantics.
17685 RM References: 11.04.01 (10.1/2) 11 (2)
17689 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
17690 @cindex AI-0200 (Ada 2012 feature)
17693 This AI plugs a gap in the RM which appeared to allow some obviously intended
17694 illegal instantiations. GNAT has never allowed these instantiations.
17697 RM References: 12.07 (16)
17701 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
17702 @cindex AI-0112 (Ada 2012 feature)
17705 This AI concerns giving names to various representation aspects, but the
17706 practical effect is simply to make the use of duplicate
17707 @code{Atomic}[@code{_Components}],
17708 @code{Volatile}[@code{_Components}] and
17709 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
17710 now performs this required check.
17713 RM References: 13.01 (8)
17716 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
17717 @cindex AI-0106 (Ada 2012 feature)
17720 The RM appeared to allow representation pragmas on generic formal parameters,
17721 but this was not intended, and GNAT has never permitted this usage.
17724 RM References: 13.01 (9.1/1)
17728 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
17729 @cindex AI-0012 (Ada 2012 feature)
17732 It is now illegal to give an inappropriate component size or a pragma
17733 @code{Pack} that attempts to change the component size in the case of atomic
17734 or aliased components. Previously GNAT ignored such an attempt with a
17738 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
17742 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
17743 @cindex AI-0039 (Ada 2012 feature)
17746 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
17747 for stream attributes, but these were never useful and are now illegal. GNAT
17748 has always regarded such expressions as illegal.
17751 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
17755 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
17756 @cindex AI-0095 (Ada 2012 feature)
17759 The prefix of @code{'Address} cannot statically denote a subprogram with
17760 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
17761 @code{Program_Error} if the prefix denotes a subprogram with convention
17765 RM References: 13.03 (11/1)
17769 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
17770 @cindex AI-0116 (Ada 2012 feature)
17773 This AI requires that the alignment of a class-wide object be no greater
17774 than the alignment of any type in the class. GNAT has always followed this
17778 RM References: 13.03 (29) 13.11 (16)
17782 @emph{AI-0146 Type invariants (2009-09-21)}
17783 @cindex AI-0146 (Ada 2012 feature)
17786 Type invariants may be specified for private types using the aspect notation.
17787 Aspect @code{Invariant} may be specified for any private type,
17788 @code{Invariant'Class} can
17789 only be specified for tagged types, and is inherited by any descendent of the
17790 tagged types. The invariant is a boolean expression that is tested for being
17791 true in the following situations: conversions to the private type, object
17792 declarations for the private type that are default initialized, and
17794 parameters and returned result on return from any primitive operation for
17795 the type that is visible to a client.
17798 RM References: 13.03.03 (00)
17801 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
17802 @cindex AI-0078 (Ada 2012 feature)
17805 In Ada 2012, compilers are required to support unchecked conversion where the
17806 target alignment is a multiple of the source alignment. GNAT always supported
17807 this case (and indeed all cases of differing alignments, doing copies where
17808 required if the alignment was reduced).
17811 RM References: 13.09 (7)
17815 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
17816 @cindex AI-0195 (Ada 2012 feature)
17819 The handling of invalid values is now designated to be implementation
17820 defined. This is a documentation change only, requiring Annex M in the GNAT
17821 Reference Manual to document this handling.
17822 In GNAT, checks for invalid values are made
17823 only when necessary to avoid erroneous behavior. Operations like assignments
17824 which cannot cause erroneous behavior ignore the possibility of invalid
17825 values and do not do a check. The date given above applies only to the
17826 documentation change, this behavior has always been implemented by GNAT.
17829 RM References: 13.09.01 (10)
17832 @emph{AI-0193 Alignment of allocators (2010-09-16)}
17833 @cindex AI-0193 (Ada 2012 feature)
17836 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
17837 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
17841 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
17842 13.11.01 (2) 13.11.01 (3)
17846 @emph{AI-0177 Parameterized expressions (2010-07-10)}
17847 @cindex AI-0177 (Ada 2012 feature)
17850 The new Ada 2012 notion of parameterized expressions is implemented. The form
17853 @i{function specification} @b{is} (@i{expression})
17857 This is exactly equivalent to the
17858 corresponding function body that returns the expression, but it can appear
17859 in a package spec. Note that the expression must be parenthesized.
17862 RM References: 13.11.01 (3/2)
17865 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
17866 @cindex AI-0033 (Ada 2012 feature)
17869 Neither of these two pragmas may appear within a generic template, because
17870 the generic might be instantiated at other than the library level.
17873 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
17877 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
17878 @cindex AI-0161 (Ada 2012 feature)
17881 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
17882 of the default stream attributes for elementary types. If this restriction is
17883 in force, then it is necessary to provide explicit subprograms for any
17884 stream attributes used.
17887 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
17890 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
17891 @cindex AI-0194 (Ada 2012 feature)
17894 The @code{Stream_Size} attribute returns the default number of bits in the
17895 stream representation of the given type.
17896 This value is not affected by the presence
17897 of stream subprogram attributes for the type. GNAT has always implemented
17898 this interpretation.
17901 RM References: 13.13.02 (1.2/2)
17904 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
17905 @cindex AI-0109 (Ada 2012 feature)
17908 This AI is an editorial change only. It removes the need for a tag check
17909 that can never fail.
17912 RM References: 13.13.02 (34/2)
17915 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
17916 @cindex AI-0007 (Ada 2012 feature)
17919 The RM as written appeared to limit the possibilities of declaring read
17920 attribute procedures for private scalar types. This limitation was not
17921 intended, and has never been enforced by GNAT.
17924 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
17928 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
17929 @cindex AI-0065 (Ada 2012 feature)
17932 This AI clarifies the fact that all remote access types support external
17933 streaming. This fixes an obvious oversight in the definition of the
17934 language, and GNAT always implemented the intended correct rules.
17937 RM References: 13.13.02 (52/2)
17940 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
17941 @cindex AI-0019 (Ada 2012 feature)
17944 The RM suggests that primitive subprograms of a specific tagged type are
17945 frozen when the tagged type is frozen. This would be an incompatible change
17946 and is not intended. GNAT has never attempted this kind of freezing and its
17947 behavior is consistent with the recommendation of this AI.
17950 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)
17953 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
17954 @cindex AI-0017 (Ada 2012 feature)
17957 So-called ``Taft-amendment types'' (i.e., types that are completed in package
17958 bodies) are not frozen by the occurrence of bodies in the
17959 enclosing declarative part. GNAT always implemented this properly.
17962 RM References: 13.14 (3/1)
17966 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
17967 @cindex AI-0060 (Ada 2012 feature)
17970 This AI extends the definition of remote access types to include access
17971 to limited, synchronized, protected or task class-wide interface types.
17972 GNAT already implemented this extension.
17975 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
17978 @emph{AI-0114 Classification of letters (0000-00-00)}
17979 @cindex AI-0114 (Ada 2012 feature)
17982 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
17983 181 (@code{MICRO SIGN}), and
17984 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
17985 lower case letters by Unicode.
17986 However, they are not allowed in identifiers, and they
17987 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
17988 This behavior is consistent with that defined in Ada 95.
17991 RM References: A.03.02 (59) A.04.06 (7)
17995 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
17996 @cindex AI-0185 (Ada 2012 feature)
17999 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
18000 classification functions for @code{Wide_Character} and
18001 @code{Wide_Wide_Character}, as well as providing
18002 case folding routines for @code{Wide_[Wide_]Character} and
18003 @code{Wide_[Wide_]String}.
18006 RM References: A.03.05 (0) A.03.06 (0)
18010 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
18011 @cindex AI-0031 (Ada 2012 feature)
18014 A new version of @code{Find_Token} is added to all relevant string packages,
18015 with an extra parameter @code{From}. Instead of starting at the first
18016 character of the string, the search for a matching Token starts at the
18017 character indexed by the value of @code{From}.
18018 These procedures are available in all versions of Ada
18019 but if used in versions earlier than Ada 2012 they will generate a warning
18020 that an Ada 2012 subprogram is being used.
18023 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
18028 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
18029 @cindex AI-0056 (Ada 2012 feature)
18032 The wording in the Ada 2005 RM implied an incompatible handling of the
18033 @code{Index} functions, resulting in raising an exception instead of
18034 returning zero in some situations.
18035 This was not intended and has been corrected.
18036 GNAT always returned zero, and is thus consistent with this AI.
18039 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
18043 @emph{AI-0137 String encoding package (2010-03-25)}
18044 @cindex AI-0137 (Ada 2012 feature)
18047 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
18048 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
18049 and @code{Wide_Wide_Strings} have been
18050 implemented. These packages (whose documentation can be found in the spec
18051 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
18052 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
18053 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
18054 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
18055 UTF-16), as well as conversions between the different UTF encodings. With
18056 the exception of @code{Wide_Wide_Strings}, these packages are available in
18057 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
18058 The @code{Wide_Wide_Strings package}
18059 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
18060 mode since it uses @code{Wide_Wide_Character}).
18063 RM References: A.04.11
18066 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
18067 @cindex AI-0038 (Ada 2012 feature)
18070 These are minor errors in the description on three points. The intent on
18071 all these points has always been clear, and GNAT has always implemented the
18072 correct intended semantics.
18075 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)
18078 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
18079 @cindex AI-0044 (Ada 2012 feature)
18082 This AI places restrictions on allowed instantiations of generic containers.
18083 These restrictions are not checked by the compiler, so there is nothing to
18084 change in the implementation. This affects only the RM documentation.
18087 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)
18090 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
18091 @cindex AI-0127 (Ada 2012 feature)
18094 This package provides an interface for identifying the current locale.
18097 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
18098 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
18103 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
18104 @cindex AI-0002 (Ada 2012 feature)
18107 The compiler is not required to support exporting an Ada subprogram with
18108 convention C if there are parameters or a return type of an unconstrained
18109 array type (such as @code{String}). GNAT allows such declarations but
18110 generates warnings. It is possible, but complicated, to write the
18111 corresponding C code and certainly such code would be specific to GNAT and
18115 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
18119 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
18120 @cindex AI05-0216 (Ada 2012 feature)
18123 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
18124 forbid tasks declared locally within subprograms, or functions returning task
18125 objects, and that is the implementation that GNAT has always provided.
18126 However the language in the RM was not sufficiently clear on this point.
18127 Thus this is a documentation change in the RM only.
18130 RM References: D.07 (3/3)
18133 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
18134 @cindex AI-0211 (Ada 2012 feature)
18137 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
18138 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
18141 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
18144 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
18145 @cindex AI-0190 (Ada 2012 feature)
18148 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
18149 used to control storage pools globally.
18150 In particular, you can force every access
18151 type that is used for allocation (@b{new}) to have an explicit storage pool,
18152 or you can declare a pool globally to be used for all access types that lack
18156 RM References: D.07 (8)
18159 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
18160 @cindex AI-0189 (Ada 2012 feature)
18163 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
18164 which says that no dynamic allocation will occur once elaboration is
18166 In general this requires a run-time check, which is not required, and which
18167 GNAT does not attempt. But the static cases of allocators in a task body or
18168 in the body of the main program are detected and flagged at compile or bind
18172 RM References: D.07 (19.1/2) H.04 (23.3/2)
18175 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
18176 @cindex AI-0171 (Ada 2012 feature)
18179 A new package @code{System.Multiprocessors} is added, together with the
18180 definition of pragma @code{CPU} for controlling task affinity. A new no
18181 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
18182 is added to the Ravenscar profile.
18185 RM References: D.13.01 (4/2) D.16
18189 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
18190 @cindex AI-0210 (Ada 2012 feature)
18193 This is a documentation only issue regarding wording of metric requirements,
18194 that does not affect the implementation of the compiler.
18197 RM References: D.15 (24/2)
18201 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
18202 @cindex AI-0206 (Ada 2012 feature)
18205 Remote types packages are now allowed to depend on preelaborated packages.
18206 This was formerly considered illegal.
18209 RM References: E.02.02 (6)
18214 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
18215 @cindex AI-0152 (Ada 2012 feature)
18218 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
18219 where the type of the returned value is an anonymous access type.
18222 RM References: H.04 (8/1)
18226 @node Obsolescent Features
18227 @chapter Obsolescent Features
18230 This chapter describes features that are provided by GNAT, but are
18231 considered obsolescent since there are preferred ways of achieving
18232 the same effect. These features are provided solely for historical
18233 compatibility purposes.
18236 * pragma No_Run_Time::
18237 * pragma Ravenscar::
18238 * pragma Restricted_Run_Time::
18241 @node pragma No_Run_Time
18242 @section pragma No_Run_Time
18244 The pragma @code{No_Run_Time} is used to achieve an affect similar
18245 to the use of the "Zero Foot Print" configurable run time, but without
18246 requiring a specially configured run time. The result of using this
18247 pragma, which must be used for all units in a partition, is to restrict
18248 the use of any language features requiring run-time support code. The
18249 preferred usage is to use an appropriately configured run-time that
18250 includes just those features that are to be made accessible.
18252 @node pragma Ravenscar
18253 @section pragma Ravenscar
18255 The pragma @code{Ravenscar} has exactly the same effect as pragma
18256 @code{Profile (Ravenscar)}. The latter usage is preferred since it
18257 is part of the new Ada 2005 standard.
18259 @node pragma Restricted_Run_Time
18260 @section pragma Restricted_Run_Time
18262 The pragma @code{Restricted_Run_Time} has exactly the same effect as
18263 pragma @code{Profile (Restricted)}. The latter usage is
18264 preferred since the Ada 2005 pragma @code{Profile} is intended for
18265 this kind of implementation dependent addition.
18268 @c GNU Free Documentation License
18270 @node Index,,GNU Free Documentation License, Top