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 Defined Restrictions::
75 * Implementation Advice::
76 * Implementation Defined Characteristics::
77 * Intrinsic Subprograms::
78 * Representation Clauses and Pragmas::
79 * Standard Library Routines::
80 * The Implementation of Standard I/O::
82 * Interfacing to Other Languages::
83 * Specialized Needs Annexes::
84 * Implementation of Specific Ada Features::
85 * Implementation of Ada 2012 Features::
86 * Obsolescent Features::
87 * GNU Free Documentation License::
90 --- The Detailed Node Listing ---
94 * What This Reference Manual Contains::
95 * Related Information::
97 Implementation Defined Pragmas
99 * Pragma Abort_Defer::
108 * Pragma Assertion_Policy::
109 * Pragma Assume_No_Invalid_Values::
111 * Pragma C_Pass_By_Copy::
113 * Pragma Check_Name::
114 * Pragma Check_Policy::
116 * Pragma Common_Object::
117 * Pragma Compile_Time_Error::
118 * Pragma Compile_Time_Warning::
119 * Pragma Compiler_Unit::
120 * Pragma Complete_Representation::
121 * Pragma Complex_Representation::
122 * Pragma Component_Alignment::
123 * Pragma Convention_Identifier::
125 * Pragma CPP_Constructor::
126 * Pragma CPP_Virtual::
127 * Pragma CPP_Vtable::
129 * Pragma Debug_Policy::
130 * Pragma Detect_Blocking::
131 * Pragma Elaboration_Checks::
133 * Pragma Export_Exception::
134 * Pragma Export_Function::
135 * Pragma Export_Object::
136 * Pragma Export_Procedure::
137 * Pragma Export_Value::
138 * Pragma Export_Valued_Procedure::
139 * Pragma Extend_System::
140 * Pragma Extensions_Allowed::
142 * Pragma External_Name_Casing::
144 * Pragma Favor_Top_Level::
145 * Pragma Finalize_Storage_Only::
146 * Pragma Float_Representation::
148 * Pragma Implemented::
149 * Pragma Implicit_Packing::
150 * Pragma Import_Exception::
151 * Pragma Import_Function::
152 * Pragma Import_Object::
153 * Pragma Import_Procedure::
154 * Pragma Import_Valued_Procedure::
155 * Pragma Initialize_Scalars::
156 * Pragma Inline_Always::
157 * Pragma Inline_Generic::
159 * Pragma Interface_Name::
160 * Pragma Interrupt_Handler::
161 * Pragma Interrupt_State::
163 * Pragma Keep_Names::
166 * Pragma Linker_Alias::
167 * Pragma Linker_Constructor::
168 * Pragma Linker_Destructor::
169 * Pragma Linker_Section::
170 * Pragma Long_Float::
171 * Pragma Machine_Attribute::
173 * Pragma Main_Storage::
176 * Pragma No_Strict_Aliasing ::
177 * Pragma Normalize_Scalars::
178 * Pragma Obsolescent::
179 * Pragma Optimize_Alignment::
182 * Pragma Persistent_BSS::
184 * Pragma Postcondition::
185 * Pragma Precondition::
186 * Pragma Profile (Ravenscar)::
187 * Pragma Profile (Restricted)::
188 * Pragma Psect_Object::
189 * Pragma Pure_Function::
190 * Pragma Remote_Access_Type::
191 * Pragma Restriction_Warnings::
193 * Pragma Short_Circuit_And_Or::
194 * Pragma Short_Descriptors::
195 * Pragma Simple_Storage_Pool_Type::
196 * Pragma Source_File_Name::
197 * Pragma Source_File_Name_Project::
198 * Pragma Source_Reference::
199 * Pragma Static_Elaboration_Desired::
200 * Pragma Stream_Convert::
201 * Pragma Style_Checks::
204 * Pragma Suppress_All::
205 * Pragma Suppress_Exception_Locations::
206 * Pragma Suppress_Initialization::
209 * Pragma Task_Storage::
211 * Pragma Thread_Local_Storage::
212 * Pragma Time_Slice::
214 * Pragma Unchecked_Union::
215 * Pragma Unimplemented_Unit::
216 * Pragma Universal_Aliasing ::
217 * Pragma Universal_Data::
218 * Pragma Unmodified::
219 * Pragma Unreferenced::
220 * Pragma Unreferenced_Objects::
221 * Pragma Unreserve_All_Interrupts::
222 * Pragma Unsuppress::
223 * Pragma Use_VADS_Size::
224 * Pragma Validity_Checks::
227 * Pragma Weak_External::
228 * Pragma Wide_Character_Encoding::
230 Implementation Defined Attributes
241 * Default_Bit_Order::
253 * Has_Access_Values::
254 * Has_Discriminants::
261 * Max_Interrupt_Priority::
263 * Maximum_Alignment::
268 * Passed_By_Reference::
274 * Simple_Storage_Pool::
278 * System_Allocator_Alignment::
284 * Unconstrained_Array::
285 * Universal_Literal_String::
286 * Unrestricted_Access::
292 Implementation Defined Restrictions
294 * Partition-Wide Restrictions::
295 * Program Unit Level Restrictions::
297 Partition-Wide Restrictions
299 * Immediate_Reclamation::
300 * Max_Asynchronous_Select_Nesting::
301 * Max_Entry_Queue_Length::
302 * Max_Protected_Entries::
303 * Max_Select_Alternatives::
304 * Max_Storage_At_Blocking::
307 * No_Abort_Statements::
308 * No_Access_Parameter_Allocators::
309 * No_Access_Subprograms::
311 * No_Anonymous_Allocators::
314 * No_Default_Initialization::
317 * No_Direct_Boolean_Operators::
319 * No_Dispatching_Calls::
320 * No_Dynamic_Attachment::
321 * No_Dynamic_Priorities::
322 * No_Entry_Calls_In_Elaboration_Code::
323 * No_Enumeration_Maps::
324 * No_Exception_Handlers::
325 * No_Exception_Propagation::
326 * No_Exception_Registration::
330 * No_Floating_Point::
331 * No_Implicit_Conditionals::
332 * No_Implicit_Dynamic_Code::
333 * No_Implicit_Heap_Allocations::
334 * No_Implicit_Loops::
335 * No_Initialize_Scalars::
337 * No_Local_Allocators::
338 * No_Local_Protected_Objects::
339 * No_Local_Timing_Events::
340 * No_Nested_Finalization::
341 * No_Protected_Type_Allocators::
342 * No_Protected_Types::
345 * No_Relative_Delay::
346 * No_Requeue_Statements::
347 * No_Secondary_Stack::
348 * No_Select_Statements::
349 * No_Specific_Termination_Handlers::
350 * No_Specification_of_Aspect::
351 * No_Standard_Allocators_After_Elaboration::
352 * No_Standard_Storage_Pools::
353 * No_Stream_Optimizations::
355 * No_Task_Allocators::
356 * No_Task_Attributes_Package::
357 * No_Task_Hierarchy::
358 * No_Task_Termination::
360 * No_Terminate_Alternatives::
361 * No_Unchecked_Access::
363 * Static_Priorities::
364 * Static_Storage_Size::
366 Program Unit Level Restrictions
368 * No_Elaboration_Code::
370 * No_Implementation_Aspect_Specifications::
371 * No_Implementation_Attributes::
372 * No_Implementation_Identifiers::
373 * No_Implementation_Pragmas::
374 * No_Implementation_Restrictions::
375 * No_Implementation_Units::
376 * No_Implicit_Aliasing::
377 * No_Obsolescent_Features::
378 * No_Wide_Characters::
381 The Implementation of Standard I/O
383 * Standard I/O Packages::
389 * Wide_Wide_Text_IO::
393 * Filenames encoding::
395 * Operations on C Streams::
396 * Interfacing to C Streams::
400 * Ada.Characters.Latin_9 (a-chlat9.ads)::
401 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
402 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
403 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
404 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
405 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
406 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
407 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
408 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
409 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
410 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
411 * Ada.Command_Line.Environment (a-colien.ads)::
412 * Ada.Command_Line.Remove (a-colire.ads)::
413 * Ada.Command_Line.Response_File (a-clrefi.ads)::
414 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
415 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
416 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
417 * Ada.Exceptions.Traceback (a-exctra.ads)::
418 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
419 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
420 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
421 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
422 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
423 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
424 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
425 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
426 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
427 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
428 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
429 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
430 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
431 * GNAT.Altivec (g-altive.ads)::
432 * GNAT.Altivec.Conversions (g-altcon.ads)::
433 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
434 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
435 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
436 * GNAT.Array_Split (g-arrspl.ads)::
437 * GNAT.AWK (g-awk.ads)::
438 * GNAT.Bounded_Buffers (g-boubuf.ads)::
439 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
440 * GNAT.Bubble_Sort (g-bubsor.ads)::
441 * GNAT.Bubble_Sort_A (g-busora.ads)::
442 * GNAT.Bubble_Sort_G (g-busorg.ads)::
443 * GNAT.Byte_Order_Mark (g-byorma.ads)::
444 * GNAT.Byte_Swapping (g-bytswa.ads)::
445 * GNAT.Calendar (g-calend.ads)::
446 * GNAT.Calendar.Time_IO (g-catiio.ads)::
447 * GNAT.Case_Util (g-casuti.ads)::
448 * GNAT.CGI (g-cgi.ads)::
449 * GNAT.CGI.Cookie (g-cgicoo.ads)::
450 * GNAT.CGI.Debug (g-cgideb.ads)::
451 * GNAT.Command_Line (g-comlin.ads)::
452 * GNAT.Compiler_Version (g-comver.ads)::
453 * GNAT.Ctrl_C (g-ctrl_c.ads)::
454 * GNAT.CRC32 (g-crc32.ads)::
455 * GNAT.Current_Exception (g-curexc.ads)::
456 * GNAT.Debug_Pools (g-debpoo.ads)::
457 * GNAT.Debug_Utilities (g-debuti.ads)::
458 * GNAT.Decode_String (g-decstr.ads)::
459 * GNAT.Decode_UTF8_String (g-deutst.ads)::
460 * GNAT.Directory_Operations (g-dirope.ads)::
461 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
462 * GNAT.Dynamic_HTables (g-dynhta.ads)::
463 * GNAT.Dynamic_Tables (g-dyntab.ads)::
464 * GNAT.Encode_String (g-encstr.ads)::
465 * GNAT.Encode_UTF8_String (g-enutst.ads)::
466 * GNAT.Exception_Actions (g-excact.ads)::
467 * GNAT.Exception_Traces (g-exctra.ads)::
468 * GNAT.Exceptions (g-except.ads)::
469 * GNAT.Expect (g-expect.ads)::
470 * GNAT.Expect.TTY (g-exptty.ads)::
471 * GNAT.Float_Control (g-flocon.ads)::
472 * GNAT.Heap_Sort (g-heasor.ads)::
473 * GNAT.Heap_Sort_A (g-hesora.ads)::
474 * GNAT.Heap_Sort_G (g-hesorg.ads)::
475 * GNAT.HTable (g-htable.ads)::
476 * GNAT.IO (g-io.ads)::
477 * GNAT.IO_Aux (g-io_aux.ads)::
478 * GNAT.Lock_Files (g-locfil.ads)::
479 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
480 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
481 * GNAT.MD5 (g-md5.ads)::
482 * GNAT.Memory_Dump (g-memdum.ads)::
483 * GNAT.Most_Recent_Exception (g-moreex.ads)::
484 * GNAT.OS_Lib (g-os_lib.ads)::
485 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
486 * GNAT.Random_Numbers (g-rannum.ads)::
487 * GNAT.Regexp (g-regexp.ads)::
488 * GNAT.Registry (g-regist.ads)::
489 * GNAT.Regpat (g-regpat.ads)::
490 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
491 * GNAT.Semaphores (g-semaph.ads)::
492 * GNAT.Serial_Communications (g-sercom.ads)::
493 * GNAT.SHA1 (g-sha1.ads)::
494 * GNAT.SHA224 (g-sha224.ads)::
495 * GNAT.SHA256 (g-sha256.ads)::
496 * GNAT.SHA384 (g-sha384.ads)::
497 * GNAT.SHA512 (g-sha512.ads)::
498 * GNAT.Signals (g-signal.ads)::
499 * GNAT.Sockets (g-socket.ads)::
500 * GNAT.Source_Info (g-souinf.ads)::
501 * GNAT.Spelling_Checker (g-speche.ads)::
502 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
503 * GNAT.Spitbol.Patterns (g-spipat.ads)::
504 * GNAT.Spitbol (g-spitbo.ads)::
505 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
506 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
507 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
508 * GNAT.SSE (g-sse.ads)::
509 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
510 * GNAT.Strings (g-string.ads)::
511 * GNAT.String_Split (g-strspl.ads)::
512 * GNAT.Table (g-table.ads)::
513 * GNAT.Task_Lock (g-tasloc.ads)::
514 * GNAT.Threads (g-thread.ads)::
515 * GNAT.Time_Stamp (g-timsta.ads)::
516 * GNAT.Traceback (g-traceb.ads)::
517 * GNAT.Traceback.Symbolic (g-trasym.ads)::
518 * GNAT.UTF_32 (g-utf_32.ads)::
519 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
520 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
521 * GNAT.Wide_String_Split (g-wistsp.ads)::
522 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
523 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
524 * Interfaces.C.Extensions (i-cexten.ads)::
525 * Interfaces.C.Streams (i-cstrea.ads)::
526 * Interfaces.CPP (i-cpp.ads)::
527 * Interfaces.Packed_Decimal (i-pacdec.ads)::
528 * Interfaces.VxWorks (i-vxwork.ads)::
529 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
530 * System.Address_Image (s-addima.ads)::
531 * System.Assertions (s-assert.ads)::
532 * System.Memory (s-memory.ads)::
533 * System.Partition_Interface (s-parint.ads)::
534 * System.Pool_Global (s-pooglo.ads)::
535 * System.Pool_Local (s-pooloc.ads)::
536 * System.Restrictions (s-restri.ads)::
537 * System.Rident (s-rident.ads)::
538 * System.Strings.Stream_Ops (s-ststop.ads)::
539 * System.Task_Info (s-tasinf.ads)::
540 * System.Wch_Cnv (s-wchcnv.ads)::
541 * System.Wch_Con (s-wchcon.ads)::
545 * Text_IO Stream Pointer Positioning::
546 * Text_IO Reading and Writing Non-Regular Files::
548 * Treating Text_IO Files as Streams::
549 * Text_IO Extensions::
550 * Text_IO Facilities for Unbounded Strings::
554 * Wide_Text_IO Stream Pointer Positioning::
555 * Wide_Text_IO Reading and Writing Non-Regular Files::
559 * Wide_Wide_Text_IO Stream Pointer Positioning::
560 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
562 Interfacing to Other Languages
565 * Interfacing to C++::
566 * Interfacing to COBOL::
567 * Interfacing to Fortran::
568 * Interfacing to non-GNAT Ada code::
570 Specialized Needs Annexes
572 Implementation of Specific Ada Features
573 * Machine Code Insertions::
574 * GNAT Implementation of Tasking::
575 * GNAT Implementation of Shared Passive Packages::
576 * Code Generation for Array Aggregates::
577 * The Size of Discriminated Records with Default Discriminants::
578 * Strict Conformance to the Ada Reference Manual::
580 Implementation of Ada 2012 Features
584 GNU Free Documentation License
591 @node About This Guide
592 @unnumbered About This Guide
595 This manual contains useful information in writing programs using the
596 @value{EDITION} compiler. It includes information on implementation dependent
597 characteristics of @value{EDITION}, including all the information required by
598 Annex M of the Ada language standard.
600 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
601 Ada 83 compatibility mode.
602 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
603 but you can override with a compiler switch
604 to explicitly specify the language version.
605 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
606 @value{EDITION} User's Guide}, for details on these switches.)
607 Throughout this manual, references to ``Ada'' without a year suffix
608 apply to both the Ada 95 and Ada 2005 versions of the language.
610 Ada is designed to be highly portable.
611 In general, a program will have the same effect even when compiled by
612 different compilers on different platforms.
613 However, since Ada is designed to be used in a
614 wide variety of applications, it also contains a number of system
615 dependent features to be used in interfacing to the external world.
616 @cindex Implementation-dependent features
619 Note: Any program that makes use of implementation-dependent features
620 may be non-portable. You should follow good programming practice and
621 isolate and clearly document any sections of your program that make use
622 of these features in a non-portable manner.
625 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
626 ``GNAT'' in the remainder of this document.
630 * What This Reference Manual Contains::
632 * Related Information::
635 @node What This Reference Manual Contains
636 @unnumberedsec What This Reference Manual Contains
639 This reference manual contains the following chapters:
643 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
644 pragmas, which can be used to extend and enhance the functionality of the
648 @ref{Implementation Defined Attributes}, lists GNAT
649 implementation-dependent attributes, which can be used to extend and
650 enhance the functionality of the compiler.
653 @ref{Implementation Defined Restrictions}, lists GNAT
654 implementation-dependent restrictions, which can be used to extend and
655 enhance the functionality of the compiler.
658 @ref{Implementation Advice}, provides information on generally
659 desirable behavior which are not requirements that all compilers must
660 follow since it cannot be provided on all systems, or which may be
661 undesirable on some systems.
664 @ref{Implementation Defined Characteristics}, provides a guide to
665 minimizing implementation dependent features.
668 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
669 implemented by GNAT, and how they can be imported into user
670 application programs.
673 @ref{Representation Clauses and Pragmas}, describes in detail the
674 way that GNAT represents data, and in particular the exact set
675 of representation clauses and pragmas that is accepted.
678 @ref{Standard Library Routines}, provides a listing of packages and a
679 brief description of the functionality that is provided by Ada's
680 extensive set of standard library routines as implemented by GNAT@.
683 @ref{The Implementation of Standard I/O}, details how the GNAT
684 implementation of the input-output facilities.
687 @ref{The GNAT Library}, is a catalog of packages that complement
688 the Ada predefined library.
691 @ref{Interfacing to Other Languages}, describes how programs
692 written in Ada using GNAT can be interfaced to other programming
695 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
696 of the specialized needs annexes.
699 @ref{Implementation of Specific Ada Features}, discusses issues related
700 to GNAT's implementation of machine code insertions, tasking, and several
704 @ref{Implementation of Ada 2012 Features}, describes the status of the
705 GNAT implementation of the Ada 2012 language standard.
708 @ref{Obsolescent Features} documents implementation dependent features,
709 including pragmas and attributes, which are considered obsolescent, since
710 there are other preferred ways of achieving the same results. These
711 obsolescent forms are retained for backwards compatibility.
715 @cindex Ada 95 Language Reference Manual
716 @cindex Ada 2005 Language Reference Manual
718 This reference manual assumes a basic familiarity with the Ada 95 language, as
719 described in the International Standard ANSI/ISO/IEC-8652:1995,
721 It does not require knowledge of the new features introduced by Ada 2005,
722 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
724 Both reference manuals are included in the GNAT documentation
728 @unnumberedsec Conventions
729 @cindex Conventions, typographical
730 @cindex Typographical conventions
733 Following are examples of the typographical and graphic conventions used
738 @code{Functions}, @code{utility program names}, @code{standard names},
745 @file{File names}, @samp{button names}, and @samp{field names}.
748 @code{Variables}, @env{environment variables}, and @var{metasyntactic
755 [optional information or parameters]
758 Examples are described by text
760 and then shown this way.
765 Commands that are entered by the user are preceded in this manual by the
766 characters @samp{$ } (dollar sign followed by space). If your system uses this
767 sequence as a prompt, then the commands will appear exactly as you see them
768 in the manual. If your system uses some other prompt, then the command will
769 appear with the @samp{$} replaced by whatever prompt character you are using.
771 @node Related Information
772 @unnumberedsec Related Information
774 See the following documents for further information on GNAT:
778 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
779 @value{EDITION} User's Guide}, which provides information on how to use the
780 GNAT compiler system.
783 @cite{Ada 95 Reference Manual}, which contains all reference
784 material for the Ada 95 programming language.
787 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
788 of the Ada 95 standard. The annotations describe
789 detailed aspects of the design decision, and in particular contain useful
790 sections on Ada 83 compatibility.
793 @cite{Ada 2005 Reference Manual}, which contains all reference
794 material for the Ada 2005 programming language.
797 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
798 of the Ada 2005 standard. The annotations describe
799 detailed aspects of the design decision, and in particular contain useful
800 sections on Ada 83 and Ada 95 compatibility.
803 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
804 which contains specific information on compatibility between GNAT and
808 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
809 describes in detail the pragmas and attributes provided by the DEC Ada 83
814 @node Implementation Defined Pragmas
815 @chapter Implementation Defined Pragmas
818 Ada defines a set of pragmas that can be used to supply additional
819 information to the compiler. These language defined pragmas are
820 implemented in GNAT and work as described in the Ada Reference Manual.
822 In addition, Ada allows implementations to define additional pragmas
823 whose meaning is defined by the implementation. GNAT provides a number
824 of these implementation-defined pragmas, which can be used to extend
825 and enhance the functionality of the compiler. This section of the GNAT
826 Reference Manual describes these additional pragmas.
828 Note that any program using these pragmas might not be portable to other
829 compilers (although GNAT implements this set of pragmas on all
830 platforms). Therefore if portability to other compilers is an important
831 consideration, the use of these pragmas should be minimized.
834 * Pragma Abort_Defer::
843 * Pragma Assertion_Policy::
844 * Pragma Assume_No_Invalid_Values::
846 * Pragma C_Pass_By_Copy::
848 * Pragma Check_Name::
849 * Pragma Check_Policy::
851 * Pragma Common_Object::
852 * Pragma Compile_Time_Error::
853 * Pragma Compile_Time_Warning::
854 * Pragma Compiler_Unit::
855 * Pragma Complete_Representation::
856 * Pragma Complex_Representation::
857 * Pragma Component_Alignment::
858 * Pragma Convention_Identifier::
860 * Pragma CPP_Constructor::
861 * Pragma CPP_Virtual::
862 * Pragma CPP_Vtable::
864 * Pragma Debug_Policy::
865 * Pragma Detect_Blocking::
866 * Pragma Elaboration_Checks::
868 * Pragma Export_Exception::
869 * Pragma Export_Function::
870 * Pragma Export_Object::
871 * Pragma Export_Procedure::
872 * Pragma Export_Value::
873 * Pragma Export_Valued_Procedure::
874 * Pragma Extend_System::
875 * Pragma Extensions_Allowed::
877 * Pragma External_Name_Casing::
879 * Pragma Favor_Top_Level::
880 * Pragma Finalize_Storage_Only::
881 * Pragma Float_Representation::
883 * Pragma Implemented::
884 * Pragma Implicit_Packing::
885 * Pragma Import_Exception::
886 * Pragma Import_Function::
887 * Pragma Import_Object::
888 * Pragma Import_Procedure::
889 * Pragma Import_Valued_Procedure::
890 * Pragma Initialize_Scalars::
891 * Pragma Inline_Always::
892 * Pragma Inline_Generic::
894 * Pragma Interface_Name::
895 * Pragma Interrupt_Handler::
896 * Pragma Interrupt_State::
898 * Pragma Keep_Names::
901 * Pragma Linker_Alias::
902 * Pragma Linker_Constructor::
903 * Pragma Linker_Destructor::
904 * Pragma Linker_Section::
905 * Pragma Long_Float::
906 * Pragma Machine_Attribute::
908 * Pragma Main_Storage::
911 * Pragma No_Strict_Aliasing::
912 * Pragma Normalize_Scalars::
913 * Pragma Obsolescent::
914 * Pragma Optimize_Alignment::
917 * Pragma Persistent_BSS::
919 * Pragma Postcondition::
920 * Pragma Precondition::
921 * Pragma Profile (Ravenscar)::
922 * Pragma Profile (Restricted)::
923 * Pragma Psect_Object::
924 * Pragma Pure_Function::
925 * Pragma Remote_Access_Type::
926 * Pragma Restriction_Warnings::
928 * Pragma Short_Circuit_And_Or::
929 * Pragma Short_Descriptors::
930 * Pragma Simple_Storage_Pool_Type::
931 * Pragma Source_File_Name::
932 * Pragma Source_File_Name_Project::
933 * Pragma Source_Reference::
934 * Pragma Static_Elaboration_Desired::
935 * Pragma Stream_Convert::
936 * Pragma Style_Checks::
939 * Pragma Suppress_All::
940 * Pragma Suppress_Exception_Locations::
941 * Pragma Suppress_Initialization::
944 * Pragma Task_Storage::
946 * Pragma Thread_Local_Storage::
947 * Pragma Time_Slice::
949 * Pragma Unchecked_Union::
950 * Pragma Unimplemented_Unit::
951 * Pragma Universal_Aliasing ::
952 * Pragma Universal_Data::
953 * Pragma Unmodified::
954 * Pragma Unreferenced::
955 * Pragma Unreferenced_Objects::
956 * Pragma Unreserve_All_Interrupts::
957 * Pragma Unsuppress::
958 * Pragma Use_VADS_Size::
959 * Pragma Validity_Checks::
962 * Pragma Weak_External::
963 * Pragma Wide_Character_Encoding::
966 @node Pragma Abort_Defer
967 @unnumberedsec Pragma Abort_Defer
969 @cindex Deferring aborts
977 This pragma must appear at the start of the statement sequence of a
978 handled sequence of statements (right after the @code{begin}). It has
979 the effect of deferring aborts for the sequence of statements (but not
980 for the declarations or handlers, if any, associated with this statement
984 @unnumberedsec Pragma Ada_83
993 A configuration pragma that establishes Ada 83 mode for the unit to
994 which it applies, regardless of the mode set by the command line
995 switches. In Ada 83 mode, GNAT attempts to be as compatible with
996 the syntax and semantics of Ada 83, as defined in the original Ada
997 83 Reference Manual as possible. In particular, the keywords added by Ada 95
998 and Ada 2005 are not recognized, optional package bodies are allowed,
999 and generics may name types with unknown discriminants without using
1000 the @code{(<>)} notation. In addition, some but not all of the additional
1001 restrictions of Ada 83 are enforced.
1003 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1004 Ada 83 code to be compiled and adapted to GNAT with less effort.
1005 Secondly, it aids in keeping code backwards compatible with Ada 83.
1006 However, there is no guarantee that code that is processed correctly
1007 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1008 83 compiler, since GNAT does not enforce all the additional checks
1012 @unnumberedsec Pragma Ada_95
1016 @smallexample @c ada
1021 A configuration pragma that establishes Ada 95 mode for the unit to which
1022 it applies, regardless of the mode set by the command line switches.
1023 This mode is set automatically for the @code{Ada} and @code{System}
1024 packages and their children, so you need not specify it in these
1025 contexts. This pragma is useful when writing a reusable component that
1026 itself uses Ada 95 features, but which is intended to be usable from
1027 either Ada 83 or Ada 95 programs.
1030 @unnumberedsec Pragma Ada_05
1034 @smallexample @c ada
1039 A configuration pragma that establishes Ada 2005 mode for the unit to which
1040 it applies, regardless of the mode set by the command line switches.
1041 This pragma is useful when writing a reusable component that
1042 itself uses Ada 2005 features, but which is intended to be usable from
1043 either Ada 83 or Ada 95 programs.
1045 @node Pragma Ada_2005
1046 @unnumberedsec Pragma Ada_2005
1050 @smallexample @c ada
1055 This configuration pragma is a synonym for pragma Ada_05 and has the
1056 same syntax and effect.
1059 @unnumberedsec Pragma Ada_12
1063 @smallexample @c ada
1068 A configuration pragma that establishes Ada 2012 mode for the unit to which
1069 it applies, regardless of the mode set by the command line switches.
1070 This mode is set automatically for the @code{Ada} and @code{System}
1071 packages and their children, so you need not specify it in these
1072 contexts. This pragma is useful when writing a reusable component that
1073 itself uses Ada 2012 features, but which is intended to be usable from
1074 Ada 83, Ada 95, or Ada 2005 programs.
1076 @node Pragma Ada_2012
1077 @unnumberedsec Pragma Ada_2012
1081 @smallexample @c ada
1086 This configuration pragma is a synonym for pragma Ada_12 and has the
1087 same syntax and effect.
1089 @node Pragma Annotate
1090 @unnumberedsec Pragma Annotate
1094 @smallexample @c ada
1095 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1097 ARG ::= NAME | EXPRESSION
1101 This pragma is used to annotate programs. @var{identifier} identifies
1102 the type of annotation. GNAT verifies that it is an identifier, but does
1103 not otherwise analyze it. The second optional identifier is also left
1104 unanalyzed, and by convention is used to control the action of the tool to
1105 which the annotation is addressed. The remaining @var{arg} arguments
1106 can be either string literals or more generally expressions.
1107 String literals are assumed to be either of type
1108 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1109 depending on the character literals they contain.
1110 All other kinds of arguments are analyzed as expressions, and must be
1113 The analyzed pragma is retained in the tree, but not otherwise processed
1114 by any part of the GNAT compiler, except to generate corresponding note
1115 lines in the generated ALI file. For the format of these note lines, see
1116 the compiler source file lib-writ.ads. This pragma is intended for use by
1117 external tools, including ASIS@. The use of pragma Annotate does not
1118 affect the compilation process in any way. This pragma may be used as
1119 a configuration pragma.
1122 @unnumberedsec Pragma Assert
1126 @smallexample @c ada
1129 [, string_EXPRESSION]);
1133 The effect of this pragma depends on whether the corresponding command
1134 line switch is set to activate assertions. The pragma expands into code
1135 equivalent to the following:
1137 @smallexample @c ada
1138 if assertions-enabled then
1139 if not boolean_EXPRESSION then
1140 System.Assertions.Raise_Assert_Failure
1141 (string_EXPRESSION);
1147 The string argument, if given, is the message that will be associated
1148 with the exception occurrence if the exception is raised. If no second
1149 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1150 where @var{file} is the name of the source file containing the assert,
1151 and @var{nnn} is the line number of the assert. A pragma is not a
1152 statement, so if a statement sequence contains nothing but a pragma
1153 assert, then a null statement is required in addition, as in:
1155 @smallexample @c ada
1158 pragma Assert (K > 3, "Bad value for K");
1164 Note that, as with the @code{if} statement to which it is equivalent, the
1165 type of the expression is either @code{Standard.Boolean}, or any type derived
1166 from this standard type.
1168 If assertions are disabled (switch @option{-gnata} not used), then there
1169 is no run-time effect (and in particular, any side effects from the
1170 expression will not occur at run time). (The expression is still
1171 analyzed at compile time, and may cause types to be frozen if they are
1172 mentioned here for the first time).
1174 If assertions are enabled, then the given expression is tested, and if
1175 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1176 which results in the raising of @code{Assert_Failure} with the given message.
1178 You should generally avoid side effects in the expression arguments of
1179 this pragma, because these side effects will turn on and off with the
1180 setting of the assertions mode, resulting in assertions that have an
1181 effect on the program. However, the expressions are analyzed for
1182 semantic correctness whether or not assertions are enabled, so turning
1183 assertions on and off cannot affect the legality of a program.
1185 Note that the implementation defined policy @code{DISABLE}, given in a
1186 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1188 Note: this is a standard language-defined pragma in versions
1189 of Ada from 2005 on. In GNAT, it is implemented in all versions
1190 of Ada, and the DISABLE policy is an implementation-defined
1194 @node Pragma Assertion_Policy
1195 @unnumberedsec Pragma Assertion_Policy
1196 @findex Debug_Policy
1200 @smallexample @c ada
1201 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1205 If the argument is @code{CHECK}, then assertions are enabled.
1206 If the argument is @code{IGNORE}, then assertions are ignored.
1207 This pragma overrides the effect of the @option{-gnata} switch on the
1210 Assertions are of three kinds:
1214 Pragma @code{Assert}.
1216 In Ada 2012, all assertions defined in the RM as aspects: preconditions,
1217 postconditions, type invariants and (sub)type predicates.
1219 Corresponding pragmas for type invariants and (sub)type predicates.
1222 The implementation defined policy @code{DISABLE} is like
1223 @code{IGNORE} except that it completely disables semantic
1224 checking of the argument to @code{pragma Assert}. This may
1225 be useful when the pragma argument references subprograms
1226 in a with'ed package which is replaced by a dummy package
1227 for the final build.
1229 Note: this is a standard language-defined pragma in versions
1230 of Ada from 2005 on. In GNAT, it is implemented in all versions
1231 of Ada, and the DISABLE policy is an implementation-defined
1234 @node Pragma Assume_No_Invalid_Values
1235 @unnumberedsec Pragma Assume_No_Invalid_Values
1236 @findex Assume_No_Invalid_Values
1237 @cindex Invalid representations
1238 @cindex Invalid values
1241 @smallexample @c ada
1242 pragma Assume_No_Invalid_Values (On | Off);
1246 This is a configuration pragma that controls the assumptions made by the
1247 compiler about the occurrence of invalid representations (invalid values)
1250 The default behavior (corresponding to an Off argument for this pragma), is
1251 to assume that values may in general be invalid unless the compiler can
1252 prove they are valid. Consider the following example:
1254 @smallexample @c ada
1255 V1 : Integer range 1 .. 10;
1256 V2 : Integer range 11 .. 20;
1258 for J in V2 .. V1 loop
1264 if V1 and V2 have valid values, then the loop is known at compile
1265 time not to execute since the lower bound must be greater than the
1266 upper bound. However in default mode, no such assumption is made,
1267 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1268 is given, the compiler will assume that any occurrence of a variable
1269 other than in an explicit @code{'Valid} test always has a valid
1270 value, and the loop above will be optimized away.
1272 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1273 you know your code is free of uninitialized variables and other
1274 possible sources of invalid representations, and may result in
1275 more efficient code. A program that accesses an invalid representation
1276 with this pragma in effect is erroneous, so no guarantees can be made
1279 It is peculiar though permissible to use this pragma in conjunction
1280 with validity checking (-gnatVa). In such cases, accessing invalid
1281 values will generally give an exception, though formally the program
1282 is erroneous so there are no guarantees that this will always be the
1283 case, and it is recommended that these two options not be used together.
1285 @node Pragma Ast_Entry
1286 @unnumberedsec Pragma Ast_Entry
1291 @smallexample @c ada
1292 pragma AST_Entry (entry_IDENTIFIER);
1296 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1297 argument is the simple name of a single entry; at most one @code{AST_Entry}
1298 pragma is allowed for any given entry. This pragma must be used in
1299 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1300 the entry declaration and in the same task type specification or single task
1301 as the entry to which it applies. This pragma specifies that the given entry
1302 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1303 resulting from an OpenVMS system service call. The pragma does not affect
1304 normal use of the entry. For further details on this pragma, see the
1305 DEC Ada Language Reference Manual, section 9.12a.
1307 @node Pragma C_Pass_By_Copy
1308 @unnumberedsec Pragma C_Pass_By_Copy
1309 @cindex Passing by copy
1310 @findex C_Pass_By_Copy
1313 @smallexample @c ada
1314 pragma C_Pass_By_Copy
1315 ([Max_Size =>] static_integer_EXPRESSION);
1319 Normally the default mechanism for passing C convention records to C
1320 convention subprograms is to pass them by reference, as suggested by RM
1321 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1322 this default, by requiring that record formal parameters be passed by
1323 copy if all of the following conditions are met:
1327 The size of the record type does not exceed the value specified for
1330 The record type has @code{Convention C}.
1332 The formal parameter has this record type, and the subprogram has a
1333 foreign (non-Ada) convention.
1337 If these conditions are met the argument is passed by copy, i.e.@: in a
1338 manner consistent with what C expects if the corresponding formal in the
1339 C prototype is a struct (rather than a pointer to a struct).
1341 You can also pass records by copy by specifying the convention
1342 @code{C_Pass_By_Copy} for the record type, or by using the extended
1343 @code{Import} and @code{Export} pragmas, which allow specification of
1344 passing mechanisms on a parameter by parameter basis.
1347 @unnumberedsec Pragma Check
1349 @cindex Named assertions
1353 @smallexample @c ada
1355 [Name =>] Identifier,
1356 [Check =>] Boolean_EXPRESSION
1357 [, [Message =>] string_EXPRESSION] );
1361 This pragma is similar to the predefined pragma @code{Assert} except that an
1362 extra identifier argument is present. In conjunction with pragma
1363 @code{Check_Policy}, this can be used to define groups of assertions that can
1364 be independently controlled. The identifier @code{Assertion} is special, it
1365 refers to the normal set of pragma @code{Assert} statements. The identifiers
1366 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1367 names, so these three names would normally not be used directly in a pragma
1370 Checks introduced by this pragma are normally deactivated by default. They can
1371 be activated either by the command line option @option{-gnata}, which turns on
1372 all checks, or individually controlled using pragma @code{Check_Policy}.
1374 @node Pragma Check_Name
1375 @unnumberedsec Pragma Check_Name
1376 @cindex Defining check names
1377 @cindex Check names, defining
1381 @smallexample @c ada
1382 pragma Check_Name (check_name_IDENTIFIER);
1386 This is a configuration pragma that defines a new implementation
1387 defined check name (unless IDENTIFIER matches one of the predefined
1388 check names, in which case the pragma has no effect). Check names
1389 are global to a partition, so if two or more configuration pragmas
1390 are present in a partition mentioning the same name, only one new
1391 check name is introduced.
1393 An implementation defined check name introduced with this pragma may
1394 be used in only three contexts: @code{pragma Suppress},
1395 @code{pragma Unsuppress},
1396 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1397 any of these three cases, the check name must be visible. A check
1398 name is visible if it is in the configuration pragmas applying to
1399 the current unit, or if it appears at the start of any unit that
1400 is part of the dependency set of the current unit (e.g., units that
1401 are mentioned in @code{with} clauses).
1403 @node Pragma Check_Policy
1404 @unnumberedsec Pragma Check_Policy
1405 @cindex Controlling assertions
1406 @cindex Assertions, control
1407 @cindex Check pragma control
1408 @cindex Named assertions
1412 @smallexample @c ada
1414 ([Name =>] Identifier,
1415 [Policy =>] POLICY_IDENTIFIER);
1417 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1421 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1422 except that it controls sets of named assertions introduced using the
1423 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1424 @code{Assertion_Policy}) can be used within a declarative part, in which case
1425 it controls the status to the end of the corresponding construct (in a manner
1426 identical to pragma @code{Suppress)}.
1428 The identifier given as the first argument corresponds to a name used in
1429 associated @code{Check} pragmas. For example, if the pragma:
1431 @smallexample @c ada
1432 pragma Check_Policy (Critical_Error, OFF);
1436 is given, then subsequent @code{Check} pragmas whose first argument is also
1437 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1438 controls the behavior of normal assertions (thus a pragma
1439 @code{Check_Policy} with this identifier is similar to the normal
1440 @code{Assertion_Policy} pragma except that it can appear within a
1443 The special identifiers @code{Precondition} and @code{Postcondition} control
1444 the status of preconditions and postconditions given as pragmas.
1445 If a @code{Precondition} pragma
1446 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1447 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1448 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1449 are recognized. Note that preconditions and postconditions given as aspects
1450 are controlled differently, either by the @code{Assertion_Policy} pragma or
1451 by the @code{Check_Policy} pragma with identifier @code{Assertion}.
1453 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1454 to turn on corresponding checks. The default for a set of checks for which no
1455 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1456 @option{-gnata} is given, which turns on all checks by default.
1458 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1459 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1460 compatibility with the standard @code{Assertion_Policy} pragma.
1462 The implementation defined policy @code{DISABLE} is like
1463 @code{OFF} except that it completely disables semantic
1464 checking of the argument to the corresponding class of
1465 pragmas. This may be useful when the pragma arguments reference
1466 subprograms in a with'ed package which is replaced by a dummy package
1467 for the final build.
1469 @node Pragma Comment
1470 @unnumberedsec Pragma Comment
1475 @smallexample @c ada
1476 pragma Comment (static_string_EXPRESSION);
1480 This is almost identical in effect to pragma @code{Ident}. It allows the
1481 placement of a comment into the object file and hence into the
1482 executable file if the operating system permits such usage. The
1483 difference is that @code{Comment}, unlike @code{Ident}, has
1484 no limitations on placement of the pragma (it can be placed
1485 anywhere in the main source unit), and if more than one pragma
1486 is used, all comments are retained.
1488 @node Pragma Common_Object
1489 @unnumberedsec Pragma Common_Object
1490 @findex Common_Object
1494 @smallexample @c ada
1495 pragma Common_Object (
1496 [Internal =>] LOCAL_NAME
1497 [, [External =>] EXTERNAL_SYMBOL]
1498 [, [Size =>] EXTERNAL_SYMBOL] );
1502 | static_string_EXPRESSION
1506 This pragma enables the shared use of variables stored in overlaid
1507 linker areas corresponding to the use of @code{COMMON}
1508 in Fortran. The single
1509 object @var{LOCAL_NAME} is assigned to the area designated by
1510 the @var{External} argument.
1511 You may define a record to correspond to a series
1512 of fields. The @var{Size} argument
1513 is syntax checked in GNAT, but otherwise ignored.
1515 @code{Common_Object} is not supported on all platforms. If no
1516 support is available, then the code generator will issue a message
1517 indicating that the necessary attribute for implementation of this
1518 pragma is not available.
1520 @node Pragma Compile_Time_Error
1521 @unnumberedsec Pragma Compile_Time_Error
1522 @findex Compile_Time_Error
1526 @smallexample @c ada
1527 pragma Compile_Time_Error
1528 (boolean_EXPRESSION, static_string_EXPRESSION);
1532 This pragma can be used to generate additional compile time
1534 is particularly useful in generics, where errors can be issued for
1535 specific problematic instantiations. The first parameter is a boolean
1536 expression. The pragma is effective only if the value of this expression
1537 is known at compile time, and has the value True. The set of expressions
1538 whose values are known at compile time includes all static boolean
1539 expressions, and also other values which the compiler can determine
1540 at compile time (e.g., the size of a record type set by an explicit
1541 size representation clause, or the value of a variable which was
1542 initialized to a constant and is known not to have been modified).
1543 If these conditions are met, an error message is generated using
1544 the value given as the second argument. This string value may contain
1545 embedded ASCII.LF characters to break the message into multiple lines.
1547 @node Pragma Compile_Time_Warning
1548 @unnumberedsec Pragma Compile_Time_Warning
1549 @findex Compile_Time_Warning
1553 @smallexample @c ada
1554 pragma Compile_Time_Warning
1555 (boolean_EXPRESSION, static_string_EXPRESSION);
1559 Same as pragma Compile_Time_Error, except a warning is issued instead
1560 of an error message. Note that if this pragma is used in a package that
1561 is with'ed by a client, the client will get the warning even though it
1562 is issued by a with'ed package (normally warnings in with'ed units are
1563 suppressed, but this is a special exception to that rule).
1565 One typical use is within a generic where compile time known characteristics
1566 of formal parameters are tested, and warnings given appropriately. Another use
1567 with a first parameter of True is to warn a client about use of a package,
1568 for example that it is not fully implemented.
1570 @node Pragma Compiler_Unit
1571 @unnumberedsec Pragma Compiler_Unit
1572 @findex Compiler_Unit
1576 @smallexample @c ada
1577 pragma Compiler_Unit;
1581 This pragma is intended only for internal use in the GNAT run-time library.
1582 It indicates that the unit is used as part of the compiler build. The effect
1583 is to disallow constructs (raise with message, conditional expressions etc)
1584 that would cause trouble when bootstrapping using an older version of GNAT.
1585 For the exact list of restrictions, see the compiler sources and references
1586 to Is_Compiler_Unit.
1588 @node Pragma Complete_Representation
1589 @unnumberedsec Pragma Complete_Representation
1590 @findex Complete_Representation
1594 @smallexample @c ada
1595 pragma Complete_Representation;
1599 This pragma must appear immediately within a record representation
1600 clause. Typical placements are before the first component clause
1601 or after the last component clause. The effect is to give an error
1602 message if any component is missing a component clause. This pragma
1603 may be used to ensure that a record representation clause is
1604 complete, and that this invariant is maintained if fields are
1605 added to the record in the future.
1607 @node Pragma Complex_Representation
1608 @unnumberedsec Pragma Complex_Representation
1609 @findex Complex_Representation
1613 @smallexample @c ada
1614 pragma Complex_Representation
1615 ([Entity =>] LOCAL_NAME);
1619 The @var{Entity} argument must be the name of a record type which has
1620 two fields of the same floating-point type. The effect of this pragma is
1621 to force gcc to use the special internal complex representation form for
1622 this record, which may be more efficient. Note that this may result in
1623 the code for this type not conforming to standard ABI (application
1624 binary interface) requirements for the handling of record types. For
1625 example, in some environments, there is a requirement for passing
1626 records by pointer, and the use of this pragma may result in passing
1627 this type in floating-point registers.
1629 @node Pragma Component_Alignment
1630 @unnumberedsec Pragma Component_Alignment
1631 @cindex Alignments of components
1632 @findex Component_Alignment
1636 @smallexample @c ada
1637 pragma Component_Alignment (
1638 [Form =>] ALIGNMENT_CHOICE
1639 [, [Name =>] type_LOCAL_NAME]);
1641 ALIGNMENT_CHOICE ::=
1649 Specifies the alignment of components in array or record types.
1650 The meaning of the @var{Form} argument is as follows:
1653 @findex Component_Size
1654 @item Component_Size
1655 Aligns scalar components and subcomponents of the array or record type
1656 on boundaries appropriate to their inherent size (naturally
1657 aligned). For example, 1-byte components are aligned on byte boundaries,
1658 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1659 integer components are aligned on 4-byte boundaries and so on. These
1660 alignment rules correspond to the normal rules for C compilers on all
1661 machines except the VAX@.
1663 @findex Component_Size_4
1664 @item Component_Size_4
1665 Naturally aligns components with a size of four or fewer
1666 bytes. Components that are larger than 4 bytes are placed on the next
1669 @findex Storage_Unit
1671 Specifies that array or record components are byte aligned, i.e.@:
1672 aligned on boundaries determined by the value of the constant
1673 @code{System.Storage_Unit}.
1677 Specifies that array or record components are aligned on default
1678 boundaries, appropriate to the underlying hardware or operating system or
1679 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1680 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1681 the @code{Default} choice is the same as @code{Component_Size} (natural
1686 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1687 refer to a local record or array type, and the specified alignment
1688 choice applies to the specified type. The use of
1689 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1690 @code{Component_Alignment} pragma to be ignored. The use of
1691 @code{Component_Alignment} together with a record representation clause
1692 is only effective for fields not specified by the representation clause.
1694 If the @code{Name} parameter is absent, the pragma can be used as either
1695 a configuration pragma, in which case it applies to one or more units in
1696 accordance with the normal rules for configuration pragmas, or it can be
1697 used within a declarative part, in which case it applies to types that
1698 are declared within this declarative part, or within any nested scope
1699 within this declarative part. In either case it specifies the alignment
1700 to be applied to any record or array type which has otherwise standard
1703 If the alignment for a record or array type is not specified (using
1704 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1705 clause), the GNAT uses the default alignment as described previously.
1707 @node Pragma Convention_Identifier
1708 @unnumberedsec Pragma Convention_Identifier
1709 @findex Convention_Identifier
1710 @cindex Conventions, synonyms
1714 @smallexample @c ada
1715 pragma Convention_Identifier (
1716 [Name =>] IDENTIFIER,
1717 [Convention =>] convention_IDENTIFIER);
1721 This pragma provides a mechanism for supplying synonyms for existing
1722 convention identifiers. The @code{Name} identifier can subsequently
1723 be used as a synonym for the given convention in other pragmas (including
1724 for example pragma @code{Import} or another @code{Convention_Identifier}
1725 pragma). As an example of the use of this, suppose you had legacy code
1726 which used Fortran77 as the identifier for Fortran. Then the pragma:
1728 @smallexample @c ada
1729 pragma Convention_Identifier (Fortran77, Fortran);
1733 would allow the use of the convention identifier @code{Fortran77} in
1734 subsequent code, avoiding the need to modify the sources. As another
1735 example, you could use this to parameterize convention requirements
1736 according to systems. Suppose you needed to use @code{Stdcall} on
1737 windows systems, and @code{C} on some other system, then you could
1738 define a convention identifier @code{Library} and use a single
1739 @code{Convention_Identifier} pragma to specify which convention
1740 would be used system-wide.
1742 @node Pragma CPP_Class
1743 @unnumberedsec Pragma CPP_Class
1745 @cindex Interfacing with C++
1749 @smallexample @c ada
1750 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1754 The argument denotes an entity in the current declarative region that is
1755 declared as a record type. It indicates that the type corresponds to an
1756 externally declared C++ class type, and is to be laid out the same way
1757 that C++ would lay out the type. If the C++ class has virtual primitives
1758 then the record must be declared as a tagged record type.
1760 Types for which @code{CPP_Class} is specified do not have assignment or
1761 equality operators defined (such operations can be imported or declared
1762 as subprograms as required). Initialization is allowed only by constructor
1763 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1764 limited if not explicitly declared as limited or derived from a limited
1765 type, and an error is issued in that case.
1767 Pragma @code{CPP_Class} is intended primarily for automatic generation
1768 using an automatic binding generator tool.
1769 See @ref{Interfacing to C++} for related information.
1771 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1772 for backward compatibility but its functionality is available
1773 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1775 @node Pragma CPP_Constructor
1776 @unnumberedsec Pragma CPP_Constructor
1777 @cindex Interfacing with C++
1778 @findex CPP_Constructor
1782 @smallexample @c ada
1783 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1784 [, [External_Name =>] static_string_EXPRESSION ]
1785 [, [Link_Name =>] static_string_EXPRESSION ]);
1789 This pragma identifies an imported function (imported in the usual way
1790 with pragma @code{Import}) as corresponding to a C++ constructor. If
1791 @code{External_Name} and @code{Link_Name} are not specified then the
1792 @code{Entity} argument is a name that must have been previously mentioned
1793 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1794 must be of one of the following forms:
1798 @code{function @var{Fname} return @var{T}}
1802 @code{function @var{Fname} return @var{T}'Class}
1805 @code{function @var{Fname} (@dots{}) return @var{T}}
1809 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1813 where @var{T} is a limited record type imported from C++ with pragma
1814 @code{Import} and @code{Convention} = @code{CPP}.
1816 The first two forms import the default constructor, used when an object
1817 of type @var{T} is created on the Ada side with no explicit constructor.
1818 The latter two forms cover all the non-default constructors of the type.
1819 See the GNAT users guide for details.
1821 If no constructors are imported, it is impossible to create any objects
1822 on the Ada side and the type is implicitly declared abstract.
1824 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1825 using an automatic binding generator tool.
1826 See @ref{Interfacing to C++} for more related information.
1828 Note: The use of functions returning class-wide types for constructors is
1829 currently obsolete. They are supported for backward compatibility. The
1830 use of functions returning the type T leave the Ada sources more clear
1831 because the imported C++ constructors always return an object of type T;
1832 that is, they never return an object whose type is a descendant of type T.
1834 @node Pragma CPP_Virtual
1835 @unnumberedsec Pragma CPP_Virtual
1836 @cindex Interfacing to C++
1839 This pragma is now obsolete has has no effect because GNAT generates
1840 the same object layout than the G++ compiler.
1842 See @ref{Interfacing to C++} for related information.
1844 @node Pragma CPP_Vtable
1845 @unnumberedsec Pragma CPP_Vtable
1846 @cindex Interfacing with C++
1849 This pragma is now obsolete has has no effect because GNAT generates
1850 the same object layout than the G++ compiler.
1852 See @ref{Interfacing to C++} for related information.
1855 @unnumberedsec Pragma Debug
1860 @smallexample @c ada
1861 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1863 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1865 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1869 The procedure call argument has the syntactic form of an expression, meeting
1870 the syntactic requirements for pragmas.
1872 If debug pragmas are not enabled or if the condition is present and evaluates
1873 to False, this pragma has no effect. If debug pragmas are enabled, the
1874 semantics of the pragma is exactly equivalent to the procedure call statement
1875 corresponding to the argument with a terminating semicolon. Pragmas are
1876 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1877 intersperse calls to debug procedures in the middle of declarations. Debug
1878 pragmas can be enabled either by use of the command line switch @option{-gnata}
1879 or by use of the configuration pragma @code{Debug_Policy}.
1881 @node Pragma Debug_Policy
1882 @unnumberedsec Pragma Debug_Policy
1883 @findex Debug_Policy
1887 @smallexample @c ada
1888 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
1892 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1893 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1894 This pragma overrides the effect of the @option{-gnata} switch on the
1897 The implementation defined policy @code{DISABLE} is like
1898 @code{IGNORE} except that it completely disables semantic
1899 checking of the argument to @code{pragma Debug}. This may
1900 be useful when the pragma argument references subprograms
1901 in a with'ed package which is replaced by a dummy package
1902 for the final build.
1904 @node Pragma Detect_Blocking
1905 @unnumberedsec Pragma Detect_Blocking
1906 @findex Detect_Blocking
1910 @smallexample @c ada
1911 pragma Detect_Blocking;
1915 This is a configuration pragma that forces the detection of potentially
1916 blocking operations within a protected operation, and to raise Program_Error
1919 @node Pragma Elaboration_Checks
1920 @unnumberedsec Pragma Elaboration_Checks
1921 @cindex Elaboration control
1922 @findex Elaboration_Checks
1926 @smallexample @c ada
1927 pragma Elaboration_Checks (Dynamic | Static);
1931 This is a configuration pragma that provides control over the
1932 elaboration model used by the compilation affected by the
1933 pragma. If the parameter is @code{Dynamic},
1934 then the dynamic elaboration
1935 model described in the Ada Reference Manual is used, as though
1936 the @option{-gnatE} switch had been specified on the command
1937 line. If the parameter is @code{Static}, then the default GNAT static
1938 model is used. This configuration pragma overrides the setting
1939 of the command line. For full details on the elaboration models
1940 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1941 gnat_ugn, @value{EDITION} User's Guide}.
1943 @node Pragma Eliminate
1944 @unnumberedsec Pragma Eliminate
1945 @cindex Elimination of unused subprograms
1950 @smallexample @c ada
1951 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
1952 [Source_Location =>] STRING_LITERAL);
1956 The string literal given for the source location is a string which
1957 specifies the line number of the occurrence of the entity, using
1958 the syntax for SOURCE_TRACE given below:
1960 @smallexample @c ada
1961 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
1966 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
1968 LINE_NUMBER ::= DIGIT @{DIGIT@}
1972 Spaces around the colon in a @code{Source_Reference} are optional.
1974 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
1975 explicit subprogram declaration, where the @code{entity} name in this
1976 designator appears on the source line specified by the source location.
1978 The source trace that is given as the @code{Source_Location} shall obey the
1979 following rules. The @code{FILE_NAME} is the short name (with no directory
1980 information) of an Ada source file, given using exactly the required syntax
1981 for the underlying file system (e.g. case is important if the underlying
1982 operating system is case sensitive). @code{LINE_NUMBER} gives the line
1983 number of the occurrence of the @code{entity}
1984 as a decimal literal without an exponent or point. If an @code{entity} is not
1985 declared in a generic instantiation (this includes generic subprogram
1986 instances), the source trace includes only one source reference. If an entity
1987 is declared inside a generic instantiation, its source trace (when parsing
1988 from left to right) starts with the source location of the declaration of the
1989 entity in the generic unit and ends with the source location of the
1990 instantiation (it is given in square brackets). This approach is recursively
1991 used in case of nested instantiations: the rightmost (nested most deeply in
1992 square brackets) element of the source trace is the location of the outermost
1993 instantiation, the next to left element is the location of the next (first
1994 nested) instantiation in the code of the corresponding generic unit, and so
1995 on, and the leftmost element (that is out of any square brackets) is the
1996 location of the declaration of the entity to eliminate in a generic unit.
1998 Note that the @code{Source_Location} argument specifies which of a set of
1999 similarly named entities is being eliminated, dealing both with overloading,
2000 and also appearence of the same entity name in different scopes.
2002 This pragma indicates that the given entity is not used in the program to be
2003 compiled and built. The effect of the pragma is to allow the compiler to
2004 eliminate the code or data associated with the named entity. Any reference to
2005 an eliminated entity causes a compile-time or link-time error.
2007 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2008 in a system-independent manner, with unused entities eliminated, without
2009 needing to modify the source text. Normally the required set of
2010 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2012 Any source file change that removes, splits, or
2013 adds lines may make the set of Eliminate pragmas invalid because their
2014 @code{Source_Location} argument values may get out of date.
2016 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2017 operation. In this case all the subprograms to which the given operation can
2018 dispatch are considered to be unused (are never called as a result of a direct
2019 or a dispatching call).
2021 @node Pragma Export_Exception
2022 @unnumberedsec Pragma Export_Exception
2024 @findex Export_Exception
2028 @smallexample @c ada
2029 pragma Export_Exception (
2030 [Internal =>] LOCAL_NAME
2031 [, [External =>] EXTERNAL_SYMBOL]
2032 [, [Form =>] Ada | VMS]
2033 [, [Code =>] static_integer_EXPRESSION]);
2037 | static_string_EXPRESSION
2041 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2042 causes the specified exception to be propagated outside of the Ada program,
2043 so that it can be handled by programs written in other OpenVMS languages.
2044 This pragma establishes an external name for an Ada exception and makes the
2045 name available to the OpenVMS Linker as a global symbol. For further details
2046 on this pragma, see the
2047 DEC Ada Language Reference Manual, section 13.9a3.2.
2049 @node Pragma Export_Function
2050 @unnumberedsec Pragma Export_Function
2051 @cindex Argument passing mechanisms
2052 @findex Export_Function
2057 @smallexample @c ada
2058 pragma Export_Function (
2059 [Internal =>] LOCAL_NAME
2060 [, [External =>] EXTERNAL_SYMBOL]
2061 [, [Parameter_Types =>] PARAMETER_TYPES]
2062 [, [Result_Type =>] result_SUBTYPE_MARK]
2063 [, [Mechanism =>] MECHANISM]
2064 [, [Result_Mechanism =>] MECHANISM_NAME]);
2068 | static_string_EXPRESSION
2073 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2077 | subtype_Name ' Access
2081 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2083 MECHANISM_ASSOCIATION ::=
2084 [formal_parameter_NAME =>] MECHANISM_NAME
2089 | Descriptor [([Class =>] CLASS_NAME)]
2090 | Short_Descriptor [([Class =>] CLASS_NAME)]
2092 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2096 Use this pragma to make a function externally callable and optionally
2097 provide information on mechanisms to be used for passing parameter and
2098 result values. We recommend, for the purposes of improving portability,
2099 this pragma always be used in conjunction with a separate pragma
2100 @code{Export}, which must precede the pragma @code{Export_Function}.
2101 GNAT does not require a separate pragma @code{Export}, but if none is
2102 present, @code{Convention Ada} is assumed, which is usually
2103 not what is wanted, so it is usually appropriate to use this
2104 pragma in conjunction with a @code{Export} or @code{Convention}
2105 pragma that specifies the desired foreign convention.
2106 Pragma @code{Export_Function}
2107 (and @code{Export}, if present) must appear in the same declarative
2108 region as the function to which they apply.
2110 @var{internal_name} must uniquely designate the function to which the
2111 pragma applies. If more than one function name exists of this name in
2112 the declarative part you must use the @code{Parameter_Types} and
2113 @code{Result_Type} parameters is mandatory to achieve the required
2114 unique designation. @var{subtype_mark}s in these parameters must
2115 exactly match the subtypes in the corresponding function specification,
2116 using positional notation to match parameters with subtype marks.
2117 The form with an @code{'Access} attribute can be used to match an
2118 anonymous access parameter.
2121 @cindex Passing by descriptor
2122 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2123 The default behavior for Export_Function is to accept either 64bit or
2124 32bit descriptors unless short_descriptor is specified, then only 32bit
2125 descriptors are accepted.
2127 @cindex Suppressing external name
2128 Special treatment is given if the EXTERNAL is an explicit null
2129 string or a static string expressions that evaluates to the null
2130 string. In this case, no external name is generated. This form
2131 still allows the specification of parameter mechanisms.
2133 @node Pragma Export_Object
2134 @unnumberedsec Pragma Export_Object
2135 @findex Export_Object
2139 @smallexample @c ada
2140 pragma Export_Object
2141 [Internal =>] LOCAL_NAME
2142 [, [External =>] EXTERNAL_SYMBOL]
2143 [, [Size =>] EXTERNAL_SYMBOL]
2147 | static_string_EXPRESSION
2151 This pragma designates an object as exported, and apart from the
2152 extended rules for external symbols, is identical in effect to the use of
2153 the normal @code{Export} pragma applied to an object. You may use a
2154 separate Export pragma (and you probably should from the point of view
2155 of portability), but it is not required. @var{Size} is syntax checked,
2156 but otherwise ignored by GNAT@.
2158 @node Pragma Export_Procedure
2159 @unnumberedsec Pragma Export_Procedure
2160 @findex Export_Procedure
2164 @smallexample @c ada
2165 pragma Export_Procedure (
2166 [Internal =>] LOCAL_NAME
2167 [, [External =>] EXTERNAL_SYMBOL]
2168 [, [Parameter_Types =>] PARAMETER_TYPES]
2169 [, [Mechanism =>] MECHANISM]);
2173 | static_string_EXPRESSION
2178 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2182 | subtype_Name ' Access
2186 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2188 MECHANISM_ASSOCIATION ::=
2189 [formal_parameter_NAME =>] MECHANISM_NAME
2194 | Descriptor [([Class =>] CLASS_NAME)]
2195 | Short_Descriptor [([Class =>] CLASS_NAME)]
2197 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2201 This pragma is identical to @code{Export_Function} except that it
2202 applies to a procedure rather than a function and the parameters
2203 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2204 GNAT does not require a separate pragma @code{Export}, but if none is
2205 present, @code{Convention Ada} is assumed, which is usually
2206 not what is wanted, so it is usually appropriate to use this
2207 pragma in conjunction with a @code{Export} or @code{Convention}
2208 pragma that specifies the desired foreign convention.
2211 @cindex Passing by descriptor
2212 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2213 The default behavior for Export_Procedure is to accept either 64bit or
2214 32bit descriptors unless short_descriptor is specified, then only 32bit
2215 descriptors are accepted.
2217 @cindex Suppressing external name
2218 Special treatment is given if the EXTERNAL is an explicit null
2219 string or a static string expressions that evaluates to the null
2220 string. In this case, no external name is generated. This form
2221 still allows the specification of parameter mechanisms.
2223 @node Pragma Export_Value
2224 @unnumberedsec Pragma Export_Value
2225 @findex Export_Value
2229 @smallexample @c ada
2230 pragma Export_Value (
2231 [Value =>] static_integer_EXPRESSION,
2232 [Link_Name =>] static_string_EXPRESSION);
2236 This pragma serves to export a static integer value for external use.
2237 The first argument specifies the value to be exported. The Link_Name
2238 argument specifies the symbolic name to be associated with the integer
2239 value. This pragma is useful for defining a named static value in Ada
2240 that can be referenced in assembly language units to be linked with
2241 the application. This pragma is currently supported only for the
2242 AAMP target and is ignored for other targets.
2244 @node Pragma Export_Valued_Procedure
2245 @unnumberedsec Pragma Export_Valued_Procedure
2246 @findex Export_Valued_Procedure
2250 @smallexample @c ada
2251 pragma Export_Valued_Procedure (
2252 [Internal =>] LOCAL_NAME
2253 [, [External =>] EXTERNAL_SYMBOL]
2254 [, [Parameter_Types =>] PARAMETER_TYPES]
2255 [, [Mechanism =>] MECHANISM]);
2259 | static_string_EXPRESSION
2264 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2268 | subtype_Name ' Access
2272 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2274 MECHANISM_ASSOCIATION ::=
2275 [formal_parameter_NAME =>] MECHANISM_NAME
2280 | Descriptor [([Class =>] CLASS_NAME)]
2281 | Short_Descriptor [([Class =>] CLASS_NAME)]
2283 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2287 This pragma is identical to @code{Export_Procedure} except that the
2288 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2289 mode @code{OUT}, and externally the subprogram is treated as a function
2290 with this parameter as the result of the function. GNAT provides for
2291 this capability to allow the use of @code{OUT} and @code{IN OUT}
2292 parameters in interfacing to external functions (which are not permitted
2294 GNAT does not require a separate pragma @code{Export}, but if none is
2295 present, @code{Convention Ada} is assumed, which is almost certainly
2296 not what is wanted since the whole point of this pragma is to interface
2297 with foreign language functions, so it is usually appropriate to use this
2298 pragma in conjunction with a @code{Export} or @code{Convention}
2299 pragma that specifies the desired foreign convention.
2302 @cindex Passing by descriptor
2303 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2304 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2305 32bit descriptors unless short_descriptor is specified, then only 32bit
2306 descriptors are accepted.
2308 @cindex Suppressing external name
2309 Special treatment is given if the EXTERNAL is an explicit null
2310 string or a static string expressions that evaluates to the null
2311 string. In this case, no external name is generated. This form
2312 still allows the specification of parameter mechanisms.
2314 @node Pragma Extend_System
2315 @unnumberedsec Pragma Extend_System
2316 @cindex @code{system}, extending
2318 @findex Extend_System
2322 @smallexample @c ada
2323 pragma Extend_System ([Name =>] IDENTIFIER);
2327 This pragma is used to provide backwards compatibility with other
2328 implementations that extend the facilities of package @code{System}. In
2329 GNAT, @code{System} contains only the definitions that are present in
2330 the Ada RM@. However, other implementations, notably the DEC Ada 83
2331 implementation, provide many extensions to package @code{System}.
2333 For each such implementation accommodated by this pragma, GNAT provides a
2334 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2335 implementation, which provides the required additional definitions. You
2336 can use this package in two ways. You can @code{with} it in the normal
2337 way and access entities either by selection or using a @code{use}
2338 clause. In this case no special processing is required.
2340 However, if existing code contains references such as
2341 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2342 definitions provided in package @code{System}, you may use this pragma
2343 to extend visibility in @code{System} in a non-standard way that
2344 provides greater compatibility with the existing code. Pragma
2345 @code{Extend_System} is a configuration pragma whose single argument is
2346 the name of the package containing the extended definition
2347 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2348 control of this pragma will be processed using special visibility
2349 processing that looks in package @code{System.Aux_@var{xxx}} where
2350 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2351 package @code{System}, but not found in package @code{System}.
2353 You can use this pragma either to access a predefined @code{System}
2354 extension supplied with the compiler, for example @code{Aux_DEC} or
2355 you can construct your own extension unit following the above
2356 definition. Note that such a package is a child of @code{System}
2357 and thus is considered part of the implementation. To compile
2358 it you will have to use the appropriate switch for compiling
2360 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2363 @node Pragma Extensions_Allowed
2364 @unnumberedsec Pragma Extensions_Allowed
2365 @cindex Ada Extensions
2366 @cindex GNAT Extensions
2367 @findex Extensions_Allowed
2371 @smallexample @c ada
2372 pragma Extensions_Allowed (On | Off);
2376 This configuration pragma enables or disables the implementation
2377 extension mode (the use of Off as a parameter cancels the effect
2378 of the @option{-gnatX} command switch).
2380 In extension mode, the latest version of the Ada language is
2381 implemented (currently Ada 2012), and in addition a small number
2382 of GNAT specific extensions are recognized as follows:
2385 @item Constrained attribute for generic objects
2386 The @code{Constrained} attribute is permitted for objects of
2387 generic types. The result indicates if the corresponding actual
2392 @node Pragma External
2393 @unnumberedsec Pragma External
2398 @smallexample @c ada
2400 [ Convention =>] convention_IDENTIFIER,
2401 [ Entity =>] LOCAL_NAME
2402 [, [External_Name =>] static_string_EXPRESSION ]
2403 [, [Link_Name =>] static_string_EXPRESSION ]);
2407 This pragma is identical in syntax and semantics to pragma
2408 @code{Export} as defined in the Ada Reference Manual. It is
2409 provided for compatibility with some Ada 83 compilers that
2410 used this pragma for exactly the same purposes as pragma
2411 @code{Export} before the latter was standardized.
2413 @node Pragma External_Name_Casing
2414 @unnumberedsec Pragma External_Name_Casing
2415 @cindex Dec Ada 83 casing compatibility
2416 @cindex External Names, casing
2417 @cindex Casing of External names
2418 @findex External_Name_Casing
2422 @smallexample @c ada
2423 pragma External_Name_Casing (
2424 Uppercase | Lowercase
2425 [, Uppercase | Lowercase | As_Is]);
2429 This pragma provides control over the casing of external names associated
2430 with Import and Export pragmas. There are two cases to consider:
2433 @item Implicit external names
2434 Implicit external names are derived from identifiers. The most common case
2435 arises when a standard Ada Import or Export pragma is used with only two
2438 @smallexample @c ada
2439 pragma Import (C, C_Routine);
2443 Since Ada is a case-insensitive language, the spelling of the identifier in
2444 the Ada source program does not provide any information on the desired
2445 casing of the external name, and so a convention is needed. In GNAT the
2446 default treatment is that such names are converted to all lower case
2447 letters. This corresponds to the normal C style in many environments.
2448 The first argument of pragma @code{External_Name_Casing} can be used to
2449 control this treatment. If @code{Uppercase} is specified, then the name
2450 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2451 then the normal default of all lower case letters will be used.
2453 This same implicit treatment is also used in the case of extended DEC Ada 83
2454 compatible Import and Export pragmas where an external name is explicitly
2455 specified using an identifier rather than a string.
2457 @item Explicit external names
2458 Explicit external names are given as string literals. The most common case
2459 arises when a standard Ada Import or Export pragma is used with three
2462 @smallexample @c ada
2463 pragma Import (C, C_Routine, "C_routine");
2467 In this case, the string literal normally provides the exact casing required
2468 for the external name. The second argument of pragma
2469 @code{External_Name_Casing} may be used to modify this behavior.
2470 If @code{Uppercase} is specified, then the name
2471 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2472 then the name will be forced to all lowercase letters. A specification of
2473 @code{As_Is} provides the normal default behavior in which the casing is
2474 taken from the string provided.
2478 This pragma may appear anywhere that a pragma is valid. In particular, it
2479 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2480 case it applies to all subsequent compilations, or it can be used as a program
2481 unit pragma, in which case it only applies to the current unit, or it can
2482 be used more locally to control individual Import/Export pragmas.
2484 It is primarily intended for use with OpenVMS systems, where many
2485 compilers convert all symbols to upper case by default. For interfacing to
2486 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2489 @smallexample @c ada
2490 pragma External_Name_Casing (Uppercase, Uppercase);
2494 to enforce the upper casing of all external symbols.
2496 @node Pragma Fast_Math
2497 @unnumberedsec Pragma Fast_Math
2502 @smallexample @c ada
2507 This is a configuration pragma which activates a mode in which speed is
2508 considered more important for floating-point operations than absolutely
2509 accurate adherence to the requirements of the standard. Currently the
2510 following operations are affected:
2513 @item Complex Multiplication
2514 The normal simple formula for complex multiplication can result in intermediate
2515 overflows for numbers near the end of the range. The Ada standard requires that
2516 this situation be detected and corrected by scaling, but in Fast_Math mode such
2517 cases will simply result in overflow. Note that to take advantage of this you
2518 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2519 under control of the pragma, rather than use the preinstantiated versions.
2522 @node Pragma Favor_Top_Level
2523 @unnumberedsec Pragma Favor_Top_Level
2524 @findex Favor_Top_Level
2528 @smallexample @c ada
2529 pragma Favor_Top_Level (type_NAME);
2533 The named type must be an access-to-subprogram type. This pragma is an
2534 efficiency hint to the compiler, regarding the use of 'Access or
2535 'Unrestricted_Access on nested (non-library-level) subprograms. The
2536 pragma means that nested subprograms are not used with this type, or
2537 are rare, so that the generated code should be efficient in the
2538 top-level case. When this pragma is used, dynamically generated
2539 trampolines may be used on some targets for nested subprograms.
2540 See also the No_Implicit_Dynamic_Code restriction.
2542 @node Pragma Finalize_Storage_Only
2543 @unnumberedsec Pragma Finalize_Storage_Only
2544 @findex Finalize_Storage_Only
2548 @smallexample @c ada
2549 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2553 This pragma allows the compiler not to emit a Finalize call for objects
2554 defined at the library level. This is mostly useful for types where
2555 finalization is only used to deal with storage reclamation since in most
2556 environments it is not necessary to reclaim memory just before terminating
2557 execution, hence the name.
2559 @node Pragma Float_Representation
2560 @unnumberedsec Pragma Float_Representation
2562 @findex Float_Representation
2566 @smallexample @c ada
2567 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2569 FLOAT_REP ::= VAX_Float | IEEE_Float
2573 In the one argument form, this pragma is a configuration pragma which
2574 allows control over the internal representation chosen for the predefined
2575 floating point types declared in the packages @code{Standard} and
2576 @code{System}. On all systems other than OpenVMS, the argument must
2577 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2578 argument may be @code{VAX_Float} to specify the use of the VAX float
2579 format for the floating-point types in Standard. This requires that
2580 the standard runtime libraries be recompiled.
2582 The two argument form specifies the representation to be used for
2583 the specified floating-point type. On all systems other than OpenVMS,
2585 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2586 argument may be @code{VAX_Float} to specify the use of the VAX float
2591 For digits values up to 6, F float format will be used.
2593 For digits values from 7 to 9, D float format will be used.
2595 For digits values from 10 to 15, G float format will be used.
2597 Digits values above 15 are not allowed.
2601 @unnumberedsec Pragma Ident
2606 @smallexample @c ada
2607 pragma Ident (static_string_EXPRESSION);
2611 This pragma provides a string identification in the generated object file,
2612 if the system supports the concept of this kind of identification string.
2613 This pragma is allowed only in the outermost declarative part or
2614 declarative items of a compilation unit. If more than one @code{Ident}
2615 pragma is given, only the last one processed is effective.
2617 On OpenVMS systems, the effect of the pragma is identical to the effect of
2618 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2619 maximum allowed length is 31 characters, so if it is important to
2620 maintain compatibility with this compiler, you should obey this length
2623 @node Pragma Implemented
2624 @unnumberedsec Pragma Implemented
2629 @smallexample @c ada
2630 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2632 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2636 This is an Ada 2012 representation pragma which applies to protected, task
2637 and synchronized interface primitives. The use of pragma Implemented provides
2638 a way to impose a static requirement on the overriding operation by adhering
2639 to one of the three implementation kids: entry, protected procedure or any of
2642 @smallexample @c ada
2643 type Synch_Iface is synchronized interface;
2644 procedure Prim_Op (Obj : in out Iface) is abstract;
2645 pragma Implemented (Prim_Op, By_Protected_Procedure);
2647 protected type Prot_1 is new Synch_Iface with
2648 procedure Prim_Op; -- Legal
2651 protected type Prot_2 is new Synch_Iface with
2652 entry Prim_Op; -- Illegal
2655 task type Task_Typ is new Synch_Iface with
2656 entry Prim_Op; -- Illegal
2661 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2662 Implemented determines the runtime behavior of the requeue. Implementation kind
2663 By_Entry guarantees that the action of requeueing will proceed from an entry to
2664 another entry. Implementation kind By_Protected_Procedure transforms the
2665 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2666 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2667 the target's overriding subprogram kind.
2669 @node Pragma Implicit_Packing
2670 @unnumberedsec Pragma Implicit_Packing
2671 @findex Implicit_Packing
2675 @smallexample @c ada
2676 pragma Implicit_Packing;
2680 This is a configuration pragma that requests implicit packing for packed
2681 arrays for which a size clause is given but no explicit pragma Pack or
2682 specification of Component_Size is present. It also applies to records
2683 where no record representation clause is present. Consider this example:
2685 @smallexample @c ada
2686 type R is array (0 .. 7) of Boolean;
2691 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2692 does not change the layout of a composite object. So the Size clause in the
2693 above example is normally rejected, since the default layout of the array uses
2694 8-bit components, and thus the array requires a minimum of 64 bits.
2696 If this declaration is compiled in a region of code covered by an occurrence
2697 of the configuration pragma Implicit_Packing, then the Size clause in this
2698 and similar examples will cause implicit packing and thus be accepted. For
2699 this implicit packing to occur, the type in question must be an array of small
2700 components whose size is known at compile time, and the Size clause must
2701 specify the exact size that corresponds to the length of the array multiplied
2702 by the size in bits of the component type.
2703 @cindex Array packing
2705 Similarly, the following example shows the use in the record case
2707 @smallexample @c ada
2709 a, b, c, d, e, f, g, h : boolean;
2716 Without a pragma Pack, each Boolean field requires 8 bits, so the
2717 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2718 sufficient. The use of pragma Implicit_Packing allows this record
2719 declaration to compile without an explicit pragma Pack.
2720 @node Pragma Import_Exception
2721 @unnumberedsec Pragma Import_Exception
2723 @findex Import_Exception
2727 @smallexample @c ada
2728 pragma Import_Exception (
2729 [Internal =>] LOCAL_NAME
2730 [, [External =>] EXTERNAL_SYMBOL]
2731 [, [Form =>] Ada | VMS]
2732 [, [Code =>] static_integer_EXPRESSION]);
2736 | static_string_EXPRESSION
2740 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2741 It allows OpenVMS conditions (for example, from OpenVMS system services or
2742 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2743 The pragma specifies that the exception associated with an exception
2744 declaration in an Ada program be defined externally (in non-Ada code).
2745 For further details on this pragma, see the
2746 DEC Ada Language Reference Manual, section 13.9a.3.1.
2748 @node Pragma Import_Function
2749 @unnumberedsec Pragma Import_Function
2750 @findex Import_Function
2754 @smallexample @c ada
2755 pragma Import_Function (
2756 [Internal =>] LOCAL_NAME,
2757 [, [External =>] EXTERNAL_SYMBOL]
2758 [, [Parameter_Types =>] PARAMETER_TYPES]
2759 [, [Result_Type =>] SUBTYPE_MARK]
2760 [, [Mechanism =>] MECHANISM]
2761 [, [Result_Mechanism =>] MECHANISM_NAME]
2762 [, [First_Optional_Parameter =>] IDENTIFIER]);
2766 | static_string_EXPRESSION
2770 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2774 | subtype_Name ' Access
2778 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2780 MECHANISM_ASSOCIATION ::=
2781 [formal_parameter_NAME =>] MECHANISM_NAME
2786 | Descriptor [([Class =>] CLASS_NAME)]
2787 | Short_Descriptor [([Class =>] CLASS_NAME)]
2789 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2793 This pragma is used in conjunction with a pragma @code{Import} to
2794 specify additional information for an imported function. The pragma
2795 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2796 @code{Import_Function} pragma and both must appear in the same
2797 declarative part as the function specification.
2799 The @var{Internal} argument must uniquely designate
2800 the function to which the
2801 pragma applies. If more than one function name exists of this name in
2802 the declarative part you must use the @code{Parameter_Types} and
2803 @var{Result_Type} parameters to achieve the required unique
2804 designation. Subtype marks in these parameters must exactly match the
2805 subtypes in the corresponding function specification, using positional
2806 notation to match parameters with subtype marks.
2807 The form with an @code{'Access} attribute can be used to match an
2808 anonymous access parameter.
2810 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2811 parameters to specify passing mechanisms for the
2812 parameters and result. If you specify a single mechanism name, it
2813 applies to all parameters. Otherwise you may specify a mechanism on a
2814 parameter by parameter basis using either positional or named
2815 notation. If the mechanism is not specified, the default mechanism
2819 @cindex Passing by descriptor
2820 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2821 The default behavior for Import_Function is to pass a 64bit descriptor
2822 unless short_descriptor is specified, then a 32bit descriptor is passed.
2824 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2825 It specifies that the designated parameter and all following parameters
2826 are optional, meaning that they are not passed at the generated code
2827 level (this is distinct from the notion of optional parameters in Ada
2828 where the parameters are passed anyway with the designated optional
2829 parameters). All optional parameters must be of mode @code{IN} and have
2830 default parameter values that are either known at compile time
2831 expressions, or uses of the @code{'Null_Parameter} attribute.
2833 @node Pragma Import_Object
2834 @unnumberedsec Pragma Import_Object
2835 @findex Import_Object
2839 @smallexample @c ada
2840 pragma Import_Object
2841 [Internal =>] LOCAL_NAME
2842 [, [External =>] EXTERNAL_SYMBOL]
2843 [, [Size =>] EXTERNAL_SYMBOL]);
2847 | static_string_EXPRESSION
2851 This pragma designates an object as imported, and apart from the
2852 extended rules for external symbols, is identical in effect to the use of
2853 the normal @code{Import} pragma applied to an object. Unlike the
2854 subprogram case, you need not use a separate @code{Import} pragma,
2855 although you may do so (and probably should do so from a portability
2856 point of view). @var{size} is syntax checked, but otherwise ignored by
2859 @node Pragma Import_Procedure
2860 @unnumberedsec Pragma Import_Procedure
2861 @findex Import_Procedure
2865 @smallexample @c ada
2866 pragma Import_Procedure (
2867 [Internal =>] LOCAL_NAME
2868 [, [External =>] EXTERNAL_SYMBOL]
2869 [, [Parameter_Types =>] PARAMETER_TYPES]
2870 [, [Mechanism =>] MECHANISM]
2871 [, [First_Optional_Parameter =>] IDENTIFIER]);
2875 | static_string_EXPRESSION
2879 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2883 | subtype_Name ' Access
2887 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2889 MECHANISM_ASSOCIATION ::=
2890 [formal_parameter_NAME =>] MECHANISM_NAME
2895 | Descriptor [([Class =>] CLASS_NAME)]
2896 | Short_Descriptor [([Class =>] CLASS_NAME)]
2898 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2902 This pragma is identical to @code{Import_Function} except that it
2903 applies to a procedure rather than a function and the parameters
2904 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2906 @node Pragma Import_Valued_Procedure
2907 @unnumberedsec Pragma Import_Valued_Procedure
2908 @findex Import_Valued_Procedure
2912 @smallexample @c ada
2913 pragma Import_Valued_Procedure (
2914 [Internal =>] LOCAL_NAME
2915 [, [External =>] EXTERNAL_SYMBOL]
2916 [, [Parameter_Types =>] PARAMETER_TYPES]
2917 [, [Mechanism =>] MECHANISM]
2918 [, [First_Optional_Parameter =>] IDENTIFIER]);
2922 | static_string_EXPRESSION
2926 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2930 | subtype_Name ' Access
2934 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2936 MECHANISM_ASSOCIATION ::=
2937 [formal_parameter_NAME =>] MECHANISM_NAME
2942 | Descriptor [([Class =>] CLASS_NAME)]
2943 | Short_Descriptor [([Class =>] CLASS_NAME)]
2945 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2949 This pragma is identical to @code{Import_Procedure} except that the
2950 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2951 mode @code{OUT}, and externally the subprogram is treated as a function
2952 with this parameter as the result of the function. The purpose of this
2953 capability is to allow the use of @code{OUT} and @code{IN OUT}
2954 parameters in interfacing to external functions (which are not permitted
2955 in Ada functions). You may optionally use the @code{Mechanism}
2956 parameters to specify passing mechanisms for the parameters.
2957 If you specify a single mechanism name, it applies to all parameters.
2958 Otherwise you may specify a mechanism on a parameter by parameter
2959 basis using either positional or named notation. If the mechanism is not
2960 specified, the default mechanism is used.
2962 Note that it is important to use this pragma in conjunction with a separate
2963 pragma Import that specifies the desired convention, since otherwise the
2964 default convention is Ada, which is almost certainly not what is required.
2966 @node Pragma Initialize_Scalars
2967 @unnumberedsec Pragma Initialize_Scalars
2968 @findex Initialize_Scalars
2969 @cindex debugging with Initialize_Scalars
2973 @smallexample @c ada
2974 pragma Initialize_Scalars;
2978 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2979 two important differences. First, there is no requirement for the pragma
2980 to be used uniformly in all units of a partition, in particular, it is fine
2981 to use this just for some or all of the application units of a partition,
2982 without needing to recompile the run-time library.
2984 In the case where some units are compiled with the pragma, and some without,
2985 then a declaration of a variable where the type is defined in package
2986 Standard or is locally declared will always be subject to initialization,
2987 as will any declaration of a scalar variable. For composite variables,
2988 whether the variable is initialized may also depend on whether the package
2989 in which the type of the variable is declared is compiled with the pragma.
2991 The other important difference is that you can control the value used
2992 for initializing scalar objects. At bind time, you can select several
2993 options for initialization. You can
2994 initialize with invalid values (similar to Normalize_Scalars, though for
2995 Initialize_Scalars it is not always possible to determine the invalid
2996 values in complex cases like signed component fields with non-standard
2997 sizes). You can also initialize with high or
2998 low values, or with a specified bit pattern. See the users guide for binder
2999 options for specifying these cases.
3001 This means that you can compile a program, and then without having to
3002 recompile the program, you can run it with different values being used
3003 for initializing otherwise uninitialized values, to test if your program
3004 behavior depends on the choice. Of course the behavior should not change,
3005 and if it does, then most likely you have an erroneous reference to an
3006 uninitialized value.
3008 It is even possible to change the value at execution time eliminating even
3009 the need to rebind with a different switch using an environment variable.
3010 See the GNAT users guide for details.
3012 Note that pragma @code{Initialize_Scalars} is particularly useful in
3013 conjunction with the enhanced validity checking that is now provided
3014 in GNAT, which checks for invalid values under more conditions.
3015 Using this feature (see description of the @option{-gnatV} flag in the
3016 users guide) in conjunction with pragma @code{Initialize_Scalars}
3017 provides a powerful new tool to assist in the detection of problems
3018 caused by uninitialized variables.
3020 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3021 effect on the generated code. This may cause your code to be
3022 substantially larger. It may also cause an increase in the amount
3023 of stack required, so it is probably a good idea to turn on stack
3024 checking (see description of stack checking in the GNAT users guide)
3025 when using this pragma.
3027 @node Pragma Inline_Always
3028 @unnumberedsec Pragma Inline_Always
3029 @findex Inline_Always
3033 @smallexample @c ada
3034 pragma Inline_Always (NAME [, NAME]);
3038 Similar to pragma @code{Inline} except that inlining is not subject to
3039 the use of option @option{-gnatn} and the inlining happens regardless of
3040 whether this option is used.
3042 @node Pragma Inline_Generic
3043 @unnumberedsec Pragma Inline_Generic
3044 @findex Inline_Generic
3048 @smallexample @c ada
3049 pragma Inline_Generic (generic_package_NAME);
3053 This is implemented for compatibility with DEC Ada 83 and is recognized,
3054 but otherwise ignored, by GNAT@. All generic instantiations are inlined
3055 by default when using GNAT@.
3057 @node Pragma Interface
3058 @unnumberedsec Pragma Interface
3063 @smallexample @c ada
3065 [Convention =>] convention_identifier,
3066 [Entity =>] local_NAME
3067 [, [External_Name =>] static_string_expression]
3068 [, [Link_Name =>] static_string_expression]);
3072 This pragma is identical in syntax and semantics to
3073 the standard Ada pragma @code{Import}. It is provided for compatibility
3074 with Ada 83. The definition is upwards compatible both with pragma
3075 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3076 with some extended implementations of this pragma in certain Ada 83
3077 implementations. The only difference between pragma @code{Interface}
3078 and pragma @code{Import} is that there is special circuitry to allow
3079 both pragmas to appear for the same subprogram entity (normally it
3080 is illegal to have multiple @code{Import} pragmas. This is useful in
3081 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3084 @node Pragma Interface_Name
3085 @unnumberedsec Pragma Interface_Name
3086 @findex Interface_Name
3090 @smallexample @c ada
3091 pragma Interface_Name (
3092 [Entity =>] LOCAL_NAME
3093 [, [External_Name =>] static_string_EXPRESSION]
3094 [, [Link_Name =>] static_string_EXPRESSION]);
3098 This pragma provides an alternative way of specifying the interface name
3099 for an interfaced subprogram, and is provided for compatibility with Ada
3100 83 compilers that use the pragma for this purpose. You must provide at
3101 least one of @var{External_Name} or @var{Link_Name}.
3103 @node Pragma Interrupt_Handler
3104 @unnumberedsec Pragma Interrupt_Handler
3105 @findex Interrupt_Handler
3109 @smallexample @c ada
3110 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3114 This program unit pragma is supported for parameterless protected procedures
3115 as described in Annex C of the Ada Reference Manual. On the AAMP target
3116 the pragma can also be specified for nonprotected parameterless procedures
3117 that are declared at the library level (which includes procedures
3118 declared at the top level of a library package). In the case of AAMP,
3119 when this pragma is applied to a nonprotected procedure, the instruction
3120 @code{IERET} is generated for returns from the procedure, enabling
3121 maskable interrupts, in place of the normal return instruction.
3123 @node Pragma Interrupt_State
3124 @unnumberedsec Pragma Interrupt_State
3125 @findex Interrupt_State
3129 @smallexample @c ada
3130 pragma Interrupt_State
3132 [State =>] SYSTEM | RUNTIME | USER);
3136 Normally certain interrupts are reserved to the implementation. Any attempt
3137 to attach an interrupt causes Program_Error to be raised, as described in
3138 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3139 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3140 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3141 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3142 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3143 Ada exceptions, or used to implement run-time functions such as the
3144 @code{abort} statement and stack overflow checking.
3146 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3147 such uses of interrupts. It subsumes the functionality of pragma
3148 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3149 available on Windows or VMS. On all other platforms than VxWorks,
3150 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3151 and may be used to mark interrupts required by the board support package
3154 Interrupts can be in one of three states:
3158 The interrupt is reserved (no Ada handler can be installed), and the
3159 Ada run-time may not install a handler. As a result you are guaranteed
3160 standard system default action if this interrupt is raised.
3164 The interrupt is reserved (no Ada handler can be installed). The run time
3165 is allowed to install a handler for internal control purposes, but is
3166 not required to do so.
3170 The interrupt is unreserved. The user may install a handler to provide
3175 These states are the allowed values of the @code{State} parameter of the
3176 pragma. The @code{Name} parameter is a value of the type
3177 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3178 @code{Ada.Interrupts.Names}.
3180 This is a configuration pragma, and the binder will check that there
3181 are no inconsistencies between different units in a partition in how a
3182 given interrupt is specified. It may appear anywhere a pragma is legal.
3184 The effect is to move the interrupt to the specified state.
3186 By declaring interrupts to be SYSTEM, you guarantee the standard system
3187 action, such as a core dump.
3189 By declaring interrupts to be USER, you guarantee that you can install
3192 Note that certain signals on many operating systems cannot be caught and
3193 handled by applications. In such cases, the pragma is ignored. See the
3194 operating system documentation, or the value of the array @code{Reserved}
3195 declared in the spec of package @code{System.OS_Interface}.
3197 Overriding the default state of signals used by the Ada runtime may interfere
3198 with an application's runtime behavior in the cases of the synchronous signals,
3199 and in the case of the signal used to implement the @code{abort} statement.
3201 @node Pragma Invariant
3202 @unnumberedsec Pragma Invariant
3207 @smallexample @c ada
3209 ([Entity =>] private_type_LOCAL_NAME,
3210 [Check =>] EXPRESSION
3211 [,[Message =>] String_Expression]);
3215 This pragma provides exactly the same capabilities as the Invariant aspect
3216 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The Invariant
3217 aspect is fully implemented in Ada 2012 mode, but since it requires the use
3218 of the aspect syntax, which is not available exception in 2012 mode, it is
3219 not possible to use the Invariant aspect in earlier versions of Ada. However
3220 the Invariant pragma may be used in any version of Ada.
3222 The pragma must appear within the visible part of the package specification,
3223 after the type to which its Entity argument appears. As with the Invariant
3224 aspect, the Check expression is not analyzed until the end of the visible
3225 part of the package, so it may contain forward references. The Message
3226 argument, if present, provides the exception message used if the invariant
3227 is violated. If no Message parameter is provided, a default message that
3228 identifies the line on which the pragma appears is used.
3230 It is permissible to have multiple Invariants for the same type entity, in
3231 which case they are and'ed together. It is permissible to use this pragma
3232 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3233 invariant pragma for the same entity.
3235 For further details on the use of this pragma, see the Ada 2012 documentation
3236 of the Invariant aspect.
3238 @node Pragma Keep_Names
3239 @unnumberedsec Pragma Keep_Names
3244 @smallexample @c ada
3245 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3249 The @var{LOCAL_NAME} argument
3250 must refer to an enumeration first subtype
3251 in the current declarative part. The effect is to retain the enumeration
3252 literal names for use by @code{Image} and @code{Value} even if a global
3253 @code{Discard_Names} pragma applies. This is useful when you want to
3254 generally suppress enumeration literal names and for example you therefore
3255 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3256 want to retain the names for specific enumeration types.
3258 @node Pragma License
3259 @unnumberedsec Pragma License
3261 @cindex License checking
3265 @smallexample @c ada
3266 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3270 This pragma is provided to allow automated checking for appropriate license
3271 conditions with respect to the standard and modified GPL@. A pragma
3272 @code{License}, which is a configuration pragma that typically appears at
3273 the start of a source file or in a separate @file{gnat.adc} file, specifies
3274 the licensing conditions of a unit as follows:
3278 This is used for a unit that can be freely used with no license restrictions.
3279 Examples of such units are public domain units, and units from the Ada
3283 This is used for a unit that is licensed under the unmodified GPL, and which
3284 therefore cannot be @code{with}'ed by a restricted unit.
3287 This is used for a unit licensed under the GNAT modified GPL that includes
3288 a special exception paragraph that specifically permits the inclusion of
3289 the unit in programs without requiring the entire program to be released
3293 This is used for a unit that is restricted in that it is not permitted to
3294 depend on units that are licensed under the GPL@. Typical examples are
3295 proprietary code that is to be released under more restrictive license
3296 conditions. Note that restricted units are permitted to @code{with} units
3297 which are licensed under the modified GPL (this is the whole point of the
3303 Normally a unit with no @code{License} pragma is considered to have an
3304 unknown license, and no checking is done. However, standard GNAT headers
3305 are recognized, and license information is derived from them as follows.
3309 A GNAT license header starts with a line containing 78 hyphens. The following
3310 comment text is searched for the appearance of any of the following strings.
3312 If the string ``GNU General Public License'' is found, then the unit is assumed
3313 to have GPL license, unless the string ``As a special exception'' follows, in
3314 which case the license is assumed to be modified GPL@.
3316 If one of the strings
3317 ``This specification is adapted from the Ada Semantic Interface'' or
3318 ``This specification is derived from the Ada Reference Manual'' is found
3319 then the unit is assumed to be unrestricted.
3323 These default actions means that a program with a restricted license pragma
3324 will automatically get warnings if a GPL unit is inappropriately
3325 @code{with}'ed. For example, the program:
3327 @smallexample @c ada
3330 procedure Secret_Stuff is
3336 if compiled with pragma @code{License} (@code{Restricted}) in a
3337 @file{gnat.adc} file will generate the warning:
3342 >>> license of withed unit "Sem_Ch3" is incompatible
3344 2. with GNAT.Sockets;
3345 3. procedure Secret_Stuff is
3349 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3350 compiler and is licensed under the
3351 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3352 run time, and is therefore licensed under the modified GPL@.
3354 @node Pragma Link_With
3355 @unnumberedsec Pragma Link_With
3360 @smallexample @c ada
3361 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3365 This pragma is provided for compatibility with certain Ada 83 compilers.
3366 It has exactly the same effect as pragma @code{Linker_Options} except
3367 that spaces occurring within one of the string expressions are treated
3368 as separators. For example, in the following case:
3370 @smallexample @c ada
3371 pragma Link_With ("-labc -ldef");
3375 results in passing the strings @code{-labc} and @code{-ldef} as two
3376 separate arguments to the linker. In addition pragma Link_With allows
3377 multiple arguments, with the same effect as successive pragmas.
3379 @node Pragma Linker_Alias
3380 @unnumberedsec Pragma Linker_Alias
3381 @findex Linker_Alias
3385 @smallexample @c ada
3386 pragma Linker_Alias (
3387 [Entity =>] LOCAL_NAME,
3388 [Target =>] static_string_EXPRESSION);
3392 @var{LOCAL_NAME} must refer to an object that is declared at the library
3393 level. This pragma establishes the given entity as a linker alias for the
3394 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3395 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3396 @var{static_string_EXPRESSION} in the object file, that is to say no space
3397 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3398 to the same address as @var{static_string_EXPRESSION} by the linker.
3400 The actual linker name for the target must be used (e.g.@: the fully
3401 encoded name with qualification in Ada, or the mangled name in C++),
3402 or it must be declared using the C convention with @code{pragma Import}
3403 or @code{pragma Export}.
3405 Not all target machines support this pragma. On some of them it is accepted
3406 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3408 @smallexample @c ada
3409 -- Example of the use of pragma Linker_Alias
3413 pragma Export (C, i);
3415 new_name_for_i : Integer;
3416 pragma Linker_Alias (new_name_for_i, "i");
3420 @node Pragma Linker_Constructor
3421 @unnumberedsec Pragma Linker_Constructor
3422 @findex Linker_Constructor
3426 @smallexample @c ada
3427 pragma Linker_Constructor (procedure_LOCAL_NAME);
3431 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3432 is declared at the library level. A procedure to which this pragma is
3433 applied will be treated as an initialization routine by the linker.
3434 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3435 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3436 of the executable is called (or immediately after the shared library is
3437 loaded if the procedure is linked in a shared library), in particular
3438 before the Ada run-time environment is set up.
3440 Because of these specific contexts, the set of operations such a procedure
3441 can perform is very limited and the type of objects it can manipulate is
3442 essentially restricted to the elementary types. In particular, it must only
3443 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3445 This pragma is used by GNAT to implement auto-initialization of shared Stand
3446 Alone Libraries, which provides a related capability without the restrictions
3447 listed above. Where possible, the use of Stand Alone Libraries is preferable
3448 to the use of this pragma.
3450 @node Pragma Linker_Destructor
3451 @unnumberedsec Pragma Linker_Destructor
3452 @findex Linker_Destructor
3456 @smallexample @c ada
3457 pragma Linker_Destructor (procedure_LOCAL_NAME);
3461 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3462 is declared at the library level. A procedure to which this pragma is
3463 applied will be treated as a finalization routine by the linker.
3464 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3465 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3466 of the executable has exited (or immediately before the shared library
3467 is unloaded if the procedure is linked in a shared library), in particular
3468 after the Ada run-time environment is shut down.
3470 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3471 because of these specific contexts.
3473 @node Pragma Linker_Section
3474 @unnumberedsec Pragma Linker_Section
3475 @findex Linker_Section
3479 @smallexample @c ada
3480 pragma Linker_Section (
3481 [Entity =>] LOCAL_NAME,
3482 [Section =>] static_string_EXPRESSION);
3486 @var{LOCAL_NAME} must refer to an object that is declared at the library
3487 level. This pragma specifies the name of the linker section for the given
3488 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3489 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3490 section of the executable (assuming the linker doesn't rename the section).
3492 The compiler normally places library-level objects in standard sections
3493 depending on their type: procedures and functions generally go in the
3494 @code{.text} section, initialized variables in the @code{.data} section
3495 and uninitialized variables in the @code{.bss} section.
3497 Other, special sections may exist on given target machines to map special
3498 hardware, for example I/O ports or flash memory. This pragma is a means to
3499 defer the final layout of the executable to the linker, thus fully working
3500 at the symbolic level with the compiler.
3502 Some file formats do not support arbitrary sections so not all target
3503 machines support this pragma. The use of this pragma may cause a program
3504 execution to be erroneous if it is used to place an entity into an
3505 inappropriate section (e.g.@: a modified variable into the @code{.text}
3506 section). See also @code{pragma Persistent_BSS}.
3508 @smallexample @c ada
3509 -- Example of the use of pragma Linker_Section
3513 pragma Volatile (Port_A);
3514 pragma Linker_Section (Port_A, ".bss.port_a");
3517 pragma Volatile (Port_B);
3518 pragma Linker_Section (Port_B, ".bss.port_b");
3522 @node Pragma Long_Float
3523 @unnumberedsec Pragma Long_Float
3529 @smallexample @c ada
3530 pragma Long_Float (FLOAT_FORMAT);
3532 FLOAT_FORMAT ::= D_Float | G_Float
3536 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3537 It allows control over the internal representation chosen for the predefined
3538 type @code{Long_Float} and for floating point type representations with
3539 @code{digits} specified in the range 7 through 15.
3540 For further details on this pragma, see the
3541 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3542 this pragma, the standard runtime libraries must be recompiled.
3544 @node Pragma Machine_Attribute
3545 @unnumberedsec Pragma Machine_Attribute
3546 @findex Machine_Attribute
3550 @smallexample @c ada
3551 pragma Machine_Attribute (
3552 [Entity =>] LOCAL_NAME,
3553 [Attribute_Name =>] static_string_EXPRESSION
3554 [, [Info =>] static_EXPRESSION] );
3558 Machine-dependent attributes can be specified for types and/or
3559 declarations. This pragma is semantically equivalent to
3560 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3561 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3562 in GNU C, where @code{@var{attribute_name}} is recognized by the
3563 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3564 specific macro. A string literal for the optional parameter @var{info}
3565 is transformed into an identifier, which may make this pragma unusable
3566 for some attributes. @xref{Target Attributes,, Defining target-specific
3567 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3568 Internals}, further information.
3571 @unnumberedsec Pragma Main
3577 @smallexample @c ada
3579 (MAIN_OPTION [, MAIN_OPTION]);
3582 [Stack_Size =>] static_integer_EXPRESSION
3583 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3584 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3588 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3589 no effect in GNAT, other than being syntax checked.
3591 @node Pragma Main_Storage
3592 @unnumberedsec Pragma Main_Storage
3594 @findex Main_Storage
3598 @smallexample @c ada
3600 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3602 MAIN_STORAGE_OPTION ::=
3603 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3604 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3608 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3609 no effect in GNAT, other than being syntax checked. Note that the pragma
3610 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3612 @node Pragma No_Body
3613 @unnumberedsec Pragma No_Body
3618 @smallexample @c ada
3623 There are a number of cases in which a package spec does not require a body,
3624 and in fact a body is not permitted. GNAT will not permit the spec to be
3625 compiled if there is a body around. The pragma No_Body allows you to provide
3626 a body file, even in a case where no body is allowed. The body file must
3627 contain only comments and a single No_Body pragma. This is recognized by
3628 the compiler as indicating that no body is logically present.
3630 This is particularly useful during maintenance when a package is modified in
3631 such a way that a body needed before is no longer needed. The provision of a
3632 dummy body with a No_Body pragma ensures that there is no interference from
3633 earlier versions of the package body.
3635 @node Pragma No_Return
3636 @unnumberedsec Pragma No_Return
3641 @smallexample @c ada
3642 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3646 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3647 declarations in the current declarative part. A procedure to which this
3648 pragma is applied may not contain any explicit @code{return} statements.
3649 In addition, if the procedure contains any implicit returns from falling
3650 off the end of a statement sequence, then execution of that implicit
3651 return will cause Program_Error to be raised.
3653 One use of this pragma is to identify procedures whose only purpose is to raise
3654 an exception. Another use of this pragma is to suppress incorrect warnings
3655 about missing returns in functions, where the last statement of a function
3656 statement sequence is a call to such a procedure.
3658 Note that in Ada 2005 mode, this pragma is part of the language, and is
3659 identical in effect to the pragma as implemented in Ada 95 mode.
3661 @node Pragma No_Strict_Aliasing
3662 @unnumberedsec Pragma No_Strict_Aliasing
3663 @findex No_Strict_Aliasing
3667 @smallexample @c ada
3668 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3672 @var{type_LOCAL_NAME} must refer to an access type
3673 declaration in the current declarative part. The effect is to inhibit
3674 strict aliasing optimization for the given type. The form with no
3675 arguments is a configuration pragma which applies to all access types
3676 declared in units to which the pragma applies. For a detailed
3677 description of the strict aliasing optimization, and the situations
3678 in which it must be suppressed, see @ref{Optimization and Strict
3679 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3681 This pragma currently has no effects on access to unconstrained array types.
3683 @node Pragma Normalize_Scalars
3684 @unnumberedsec Pragma Normalize_Scalars
3685 @findex Normalize_Scalars
3689 @smallexample @c ada
3690 pragma Normalize_Scalars;
3694 This is a language defined pragma which is fully implemented in GNAT@. The
3695 effect is to cause all scalar objects that are not otherwise initialized
3696 to be initialized. The initial values are implementation dependent and
3700 @item Standard.Character
3702 Objects whose root type is Standard.Character are initialized to
3703 Character'Last unless the subtype range excludes NUL (in which case
3704 NUL is used). This choice will always generate an invalid value if
3707 @item Standard.Wide_Character
3709 Objects whose root type is Standard.Wide_Character are initialized to
3710 Wide_Character'Last unless the subtype range excludes NUL (in which case
3711 NUL is used). This choice will always generate an invalid value if
3714 @item Standard.Wide_Wide_Character
3716 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3717 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3718 which case NUL is used). This choice will always generate an invalid value if
3723 Objects of an integer type are treated differently depending on whether
3724 negative values are present in the subtype. If no negative values are
3725 present, then all one bits is used as the initial value except in the
3726 special case where zero is excluded from the subtype, in which case
3727 all zero bits are used. This choice will always generate an invalid
3728 value if one exists.
3730 For subtypes with negative values present, the largest negative number
3731 is used, except in the unusual case where this largest negative number
3732 is in the subtype, and the largest positive number is not, in which case
3733 the largest positive value is used. This choice will always generate
3734 an invalid value if one exists.
3736 @item Floating-Point Types
3737 Objects of all floating-point types are initialized to all 1-bits. For
3738 standard IEEE format, this corresponds to a NaN (not a number) which is
3739 indeed an invalid value.
3741 @item Fixed-Point Types
3742 Objects of all fixed-point types are treated as described above for integers,
3743 with the rules applying to the underlying integer value used to represent
3744 the fixed-point value.
3747 Objects of a modular type are initialized to all one bits, except in
3748 the special case where zero is excluded from the subtype, in which
3749 case all zero bits are used. This choice will always generate an
3750 invalid value if one exists.
3752 @item Enumeration types
3753 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3754 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3755 whose Pos value is zero, in which case a code of zero is used. This choice
3756 will always generate an invalid value if one exists.
3760 @node Pragma Obsolescent
3761 @unnumberedsec Pragma Obsolescent
3766 @smallexample @c ada
3769 pragma Obsolescent (
3770 [Message =>] static_string_EXPRESSION
3771 [,[Version =>] Ada_05]]);
3773 pragma Obsolescent (
3775 [,[Message =>] static_string_EXPRESSION
3776 [,[Version =>] Ada_05]] );
3780 This pragma can occur immediately following a declaration of an entity,
3781 including the case of a record component. If no Entity argument is present,
3782 then this declaration is the one to which the pragma applies. If an Entity
3783 parameter is present, it must either match the name of the entity in this
3784 declaration, or alternatively, the pragma can immediately follow an enumeration
3785 type declaration, where the Entity argument names one of the enumeration
3788 This pragma is used to indicate that the named entity
3789 is considered obsolescent and should not be used. Typically this is
3790 used when an API must be modified by eventually removing or modifying
3791 existing subprograms or other entities. The pragma can be used at an
3792 intermediate stage when the entity is still present, but will be
3795 The effect of this pragma is to output a warning message on a reference to
3796 an entity thus marked that the subprogram is obsolescent if the appropriate
3797 warning option in the compiler is activated. If the Message parameter is
3798 present, then a second warning message is given containing this text. In
3799 addition, a reference to the entity is considered to be a violation of pragma
3800 Restrictions (No_Obsolescent_Features).
3802 This pragma can also be used as a program unit pragma for a package,
3803 in which case the entity name is the name of the package, and the
3804 pragma indicates that the entire package is considered
3805 obsolescent. In this case a client @code{with}'ing such a package
3806 violates the restriction, and the @code{with} statement is
3807 flagged with warnings if the warning option is set.
3809 If the Version parameter is present (which must be exactly
3810 the identifier Ada_05, no other argument is allowed), then the
3811 indication of obsolescence applies only when compiling in Ada 2005
3812 mode. This is primarily intended for dealing with the situations
3813 in the predefined library where subprograms or packages
3814 have become defined as obsolescent in Ada 2005
3815 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3817 The following examples show typical uses of this pragma:
3819 @smallexample @c ada
3821 pragma Obsolescent (p, Message => "use pp instead of p");
3826 pragma Obsolescent ("use q2new instead");
3828 type R is new integer;
3831 Message => "use RR in Ada 2005",
3841 type E is (a, bc, 'd', quack);
3842 pragma Obsolescent (Entity => bc)
3843 pragma Obsolescent (Entity => 'd')
3846 (a, b : character) return character;
3847 pragma Obsolescent (Entity => "+");
3852 Note that, as for all pragmas, if you use a pragma argument identifier,
3853 then all subsequent parameters must also use a pragma argument identifier.
3854 So if you specify "Entity =>" for the Entity argument, and a Message
3855 argument is present, it must be preceded by "Message =>".
3857 @node Pragma Optimize_Alignment
3858 @unnumberedsec Pragma Optimize_Alignment
3859 @findex Optimize_Alignment
3860 @cindex Alignment, default settings
3864 @smallexample @c ada
3865 pragma Optimize_Alignment (TIME | SPACE | OFF);
3869 This is a configuration pragma which affects the choice of default alignments
3870 for types where no alignment is explicitly specified. There is a time/space
3871 trade-off in the selection of these values. Large alignments result in more
3872 efficient code, at the expense of larger data space, since sizes have to be
3873 increased to match these alignments. Smaller alignments save space, but the
3874 access code is slower. The normal choice of default alignments (which is what
3875 you get if you do not use this pragma, or if you use an argument of OFF),
3876 tries to balance these two requirements.
3878 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3879 First any packed record is given an alignment of 1. Second, if a size is given
3880 for the type, then the alignment is chosen to avoid increasing this size. For
3883 @smallexample @c ada
3893 In the default mode, this type gets an alignment of 4, so that access to the
3894 Integer field X are efficient. But this means that objects of the type end up
3895 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3896 allowed to be bigger than the size of the type, but it can waste space if for
3897 example fields of type R appear in an enclosing record. If the above type is
3898 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3900 Specifying TIME causes larger default alignments to be chosen in the case of
3901 small types with sizes that are not a power of 2. For example, consider:
3903 @smallexample @c ada
3915 The default alignment for this record is normally 1, but if this type is
3916 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3917 to 4, which wastes space for objects of the type, since they are now 4 bytes
3918 long, but results in more efficient access when the whole record is referenced.
3920 As noted above, this is a configuration pragma, and there is a requirement
3921 that all units in a partition be compiled with a consistent setting of the
3922 optimization setting. This would normally be achieved by use of a configuration
3923 pragma file containing the appropriate setting. The exception to this rule is
3924 that units with an explicit configuration pragma in the same file as the source
3925 unit are excluded from the consistency check, as are all predefined units. The
3926 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3927 pragma appears at the start of the file.
3929 @node Pragma Ordered
3930 @unnumberedsec Pragma Ordered
3932 @findex pragma @code{Ordered}
3936 @smallexample @c ada
3937 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3941 Most enumeration types are from a conceptual point of view unordered.
3942 For example, consider:
3944 @smallexample @c ada
3945 type Color is (Red, Blue, Green, Yellow);
3949 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
3950 but really these relations make no sense; the enumeration type merely
3951 specifies a set of possible colors, and the order is unimportant.
3953 For unordered enumeration types, it is generally a good idea if
3954 clients avoid comparisons (other than equality or inequality) and
3955 explicit ranges. (A @emph{client} is a unit where the type is referenced,
3956 other than the unit where the type is declared, its body, and its subunits.)
3957 For example, if code buried in some client says:
3959 @smallexample @c ada
3960 if Current_Color < Yellow then ...
3961 if Current_Color in Blue .. Green then ...
3965 then the client code is relying on the order, which is undesirable.
3966 It makes the code hard to read and creates maintenance difficulties if
3967 entries have to be added to the enumeration type. Instead,
3968 the code in the client should list the possibilities, or an
3969 appropriate subtype should be declared in the unit that declares
3970 the original enumeration type. E.g., the following subtype could
3971 be declared along with the type @code{Color}:
3973 @smallexample @c ada
3974 subtype RBG is Color range Red .. Green;
3978 and then the client could write:
3980 @smallexample @c ada
3981 if Current_Color in RBG then ...
3982 if Current_Color = Blue or Current_Color = Green then ...
3986 However, some enumeration types are legitimately ordered from a conceptual
3987 point of view. For example, if you declare:
3989 @smallexample @c ada
3990 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3994 then the ordering imposed by the language is reasonable, and
3995 clients can depend on it, writing for example:
3997 @smallexample @c ada
3998 if D in Mon .. Fri then ...
4003 The pragma @option{Ordered} is provided to mark enumeration types that
4004 are conceptually ordered, alerting the reader that clients may depend
4005 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4006 rather than one to mark them as unordered, since in our experience,
4007 the great majority of enumeration types are conceptually unordered.
4009 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4010 and @code{Wide_Wide_Character}
4011 are considered to be ordered types, so each is declared with a
4012 pragma @code{Ordered} in package @code{Standard}.
4014 Normally pragma @code{Ordered} serves only as documentation and a guide for
4015 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4016 requests warnings for inappropriate uses (comparisons and explicit
4017 subranges) for unordered types. If this switch is used, then any
4018 enumeration type not marked with pragma @code{Ordered} will be considered
4019 as unordered, and will generate warnings for inappropriate uses.
4021 For additional information please refer to the description of the
4022 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4024 @node Pragma Passive
4025 @unnumberedsec Pragma Passive
4030 @smallexample @c ada
4031 pragma Passive [(Semaphore | No)];
4035 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
4036 compatibility with DEC Ada 83 implementations, where it is used within a
4037 task definition to request that a task be made passive. If the argument
4038 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4039 treats the pragma as an assertion that the containing task is passive
4040 and that optimization of context switch with this task is permitted and
4041 desired. If the argument @code{No} is present, the task must not be
4042 optimized. GNAT does not attempt to optimize any tasks in this manner
4043 (since protected objects are available in place of passive tasks).
4045 @node Pragma Persistent_BSS
4046 @unnumberedsec Pragma Persistent_BSS
4047 @findex Persistent_BSS
4051 @smallexample @c ada
4052 pragma Persistent_BSS [(LOCAL_NAME)]
4056 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4057 section. On some targets the linker and loader provide for special
4058 treatment of this section, allowing a program to be reloaded without
4059 affecting the contents of this data (hence the name persistent).
4061 There are two forms of usage. If an argument is given, it must be the
4062 local name of a library level object, with no explicit initialization
4063 and whose type is potentially persistent. If no argument is given, then
4064 the pragma is a configuration pragma, and applies to all library level
4065 objects with no explicit initialization of potentially persistent types.
4067 A potentially persistent type is a scalar type, or a non-tagged,
4068 non-discriminated record, all of whose components have no explicit
4069 initialization and are themselves of a potentially persistent type,
4070 or an array, all of whose constraints are static, and whose component
4071 type is potentially persistent.
4073 If this pragma is used on a target where this feature is not supported,
4074 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4076 @node Pragma Polling
4077 @unnumberedsec Pragma Polling
4082 @smallexample @c ada
4083 pragma Polling (ON | OFF);
4087 This pragma controls the generation of polling code. This is normally off.
4088 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4089 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
4090 runtime library, and can be found in file @file{a-excpol.adb}.
4092 Pragma @code{Polling} can appear as a configuration pragma (for example it
4093 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4094 can be used in the statement or declaration sequence to control polling
4097 A call to the polling routine is generated at the start of every loop and
4098 at the start of every subprogram call. This guarantees that the @code{Poll}
4099 routine is called frequently, and places an upper bound (determined by
4100 the complexity of the code) on the period between two @code{Poll} calls.
4102 The primary purpose of the polling interface is to enable asynchronous
4103 aborts on targets that cannot otherwise support it (for example Windows
4104 NT), but it may be used for any other purpose requiring periodic polling.
4105 The standard version is null, and can be replaced by a user program. This
4106 will require re-compilation of the @code{Ada.Exceptions} package that can
4107 be found in files @file{a-except.ads} and @file{a-except.adb}.
4109 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
4110 distribution) is used to enable the asynchronous abort capability on
4111 targets that do not normally support the capability. The version of
4112 @code{Poll} in this file makes a call to the appropriate runtime routine
4113 to test for an abort condition.
4115 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4116 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4119 @node Pragma Postcondition
4120 @unnumberedsec Pragma Postcondition
4121 @cindex Postconditions
4122 @cindex Checks, postconditions
4123 @findex Postconditions
4127 @smallexample @c ada
4128 pragma Postcondition (
4129 [Check =>] Boolean_Expression
4130 [,[Message =>] String_Expression]);
4134 The @code{Postcondition} pragma allows specification of automatic
4135 postcondition checks for subprograms. These checks are similar to
4136 assertions, but are automatically inserted just prior to the return
4137 statements of the subprogram with which they are associated (including
4138 implicit returns at the end of procedure bodies and associated
4139 exception handlers).
4141 In addition, the boolean expression which is the condition which
4142 must be true may contain references to function'Result in the case
4143 of a function to refer to the returned value.
4145 @code{Postcondition} pragmas may appear either immediately following the
4146 (separate) declaration of a subprogram, or at the start of the
4147 declarations of a subprogram body. Only other pragmas may intervene
4148 (that is appear between the subprogram declaration and its
4149 postconditions, or appear before the postcondition in the
4150 declaration sequence in a subprogram body). In the case of a
4151 postcondition appearing after a subprogram declaration, the
4152 formal arguments of the subprogram are visible, and can be
4153 referenced in the postcondition expressions.
4155 The postconditions are collected and automatically tested just
4156 before any return (implicit or explicit) in the subprogram body.
4157 A postcondition is only recognized if postconditions are active
4158 at the time the pragma is encountered. The compiler switch @option{gnata}
4159 turns on all postconditions by default, and pragma @code{Check_Policy}
4160 with an identifier of @code{Postcondition} can also be used to
4161 control whether postconditions are active.
4163 The general approach is that postconditions are placed in the spec
4164 if they represent functional aspects which make sense to the client.
4165 For example we might have:
4167 @smallexample @c ada
4168 function Direction return Integer;
4169 pragma Postcondition
4170 (Direction'Result = +1
4172 Direction'Result = -1);
4176 which serves to document that the result must be +1 or -1, and
4177 will test that this is the case at run time if postcondition
4180 Postconditions within the subprogram body can be used to
4181 check that some internal aspect of the implementation,
4182 not visible to the client, is operating as expected.
4183 For instance if a square root routine keeps an internal
4184 counter of the number of times it is called, then we
4185 might have the following postcondition:
4187 @smallexample @c ada
4188 Sqrt_Calls : Natural := 0;
4190 function Sqrt (Arg : Float) return Float is
4191 pragma Postcondition
4192 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4198 As this example, shows, the use of the @code{Old} attribute
4199 is often useful in postconditions to refer to the state on
4200 entry to the subprogram.
4202 Note that postconditions are only checked on normal returns
4203 from the subprogram. If an abnormal return results from
4204 raising an exception, then the postconditions are not checked.
4206 If a postcondition fails, then the exception
4207 @code{System.Assertions.Assert_Failure} is raised. If
4208 a message argument was supplied, then the given string
4209 will be used as the exception message. If no message
4210 argument was supplied, then the default message has
4211 the form "Postcondition failed at file:line". The
4212 exception is raised in the context of the subprogram
4213 body, so it is possible to catch postcondition failures
4214 within the subprogram body itself.
4216 Within a package spec, normal visibility rules
4217 in Ada would prevent forward references within a
4218 postcondition pragma to functions defined later in
4219 the same package. This would introduce undesirable
4220 ordering constraints. To avoid this problem, all
4221 postcondition pragmas are analyzed at the end of
4222 the package spec, allowing forward references.
4224 The following example shows that this even allows
4225 mutually recursive postconditions as in:
4227 @smallexample @c ada
4228 package Parity_Functions is
4229 function Odd (X : Natural) return Boolean;
4230 pragma Postcondition
4234 (x /= 0 and then Even (X - 1))));
4236 function Even (X : Natural) return Boolean;
4237 pragma Postcondition
4241 (x /= 1 and then Odd (X - 1))));
4243 end Parity_Functions;
4247 There are no restrictions on the complexity or form of
4248 conditions used within @code{Postcondition} pragmas.
4249 The following example shows that it is even possible
4250 to verify performance behavior.
4252 @smallexample @c ada
4255 Performance : constant Float;
4256 -- Performance constant set by implementation
4257 -- to match target architecture behavior.
4259 procedure Treesort (Arg : String);
4260 -- Sorts characters of argument using N*logN sort
4261 pragma Postcondition
4262 (Float (Clock - Clock'Old) <=
4263 Float (Arg'Length) *
4264 log (Float (Arg'Length)) *
4270 Note: postcondition pragmas associated with subprograms that are
4271 marked as Inline_Always, or those marked as Inline with front-end
4272 inlining (-gnatN option set) are accepted and legality-checked
4273 by the compiler, but are ignored at run-time even if postcondition
4274 checking is enabled.
4276 @node Pragma Precondition
4277 @unnumberedsec Pragma Precondition
4278 @cindex Preconditions
4279 @cindex Checks, preconditions
4280 @findex Preconditions
4284 @smallexample @c ada
4285 pragma Precondition (
4286 [Check =>] Boolean_Expression
4287 [,[Message =>] String_Expression]);
4291 The @code{Precondition} pragma is similar to @code{Postcondition}
4292 except that the corresponding checks take place immediately upon
4293 entry to the subprogram, and if a precondition fails, the exception
4294 is raised in the context of the caller, and the attribute 'Result
4295 cannot be used within the precondition expression.
4297 Otherwise, the placement and visibility rules are identical to those
4298 described for postconditions. The following is an example of use
4299 within a package spec:
4301 @smallexample @c ada
4302 package Math_Functions is
4304 function Sqrt (Arg : Float) return Float;
4305 pragma Precondition (Arg >= 0.0)
4311 @code{Precondition} pragmas may appear either immediately following the
4312 (separate) declaration of a subprogram, or at the start of the
4313 declarations of a subprogram body. Only other pragmas may intervene
4314 (that is appear between the subprogram declaration and its
4315 postconditions, or appear before the postcondition in the
4316 declaration sequence in a subprogram body).
4318 Note: postcondition pragmas associated with subprograms that are
4319 marked as Inline_Always, or those marked as Inline with front-end
4320 inlining (-gnatN option set) are accepted and legality-checked
4321 by the compiler, but are ignored at run-time even if postcondition
4322 checking is enabled.
4324 @node Pragma Profile (Ravenscar)
4325 @unnumberedsec Pragma Profile (Ravenscar)
4330 @smallexample @c ada
4331 pragma Profile (Ravenscar);
4335 A configuration pragma that establishes the following set of configuration
4339 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4340 [RM D.2.2] Tasks are dispatched following a preemptive
4341 priority-ordered scheduling policy.
4343 @item Locking_Policy (Ceiling_Locking)
4344 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4345 the ceiling priority of the corresponding protected object.
4347 @c @item Detect_Blocking
4348 @c This pragma forces the detection of potentially blocking operations within a
4349 @c protected operation, and to raise Program_Error if that happens.
4353 plus the following set of restrictions:
4356 @item Max_Entry_Queue_Length => 1
4357 No task can be queued on a protected entry.
4358 @item Max_Protected_Entries => 1
4359 @item Max_Task_Entries => 0
4360 No rendezvous statements are allowed.
4361 @item No_Abort_Statements
4362 @item No_Dynamic_Attachment
4363 @item No_Dynamic_Priorities
4364 @item No_Implicit_Heap_Allocations
4365 @item No_Local_Protected_Objects
4366 @item No_Local_Timing_Events
4367 @item No_Protected_Type_Allocators
4368 @item No_Relative_Delay
4369 @item No_Requeue_Statements
4370 @item No_Select_Statements
4371 @item No_Specific_Termination_Handlers
4372 @item No_Task_Allocators
4373 @item No_Task_Hierarchy
4374 @item No_Task_Termination
4375 @item Simple_Barriers
4379 The Ravenscar profile also includes the following restrictions that specify
4380 that there are no semantic dependences on the corresponding predefined
4384 @item No_Dependence => Ada.Asynchronous_Task_Control
4385 @item No_Dependence => Ada.Calendar
4386 @item No_Dependence => Ada.Execution_Time.Group_Budget
4387 @item No_Dependence => Ada.Execution_Time.Timers
4388 @item No_Dependence => Ada.Task_Attributes
4389 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4394 This set of configuration pragmas and restrictions correspond to the
4395 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4396 published by the @cite{International Real-Time Ada Workshop}, 1997,
4397 and whose most recent description is available at
4398 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4400 The original definition of the profile was revised at subsequent IRTAW
4401 meetings. It has been included in the ISO
4402 @cite{Guide for the Use of the Ada Programming Language in High
4403 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4404 the next revision of the standard. The formal definition given by
4405 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4406 AI-305) available at
4407 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4408 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4410 The above set is a superset of the restrictions provided by pragma
4411 @code{Profile (Restricted)}, it includes six additional restrictions
4412 (@code{Simple_Barriers}, @code{No_Select_Statements},
4413 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4414 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4415 that pragma @code{Profile (Ravenscar)}, like the pragma
4416 @code{Profile (Restricted)},
4417 automatically causes the use of a simplified,
4418 more efficient version of the tasking run-time system.
4420 @node Pragma Profile (Restricted)
4421 @unnumberedsec Pragma Profile (Restricted)
4422 @findex Restricted Run Time
4426 @smallexample @c ada
4427 pragma Profile (Restricted);
4431 A configuration pragma that establishes the following set of restrictions:
4434 @item No_Abort_Statements
4435 @item No_Entry_Queue
4436 @item No_Task_Hierarchy
4437 @item No_Task_Allocators
4438 @item No_Dynamic_Priorities
4439 @item No_Terminate_Alternatives
4440 @item No_Dynamic_Attachment
4441 @item No_Protected_Type_Allocators
4442 @item No_Local_Protected_Objects
4443 @item No_Requeue_Statements
4444 @item No_Task_Attributes_Package
4445 @item Max_Asynchronous_Select_Nesting = 0
4446 @item Max_Task_Entries = 0
4447 @item Max_Protected_Entries = 1
4448 @item Max_Select_Alternatives = 0
4452 This set of restrictions causes the automatic selection of a simplified
4453 version of the run time that provides improved performance for the
4454 limited set of tasking functionality permitted by this set of restrictions.
4456 @node Pragma Psect_Object
4457 @unnumberedsec Pragma Psect_Object
4458 @findex Psect_Object
4462 @smallexample @c ada
4463 pragma Psect_Object (
4464 [Internal =>] LOCAL_NAME,
4465 [, [External =>] EXTERNAL_SYMBOL]
4466 [, [Size =>] EXTERNAL_SYMBOL]);
4470 | static_string_EXPRESSION
4474 This pragma is identical in effect to pragma @code{Common_Object}.
4476 @node Pragma Pure_Function
4477 @unnumberedsec Pragma Pure_Function
4478 @findex Pure_Function
4482 @smallexample @c ada
4483 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4487 This pragma appears in the same declarative part as a function
4488 declaration (or a set of function declarations if more than one
4489 overloaded declaration exists, in which case the pragma applies
4490 to all entities). It specifies that the function @code{Entity} is
4491 to be considered pure for the purposes of code generation. This means
4492 that the compiler can assume that there are no side effects, and
4493 in particular that two calls with identical arguments produce the
4494 same result. It also means that the function can be used in an
4497 Note that, quite deliberately, there are no static checks to try
4498 to ensure that this promise is met, so @code{Pure_Function} can be used
4499 with functions that are conceptually pure, even if they do modify
4500 global variables. For example, a square root function that is
4501 instrumented to count the number of times it is called is still
4502 conceptually pure, and can still be optimized, even though it
4503 modifies a global variable (the count). Memo functions are another
4504 example (where a table of previous calls is kept and consulted to
4505 avoid re-computation).
4507 Note also that the normal rules excluding optimization of subprograms
4508 in pure units (when parameter types are descended from System.Address,
4509 or when the full view of a parameter type is limited), do not apply
4510 for the Pure_Function case. If you explicitly specify Pure_Function,
4511 the compiler may optimize away calls with identical arguments, and
4512 if that results in unexpected behavior, the proper action is not to
4513 use the pragma for subprograms that are not (conceptually) pure.
4516 Note: Most functions in a @code{Pure} package are automatically pure, and
4517 there is no need to use pragma @code{Pure_Function} for such functions. One
4518 exception is any function that has at least one formal of type
4519 @code{System.Address} or a type derived from it. Such functions are not
4520 considered pure by default, since the compiler assumes that the
4521 @code{Address} parameter may be functioning as a pointer and that the
4522 referenced data may change even if the address value does not.
4523 Similarly, imported functions are not considered to be pure by default,
4524 since there is no way of checking that they are in fact pure. The use
4525 of pragma @code{Pure_Function} for such a function will override these default
4526 assumption, and cause the compiler to treat a designated subprogram as pure
4529 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4530 applies to the underlying renamed function. This can be used to
4531 disambiguate cases of overloading where some but not all functions
4532 in a set of overloaded functions are to be designated as pure.
4534 If pragma @code{Pure_Function} is applied to a library level function, the
4535 function is also considered pure from an optimization point of view, but the
4536 unit is not a Pure unit in the categorization sense. So for example, a function
4537 thus marked is free to @code{with} non-pure units.
4539 @node Pragma Remote_Access_Type
4540 @unnumberedsec Pragma Remote_Access_Type
4541 @findex Remote_Access_Type
4545 @smallexample @c ada
4546 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
4550 This pragma appears in the formal part of a generic declaration.
4551 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
4552 the use of a remote access to class-wide type as actual for a formal
4555 When this pragma applies to a formal access type @code{Entity}, that
4556 type is treated as a remote access to class-wide type in the generic.
4557 It must be a formal general access type, and its designated type must
4558 be the class-wide type of a formal tagged limited private type from the
4559 same generic declaration.
4561 In the generic unit, the formal type is subject to all restrictions
4562 pertaining to remote access to class-wide types. At instantiation, the
4563 actual type must be a remote access to class-wide type.
4565 @node Pragma Restriction_Warnings
4566 @unnumberedsec Pragma Restriction_Warnings
4567 @findex Restriction_Warnings
4571 @smallexample @c ada
4572 pragma Restriction_Warnings
4573 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4577 This pragma allows a series of restriction identifiers to be
4578 specified (the list of allowed identifiers is the same as for
4579 pragma @code{Restrictions}). For each of these identifiers
4580 the compiler checks for violations of the restriction, but
4581 generates a warning message rather than an error message
4582 if the restriction is violated.
4585 @unnumberedsec Pragma Shared
4589 This pragma is provided for compatibility with Ada 83. The syntax and
4590 semantics are identical to pragma Atomic.
4592 @node Pragma Short_Circuit_And_Or
4593 @unnumberedsec Pragma Short_Circuit_And_Or
4594 @findex Short_Circuit_And_Or
4597 This configuration pragma causes any occurrence of the AND operator applied to
4598 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4599 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4600 may be useful in the context of certification protocols requiring the use of
4601 short-circuited logical operators. If this configuration pragma occurs locally
4602 within the file being compiled, it applies only to the file being compiled.
4603 There is no requirement that all units in a partition use this option.
4605 @node Pragma Short_Descriptors
4606 @unnumberedsec Pragma Short_Descriptors
4607 @findex Short_Descriptors
4611 @smallexample @c ada
4612 pragma Short_Descriptors
4616 In VMS versions of the compiler, this configuration pragma causes all
4617 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4618 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4619 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4622 @node Pragma Simple_Storage_Pool_Type
4623 @unnumberedsec Pragma Simple_Storage_Pool_Type
4624 @findex Simple_Storage_Pool_Type
4625 @cindex Storage pool, simple
4626 @cindex Simple storage pool
4630 @smallexample @c ada
4631 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
4635 A type can be established as a ``simple storage pool type'' by applying
4636 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
4637 A type named in the pragma must be a library-level immutably limited record
4638 type or limited tagged type declared immediately within a package declaration.
4639 The type can also be a limited private type whose full type is allowed as
4640 a simple storage pool type.
4642 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
4643 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
4644 are subtype conformant with the following subprogram declarations:
4646 @smallexample @c ada
4649 Storage_Address : out System.Address;
4650 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4651 Alignment : System.Storage_Elements.Storage_Count);
4653 procedure Deallocate
4655 Storage_Address : System.Address;
4656 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4657 Alignment : System.Storage_Elements.Storage_Count);
4659 function Storage_Size (Pool : SSP)
4660 return System.Storage_Elements.Storage_Count;
4664 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
4665 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
4666 applying an unchecked deallocation has no effect other than to set its actual
4667 parameter to null. If @code{Storage_Size} is not declared, then the
4668 @code{Storage_Size} attribute applied to an access type associated with
4669 a pool object of type SSP returns zero. Additional operations can be declared
4670 for a simple storage pool type (such as for supporting a mark/release
4671 storage-management discipline).
4673 An object of a simple storage pool type can be associated with an access
4674 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
4676 @smallexample @c ada
4678 My_Pool : My_Simple_Storage_Pool_Type;
4680 type Acc is access My_Data_Type;
4682 for Acc'Simple_Storage_Pool use My_Pool;
4687 See attribute @code{Simple_Storage_Pool} for further details.
4689 @node Pragma Source_File_Name
4690 @unnumberedsec Pragma Source_File_Name
4691 @findex Source_File_Name
4695 @smallexample @c ada
4696 pragma Source_File_Name (
4697 [Unit_Name =>] unit_NAME,
4698 Spec_File_Name => STRING_LITERAL,
4699 [Index => INTEGER_LITERAL]);
4701 pragma Source_File_Name (
4702 [Unit_Name =>] unit_NAME,
4703 Body_File_Name => STRING_LITERAL,
4704 [Index => INTEGER_LITERAL]);
4708 Use this to override the normal naming convention. It is a configuration
4709 pragma, and so has the usual applicability of configuration pragmas
4710 (i.e.@: it applies to either an entire partition, or to all units in a
4711 compilation, or to a single unit, depending on how it is used.
4712 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4713 the second argument is required, and indicates whether this is the file
4714 name for the spec or for the body.
4716 The optional Index argument should be used when a file contains multiple
4717 units, and when you do not want to use @code{gnatchop} to separate then
4718 into multiple files (which is the recommended procedure to limit the
4719 number of recompilations that are needed when some sources change).
4720 For instance, if the source file @file{source.ada} contains
4722 @smallexample @c ada
4734 you could use the following configuration pragmas:
4736 @smallexample @c ada
4737 pragma Source_File_Name
4738 (B, Spec_File_Name => "source.ada", Index => 1);
4739 pragma Source_File_Name
4740 (A, Body_File_Name => "source.ada", Index => 2);
4743 Note that the @code{gnatname} utility can also be used to generate those
4744 configuration pragmas.
4746 Another form of the @code{Source_File_Name} pragma allows
4747 the specification of patterns defining alternative file naming schemes
4748 to apply to all files.
4750 @smallexample @c ada
4751 pragma Source_File_Name
4752 ( [Spec_File_Name =>] STRING_LITERAL
4753 [,[Casing =>] CASING_SPEC]
4754 [,[Dot_Replacement =>] STRING_LITERAL]);
4756 pragma Source_File_Name
4757 ( [Body_File_Name =>] STRING_LITERAL
4758 [,[Casing =>] CASING_SPEC]
4759 [,[Dot_Replacement =>] STRING_LITERAL]);
4761 pragma Source_File_Name
4762 ( [Subunit_File_Name =>] STRING_LITERAL
4763 [,[Casing =>] CASING_SPEC]
4764 [,[Dot_Replacement =>] STRING_LITERAL]);
4766 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4770 The first argument is a pattern that contains a single asterisk indicating
4771 the point at which the unit name is to be inserted in the pattern string
4772 to form the file name. The second argument is optional. If present it
4773 specifies the casing of the unit name in the resulting file name string.
4774 The default is lower case. Finally the third argument allows for systematic
4775 replacement of any dots in the unit name by the specified string literal.
4777 Note that Source_File_Name pragmas should not be used if you are using
4778 project files. The reason for this rule is that the project manager is not
4779 aware of these pragmas, and so other tools that use the projet file would not
4780 be aware of the intended naming conventions. If you are using project files,
4781 file naming is controlled by Source_File_Name_Project pragmas, which are
4782 usually supplied automatically by the project manager. A pragma
4783 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
4785 For more details on the use of the @code{Source_File_Name} pragma,
4786 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4787 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4790 @node Pragma Source_File_Name_Project
4791 @unnumberedsec Pragma Source_File_Name_Project
4792 @findex Source_File_Name_Project
4795 This pragma has the same syntax and semantics as pragma Source_File_Name.
4796 It is only allowed as a stand alone configuration pragma.
4797 It cannot appear after a @ref{Pragma Source_File_Name}, and
4798 most importantly, once pragma Source_File_Name_Project appears,
4799 no further Source_File_Name pragmas are allowed.
4801 The intention is that Source_File_Name_Project pragmas are always
4802 generated by the Project Manager in a manner consistent with the naming
4803 specified in a project file, and when naming is controlled in this manner,
4804 it is not permissible to attempt to modify this naming scheme using
4805 Source_File_Name or Source_File_Name_Project pragmas (which would not be
4806 known to the project manager).
4808 @node Pragma Source_Reference
4809 @unnumberedsec Pragma Source_Reference
4810 @findex Source_Reference
4814 @smallexample @c ada
4815 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4819 This pragma must appear as the first line of a source file.
4820 @var{integer_literal} is the logical line number of the line following
4821 the pragma line (for use in error messages and debugging
4822 information). @var{string_literal} is a static string constant that
4823 specifies the file name to be used in error messages and debugging
4824 information. This is most notably used for the output of @code{gnatchop}
4825 with the @option{-r} switch, to make sure that the original unchopped
4826 source file is the one referred to.
4828 The second argument must be a string literal, it cannot be a static
4829 string expression other than a string literal. This is because its value
4830 is needed for error messages issued by all phases of the compiler.
4832 @node Pragma Static_Elaboration_Desired
4833 @unnumberedsec Pragma Static_Elaboration_Desired
4834 @findex Static_Elaboration_Desired
4838 @smallexample @c ada
4839 pragma Static_Elaboration_Desired;
4843 This pragma is used to indicate that the compiler should attempt to initialize
4844 statically the objects declared in the library unit to which the pragma applies,
4845 when these objects are initialized (explicitly or implicitly) by an aggregate.
4846 In the absence of this pragma, aggregates in object declarations are expanded
4847 into assignments and loops, even when the aggregate components are static
4848 constants. When the aggregate is present the compiler builds a static expression
4849 that requires no run-time code, so that the initialized object can be placed in
4850 read-only data space. If the components are not static, or the aggregate has
4851 more that 100 components, the compiler emits a warning that the pragma cannot
4852 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
4853 construction of larger aggregates with static components that include an others
4856 @node Pragma Stream_Convert
4857 @unnumberedsec Pragma Stream_Convert
4858 @findex Stream_Convert
4862 @smallexample @c ada
4863 pragma Stream_Convert (
4864 [Entity =>] type_LOCAL_NAME,
4865 [Read =>] function_NAME,
4866 [Write =>] function_NAME);
4870 This pragma provides an efficient way of providing stream functions for
4871 types defined in packages. Not only is it simpler to use than declaring
4872 the necessary functions with attribute representation clauses, but more
4873 significantly, it allows the declaration to made in such a way that the
4874 stream packages are not loaded unless they are needed. The use of
4875 the Stream_Convert pragma adds no overhead at all, unless the stream
4876 attributes are actually used on the designated type.
4878 The first argument specifies the type for which stream functions are
4879 provided. The second parameter provides a function used to read values
4880 of this type. It must name a function whose argument type may be any
4881 subtype, and whose returned type must be the type given as the first
4882 argument to the pragma.
4884 The meaning of the @var{Read}
4885 parameter is that if a stream attribute directly
4886 or indirectly specifies reading of the type given as the first parameter,
4887 then a value of the type given as the argument to the Read function is
4888 read from the stream, and then the Read function is used to convert this
4889 to the required target type.
4891 Similarly the @var{Write} parameter specifies how to treat write attributes
4892 that directly or indirectly apply to the type given as the first parameter.
4893 It must have an input parameter of the type specified by the first parameter,
4894 and the return type must be the same as the input type of the Read function.
4895 The effect is to first call the Write function to convert to the given stream
4896 type, and then write the result type to the stream.
4898 The Read and Write functions must not be overloaded subprograms. If necessary
4899 renamings can be supplied to meet this requirement.
4900 The usage of this attribute is best illustrated by a simple example, taken
4901 from the GNAT implementation of package Ada.Strings.Unbounded:
4903 @smallexample @c ada
4904 function To_Unbounded (S : String)
4905 return Unbounded_String
4906 renames To_Unbounded_String;
4908 pragma Stream_Convert
4909 (Unbounded_String, To_Unbounded, To_String);
4913 The specifications of the referenced functions, as given in the Ada
4914 Reference Manual are:
4916 @smallexample @c ada
4917 function To_Unbounded_String (Source : String)
4918 return Unbounded_String;
4920 function To_String (Source : Unbounded_String)
4925 The effect is that if the value of an unbounded string is written to a stream,
4926 then the representation of the item in the stream is in the same format that
4927 would be used for @code{Standard.String'Output}, and this same representation
4928 is expected when a value of this type is read from the stream. Note that the
4929 value written always includes the bounds, even for Unbounded_String'Write,
4930 since Unbounded_String is not an array type.
4932 @node Pragma Style_Checks
4933 @unnumberedsec Pragma Style_Checks
4934 @findex Style_Checks
4938 @smallexample @c ada
4939 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4940 On | Off [, LOCAL_NAME]);
4944 This pragma is used in conjunction with compiler switches to control the
4945 built in style checking provided by GNAT@. The compiler switches, if set,
4946 provide an initial setting for the switches, and this pragma may be used
4947 to modify these settings, or the settings may be provided entirely by
4948 the use of the pragma. This pragma can be used anywhere that a pragma
4949 is legal, including use as a configuration pragma (including use in
4950 the @file{gnat.adc} file).
4952 The form with a string literal specifies which style options are to be
4953 activated. These are additive, so they apply in addition to any previously
4954 set style check options. The codes for the options are the same as those
4955 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4956 For example the following two methods can be used to enable
4961 @smallexample @c ada
4962 pragma Style_Checks ("l");
4967 gcc -c -gnatyl @dots{}
4972 The form ALL_CHECKS activates all standard checks (its use is equivalent
4973 to the use of the @code{gnaty} switch with no options. @xref{Top,
4974 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4975 @value{EDITION} User's Guide}, for details.)
4977 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4978 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4979 options (i.e. equivalent to -gnatyg).
4981 The forms with @code{Off} and @code{On}
4982 can be used to temporarily disable style checks
4983 as shown in the following example:
4985 @smallexample @c ada
4989 pragma Style_Checks ("k"); -- requires keywords in lower case
4990 pragma Style_Checks (Off); -- turn off style checks
4991 NULL; -- this will not generate an error message
4992 pragma Style_Checks (On); -- turn style checks back on
4993 NULL; -- this will generate an error message
4997 Finally the two argument form is allowed only if the first argument is
4998 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4999 for the specified entity, as shown in the following example:
5001 @smallexample @c ada
5005 pragma Style_Checks ("r"); -- require consistency of identifier casing
5007 Rf1 : Integer := ARG; -- incorrect, wrong case
5008 pragma Style_Checks (Off, Arg);
5009 Rf2 : Integer := ARG; -- OK, no error
5012 @node Pragma Subtitle
5013 @unnumberedsec Pragma Subtitle
5018 @smallexample @c ada
5019 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5023 This pragma is recognized for compatibility with other Ada compilers
5024 but is ignored by GNAT@.
5026 @node Pragma Suppress
5027 @unnumberedsec Pragma Suppress
5032 @smallexample @c ada
5033 pragma Suppress (Identifier [, [On =>] Name]);
5037 This is a standard pragma, and supports all the check names required in
5038 the RM. It is included here because GNAT recognizes one additional check
5039 name: @code{Alignment_Check} which can be used to suppress alignment checks
5040 on addresses used in address clauses. Such checks can also be suppressed
5041 by suppressing range checks, but the specific use of @code{Alignment_Check}
5042 allows suppression of alignment checks without suppressing other range checks.
5044 Note that pragma Suppress gives the compiler permission to omit
5045 checks, but does not require the compiler to omit checks. The compiler
5046 will generate checks if they are essentially free, even when they are
5047 suppressed. In particular, if the compiler can prove that a certain
5048 check will necessarily fail, it will generate code to do an
5049 unconditional ``raise'', even if checks are suppressed. The compiler
5052 Of course, run-time checks are omitted whenever the compiler can prove
5053 that they will not fail, whether or not checks are suppressed.
5055 @node Pragma Suppress_All
5056 @unnumberedsec Pragma Suppress_All
5057 @findex Suppress_All
5061 @smallexample @c ada
5062 pragma Suppress_All;
5066 This pragma can appear anywhere within a unit.
5067 The effect is to apply @code{Suppress (All_Checks)} to the unit
5068 in which it appears. This pragma is implemented for compatibility with DEC
5069 Ada 83 usage where it appears at the end of a unit, and for compatibility
5070 with Rational Ada, where it appears as a program unit pragma.
5071 The use of the standard Ada pragma @code{Suppress (All_Checks)}
5072 as a normal configuration pragma is the preferred usage in GNAT@.
5074 @node Pragma Suppress_Exception_Locations
5075 @unnumberedsec Pragma Suppress_Exception_Locations
5076 @findex Suppress_Exception_Locations
5080 @smallexample @c ada
5081 pragma Suppress_Exception_Locations;
5085 In normal mode, a raise statement for an exception by default generates
5086 an exception message giving the file name and line number for the location
5087 of the raise. This is useful for debugging and logging purposes, but this
5088 entails extra space for the strings for the messages. The configuration
5089 pragma @code{Suppress_Exception_Locations} can be used to suppress the
5090 generation of these strings, with the result that space is saved, but the
5091 exception message for such raises is null. This configuration pragma may
5092 appear in a global configuration pragma file, or in a specific unit as
5093 usual. It is not required that this pragma be used consistently within
5094 a partition, so it is fine to have some units within a partition compiled
5095 with this pragma and others compiled in normal mode without it.
5097 @node Pragma Suppress_Initialization
5098 @unnumberedsec Pragma Suppress_Initialization
5099 @findex Suppress_Initialization
5100 @cindex Suppressing initialization
5101 @cindex Initialization, suppression of
5105 @smallexample @c ada
5106 pragma Suppress_Initialization ([Entity =>] subtype_Name);
5110 Here subtype_Name is the name introduced by a type declaration
5111 or subtype declaration.
5112 This pragma suppresses any implicit or explicit initialization
5113 for all variables of the given type or subtype,
5114 including initialization resulting from the use of pragmas
5115 Normalize_Scalars or Initialize_Scalars.
5117 This is considered a representation item, so it cannot be given after
5118 the type is frozen. It applies to all subsequent object declarations,
5119 and also any allocator that creates objects of the type.
5121 If the pragma is given for the first subtype, then it is considered
5122 to apply to the base type and all its subtypes. If the pragma is given
5123 for other than a first subtype, then it applies only to the given subtype.
5124 The pragma may not be given after the type is frozen.
5126 @node Pragma Task_Info
5127 @unnumberedsec Pragma Task_Info
5132 @smallexample @c ada
5133 pragma Task_Info (EXPRESSION);
5137 This pragma appears within a task definition (like pragma
5138 @code{Priority}) and applies to the task in which it appears. The
5139 argument must be of type @code{System.Task_Info.Task_Info_Type}.
5140 The @code{Task_Info} pragma provides system dependent control over
5141 aspects of tasking implementation, for example, the ability to map
5142 tasks to specific processors. For details on the facilities available
5143 for the version of GNAT that you are using, see the documentation
5144 in the spec of package System.Task_Info in the runtime
5147 @node Pragma Task_Name
5148 @unnumberedsec Pragma Task_Name
5153 @smallexample @c ada
5154 pragma Task_Name (string_EXPRESSION);
5158 This pragma appears within a task definition (like pragma
5159 @code{Priority}) and applies to the task in which it appears. The
5160 argument must be of type String, and provides a name to be used for
5161 the task instance when the task is created. Note that this expression
5162 is not required to be static, and in particular, it can contain
5163 references to task discriminants. This facility can be used to
5164 provide different names for different tasks as they are created,
5165 as illustrated in the example below.
5167 The task name is recorded internally in the run-time structures
5168 and is accessible to tools like the debugger. In addition the
5169 routine @code{Ada.Task_Identification.Image} will return this
5170 string, with a unique task address appended.
5172 @smallexample @c ada
5173 -- Example of the use of pragma Task_Name
5175 with Ada.Task_Identification;
5176 use Ada.Task_Identification;
5177 with Text_IO; use Text_IO;
5180 type Astring is access String;
5182 task type Task_Typ (Name : access String) is
5183 pragma Task_Name (Name.all);
5186 task body Task_Typ is
5187 Nam : constant String := Image (Current_Task);
5189 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5192 type Ptr_Task is access Task_Typ;
5193 Task_Var : Ptr_Task;
5197 new Task_Typ (new String'("This is task 1"));
5199 new Task_Typ (new String'("This is task 2"));
5203 @node Pragma Task_Storage
5204 @unnumberedsec Pragma Task_Storage
5205 @findex Task_Storage
5208 @smallexample @c ada
5209 pragma Task_Storage (
5210 [Task_Type =>] LOCAL_NAME,
5211 [Top_Guard =>] static_integer_EXPRESSION);
5215 This pragma specifies the length of the guard area for tasks. The guard
5216 area is an additional storage area allocated to a task. A value of zero
5217 means that either no guard area is created or a minimal guard area is
5218 created, depending on the target. This pragma can appear anywhere a
5219 @code{Storage_Size} attribute definition clause is allowed for a task
5222 @node Pragma Test_Case
5223 @unnumberedsec Pragma Test_Case
5229 @smallexample @c ada
5231 [Name =>] static_string_Expression
5232 ,[Mode =>] (Nominal | Robustness)
5233 [, Requires => Boolean_Expression]
5234 [, Ensures => Boolean_Expression]);
5238 The @code{Test_Case} pragma allows defining fine-grain specifications
5239 for use by testing and verification tools. The compiler checks its
5240 validity but the presence of pragma @code{Test_Case} does not lead to
5241 any modification of the code generated by the compiler.
5243 @code{Test_Case} pragmas may only appear immediately following the
5244 (separate) declaration of a subprogram in a package declaration, inside
5245 a package spec unit. Only other pragmas may intervene (that is appear
5246 between the subprogram declaration and a test case).
5248 The compiler checks that boolean expressions given in @code{Requires} and
5249 @code{Ensures} are valid, where the rules for @code{Requires} are the
5250 same as the rule for an expression in @code{Precondition} and the rules
5251 for @code{Ensures} are the same as the rule for an expression in
5252 @code{Postcondition}. In particular, attributes @code{'Old} and
5253 @code{'Result} can only be used within the @code{Ensures}
5254 expression. The following is an example of use within a package spec:
5256 @smallexample @c ada
5257 package Math_Functions is
5259 function Sqrt (Arg : Float) return Float;
5260 pragma Test_Case (Name => "Test 1",
5262 Requires => Arg < 100,
5263 Ensures => Sqrt'Result < 10);
5269 The meaning of a test case is that, if the associated subprogram is
5270 executed in a context where @code{Requires} holds, then @code{Ensures}
5271 should hold when the subprogram returns. Mode @code{Nominal} indicates
5272 that the input context should satisfy the precondition of the
5273 subprogram, and the output context should then satisfy its
5274 postcondition. More @code{Robustness} indicates that the pre- and
5275 postcondition of the subprogram should be ignored for this test case.
5277 @node Pragma Thread_Local_Storage
5278 @unnumberedsec Pragma Thread_Local_Storage
5279 @findex Thread_Local_Storage
5280 @cindex Task specific storage
5281 @cindex TLS (Thread Local Storage)
5284 @smallexample @c ada
5285 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5289 This pragma specifies that the specified entity, which must be
5290 a variable declared in a library level package, is to be marked as
5291 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5292 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5293 (and hence each Ada task) to see a distinct copy of the variable.
5295 The variable may not have default initialization, and if there is
5296 an explicit initialization, it must be either @code{null} for an
5297 access variable, or a static expression for a scalar variable.
5298 This provides a low level mechanism similar to that provided by
5299 the @code{Ada.Task_Attributes} package, but much more efficient
5300 and is also useful in writing interface code that will interact
5301 with foreign threads.
5303 If this pragma is used on a system where @code{TLS} is not supported,
5304 then an error message will be generated and the program will be rejected.
5306 @node Pragma Time_Slice
5307 @unnumberedsec Pragma Time_Slice
5312 @smallexample @c ada
5313 pragma Time_Slice (static_duration_EXPRESSION);
5317 For implementations of GNAT on operating systems where it is possible
5318 to supply a time slice value, this pragma may be used for this purpose.
5319 It is ignored if it is used in a system that does not allow this control,
5320 or if it appears in other than the main program unit.
5322 Note that the effect of this pragma is identical to the effect of the
5323 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5326 @unnumberedsec Pragma Title
5331 @smallexample @c ada
5332 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5335 [Title =>] STRING_LITERAL,
5336 | [Subtitle =>] STRING_LITERAL
5340 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5341 pragma used in DEC Ada 83 implementations to provide a title and/or
5342 subtitle for the program listing. The program listing generated by GNAT
5343 does not have titles or subtitles.
5345 Unlike other pragmas, the full flexibility of named notation is allowed
5346 for this pragma, i.e.@: the parameters may be given in any order if named
5347 notation is used, and named and positional notation can be mixed
5348 following the normal rules for procedure calls in Ada.
5350 @node Pragma Unchecked_Union
5351 @unnumberedsec Pragma Unchecked_Union
5353 @findex Unchecked_Union
5357 @smallexample @c ada
5358 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5362 This pragma is used to specify a representation of a record type that is
5363 equivalent to a C union. It was introduced as a GNAT implementation defined
5364 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5365 pragma, making it language defined, and GNAT fully implements this extended
5366 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5367 details, consult the Ada 2005 Reference Manual, section B.3.3.
5369 @node Pragma Unimplemented_Unit
5370 @unnumberedsec Pragma Unimplemented_Unit
5371 @findex Unimplemented_Unit
5375 @smallexample @c ada
5376 pragma Unimplemented_Unit;
5380 If this pragma occurs in a unit that is processed by the compiler, GNAT
5381 aborts with the message @samp{@var{xxx} not implemented}, where
5382 @var{xxx} is the name of the current compilation unit. This pragma is
5383 intended to allow the compiler to handle unimplemented library units in
5386 The abort only happens if code is being generated. Thus you can use
5387 specs of unimplemented packages in syntax or semantic checking mode.
5389 @node Pragma Universal_Aliasing
5390 @unnumberedsec Pragma Universal_Aliasing
5391 @findex Universal_Aliasing
5395 @smallexample @c ada
5396 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5400 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5401 declarative part. The effect is to inhibit strict type-based aliasing
5402 optimization for the given type. In other words, the effect is as though
5403 access types designating this type were subject to pragma No_Strict_Aliasing.
5404 For a detailed description of the strict aliasing optimization, and the
5405 situations in which it must be suppressed, @xref{Optimization and Strict
5406 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5408 @node Pragma Universal_Data
5409 @unnumberedsec Pragma Universal_Data
5410 @findex Universal_Data
5414 @smallexample @c ada
5415 pragma Universal_Data [(library_unit_Name)];
5419 This pragma is supported only for the AAMP target and is ignored for
5420 other targets. The pragma specifies that all library-level objects
5421 (Counter 0 data) associated with the library unit are to be accessed
5422 and updated using universal addressing (24-bit addresses for AAMP5)
5423 rather than the default of 16-bit Data Environment (DENV) addressing.
5424 Use of this pragma will generally result in less efficient code for
5425 references to global data associated with the library unit, but
5426 allows such data to be located anywhere in memory. This pragma is
5427 a library unit pragma, but can also be used as a configuration pragma
5428 (including use in the @file{gnat.adc} file). The functionality
5429 of this pragma is also available by applying the -univ switch on the
5430 compilations of units where universal addressing of the data is desired.
5432 @node Pragma Unmodified
5433 @unnumberedsec Pragma Unmodified
5435 @cindex Warnings, unmodified
5439 @smallexample @c ada
5440 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5444 This pragma signals that the assignable entities (variables,
5445 @code{out} parameters, @code{in out} parameters) whose names are listed are
5446 deliberately not assigned in the current source unit. This
5447 suppresses warnings about the
5448 entities being referenced but not assigned, and in addition a warning will be
5449 generated if one of these entities is in fact assigned in the
5450 same unit as the pragma (or in the corresponding body, or one
5453 This is particularly useful for clearly signaling that a particular
5454 parameter is not modified, even though the spec suggests that it might
5457 @node Pragma Unreferenced
5458 @unnumberedsec Pragma Unreferenced
5459 @findex Unreferenced
5460 @cindex Warnings, unreferenced
5464 @smallexample @c ada
5465 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5466 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5470 This pragma signals that the entities whose names are listed are
5471 deliberately not referenced in the current source unit. This
5472 suppresses warnings about the
5473 entities being unreferenced, and in addition a warning will be
5474 generated if one of these entities is in fact subsequently referenced in the
5475 same unit as the pragma (or in the corresponding body, or one
5478 This is particularly useful for clearly signaling that a particular
5479 parameter is not referenced in some particular subprogram implementation
5480 and that this is deliberate. It can also be useful in the case of
5481 objects declared only for their initialization or finalization side
5484 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5485 current scope, then the entity most recently declared is the one to which
5486 the pragma applies. Note that in the case of accept formals, the pragma
5487 Unreferenced may appear immediately after the keyword @code{do} which
5488 allows the indication of whether or not accept formals are referenced
5489 or not to be given individually for each accept statement.
5491 The left hand side of an assignment does not count as a reference for the
5492 purpose of this pragma. Thus it is fine to assign to an entity for which
5493 pragma Unreferenced is given.
5495 Note that if a warning is desired for all calls to a given subprogram,
5496 regardless of whether they occur in the same unit as the subprogram
5497 declaration, then this pragma should not be used (calls from another
5498 unit would not be flagged); pragma Obsolescent can be used instead
5499 for this purpose, see @xref{Pragma Obsolescent}.
5501 The second form of pragma @code{Unreferenced} is used within a context
5502 clause. In this case the arguments must be unit names of units previously
5503 mentioned in @code{with} clauses (similar to the usage of pragma
5504 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5505 units and unreferenced entities within these units.
5507 @node Pragma Unreferenced_Objects
5508 @unnumberedsec Pragma Unreferenced_Objects
5509 @findex Unreferenced_Objects
5510 @cindex Warnings, unreferenced
5514 @smallexample @c ada
5515 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5519 This pragma signals that for the types or subtypes whose names are
5520 listed, objects which are declared with one of these types or subtypes may
5521 not be referenced, and if no references appear, no warnings are given.
5523 This is particularly useful for objects which are declared solely for their
5524 initialization and finalization effect. Such variables are sometimes referred
5525 to as RAII variables (Resource Acquisition Is Initialization). Using this
5526 pragma on the relevant type (most typically a limited controlled type), the
5527 compiler will automatically suppress unwanted warnings about these variables
5528 not being referenced.
5530 @node Pragma Unreserve_All_Interrupts
5531 @unnumberedsec Pragma Unreserve_All_Interrupts
5532 @findex Unreserve_All_Interrupts
5536 @smallexample @c ada
5537 pragma Unreserve_All_Interrupts;
5541 Normally certain interrupts are reserved to the implementation. Any attempt
5542 to attach an interrupt causes Program_Error to be raised, as described in
5543 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5544 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5545 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5546 interrupt execution.
5548 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5549 a program, then all such interrupts are unreserved. This allows the
5550 program to handle these interrupts, but disables their standard
5551 functions. For example, if this pragma is used, then pressing
5552 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5553 a program can then handle the @code{SIGINT} interrupt as it chooses.
5555 For a full list of the interrupts handled in a specific implementation,
5556 see the source code for the spec of @code{Ada.Interrupts.Names} in
5557 file @file{a-intnam.ads}. This is a target dependent file that contains the
5558 list of interrupts recognized for a given target. The documentation in
5559 this file also specifies what interrupts are affected by the use of
5560 the @code{Unreserve_All_Interrupts} pragma.
5562 For a more general facility for controlling what interrupts can be
5563 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5564 of the @code{Unreserve_All_Interrupts} pragma.
5566 @node Pragma Unsuppress
5567 @unnumberedsec Pragma Unsuppress
5572 @smallexample @c ada
5573 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5577 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5578 there is no corresponding pragma @code{Suppress} in effect, it has no
5579 effect. The range of the effect is the same as for pragma
5580 @code{Suppress}. The meaning of the arguments is identical to that used
5581 in pragma @code{Suppress}.
5583 One important application is to ensure that checks are on in cases where
5584 code depends on the checks for its correct functioning, so that the code
5585 will compile correctly even if the compiler switches are set to suppress
5588 @node Pragma Use_VADS_Size
5589 @unnumberedsec Pragma Use_VADS_Size
5590 @cindex @code{Size}, VADS compatibility
5591 @findex Use_VADS_Size
5595 @smallexample @c ada
5596 pragma Use_VADS_Size;
5600 This is a configuration pragma. In a unit to which it applies, any use
5601 of the 'Size attribute is automatically interpreted as a use of the
5602 'VADS_Size attribute. Note that this may result in incorrect semantic
5603 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5604 the handling of existing code which depends on the interpretation of Size
5605 as implemented in the VADS compiler. See description of the VADS_Size
5606 attribute for further details.
5608 @node Pragma Validity_Checks
5609 @unnumberedsec Pragma Validity_Checks
5610 @findex Validity_Checks
5614 @smallexample @c ada
5615 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5619 This pragma is used in conjunction with compiler switches to control the
5620 built-in validity checking provided by GNAT@. The compiler switches, if set
5621 provide an initial setting for the switches, and this pragma may be used
5622 to modify these settings, or the settings may be provided entirely by
5623 the use of the pragma. This pragma can be used anywhere that a pragma
5624 is legal, including use as a configuration pragma (including use in
5625 the @file{gnat.adc} file).
5627 The form with a string literal specifies which validity options are to be
5628 activated. The validity checks are first set to include only the default
5629 reference manual settings, and then a string of letters in the string
5630 specifies the exact set of options required. The form of this string
5631 is exactly as described for the @option{-gnatVx} compiler switch (see the
5632 GNAT users guide for details). For example the following two methods
5633 can be used to enable validity checking for mode @code{in} and
5634 @code{in out} subprogram parameters:
5638 @smallexample @c ada
5639 pragma Validity_Checks ("im");
5644 gcc -c -gnatVim @dots{}
5649 The form ALL_CHECKS activates all standard checks (its use is equivalent
5650 to the use of the @code{gnatva} switch.
5652 The forms with @code{Off} and @code{On}
5653 can be used to temporarily disable validity checks
5654 as shown in the following example:
5656 @smallexample @c ada
5660 pragma Validity_Checks ("c"); -- validity checks for copies
5661 pragma Validity_Checks (Off); -- turn off validity checks
5662 A := B; -- B will not be validity checked
5663 pragma Validity_Checks (On); -- turn validity checks back on
5664 A := C; -- C will be validity checked
5667 @node Pragma Volatile
5668 @unnumberedsec Pragma Volatile
5673 @smallexample @c ada
5674 pragma Volatile (LOCAL_NAME);
5678 This pragma is defined by the Ada Reference Manual, and the GNAT
5679 implementation is fully conformant with this definition. The reason it
5680 is mentioned in this section is that a pragma of the same name was supplied
5681 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5682 implementation of pragma Volatile is upwards compatible with the
5683 implementation in DEC Ada 83.
5685 @node Pragma Warnings
5686 @unnumberedsec Pragma Warnings
5691 @smallexample @c ada
5692 pragma Warnings (On | Off);
5693 pragma Warnings (On | Off, LOCAL_NAME);
5694 pragma Warnings (static_string_EXPRESSION);
5695 pragma Warnings (On | Off, static_string_EXPRESSION);
5699 Normally warnings are enabled, with the output being controlled by
5700 the command line switch. Warnings (@code{Off}) turns off generation of
5701 warnings until a Warnings (@code{On}) is encountered or the end of the
5702 current unit. If generation of warnings is turned off using this
5703 pragma, then no warning messages are output, regardless of the
5704 setting of the command line switches.
5706 The form with a single argument may be used as a configuration pragma.
5708 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5709 the specified entity. This suppression is effective from the point where
5710 it occurs till the end of the extended scope of the variable (similar to
5711 the scope of @code{Suppress}).
5713 The form with a single static_string_EXPRESSION argument provides more precise
5714 control over which warnings are active. The string is a list of letters
5715 specifying which warnings are to be activated and which deactivated. The
5716 code for these letters is the same as the string used in the command
5717 line switch controlling warnings. For a brief summary, use the gnatmake
5718 command with no arguments, which will generate usage information containing
5719 the list of warnings switches supported. For
5720 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5724 The specified warnings will be in effect until the end of the program
5725 or another pragma Warnings is encountered. The effect of the pragma is
5726 cumulative. Initially the set of warnings is the standard default set
5727 as possibly modified by compiler switches. Then each pragma Warning
5728 modifies this set of warnings as specified. This form of the pragma may
5729 also be used as a configuration pragma.
5731 The fourth form, with an @code{On|Off} parameter and a string, is used to
5732 control individual messages, based on their text. The string argument
5733 is a pattern that is used to match against the text of individual
5734 warning messages (not including the initial "warning: " tag).
5736 The pattern may contain asterisks, which match zero or more characters in
5737 the message. For example, you can use
5738 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5739 message @code{warning: 960 bits of "a" unused}. No other regular
5740 expression notations are permitted. All characters other than asterisk in
5741 these three specific cases are treated as literal characters in the match.
5743 There are two ways to use the pragma in this form. The OFF form can be used as a
5744 configuration pragma. The effect is to suppress all warnings (if any)
5745 that match the pattern string throughout the compilation.
5747 The second usage is to suppress a warning locally, and in this case, two
5748 pragmas must appear in sequence:
5750 @smallexample @c ada
5751 pragma Warnings (Off, Pattern);
5752 @dots{} code where given warning is to be suppressed
5753 pragma Warnings (On, Pattern);
5757 In this usage, the pattern string must match in the Off and On pragmas,
5758 and at least one matching warning must be suppressed.
5760 Note: to write a string that will match any warning, use the string
5761 @code{"***"}. It will not work to use a single asterisk or two asterisks
5762 since this looks like an operator name. This form with three asterisks
5763 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
5764 matching @code{pragma Warnings (On, "***")} will be required. This can be
5765 helpful in avoiding forgetting to turn warnings back on.
5767 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5768 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5769 be useful in checking whether obsolete pragmas in existing programs are hiding
5772 Note: pragma Warnings does not affect the processing of style messages. See
5773 separate entry for pragma Style_Checks for control of style messages.
5775 @node Pragma Weak_External
5776 @unnumberedsec Pragma Weak_External
5777 @findex Weak_External
5781 @smallexample @c ada
5782 pragma Weak_External ([Entity =>] LOCAL_NAME);
5786 @var{LOCAL_NAME} must refer to an object that is declared at the library
5787 level. This pragma specifies that the given entity should be marked as a
5788 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5789 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5790 of a regular symbol, that is to say a symbol that does not have to be
5791 resolved by the linker if used in conjunction with a pragma Import.
5793 When a weak symbol is not resolved by the linker, its address is set to
5794 zero. This is useful in writing interfaces to external modules that may
5795 or may not be linked in the final executable, for example depending on
5796 configuration settings.
5798 If a program references at run time an entity to which this pragma has been
5799 applied, and the corresponding symbol was not resolved at link time, then
5800 the execution of the program is erroneous. It is not erroneous to take the
5801 Address of such an entity, for example to guard potential references,
5802 as shown in the example below.
5804 Some file formats do not support weak symbols so not all target machines
5805 support this pragma.
5807 @smallexample @c ada
5808 -- Example of the use of pragma Weak_External
5810 package External_Module is
5812 pragma Import (C, key);
5813 pragma Weak_External (key);
5814 function Present return boolean;
5815 end External_Module;
5817 with System; use System;
5818 package body External_Module is
5819 function Present return boolean is
5821 return key'Address /= System.Null_Address;
5823 end External_Module;
5826 @node Pragma Wide_Character_Encoding
5827 @unnumberedsec Pragma Wide_Character_Encoding
5828 @findex Wide_Character_Encoding
5832 @smallexample @c ada
5833 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5837 This pragma specifies the wide character encoding to be used in program
5838 source text appearing subsequently. It is a configuration pragma, but may
5839 also be used at any point that a pragma is allowed, and it is permissible
5840 to have more than one such pragma in a file, allowing multiple encodings
5841 to appear within the same file.
5843 The argument can be an identifier or a character literal. In the identifier
5844 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5845 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5846 case it is correspondingly one of the characters @samp{h}, @samp{u},
5847 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5849 Note that when the pragma is used within a file, it affects only the
5850 encoding within that file, and does not affect withed units, specs,
5853 @node Implementation Defined Attributes
5854 @chapter Implementation Defined Attributes
5855 Ada defines (throughout the Ada reference manual,
5856 summarized in Annex K),
5857 a set of attributes that provide useful additional functionality in all
5858 areas of the language. These language defined attributes are implemented
5859 in GNAT and work as described in the Ada Reference Manual.
5861 In addition, Ada allows implementations to define additional
5862 attributes whose meaning is defined by the implementation. GNAT provides
5863 a number of these implementation-dependent attributes which can be used
5864 to extend and enhance the functionality of the compiler. This section of
5865 the GNAT reference manual describes these additional attributes.
5867 Note that any program using these attributes may not be portable to
5868 other compilers (although GNAT implements this set of attributes on all
5869 platforms). Therefore if portability to other compilers is an important
5870 consideration, you should minimize the use of these attributes.
5880 * Compiler_Version::
5882 * Default_Bit_Order::
5894 * Has_Access_Values::
5895 * Has_Discriminants::
5902 * Max_Interrupt_Priority::
5904 * Maximum_Alignment::
5909 * Passed_By_Reference::
5916 * Simple_Storage_Pool::
5920 * System_Allocator_Alignment::
5926 * Unconstrained_Array::
5927 * Universal_Literal_String::
5928 * Unrestricted_Access::
5936 @unnumberedsec Abort_Signal
5937 @findex Abort_Signal
5939 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5940 prefix) provides the entity for the special exception used to signal
5941 task abort or asynchronous transfer of control. Normally this attribute
5942 should only be used in the tasking runtime (it is highly peculiar, and
5943 completely outside the normal semantics of Ada, for a user program to
5944 intercept the abort exception).
5947 @unnumberedsec Address_Size
5948 @cindex Size of @code{Address}
5949 @findex Address_Size
5951 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5952 prefix) is a static constant giving the number of bits in an
5953 @code{Address}. It is the same value as System.Address'Size,
5954 but has the advantage of being static, while a direct
5955 reference to System.Address'Size is non-static because Address
5959 @unnumberedsec Asm_Input
5962 The @code{Asm_Input} attribute denotes a function that takes two
5963 parameters. The first is a string, the second is an expression of the
5964 type designated by the prefix. The first (string) argument is required
5965 to be a static expression, and is the constraint for the parameter,
5966 (e.g.@: what kind of register is required). The second argument is the
5967 value to be used as the input argument. The possible values for the
5968 constant are the same as those used in the RTL, and are dependent on
5969 the configuration file used to built the GCC back end.
5970 @ref{Machine Code Insertions}
5973 @unnumberedsec Asm_Output
5976 The @code{Asm_Output} attribute denotes a function that takes two
5977 parameters. The first is a string, the second is the name of a variable
5978 of the type designated by the attribute prefix. The first (string)
5979 argument is required to be a static expression and designates the
5980 constraint for the parameter (e.g.@: what kind of register is
5981 required). The second argument is the variable to be updated with the
5982 result. The possible values for constraint are the same as those used in
5983 the RTL, and are dependent on the configuration file used to build the
5984 GCC back end. If there are no output operands, then this argument may
5985 either be omitted, or explicitly given as @code{No_Output_Operands}.
5986 @ref{Machine Code Insertions}
5989 @unnumberedsec AST_Entry
5993 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5994 the name of an entry, it yields a value of the predefined type AST_Handler
5995 (declared in the predefined package System, as extended by the use of
5996 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5997 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5998 Language Reference Manual}, section 9.12a.
6003 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
6004 offset within the storage unit (byte) that contains the first bit of
6005 storage allocated for the object. The value of this attribute is of the
6006 type @code{Universal_Integer}, and is always a non-negative number not
6007 exceeding the value of @code{System.Storage_Unit}.
6009 For an object that is a variable or a constant allocated in a register,
6010 the value is zero. (The use of this attribute does not force the
6011 allocation of a variable to memory).
6013 For an object that is a formal parameter, this attribute applies
6014 to either the matching actual parameter or to a copy of the
6015 matching actual parameter.
6017 For an access object the value is zero. Note that
6018 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
6019 designated object. Similarly for a record component
6020 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
6021 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
6022 are subject to index checks.
6024 This attribute is designed to be compatible with the DEC Ada 83 definition
6025 and implementation of the @code{Bit} attribute.
6028 @unnumberedsec Bit_Position
6029 @findex Bit_Position
6031 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
6032 of the fields of the record type, yields the bit
6033 offset within the record contains the first bit of
6034 storage allocated for the object. The value of this attribute is of the
6035 type @code{Universal_Integer}. The value depends only on the field
6036 @var{C} and is independent of the alignment of
6037 the containing record @var{R}.
6039 @node Compiler_Version
6040 @unnumberedsec Compiler_Version
6041 @findex Compiler_Version
6043 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
6044 prefix) yields a static string identifying the version of the compiler
6045 being used to compile the unit containing the attribute reference. A
6046 typical result would be something like "@value{EDITION} @i{version} (20090221)".
6049 @unnumberedsec Code_Address
6050 @findex Code_Address
6051 @cindex Subprogram address
6052 @cindex Address of subprogram code
6055 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
6056 intended effect seems to be to provide
6057 an address value which can be used to call the subprogram by means of
6058 an address clause as in the following example:
6060 @smallexample @c ada
6061 procedure K is @dots{}
6064 for L'Address use K'Address;
6065 pragma Import (Ada, L);
6069 A call to @code{L} is then expected to result in a call to @code{K}@.
6070 In Ada 83, where there were no access-to-subprogram values, this was
6071 a common work-around for getting the effect of an indirect call.
6072 GNAT implements the above use of @code{Address} and the technique
6073 illustrated by the example code works correctly.
6075 However, for some purposes, it is useful to have the address of the start
6076 of the generated code for the subprogram. On some architectures, this is
6077 not necessarily the same as the @code{Address} value described above.
6078 For example, the @code{Address} value may reference a subprogram
6079 descriptor rather than the subprogram itself.
6081 The @code{'Code_Address} attribute, which can only be applied to
6082 subprogram entities, always returns the address of the start of the
6083 generated code of the specified subprogram, which may or may not be
6084 the same value as is returned by the corresponding @code{'Address}
6087 @node Default_Bit_Order
6088 @unnumberedsec Default_Bit_Order
6090 @cindex Little endian
6091 @findex Default_Bit_Order
6093 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
6094 permissible prefix), provides the value @code{System.Default_Bit_Order}
6095 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
6096 @code{Low_Order_First}). This is used to construct the definition of
6097 @code{Default_Bit_Order} in package @code{System}.
6099 @node Descriptor_Size
6100 @unnumberedsec Descriptor_Size
6103 @findex Descriptor_Size
6105 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
6106 descriptor allocated for a type. The result is non-zero only for unconstrained
6107 array types and the returned value is of type universal integer. In GNAT, an
6108 array descriptor contains bounds information and is located immediately before
6109 the first element of the array.
6111 @smallexample @c ada
6112 type Unconstr_Array is array (Positive range <>) of Boolean;
6113 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
6117 The attribute takes into account any additional padding due to type alignment.
6118 In the example above, the descriptor contains two values of type
6119 @code{Positive} representing the low and high bound. Since @code{Positive} has
6120 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
6121 Positive'Size + 2} or 64 bits.
6124 @unnumberedsec Elaborated
6127 The prefix of the @code{'Elaborated} attribute must be a unit name. The
6128 value is a Boolean which indicates whether or not the given unit has been
6129 elaborated. This attribute is primarily intended for internal use by the
6130 generated code for dynamic elaboration checking, but it can also be used
6131 in user programs. The value will always be True once elaboration of all
6132 units has been completed. An exception is for units which need no
6133 elaboration, the value is always False for such units.
6136 @unnumberedsec Elab_Body
6139 This attribute can only be applied to a program unit name. It returns
6140 the entity for the corresponding elaboration procedure for elaborating
6141 the body of the referenced unit. This is used in the main generated
6142 elaboration procedure by the binder and is not normally used in any
6143 other context. However, there may be specialized situations in which it
6144 is useful to be able to call this elaboration procedure from Ada code,
6145 e.g.@: if it is necessary to do selective re-elaboration to fix some
6149 @unnumberedsec Elab_Spec
6152 This attribute can only be applied to a program unit name. It returns
6153 the entity for the corresponding elaboration procedure for elaborating
6154 the spec of the referenced unit. This is used in the main
6155 generated elaboration procedure by the binder and is not normally used
6156 in any other context. However, there may be specialized situations in
6157 which it is useful to be able to call this elaboration procedure from
6158 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6161 @node Elab_Subp_Body
6162 @unnumberedsec Elab_Subp_Body
6163 @findex Elab_Subp_Body
6165 This attribute can only be applied to a library level subprogram
6166 name and is only allowed in CodePeer mode. It returns the entity
6167 for the corresponding elaboration procedure for elaborating the body
6168 of the referenced subprogram unit. This is used in the main generated
6169 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6174 @cindex Ada 83 attributes
6177 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6178 the Ada 83 reference manual for an exact description of the semantics of
6182 @unnumberedsec Enabled
6185 The @code{Enabled} attribute allows an application program to check at compile
6186 time to see if the designated check is currently enabled. The prefix is a
6187 simple identifier, referencing any predefined check name (other than
6188 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6189 no argument is given for the attribute, the check is for the general state
6190 of the check, if an argument is given, then it is an entity name, and the
6191 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6192 given naming the entity (if not, then the argument is ignored).
6194 Note that instantiations inherit the check status at the point of the
6195 instantiation, so a useful idiom is to have a library package that
6196 introduces a check name with @code{pragma Check_Name}, and then contains
6197 generic packages or subprograms which use the @code{Enabled} attribute
6198 to see if the check is enabled. A user of this package can then issue
6199 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6200 the package or subprogram, controlling whether the check will be present.
6203 @unnumberedsec Enum_Rep
6204 @cindex Representation of enums
6207 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6208 function with the following spec:
6210 @smallexample @c ada
6211 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6212 return @i{Universal_Integer};
6216 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6217 enumeration type or to a non-overloaded enumeration
6218 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6219 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6220 enumeration literal or object.
6222 The function returns the representation value for the given enumeration
6223 value. This will be equal to value of the @code{Pos} attribute in the
6224 absence of an enumeration representation clause. This is a static
6225 attribute (i.e.@: the result is static if the argument is static).
6227 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6228 in which case it simply returns the integer value. The reason for this
6229 is to allow it to be used for @code{(<>)} discrete formal arguments in
6230 a generic unit that can be instantiated with either enumeration types
6231 or integer types. Note that if @code{Enum_Rep} is used on a modular
6232 type whose upper bound exceeds the upper bound of the largest signed
6233 integer type, and the argument is a variable, so that the universal
6234 integer calculation is done at run time, then the call to @code{Enum_Rep}
6235 may raise @code{Constraint_Error}.
6238 @unnumberedsec Enum_Val
6239 @cindex Representation of enums
6242 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6243 function with the following spec:
6245 @smallexample @c ada
6246 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6247 return @var{S}'Base};
6251 The function returns the enumeration value whose representation matches the
6252 argument, or raises Constraint_Error if no enumeration literal of the type
6253 has the matching value.
6254 This will be equal to value of the @code{Val} attribute in the
6255 absence of an enumeration representation clause. This is a static
6256 attribute (i.e.@: the result is static if the argument is static).
6259 @unnumberedsec Epsilon
6260 @cindex Ada 83 attributes
6263 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6264 the Ada 83 reference manual for an exact description of the semantics of
6268 @unnumberedsec Fixed_Value
6271 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6272 function with the following specification:
6274 @smallexample @c ada
6275 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6280 The value returned is the fixed-point value @var{V} such that
6282 @smallexample @c ada
6283 @var{V} = Arg * @var{S}'Small
6287 The effect is thus similar to first converting the argument to the
6288 integer type used to represent @var{S}, and then doing an unchecked
6289 conversion to the fixed-point type. The difference is
6290 that there are full range checks, to ensure that the result is in range.
6291 This attribute is primarily intended for use in implementation of the
6292 input-output functions for fixed-point values.
6294 @node Has_Access_Values
6295 @unnumberedsec Has_Access_Values
6296 @cindex Access values, testing for
6297 @findex Has_Access_Values
6299 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6300 is a Boolean value which is True if the is an access type, or is a composite
6301 type with a component (at any nesting depth) that is an access type, and is
6303 The intended use of this attribute is in conjunction with generic
6304 definitions. If the attribute is applied to a generic private type, it
6305 indicates whether or not the corresponding actual type has access values.
6307 @node Has_Discriminants
6308 @unnumberedsec Has_Discriminants
6309 @cindex Discriminants, testing for
6310 @findex Has_Discriminants
6312 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6313 is a Boolean value which is True if the type has discriminants, and False
6314 otherwise. The intended use of this attribute is in conjunction with generic
6315 definitions. If the attribute is applied to a generic private type, it
6316 indicates whether or not the corresponding actual type has discriminants.
6322 The @code{Img} attribute differs from @code{Image} in that it may be
6323 applied to objects as well as types, in which case it gives the
6324 @code{Image} for the subtype of the object. This is convenient for
6327 @smallexample @c ada
6328 Put_Line ("X = " & X'Img);
6332 has the same meaning as the more verbose:
6334 @smallexample @c ada
6335 Put_Line ("X = " & @var{T}'Image (X));
6339 where @var{T} is the (sub)type of the object @code{X}.
6342 @unnumberedsec Integer_Value
6343 @findex Integer_Value
6345 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6346 function with the following spec:
6348 @smallexample @c ada
6349 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6354 The value returned is the integer value @var{V}, such that
6356 @smallexample @c ada
6357 Arg = @var{V} * @var{T}'Small
6361 where @var{T} is the type of @code{Arg}.
6362 The effect is thus similar to first doing an unchecked conversion from
6363 the fixed-point type to its corresponding implementation type, and then
6364 converting the result to the target integer type. The difference is
6365 that there are full range checks, to ensure that the result is in range.
6366 This attribute is primarily intended for use in implementation of the
6367 standard input-output functions for fixed-point values.
6370 @unnumberedsec Invalid_Value
6371 @findex Invalid_Value
6373 For every scalar type S, S'Invalid_Value returns an undefined value of the
6374 type. If possible this value is an invalid representation for the type. The
6375 value returned is identical to the value used to initialize an otherwise
6376 uninitialized value of the type if pragma Initialize_Scalars is used,
6377 including the ability to modify the value with the binder -Sxx flag and
6378 relevant environment variables at run time.
6381 @unnumberedsec Large
6382 @cindex Ada 83 attributes
6385 The @code{Large} attribute is provided for compatibility with Ada 83. See
6386 the Ada 83 reference manual for an exact description of the semantics of
6390 @unnumberedsec Machine_Size
6391 @findex Machine_Size
6393 This attribute is identical to the @code{Object_Size} attribute. It is
6394 provided for compatibility with the DEC Ada 83 attribute of this name.
6397 @unnumberedsec Mantissa
6398 @cindex Ada 83 attributes
6401 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6402 the Ada 83 reference manual for an exact description of the semantics of
6405 @node Max_Interrupt_Priority
6406 @unnumberedsec Max_Interrupt_Priority
6407 @cindex Interrupt priority, maximum
6408 @findex Max_Interrupt_Priority
6410 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6411 permissible prefix), provides the same value as
6412 @code{System.Max_Interrupt_Priority}.
6415 @unnumberedsec Max_Priority
6416 @cindex Priority, maximum
6417 @findex Max_Priority
6419 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6420 prefix) provides the same value as @code{System.Max_Priority}.
6422 @node Maximum_Alignment
6423 @unnumberedsec Maximum_Alignment
6424 @cindex Alignment, maximum
6425 @findex Maximum_Alignment
6427 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6428 permissible prefix) provides the maximum useful alignment value for the
6429 target. This is a static value that can be used to specify the alignment
6430 for an object, guaranteeing that it is properly aligned in all
6433 @node Mechanism_Code
6434 @unnumberedsec Mechanism_Code
6435 @cindex Return values, passing mechanism
6436 @cindex Parameters, passing mechanism
6437 @findex Mechanism_Code
6439 @code{@var{function}'Mechanism_Code} yields an integer code for the
6440 mechanism used for the result of function, and
6441 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6442 used for formal parameter number @var{n} (a static integer value with 1
6443 meaning the first parameter) of @var{subprogram}. The code returned is:
6451 by descriptor (default descriptor class)
6453 by descriptor (UBS: unaligned bit string)
6455 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6457 by descriptor (UBA: unaligned bit array)
6459 by descriptor (S: string, also scalar access type parameter)
6461 by descriptor (SB: string with arbitrary bounds)
6463 by descriptor (A: contiguous array)
6465 by descriptor (NCA: non-contiguous array)
6469 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6472 @node Null_Parameter
6473 @unnumberedsec Null_Parameter
6474 @cindex Zero address, passing
6475 @findex Null_Parameter
6477 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6478 type or subtype @var{T} allocated at machine address zero. The attribute
6479 is allowed only as the default expression of a formal parameter, or as
6480 an actual expression of a subprogram call. In either case, the
6481 subprogram must be imported.
6483 The identity of the object is represented by the address zero in the
6484 argument list, independent of the passing mechanism (explicit or
6487 This capability is needed to specify that a zero address should be
6488 passed for a record or other composite object passed by reference.
6489 There is no way of indicating this without the @code{Null_Parameter}
6493 @unnumberedsec Object_Size
6494 @cindex Size, used for objects
6497 The size of an object is not necessarily the same as the size of the type
6498 of an object. This is because by default object sizes are increased to be
6499 a multiple of the alignment of the object. For example,
6500 @code{Natural'Size} is
6501 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6502 Similarly, a record containing an integer and a character:
6504 @smallexample @c ada
6512 will have a size of 40 (that is @code{Rec'Size} will be 40). The
6513 alignment will be 4, because of the
6514 integer field, and so the default size of record objects for this type
6515 will be 64 (8 bytes).
6519 @cindex Capturing Old values
6520 @cindex Postconditions
6522 The attribute Prefix'Old can be used within a
6523 subprogram body or within a precondition or
6524 postcondition pragma. The effect is to
6525 refer to the value of the prefix on entry. So for
6526 example if you have an argument of a record type X called Arg1,
6527 you can refer to Arg1.Field'Old which yields the value of
6528 Arg1.Field on entry. The implementation simply involves generating
6529 an object declaration which captures the value on entry.
6530 The prefix must denote an object of a nonlimited type (since limited types
6531 cannot be copied to capture their values) and it must not reference a local
6532 variable (since local variables do not exist at subprogram entry time). Note
6533 that the variable introduced by a quantified expression is a local variable.
6534 The following example shows the use of 'Old to implement
6535 a test of a postcondition:
6537 @smallexample @c ada
6548 package body Old_Pkg is
6549 Count : Natural := 0;
6553 ... code manipulating the value of Count
6555 pragma Assert (Count = Count'Old + 1);
6561 Note that it is allowed to apply 'Old to a constant entity, but this will
6562 result in a warning, since the old and new values will always be the same.
6564 @node Passed_By_Reference
6565 @unnumberedsec Passed_By_Reference
6566 @cindex Parameters, when passed by reference
6567 @findex Passed_By_Reference
6569 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6570 a value of type @code{Boolean} value that is @code{True} if the type is
6571 normally passed by reference and @code{False} if the type is normally
6572 passed by copy in calls. For scalar types, the result is always @code{False}
6573 and is static. For non-scalar types, the result is non-static.
6576 @unnumberedsec Pool_Address
6577 @cindex Parameters, when passed by reference
6578 @findex Pool_Address
6580 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6581 of X within its storage pool. This is the same as
6582 @code{@var{X}'Address}, except that for an unconstrained array whose
6583 bounds are allocated just before the first component,
6584 @code{@var{X}'Pool_Address} returns the address of those bounds,
6585 whereas @code{@var{X}'Address} returns the address of the first
6588 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6589 the object is allocated'', which could be a user-defined storage pool,
6590 the global heap, on the stack, or in a static memory area. For an
6591 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6592 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6595 @unnumberedsec Range_Length
6596 @findex Range_Length
6598 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6599 the number of values represented by the subtype (zero for a null
6600 range). The result is static for static subtypes. @code{Range_Length}
6601 applied to the index subtype of a one dimensional array always gives the
6602 same result as @code{Range} applied to the array itself.
6608 The @code{System.Address'Ref}
6609 (@code{System.Address} is the only permissible prefix)
6610 denotes a function identical to
6611 @code{System.Storage_Elements.To_Address} except that
6612 it is a static attribute. See @ref{To_Address} for more details.
6615 @unnumberedsec Result
6618 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6619 for a function. The prefix must be the name of the corresponding function. This
6620 is used to refer to the result of the function in the postcondition expression.
6621 For a further discussion of the use of this attribute and examples of its use,
6622 see the description of pragma Postcondition.
6625 @unnumberedsec Safe_Emax
6626 @cindex Ada 83 attributes
6629 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6630 the Ada 83 reference manual for an exact description of the semantics of
6634 @unnumberedsec Safe_Large
6635 @cindex Ada 83 attributes
6638 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6639 the Ada 83 reference manual for an exact description of the semantics of
6642 @node Simple_Storage_Pool
6643 @unnumberedsec Simple_Storage_Pool
6644 @cindex Storage pool, simple
6645 @cindex Simple storage pool
6646 @findex Simple_Storage_Pool
6648 For every nonformal, nonderived access-to-object type @var{Acc}, the
6649 representation attribute @code{Simple_Storage_Pool} may be specified
6650 via an attribute_definition_clause (or by specifying the equivalent aspect):
6652 @smallexample @c ada
6654 My_Pool : My_Simple_Storage_Pool_Type;
6656 type Acc is access My_Data_Type;
6658 for Acc'Simple_Storage_Pool use My_Pool;
6663 The name given in an attribute_definition_clause for the
6664 @code{Simple_Storage_Pool} attribute shall denote a variable of
6665 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
6667 The use of this attribute is only allowed for a prefix denoting a type
6668 for which it has been specified. The type of the attribute is the type
6669 of the variable specified as the simple storage pool of the access type,
6670 and the attribute denotes that variable.
6672 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
6673 for the same access type.
6675 If the @code{Simple_Storage_Pool} attribute has been specified for an access
6676 type, then applying the @code{Storage_Pool} attribute to the type is flagged
6677 with a warning and its evaluation raises the exception @code{Program_Error}.
6679 If the Simple_Storage_Pool attribute has been specified for an access
6680 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
6681 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
6682 which is intended to indicate the number of storage elements reserved for
6683 the simple storage pool. If the Storage_Size function has not been defined
6684 for the simple storage pool type, then this attribute returns zero.
6686 If an access type @var{S} has a specified simple storage pool of type
6687 @var{SSP}, then the evaluation of an allocator for that access type calls
6688 the primitive @code{Allocate} procedure for type @var{SSP}, passing
6689 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
6690 semantics of such allocators is the same as those defined for allocators
6691 in section 13.11 of the Ada Reference Manual, with the term
6692 ``simple storage pool'' substituted for ``storage pool''.
6694 If an access type @var{S} has a specified simple storage pool of type
6695 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
6696 for that access type invokes the primitive @code{Deallocate} procedure
6697 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
6698 parameter. The detailed semantics of such unchecked deallocations is the same
6699 as defined in section 13.11.2 of the Ada Reference Manual, except that the
6700 term ``simple storage pool'' is substituted for ``storage pool''.
6703 @unnumberedsec Small
6704 @cindex Ada 83 attributes
6707 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6709 GNAT also allows this attribute to be applied to floating-point types
6710 for compatibility with Ada 83. See
6711 the Ada 83 reference manual for an exact description of the semantics of
6712 this attribute when applied to floating-point types.
6715 @unnumberedsec Storage_Unit
6716 @findex Storage_Unit
6718 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6719 prefix) provides the same value as @code{System.Storage_Unit}.
6722 @unnumberedsec Stub_Type
6725 The GNAT implementation of remote access-to-classwide types is
6726 organized as described in AARM section E.4 (20.t): a value of an RACW type
6727 (designating a remote object) is represented as a normal access
6728 value, pointing to a "stub" object which in turn contains the
6729 necessary information to contact the designated remote object. A
6730 call on any dispatching operation of such a stub object does the
6731 remote call, if necessary, using the information in the stub object
6732 to locate the target partition, etc.
6734 For a prefix @code{T} that denotes a remote access-to-classwide type,
6735 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6737 By construction, the layout of @code{T'Stub_Type} is identical to that of
6738 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6739 unit @code{System.Partition_Interface}. Use of this attribute will create
6740 an implicit dependency on this unit.
6742 @node System_Allocator_Alignment
6743 @unnumberedsec System_Allocator_Alignment
6744 @cindex Alignment, allocator
6745 @findex System_Allocator_Alignment
6747 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
6748 permissible prefix) provides the observable guaranted to be honored by
6749 the system allocator (malloc). This is a static value that can be used
6750 in user storage pools based on malloc either to reject allocation
6751 with alignment too large or to enable a realignment circuitry if the
6752 alignment request is larger than this value.
6755 @unnumberedsec Target_Name
6758 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6759 prefix) provides a static string value that identifies the target
6760 for the current compilation. For GCC implementations, this is the
6761 standard gcc target name without the terminating slash (for
6762 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6768 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6769 provides the same value as @code{System.Tick},
6772 @unnumberedsec To_Address
6775 The @code{System'To_Address}
6776 (@code{System} is the only permissible prefix)
6777 denotes a function identical to
6778 @code{System.Storage_Elements.To_Address} except that
6779 it is a static attribute. This means that if its argument is
6780 a static expression, then the result of the attribute is a
6781 static expression. The result is that such an expression can be
6782 used in contexts (e.g.@: preelaborable packages) which require a
6783 static expression and where the function call could not be used
6784 (since the function call is always non-static, even if its
6785 argument is static).
6788 @unnumberedsec Type_Class
6791 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6792 the value of the type class for the full type of @var{type}. If
6793 @var{type} is a generic formal type, the value is the value for the
6794 corresponding actual subtype. The value of this attribute is of type
6795 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6797 @smallexample @c ada
6799 (Type_Class_Enumeration,
6801 Type_Class_Fixed_Point,
6802 Type_Class_Floating_Point,
6807 Type_Class_Address);
6811 Protected types yield the value @code{Type_Class_Task}, which thus
6812 applies to all concurrent types. This attribute is designed to
6813 be compatible with the DEC Ada 83 attribute of the same name.
6816 @unnumberedsec UET_Address
6819 The @code{UET_Address} attribute can only be used for a prefix which
6820 denotes a library package. It yields the address of the unit exception
6821 table when zero cost exception handling is used. This attribute is
6822 intended only for use within the GNAT implementation. See the unit
6823 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6824 for details on how this attribute is used in the implementation.
6826 @node Unconstrained_Array
6827 @unnumberedsec Unconstrained_Array
6828 @findex Unconstrained_Array
6830 The @code{Unconstrained_Array} attribute can be used with a prefix that
6831 denotes any type or subtype. It is a static attribute that yields
6832 @code{True} if the prefix designates an unconstrained array,
6833 and @code{False} otherwise. In a generic instance, the result is
6834 still static, and yields the result of applying this test to the
6837 @node Universal_Literal_String
6838 @unnumberedsec Universal_Literal_String
6839 @cindex Named numbers, representation of
6840 @findex Universal_Literal_String
6842 The prefix of @code{Universal_Literal_String} must be a named
6843 number. The static result is the string consisting of the characters of
6844 the number as defined in the original source. This allows the user
6845 program to access the actual text of named numbers without intermediate
6846 conversions and without the need to enclose the strings in quotes (which
6847 would preclude their use as numbers).
6849 For example, the following program prints the first 50 digits of pi:
6851 @smallexample @c ada
6852 with Text_IO; use Text_IO;
6856 Put (Ada.Numerics.Pi'Universal_Literal_String);
6860 @node Unrestricted_Access
6861 @unnumberedsec Unrestricted_Access
6862 @cindex @code{Access}, unrestricted
6863 @findex Unrestricted_Access
6865 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6866 except that all accessibility and aliased view checks are omitted. This
6867 is a user-beware attribute. It is similar to
6868 @code{Address}, for which it is a desirable replacement where the value
6869 desired is an access type. In other words, its effect is identical to
6870 first applying the @code{Address} attribute and then doing an unchecked
6871 conversion to a desired access type. In GNAT, but not necessarily in
6872 other implementations, the use of static chains for inner level
6873 subprograms means that @code{Unrestricted_Access} applied to a
6874 subprogram yields a value that can be called as long as the subprogram
6875 is in scope (normal Ada accessibility rules restrict this usage).
6877 It is possible to use @code{Unrestricted_Access} for any type, but care
6878 must be exercised if it is used to create pointers to unconstrained
6879 objects. In this case, the resulting pointer has the same scope as the
6880 context of the attribute, and may not be returned to some enclosing
6881 scope. For instance, a function cannot use @code{Unrestricted_Access}
6882 to create a unconstrained pointer and then return that value to the
6886 @unnumberedsec VADS_Size
6887 @cindex @code{Size}, VADS compatibility
6890 The @code{'VADS_Size} attribute is intended to make it easier to port
6891 legacy code which relies on the semantics of @code{'Size} as implemented
6892 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6893 same semantic interpretation. In particular, @code{'VADS_Size} applied
6894 to a predefined or other primitive type with no Size clause yields the
6895 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6896 typical machines). In addition @code{'VADS_Size} applied to an object
6897 gives the result that would be obtained by applying the attribute to
6898 the corresponding type.
6901 @unnumberedsec Value_Size
6902 @cindex @code{Size}, setting for not-first subtype
6904 @code{@var{type}'Value_Size} is the number of bits required to represent
6905 a value of the given subtype. It is the same as @code{@var{type}'Size},
6906 but, unlike @code{Size}, may be set for non-first subtypes.
6909 @unnumberedsec Wchar_T_Size
6910 @findex Wchar_T_Size
6911 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6912 prefix) provides the size in bits of the C @code{wchar_t} type
6913 primarily for constructing the definition of this type in
6914 package @code{Interfaces.C}.
6917 @unnumberedsec Word_Size
6919 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6920 prefix) provides the value @code{System.Word_Size}.
6922 @node Implementation Defined Restrictions
6923 @chapter Implementation Defined Restrictions
6926 All RM defined Restriction identifiers are implemented:
6929 @item language-defined restrictions (see 13.12.1)
6930 @item tasking restrictions (see D.7)
6931 @item high integrity restrictions (see H.4)
6935 GNAT implements additional restriction identifiers. All restrictions, whether
6936 language defined or GNAT-specific, are listed in the following.
6939 * Partition-Wide Restrictions::
6940 * Program Unit Level Restrictions::
6943 @node Partition-Wide Restrictions
6944 @section Partition-Wide Restrictions
6946 There are two separate lists of restriction identifiers. The first
6947 set requires consistency throughout a partition (in other words, if the
6948 restriction identifier is used for any compilation unit in the partition,
6949 then all compilation units in the partition must obey the restriction).
6952 * Immediate_Reclamation::
6953 * Max_Asynchronous_Select_Nesting::
6954 * Max_Entry_Queue_Length::
6955 * Max_Protected_Entries::
6956 * Max_Select_Alternatives::
6957 * Max_Storage_At_Blocking::
6958 * Max_Task_Entries::
6960 * No_Abort_Statements::
6961 * No_Access_Parameter_Allocators::
6962 * No_Access_Subprograms::
6964 * No_Anonymous_Allocators::
6967 * No_Default_Initialization::
6970 * No_Direct_Boolean_Operators::
6972 * No_Dispatching_Calls::
6973 * No_Dynamic_Attachment::
6974 * No_Dynamic_Priorities::
6975 * No_Entry_Calls_In_Elaboration_Code::
6976 * No_Enumeration_Maps::
6977 * No_Exception_Handlers::
6978 * No_Exception_Propagation::
6979 * No_Exception_Registration::
6983 * No_Floating_Point::
6984 * No_Implicit_Conditionals::
6985 * No_Implicit_Dynamic_Code::
6986 * No_Implicit_Heap_Allocations::
6987 * No_Implicit_Loops::
6988 * No_Initialize_Scalars::
6990 * No_Local_Allocators::
6991 * No_Local_Protected_Objects::
6992 * No_Local_Timing_Events::
6993 * No_Nested_Finalization::
6994 * No_Protected_Type_Allocators::
6995 * No_Protected_Types::
6998 * No_Relative_Delay::
6999 * No_Requeue_Statements::
7000 * No_Secondary_Stack::
7001 * No_Select_Statements::
7002 * No_Specific_Termination_Handlers::
7003 * No_Specification_of_Aspect::
7004 * No_Standard_Allocators_After_Elaboration::
7005 * No_Standard_Storage_Pools::
7006 * No_Stream_Optimizations::
7008 * No_Task_Allocators::
7009 * No_Task_Attributes_Package::
7010 * No_Task_Hierarchy::
7011 * No_Task_Termination::
7013 * No_Terminate_Alternatives::
7014 * No_Unchecked_Access::
7016 * Static_Priorities::
7017 * Static_Storage_Size::
7020 @node Immediate_Reclamation
7021 @unnumberedsubsec Immediate_Reclamation
7022 @findex Immediate_Reclamation
7023 [RM H.4] This restriction ensures that, except for storage occupied by
7024 objects created by allocators and not deallocated via unchecked
7025 deallocation, any storage reserved at run time for an object is
7026 immediately reclaimed when the object no longer exists.
7028 @node Max_Asynchronous_Select_Nesting
7029 @unnumberedsubsec Max_Asynchronous_Select_Nesting
7030 @findex Max_Asynchronous_Select_Nesting
7031 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
7032 selects. Violations of this restriction with a value of zero are
7033 detected at compile time. Violations of this restriction with values
7034 other than zero cause Storage_Error to be raised.
7036 @node Max_Entry_Queue_Length
7037 @unnumberedsubsec Max_Entry_Queue_Length
7038 @findex Max_Entry_Queue_Length
7039 [RM D.7] This restriction is a declaration that any protected entry compiled in
7040 the scope of the restriction has at most the specified number of
7041 tasks waiting on the entry at any one time, and so no queue is required.
7042 Note that this restriction is checked at run time. Violation of this
7043 restriction results in the raising of Program_Error exception at the point of
7046 @node Max_Protected_Entries
7047 @unnumberedsubsec Max_Protected_Entries
7048 @findex Max_Protected_Entries
7049 [RM D.7] Specifies the maximum number of entries per protected type. The
7050 bounds of every entry family of a protected unit shall be static, or shall be
7051 defined by a discriminant of a subtype whose corresponding bound is static.
7053 @node Max_Select_Alternatives
7054 @unnumberedsubsec Max_Select_Alternatives
7055 @findex Max_Select_Alternatives
7056 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
7058 @node Max_Storage_At_Blocking
7059 @unnumberedsubsec Max_Storage_At_Blocking
7060 @findex Max_Storage_At_Blocking
7061 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
7062 Storage_Size that can be retained by a blocked task. A violation of this
7063 restriction causes Storage_Error to be raised.
7065 @node Max_Task_Entries
7066 @unnumberedsubsec Max_Task_Entries
7067 @findex Max_Task_Entries
7068 [RM D.7] Specifies the maximum number of entries
7069 per task. The bounds of every entry family
7070 of a task unit shall be static, or shall be
7071 defined by a discriminant of a subtype whose
7072 corresponding bound is static.
7075 @unnumberedsubsec Max_Tasks
7077 [RM D.7] Specifies the maximum number of task that may be created, not
7078 counting the creation of the environment task. Violations of this
7079 restriction with a value of zero are detected at compile
7080 time. Violations of this restriction with values other than zero cause
7081 Storage_Error to be raised.
7083 @node No_Abort_Statements
7084 @unnumberedsubsec No_Abort_Statements
7085 @findex No_Abort_Statements
7086 [RM D.7] There are no abort_statements, and there are
7087 no calls to Task_Identification.Abort_Task.
7089 @node No_Access_Parameter_Allocators
7090 @unnumberedsubsec No_Access_Parameter_Allocators
7091 @findex No_Access_Parameter_Allocators
7092 [RM H.4] This restriction ensures at compile time that there are no
7093 occurrences of an allocator as the actual parameter to an access
7096 @node No_Access_Subprograms
7097 @unnumberedsubsec No_Access_Subprograms
7098 @findex No_Access_Subprograms
7099 [RM H.4] This restriction ensures at compile time that there are no
7100 declarations of access-to-subprogram types.
7103 @unnumberedsubsec No_Allocators
7104 @findex No_Allocators
7105 [RM H.4] This restriction ensures at compile time that there are no
7106 occurrences of an allocator.
7108 @node No_Anonymous_Allocators
7109 @unnumberedsubsec No_Anonymous_Allocators
7110 @findex No_Anonymous_Allocators
7111 [RM H.4] This restriction ensures at compile time that there are no
7112 occurrences of an allocator of anonymous access type.
7115 @unnumberedsubsec No_Calendar
7117 [GNAT] This restriction ensures at compile time that there is no implicit or
7118 explicit dependence on the package @code{Ada.Calendar}.
7120 @node No_Coextensions
7121 @unnumberedsubsec No_Coextensions
7122 @findex No_Coextensions
7123 [RM H.4] This restriction ensures at compile time that there are no
7124 coextensions. See 3.10.2.
7126 @node No_Default_Initialization
7127 @unnumberedsubsec No_Default_Initialization
7128 @findex No_Default_Initialization
7130 [GNAT] This restriction prohibits any instance of default initialization
7131 of variables. The binder implements a consistency rule which prevents
7132 any unit compiled without the restriction from with'ing a unit with the
7133 restriction (this allows the generation of initialization procedures to
7134 be skipped, since you can be sure that no call is ever generated to an
7135 initialization procedure in a unit with the restriction active). If used
7136 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
7137 is to prohibit all cases of variables declared without a specific
7138 initializer (including the case of OUT scalar parameters).
7141 @unnumberedsubsec No_Delay
7143 [RM H.4] This restriction ensures at compile time that there are no
7144 delay statements and no dependences on package Calendar.
7147 @unnumberedsubsec No_Dependence
7148 @findex No_Dependence
7149 [RM 13.12.1] This restriction checks at compile time that there are no
7150 dependence on a library unit.
7152 @node No_Direct_Boolean_Operators
7153 @unnumberedsubsec No_Direct_Boolean_Operators
7154 @findex No_Direct_Boolean_Operators
7155 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
7156 operands of type Boolean (or any type derived
7157 from Boolean). This is intended for use in safety critical programs
7158 where the certification protocol requires the use of short-circuit
7159 (and then, or else) forms for all composite boolean operations.
7162 @unnumberedsubsec No_Dispatch
7164 [RM H.4] This restriction ensures at compile time that there are no
7165 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
7167 @node No_Dispatching_Calls
7168 @unnumberedsubsec No_Dispatching_Calls
7169 @findex No_Dispatching_Calls
7170 [GNAT] This restriction ensures at compile time that the code generated by the
7171 compiler involves no dispatching calls. The use of this restriction allows the
7172 safe use of record extensions, classwide membership tests and other classwide
7173 features not involving implicit dispatching. This restriction ensures that
7174 the code contains no indirect calls through a dispatching mechanism. Note that
7175 this includes internally-generated calls created by the compiler, for example
7176 in the implementation of class-wide objects assignments. The
7177 membership test is allowed in the presence of this restriction, because its
7178 implementation requires no dispatching.
7179 This restriction is comparable to the official Ada restriction
7180 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7181 all classwide constructs that do not imply dispatching.
7182 The following example indicates constructs that violate this restriction.
7186 type T is tagged record
7189 procedure P (X : T);
7191 type DT is new T with record
7192 More_Data : Natural;
7194 procedure Q (X : DT);
7198 procedure Example is
7199 procedure Test (O : T'Class) is
7200 N : Natural := O'Size;-- Error: Dispatching call
7201 C : T'Class := O; -- Error: implicit Dispatching Call
7203 if O in DT'Class then -- OK : Membership test
7204 Q (DT (O)); -- OK : Type conversion plus direct call
7206 P (O); -- Error: Dispatching call
7212 P (Obj); -- OK : Direct call
7213 P (T (Obj)); -- OK : Type conversion plus direct call
7214 P (T'Class (Obj)); -- Error: Dispatching call
7216 Test (Obj); -- OK : Type conversion
7218 if Obj in T'Class then -- OK : Membership test
7224 @node No_Dynamic_Attachment
7225 @unnumberedsubsec No_Dynamic_Attachment
7226 @findex No_Dynamic_Attachment
7227 [RM D.7] This restriction ensures that there is no call to any of the
7228 operations defined in package Ada.Interrupts
7229 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
7230 Detach_Handler, and Reference).
7232 @node No_Dynamic_Priorities
7233 @unnumberedsubsec No_Dynamic_Priorities
7234 @findex No_Dynamic_Priorities
7235 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
7237 @node No_Entry_Calls_In_Elaboration_Code
7238 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
7239 @findex No_Entry_Calls_In_Elaboration_Code
7240 [GNAT] This restriction ensures at compile time that no task or protected entry
7241 calls are made during elaboration code. As a result of the use of this
7242 restriction, the compiler can assume that no code past an accept statement
7243 in a task can be executed at elaboration time.
7245 @node No_Enumeration_Maps
7246 @unnumberedsubsec No_Enumeration_Maps
7247 @findex No_Enumeration_Maps
7248 [GNAT] This restriction ensures at compile time that no operations requiring
7249 enumeration maps are used (that is Image and Value attributes applied
7250 to enumeration types).
7252 @node No_Exception_Handlers
7253 @unnumberedsubsec No_Exception_Handlers
7254 @findex No_Exception_Handlers
7255 [GNAT] This restriction ensures at compile time that there are no explicit
7256 exception handlers. It also indicates that no exception propagation will
7257 be provided. In this mode, exceptions may be raised but will result in
7258 an immediate call to the last chance handler, a routine that the user
7259 must define with the following profile:
7261 @smallexample @c ada
7262 procedure Last_Chance_Handler
7263 (Source_Location : System.Address; Line : Integer);
7264 pragma Export (C, Last_Chance_Handler,
7265 "__gnat_last_chance_handler");
7268 The parameter is a C null-terminated string representing a message to be
7269 associated with the exception (typically the source location of the raise
7270 statement generated by the compiler). The Line parameter when nonzero
7271 represents the line number in the source program where the raise occurs.
7273 @node No_Exception_Propagation
7274 @unnumberedsubsec No_Exception_Propagation
7275 @findex No_Exception_Propagation
7276 [GNAT] This restriction guarantees that exceptions are never propagated
7277 to an outer subprogram scope. The only case in which an exception may
7278 be raised is when the handler is statically in the same subprogram, so
7279 that the effect of a raise is essentially like a goto statement. Any
7280 other raise statement (implicit or explicit) will be considered
7281 unhandled. Exception handlers are allowed, but may not contain an
7282 exception occurrence identifier (exception choice). In addition, use of
7283 the package GNAT.Current_Exception is not permitted, and reraise
7284 statements (raise with no operand) are not permitted.
7286 @node No_Exception_Registration
7287 @unnumberedsubsec No_Exception_Registration
7288 @findex No_Exception_Registration
7289 [GNAT] This restriction ensures at compile time that no stream operations for
7290 types Exception_Id or Exception_Occurrence are used. This also makes it
7291 impossible to pass exceptions to or from a partition with this restriction
7292 in a distributed environment. If this exception is active, then the generated
7293 code is simplified by omitting the otherwise-required global registration
7294 of exceptions when they are declared.
7297 @unnumberedsubsec No_Exceptions
7298 @findex No_Exceptions
7299 [RM H.4] This restriction ensures at compile time that there are no
7300 raise statements and no exception handlers.
7302 @node No_Finalization
7303 @unnumberedsubsec No_Finalization
7304 @findex No_Finalization
7305 [GNAT] This restriction disables the language features described in
7306 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
7307 performed by the compiler to support these features. The following types
7308 are no longer considered controlled when this restriction is in effect:
7311 @code{Ada.Finalization.Controlled}
7313 @code{Ada.Finalization.Limited_Controlled}
7315 Derivations from @code{Controlled} or @code{Limited_Controlled}
7323 Array and record types with controlled components
7325 The compiler no longer generates code to initialize, finalize or adjust an
7326 object or a nested component, either declared on the stack or on the heap. The
7327 deallocation of a controlled object no longer finalizes its contents.
7329 @node No_Fixed_Point
7330 @unnumberedsubsec No_Fixed_Point
7331 @findex No_Fixed_Point
7332 [RM H.4] This restriction ensures at compile time that there are no
7333 occurrences of fixed point types and operations.
7335 @node No_Floating_Point
7336 @unnumberedsubsec No_Floating_Point
7337 @findex No_Floating_Point
7338 [RM H.4] This restriction ensures at compile time that there are no
7339 occurrences of floating point types and operations.
7341 @node No_Implicit_Conditionals
7342 @unnumberedsubsec No_Implicit_Conditionals
7343 @findex No_Implicit_Conditionals
7344 [GNAT] This restriction ensures that the generated code does not contain any
7345 implicit conditionals, either by modifying the generated code where possible,
7346 or by rejecting any construct that would otherwise generate an implicit
7347 conditional. Note that this check does not include run time constraint
7348 checks, which on some targets may generate implicit conditionals as
7349 well. To control the latter, constraint checks can be suppressed in the
7350 normal manner. Constructs generating implicit conditionals include comparisons
7351 of composite objects and the Max/Min attributes.
7353 @node No_Implicit_Dynamic_Code
7354 @unnumberedsubsec No_Implicit_Dynamic_Code
7355 @findex No_Implicit_Dynamic_Code
7357 [GNAT] This restriction prevents the compiler from building ``trampolines''.
7358 This is a structure that is built on the stack and contains dynamic
7359 code to be executed at run time. On some targets, a trampoline is
7360 built for the following features: @code{Access},
7361 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
7362 nested task bodies; primitive operations of nested tagged types.
7363 Trampolines do not work on machines that prevent execution of stack
7364 data. For example, on windows systems, enabling DEP (data execution
7365 protection) will cause trampolines to raise an exception.
7366 Trampolines are also quite slow at run time.
7368 On many targets, trampolines have been largely eliminated. Look at the
7369 version of system.ads for your target --- if it has
7370 Always_Compatible_Rep equal to False, then trampolines are largely
7371 eliminated. In particular, a trampoline is built for the following
7372 features: @code{Address} of a nested subprogram;
7373 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
7374 but only if pragma Favor_Top_Level applies, or the access type has a
7375 foreign-language convention; primitive operations of nested tagged
7378 @node No_Implicit_Heap_Allocations
7379 @unnumberedsubsec No_Implicit_Heap_Allocations
7380 @findex No_Implicit_Heap_Allocations
7381 [RM D.7] No constructs are allowed to cause implicit heap allocation.
7383 @node No_Implicit_Loops
7384 @unnumberedsubsec No_Implicit_Loops
7385 @findex No_Implicit_Loops
7386 [GNAT] This restriction ensures that the generated code does not contain any
7387 implicit @code{for} loops, either by modifying
7388 the generated code where possible,
7389 or by rejecting any construct that would otherwise generate an implicit
7390 @code{for} loop. If this restriction is active, it is possible to build
7391 large array aggregates with all static components without generating an
7392 intermediate temporary, and without generating a loop to initialize individual
7393 components. Otherwise, a loop is created for arrays larger than about 5000
7396 @node No_Initialize_Scalars
7397 @unnumberedsubsec No_Initialize_Scalars
7398 @findex No_Initialize_Scalars
7399 [GNAT] This restriction ensures that no unit in the partition is compiled with
7400 pragma Initialize_Scalars. This allows the generation of more efficient
7401 code, and in particular eliminates dummy null initialization routines that
7402 are otherwise generated for some record and array types.
7405 @unnumberedsubsec No_IO
7407 [RM H.4] This restriction ensures at compile time that there are no
7408 dependences on any of the library units Sequential_IO, Direct_IO,
7409 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
7411 @node No_Local_Allocators
7412 @unnumberedsubsec No_Local_Allocators
7413 @findex No_Local_Allocators
7414 [RM H.4] This restriction ensures at compile time that there are no
7415 occurrences of an allocator in subprograms, generic subprograms, tasks,
7418 @node No_Local_Protected_Objects
7419 @unnumberedsubsec No_Local_Protected_Objects
7420 @findex No_Local_Protected_Objects
7421 [RM D.7] This restriction ensures at compile time that protected objects are
7422 only declared at the library level.
7424 @node No_Local_Timing_Events
7425 @unnumberedsubsec No_Local_Timing_Events
7426 @findex No_Local_Timing_Events
7427 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
7428 declared at the library level.
7430 @node No_Nested_Finalization
7431 @unnumberedsubsec No_Nested_Finalization
7432 @findex No_Nested_Finalization
7433 [RM D.7] All objects requiring finalization are declared at the library level.
7435 @node No_Protected_Type_Allocators
7436 @unnumberedsubsec No_Protected_Type_Allocators
7437 @findex No_Protected_Type_Allocators
7438 [RM D.7] This restriction ensures at compile time that there are no allocator
7439 expressions that attempt to allocate protected objects.
7441 @node No_Protected_Types
7442 @unnumberedsubsec No_Protected_Types
7443 @findex No_Protected_Types
7444 [RM H.4] This restriction ensures at compile time that there are no
7445 declarations of protected types or protected objects.
7448 @unnumberedsubsec No_Recursion
7449 @findex No_Recursion
7450 [RM H.4] A program execution is erroneous if a subprogram is invoked as
7451 part of its execution.
7454 @unnumberedsubsec No_Reentrancy
7455 @findex No_Reentrancy
7456 [RM H.4] A program execution is erroneous if a subprogram is executed by
7457 two tasks at the same time.
7459 @node No_Relative_Delay
7460 @unnumberedsubsec No_Relative_Delay
7461 @findex No_Relative_Delay
7462 [RM D.7] This restriction ensures at compile time that there are no delay
7463 relative statements and prevents expressions such as @code{delay 1.23;} from
7464 appearing in source code.
7466 @node No_Requeue_Statements
7467 @unnumberedsubsec No_Requeue_Statements
7468 @findex No_Requeue_Statements
7469 [RM D.7] This restriction ensures at compile time that no requeue statements
7470 are permitted and prevents keyword @code{requeue} from being used in source
7473 @node No_Secondary_Stack
7474 @unnumberedsubsec No_Secondary_Stack
7475 @findex No_Secondary_Stack
7476 [GNAT] This restriction ensures at compile time that the generated code
7477 does not contain any reference to the secondary stack. The secondary
7478 stack is used to implement functions returning unconstrained objects
7479 (arrays or records) on some targets.
7481 @node No_Select_Statements
7482 @unnumberedsubsec No_Select_Statements
7483 @findex No_Select_Statements
7484 [RM D.7] This restriction ensures at compile time no select statements of any
7485 kind are permitted, that is the keyword @code{select} may not appear.
7487 @node No_Specific_Termination_Handlers
7488 @unnumberedsubsec No_Specific_Termination_Handlers
7489 @findex No_Specific_Termination_Handlers
7490 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
7491 or to Ada.Task_Termination.Specific_Handler.
7493 @node No_Specification_of_Aspect
7494 @unnumberedsubsec No_Specification_of_Aspect
7495 @findex No_Specification_of_Aspect
7496 [RM 13.12.1] This restriction checks at compile time that no aspect
7497 specification, attribute definition clause, or pragma is given for a
7500 @node No_Standard_Allocators_After_Elaboration
7501 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
7502 @findex No_Standard_Allocators_After_Elaboration
7503 [RM D.7] Specifies that an allocator using a standard storage pool
7504 should never be evaluated at run time after the elaboration of the
7505 library items of the partition has completed. Otherwise, Storage_Error
7508 @node No_Standard_Storage_Pools
7509 @unnumberedsubsec No_Standard_Storage_Pools
7510 @findex No_Standard_Storage_Pools
7511 [GNAT] This restriction ensures at compile time that no access types
7512 use the standard default storage pool. Any access type declared must
7513 have an explicit Storage_Pool attribute defined specifying a
7514 user-defined storage pool.
7516 @node No_Stream_Optimizations
7517 @unnumberedsubsec No_Stream_Optimizations
7518 @findex No_Stream_Optimizations
7519 [GNAT] This restriction affects the performance of stream operations on types
7520 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
7521 compiler uses block reads and writes when manipulating @code{String} objects
7522 due to their supperior performance. When this restriction is in effect, the
7523 compiler performs all IO operations on a per-character basis.
7526 @unnumberedsubsec No_Streams
7528 [GNAT] This restriction ensures at compile/bind time that there are no
7529 stream objects created and no use of stream attributes.
7530 This restriction does not forbid dependences on the package
7531 @code{Ada.Streams}. So it is permissible to with
7532 @code{Ada.Streams} (or another package that does so itself)
7533 as long as no actual stream objects are created and no
7534 stream attributes are used.
7536 Note that the use of restriction allows optimization of tagged types,
7537 since they do not need to worry about dispatching stream operations.
7538 To take maximum advantage of this space-saving optimization, any
7539 unit declaring a tagged type should be compiled with the restriction,
7540 though this is not required.
7542 @node No_Task_Allocators
7543 @unnumberedsubsec No_Task_Allocators
7544 @findex No_Task_Allocators
7545 [RM D.7] There are no allocators for task types
7546 or types containing task subcomponents.
7548 @node No_Task_Attributes_Package
7549 @unnumberedsubsec No_Task_Attributes_Package
7550 @findex No_Task_Attributes_Package
7551 [GNAT] This restriction ensures at compile time that there are no implicit or
7552 explicit dependencies on the package @code{Ada.Task_Attributes}.
7554 @node No_Task_Hierarchy
7555 @unnumberedsubsec No_Task_Hierarchy
7556 @findex No_Task_Hierarchy
7557 [RM D.7] All (non-environment) tasks depend
7558 directly on the environment task of the partition.
7560 @node No_Task_Termination
7561 @unnumberedsubsec No_Task_Termination
7562 @findex No_Task_Termination
7563 [RM D.7] Tasks which terminate are erroneous.
7566 @unnumberedsubsec No_Tasking
7568 [GNAT] This restriction prevents the declaration of tasks or task types
7569 throughout the partition. It is similar in effect to the use of
7570 @code{Max_Tasks => 0} except that violations are caught at compile time
7571 and cause an error message to be output either by the compiler or
7574 @node No_Terminate_Alternatives
7575 @unnumberedsubsec No_Terminate_Alternatives
7576 @findex No_Terminate_Alternatives
7577 [RM D.7] There are no selective accepts with terminate alternatives.
7579 @node No_Unchecked_Access
7580 @unnumberedsubsec No_Unchecked_Access
7581 @findex No_Unchecked_Access
7582 [RM H.4] This restriction ensures at compile time that there are no
7583 occurrences of the Unchecked_Access attribute.
7585 @node Simple_Barriers
7586 @unnumberedsubsec Simple_Barriers
7587 @findex Simple_Barriers
7588 [RM D.7] This restriction ensures at compile time that barriers in entry
7589 declarations for protected types are restricted to either static boolean
7590 expressions or references to simple boolean variables defined in the private
7591 part of the protected type. No other form of entry barriers is permitted.
7593 @node Static_Priorities
7594 @unnumberedsubsec Static_Priorities
7595 @findex Static_Priorities
7596 [GNAT] This restriction ensures at compile time that all priority expressions
7597 are static, and that there are no dependences on the package
7598 @code{Ada.Dynamic_Priorities}.
7600 @node Static_Storage_Size
7601 @unnumberedsubsec Static_Storage_Size
7602 @findex Static_Storage_Size
7603 [GNAT] This restriction ensures at compile time that any expression appearing
7604 in a Storage_Size pragma or attribute definition clause is static.
7606 @node Program Unit Level Restrictions
7607 @section Program Unit Level Restrictions
7610 The second set of restriction identifiers
7611 does not require partition-wide consistency.
7612 The restriction may be enforced for a single
7613 compilation unit without any effect on any of the
7614 other compilation units in the partition.
7617 * No_Elaboration_Code::
7619 * No_Implementation_Aspect_Specifications::
7620 * No_Implementation_Attributes::
7621 * No_Implementation_Identifiers::
7622 * No_Implementation_Pragmas::
7623 * No_Implementation_Restrictions::
7624 * No_Implementation_Units::
7625 * No_Implicit_Aliasing::
7626 * No_Obsolescent_Features::
7627 * No_Wide_Characters::
7631 @node No_Elaboration_Code
7632 @unnumberedsubsec No_Elaboration_Code
7633 @findex No_Elaboration_Code
7634 [GNAT] This restriction ensures at compile time that no elaboration code is
7635 generated. Note that this is not the same condition as is enforced
7636 by pragma @code{Preelaborate}. There are cases in which pragma
7637 @code{Preelaborate} still permits code to be generated (e.g.@: code
7638 to initialize a large array to all zeroes), and there are cases of units
7639 which do not meet the requirements for pragma @code{Preelaborate},
7640 but for which no elaboration code is generated. Generally, it is
7641 the case that preelaborable units will meet the restrictions, with
7642 the exception of large aggregates initialized with an others_clause,
7643 and exception declarations (which generate calls to a run-time
7644 registry procedure). This restriction is enforced on
7645 a unit by unit basis, it need not be obeyed consistently
7646 throughout a partition.
7648 In the case of aggregates with others, if the aggregate has a dynamic
7649 size, there is no way to eliminate the elaboration code (such dynamic
7650 bounds would be incompatible with @code{Preelaborate} in any case). If
7651 the bounds are static, then use of this restriction actually modifies
7652 the code choice of the compiler to avoid generating a loop, and instead
7653 generate the aggregate statically if possible, no matter how many times
7654 the data for the others clause must be repeatedly generated.
7656 It is not possible to precisely document
7657 the constructs which are compatible with this restriction, since,
7658 unlike most other restrictions, this is not a restriction on the
7659 source code, but a restriction on the generated object code. For
7660 example, if the source contains a declaration:
7663 Val : constant Integer := X;
7667 where X is not a static constant, it may be possible, depending
7668 on complex optimization circuitry, for the compiler to figure
7669 out the value of X at compile time, in which case this initialization
7670 can be done by the loader, and requires no initialization code. It
7671 is not possible to document the precise conditions under which the
7672 optimizer can figure this out.
7674 Note that this the implementation of this restriction requires full
7675 code generation. If it is used in conjunction with "semantics only"
7676 checking, then some cases of violations may be missed.
7678 @node No_Entry_Queue
7679 @unnumberedsubsec No_Entry_Queue
7680 @findex No_Entry_Queue
7681 [GNAT] This restriction is a declaration that any protected entry compiled in
7682 the scope of the restriction has at most one task waiting on the entry
7683 at any one time, and so no queue is required. This restriction is not
7684 checked at compile time. A program execution is erroneous if an attempt
7685 is made to queue a second task on such an entry.
7687 @node No_Implementation_Aspect_Specifications
7688 @unnumberedsubsec No_Implementation_Aspect_Specifications
7689 @findex No_Implementation_Aspect_Specifications
7690 [RM 13.12.1] This restriction checks at compile time that no
7691 GNAT-defined aspects are present. With this restriction, the only
7692 aspects that can be used are those defined in the Ada Reference Manual.
7694 @node No_Implementation_Attributes
7695 @unnumberedsubsec No_Implementation_Attributes
7696 @findex No_Implementation_Attributes
7697 [RM 13.12.1] This restriction checks at compile time that no
7698 GNAT-defined attributes are present. With this restriction, the only
7699 attributes that can be used are those defined in the Ada Reference
7702 @node No_Implementation_Identifiers
7703 @unnumberedsubsec No_Implementation_Identifiers
7704 @findex No_Implementation_Identifiers
7705 [RM 13.12.1] This restriction checks at compile time that no
7706 implementation-defined identifiers occur within language-defined
7709 @node No_Implementation_Pragmas
7710 @unnumberedsubsec No_Implementation_Pragmas
7711 @findex No_Implementation_Pragmas
7712 [RM 13.12.1] This restriction checks at compile time that no
7713 GNAT-defined pragmas are present. With this restriction, the only
7714 pragmas that can be used are those defined in the Ada Reference Manual.
7716 @node No_Implementation_Restrictions
7717 @unnumberedsubsec No_Implementation_Restrictions
7718 @findex No_Implementation_Restrictions
7719 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
7720 identifiers (other than @code{No_Implementation_Restrictions} itself)
7721 are present. With this restriction, the only other restriction identifiers
7722 that can be used are those defined in the Ada Reference Manual.
7724 @node No_Implementation_Units
7725 @unnumberedsubsec No_Implementation_Units
7726 @findex No_Implementation_Units
7727 [RM 13.12.1] This restriction checks at compile time that there is no
7728 mention in the context clause of any implementation-defined descendants
7729 of packages Ada, Interfaces, or System.
7731 @node No_Implicit_Aliasing
7732 @unnumberedsubsec No_Implicit_Aliasing
7733 @findex No_Implicit_Aliasing
7734 [GNAT] This restriction, which is not required to be partition-wide consistent,
7735 requires an explicit aliased keyword for an object to which 'Access,
7736 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
7737 the 'Unrestricted_Access attribute for objects. Note: the reason that
7738 Unrestricted_Access is forbidden is that it would require the prefix
7739 to be aliased, and in such cases, it can always be replaced by
7740 the standard attribute Unchecked_Access which is preferable.
7742 @node No_Obsolescent_Features
7743 @unnumberedsubsec No_Obsolescent_Features
7744 @findex No_Obsolescent_Features
7745 [RM 13.12.1] This restriction checks at compile time that no obsolescent
7746 features are used, as defined in Annex J of the Ada Reference Manual.
7748 @node No_Wide_Characters
7749 @unnumberedsubsec No_Wide_Characters
7750 @findex No_Wide_Characters
7751 [GNAT] This restriction ensures at compile time that no uses of the types
7752 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7754 appear, and that no wide or wide wide string or character literals
7755 appear in the program (that is literals representing characters not in
7756 type @code{Character}.
7759 @unnumberedsubsec SPARK
7761 [GNAT] This restriction checks at compile time that some constructs
7762 forbidden in SPARK are not present. The SPARK version used as a
7763 reference is the same as the Ada mode for the unit, so a unit compiled
7764 in Ada 95 mode with SPARK restrictions will be checked for constructs
7765 forbidden in SPARK 95. Error messages related to SPARK restriction have
7769 violation of restriction "SPARK" at <file>
7773 This is not a replacement for the semantic checks performed by the
7774 SPARK Examiner tool, as the compiler only deals currently with code,
7775 not at all with SPARK annotations and does not guarantee catching all
7776 cases of constructs forbidden by SPARK.
7778 Thus it may well be the case that code which
7779 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
7780 e.g. due to the different visibility rules of the Examiner based on
7781 SPARK @code{inherit} annotations.
7783 This restriction can be useful in providing an initial filter for
7784 code developed using SPARK, or in examining legacy code to see how far
7785 it is from meeting SPARK restrictions.
7787 @c ------------------------
7788 @node Implementation Advice
7789 @chapter Implementation Advice
7791 The main text of the Ada Reference Manual describes the required
7792 behavior of all Ada compilers, and the GNAT compiler conforms to
7795 In addition, there are sections throughout the Ada Reference Manual headed
7796 by the phrase ``Implementation advice''. These sections are not normative,
7797 i.e., they do not specify requirements that all compilers must
7798 follow. Rather they provide advice on generally desirable behavior. You
7799 may wonder why they are not requirements. The most typical answer is
7800 that they describe behavior that seems generally desirable, but cannot
7801 be provided on all systems, or which may be undesirable on some systems.
7803 As far as practical, GNAT follows the implementation advice sections in
7804 the Ada Reference Manual. This chapter contains a table giving the
7805 reference manual section number, paragraph number and several keywords
7806 for each advice. Each entry consists of the text of the advice followed
7807 by the GNAT interpretation of this advice. Most often, this simply says
7808 ``followed'', which means that GNAT follows the advice. However, in a
7809 number of cases, GNAT deliberately deviates from this advice, in which
7810 case the text describes what GNAT does and why.
7812 @cindex Error detection
7813 @unnumberedsec 1.1.3(20): Error Detection
7816 If an implementation detects the use of an unsupported Specialized Needs
7817 Annex feature at run time, it should raise @code{Program_Error} if
7820 Not relevant. All specialized needs annex features are either supported,
7821 or diagnosed at compile time.
7824 @unnumberedsec 1.1.3(31): Child Units
7827 If an implementation wishes to provide implementation-defined
7828 extensions to the functionality of a language-defined library unit, it
7829 should normally do so by adding children to the library unit.
7833 @cindex Bounded errors
7834 @unnumberedsec 1.1.5(12): Bounded Errors
7837 If an implementation detects a bounded error or erroneous
7838 execution, it should raise @code{Program_Error}.
7840 Followed in all cases in which the implementation detects a bounded
7841 error or erroneous execution. Not all such situations are detected at
7845 @unnumberedsec 2.8(16): Pragmas
7848 Normally, implementation-defined pragmas should have no semantic effect
7849 for error-free programs; that is, if the implementation-defined pragmas
7850 are removed from a working program, the program should still be legal,
7851 and should still have the same semantics.
7853 The following implementation defined pragmas are exceptions to this
7865 @item CPP_Constructor
7869 @item Interface_Name
7871 @item Machine_Attribute
7873 @item Unimplemented_Unit
7875 @item Unchecked_Union
7880 In each of the above cases, it is essential to the purpose of the pragma
7881 that this advice not be followed. For details see the separate section
7882 on implementation defined pragmas.
7884 @unnumberedsec 2.8(17-19): Pragmas
7887 Normally, an implementation should not define pragmas that can
7888 make an illegal program legal, except as follows:
7892 A pragma used to complete a declaration, such as a pragma @code{Import};
7896 A pragma used to configure the environment by adding, removing, or
7897 replacing @code{library_items}.
7899 See response to paragraph 16 of this same section.
7901 @cindex Character Sets
7902 @cindex Alternative Character Sets
7903 @unnumberedsec 3.5.2(5): Alternative Character Sets
7906 If an implementation supports a mode with alternative interpretations
7907 for @code{Character} and @code{Wide_Character}, the set of graphic
7908 characters of @code{Character} should nevertheless remain a proper
7909 subset of the set of graphic characters of @code{Wide_Character}. Any
7910 character set ``localizations'' should be reflected in the results of
7911 the subprograms defined in the language-defined package
7912 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
7913 an alternative interpretation of @code{Character}, the implementation should
7914 also support a corresponding change in what is a legal
7915 @code{identifier_letter}.
7917 Not all wide character modes follow this advice, in particular the JIS
7918 and IEC modes reflect standard usage in Japan, and in these encoding,
7919 the upper half of the Latin-1 set is not part of the wide-character
7920 subset, since the most significant bit is used for wide character
7921 encoding. However, this only applies to the external forms. Internally
7922 there is no such restriction.
7924 @cindex Integer types
7925 @unnumberedsec 3.5.4(28): Integer Types
7929 An implementation should support @code{Long_Integer} in addition to
7930 @code{Integer} if the target machine supports 32-bit (or longer)
7931 arithmetic. No other named integer subtypes are recommended for package
7932 @code{Standard}. Instead, appropriate named integer subtypes should be
7933 provided in the library package @code{Interfaces} (see B.2).
7935 @code{Long_Integer} is supported. Other standard integer types are supported
7936 so this advice is not fully followed. These types
7937 are supported for convenient interface to C, and so that all hardware
7938 types of the machine are easily available.
7939 @unnumberedsec 3.5.4(29): Integer Types
7943 An implementation for a two's complement machine should support
7944 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
7945 implementation should support a non-binary modules up to @code{Integer'Last}.
7949 @cindex Enumeration values
7950 @unnumberedsec 3.5.5(8): Enumeration Values
7953 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
7954 subtype, if the value of the operand does not correspond to the internal
7955 code for any enumeration literal of its type (perhaps due to an
7956 un-initialized variable), then the implementation should raise
7957 @code{Program_Error}. This is particularly important for enumeration
7958 types with noncontiguous internal codes specified by an
7959 enumeration_representation_clause.
7964 @unnumberedsec 3.5.7(17): Float Types
7967 An implementation should support @code{Long_Float} in addition to
7968 @code{Float} if the target machine supports 11 or more digits of
7969 precision. No other named floating point subtypes are recommended for
7970 package @code{Standard}. Instead, appropriate named floating point subtypes
7971 should be provided in the library package @code{Interfaces} (see B.2).
7973 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
7974 former provides improved compatibility with other implementations
7975 supporting this type. The latter corresponds to the highest precision
7976 floating-point type supported by the hardware. On most machines, this
7977 will be the same as @code{Long_Float}, but on some machines, it will
7978 correspond to the IEEE extended form. The notable case is all ia32
7979 (x86) implementations, where @code{Long_Long_Float} corresponds to
7980 the 80-bit extended precision format supported in hardware on this
7981 processor. Note that the 128-bit format on SPARC is not supported,
7982 since this is a software rather than a hardware format.
7984 @cindex Multidimensional arrays
7985 @cindex Arrays, multidimensional
7986 @unnumberedsec 3.6.2(11): Multidimensional Arrays
7989 An implementation should normally represent multidimensional arrays in
7990 row-major order, consistent with the notation used for multidimensional
7991 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
7992 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
7993 column-major order should be used instead (see B.5, ``Interfacing with
7998 @findex Duration'Small
7999 @unnumberedsec 9.6(30-31): Duration'Small
8002 Whenever possible in an implementation, the value of @code{Duration'Small}
8003 should be no greater than 100 microseconds.
8005 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
8009 The time base for @code{delay_relative_statements} should be monotonic;
8010 it need not be the same time base as used for @code{Calendar.Clock}.
8014 @unnumberedsec 10.2.1(12): Consistent Representation
8017 In an implementation, a type declared in a pre-elaborated package should
8018 have the same representation in every elaboration of a given version of
8019 the package, whether the elaborations occur in distinct executions of
8020 the same program, or in executions of distinct programs or partitions
8021 that include the given version.
8023 Followed, except in the case of tagged types. Tagged types involve
8024 implicit pointers to a local copy of a dispatch table, and these pointers
8025 have representations which thus depend on a particular elaboration of the
8026 package. It is not easy to see how it would be possible to follow this
8027 advice without severely impacting efficiency of execution.
8029 @cindex Exception information
8030 @unnumberedsec 11.4.1(19): Exception Information
8033 @code{Exception_Message} by default and @code{Exception_Information}
8034 should produce information useful for
8035 debugging. @code{Exception_Message} should be short, about one
8036 line. @code{Exception_Information} can be long. @code{Exception_Message}
8037 should not include the
8038 @code{Exception_Name}. @code{Exception_Information} should include both
8039 the @code{Exception_Name} and the @code{Exception_Message}.
8041 Followed. For each exception that doesn't have a specified
8042 @code{Exception_Message}, the compiler generates one containing the location
8043 of the raise statement. This location has the form ``file:line'', where
8044 file is the short file name (without path information) and line is the line
8045 number in the file. Note that in the case of the Zero Cost Exception
8046 mechanism, these messages become redundant with the Exception_Information that
8047 contains a full backtrace of the calling sequence, so they are disabled.
8048 To disable explicitly the generation of the source location message, use the
8049 Pragma @code{Discard_Names}.
8051 @cindex Suppression of checks
8052 @cindex Checks, suppression of
8053 @unnumberedsec 11.5(28): Suppression of Checks
8056 The implementation should minimize the code executed for checks that
8057 have been suppressed.
8061 @cindex Representation clauses
8062 @unnumberedsec 13.1 (21-24): Representation Clauses
8065 The recommended level of support for all representation items is
8066 qualified as follows:
8070 An implementation need not support representation items containing
8071 non-static expressions, except that an implementation should support a
8072 representation item for a given entity if each non-static expression in
8073 the representation item is a name that statically denotes a constant
8074 declared before the entity.
8076 Followed. In fact, GNAT goes beyond the recommended level of support
8077 by allowing nonstatic expressions in some representation clauses even
8078 without the need to declare constants initialized with the values of
8082 @smallexample @c ada
8085 for Y'Address use X'Address;>>
8090 An implementation need not support a specification for the @code{Size}
8091 for a given composite subtype, nor the size or storage place for an
8092 object (including a component) of a given composite subtype, unless the
8093 constraints on the subtype and its composite subcomponents (if any) are
8094 all static constraints.
8096 Followed. Size Clauses are not permitted on non-static components, as
8101 An aliased component, or a component whose type is by-reference, should
8102 always be allocated at an addressable location.
8106 @cindex Packed types
8107 @unnumberedsec 13.2(6-8): Packed Types
8110 If a type is packed, then the implementation should try to minimize
8111 storage allocated to objects of the type, possibly at the expense of
8112 speed of accessing components, subject to reasonable complexity in
8113 addressing calculations.
8117 The recommended level of support pragma @code{Pack} is:
8119 For a packed record type, the components should be packed as tightly as
8120 possible subject to the Sizes of the component subtypes, and subject to
8121 any @code{record_representation_clause} that applies to the type; the
8122 implementation may, but need not, reorder components or cross aligned
8123 word boundaries to improve the packing. A component whose @code{Size} is
8124 greater than the word size may be allocated an integral number of words.
8126 Followed. Tight packing of arrays is supported for all component sizes
8127 up to 64-bits. If the array component size is 1 (that is to say, if
8128 the component is a boolean type or an enumeration type with two values)
8129 then values of the type are implicitly initialized to zero. This
8130 happens both for objects of the packed type, and for objects that have a
8131 subcomponent of the packed type.
8135 An implementation should support Address clauses for imported
8139 @cindex @code{Address} clauses
8140 @unnumberedsec 13.3(14-19): Address Clauses
8144 For an array @var{X}, @code{@var{X}'Address} should point at the first
8145 component of the array, and not at the array bounds.
8151 The recommended level of support for the @code{Address} attribute is:
8153 @code{@var{X}'Address} should produce a useful result if @var{X} is an
8154 object that is aliased or of a by-reference type, or is an entity whose
8155 @code{Address} has been specified.
8157 Followed. A valid address will be produced even if none of those
8158 conditions have been met. If necessary, the object is forced into
8159 memory to ensure the address is valid.
8163 An implementation should support @code{Address} clauses for imported
8170 Objects (including subcomponents) that are aliased or of a by-reference
8171 type should be allocated on storage element boundaries.
8177 If the @code{Address} of an object is specified, or it is imported or exported,
8178 then the implementation should not perform optimizations based on
8179 assumptions of no aliases.
8183 @cindex @code{Alignment} clauses
8184 @unnumberedsec 13.3(29-35): Alignment Clauses
8187 The recommended level of support for the @code{Alignment} attribute for
8190 An implementation should support specified Alignments that are factors
8191 and multiples of the number of storage elements per word, subject to the
8198 An implementation need not support specified @code{Alignment}s for
8199 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
8200 loaded and stored by available machine instructions.
8206 An implementation need not support specified @code{Alignment}s that are
8207 greater than the maximum @code{Alignment} the implementation ever returns by
8214 The recommended level of support for the @code{Alignment} attribute for
8217 Same as above, for subtypes, but in addition:
8223 For stand-alone library-level objects of statically constrained
8224 subtypes, the implementation should support all @code{Alignment}s
8225 supported by the target linker. For example, page alignment is likely to
8226 be supported for such objects, but not for subtypes.
8230 @cindex @code{Size} clauses
8231 @unnumberedsec 13.3(42-43): Size Clauses
8234 The recommended level of support for the @code{Size} attribute of
8237 A @code{Size} clause should be supported for an object if the specified
8238 @code{Size} is at least as large as its subtype's @code{Size}, and
8239 corresponds to a size in storage elements that is a multiple of the
8240 object's @code{Alignment} (if the @code{Alignment} is nonzero).
8244 @unnumberedsec 13.3(50-56): Size Clauses
8247 If the @code{Size} of a subtype is specified, and allows for efficient
8248 independent addressability (see 9.10) on the target architecture, then
8249 the @code{Size} of the following objects of the subtype should equal the
8250 @code{Size} of the subtype:
8252 Aliased objects (including components).
8258 @code{Size} clause on a composite subtype should not affect the
8259 internal layout of components.
8261 Followed. But note that this can be overridden by use of the implementation
8262 pragma Implicit_Packing in the case of packed arrays.
8266 The recommended level of support for the @code{Size} attribute of subtypes is:
8270 The @code{Size} (if not specified) of a static discrete or fixed point
8271 subtype should be the number of bits needed to represent each value
8272 belonging to the subtype using an unbiased representation, leaving space
8273 for a sign bit only if the subtype contains negative values. If such a
8274 subtype is a first subtype, then an implementation should support a
8275 specified @code{Size} for it that reflects this representation.
8281 For a subtype implemented with levels of indirection, the @code{Size}
8282 should include the size of the pointers, but not the size of what they
8287 @cindex @code{Component_Size} clauses
8288 @unnumberedsec 13.3(71-73): Component Size Clauses
8291 The recommended level of support for the @code{Component_Size}
8296 An implementation need not support specified @code{Component_Sizes} that are
8297 less than the @code{Size} of the component subtype.
8303 An implementation should support specified @code{Component_Size}s that
8304 are factors and multiples of the word size. For such
8305 @code{Component_Size}s, the array should contain no gaps between
8306 components. For other @code{Component_Size}s (if supported), the array
8307 should contain no gaps between components when packing is also
8308 specified; the implementation should forbid this combination in cases
8309 where it cannot support a no-gaps representation.
8313 @cindex Enumeration representation clauses
8314 @cindex Representation clauses, enumeration
8315 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
8318 The recommended level of support for enumeration representation clauses
8321 An implementation need not support enumeration representation clauses
8322 for boolean types, but should at minimum support the internal codes in
8323 the range @code{System.Min_Int.System.Max_Int}.
8327 @cindex Record representation clauses
8328 @cindex Representation clauses, records
8329 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
8332 The recommended level of support for
8333 @*@code{record_representation_clauses} is:
8335 An implementation should support storage places that can be extracted
8336 with a load, mask, shift sequence of machine code, and set with a load,
8337 shift, mask, store sequence, given the available machine instructions
8344 A storage place should be supported if its size is equal to the
8345 @code{Size} of the component subtype, and it starts and ends on a
8346 boundary that obeys the @code{Alignment} of the component subtype.
8352 If the default bit ordering applies to the declaration of a given type,
8353 then for a component whose subtype's @code{Size} is less than the word
8354 size, any storage place that does not cross an aligned word boundary
8355 should be supported.
8361 An implementation may reserve a storage place for the tag field of a
8362 tagged type, and disallow other components from overlapping that place.
8364 Followed. The storage place for the tag field is the beginning of the tagged
8365 record, and its size is Address'Size. GNAT will reject an explicit component
8366 clause for the tag field.
8370 An implementation need not support a @code{component_clause} for a
8371 component of an extension part if the storage place is not after the
8372 storage places of all components of the parent type, whether or not
8373 those storage places had been specified.
8375 Followed. The above advice on record representation clauses is followed,
8376 and all mentioned features are implemented.
8378 @cindex Storage place attributes
8379 @unnumberedsec 13.5.2(5): Storage Place Attributes
8382 If a component is represented using some form of pointer (such as an
8383 offset) to the actual data of the component, and this data is contiguous
8384 with the rest of the object, then the storage place attributes should
8385 reflect the place of the actual data, not the pointer. If a component is
8386 allocated discontinuously from the rest of the object, then a warning
8387 should be generated upon reference to one of its storage place
8390 Followed. There are no such components in GNAT@.
8392 @cindex Bit ordering
8393 @unnumberedsec 13.5.3(7-8): Bit Ordering
8396 The recommended level of support for the non-default bit ordering is:
8400 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
8401 should support the non-default bit ordering in addition to the default
8404 Followed. Word size does not equal storage size in this implementation.
8405 Thus non-default bit ordering is not supported.
8407 @cindex @code{Address}, as private type
8408 @unnumberedsec 13.7(37): Address as Private
8411 @code{Address} should be of a private type.
8415 @cindex Operations, on @code{Address}
8416 @cindex @code{Address}, operations of
8417 @unnumberedsec 13.7.1(16): Address Operations
8420 Operations in @code{System} and its children should reflect the target
8421 environment semantics as closely as is reasonable. For example, on most
8422 machines, it makes sense for address arithmetic to ``wrap around''.
8423 Operations that do not make sense should raise @code{Program_Error}.
8425 Followed. Address arithmetic is modular arithmetic that wraps around. No
8426 operation raises @code{Program_Error}, since all operations make sense.
8428 @cindex Unchecked conversion
8429 @unnumberedsec 13.9(14-17): Unchecked Conversion
8432 The @code{Size} of an array object should not include its bounds; hence,
8433 the bounds should not be part of the converted data.
8439 The implementation should not generate unnecessary run-time checks to
8440 ensure that the representation of @var{S} is a representation of the
8441 target type. It should take advantage of the permission to return by
8442 reference when possible. Restrictions on unchecked conversions should be
8443 avoided unless required by the target environment.
8445 Followed. There are no restrictions on unchecked conversion. A warning is
8446 generated if the source and target types do not have the same size since
8447 the semantics in this case may be target dependent.
8451 The recommended level of support for unchecked conversions is:
8455 Unchecked conversions should be supported and should be reversible in
8456 the cases where this clause defines the result. To enable meaningful use
8457 of unchecked conversion, a contiguous representation should be used for
8458 elementary subtypes, for statically constrained array subtypes whose
8459 component subtype is one of the subtypes described in this paragraph,
8460 and for record subtypes without discriminants whose component subtypes
8461 are described in this paragraph.
8465 @cindex Heap usage, implicit
8466 @unnumberedsec 13.11(23-25): Implicit Heap Usage
8469 An implementation should document any cases in which it dynamically
8470 allocates heap storage for a purpose other than the evaluation of an
8473 Followed, the only other points at which heap storage is dynamically
8474 allocated are as follows:
8478 At initial elaboration time, to allocate dynamically sized global
8482 To allocate space for a task when a task is created.
8485 To extend the secondary stack dynamically when needed. The secondary
8486 stack is used for returning variable length results.
8491 A default (implementation-provided) storage pool for an
8492 access-to-constant type should not have overhead to support deallocation of
8499 A storage pool for an anonymous access type should be created at the
8500 point of an allocator for the type, and be reclaimed when the designated
8501 object becomes inaccessible.
8505 @cindex Unchecked deallocation
8506 @unnumberedsec 13.11.2(17): Unchecked De-allocation
8509 For a standard storage pool, @code{Free} should actually reclaim the
8514 @cindex Stream oriented attributes
8515 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
8518 If a stream element is the same size as a storage element, then the
8519 normal in-memory representation should be used by @code{Read} and
8520 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
8521 should use the smallest number of stream elements needed to represent
8522 all values in the base range of the scalar type.
8525 Followed. By default, GNAT uses the interpretation suggested by AI-195,
8526 which specifies using the size of the first subtype.
8527 However, such an implementation is based on direct binary
8528 representations and is therefore target- and endianness-dependent.
8529 To address this issue, GNAT also supplies an alternate implementation
8530 of the stream attributes @code{Read} and @code{Write},
8531 which uses the target-independent XDR standard representation
8533 @cindex XDR representation
8534 @cindex @code{Read} attribute
8535 @cindex @code{Write} attribute
8536 @cindex Stream oriented attributes
8537 The XDR implementation is provided as an alternative body of the
8538 @code{System.Stream_Attributes} package, in the file
8539 @file{s-stratt-xdr.adb} in the GNAT library.
8540 There is no @file{s-stratt-xdr.ads} file.
8541 In order to install the XDR implementation, do the following:
8543 @item Replace the default implementation of the
8544 @code{System.Stream_Attributes} package with the XDR implementation.
8545 For example on a Unix platform issue the commands:
8547 $ mv s-stratt.adb s-stratt-default.adb
8548 $ mv s-stratt-xdr.adb s-stratt.adb
8552 Rebuild the GNAT run-time library as documented in
8553 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
8556 @unnumberedsec A.1(52): Names of Predefined Numeric Types
8559 If an implementation provides additional named predefined integer types,
8560 then the names should end with @samp{Integer} as in
8561 @samp{Long_Integer}. If an implementation provides additional named
8562 predefined floating point types, then the names should end with
8563 @samp{Float} as in @samp{Long_Float}.
8567 @findex Ada.Characters.Handling
8568 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
8571 If an implementation provides a localized definition of @code{Character}
8572 or @code{Wide_Character}, then the effects of the subprograms in
8573 @code{Characters.Handling} should reflect the localizations. See also
8576 Followed. GNAT provides no such localized definitions.
8578 @cindex Bounded-length strings
8579 @unnumberedsec A.4.4(106): Bounded-Length String Handling
8582 Bounded string objects should not be implemented by implicit pointers
8583 and dynamic allocation.
8585 Followed. No implicit pointers or dynamic allocation are used.
8587 @cindex Random number generation
8588 @unnumberedsec A.5.2(46-47): Random Number Generation
8591 Any storage associated with an object of type @code{Generator} should be
8592 reclaimed on exit from the scope of the object.
8598 If the generator period is sufficiently long in relation to the number
8599 of distinct initiator values, then each possible value of
8600 @code{Initiator} passed to @code{Reset} should initiate a sequence of
8601 random numbers that does not, in a practical sense, overlap the sequence
8602 initiated by any other value. If this is not possible, then the mapping
8603 between initiator values and generator states should be a rapidly
8604 varying function of the initiator value.
8606 Followed. The generator period is sufficiently long for the first
8607 condition here to hold true.
8609 @findex Get_Immediate
8610 @unnumberedsec A.10.7(23): @code{Get_Immediate}
8613 The @code{Get_Immediate} procedures should be implemented with
8614 unbuffered input. For a device such as a keyboard, input should be
8615 @dfn{available} if a key has already been typed, whereas for a disk
8616 file, input should always be available except at end of file. For a file
8617 associated with a keyboard-like device, any line-editing features of the
8618 underlying operating system should be disabled during the execution of
8619 @code{Get_Immediate}.
8621 Followed on all targets except VxWorks. For VxWorks, there is no way to
8622 provide this functionality that does not result in the input buffer being
8623 flushed before the @code{Get_Immediate} call. A special unit
8624 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
8628 @unnumberedsec B.1(39-41): Pragma @code{Export}
8631 If an implementation supports pragma @code{Export} to a given language,
8632 then it should also allow the main subprogram to be written in that
8633 language. It should support some mechanism for invoking the elaboration
8634 of the Ada library units included in the system, and for invoking the
8635 finalization of the environment task. On typical systems, the
8636 recommended mechanism is to provide two subprograms whose link names are
8637 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
8638 elaboration code for library units. @code{adafinal} should contain the
8639 finalization code. These subprograms should have no effect the second
8640 and subsequent time they are called.
8646 Automatic elaboration of pre-elaborated packages should be
8647 provided when pragma @code{Export} is supported.
8649 Followed when the main program is in Ada. If the main program is in a
8650 foreign language, then
8651 @code{adainit} must be called to elaborate pre-elaborated
8656 For each supported convention @var{L} other than @code{Intrinsic}, an
8657 implementation should support @code{Import} and @code{Export} pragmas
8658 for objects of @var{L}-compatible types and for subprograms, and pragma
8659 @code{Convention} for @var{L}-eligible types and for subprograms,
8660 presuming the other language has corresponding features. Pragma
8661 @code{Convention} need not be supported for scalar types.
8665 @cindex Package @code{Interfaces}
8667 @unnumberedsec B.2(12-13): Package @code{Interfaces}
8670 For each implementation-defined convention identifier, there should be a
8671 child package of package Interfaces with the corresponding name. This
8672 package should contain any declarations that would be useful for
8673 interfacing to the language (implementation) represented by the
8674 convention. Any declarations useful for interfacing to any language on
8675 the given hardware architecture should be provided directly in
8678 Followed. An additional package not defined
8679 in the Ada Reference Manual is @code{Interfaces.CPP}, used
8680 for interfacing to C++.
8684 An implementation supporting an interface to C, COBOL, or Fortran should
8685 provide the corresponding package or packages described in the following
8688 Followed. GNAT provides all the packages described in this section.
8690 @cindex C, interfacing with
8691 @unnumberedsec B.3(63-71): Interfacing with C
8694 An implementation should support the following interface correspondences
8701 An Ada procedure corresponds to a void-returning C function.
8707 An Ada function corresponds to a non-void C function.
8713 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
8720 An Ada @code{in} parameter of an access-to-object type with designated
8721 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
8722 where @var{t} is the C type corresponding to the Ada type @var{T}.
8728 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
8729 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
8730 argument to a C function, where @var{t} is the C type corresponding to
8731 the Ada type @var{T}. In the case of an elementary @code{out} or
8732 @code{in out} parameter, a pointer to a temporary copy is used to
8733 preserve by-copy semantics.
8739 An Ada parameter of a record type @var{T}, of any mode, is passed as a
8740 @code{@var{t}*} argument to a C function, where @var{t} is the C
8741 structure corresponding to the Ada type @var{T}.
8743 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
8744 pragma, or Convention, or by explicitly specifying the mechanism for a given
8745 call using an extended import or export pragma.
8749 An Ada parameter of an array type with component type @var{T}, of any
8750 mode, is passed as a @code{@var{t}*} argument to a C function, where
8751 @var{t} is the C type corresponding to the Ada type @var{T}.
8757 An Ada parameter of an access-to-subprogram type is passed as a pointer
8758 to a C function whose prototype corresponds to the designated
8759 subprogram's specification.
8763 @cindex COBOL, interfacing with
8764 @unnumberedsec B.4(95-98): Interfacing with COBOL
8767 An Ada implementation should support the following interface
8768 correspondences between Ada and COBOL@.
8774 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
8775 the COBOL type corresponding to @var{T}.
8781 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
8782 the corresponding COBOL type.
8788 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
8789 COBOL type corresponding to the Ada parameter type; for scalars, a local
8790 copy is used if necessary to ensure by-copy semantics.
8794 @cindex Fortran, interfacing with
8795 @unnumberedsec B.5(22-26): Interfacing with Fortran
8798 An Ada implementation should support the following interface
8799 correspondences between Ada and Fortran:
8805 An Ada procedure corresponds to a Fortran subroutine.
8811 An Ada function corresponds to a Fortran function.
8817 An Ada parameter of an elementary, array, or record type @var{T} is
8818 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
8819 the Fortran type corresponding to the Ada type @var{T}, and where the
8820 INTENT attribute of the corresponding dummy argument matches the Ada
8821 formal parameter mode; the Fortran implementation's parameter passing
8822 conventions are used. For elementary types, a local copy is used if
8823 necessary to ensure by-copy semantics.
8829 An Ada parameter of an access-to-subprogram type is passed as a
8830 reference to a Fortran procedure whose interface corresponds to the
8831 designated subprogram's specification.
8835 @cindex Machine operations
8836 @unnumberedsec C.1(3-5): Access to Machine Operations
8839 The machine code or intrinsic support should allow access to all
8840 operations normally available to assembly language programmers for the
8841 target environment, including privileged instructions, if any.
8847 The interfacing pragmas (see Annex B) should support interface to
8848 assembler; the default assembler should be associated with the
8849 convention identifier @code{Assembler}.
8855 If an entity is exported to assembly language, then the implementation
8856 should allocate it at an addressable location, and should ensure that it
8857 is retained by the linking process, even if not otherwise referenced
8858 from the Ada code. The implementation should assume that any call to a
8859 machine code or assembler subprogram is allowed to read or update every
8860 object that is specified as exported.
8864 @unnumberedsec C.1(10-16): Access to Machine Operations
8867 The implementation should ensure that little or no overhead is
8868 associated with calling intrinsic and machine-code subprograms.
8870 Followed for both intrinsics and machine-code subprograms.
8874 It is recommended that intrinsic subprograms be provided for convenient
8875 access to any machine operations that provide special capabilities or
8876 efficiency and that are not otherwise available through the language
8879 Followed. A full set of machine operation intrinsic subprograms is provided.
8883 Atomic read-modify-write operations---e.g.@:, test and set, compare and
8884 swap, decrement and test, enqueue/dequeue.
8886 Followed on any target supporting such operations.
8890 Standard numeric functions---e.g.@:, sin, log.
8892 Followed on any target supporting such operations.
8896 String manipulation operations---e.g.@:, translate and test.
8898 Followed on any target supporting such operations.
8902 Vector operations---e.g.@:, compare vector against thresholds.
8904 Followed on any target supporting such operations.
8908 Direct operations on I/O ports.
8910 Followed on any target supporting such operations.
8912 @cindex Interrupt support
8913 @unnumberedsec C.3(28): Interrupt Support
8916 If the @code{Ceiling_Locking} policy is not in effect, the
8917 implementation should provide means for the application to specify which
8918 interrupts are to be blocked during protected actions, if the underlying
8919 system allows for a finer-grain control of interrupt blocking.
8921 Followed. The underlying system does not allow for finer-grain control
8922 of interrupt blocking.
8924 @cindex Protected procedure handlers
8925 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
8928 Whenever possible, the implementation should allow interrupt handlers to
8929 be called directly by the hardware.
8933 This is never possible under IRIX, so this is followed by default.
8935 Followed on any target where the underlying operating system permits
8940 Whenever practical, violations of any
8941 implementation-defined restrictions should be detected before run time.
8943 Followed. Compile time warnings are given when possible.
8945 @cindex Package @code{Interrupts}
8947 @unnumberedsec C.3.2(25): Package @code{Interrupts}
8951 If implementation-defined forms of interrupt handler procedures are
8952 supported, such as protected procedures with parameters, then for each
8953 such form of a handler, a type analogous to @code{Parameterless_Handler}
8954 should be specified in a child package of @code{Interrupts}, with the
8955 same operations as in the predefined package Interrupts.
8959 @cindex Pre-elaboration requirements
8960 @unnumberedsec C.4(14): Pre-elaboration Requirements
8963 It is recommended that pre-elaborated packages be implemented in such a
8964 way that there should be little or no code executed at run time for the
8965 elaboration of entities not already covered by the Implementation
8968 Followed. Executable code is generated in some cases, e.g.@: loops
8969 to initialize large arrays.
8971 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
8974 If the pragma applies to an entity, then the implementation should
8975 reduce the amount of storage used for storing names associated with that
8980 @cindex Package @code{Task_Attributes}
8981 @findex Task_Attributes
8982 @unnumberedsec C.7.2(30): The Package Task_Attributes
8985 Some implementations are targeted to domains in which memory use at run
8986 time must be completely deterministic. For such implementations, it is
8987 recommended that the storage for task attributes will be pre-allocated
8988 statically and not from the heap. This can be accomplished by either
8989 placing restrictions on the number and the size of the task's
8990 attributes, or by using the pre-allocated storage for the first @var{N}
8991 attribute objects, and the heap for the others. In the latter case,
8992 @var{N} should be documented.
8994 Not followed. This implementation is not targeted to such a domain.
8996 @cindex Locking Policies
8997 @unnumberedsec D.3(17): Locking Policies
9001 The implementation should use names that end with @samp{_Locking} for
9002 locking policies defined by the implementation.
9004 Followed. Two implementation-defined locking policies are defined,
9005 whose names (@code{Inheritance_Locking} and
9006 @code{Concurrent_Readers_Locking}) follow this suggestion.
9008 @cindex Entry queuing policies
9009 @unnumberedsec D.4(16): Entry Queuing Policies
9012 Names that end with @samp{_Queuing} should be used
9013 for all implementation-defined queuing policies.
9015 Followed. No such implementation-defined queuing policies exist.
9017 @cindex Preemptive abort
9018 @unnumberedsec D.6(9-10): Preemptive Abort
9021 Even though the @code{abort_statement} is included in the list of
9022 potentially blocking operations (see 9.5.1), it is recommended that this
9023 statement be implemented in a way that never requires the task executing
9024 the @code{abort_statement} to block.
9030 On a multi-processor, the delay associated with aborting a task on
9031 another processor should be bounded; the implementation should use
9032 periodic polling, if necessary, to achieve this.
9036 @cindex Tasking restrictions
9037 @unnumberedsec D.7(21): Tasking Restrictions
9040 When feasible, the implementation should take advantage of the specified
9041 restrictions to produce a more efficient implementation.
9043 GNAT currently takes advantage of these restrictions by providing an optimized
9044 run time when the Ravenscar profile and the GNAT restricted run time set
9045 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
9046 pragma @code{Profile (Restricted)} for more details.
9048 @cindex Time, monotonic
9049 @unnumberedsec D.8(47-49): Monotonic Time
9052 When appropriate, implementations should provide configuration
9053 mechanisms to change the value of @code{Tick}.
9055 Such configuration mechanisms are not appropriate to this implementation
9056 and are thus not supported.
9060 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
9061 be implemented as transformations of the same time base.
9067 It is recommended that the @dfn{best} time base which exists in
9068 the underlying system be available to the application through
9069 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
9073 @cindex Partition communication subsystem
9075 @unnumberedsec E.5(28-29): Partition Communication Subsystem
9078 Whenever possible, the PCS on the called partition should allow for
9079 multiple tasks to call the RPC-receiver with different messages and
9080 should allow them to block until the corresponding subprogram body
9083 Followed by GLADE, a separately supplied PCS that can be used with
9088 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
9089 should raise @code{Storage_Error} if it runs out of space trying to
9090 write the @code{Item} into the stream.
9092 Followed by GLADE, a separately supplied PCS that can be used with
9095 @cindex COBOL support
9096 @unnumberedsec F(7): COBOL Support
9099 If COBOL (respectively, C) is widely supported in the target
9100 environment, implementations supporting the Information Systems Annex
9101 should provide the child package @code{Interfaces.COBOL} (respectively,
9102 @code{Interfaces.C}) specified in Annex B and should support a
9103 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
9104 pragmas (see Annex B), thus allowing Ada programs to interface with
9105 programs written in that language.
9109 @cindex Decimal radix support
9110 @unnumberedsec F.1(2): Decimal Radix Support
9113 Packed decimal should be used as the internal representation for objects
9114 of subtype @var{S} when @var{S}'Machine_Radix = 10.
9116 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
9120 @unnumberedsec G: Numerics
9123 If Fortran (respectively, C) is widely supported in the target
9124 environment, implementations supporting the Numerics Annex
9125 should provide the child package @code{Interfaces.Fortran} (respectively,
9126 @code{Interfaces.C}) specified in Annex B and should support a
9127 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
9128 pragmas (see Annex B), thus allowing Ada programs to interface with
9129 programs written in that language.
9133 @cindex Complex types
9134 @unnumberedsec G.1.1(56-58): Complex Types
9137 Because the usual mathematical meaning of multiplication of a complex
9138 operand and a real operand is that of the scaling of both components of
9139 the former by the latter, an implementation should not perform this
9140 operation by first promoting the real operand to complex type and then
9141 performing a full complex multiplication. In systems that, in the
9142 future, support an Ada binding to IEC 559:1989, the latter technique
9143 will not generate the required result when one of the components of the
9144 complex operand is infinite. (Explicit multiplication of the infinite
9145 component by the zero component obtained during promotion yields a NaN
9146 that propagates into the final result.) Analogous advice applies in the
9147 case of multiplication of a complex operand and a pure-imaginary
9148 operand, and in the case of division of a complex operand by a real or
9149 pure-imaginary operand.
9155 Similarly, because the usual mathematical meaning of addition of a
9156 complex operand and a real operand is that the imaginary operand remains
9157 unchanged, an implementation should not perform this operation by first
9158 promoting the real operand to complex type and then performing a full
9159 complex addition. In implementations in which the @code{Signed_Zeros}
9160 attribute of the component type is @code{True} (and which therefore
9161 conform to IEC 559:1989 in regard to the handling of the sign of zero in
9162 predefined arithmetic operations), the latter technique will not
9163 generate the required result when the imaginary component of the complex
9164 operand is a negatively signed zero. (Explicit addition of the negative
9165 zero to the zero obtained during promotion yields a positive zero.)
9166 Analogous advice applies in the case of addition of a complex operand
9167 and a pure-imaginary operand, and in the case of subtraction of a
9168 complex operand and a real or pure-imaginary operand.
9174 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
9175 attempt to provide a rational treatment of the signs of zero results and
9176 result components. As one example, the result of the @code{Argument}
9177 function should have the sign of the imaginary component of the
9178 parameter @code{X} when the point represented by that parameter lies on
9179 the positive real axis; as another, the sign of the imaginary component
9180 of the @code{Compose_From_Polar} function should be the same as
9181 (respectively, the opposite of) that of the @code{Argument} parameter when that
9182 parameter has a value of zero and the @code{Modulus} parameter has a
9183 nonnegative (respectively, negative) value.
9187 @cindex Complex elementary functions
9188 @unnumberedsec G.1.2(49): Complex Elementary Functions
9191 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
9192 @code{True} should attempt to provide a rational treatment of the signs
9193 of zero results and result components. For example, many of the complex
9194 elementary functions have components that are odd functions of one of
9195 the parameter components; in these cases, the result component should
9196 have the sign of the parameter component at the origin. Other complex
9197 elementary functions have zero components whose sign is opposite that of
9198 a parameter component at the origin, or is always positive or always
9203 @cindex Accuracy requirements
9204 @unnumberedsec G.2.4(19): Accuracy Requirements
9207 The versions of the forward trigonometric functions without a
9208 @code{Cycle} parameter should not be implemented by calling the
9209 corresponding version with a @code{Cycle} parameter of
9210 @code{2.0*Numerics.Pi}, since this will not provide the required
9211 accuracy in some portions of the domain. For the same reason, the
9212 version of @code{Log} without a @code{Base} parameter should not be
9213 implemented by calling the corresponding version with a @code{Base}
9214 parameter of @code{Numerics.e}.
9218 @cindex Complex arithmetic accuracy
9219 @cindex Accuracy, complex arithmetic
9220 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
9224 The version of the @code{Compose_From_Polar} function without a
9225 @code{Cycle} parameter should not be implemented by calling the
9226 corresponding version with a @code{Cycle} parameter of
9227 @code{2.0*Numerics.Pi}, since this will not provide the required
9228 accuracy in some portions of the domain.
9232 @c -----------------------------------------
9233 @node Implementation Defined Characteristics
9234 @chapter Implementation Defined Characteristics
9237 In addition to the implementation dependent pragmas and attributes, and the
9238 implementation advice, there are a number of other Ada features that are
9239 potentially implementation dependent and are designated as
9240 implementation-defined. These are mentioned throughout the Ada Reference
9241 Manual, and are summarized in Annex M@.
9243 A requirement for conforming Ada compilers is that they provide
9244 documentation describing how the implementation deals with each of these
9245 issues. In this chapter, you will find each point in Annex M listed
9246 followed by a description in italic font of how GNAT
9250 implementation on IRIX 5.3 operating system or greater
9252 handles the implementation dependence.
9254 You can use this chapter as a guide to minimizing implementation
9255 dependent features in your programs if portability to other compilers
9256 and other operating systems is an important consideration. The numbers
9257 in each section below correspond to the paragraph number in the Ada
9263 @strong{2}. Whether or not each recommendation given in Implementation
9264 Advice is followed. See 1.1.2(37).
9267 @xref{Implementation Advice}.
9272 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
9275 The complexity of programs that can be processed is limited only by the
9276 total amount of available virtual memory, and disk space for the
9277 generated object files.
9282 @strong{4}. Variations from the standard that are impractical to avoid
9283 given the implementation's execution environment. See 1.1.3(6).
9286 There are no variations from the standard.
9291 @strong{5}. Which @code{code_statement}s cause external
9292 interactions. See 1.1.3(10).
9295 Any @code{code_statement} can potentially cause external interactions.
9300 @strong{6}. The coded representation for the text of an Ada
9301 program. See 2.1(4).
9304 See separate section on source representation.
9309 @strong{7}. The control functions allowed in comments. See 2.1(14).
9312 See separate section on source representation.
9317 @strong{8}. The representation for an end of line. See 2.2(2).
9320 See separate section on source representation.
9325 @strong{9}. Maximum supported line length and lexical element
9326 length. See 2.2(15).
9329 The maximum line length is 255 characters and the maximum length of a
9330 lexical element is also 255 characters.
9335 @strong{10}. Implementation defined pragmas. See 2.8(14).
9339 @xref{Implementation Defined Pragmas}.
9344 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
9347 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
9348 parameter, checks that the optimization flag is set, and aborts if it is
9354 @strong{12}. The sequence of characters of the value returned by
9355 @code{@var{S}'Image} when some of the graphic characters of
9356 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
9360 The sequence of characters is as defined by the wide character encoding
9361 method used for the source. See section on source representation for
9367 @strong{13}. The predefined integer types declared in
9368 @code{Standard}. See 3.5.4(25).
9372 @item Short_Short_Integer
9375 (Short) 16 bit signed
9379 64 bit signed (on most 64 bit targets, depending on the C definition of long).
9380 32 bit signed (all other targets)
9381 @item Long_Long_Integer
9388 @strong{14}. Any nonstandard integer types and the operators defined
9389 for them. See 3.5.4(26).
9392 There are no nonstandard integer types.
9397 @strong{15}. Any nonstandard real types and the operators defined for
9401 There are no nonstandard real types.
9406 @strong{16}. What combinations of requested decimal precision and range
9407 are supported for floating point types. See 3.5.7(7).
9410 The precision and range is as defined by the IEEE standard.
9415 @strong{17}. The predefined floating point types declared in
9416 @code{Standard}. See 3.5.7(16).
9423 (Short) 32 bit IEEE short
9426 @item Long_Long_Float
9427 64 bit IEEE long (80 bit IEEE long on x86 processors)
9433 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
9436 @code{Fine_Delta} is 2**(@minus{}63)
9441 @strong{19}. What combinations of small, range, and digits are
9442 supported for fixed point types. See 3.5.9(10).
9445 Any combinations are permitted that do not result in a small less than
9446 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
9447 If the mantissa is larger than 53 bits on machines where Long_Long_Float
9448 is 64 bits (true of all architectures except ia32), then the output from
9449 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
9450 is because floating-point conversions are used to convert fixed point.
9455 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
9456 within an unnamed @code{block_statement}. See 3.9(10).
9459 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
9460 decimal integer are allocated.
9465 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
9468 @xref{Implementation Defined Attributes}.
9473 @strong{22}. Any implementation-defined time types. See 9.6(6).
9476 There are no implementation-defined time types.
9481 @strong{23}. The time base associated with relative delays.
9484 See 9.6(20). The time base used is that provided by the C library
9485 function @code{gettimeofday}.
9490 @strong{24}. The time base of the type @code{Calendar.Time}. See
9494 The time base used is that provided by the C library function
9495 @code{gettimeofday}.
9500 @strong{25}. The time zone used for package @code{Calendar}
9501 operations. See 9.6(24).
9504 The time zone used by package @code{Calendar} is the current system time zone
9505 setting for local time, as accessed by the C library function
9511 @strong{26}. Any limit on @code{delay_until_statements} of
9512 @code{select_statements}. See 9.6(29).
9515 There are no such limits.
9520 @strong{27}. Whether or not two non-overlapping parts of a composite
9521 object are independently addressable, in the case where packing, record
9522 layout, or @code{Component_Size} is specified for the object. See
9526 Separate components are independently addressable if they do not share
9527 overlapping storage units.
9532 @strong{28}. The representation for a compilation. See 10.1(2).
9535 A compilation is represented by a sequence of files presented to the
9536 compiler in a single invocation of the @command{gcc} command.
9541 @strong{29}. Any restrictions on compilations that contain multiple
9542 compilation_units. See 10.1(4).
9545 No single file can contain more than one compilation unit, but any
9546 sequence of files can be presented to the compiler as a single
9552 @strong{30}. The mechanisms for creating an environment and for adding
9553 and replacing compilation units. See 10.1.4(3).
9556 See separate section on compilation model.
9561 @strong{31}. The manner of explicitly assigning library units to a
9562 partition. See 10.2(2).
9565 If a unit contains an Ada main program, then the Ada units for the partition
9566 are determined by recursive application of the rules in the Ada Reference
9567 Manual section 10.2(2-6). In other words, the Ada units will be those that
9568 are needed by the main program, and then this definition of need is applied
9569 recursively to those units, and the partition contains the transitive
9570 closure determined by this relationship. In short, all the necessary units
9571 are included, with no need to explicitly specify the list. If additional
9572 units are required, e.g.@: by foreign language units, then all units must be
9573 mentioned in the context clause of one of the needed Ada units.
9575 If the partition contains no main program, or if the main program is in
9576 a language other than Ada, then GNAT
9577 provides the binder options @option{-z} and @option{-n} respectively, and in
9578 this case a list of units can be explicitly supplied to the binder for
9579 inclusion in the partition (all units needed by these units will also
9580 be included automatically). For full details on the use of these
9581 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
9582 @value{EDITION} User's Guide}.
9587 @strong{32}. The implementation-defined means, if any, of specifying
9588 which compilation units are needed by a given compilation unit. See
9592 The units needed by a given compilation unit are as defined in
9593 the Ada Reference Manual section 10.2(2-6). There are no
9594 implementation-defined pragmas or other implementation-defined
9595 means for specifying needed units.
9600 @strong{33}. The manner of designating the main subprogram of a
9601 partition. See 10.2(7).
9604 The main program is designated by providing the name of the
9605 corresponding @file{ALI} file as the input parameter to the binder.
9610 @strong{34}. The order of elaboration of @code{library_items}. See
9614 The first constraint on ordering is that it meets the requirements of
9615 Chapter 10 of the Ada Reference Manual. This still leaves some
9616 implementation dependent choices, which are resolved by first
9617 elaborating bodies as early as possible (i.e., in preference to specs
9618 where there is a choice), and second by evaluating the immediate with
9619 clauses of a unit to determine the probably best choice, and
9620 third by elaborating in alphabetical order of unit names
9621 where a choice still remains.
9626 @strong{35}. Parameter passing and function return for the main
9627 subprogram. See 10.2(21).
9630 The main program has no parameters. It may be a procedure, or a function
9631 returning an integer type. In the latter case, the returned integer
9632 value is the return code of the program (overriding any value that
9633 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
9638 @strong{36}. The mechanisms for building and running partitions. See
9642 GNAT itself supports programs with only a single partition. The GNATDIST
9643 tool provided with the GLADE package (which also includes an implementation
9644 of the PCS) provides a completely flexible method for building and running
9645 programs consisting of multiple partitions. See the separate GLADE manual
9651 @strong{37}. The details of program execution, including program
9652 termination. See 10.2(25).
9655 See separate section on compilation model.
9660 @strong{38}. The semantics of any non-active partitions supported by the
9661 implementation. See 10.2(28).
9664 Passive partitions are supported on targets where shared memory is
9665 provided by the operating system. See the GLADE reference manual for
9671 @strong{39}. The information returned by @code{Exception_Message}. See
9675 Exception message returns the null string unless a specific message has
9676 been passed by the program.
9681 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
9682 declared within an unnamed @code{block_statement}. See 11.4.1(12).
9685 Blocks have implementation defined names of the form @code{B@var{nnn}}
9686 where @var{nnn} is an integer.
9691 @strong{41}. The information returned by
9692 @code{Exception_Information}. See 11.4.1(13).
9695 @code{Exception_Information} returns a string in the following format:
9698 @emph{Exception_Name:} nnnnn
9699 @emph{Message:} mmmmm
9701 @emph{Call stack traceback locations:}
9702 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
9710 @code{nnnn} is the fully qualified name of the exception in all upper
9711 case letters. This line is always present.
9714 @code{mmmm} is the message (this line present only if message is non-null)
9717 @code{ppp} is the Process Id value as a decimal integer (this line is
9718 present only if the Process Id is nonzero). Currently we are
9719 not making use of this field.
9722 The Call stack traceback locations line and the following values
9723 are present only if at least one traceback location was recorded.
9724 The values are given in C style format, with lower case letters
9725 for a-f, and only as many digits present as are necessary.
9729 The line terminator sequence at the end of each line, including
9730 the last line is a single @code{LF} character (@code{16#0A#}).
9735 @strong{42}. Implementation-defined check names. See 11.5(27).
9738 The implementation defined check name Alignment_Check controls checking of
9739 address clause values for proper alignment (that is, the address supplied
9740 must be consistent with the alignment of the type).
9742 In addition, a user program can add implementation-defined check names
9743 by means of the pragma Check_Name.
9748 @strong{43}. The interpretation of each aspect of representation. See
9752 See separate section on data representations.
9757 @strong{44}. Any restrictions placed upon representation items. See
9761 See separate section on data representations.
9766 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
9770 Size for an indefinite subtype is the maximum possible size, except that
9771 for the case of a subprogram parameter, the size of the parameter object
9777 @strong{46}. The default external representation for a type tag. See
9781 The default external representation for a type tag is the fully expanded
9782 name of the type in upper case letters.
9787 @strong{47}. What determines whether a compilation unit is the same in
9788 two different partitions. See 13.3(76).
9791 A compilation unit is the same in two different partitions if and only
9792 if it derives from the same source file.
9797 @strong{48}. Implementation-defined components. See 13.5.1(15).
9800 The only implementation defined component is the tag for a tagged type,
9801 which contains a pointer to the dispatching table.
9806 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
9807 ordering. See 13.5.3(5).
9810 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
9811 implementation, so no non-default bit ordering is supported. The default
9812 bit ordering corresponds to the natural endianness of the target architecture.
9817 @strong{50}. The contents of the visible part of package @code{System}
9818 and its language-defined children. See 13.7(2).
9821 See the definition of these packages in files @file{system.ads} and
9822 @file{s-stoele.ads}.
9827 @strong{51}. The contents of the visible part of package
9828 @code{System.Machine_Code}, and the meaning of
9829 @code{code_statements}. See 13.8(7).
9832 See the definition and documentation in file @file{s-maccod.ads}.
9837 @strong{52}. The effect of unchecked conversion. See 13.9(11).
9840 Unchecked conversion between types of the same size
9841 results in an uninterpreted transmission of the bits from one type
9842 to the other. If the types are of unequal sizes, then in the case of
9843 discrete types, a shorter source is first zero or sign extended as
9844 necessary, and a shorter target is simply truncated on the left.
9845 For all non-discrete types, the source is first copied if necessary
9846 to ensure that the alignment requirements of the target are met, then
9847 a pointer is constructed to the source value, and the result is obtained
9848 by dereferencing this pointer after converting it to be a pointer to the
9849 target type. Unchecked conversions where the target subtype is an
9850 unconstrained array are not permitted. If the target alignment is
9851 greater than the source alignment, then a copy of the result is
9852 made with appropriate alignment
9857 @strong{53}. The semantics of operations on invalid representations.
9861 For assignments and other operations where the use of invalid values cannot
9862 result in erroneous behavior, the compiler ignores the possibility of invalid
9863 values. An exception is raised at the point where an invalid value would
9864 result in erroneous behavior. For example executing:
9866 @smallexample @c ada
9867 procedure invalidvals is
9869 Y : Natural range 1 .. 10;
9870 for Y'Address use X'Address;
9871 Z : Natural range 1 .. 10;
9872 A : array (Natural range 1 .. 10) of Integer;
9874 Z := Y; -- no exception
9875 A (Z) := 3; -- exception raised;
9880 As indicated, an exception is raised on the array assignment, but not
9881 on the simple assignment of the invalid negative value from Y to Z.
9886 @strong{53}. The manner of choosing a storage pool for an access type
9887 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
9890 There are 3 different standard pools used by the compiler when
9891 @code{Storage_Pool} is not specified depending whether the type is local
9892 to a subprogram or defined at the library level and whether
9893 @code{Storage_Size}is specified or not. See documentation in the runtime
9894 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
9895 @code{System.Pool_Local} in files @file{s-poosiz.ads},
9896 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
9902 @strong{54}. Whether or not the implementation provides user-accessible
9903 names for the standard pool type(s). See 13.11(17).
9907 See documentation in the sources of the run time mentioned in paragraph
9908 @strong{53} . All these pools are accessible by means of @code{with}'ing
9914 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
9917 @code{Storage_Size} is measured in storage units, and refers to the
9918 total space available for an access type collection, or to the primary
9919 stack space for a task.
9924 @strong{56}. Implementation-defined aspects of storage pools. See
9928 See documentation in the sources of the run time mentioned in paragraph
9929 @strong{53} for details on GNAT-defined aspects of storage pools.
9934 @strong{57}. The set of restrictions allowed in a pragma
9935 @code{Restrictions}. See 13.12(7).
9938 @xref{Implementation Defined Restrictions}.
9943 @strong{58}. The consequences of violating limitations on
9944 @code{Restrictions} pragmas. See 13.12(9).
9947 Restrictions that can be checked at compile time result in illegalities
9948 if violated. Currently there are no other consequences of violating
9954 @strong{59}. The representation used by the @code{Read} and
9955 @code{Write} attributes of elementary types in terms of stream
9956 elements. See 13.13.2(9).
9959 The representation is the in-memory representation of the base type of
9960 the type, using the number of bits corresponding to the
9961 @code{@var{type}'Size} value, and the natural ordering of the machine.
9966 @strong{60}. The names and characteristics of the numeric subtypes
9967 declared in the visible part of package @code{Standard}. See A.1(3).
9970 See items describing the integer and floating-point types supported.
9975 @strong{61}. The accuracy actually achieved by the elementary
9976 functions. See A.5.1(1).
9979 The elementary functions correspond to the functions available in the C
9980 library. Only fast math mode is implemented.
9985 @strong{62}. The sign of a zero result from some of the operators or
9986 functions in @code{Numerics.Generic_Elementary_Functions}, when
9987 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
9990 The sign of zeroes follows the requirements of the IEEE 754 standard on
9996 @strong{63}. The value of
9997 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
10000 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10005 @strong{64}. The value of
10006 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
10009 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10014 @strong{65}. The algorithms for random number generation. See
10018 The algorithm is the Mersenne Twister, as documented in the source file
10019 @file{s-rannum.adb}. This version of the algorithm has a period of
10025 @strong{66}. The string representation of a random number generator's
10026 state. See A.5.2(38).
10029 The value returned by the Image function is the concatenation of
10030 the fixed-width decimal representations of the 624 32-bit integers
10031 of the state vector.
10036 @strong{67}. The minimum time interval between calls to the
10037 time-dependent Reset procedure that are guaranteed to initiate different
10038 random number sequences. See A.5.2(45).
10041 The minimum period between reset calls to guarantee distinct series of
10042 random numbers is one microsecond.
10047 @strong{68}. The values of the @code{Model_Mantissa},
10048 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
10049 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
10050 Annex is not supported. See A.5.3(72).
10053 Run the compiler with @option{-gnatS} to produce a listing of package
10054 @code{Standard}, has the values of all numeric attributes.
10059 @strong{69}. Any implementation-defined characteristics of the
10060 input-output packages. See A.7(14).
10063 There are no special implementation defined characteristics for these
10069 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
10073 All type representations are contiguous, and the @code{Buffer_Size} is
10074 the value of @code{@var{type}'Size} rounded up to the next storage unit
10080 @strong{71}. External files for standard input, standard output, and
10081 standard error See A.10(5).
10084 These files are mapped onto the files provided by the C streams
10085 libraries. See source file @file{i-cstrea.ads} for further details.
10090 @strong{72}. The accuracy of the value produced by @code{Put}. See
10094 If more digits are requested in the output than are represented by the
10095 precision of the value, zeroes are output in the corresponding least
10096 significant digit positions.
10101 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
10102 @code{Command_Name}. See A.15(1).
10105 These are mapped onto the @code{argv} and @code{argc} parameters of the
10106 main program in the natural manner.
10111 @strong{74}. The interpretation of the @code{Form} parameter in procedure
10112 @code{Create_Directory}. See A.16(56).
10115 The @code{Form} parameter is not used.
10120 @strong{75}. The interpretation of the @code{Form} parameter in procedure
10121 @code{Create_Path}. See A.16(60).
10124 The @code{Form} parameter is not used.
10129 @strong{76}. The interpretation of the @code{Form} parameter in procedure
10130 @code{Copy_File}. See A.16(68).
10133 The @code{Form} parameter is case-insensitive.
10135 Two fields are recognized in the @code{Form} parameter:
10139 @item preserve=<value>
10146 <value> starts immediately after the character '=' and ends with the
10147 character immediately preceding the next comma (',') or with the last
10148 character of the parameter.
10150 The only possible values for preserve= are:
10154 @item no_attributes
10155 Do not try to preserve any file attributes. This is the default if no
10156 preserve= is found in Form.
10158 @item all_attributes
10159 Try to preserve all file attributes (timestamps, access rights).
10162 Preserve the timestamp of the copied file, but not the other file attributes.
10167 The only possible values for mode= are:
10172 Only do the copy if the destination file does not already exist. If it already
10173 exists, Copy_File fails.
10176 Copy the file in all cases. Overwrite an already existing destination file.
10179 Append the original file to the destination file. If the destination file does
10180 not exist, the destination file is a copy of the source file. When mode=append,
10181 the field preserve=, if it exists, is not taken into account.
10186 If the Form parameter includes one or both of the fields and the value or
10187 values are incorrect, Copy_file fails with Use_Error.
10189 Examples of correct Forms:
10192 Form => "preserve=no_attributes,mode=overwrite" (the default)
10193 Form => "mode=append"
10194 Form => "mode=copy, preserve=all_attributes"
10198 Examples of incorrect Forms
10201 Form => "preserve=junk"
10202 Form => "mode=internal, preserve=timestamps"
10208 @strong{77}. Implementation-defined convention names. See B.1(11).
10211 The following convention names are supported
10216 @item Ada_Pass_By_Copy
10217 Allowed for any types except by-reference types such as limited
10218 records. Compatible with convention Ada, but causes any parameters
10219 with this convention to be passed by copy.
10220 @item Ada_Pass_By_Reference
10221 Allowed for any types except by-copy types such as scalars.
10222 Compatible with convention Ada, but causes any parameters
10223 with this convention to be passed by reference.
10227 Synonym for Assembler
10229 Synonym for Assembler
10232 @item C_Pass_By_Copy
10233 Allowed only for record types, like C, but also notes that record
10234 is to be passed by copy rather than reference.
10237 @item C_Plus_Plus (or CPP)
10240 Treated the same as C
10242 Treated the same as C
10246 For support of pragma @code{Import} with convention Intrinsic, see
10247 separate section on Intrinsic Subprograms.
10249 Stdcall (used for Windows implementations only). This convention correspond
10250 to the WINAPI (previously called Pascal convention) C/C++ convention under
10251 Windows. A routine with this convention cleans the stack before
10252 exit. This pragma cannot be applied to a dispatching call.
10254 Synonym for Stdcall
10256 Synonym for Stdcall
10258 Stubbed is a special convention used to indicate that the body of the
10259 subprogram will be entirely ignored. Any call to the subprogram
10260 is converted into a raise of the @code{Program_Error} exception. If a
10261 pragma @code{Import} specifies convention @code{stubbed} then no body need
10262 be present at all. This convention is useful during development for the
10263 inclusion of subprograms whose body has not yet been written.
10267 In addition, all otherwise unrecognized convention names are also
10268 treated as being synonymous with convention C@. In all implementations
10269 except for VMS, use of such other names results in a warning. In VMS
10270 implementations, these names are accepted silently.
10275 @strong{78}. The meaning of link names. See B.1(36).
10278 Link names are the actual names used by the linker.
10283 @strong{79}. The manner of choosing link names when neither the link
10284 name nor the address of an imported or exported entity is specified. See
10288 The default linker name is that which would be assigned by the relevant
10289 external language, interpreting the Ada name as being in all lower case
10295 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
10298 The string passed to @code{Linker_Options} is presented uninterpreted as
10299 an argument to the link command, unless it contains ASCII.NUL characters.
10300 NUL characters if they appear act as argument separators, so for example
10302 @smallexample @c ada
10303 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
10307 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
10308 linker. The order of linker options is preserved for a given unit. The final
10309 list of options passed to the linker is in reverse order of the elaboration
10310 order. For example, linker options for a body always appear before the options
10311 from the corresponding package spec.
10316 @strong{81}. The contents of the visible part of package
10317 @code{Interfaces} and its language-defined descendants. See B.2(1).
10320 See files with prefix @file{i-} in the distributed library.
10325 @strong{82}. Implementation-defined children of package
10326 @code{Interfaces}. The contents of the visible part of package
10327 @code{Interfaces}. See B.2(11).
10330 See files with prefix @file{i-} in the distributed library.
10335 @strong{83}. The types @code{Floating}, @code{Long_Floating},
10336 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
10337 @code{COBOL_Character}; and the initialization of the variables
10338 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
10339 @code{Interfaces.COBOL}. See B.4(50).
10345 @item Long_Floating
10346 (Floating) Long_Float
10351 @item Decimal_Element
10353 @item COBOL_Character
10358 For initialization, see the file @file{i-cobol.ads} in the distributed library.
10363 @strong{84}. Support for access to machine instructions. See C.1(1).
10366 See documentation in file @file{s-maccod.ads} in the distributed library.
10371 @strong{85}. Implementation-defined aspects of access to machine
10372 operations. See C.1(9).
10375 See documentation in file @file{s-maccod.ads} in the distributed library.
10380 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
10383 Interrupts are mapped to signals or conditions as appropriate. See
10385 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
10386 on the interrupts supported on a particular target.
10391 @strong{87}. Implementation-defined aspects of pre-elaboration. See
10395 GNAT does not permit a partition to be restarted without reloading,
10396 except under control of the debugger.
10401 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
10404 Pragma @code{Discard_Names} causes names of enumeration literals to
10405 be suppressed. In the presence of this pragma, the Image attribute
10406 provides the image of the Pos of the literal, and Value accepts
10412 @strong{89}. The result of the @code{Task_Identification.Image}
10413 attribute. See C.7.1(7).
10416 The result of this attribute is a string that identifies
10417 the object or component that denotes a given task. If a variable @code{Var}
10418 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
10420 is the hexadecimal representation of the virtual address of the corresponding
10421 task control block. If the variable is an array of tasks, the image of each
10422 task will have the form of an indexed component indicating the position of a
10423 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
10424 component of a record, the image of the task will have the form of a selected
10425 component. These rules are fully recursive, so that the image of a task that
10426 is a subcomponent of a composite object corresponds to the expression that
10427 designates this task.
10429 If a task is created by an allocator, its image depends on the context. If the
10430 allocator is part of an object declaration, the rules described above are used
10431 to construct its image, and this image is not affected by subsequent
10432 assignments. If the allocator appears within an expression, the image
10433 includes only the name of the task type.
10435 If the configuration pragma Discard_Names is present, or if the restriction
10436 No_Implicit_Heap_Allocation is in effect, the image reduces to
10437 the numeric suffix, that is to say the hexadecimal representation of the
10438 virtual address of the control block of the task.
10442 @strong{90}. The value of @code{Current_Task} when in a protected entry
10443 or interrupt handler. See C.7.1(17).
10446 Protected entries or interrupt handlers can be executed by any
10447 convenient thread, so the value of @code{Current_Task} is undefined.
10452 @strong{91}. The effect of calling @code{Current_Task} from an entry
10453 body or interrupt handler. See C.7.1(19).
10456 The effect of calling @code{Current_Task} from an entry body or
10457 interrupt handler is to return the identification of the task currently
10458 executing the code.
10463 @strong{92}. Implementation-defined aspects of
10464 @code{Task_Attributes}. See C.7.2(19).
10467 There are no implementation-defined aspects of @code{Task_Attributes}.
10472 @strong{93}. Values of all @code{Metrics}. See D(2).
10475 The metrics information for GNAT depends on the performance of the
10476 underlying operating system. The sources of the run-time for tasking
10477 implementation, together with the output from @option{-gnatG} can be
10478 used to determine the exact sequence of operating systems calls made
10479 to implement various tasking constructs. Together with appropriate
10480 information on the performance of the underlying operating system,
10481 on the exact target in use, this information can be used to determine
10482 the required metrics.
10487 @strong{94}. The declarations of @code{Any_Priority} and
10488 @code{Priority}. See D.1(11).
10491 See declarations in file @file{system.ads}.
10496 @strong{95}. Implementation-defined execution resources. See D.1(15).
10499 There are no implementation-defined execution resources.
10504 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
10505 access to a protected object keeps its processor busy. See D.2.1(3).
10508 On a multi-processor, a task that is waiting for access to a protected
10509 object does not keep its processor busy.
10514 @strong{97}. The affect of implementation defined execution resources
10515 on task dispatching. See D.2.1(9).
10520 Tasks map to IRIX threads, and the dispatching policy is as defined by
10521 the IRIX implementation of threads.
10523 Tasks map to threads in the threads package used by GNAT@. Where possible
10524 and appropriate, these threads correspond to native threads of the
10525 underlying operating system.
10530 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
10531 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
10534 There are no implementation-defined policy-identifiers allowed in this
10540 @strong{99}. Implementation-defined aspects of priority inversion. See
10544 Execution of a task cannot be preempted by the implementation processing
10545 of delay expirations for lower priority tasks.
10550 @strong{100}. Implementation-defined task dispatching. See D.2.2(18).
10555 Tasks map to IRIX threads, and the dispatching policy is as defined by
10556 the IRIX implementation of threads.
10558 The policy is the same as that of the underlying threads implementation.
10563 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
10564 in a pragma @code{Locking_Policy}. See D.3(4).
10567 The two implementation defined policies permitted in GNAT are
10568 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
10569 targets that support the @code{Inheritance_Locking} policy, locking is
10570 implemented by inheritance, i.e.@: the task owning the lock operates
10571 at a priority equal to the highest priority of any task currently
10572 requesting the lock. On targets that support the
10573 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
10574 read/write lock allowing multiple propected object functions to enter
10580 @strong{102}. Default ceiling priorities. See D.3(10).
10583 The ceiling priority of protected objects of the type
10584 @code{System.Interrupt_Priority'Last} as described in the Ada
10585 Reference Manual D.3(10),
10590 @strong{103}. The ceiling of any protected object used internally by
10591 the implementation. See D.3(16).
10594 The ceiling priority of internal protected objects is
10595 @code{System.Priority'Last}.
10600 @strong{104}. Implementation-defined queuing policies. See D.4(1).
10603 There are no implementation-defined queuing policies.
10608 @strong{105}. On a multiprocessor, any conditions that cause the
10609 completion of an aborted construct to be delayed later than what is
10610 specified for a single processor. See D.6(3).
10613 The semantics for abort on a multi-processor is the same as on a single
10614 processor, there are no further delays.
10619 @strong{106}. Any operations that implicitly require heap storage
10620 allocation. See D.7(8).
10623 The only operation that implicitly requires heap storage allocation is
10629 @strong{107}. Implementation-defined aspects of pragma
10630 @code{Restrictions}. See D.7(20).
10633 There are no such implementation-defined aspects.
10638 @strong{108}. Implementation-defined aspects of package
10639 @code{Real_Time}. See D.8(17).
10642 There are no implementation defined aspects of package @code{Real_Time}.
10647 @strong{109}. Implementation-defined aspects of
10648 @code{delay_statements}. See D.9(8).
10651 Any difference greater than one microsecond will cause the task to be
10652 delayed (see D.9(7)).
10657 @strong{110}. The upper bound on the duration of interrupt blocking
10658 caused by the implementation. See D.12(5).
10661 The upper bound is determined by the underlying operating system. In
10662 no cases is it more than 10 milliseconds.
10667 @strong{111}. The means for creating and executing distributed
10668 programs. See E(5).
10671 The GLADE package provides a utility GNATDIST for creating and executing
10672 distributed programs. See the GLADE reference manual for further details.
10677 @strong{112}. Any events that can result in a partition becoming
10678 inaccessible. See E.1(7).
10681 See the GLADE reference manual for full details on such events.
10686 @strong{113}. The scheduling policies, treatment of priorities, and
10687 management of shared resources between partitions in certain cases. See
10691 See the GLADE reference manual for full details on these aspects of
10692 multi-partition execution.
10697 @strong{114}. Events that cause the version of a compilation unit to
10698 change. See E.3(5).
10701 Editing the source file of a compilation unit, or the source files of
10702 any units on which it is dependent in a significant way cause the version
10703 to change. No other actions cause the version number to change. All changes
10704 are significant except those which affect only layout, capitalization or
10710 @strong{115}. Whether the execution of the remote subprogram is
10711 immediately aborted as a result of cancellation. See E.4(13).
10714 See the GLADE reference manual for details on the effect of abort in
10715 a distributed application.
10720 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
10723 See the GLADE reference manual for a full description of all implementation
10724 defined aspects of the PCS@.
10729 @strong{117}. Implementation-defined interfaces in the PCS@. See
10733 See the GLADE reference manual for a full description of all
10734 implementation defined interfaces.
10739 @strong{118}. The values of named numbers in the package
10740 @code{Decimal}. See F.2(7).
10752 @item Max_Decimal_Digits
10759 @strong{119}. The value of @code{Max_Picture_Length} in the package
10760 @code{Text_IO.Editing}. See F.3.3(16).
10768 @strong{120}. The value of @code{Max_Picture_Length} in the package
10769 @code{Wide_Text_IO.Editing}. See F.3.4(5).
10777 @strong{121}. The accuracy actually achieved by the complex elementary
10778 functions and by other complex arithmetic operations. See G.1(1).
10781 Standard library functions are used for the complex arithmetic
10782 operations. Only fast math mode is currently supported.
10787 @strong{122}. The sign of a zero result (or a component thereof) from
10788 any operator or function in @code{Numerics.Generic_Complex_Types}, when
10789 @code{Real'Signed_Zeros} is True. See G.1.1(53).
10792 The signs of zero values are as recommended by the relevant
10793 implementation advice.
10798 @strong{123}. The sign of a zero result (or a component thereof) from
10799 any operator or function in
10800 @code{Numerics.Generic_Complex_Elementary_Functions}, when
10801 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
10804 The signs of zero values are as recommended by the relevant
10805 implementation advice.
10810 @strong{124}. Whether the strict mode or the relaxed mode is the
10811 default. See G.2(2).
10814 The strict mode is the default. There is no separate relaxed mode. GNAT
10815 provides a highly efficient implementation of strict mode.
10820 @strong{125}. The result interval in certain cases of fixed-to-float
10821 conversion. See G.2.1(10).
10824 For cases where the result interval is implementation dependent, the
10825 accuracy is that provided by performing all operations in 64-bit IEEE
10826 floating-point format.
10831 @strong{126}. The result of a floating point arithmetic operation in
10832 overflow situations, when the @code{Machine_Overflows} attribute of the
10833 result type is @code{False}. See G.2.1(13).
10836 Infinite and NaN values are produced as dictated by the IEEE
10837 floating-point standard.
10839 Note that on machines that are not fully compliant with the IEEE
10840 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
10841 must be used for achieving IEEE conforming behavior (although at the cost
10842 of a significant performance penalty), so infinite and NaN values are
10843 properly generated.
10848 @strong{127}. The result interval for division (or exponentiation by a
10849 negative exponent), when the floating point hardware implements division
10850 as multiplication by a reciprocal. See G.2.1(16).
10853 Not relevant, division is IEEE exact.
10858 @strong{128}. The definition of close result set, which determines the
10859 accuracy of certain fixed point multiplications and divisions. See
10863 Operations in the close result set are performed using IEEE long format
10864 floating-point arithmetic. The input operands are converted to
10865 floating-point, the operation is done in floating-point, and the result
10866 is converted to the target type.
10871 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
10872 point multiplication or division for which the result shall be in the
10873 perfect result set. See G.2.3(22).
10876 The result is only defined to be in the perfect result set if the result
10877 can be computed by a single scaling operation involving a scale factor
10878 representable in 64-bits.
10883 @strong{130}. The result of a fixed point arithmetic operation in
10884 overflow situations, when the @code{Machine_Overflows} attribute of the
10885 result type is @code{False}. See G.2.3(27).
10888 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
10894 @strong{131}. The result of an elementary function reference in
10895 overflow situations, when the @code{Machine_Overflows} attribute of the
10896 result type is @code{False}. See G.2.4(4).
10899 IEEE infinite and Nan values are produced as appropriate.
10904 @strong{132}. The value of the angle threshold, within which certain
10905 elementary functions, complex arithmetic operations, and complex
10906 elementary functions yield results conforming to a maximum relative
10907 error bound. See G.2.4(10).
10910 Information on this subject is not yet available.
10915 @strong{133}. The accuracy of certain elementary functions for
10916 parameters beyond the angle threshold. See G.2.4(10).
10919 Information on this subject is not yet available.
10924 @strong{134}. The result of a complex arithmetic operation or complex
10925 elementary function reference in overflow situations, when the
10926 @code{Machine_Overflows} attribute of the corresponding real type is
10927 @code{False}. See G.2.6(5).
10930 IEEE infinite and Nan values are produced as appropriate.
10935 @strong{135}. The accuracy of certain complex arithmetic operations and
10936 certain complex elementary functions for parameters (or components
10937 thereof) beyond the angle threshold. See G.2.6(8).
10940 Information on those subjects is not yet available.
10945 @strong{136}. Information regarding bounded errors and erroneous
10946 execution. See H.2(1).
10949 Information on this subject is not yet available.
10954 @strong{137}. Implementation-defined aspects of pragma
10955 @code{Inspection_Point}. See H.3.2(8).
10958 Pragma @code{Inspection_Point} ensures that the variable is live and can
10959 be examined by the debugger at the inspection point.
10964 @strong{138}. Implementation-defined aspects of pragma
10965 @code{Restrictions}. See H.4(25).
10968 There are no implementation-defined aspects of pragma @code{Restrictions}. The
10969 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
10970 generated code. Checks must suppressed by use of pragma @code{Suppress}.
10975 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
10979 There are no restrictions on pragma @code{Restrictions}.
10981 @node Intrinsic Subprograms
10982 @chapter Intrinsic Subprograms
10983 @cindex Intrinsic Subprograms
10986 * Intrinsic Operators::
10987 * Enclosing_Entity::
10988 * Exception_Information::
10989 * Exception_Message::
10993 * Shifts and Rotates::
10994 * Source_Location::
10998 GNAT allows a user application program to write the declaration:
11000 @smallexample @c ada
11001 pragma Import (Intrinsic, name);
11005 providing that the name corresponds to one of the implemented intrinsic
11006 subprograms in GNAT, and that the parameter profile of the referenced
11007 subprogram meets the requirements. This chapter describes the set of
11008 implemented intrinsic subprograms, and the requirements on parameter profiles.
11009 Note that no body is supplied; as with other uses of pragma Import, the
11010 body is supplied elsewhere (in this case by the compiler itself). Note
11011 that any use of this feature is potentially non-portable, since the
11012 Ada standard does not require Ada compilers to implement this feature.
11014 @node Intrinsic Operators
11015 @section Intrinsic Operators
11016 @cindex Intrinsic operator
11019 All the predefined numeric operators in package Standard
11020 in @code{pragma Import (Intrinsic,..)}
11021 declarations. In the binary operator case, the operands must have the same
11022 size. The operand or operands must also be appropriate for
11023 the operator. For example, for addition, the operands must
11024 both be floating-point or both be fixed-point, and the
11025 right operand for @code{"**"} must have a root type of
11026 @code{Standard.Integer'Base}.
11027 You can use an intrinsic operator declaration as in the following example:
11029 @smallexample @c ada
11030 type Int1 is new Integer;
11031 type Int2 is new Integer;
11033 function "+" (X1 : Int1; X2 : Int2) return Int1;
11034 function "+" (X1 : Int1; X2 : Int2) return Int2;
11035 pragma Import (Intrinsic, "+");
11039 This declaration would permit ``mixed mode'' arithmetic on items
11040 of the differing types @code{Int1} and @code{Int2}.
11041 It is also possible to specify such operators for private types, if the
11042 full views are appropriate arithmetic types.
11044 @node Enclosing_Entity
11045 @section Enclosing_Entity
11046 @cindex Enclosing_Entity
11048 This intrinsic subprogram is used in the implementation of the
11049 library routine @code{GNAT.Source_Info}. The only useful use of the
11050 intrinsic import in this case is the one in this unit, so an
11051 application program should simply call the function
11052 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
11053 the current subprogram, package, task, entry, or protected subprogram.
11055 @node Exception_Information
11056 @section Exception_Information
11057 @cindex Exception_Information'
11059 This intrinsic subprogram is used in the implementation of the
11060 library routine @code{GNAT.Current_Exception}. The only useful
11061 use of the intrinsic import in this case is the one in this unit,
11062 so an application program should simply call the function
11063 @code{GNAT.Current_Exception.Exception_Information} to obtain
11064 the exception information associated with the current exception.
11066 @node Exception_Message
11067 @section Exception_Message
11068 @cindex Exception_Message
11070 This intrinsic subprogram is used in the implementation of the
11071 library routine @code{GNAT.Current_Exception}. The only useful
11072 use of the intrinsic import in this case is the one in this unit,
11073 so an application program should simply call the function
11074 @code{GNAT.Current_Exception.Exception_Message} to obtain
11075 the message associated with the current exception.
11077 @node Exception_Name
11078 @section Exception_Name
11079 @cindex Exception_Name
11081 This intrinsic subprogram is used in the implementation of the
11082 library routine @code{GNAT.Current_Exception}. The only useful
11083 use of the intrinsic import in this case is the one in this unit,
11084 so an application program should simply call the function
11085 @code{GNAT.Current_Exception.Exception_Name} to obtain
11086 the name of the current exception.
11092 This intrinsic subprogram is used in the implementation of the
11093 library routine @code{GNAT.Source_Info}. The only useful use of the
11094 intrinsic import in this case is the one in this unit, so an
11095 application program should simply call the function
11096 @code{GNAT.Source_Info.File} to obtain the name of the current
11103 This intrinsic subprogram is used in the implementation of the
11104 library routine @code{GNAT.Source_Info}. The only useful use of the
11105 intrinsic import in this case is the one in this unit, so an
11106 application program should simply call the function
11107 @code{GNAT.Source_Info.Line} to obtain the number of the current
11110 @node Shifts and Rotates
11111 @section Shifts and Rotates
11113 @cindex Shift_Right
11114 @cindex Shift_Right_Arithmetic
11115 @cindex Rotate_Left
11116 @cindex Rotate_Right
11118 In standard Ada, the shift and rotate functions are available only
11119 for the predefined modular types in package @code{Interfaces}. However, in
11120 GNAT it is possible to define these functions for any integer
11121 type (signed or modular), as in this example:
11123 @smallexample @c ada
11124 function Shift_Left
11131 The function name must be one of
11132 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
11133 Rotate_Right. T must be an integer type. T'Size must be
11134 8, 16, 32 or 64 bits; if T is modular, the modulus
11135 must be 2**8, 2**16, 2**32 or 2**64.
11136 The result type must be the same as the type of @code{Value}.
11137 The shift amount must be Natural.
11138 The formal parameter names can be anything.
11140 @node Source_Location
11141 @section Source_Location
11142 @cindex Source_Location
11144 This intrinsic subprogram is used in the implementation of the
11145 library routine @code{GNAT.Source_Info}. The only useful use of the
11146 intrinsic import in this case is the one in this unit, so an
11147 application program should simply call the function
11148 @code{GNAT.Source_Info.Source_Location} to obtain the current
11149 source file location.
11151 @node Representation Clauses and Pragmas
11152 @chapter Representation Clauses and Pragmas
11153 @cindex Representation Clauses
11156 * Alignment Clauses::
11158 * Storage_Size Clauses::
11159 * Size of Variant Record Objects::
11160 * Biased Representation ::
11161 * Value_Size and Object_Size Clauses::
11162 * Component_Size Clauses::
11163 * Bit_Order Clauses::
11164 * Effect of Bit_Order on Byte Ordering::
11165 * Pragma Pack for Arrays::
11166 * Pragma Pack for Records::
11167 * Record Representation Clauses::
11168 * Enumeration Clauses::
11169 * Address Clauses::
11170 * Effect of Convention on Representation::
11171 * Determining the Representations chosen by GNAT::
11175 @cindex Representation Clause
11176 @cindex Representation Pragma
11177 @cindex Pragma, representation
11178 This section describes the representation clauses accepted by GNAT, and
11179 their effect on the representation of corresponding data objects.
11181 GNAT fully implements Annex C (Systems Programming). This means that all
11182 the implementation advice sections in chapter 13 are fully implemented.
11183 However, these sections only require a minimal level of support for
11184 representation clauses. GNAT provides much more extensive capabilities,
11185 and this section describes the additional capabilities provided.
11187 @node Alignment Clauses
11188 @section Alignment Clauses
11189 @cindex Alignment Clause
11192 GNAT requires that all alignment clauses specify a power of 2, and all
11193 default alignments are always a power of 2. The default alignment
11194 values are as follows:
11197 @item @emph{Primitive Types}.
11198 For primitive types, the alignment is the minimum of the actual size of
11199 objects of the type divided by @code{Storage_Unit},
11200 and the maximum alignment supported by the target.
11201 (This maximum alignment is given by the GNAT-specific attribute
11202 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
11203 @cindex @code{Maximum_Alignment} attribute
11204 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
11205 default alignment will be 8 on any target that supports alignments
11206 this large, but on some targets, the maximum alignment may be smaller
11207 than 8, in which case objects of type @code{Long_Float} will be maximally
11210 @item @emph{Arrays}.
11211 For arrays, the alignment is equal to the alignment of the component type
11212 for the normal case where no packing or component size is given. If the
11213 array is packed, and the packing is effective (see separate section on
11214 packed arrays), then the alignment will be one for long packed arrays,
11215 or arrays whose length is not known at compile time. For short packed
11216 arrays, which are handled internally as modular types, the alignment
11217 will be as described for primitive types, e.g.@: a packed array of length
11218 31 bits will have an object size of four bytes, and an alignment of 4.
11220 @item @emph{Records}.
11221 For the normal non-packed case, the alignment of a record is equal to
11222 the maximum alignment of any of its components. For tagged records, this
11223 includes the implicit access type used for the tag. If a pragma @code{Pack}
11224 is used and all components are packable (see separate section on pragma
11225 @code{Pack}), then the resulting alignment is 1, unless the layout of the
11226 record makes it profitable to increase it.
11228 A special case is when:
11231 the size of the record is given explicitly, or a
11232 full record representation clause is given, and
11234 the size of the record is 2, 4, or 8 bytes.
11237 In this case, an alignment is chosen to match the
11238 size of the record. For example, if we have:
11240 @smallexample @c ada
11241 type Small is record
11244 for Small'Size use 16;
11248 then the default alignment of the record type @code{Small} is 2, not 1. This
11249 leads to more efficient code when the record is treated as a unit, and also
11250 allows the type to specified as @code{Atomic} on architectures requiring
11256 An alignment clause may specify a larger alignment than the default value
11257 up to some maximum value dependent on the target (obtainable by using the
11258 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
11259 a smaller alignment than the default value for enumeration, integer and
11260 fixed point types, as well as for record types, for example
11262 @smallexample @c ada
11267 for V'alignment use 1;
11271 @cindex Alignment, default
11272 The default alignment for the type @code{V} is 4, as a result of the
11273 Integer field in the record, but it is permissible, as shown, to
11274 override the default alignment of the record with a smaller value.
11277 @section Size Clauses
11278 @cindex Size Clause
11281 The default size for a type @code{T} is obtainable through the
11282 language-defined attribute @code{T'Size} and also through the
11283 equivalent GNAT-defined attribute @code{T'Value_Size}.
11284 For objects of type @code{T}, GNAT will generally increase the type size
11285 so that the object size (obtainable through the GNAT-defined attribute
11286 @code{T'Object_Size})
11287 is a multiple of @code{T'Alignment * Storage_Unit}.
11290 @smallexample @c ada
11291 type Smallint is range 1 .. 6;
11300 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
11301 as specified by the RM rules,
11302 but objects of this type will have a size of 8
11303 (@code{Smallint'Object_Size} = 8),
11304 since objects by default occupy an integral number
11305 of storage units. On some targets, notably older
11306 versions of the Digital Alpha, the size of stand
11307 alone objects of this type may be 32, reflecting
11308 the inability of the hardware to do byte load/stores.
11310 Similarly, the size of type @code{Rec} is 40 bits
11311 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
11312 the alignment is 4, so objects of this type will have
11313 their size increased to 64 bits so that it is a multiple
11314 of the alignment (in bits). This decision is
11315 in accordance with the specific Implementation Advice in RM 13.3(43):
11318 A @code{Size} clause should be supported for an object if the specified
11319 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
11320 to a size in storage elements that is a multiple of the object's
11321 @code{Alignment} (if the @code{Alignment} is nonzero).
11325 An explicit size clause may be used to override the default size by
11326 increasing it. For example, if we have:
11328 @smallexample @c ada
11329 type My_Boolean is new Boolean;
11330 for My_Boolean'Size use 32;
11334 then values of this type will always be 32 bits long. In the case of
11335 discrete types, the size can be increased up to 64 bits, with the effect
11336 that the entire specified field is used to hold the value, sign- or
11337 zero-extended as appropriate. If more than 64 bits is specified, then
11338 padding space is allocated after the value, and a warning is issued that
11339 there are unused bits.
11341 Similarly the size of records and arrays may be increased, and the effect
11342 is to add padding bits after the value. This also causes a warning message
11345 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
11346 Size in bits, this corresponds to an object of size 256 megabytes (minus
11347 one). This limitation is true on all targets. The reason for this
11348 limitation is that it improves the quality of the code in many cases
11349 if it is known that a Size value can be accommodated in an object of
11352 @node Storage_Size Clauses
11353 @section Storage_Size Clauses
11354 @cindex Storage_Size Clause
11357 For tasks, the @code{Storage_Size} clause specifies the amount of space
11358 to be allocated for the task stack. This cannot be extended, and if the
11359 stack is exhausted, then @code{Storage_Error} will be raised (if stack
11360 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
11361 or a @code{Storage_Size} pragma in the task definition to set the
11362 appropriate required size. A useful technique is to include in every
11363 task definition a pragma of the form:
11365 @smallexample @c ada
11366 pragma Storage_Size (Default_Stack_Size);
11370 Then @code{Default_Stack_Size} can be defined in a global package, and
11371 modified as required. Any tasks requiring stack sizes different from the
11372 default can have an appropriate alternative reference in the pragma.
11374 You can also use the @option{-d} binder switch to modify the default stack
11377 For access types, the @code{Storage_Size} clause specifies the maximum
11378 space available for allocation of objects of the type. If this space is
11379 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
11380 In the case where the access type is declared local to a subprogram, the
11381 use of a @code{Storage_Size} clause triggers automatic use of a special
11382 predefined storage pool (@code{System.Pool_Size}) that ensures that all
11383 space for the pool is automatically reclaimed on exit from the scope in
11384 which the type is declared.
11386 A special case recognized by the compiler is the specification of a
11387 @code{Storage_Size} of zero for an access type. This means that no
11388 items can be allocated from the pool, and this is recognized at compile
11389 time, and all the overhead normally associated with maintaining a fixed
11390 size storage pool is eliminated. Consider the following example:
11392 @smallexample @c ada
11394 type R is array (Natural) of Character;
11395 type P is access all R;
11396 for P'Storage_Size use 0;
11397 -- Above access type intended only for interfacing purposes
11401 procedure g (m : P);
11402 pragma Import (C, g);
11413 As indicated in this example, these dummy storage pools are often useful in
11414 connection with interfacing where no object will ever be allocated. If you
11415 compile the above example, you get the warning:
11418 p.adb:16:09: warning: allocation from empty storage pool
11419 p.adb:16:09: warning: Storage_Error will be raised at run time
11423 Of course in practice, there will not be any explicit allocators in the
11424 case of such an access declaration.
11426 @node Size of Variant Record Objects
11427 @section Size of Variant Record Objects
11428 @cindex Size, variant record objects
11429 @cindex Variant record objects, size
11432 In the case of variant record objects, there is a question whether Size gives
11433 information about a particular variant, or the maximum size required
11434 for any variant. Consider the following program
11436 @smallexample @c ada
11437 with Text_IO; use Text_IO;
11439 type R1 (A : Boolean := False) is record
11441 when True => X : Character;
11442 when False => null;
11450 Put_Line (Integer'Image (V1'Size));
11451 Put_Line (Integer'Image (V2'Size));
11456 Here we are dealing with a variant record, where the True variant
11457 requires 16 bits, and the False variant requires 8 bits.
11458 In the above example, both V1 and V2 contain the False variant,
11459 which is only 8 bits long. However, the result of running the
11468 The reason for the difference here is that the discriminant value of
11469 V1 is fixed, and will always be False. It is not possible to assign
11470 a True variant value to V1, therefore 8 bits is sufficient. On the
11471 other hand, in the case of V2, the initial discriminant value is
11472 False (from the default), but it is possible to assign a True
11473 variant value to V2, therefore 16 bits must be allocated for V2
11474 in the general case, even fewer bits may be needed at any particular
11475 point during the program execution.
11477 As can be seen from the output of this program, the @code{'Size}
11478 attribute applied to such an object in GNAT gives the actual allocated
11479 size of the variable, which is the largest size of any of the variants.
11480 The Ada Reference Manual is not completely clear on what choice should
11481 be made here, but the GNAT behavior seems most consistent with the
11482 language in the RM@.
11484 In some cases, it may be desirable to obtain the size of the current
11485 variant, rather than the size of the largest variant. This can be
11486 achieved in GNAT by making use of the fact that in the case of a
11487 subprogram parameter, GNAT does indeed return the size of the current
11488 variant (because a subprogram has no way of knowing how much space
11489 is actually allocated for the actual).
11491 Consider the following modified version of the above program:
11493 @smallexample @c ada
11494 with Text_IO; use Text_IO;
11496 type R1 (A : Boolean := False) is record
11498 when True => X : Character;
11499 when False => null;
11505 function Size (V : R1) return Integer is
11511 Put_Line (Integer'Image (V2'Size));
11512 Put_Line (Integer'IMage (Size (V2)));
11514 Put_Line (Integer'Image (V2'Size));
11515 Put_Line (Integer'IMage (Size (V2)));
11520 The output from this program is
11530 Here we see that while the @code{'Size} attribute always returns
11531 the maximum size, regardless of the current variant value, the
11532 @code{Size} function does indeed return the size of the current
11535 @node Biased Representation
11536 @section Biased Representation
11537 @cindex Size for biased representation
11538 @cindex Biased representation
11541 In the case of scalars with a range starting at other than zero, it is
11542 possible in some cases to specify a size smaller than the default minimum
11543 value, and in such cases, GNAT uses an unsigned biased representation,
11544 in which zero is used to represent the lower bound, and successive values
11545 represent successive values of the type.
11547 For example, suppose we have the declaration:
11549 @smallexample @c ada
11550 type Small is range -7 .. -4;
11551 for Small'Size use 2;
11555 Although the default size of type @code{Small} is 4, the @code{Size}
11556 clause is accepted by GNAT and results in the following representation
11560 -7 is represented as 2#00#
11561 -6 is represented as 2#01#
11562 -5 is represented as 2#10#
11563 -4 is represented as 2#11#
11567 Biased representation is only used if the specified @code{Size} clause
11568 cannot be accepted in any other manner. These reduced sizes that force
11569 biased representation can be used for all discrete types except for
11570 enumeration types for which a representation clause is given.
11572 @node Value_Size and Object_Size Clauses
11573 @section Value_Size and Object_Size Clauses
11575 @findex Object_Size
11576 @cindex Size, of objects
11579 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
11580 number of bits required to hold values of type @code{T}.
11581 Although this interpretation was allowed in Ada 83, it was not required,
11582 and this requirement in practice can cause some significant difficulties.
11583 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
11584 However, in Ada 95 and Ada 2005,
11585 @code{Natural'Size} is
11586 typically 31. This means that code may change in behavior when moving
11587 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
11589 @smallexample @c ada
11590 type Rec is record;
11596 at 0 range 0 .. Natural'Size - 1;
11597 at 0 range Natural'Size .. 2 * Natural'Size - 1;
11602 In the above code, since the typical size of @code{Natural} objects
11603 is 32 bits and @code{Natural'Size} is 31, the above code can cause
11604 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
11605 there are cases where the fact that the object size can exceed the
11606 size of the type causes surprises.
11608 To help get around this problem GNAT provides two implementation
11609 defined attributes, @code{Value_Size} and @code{Object_Size}. When
11610 applied to a type, these attributes yield the size of the type
11611 (corresponding to the RM defined size attribute), and the size of
11612 objects of the type respectively.
11614 The @code{Object_Size} is used for determining the default size of
11615 objects and components. This size value can be referred to using the
11616 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
11617 the basis of the determination of the size. The backend is free to
11618 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
11619 character might be stored in 32 bits on a machine with no efficient
11620 byte access instructions such as the Alpha.
11622 The default rules for the value of @code{Object_Size} for
11623 discrete types are as follows:
11627 The @code{Object_Size} for base subtypes reflect the natural hardware
11628 size in bits (run the compiler with @option{-gnatS} to find those values
11629 for numeric types). Enumeration types and fixed-point base subtypes have
11630 8, 16, 32 or 64 bits for this size, depending on the range of values
11634 The @code{Object_Size} of a subtype is the same as the
11635 @code{Object_Size} of
11636 the type from which it is obtained.
11639 The @code{Object_Size} of a derived base type is copied from the parent
11640 base type, and the @code{Object_Size} of a derived first subtype is copied
11641 from the parent first subtype.
11645 The @code{Value_Size} attribute
11646 is the (minimum) number of bits required to store a value
11648 This value is used to determine how tightly to pack
11649 records or arrays with components of this type, and also affects
11650 the semantics of unchecked conversion (unchecked conversions where
11651 the @code{Value_Size} values differ generate a warning, and are potentially
11654 The default rules for the value of @code{Value_Size} are as follows:
11658 The @code{Value_Size} for a base subtype is the minimum number of bits
11659 required to store all values of the type (including the sign bit
11660 only if negative values are possible).
11663 If a subtype statically matches the first subtype of a given type, then it has
11664 by default the same @code{Value_Size} as the first subtype. This is a
11665 consequence of RM 13.1(14) (``if two subtypes statically match,
11666 then their subtype-specific aspects are the same''.)
11669 All other subtypes have a @code{Value_Size} corresponding to the minimum
11670 number of bits required to store all values of the subtype. For
11671 dynamic bounds, it is assumed that the value can range down or up
11672 to the corresponding bound of the ancestor
11676 The RM defined attribute @code{Size} corresponds to the
11677 @code{Value_Size} attribute.
11679 The @code{Size} attribute may be defined for a first-named subtype. This sets
11680 the @code{Value_Size} of
11681 the first-named subtype to the given value, and the
11682 @code{Object_Size} of this first-named subtype to the given value padded up
11683 to an appropriate boundary. It is a consequence of the default rules
11684 above that this @code{Object_Size} will apply to all further subtypes. On the
11685 other hand, @code{Value_Size} is affected only for the first subtype, any
11686 dynamic subtypes obtained from it directly, and any statically matching
11687 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
11689 @code{Value_Size} and
11690 @code{Object_Size} may be explicitly set for any subtype using
11691 an attribute definition clause. Note that the use of these attributes
11692 can cause the RM 13.1(14) rule to be violated. If two access types
11693 reference aliased objects whose subtypes have differing @code{Object_Size}
11694 values as a result of explicit attribute definition clauses, then it
11695 is erroneous to convert from one access subtype to the other.
11697 At the implementation level, Esize stores the Object_Size and the
11698 RM_Size field stores the @code{Value_Size} (and hence the value of the
11699 @code{Size} attribute,
11700 which, as noted above, is equivalent to @code{Value_Size}).
11702 To get a feel for the difference, consider the following examples (note
11703 that in each case the base is @code{Short_Short_Integer} with a size of 8):
11706 Object_Size Value_Size
11708 type x1 is range 0 .. 5; 8 3
11710 type x2 is range 0 .. 5;
11711 for x2'size use 12; 16 12
11713 subtype x3 is x2 range 0 .. 3; 16 2
11715 subtype x4 is x2'base range 0 .. 10; 8 4
11717 subtype x5 is x2 range 0 .. dynamic; 16 3*
11719 subtype x6 is x2'base range 0 .. dynamic; 8 3*
11724 Note: the entries marked ``3*'' are not actually specified by the Ada
11725 Reference Manual, but it seems in the spirit of the RM rules to allocate
11726 the minimum number of bits (here 3, given the range for @code{x2})
11727 known to be large enough to hold the given range of values.
11729 So far, so good, but GNAT has to obey the RM rules, so the question is
11730 under what conditions must the RM @code{Size} be used.
11731 The following is a list
11732 of the occasions on which the RM @code{Size} must be used:
11736 Component size for packed arrays or records
11739 Value of the attribute @code{Size} for a type
11742 Warning about sizes not matching for unchecked conversion
11746 For record types, the @code{Object_Size} is always a multiple of the
11747 alignment of the type (this is true for all types). In some cases the
11748 @code{Value_Size} can be smaller. Consider:
11758 On a typical 32-bit architecture, the X component will be four bytes, and
11759 require four-byte alignment, and the Y component will be one byte. In this
11760 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
11761 required to store a value of this type, and for example, it is permissible
11762 to have a component of type R in an outer array whose component size is
11763 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
11764 since it must be rounded up so that this value is a multiple of the
11765 alignment (4 bytes = 32 bits).
11768 For all other types, the @code{Object_Size}
11769 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
11770 Only @code{Size} may be specified for such types.
11772 @node Component_Size Clauses
11773 @section Component_Size Clauses
11774 @cindex Component_Size Clause
11777 Normally, the value specified in a component size clause must be consistent
11778 with the subtype of the array component with regard to size and alignment.
11779 In other words, the value specified must be at least equal to the size
11780 of this subtype, and must be a multiple of the alignment value.
11782 In addition, component size clauses are allowed which cause the array
11783 to be packed, by specifying a smaller value. A first case is for
11784 component size values in the range 1 through 63. The value specified
11785 must not be smaller than the Size of the subtype. GNAT will accurately
11786 honor all packing requests in this range. For example, if we have:
11788 @smallexample @c ada
11789 type r is array (1 .. 8) of Natural;
11790 for r'Component_Size use 31;
11794 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
11795 Of course access to the components of such an array is considerably
11796 less efficient than if the natural component size of 32 is used.
11797 A second case is when the subtype of the component is a record type
11798 padded because of its default alignment. For example, if we have:
11800 @smallexample @c ada
11807 type a is array (1 .. 8) of r;
11808 for a'Component_Size use 72;
11812 then the resulting array has a length of 72 bytes, instead of 96 bytes
11813 if the alignment of the record (4) was obeyed.
11815 Note that there is no point in giving both a component size clause
11816 and a pragma Pack for the same array type. if such duplicate
11817 clauses are given, the pragma Pack will be ignored.
11819 @node Bit_Order Clauses
11820 @section Bit_Order Clauses
11821 @cindex Bit_Order Clause
11822 @cindex bit ordering
11823 @cindex ordering, of bits
11826 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
11827 attribute. The specification may either correspond to the default bit
11828 order for the target, in which case the specification has no effect and
11829 places no additional restrictions, or it may be for the non-standard
11830 setting (that is the opposite of the default).
11832 In the case where the non-standard value is specified, the effect is
11833 to renumber bits within each byte, but the ordering of bytes is not
11834 affected. There are certain
11835 restrictions placed on component clauses as follows:
11839 @item Components fitting within a single storage unit.
11841 These are unrestricted, and the effect is merely to renumber bits. For
11842 example if we are on a little-endian machine with @code{Low_Order_First}
11843 being the default, then the following two declarations have exactly
11846 @smallexample @c ada
11849 B : Integer range 1 .. 120;
11853 A at 0 range 0 .. 0;
11854 B at 0 range 1 .. 7;
11859 B : Integer range 1 .. 120;
11862 for R2'Bit_Order use High_Order_First;
11865 A at 0 range 7 .. 7;
11866 B at 0 range 0 .. 6;
11871 The useful application here is to write the second declaration with the
11872 @code{Bit_Order} attribute definition clause, and know that it will be treated
11873 the same, regardless of whether the target is little-endian or big-endian.
11875 @item Components occupying an integral number of bytes.
11877 These are components that exactly fit in two or more bytes. Such component
11878 declarations are allowed, but have no effect, since it is important to realize
11879 that the @code{Bit_Order} specification does not affect the ordering of bytes.
11880 In particular, the following attempt at getting an endian-independent integer
11883 @smallexample @c ada
11888 for R2'Bit_Order use High_Order_First;
11891 A at 0 range 0 .. 31;
11896 This declaration will result in a little-endian integer on a
11897 little-endian machine, and a big-endian integer on a big-endian machine.
11898 If byte flipping is required for interoperability between big- and
11899 little-endian machines, this must be explicitly programmed. This capability
11900 is not provided by @code{Bit_Order}.
11902 @item Components that are positioned across byte boundaries
11904 but do not occupy an integral number of bytes. Given that bytes are not
11905 reordered, such fields would occupy a non-contiguous sequence of bits
11906 in memory, requiring non-trivial code to reassemble. They are for this
11907 reason not permitted, and any component clause specifying such a layout
11908 will be flagged as illegal by GNAT@.
11913 Since the misconception that Bit_Order automatically deals with all
11914 endian-related incompatibilities is a common one, the specification of
11915 a component field that is an integral number of bytes will always
11916 generate a warning. This warning may be suppressed using @code{pragma
11917 Warnings (Off)} if desired. The following section contains additional
11918 details regarding the issue of byte ordering.
11920 @node Effect of Bit_Order on Byte Ordering
11921 @section Effect of Bit_Order on Byte Ordering
11922 @cindex byte ordering
11923 @cindex ordering, of bytes
11926 In this section we will review the effect of the @code{Bit_Order} attribute
11927 definition clause on byte ordering. Briefly, it has no effect at all, but
11928 a detailed example will be helpful. Before giving this
11929 example, let us review the precise
11930 definition of the effect of defining @code{Bit_Order}. The effect of a
11931 non-standard bit order is described in section 15.5.3 of the Ada
11935 2 A bit ordering is a method of interpreting the meaning of
11936 the storage place attributes.
11940 To understand the precise definition of storage place attributes in
11941 this context, we visit section 13.5.1 of the manual:
11944 13 A record_representation_clause (without the mod_clause)
11945 specifies the layout. The storage place attributes (see 13.5.2)
11946 are taken from the values of the position, first_bit, and last_bit
11947 expressions after normalizing those values so that first_bit is
11948 less than Storage_Unit.
11952 The critical point here is that storage places are taken from
11953 the values after normalization, not before. So the @code{Bit_Order}
11954 interpretation applies to normalized values. The interpretation
11955 is described in the later part of the 15.5.3 paragraph:
11958 2 A bit ordering is a method of interpreting the meaning of
11959 the storage place attributes. High_Order_First (known in the
11960 vernacular as ``big endian'') means that the first bit of a
11961 storage element (bit 0) is the most significant bit (interpreting
11962 the sequence of bits that represent a component as an unsigned
11963 integer value). Low_Order_First (known in the vernacular as
11964 ``little endian'') means the opposite: the first bit is the
11969 Note that the numbering is with respect to the bits of a storage
11970 unit. In other words, the specification affects only the numbering
11971 of bits within a single storage unit.
11973 We can make the effect clearer by giving an example.
11975 Suppose that we have an external device which presents two bytes, the first
11976 byte presented, which is the first (low addressed byte) of the two byte
11977 record is called Master, and the second byte is called Slave.
11979 The left most (most significant bit is called Control for each byte, and
11980 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
11981 (least significant) bit.
11983 On a big-endian machine, we can write the following representation clause
11985 @smallexample @c ada
11986 type Data is record
11987 Master_Control : Bit;
11995 Slave_Control : Bit;
12005 for Data use record
12006 Master_Control at 0 range 0 .. 0;
12007 Master_V1 at 0 range 1 .. 1;
12008 Master_V2 at 0 range 2 .. 2;
12009 Master_V3 at 0 range 3 .. 3;
12010 Master_V4 at 0 range 4 .. 4;
12011 Master_V5 at 0 range 5 .. 5;
12012 Master_V6 at 0 range 6 .. 6;
12013 Master_V7 at 0 range 7 .. 7;
12014 Slave_Control at 1 range 0 .. 0;
12015 Slave_V1 at 1 range 1 .. 1;
12016 Slave_V2 at 1 range 2 .. 2;
12017 Slave_V3 at 1 range 3 .. 3;
12018 Slave_V4 at 1 range 4 .. 4;
12019 Slave_V5 at 1 range 5 .. 5;
12020 Slave_V6 at 1 range 6 .. 6;
12021 Slave_V7 at 1 range 7 .. 7;
12026 Now if we move this to a little endian machine, then the bit ordering within
12027 the byte is backwards, so we have to rewrite the record rep clause as:
12029 @smallexample @c ada
12030 for Data use record
12031 Master_Control at 0 range 7 .. 7;
12032 Master_V1 at 0 range 6 .. 6;
12033 Master_V2 at 0 range 5 .. 5;
12034 Master_V3 at 0 range 4 .. 4;
12035 Master_V4 at 0 range 3 .. 3;
12036 Master_V5 at 0 range 2 .. 2;
12037 Master_V6 at 0 range 1 .. 1;
12038 Master_V7 at 0 range 0 .. 0;
12039 Slave_Control at 1 range 7 .. 7;
12040 Slave_V1 at 1 range 6 .. 6;
12041 Slave_V2 at 1 range 5 .. 5;
12042 Slave_V3 at 1 range 4 .. 4;
12043 Slave_V4 at 1 range 3 .. 3;
12044 Slave_V5 at 1 range 2 .. 2;
12045 Slave_V6 at 1 range 1 .. 1;
12046 Slave_V7 at 1 range 0 .. 0;
12051 It is a nuisance to have to rewrite the clause, especially if
12052 the code has to be maintained on both machines. However,
12053 this is a case that we can handle with the
12054 @code{Bit_Order} attribute if it is implemented.
12055 Note that the implementation is not required on byte addressed
12056 machines, but it is indeed implemented in GNAT.
12057 This means that we can simply use the
12058 first record clause, together with the declaration
12060 @smallexample @c ada
12061 for Data'Bit_Order use High_Order_First;
12065 and the effect is what is desired, namely the layout is exactly the same,
12066 independent of whether the code is compiled on a big-endian or little-endian
12069 The important point to understand is that byte ordering is not affected.
12070 A @code{Bit_Order} attribute definition never affects which byte a field
12071 ends up in, only where it ends up in that byte.
12072 To make this clear, let us rewrite the record rep clause of the previous
12075 @smallexample @c ada
12076 for Data'Bit_Order use High_Order_First;
12077 for Data use record
12078 Master_Control at 0 range 0 .. 0;
12079 Master_V1 at 0 range 1 .. 1;
12080 Master_V2 at 0 range 2 .. 2;
12081 Master_V3 at 0 range 3 .. 3;
12082 Master_V4 at 0 range 4 .. 4;
12083 Master_V5 at 0 range 5 .. 5;
12084 Master_V6 at 0 range 6 .. 6;
12085 Master_V7 at 0 range 7 .. 7;
12086 Slave_Control at 0 range 8 .. 8;
12087 Slave_V1 at 0 range 9 .. 9;
12088 Slave_V2 at 0 range 10 .. 10;
12089 Slave_V3 at 0 range 11 .. 11;
12090 Slave_V4 at 0 range 12 .. 12;
12091 Slave_V5 at 0 range 13 .. 13;
12092 Slave_V6 at 0 range 14 .. 14;
12093 Slave_V7 at 0 range 15 .. 15;
12098 This is exactly equivalent to saying (a repeat of the first example):
12100 @smallexample @c ada
12101 for Data'Bit_Order use High_Order_First;
12102 for Data use record
12103 Master_Control at 0 range 0 .. 0;
12104 Master_V1 at 0 range 1 .. 1;
12105 Master_V2 at 0 range 2 .. 2;
12106 Master_V3 at 0 range 3 .. 3;
12107 Master_V4 at 0 range 4 .. 4;
12108 Master_V5 at 0 range 5 .. 5;
12109 Master_V6 at 0 range 6 .. 6;
12110 Master_V7 at 0 range 7 .. 7;
12111 Slave_Control at 1 range 0 .. 0;
12112 Slave_V1 at 1 range 1 .. 1;
12113 Slave_V2 at 1 range 2 .. 2;
12114 Slave_V3 at 1 range 3 .. 3;
12115 Slave_V4 at 1 range 4 .. 4;
12116 Slave_V5 at 1 range 5 .. 5;
12117 Slave_V6 at 1 range 6 .. 6;
12118 Slave_V7 at 1 range 7 .. 7;
12123 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
12124 field. The storage place attributes are obtained by normalizing the
12125 values given so that the @code{First_Bit} value is less than 8. After
12126 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
12127 we specified in the other case.
12129 Now one might expect that the @code{Bit_Order} attribute might affect
12130 bit numbering within the entire record component (two bytes in this
12131 case, thus affecting which byte fields end up in), but that is not
12132 the way this feature is defined, it only affects numbering of bits,
12133 not which byte they end up in.
12135 Consequently it never makes sense to specify a starting bit number
12136 greater than 7 (for a byte addressable field) if an attribute
12137 definition for @code{Bit_Order} has been given, and indeed it
12138 may be actively confusing to specify such a value, so the compiler
12139 generates a warning for such usage.
12141 If you do need to control byte ordering then appropriate conditional
12142 values must be used. If in our example, the slave byte came first on
12143 some machines we might write:
12145 @smallexample @c ada
12146 Master_Byte_First constant Boolean := @dots{};
12148 Master_Byte : constant Natural :=
12149 1 - Boolean'Pos (Master_Byte_First);
12150 Slave_Byte : constant Natural :=
12151 Boolean'Pos (Master_Byte_First);
12153 for Data'Bit_Order use High_Order_First;
12154 for Data use record
12155 Master_Control at Master_Byte range 0 .. 0;
12156 Master_V1 at Master_Byte range 1 .. 1;
12157 Master_V2 at Master_Byte range 2 .. 2;
12158 Master_V3 at Master_Byte range 3 .. 3;
12159 Master_V4 at Master_Byte range 4 .. 4;
12160 Master_V5 at Master_Byte range 5 .. 5;
12161 Master_V6 at Master_Byte range 6 .. 6;
12162 Master_V7 at Master_Byte range 7 .. 7;
12163 Slave_Control at Slave_Byte range 0 .. 0;
12164 Slave_V1 at Slave_Byte range 1 .. 1;
12165 Slave_V2 at Slave_Byte range 2 .. 2;
12166 Slave_V3 at Slave_Byte range 3 .. 3;
12167 Slave_V4 at Slave_Byte range 4 .. 4;
12168 Slave_V5 at Slave_Byte range 5 .. 5;
12169 Slave_V6 at Slave_Byte range 6 .. 6;
12170 Slave_V7 at Slave_Byte range 7 .. 7;
12175 Now to switch between machines, all that is necessary is
12176 to set the boolean constant @code{Master_Byte_First} in
12177 an appropriate manner.
12179 @node Pragma Pack for Arrays
12180 @section Pragma Pack for Arrays
12181 @cindex Pragma Pack (for arrays)
12184 Pragma @code{Pack} applied to an array has no effect unless the component type
12185 is packable. For a component type to be packable, it must be one of the
12192 Any type whose size is specified with a size clause
12194 Any packed array type with a static size
12196 Any record type padded because of its default alignment
12200 For all these cases, if the component subtype size is in the range
12201 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
12202 component size were specified giving the component subtype size.
12203 For example if we have:
12205 @smallexample @c ada
12206 type r is range 0 .. 17;
12208 type ar is array (1 .. 8) of r;
12213 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
12214 and the size of the array @code{ar} will be exactly 40 bits.
12216 Note that in some cases this rather fierce approach to packing can produce
12217 unexpected effects. For example, in Ada 95 and Ada 2005,
12218 subtype @code{Natural} typically has a size of 31, meaning that if you
12219 pack an array of @code{Natural}, you get 31-bit
12220 close packing, which saves a few bits, but results in far less efficient
12221 access. Since many other Ada compilers will ignore such a packing request,
12222 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
12223 might not be what is intended. You can easily remove this warning by
12224 using an explicit @code{Component_Size} setting instead, which never generates
12225 a warning, since the intention of the programmer is clear in this case.
12227 GNAT treats packed arrays in one of two ways. If the size of the array is
12228 known at compile time and is less than 64 bits, then internally the array
12229 is represented as a single modular type, of exactly the appropriate number
12230 of bits. If the length is greater than 63 bits, or is not known at compile
12231 time, then the packed array is represented as an array of bytes, and the
12232 length is always a multiple of 8 bits.
12234 Note that to represent a packed array as a modular type, the alignment must
12235 be suitable for the modular type involved. For example, on typical machines
12236 a 32-bit packed array will be represented by a 32-bit modular integer with
12237 an alignment of four bytes. If you explicitly override the default alignment
12238 with an alignment clause that is too small, the modular representation
12239 cannot be used. For example, consider the following set of declarations:
12241 @smallexample @c ada
12242 type R is range 1 .. 3;
12243 type S is array (1 .. 31) of R;
12244 for S'Component_Size use 2;
12246 for S'Alignment use 1;
12250 If the alignment clause were not present, then a 62-bit modular
12251 representation would be chosen (typically with an alignment of 4 or 8
12252 bytes depending on the target). But the default alignment is overridden
12253 with the explicit alignment clause. This means that the modular
12254 representation cannot be used, and instead the array of bytes
12255 representation must be used, meaning that the length must be a multiple
12256 of 8. Thus the above set of declarations will result in a diagnostic
12257 rejecting the size clause and noting that the minimum size allowed is 64.
12259 @cindex Pragma Pack (for type Natural)
12260 @cindex Pragma Pack warning
12262 One special case that is worth noting occurs when the base type of the
12263 component size is 8/16/32 and the subtype is one bit less. Notably this
12264 occurs with subtype @code{Natural}. Consider:
12266 @smallexample @c ada
12267 type Arr is array (1 .. 32) of Natural;
12272 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
12273 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
12274 Ada 83 compilers did not attempt 31 bit packing.
12276 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
12277 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
12278 substantial unintended performance penalty when porting legacy Ada 83 code.
12279 To help prevent this, GNAT generates a warning in such cases. If you really
12280 want 31 bit packing in a case like this, you can set the component size
12283 @smallexample @c ada
12284 type Arr is array (1 .. 32) of Natural;
12285 for Arr'Component_Size use 31;
12289 Here 31-bit packing is achieved as required, and no warning is generated,
12290 since in this case the programmer intention is clear.
12292 @node Pragma Pack for Records
12293 @section Pragma Pack for Records
12294 @cindex Pragma Pack (for records)
12297 Pragma @code{Pack} applied to a record will pack the components to reduce
12298 wasted space from alignment gaps and by reducing the amount of space
12299 taken by components. We distinguish between @emph{packable} components and
12300 @emph{non-packable} components.
12301 Components of the following types are considered packable:
12304 All primitive types are packable.
12307 Small packed arrays, whose size does not exceed 64 bits, and where the
12308 size is statically known at compile time, are represented internally
12309 as modular integers, and so they are also packable.
12314 All packable components occupy the exact number of bits corresponding to
12315 their @code{Size} value, and are packed with no padding bits, i.e.@: they
12316 can start on an arbitrary bit boundary.
12318 All other types are non-packable, they occupy an integral number of
12320 are placed at a boundary corresponding to their alignment requirements.
12322 For example, consider the record
12324 @smallexample @c ada
12325 type Rb1 is array (1 .. 13) of Boolean;
12328 type Rb2 is array (1 .. 65) of Boolean;
12343 The representation for the record x2 is as follows:
12345 @smallexample @c ada
12346 for x2'Size use 224;
12348 l1 at 0 range 0 .. 0;
12349 l2 at 0 range 1 .. 64;
12350 l3 at 12 range 0 .. 31;
12351 l4 at 16 range 0 .. 0;
12352 l5 at 16 range 1 .. 13;
12353 l6 at 18 range 0 .. 71;
12358 Studying this example, we see that the packable fields @code{l1}
12360 of length equal to their sizes, and placed at specific bit boundaries (and
12361 not byte boundaries) to
12362 eliminate padding. But @code{l3} is of a non-packable float type, so
12363 it is on the next appropriate alignment boundary.
12365 The next two fields are fully packable, so @code{l4} and @code{l5} are
12366 minimally packed with no gaps. However, type @code{Rb2} is a packed
12367 array that is longer than 64 bits, so it is itself non-packable. Thus
12368 the @code{l6} field is aligned to the next byte boundary, and takes an
12369 integral number of bytes, i.e.@: 72 bits.
12371 @node Record Representation Clauses
12372 @section Record Representation Clauses
12373 @cindex Record Representation Clause
12376 Record representation clauses may be given for all record types, including
12377 types obtained by record extension. Component clauses are allowed for any
12378 static component. The restrictions on component clauses depend on the type
12381 @cindex Component Clause
12382 For all components of an elementary type, the only restriction on component
12383 clauses is that the size must be at least the 'Size value of the type
12384 (actually the Value_Size). There are no restrictions due to alignment,
12385 and such components may freely cross storage boundaries.
12387 Packed arrays with a size up to and including 64 bits are represented
12388 internally using a modular type with the appropriate number of bits, and
12389 thus the same lack of restriction applies. For example, if you declare:
12391 @smallexample @c ada
12392 type R is array (1 .. 49) of Boolean;
12398 then a component clause for a component of type R may start on any
12399 specified bit boundary, and may specify a value of 49 bits or greater.
12401 For packed bit arrays that are longer than 64 bits, there are two
12402 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
12403 including the important case of single bits or boolean values, then
12404 there are no limitations on placement of such components, and they
12405 may start and end at arbitrary bit boundaries.
12407 If the component size is not a power of 2 (e.g.@: 3 or 5), then
12408 an array of this type longer than 64 bits must always be placed on
12409 on a storage unit (byte) boundary and occupy an integral number
12410 of storage units (bytes). Any component clause that does not
12411 meet this requirement will be rejected.
12413 Any aliased component, or component of an aliased type, must
12414 have its normal alignment and size. A component clause that
12415 does not meet this requirement will be rejected.
12417 The tag field of a tagged type always occupies an address sized field at
12418 the start of the record. No component clause may attempt to overlay this
12419 tag. When a tagged type appears as a component, the tag field must have
12422 In the case of a record extension T1, of a type T, no component clause applied
12423 to the type T1 can specify a storage location that would overlap the first
12424 T'Size bytes of the record.
12426 For all other component types, including non-bit-packed arrays,
12427 the component can be placed at an arbitrary bit boundary,
12428 so for example, the following is permitted:
12430 @smallexample @c ada
12431 type R is array (1 .. 10) of Boolean;
12440 G at 0 range 0 .. 0;
12441 H at 0 range 1 .. 1;
12442 L at 0 range 2 .. 81;
12443 R at 0 range 82 .. 161;
12448 Note: the above rules apply to recent releases of GNAT 5.
12449 In GNAT 3, there are more severe restrictions on larger components.
12450 For non-primitive types, including packed arrays with a size greater than
12451 64 bits, component clauses must respect the alignment requirement of the
12452 type, in particular, always starting on a byte boundary, and the length
12453 must be a multiple of the storage unit.
12455 @node Enumeration Clauses
12456 @section Enumeration Clauses
12458 The only restriction on enumeration clauses is that the range of values
12459 must be representable. For the signed case, if one or more of the
12460 representation values are negative, all values must be in the range:
12462 @smallexample @c ada
12463 System.Min_Int .. System.Max_Int
12467 For the unsigned case, where all values are nonnegative, the values must
12470 @smallexample @c ada
12471 0 .. System.Max_Binary_Modulus;
12475 A @emph{confirming} representation clause is one in which the values range
12476 from 0 in sequence, i.e.@: a clause that confirms the default representation
12477 for an enumeration type.
12478 Such a confirming representation
12479 is permitted by these rules, and is specially recognized by the compiler so
12480 that no extra overhead results from the use of such a clause.
12482 If an array has an index type which is an enumeration type to which an
12483 enumeration clause has been applied, then the array is stored in a compact
12484 manner. Consider the declarations:
12486 @smallexample @c ada
12487 type r is (A, B, C);
12488 for r use (A => 1, B => 5, C => 10);
12489 type t is array (r) of Character;
12493 The array type t corresponds to a vector with exactly three elements and
12494 has a default size equal to @code{3*Character'Size}. This ensures efficient
12495 use of space, but means that accesses to elements of the array will incur
12496 the overhead of converting representation values to the corresponding
12497 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
12499 @node Address Clauses
12500 @section Address Clauses
12501 @cindex Address Clause
12503 The reference manual allows a general restriction on representation clauses,
12504 as found in RM 13.1(22):
12507 An implementation need not support representation
12508 items containing nonstatic expressions, except that
12509 an implementation should support a representation item
12510 for a given entity if each nonstatic expression in the
12511 representation item is a name that statically denotes
12512 a constant declared before the entity.
12516 In practice this is applicable only to address clauses, since this is the
12517 only case in which a non-static expression is permitted by the syntax. As
12518 the AARM notes in sections 13.1 (22.a-22.h):
12521 22.a Reason: This is to avoid the following sort of thing:
12523 22.b X : Integer := F(@dots{});
12524 Y : Address := G(@dots{});
12525 for X'Address use Y;
12527 22.c In the above, we have to evaluate the
12528 initialization expression for X before we
12529 know where to put the result. This seems
12530 like an unreasonable implementation burden.
12532 22.d The above code should instead be written
12535 22.e Y : constant Address := G(@dots{});
12536 X : Integer := F(@dots{});
12537 for X'Address use Y;
12539 22.f This allows the expression ``Y'' to be safely
12540 evaluated before X is created.
12542 22.g The constant could be a formal parameter of mode in.
12544 22.h An implementation can support other nonstatic
12545 expressions if it wants to. Expressions of type
12546 Address are hardly ever static, but their value
12547 might be known at compile time anyway in many
12552 GNAT does indeed permit many additional cases of non-static expressions. In
12553 particular, if the type involved is elementary there are no restrictions
12554 (since in this case, holding a temporary copy of the initialization value,
12555 if one is present, is inexpensive). In addition, if there is no implicit or
12556 explicit initialization, then there are no restrictions. GNAT will reject
12557 only the case where all three of these conditions hold:
12562 The type of the item is non-elementary (e.g.@: a record or array).
12565 There is explicit or implicit initialization required for the object.
12566 Note that access values are always implicitly initialized.
12569 The address value is non-static. Here GNAT is more permissive than the
12570 RM, and allows the address value to be the address of a previously declared
12571 stand-alone variable, as long as it does not itself have an address clause.
12573 @smallexample @c ada
12574 Anchor : Some_Initialized_Type;
12575 Overlay : Some_Initialized_Type;
12576 for Overlay'Address use Anchor'Address;
12580 However, the prefix of the address clause cannot be an array component, or
12581 a component of a discriminated record.
12586 As noted above in section 22.h, address values are typically non-static. In
12587 particular the To_Address function, even if applied to a literal value, is
12588 a non-static function call. To avoid this minor annoyance, GNAT provides
12589 the implementation defined attribute 'To_Address. The following two
12590 expressions have identical values:
12594 @smallexample @c ada
12595 To_Address (16#1234_0000#)
12596 System'To_Address (16#1234_0000#);
12600 except that the second form is considered to be a static expression, and
12601 thus when used as an address clause value is always permitted.
12604 Additionally, GNAT treats as static an address clause that is an
12605 unchecked_conversion of a static integer value. This simplifies the porting
12606 of legacy code, and provides a portable equivalent to the GNAT attribute
12609 Another issue with address clauses is the interaction with alignment
12610 requirements. When an address clause is given for an object, the address
12611 value must be consistent with the alignment of the object (which is usually
12612 the same as the alignment of the type of the object). If an address clause
12613 is given that specifies an inappropriately aligned address value, then the
12614 program execution is erroneous.
12616 Since this source of erroneous behavior can have unfortunate effects, GNAT
12617 checks (at compile time if possible, generating a warning, or at execution
12618 time with a run-time check) that the alignment is appropriate. If the
12619 run-time check fails, then @code{Program_Error} is raised. This run-time
12620 check is suppressed if range checks are suppressed, or if the special GNAT
12621 check Alignment_Check is suppressed, or if
12622 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
12624 Finally, GNAT does not permit overlaying of objects of controlled types or
12625 composite types containing a controlled component. In most cases, the compiler
12626 can detect an attempt at such overlays and will generate a warning at compile
12627 time and a Program_Error exception at run time.
12630 An address clause cannot be given for an exported object. More
12631 understandably the real restriction is that objects with an address
12632 clause cannot be exported. This is because such variables are not
12633 defined by the Ada program, so there is no external object to export.
12636 It is permissible to give an address clause and a pragma Import for the
12637 same object. In this case, the variable is not really defined by the
12638 Ada program, so there is no external symbol to be linked. The link name
12639 and the external name are ignored in this case. The reason that we allow this
12640 combination is that it provides a useful idiom to avoid unwanted
12641 initializations on objects with address clauses.
12643 When an address clause is given for an object that has implicit or
12644 explicit initialization, then by default initialization takes place. This
12645 means that the effect of the object declaration is to overwrite the
12646 memory at the specified address. This is almost always not what the
12647 programmer wants, so GNAT will output a warning:
12657 for Ext'Address use System'To_Address (16#1234_1234#);
12659 >>> warning: implicit initialization of "Ext" may
12660 modify overlaid storage
12661 >>> warning: use pragma Import for "Ext" to suppress
12662 initialization (RM B(24))
12668 As indicated by the warning message, the solution is to use a (dummy) pragma
12669 Import to suppress this initialization. The pragma tell the compiler that the
12670 object is declared and initialized elsewhere. The following package compiles
12671 without warnings (and the initialization is suppressed):
12673 @smallexample @c ada
12681 for Ext'Address use System'To_Address (16#1234_1234#);
12682 pragma Import (Ada, Ext);
12687 A final issue with address clauses involves their use for overlaying
12688 variables, as in the following example:
12689 @cindex Overlaying of objects
12691 @smallexample @c ada
12694 for B'Address use A'Address;
12698 or alternatively, using the form recommended by the RM:
12700 @smallexample @c ada
12702 Addr : constant Address := A'Address;
12704 for B'Address use Addr;
12708 In both of these cases, @code{A}
12709 and @code{B} become aliased to one another via the
12710 address clause. This use of address clauses to overlay
12711 variables, achieving an effect similar to unchecked
12712 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
12713 the effect is implementation defined. Furthermore, the
12714 Ada RM specifically recommends that in a situation
12715 like this, @code{B} should be subject to the following
12716 implementation advice (RM 13.3(19)):
12719 19 If the Address of an object is specified, or it is imported
12720 or exported, then the implementation should not perform
12721 optimizations based on assumptions of no aliases.
12725 GNAT follows this recommendation, and goes further by also applying
12726 this recommendation to the overlaid variable (@code{A}
12727 in the above example) in this case. This means that the overlay
12728 works "as expected", in that a modification to one of the variables
12729 will affect the value of the other.
12731 @node Effect of Convention on Representation
12732 @section Effect of Convention on Representation
12733 @cindex Convention, effect on representation
12736 Normally the specification of a foreign language convention for a type or
12737 an object has no effect on the chosen representation. In particular, the
12738 representation chosen for data in GNAT generally meets the standard system
12739 conventions, and for example records are laid out in a manner that is
12740 consistent with C@. This means that specifying convention C (for example)
12743 There are four exceptions to this general rule:
12747 @item Convention Fortran and array subtypes
12748 If pragma Convention Fortran is specified for an array subtype, then in
12749 accordance with the implementation advice in section 3.6.2(11) of the
12750 Ada Reference Manual, the array will be stored in a Fortran-compatible
12751 column-major manner, instead of the normal default row-major order.
12753 @item Convention C and enumeration types
12754 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
12755 to accommodate all values of the type. For example, for the enumeration
12758 @smallexample @c ada
12759 type Color is (Red, Green, Blue);
12763 8 bits is sufficient to store all values of the type, so by default, objects
12764 of type @code{Color} will be represented using 8 bits. However, normal C
12765 convention is to use 32 bits for all enum values in C, since enum values
12766 are essentially of type int. If pragma @code{Convention C} is specified for an
12767 Ada enumeration type, then the size is modified as necessary (usually to
12768 32 bits) to be consistent with the C convention for enum values.
12770 Note that this treatment applies only to types. If Convention C is given for
12771 an enumeration object, where the enumeration type is not Convention C, then
12772 Object_Size bits are allocated. For example, for a normal enumeration type,
12773 with less than 256 elements, only 8 bits will be allocated for the object.
12774 Since this may be a surprise in terms of what C expects, GNAT will issue a
12775 warning in this situation. The warning can be suppressed by giving an explicit
12776 size clause specifying the desired size.
12778 @item Convention C/Fortran and Boolean types
12779 In C, the usual convention for boolean values, that is values used for
12780 conditions, is that zero represents false, and nonzero values represent
12781 true. In Ada, the normal convention is that two specific values, typically
12782 0/1, are used to represent false/true respectively.
12784 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
12785 value represents true).
12787 To accommodate the Fortran and C conventions, if a pragma Convention specifies
12788 C or Fortran convention for a derived Boolean, as in the following example:
12790 @smallexample @c ada
12791 type C_Switch is new Boolean;
12792 pragma Convention (C, C_Switch);
12796 then the GNAT generated code will treat any nonzero value as true. For truth
12797 values generated by GNAT, the conventional value 1 will be used for True, but
12798 when one of these values is read, any nonzero value is treated as True.
12800 @item Access types on OpenVMS
12801 For 64-bit OpenVMS systems, access types (other than those for unconstrained
12802 arrays) are 64-bits long. An exception to this rule is for the case of
12803 C-convention access types where there is no explicit size clause present (or
12804 inherited for derived types). In this case, GNAT chooses to make these
12805 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
12806 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
12810 @node Determining the Representations chosen by GNAT
12811 @section Determining the Representations chosen by GNAT
12812 @cindex Representation, determination of
12813 @cindex @option{-gnatR} switch
12816 Although the descriptions in this section are intended to be complete, it is
12817 often easier to simply experiment to see what GNAT accepts and what the
12818 effect is on the layout of types and objects.
12820 As required by the Ada RM, if a representation clause is not accepted, then
12821 it must be rejected as illegal by the compiler. However, when a
12822 representation clause or pragma is accepted, there can still be questions
12823 of what the compiler actually does. For example, if a partial record
12824 representation clause specifies the location of some components and not
12825 others, then where are the non-specified components placed? Or if pragma
12826 @code{Pack} is used on a record, then exactly where are the resulting
12827 fields placed? The section on pragma @code{Pack} in this chapter can be
12828 used to answer the second question, but it is often easier to just see
12829 what the compiler does.
12831 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
12832 with this option, then the compiler will output information on the actual
12833 representations chosen, in a format similar to source representation
12834 clauses. For example, if we compile the package:
12836 @smallexample @c ada
12838 type r (x : boolean) is tagged record
12840 when True => S : String (1 .. 100);
12841 when False => null;
12845 type r2 is new r (false) with record
12850 y2 at 16 range 0 .. 31;
12857 type x1 is array (1 .. 10) of x;
12858 for x1'component_size use 11;
12860 type ia is access integer;
12862 type Rb1 is array (1 .. 13) of Boolean;
12865 type Rb2 is array (1 .. 65) of Boolean;
12881 using the switch @option{-gnatR} we obtain the following output:
12884 Representation information for unit q
12885 -------------------------------------
12888 for r'Alignment use 4;
12890 x at 4 range 0 .. 7;
12891 _tag at 0 range 0 .. 31;
12892 s at 5 range 0 .. 799;
12895 for r2'Size use 160;
12896 for r2'Alignment use 4;
12898 x at 4 range 0 .. 7;
12899 _tag at 0 range 0 .. 31;
12900 _parent at 0 range 0 .. 63;
12901 y2 at 16 range 0 .. 31;
12905 for x'Alignment use 1;
12907 y at 0 range 0 .. 7;
12910 for x1'Size use 112;
12911 for x1'Alignment use 1;
12912 for x1'Component_Size use 11;
12914 for rb1'Size use 13;
12915 for rb1'Alignment use 2;
12916 for rb1'Component_Size use 1;
12918 for rb2'Size use 72;
12919 for rb2'Alignment use 1;
12920 for rb2'Component_Size use 1;
12922 for x2'Size use 224;
12923 for x2'Alignment use 4;
12925 l1 at 0 range 0 .. 0;
12926 l2 at 0 range 1 .. 64;
12927 l3 at 12 range 0 .. 31;
12928 l4 at 16 range 0 .. 0;
12929 l5 at 16 range 1 .. 13;
12930 l6 at 18 range 0 .. 71;
12935 The Size values are actually the Object_Size, i.e.@: the default size that
12936 will be allocated for objects of the type.
12937 The ?? size for type r indicates that we have a variant record, and the
12938 actual size of objects will depend on the discriminant value.
12940 The Alignment values show the actual alignment chosen by the compiler
12941 for each record or array type.
12943 The record representation clause for type r shows where all fields
12944 are placed, including the compiler generated tag field (whose location
12945 cannot be controlled by the programmer).
12947 The record representation clause for the type extension r2 shows all the
12948 fields present, including the parent field, which is a copy of the fields
12949 of the parent type of r2, i.e.@: r1.
12951 The component size and size clauses for types rb1 and rb2 show
12952 the exact effect of pragma @code{Pack} on these arrays, and the record
12953 representation clause for type x2 shows how pragma @code{Pack} affects
12956 In some cases, it may be useful to cut and paste the representation clauses
12957 generated by the compiler into the original source to fix and guarantee
12958 the actual representation to be used.
12960 @node Standard Library Routines
12961 @chapter Standard Library Routines
12964 The Ada Reference Manual contains in Annex A a full description of an
12965 extensive set of standard library routines that can be used in any Ada
12966 program, and which must be provided by all Ada compilers. They are
12967 analogous to the standard C library used by C programs.
12969 GNAT implements all of the facilities described in annex A, and for most
12970 purposes the description in the Ada Reference Manual, or appropriate Ada
12971 text book, will be sufficient for making use of these facilities.
12973 In the case of the input-output facilities,
12974 @xref{The Implementation of Standard I/O},
12975 gives details on exactly how GNAT interfaces to the
12976 file system. For the remaining packages, the Ada Reference Manual
12977 should be sufficient. The following is a list of the packages included,
12978 together with a brief description of the functionality that is provided.
12980 For completeness, references are included to other predefined library
12981 routines defined in other sections of the Ada Reference Manual (these are
12982 cross-indexed from Annex A).
12986 This is a parent package for all the standard library packages. It is
12987 usually included implicitly in your program, and itself contains no
12988 useful data or routines.
12990 @item Ada.Calendar (9.6)
12991 @code{Calendar} provides time of day access, and routines for
12992 manipulating times and durations.
12994 @item Ada.Characters (A.3.1)
12995 This is a dummy parent package that contains no useful entities
12997 @item Ada.Characters.Handling (A.3.2)
12998 This package provides some basic character handling capabilities,
12999 including classification functions for classes of characters (e.g.@: test
13000 for letters, or digits).
13002 @item Ada.Characters.Latin_1 (A.3.3)
13003 This package includes a complete set of definitions of the characters
13004 that appear in type CHARACTER@. It is useful for writing programs that
13005 will run in international environments. For example, if you want an
13006 upper case E with an acute accent in a string, it is often better to use
13007 the definition of @code{UC_E_Acute} in this package. Then your program
13008 will print in an understandable manner even if your environment does not
13009 support these extended characters.
13011 @item Ada.Command_Line (A.15)
13012 This package provides access to the command line parameters and the name
13013 of the current program (analogous to the use of @code{argc} and @code{argv}
13014 in C), and also allows the exit status for the program to be set in a
13015 system-independent manner.
13017 @item Ada.Decimal (F.2)
13018 This package provides constants describing the range of decimal numbers
13019 implemented, and also a decimal divide routine (analogous to the COBOL
13020 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
13022 @item Ada.Direct_IO (A.8.4)
13023 This package provides input-output using a model of a set of records of
13024 fixed-length, containing an arbitrary definite Ada type, indexed by an
13025 integer record number.
13027 @item Ada.Dynamic_Priorities (D.5)
13028 This package allows the priorities of a task to be adjusted dynamically
13029 as the task is running.
13031 @item Ada.Exceptions (11.4.1)
13032 This package provides additional information on exceptions, and also
13033 contains facilities for treating exceptions as data objects, and raising
13034 exceptions with associated messages.
13036 @item Ada.Finalization (7.6)
13037 This package contains the declarations and subprograms to support the
13038 use of controlled types, providing for automatic initialization and
13039 finalization (analogous to the constructors and destructors of C++)
13041 @item Ada.Interrupts (C.3.2)
13042 This package provides facilities for interfacing to interrupts, which
13043 includes the set of signals or conditions that can be raised and
13044 recognized as interrupts.
13046 @item Ada.Interrupts.Names (C.3.2)
13047 This package provides the set of interrupt names (actually signal
13048 or condition names) that can be handled by GNAT@.
13050 @item Ada.IO_Exceptions (A.13)
13051 This package defines the set of exceptions that can be raised by use of
13052 the standard IO packages.
13055 This package contains some standard constants and exceptions used
13056 throughout the numerics packages. Note that the constants pi and e are
13057 defined here, and it is better to use these definitions than rolling
13060 @item Ada.Numerics.Complex_Elementary_Functions
13061 Provides the implementation of standard elementary functions (such as
13062 log and trigonometric functions) operating on complex numbers using the
13063 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
13064 created by the package @code{Numerics.Complex_Types}.
13066 @item Ada.Numerics.Complex_Types
13067 This is a predefined instantiation of
13068 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
13069 build the type @code{Complex} and @code{Imaginary}.
13071 @item Ada.Numerics.Discrete_Random
13072 This generic package provides a random number generator suitable for generating
13073 uniformly distributed values of a specified discrete subtype.
13075 @item Ada.Numerics.Float_Random
13076 This package provides a random number generator suitable for generating
13077 uniformly distributed floating point values in the unit interval.
13079 @item Ada.Numerics.Generic_Complex_Elementary_Functions
13080 This is a generic version of the package that provides the
13081 implementation of standard elementary functions (such as log and
13082 trigonometric functions) for an arbitrary complex type.
13084 The following predefined instantiations of this package are provided:
13088 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
13090 @code{Ada.Numerics.Complex_Elementary_Functions}
13092 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
13095 @item Ada.Numerics.Generic_Complex_Types
13096 This is a generic package that allows the creation of complex types,
13097 with associated complex arithmetic operations.
13099 The following predefined instantiations of this package exist
13102 @code{Ada.Numerics.Short_Complex_Complex_Types}
13104 @code{Ada.Numerics.Complex_Complex_Types}
13106 @code{Ada.Numerics.Long_Complex_Complex_Types}
13109 @item Ada.Numerics.Generic_Elementary_Functions
13110 This is a generic package that provides the implementation of standard
13111 elementary functions (such as log an trigonometric functions) for an
13112 arbitrary float type.
13114 The following predefined instantiations of this package exist
13118 @code{Ada.Numerics.Short_Elementary_Functions}
13120 @code{Ada.Numerics.Elementary_Functions}
13122 @code{Ada.Numerics.Long_Elementary_Functions}
13125 @item Ada.Real_Time (D.8)
13126 This package provides facilities similar to those of @code{Calendar}, but
13127 operating with a finer clock suitable for real time control. Note that
13128 annex D requires that there be no backward clock jumps, and GNAT generally
13129 guarantees this behavior, but of course if the external clock on which
13130 the GNAT runtime depends is deliberately reset by some external event,
13131 then such a backward jump may occur.
13133 @item Ada.Sequential_IO (A.8.1)
13134 This package provides input-output facilities for sequential files,
13135 which can contain a sequence of values of a single type, which can be
13136 any Ada type, including indefinite (unconstrained) types.
13138 @item Ada.Storage_IO (A.9)
13139 This package provides a facility for mapping arbitrary Ada types to and
13140 from a storage buffer. It is primarily intended for the creation of new
13143 @item Ada.Streams (13.13.1)
13144 This is a generic package that provides the basic support for the
13145 concept of streams as used by the stream attributes (@code{Input},
13146 @code{Output}, @code{Read} and @code{Write}).
13148 @item Ada.Streams.Stream_IO (A.12.1)
13149 This package is a specialization of the type @code{Streams} defined in
13150 package @code{Streams} together with a set of operations providing
13151 Stream_IO capability. The Stream_IO model permits both random and
13152 sequential access to a file which can contain an arbitrary set of values
13153 of one or more Ada types.
13155 @item Ada.Strings (A.4.1)
13156 This package provides some basic constants used by the string handling
13159 @item Ada.Strings.Bounded (A.4.4)
13160 This package provides facilities for handling variable length
13161 strings. The bounded model requires a maximum length. It is thus
13162 somewhat more limited than the unbounded model, but avoids the use of
13163 dynamic allocation or finalization.
13165 @item Ada.Strings.Fixed (A.4.3)
13166 This package provides facilities for handling fixed length strings.
13168 @item Ada.Strings.Maps (A.4.2)
13169 This package provides facilities for handling character mappings and
13170 arbitrarily defined subsets of characters. For instance it is useful in
13171 defining specialized translation tables.
13173 @item Ada.Strings.Maps.Constants (A.4.6)
13174 This package provides a standard set of predefined mappings and
13175 predefined character sets. For example, the standard upper to lower case
13176 conversion table is found in this package. Note that upper to lower case
13177 conversion is non-trivial if you want to take the entire set of
13178 characters, including extended characters like E with an acute accent,
13179 into account. You should use the mappings in this package (rather than
13180 adding 32 yourself) to do case mappings.
13182 @item Ada.Strings.Unbounded (A.4.5)
13183 This package provides facilities for handling variable length
13184 strings. The unbounded model allows arbitrary length strings, but
13185 requires the use of dynamic allocation and finalization.
13187 @item Ada.Strings.Wide_Bounded (A.4.7)
13188 @itemx Ada.Strings.Wide_Fixed (A.4.7)
13189 @itemx Ada.Strings.Wide_Maps (A.4.7)
13190 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
13191 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
13192 These packages provide analogous capabilities to the corresponding
13193 packages without @samp{Wide_} in the name, but operate with the types
13194 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
13195 and @code{Character}.
13197 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
13198 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
13199 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
13200 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
13201 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
13202 These packages provide analogous capabilities to the corresponding
13203 packages without @samp{Wide_} in the name, but operate with the types
13204 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
13205 of @code{String} and @code{Character}.
13207 @item Ada.Synchronous_Task_Control (D.10)
13208 This package provides some standard facilities for controlling task
13209 communication in a synchronous manner.
13212 This package contains definitions for manipulation of the tags of tagged
13215 @item Ada.Task_Attributes
13216 This package provides the capability of associating arbitrary
13217 task-specific data with separate tasks.
13220 This package provides basic text input-output capabilities for
13221 character, string and numeric data. The subpackages of this
13222 package are listed next.
13224 @item Ada.Text_IO.Decimal_IO
13225 Provides input-output facilities for decimal fixed-point types
13227 @item Ada.Text_IO.Enumeration_IO
13228 Provides input-output facilities for enumeration types.
13230 @item Ada.Text_IO.Fixed_IO
13231 Provides input-output facilities for ordinary fixed-point types.
13233 @item Ada.Text_IO.Float_IO
13234 Provides input-output facilities for float types. The following
13235 predefined instantiations of this generic package are available:
13239 @code{Short_Float_Text_IO}
13241 @code{Float_Text_IO}
13243 @code{Long_Float_Text_IO}
13246 @item Ada.Text_IO.Integer_IO
13247 Provides input-output facilities for integer types. The following
13248 predefined instantiations of this generic package are available:
13251 @item Short_Short_Integer
13252 @code{Ada.Short_Short_Integer_Text_IO}
13253 @item Short_Integer
13254 @code{Ada.Short_Integer_Text_IO}
13256 @code{Ada.Integer_Text_IO}
13258 @code{Ada.Long_Integer_Text_IO}
13259 @item Long_Long_Integer
13260 @code{Ada.Long_Long_Integer_Text_IO}
13263 @item Ada.Text_IO.Modular_IO
13264 Provides input-output facilities for modular (unsigned) types
13266 @item Ada.Text_IO.Complex_IO (G.1.3)
13267 This package provides basic text input-output capabilities for complex
13270 @item Ada.Text_IO.Editing (F.3.3)
13271 This package contains routines for edited output, analogous to the use
13272 of pictures in COBOL@. The picture formats used by this package are a
13273 close copy of the facility in COBOL@.
13275 @item Ada.Text_IO.Text_Streams (A.12.2)
13276 This package provides a facility that allows Text_IO files to be treated
13277 as streams, so that the stream attributes can be used for writing
13278 arbitrary data, including binary data, to Text_IO files.
13280 @item Ada.Unchecked_Conversion (13.9)
13281 This generic package allows arbitrary conversion from one type to
13282 another of the same size, providing for breaking the type safety in
13283 special circumstances.
13285 If the types have the same Size (more accurately the same Value_Size),
13286 then the effect is simply to transfer the bits from the source to the
13287 target type without any modification. This usage is well defined, and
13288 for simple types whose representation is typically the same across
13289 all implementations, gives a portable method of performing such
13292 If the types do not have the same size, then the result is implementation
13293 defined, and thus may be non-portable. The following describes how GNAT
13294 handles such unchecked conversion cases.
13296 If the types are of different sizes, and are both discrete types, then
13297 the effect is of a normal type conversion without any constraint checking.
13298 In particular if the result type has a larger size, the result will be
13299 zero or sign extended. If the result type has a smaller size, the result
13300 will be truncated by ignoring high order bits.
13302 If the types are of different sizes, and are not both discrete types,
13303 then the conversion works as though pointers were created to the source
13304 and target, and the pointer value is converted. The effect is that bits
13305 are copied from successive low order storage units and bits of the source
13306 up to the length of the target type.
13308 A warning is issued if the lengths differ, since the effect in this
13309 case is implementation dependent, and the above behavior may not match
13310 that of some other compiler.
13312 A pointer to one type may be converted to a pointer to another type using
13313 unchecked conversion. The only case in which the effect is undefined is
13314 when one or both pointers are pointers to unconstrained array types. In
13315 this case, the bounds information may get incorrectly transferred, and in
13316 particular, GNAT uses double size pointers for such types, and it is
13317 meaningless to convert between such pointer types. GNAT will issue a
13318 warning if the alignment of the target designated type is more strict
13319 than the alignment of the source designated type (since the result may
13320 be unaligned in this case).
13322 A pointer other than a pointer to an unconstrained array type may be
13323 converted to and from System.Address. Such usage is common in Ada 83
13324 programs, but note that Ada.Address_To_Access_Conversions is the
13325 preferred method of performing such conversions in Ada 95 and Ada 2005.
13327 unchecked conversion nor Ada.Address_To_Access_Conversions should be
13328 used in conjunction with pointers to unconstrained objects, since
13329 the bounds information cannot be handled correctly in this case.
13331 @item Ada.Unchecked_Deallocation (13.11.2)
13332 This generic package allows explicit freeing of storage previously
13333 allocated by use of an allocator.
13335 @item Ada.Wide_Text_IO (A.11)
13336 This package is similar to @code{Ada.Text_IO}, except that the external
13337 file supports wide character representations, and the internal types are
13338 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13339 and @code{String}. It contains generic subpackages listed next.
13341 @item Ada.Wide_Text_IO.Decimal_IO
13342 Provides input-output facilities for decimal fixed-point types
13344 @item Ada.Wide_Text_IO.Enumeration_IO
13345 Provides input-output facilities for enumeration types.
13347 @item Ada.Wide_Text_IO.Fixed_IO
13348 Provides input-output facilities for ordinary fixed-point types.
13350 @item Ada.Wide_Text_IO.Float_IO
13351 Provides input-output facilities for float types. The following
13352 predefined instantiations of this generic package are available:
13356 @code{Short_Float_Wide_Text_IO}
13358 @code{Float_Wide_Text_IO}
13360 @code{Long_Float_Wide_Text_IO}
13363 @item Ada.Wide_Text_IO.Integer_IO
13364 Provides input-output facilities for integer types. The following
13365 predefined instantiations of this generic package are available:
13368 @item Short_Short_Integer
13369 @code{Ada.Short_Short_Integer_Wide_Text_IO}
13370 @item Short_Integer
13371 @code{Ada.Short_Integer_Wide_Text_IO}
13373 @code{Ada.Integer_Wide_Text_IO}
13375 @code{Ada.Long_Integer_Wide_Text_IO}
13376 @item Long_Long_Integer
13377 @code{Ada.Long_Long_Integer_Wide_Text_IO}
13380 @item Ada.Wide_Text_IO.Modular_IO
13381 Provides input-output facilities for modular (unsigned) types
13383 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
13384 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13385 external file supports wide character representations.
13387 @item Ada.Wide_Text_IO.Editing (F.3.4)
13388 This package is similar to @code{Ada.Text_IO.Editing}, except that the
13389 types are @code{Wide_Character} and @code{Wide_String} instead of
13390 @code{Character} and @code{String}.
13392 @item Ada.Wide_Text_IO.Streams (A.12.3)
13393 This package is similar to @code{Ada.Text_IO.Streams}, except that the
13394 types are @code{Wide_Character} and @code{Wide_String} instead of
13395 @code{Character} and @code{String}.
13397 @item Ada.Wide_Wide_Text_IO (A.11)
13398 This package is similar to @code{Ada.Text_IO}, except that the external
13399 file supports wide character representations, and the internal types are
13400 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13401 and @code{String}. It contains generic subpackages listed next.
13403 @item Ada.Wide_Wide_Text_IO.Decimal_IO
13404 Provides input-output facilities for decimal fixed-point types
13406 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
13407 Provides input-output facilities for enumeration types.
13409 @item Ada.Wide_Wide_Text_IO.Fixed_IO
13410 Provides input-output facilities for ordinary fixed-point types.
13412 @item Ada.Wide_Wide_Text_IO.Float_IO
13413 Provides input-output facilities for float types. The following
13414 predefined instantiations of this generic package are available:
13418 @code{Short_Float_Wide_Wide_Text_IO}
13420 @code{Float_Wide_Wide_Text_IO}
13422 @code{Long_Float_Wide_Wide_Text_IO}
13425 @item Ada.Wide_Wide_Text_IO.Integer_IO
13426 Provides input-output facilities for integer types. The following
13427 predefined instantiations of this generic package are available:
13430 @item Short_Short_Integer
13431 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
13432 @item Short_Integer
13433 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
13435 @code{Ada.Integer_Wide_Wide_Text_IO}
13437 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
13438 @item Long_Long_Integer
13439 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
13442 @item Ada.Wide_Wide_Text_IO.Modular_IO
13443 Provides input-output facilities for modular (unsigned) types
13445 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
13446 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13447 external file supports wide character representations.
13449 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
13450 This package is similar to @code{Ada.Text_IO.Editing}, except that the
13451 types are @code{Wide_Character} and @code{Wide_String} instead of
13452 @code{Character} and @code{String}.
13454 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
13455 This package is similar to @code{Ada.Text_IO.Streams}, except that the
13456 types are @code{Wide_Character} and @code{Wide_String} instead of
13457 @code{Character} and @code{String}.
13460 @node The Implementation of Standard I/O
13461 @chapter The Implementation of Standard I/O
13464 GNAT implements all the required input-output facilities described in
13465 A.6 through A.14. These sections of the Ada Reference Manual describe the
13466 required behavior of these packages from the Ada point of view, and if
13467 you are writing a portable Ada program that does not need to know the
13468 exact manner in which Ada maps to the outside world when it comes to
13469 reading or writing external files, then you do not need to read this
13470 chapter. As long as your files are all regular files (not pipes or
13471 devices), and as long as you write and read the files only from Ada, the
13472 description in the Ada Reference Manual is sufficient.
13474 However, if you want to do input-output to pipes or other devices, such
13475 as the keyboard or screen, or if the files you are dealing with are
13476 either generated by some other language, or to be read by some other
13477 language, then you need to know more about the details of how the GNAT
13478 implementation of these input-output facilities behaves.
13480 In this chapter we give a detailed description of exactly how GNAT
13481 interfaces to the file system. As always, the sources of the system are
13482 available to you for answering questions at an even more detailed level,
13483 but for most purposes the information in this chapter will suffice.
13485 Another reason that you may need to know more about how input-output is
13486 implemented arises when you have a program written in mixed languages
13487 where, for example, files are shared between the C and Ada sections of
13488 the same program. GNAT provides some additional facilities, in the form
13489 of additional child library packages, that facilitate this sharing, and
13490 these additional facilities are also described in this chapter.
13493 * Standard I/O Packages::
13499 * Wide_Wide_Text_IO::
13501 * Text Translation::
13503 * Filenames encoding::
13505 * Operations on C Streams::
13506 * Interfacing to C Streams::
13509 @node Standard I/O Packages
13510 @section Standard I/O Packages
13513 The Standard I/O packages described in Annex A for
13519 Ada.Text_IO.Complex_IO
13521 Ada.Text_IO.Text_Streams
13525 Ada.Wide_Text_IO.Complex_IO
13527 Ada.Wide_Text_IO.Text_Streams
13529 Ada.Wide_Wide_Text_IO
13531 Ada.Wide_Wide_Text_IO.Complex_IO
13533 Ada.Wide_Wide_Text_IO.Text_Streams
13543 are implemented using the C
13544 library streams facility; where
13548 All files are opened using @code{fopen}.
13550 All input/output operations use @code{fread}/@code{fwrite}.
13554 There is no internal buffering of any kind at the Ada library level. The only
13555 buffering is that provided at the system level in the implementation of the
13556 library routines that support streams. This facilitates shared use of these
13557 streams by mixed language programs. Note though that system level buffering is
13558 explicitly enabled at elaboration of the standard I/O packages and that can
13559 have an impact on mixed language programs, in particular those using I/O before
13560 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
13561 the Ada elaboration routine before performing any I/O or when impractical,
13562 flush the common I/O streams and in particular Standard_Output before
13563 elaborating the Ada code.
13566 @section FORM Strings
13569 The format of a FORM string in GNAT is:
13572 "keyword=value,keyword=value,@dots{},keyword=value"
13576 where letters may be in upper or lower case, and there are no spaces
13577 between values. The order of the entries is not important. Currently
13578 the following keywords defined.
13581 TEXT_TRANSLATION=[YES|NO]
13583 WCEM=[n|h|u|s|e|8|b]
13584 ENCODING=[UTF8|8BITS]
13588 The use of these parameters is described later in this section.
13594 Direct_IO can only be instantiated for definite types. This is a
13595 restriction of the Ada language, which means that the records are fixed
13596 length (the length being determined by @code{@var{type}'Size}, rounded
13597 up to the next storage unit boundary if necessary).
13599 The records of a Direct_IO file are simply written to the file in index
13600 sequence, with the first record starting at offset zero, and subsequent
13601 records following. There is no control information of any kind. For
13602 example, if 32-bit integers are being written, each record takes
13603 4-bytes, so the record at index @var{K} starts at offset
13604 (@var{K}@minus{}1)*4.
13606 There is no limit on the size of Direct_IO files, they are expanded as
13607 necessary to accommodate whatever records are written to the file.
13609 @node Sequential_IO
13610 @section Sequential_IO
13613 Sequential_IO may be instantiated with either a definite (constrained)
13614 or indefinite (unconstrained) type.
13616 For the definite type case, the elements written to the file are simply
13617 the memory images of the data values with no control information of any
13618 kind. The resulting file should be read using the same type, no validity
13619 checking is performed on input.
13621 For the indefinite type case, the elements written consist of two
13622 parts. First is the size of the data item, written as the memory image
13623 of a @code{Interfaces.C.size_t} value, followed by the memory image of
13624 the data value. The resulting file can only be read using the same
13625 (unconstrained) type. Normal assignment checks are performed on these
13626 read operations, and if these checks fail, @code{Data_Error} is
13627 raised. In particular, in the array case, the lengths must match, and in
13628 the variant record case, if the variable for a particular read operation
13629 is constrained, the discriminants must match.
13631 Note that it is not possible to use Sequential_IO to write variable
13632 length array items, and then read the data back into different length
13633 arrays. For example, the following will raise @code{Data_Error}:
13635 @smallexample @c ada
13636 package IO is new Sequential_IO (String);
13641 IO.Write (F, "hello!")
13642 IO.Reset (F, Mode=>In_File);
13649 On some Ada implementations, this will print @code{hell}, but the program is
13650 clearly incorrect, since there is only one element in the file, and that
13651 element is the string @code{hello!}.
13653 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
13654 using Stream_IO, and this is the preferred mechanism. In particular, the
13655 above program fragment rewritten to use Stream_IO will work correctly.
13661 Text_IO files consist of a stream of characters containing the following
13662 special control characters:
13665 LF (line feed, 16#0A#) Line Mark
13666 FF (form feed, 16#0C#) Page Mark
13670 A canonical Text_IO file is defined as one in which the following
13671 conditions are met:
13675 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
13679 The character @code{FF} is used only as a page mark, i.e.@: to mark the
13680 end of a page and consequently can appear only immediately following a
13681 @code{LF} (line mark) character.
13684 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
13685 (line mark, page mark). In the former case, the page mark is implicitly
13686 assumed to be present.
13690 A file written using Text_IO will be in canonical form provided that no
13691 explicit @code{LF} or @code{FF} characters are written using @code{Put}
13692 or @code{Put_Line}. There will be no @code{FF} character at the end of
13693 the file unless an explicit @code{New_Page} operation was performed
13694 before closing the file.
13696 A canonical Text_IO file that is a regular file (i.e., not a device or a
13697 pipe) can be read using any of the routines in Text_IO@. The
13698 semantics in this case will be exactly as defined in the Ada Reference
13699 Manual, and all the routines in Text_IO are fully implemented.
13701 A text file that does not meet the requirements for a canonical Text_IO
13702 file has one of the following:
13706 The file contains @code{FF} characters not immediately following a
13707 @code{LF} character.
13710 The file contains @code{LF} or @code{FF} characters written by
13711 @code{Put} or @code{Put_Line}, which are not logically considered to be
13712 line marks or page marks.
13715 The file ends in a character other than @code{LF} or @code{FF},
13716 i.e.@: there is no explicit line mark or page mark at the end of the file.
13720 Text_IO can be used to read such non-standard text files but subprograms
13721 to do with line or page numbers do not have defined meanings. In
13722 particular, a @code{FF} character that does not follow a @code{LF}
13723 character may or may not be treated as a page mark from the point of
13724 view of page and line numbering. Every @code{LF} character is considered
13725 to end a line, and there is an implied @code{LF} character at the end of
13729 * Text_IO Stream Pointer Positioning::
13730 * Text_IO Reading and Writing Non-Regular Files::
13732 * Treating Text_IO Files as Streams::
13733 * Text_IO Extensions::
13734 * Text_IO Facilities for Unbounded Strings::
13737 @node Text_IO Stream Pointer Positioning
13738 @subsection Stream Pointer Positioning
13741 @code{Ada.Text_IO} has a definition of current position for a file that
13742 is being read. No internal buffering occurs in Text_IO, and usually the
13743 physical position in the stream used to implement the file corresponds
13744 to this logical position defined by Text_IO@. There are two exceptions:
13748 After a call to @code{End_Of_Page} that returns @code{True}, the stream
13749 is positioned past the @code{LF} (line mark) that precedes the page
13750 mark. Text_IO maintains an internal flag so that subsequent read
13751 operations properly handle the logical position which is unchanged by
13752 the @code{End_Of_Page} call.
13755 After a call to @code{End_Of_File} that returns @code{True}, if the
13756 Text_IO file was positioned before the line mark at the end of file
13757 before the call, then the logical position is unchanged, but the stream
13758 is physically positioned right at the end of file (past the line mark,
13759 and past a possible page mark following the line mark. Again Text_IO
13760 maintains internal flags so that subsequent read operations properly
13761 handle the logical position.
13765 These discrepancies have no effect on the observable behavior of
13766 Text_IO, but if a single Ada stream is shared between a C program and
13767 Ada program, or shared (using @samp{shared=yes} in the form string)
13768 between two Ada files, then the difference may be observable in some
13771 @node Text_IO Reading and Writing Non-Regular Files
13772 @subsection Reading and Writing Non-Regular Files
13775 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
13776 can be used for reading and writing. Writing is not affected and the
13777 sequence of characters output is identical to the normal file case, but
13778 for reading, the behavior of Text_IO is modified to avoid undesirable
13779 look-ahead as follows:
13781 An input file that is not a regular file is considered to have no page
13782 marks. Any @code{Ascii.FF} characters (the character normally used for a
13783 page mark) appearing in the file are considered to be data
13784 characters. In particular:
13788 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
13789 following a line mark. If a page mark appears, it will be treated as a
13793 This avoids the need to wait for an extra character to be typed or
13794 entered from the pipe to complete one of these operations.
13797 @code{End_Of_Page} always returns @code{False}
13800 @code{End_Of_File} will return @code{False} if there is a page mark at
13801 the end of the file.
13805 Output to non-regular files is the same as for regular files. Page marks
13806 may be written to non-regular files using @code{New_Page}, but as noted
13807 above they will not be treated as page marks on input if the output is
13808 piped to another Ada program.
13810 Another important discrepancy when reading non-regular files is that the end
13811 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
13812 pressing the @key{EOT} key,
13814 is signaled once (i.e.@: the test @code{End_Of_File}
13815 will yield @code{True}, or a read will
13816 raise @code{End_Error}), but then reading can resume
13817 to read data past that end of
13818 file indication, until another end of file indication is entered.
13820 @node Get_Immediate
13821 @subsection Get_Immediate
13822 @cindex Get_Immediate
13825 Get_Immediate returns the next character (including control characters)
13826 from the input file. In particular, Get_Immediate will return LF or FF
13827 characters used as line marks or page marks. Such operations leave the
13828 file positioned past the control character, and it is thus not treated
13829 as having its normal function. This means that page, line and column
13830 counts after this kind of Get_Immediate call are set as though the mark
13831 did not occur. In the case where a Get_Immediate leaves the file
13832 positioned between the line mark and page mark (which is not normally
13833 possible), it is undefined whether the FF character will be treated as a
13836 @node Treating Text_IO Files as Streams
13837 @subsection Treating Text_IO Files as Streams
13838 @cindex Stream files
13841 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
13842 as a stream. Data written to a Text_IO file in this stream mode is
13843 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
13844 16#0C# (@code{FF}), the resulting file may have non-standard
13845 format. Similarly if read operations are used to read from a Text_IO
13846 file treated as a stream, then @code{LF} and @code{FF} characters may be
13847 skipped and the effect is similar to that described above for
13848 @code{Get_Immediate}.
13850 @node Text_IO Extensions
13851 @subsection Text_IO Extensions
13852 @cindex Text_IO extensions
13855 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
13856 to the standard @code{Text_IO} package:
13859 @item function File_Exists (Name : String) return Boolean;
13860 Determines if a file of the given name exists.
13862 @item function Get_Line return String;
13863 Reads a string from the standard input file. The value returned is exactly
13864 the length of the line that was read.
13866 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
13867 Similar, except that the parameter File specifies the file from which
13868 the string is to be read.
13872 @node Text_IO Facilities for Unbounded Strings
13873 @subsection Text_IO Facilities for Unbounded Strings
13874 @cindex Text_IO for unbounded strings
13875 @cindex Unbounded_String, Text_IO operations
13878 The package @code{Ada.Strings.Unbounded.Text_IO}
13879 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
13880 subprograms useful for Text_IO operations on unbounded strings:
13884 @item function Get_Line (File : File_Type) return Unbounded_String;
13885 Reads a line from the specified file
13886 and returns the result as an unbounded string.
13888 @item procedure Put (File : File_Type; U : Unbounded_String);
13889 Writes the value of the given unbounded string to the specified file
13890 Similar to the effect of
13891 @code{Put (To_String (U))} except that an extra copy is avoided.
13893 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
13894 Writes the value of the given unbounded string to the specified file,
13895 followed by a @code{New_Line}.
13896 Similar to the effect of @code{Put_Line (To_String (U))} except
13897 that an extra copy is avoided.
13901 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
13902 and is optional. If the parameter is omitted, then the standard input or
13903 output file is referenced as appropriate.
13905 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
13906 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
13907 @code{Wide_Text_IO} functionality for unbounded wide strings.
13909 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
13910 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
13911 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
13914 @section Wide_Text_IO
13917 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
13918 both input and output files may contain special sequences that represent
13919 wide character values. The encoding scheme for a given file may be
13920 specified using a FORM parameter:
13927 as part of the FORM string (WCEM = wide character encoding method),
13928 where @var{x} is one of the following characters
13934 Upper half encoding
13946 The encoding methods match those that
13947 can be used in a source
13948 program, but there is no requirement that the encoding method used for
13949 the source program be the same as the encoding method used for files,
13950 and different files may use different encoding methods.
13952 The default encoding method for the standard files, and for opened files
13953 for which no WCEM parameter is given in the FORM string matches the
13954 wide character encoding specified for the main program (the default
13955 being brackets encoding if no coding method was specified with -gnatW).
13959 In this encoding, a wide character is represented by a five character
13967 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
13968 characters (using upper case letters) of the wide character code. For
13969 example, ESC A345 is used to represent the wide character with code
13970 16#A345#. This scheme is compatible with use of the full
13971 @code{Wide_Character} set.
13973 @item Upper Half Coding
13974 The wide character with encoding 16#abcd#, where the upper bit is on
13975 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
13976 16#cd#. The second byte may never be a format control character, but is
13977 not required to be in the upper half. This method can be also used for
13978 shift-JIS or EUC where the internal coding matches the external coding.
13980 @item Shift JIS Coding
13981 A wide character is represented by a two character sequence 16#ab# and
13982 16#cd#, with the restrictions described for upper half encoding as
13983 described above. The internal character code is the corresponding JIS
13984 character according to the standard algorithm for Shift-JIS
13985 conversion. Only characters defined in the JIS code set table can be
13986 used with this encoding method.
13989 A wide character is represented by a two character sequence 16#ab# and
13990 16#cd#, with both characters being in the upper half. The internal
13991 character code is the corresponding JIS character according to the EUC
13992 encoding algorithm. Only characters defined in the JIS code set table
13993 can be used with this encoding method.
13996 A wide character is represented using
13997 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13998 10646-1/Am.2. Depending on the character value, the representation
13999 is a one, two, or three byte sequence:
14002 16#0000#-16#007f#: 2#0xxxxxxx#
14003 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
14004 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14008 where the @var{xxx} bits correspond to the left-padded bits of the
14009 16-bit character value. Note that all lower half ASCII characters
14010 are represented as ASCII bytes and all upper half characters and
14011 other wide characters are represented as sequences of upper-half
14012 (The full UTF-8 scheme allows for encoding 31-bit characters as
14013 6-byte sequences, but in this implementation, all UTF-8 sequences
14014 of four or more bytes length will raise a Constraint_Error, as
14015 will all invalid UTF-8 sequences.)
14017 @item Brackets Coding
14018 In this encoding, a wide character is represented by the following eight
14019 character sequence:
14026 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
14027 characters (using uppercase letters) of the wide character code. For
14028 example, @code{["A345"]} is used to represent the wide character with code
14030 This scheme is compatible with use of the full Wide_Character set.
14031 On input, brackets coding can also be used for upper half characters,
14032 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14033 is only used for wide characters with a code greater than @code{16#FF#}.
14035 Note that brackets coding is not normally used in the context of
14036 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
14037 a portable way of encoding source files. In the context of Wide_Text_IO
14038 or Wide_Wide_Text_IO, it can only be used if the file does not contain
14039 any instance of the left bracket character other than to encode wide
14040 character values using the brackets encoding method. In practice it is
14041 expected that some standard wide character encoding method such
14042 as UTF-8 will be used for text input output.
14044 If brackets notation is used, then any occurrence of a left bracket
14045 in the input file which is not the start of a valid wide character
14046 sequence will cause Constraint_Error to be raised. It is possible to
14047 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
14048 input will interpret this as a left bracket.
14050 However, when a left bracket is output, it will be output as a left bracket
14051 and not as ["5B"]. We make this decision because for normal use of
14052 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
14053 brackets. For example, if we write:
14056 Put_Line ("Start of output [first run]");
14060 we really do not want to have the left bracket in this message clobbered so
14061 that the output reads:
14064 Start of output ["5B"]first run]
14068 In practice brackets encoding is reasonably useful for normal Put_Line use
14069 since we won't get confused between left brackets and wide character
14070 sequences in the output. But for input, or when files are written out
14071 and read back in, it really makes better sense to use one of the standard
14072 encoding methods such as UTF-8.
14077 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
14078 not all wide character
14079 values can be represented. An attempt to output a character that cannot
14080 be represented using the encoding scheme for the file causes
14081 Constraint_Error to be raised. An invalid wide character sequence on
14082 input also causes Constraint_Error to be raised.
14085 * Wide_Text_IO Stream Pointer Positioning::
14086 * Wide_Text_IO Reading and Writing Non-Regular Files::
14089 @node Wide_Text_IO Stream Pointer Positioning
14090 @subsection Stream Pointer Positioning
14093 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14094 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14097 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
14098 normal lower ASCII set (i.e.@: a character in the range:
14100 @smallexample @c ada
14101 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
14105 then although the logical position of the file pointer is unchanged by
14106 the @code{Look_Ahead} call, the stream is physically positioned past the
14107 wide character sequence. Again this is to avoid the need for buffering
14108 or backup, and all @code{Wide_Text_IO} routines check the internal
14109 indication that this situation has occurred so that this is not visible
14110 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
14111 can be observed if the wide text file shares a stream with another file.
14113 @node Wide_Text_IO Reading and Writing Non-Regular Files
14114 @subsection Reading and Writing Non-Regular Files
14117 As in the case of Text_IO, when a non-regular file is read, it is
14118 assumed that the file contains no page marks (any form characters are
14119 treated as data characters), and @code{End_Of_Page} always returns
14120 @code{False}. Similarly, the end of file indication is not sticky, so
14121 it is possible to read beyond an end of file.
14123 @node Wide_Wide_Text_IO
14124 @section Wide_Wide_Text_IO
14127 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
14128 both input and output files may contain special sequences that represent
14129 wide wide character values. The encoding scheme for a given file may be
14130 specified using a FORM parameter:
14137 as part of the FORM string (WCEM = wide character encoding method),
14138 where @var{x} is one of the following characters
14144 Upper half encoding
14156 The encoding methods match those that
14157 can be used in a source
14158 program, but there is no requirement that the encoding method used for
14159 the source program be the same as the encoding method used for files,
14160 and different files may use different encoding methods.
14162 The default encoding method for the standard files, and for opened files
14163 for which no WCEM parameter is given in the FORM string matches the
14164 wide character encoding specified for the main program (the default
14165 being brackets encoding if no coding method was specified with -gnatW).
14170 A wide character is represented using
14171 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14172 10646-1/Am.2. Depending on the character value, the representation
14173 is a one, two, three, or four byte sequence:
14176 16#000000#-16#00007f#: 2#0xxxxxxx#
14177 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
14178 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14179 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
14183 where the @var{xxx} bits correspond to the left-padded bits of the
14184 21-bit character value. Note that all lower half ASCII characters
14185 are represented as ASCII bytes and all upper half characters and
14186 other wide characters are represented as sequences of upper-half
14189 @item Brackets Coding
14190 In this encoding, a wide wide character is represented by the following eight
14191 character sequence if is in wide character range
14197 and by the following ten character sequence if not
14200 [ " a b c d e f " ]
14204 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
14205 are the four or six hexadecimal
14206 characters (using uppercase letters) of the wide wide character code. For
14207 example, @code{["01A345"]} is used to represent the wide wide character
14208 with code @code{16#01A345#}.
14210 This scheme is compatible with use of the full Wide_Wide_Character set.
14211 On input, brackets coding can also be used for upper half characters,
14212 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14213 is only used for wide characters with a code greater than @code{16#FF#}.
14218 If is also possible to use the other Wide_Character encoding methods,
14219 such as Shift-JIS, but the other schemes cannot support the full range
14220 of wide wide characters.
14221 An attempt to output a character that cannot
14222 be represented using the encoding scheme for the file causes
14223 Constraint_Error to be raised. An invalid wide character sequence on
14224 input also causes Constraint_Error to be raised.
14227 * Wide_Wide_Text_IO Stream Pointer Positioning::
14228 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
14231 @node Wide_Wide_Text_IO Stream Pointer Positioning
14232 @subsection Stream Pointer Positioning
14235 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14236 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14239 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
14240 normal lower ASCII set (i.e.@: a character in the range:
14242 @smallexample @c ada
14243 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
14247 then although the logical position of the file pointer is unchanged by
14248 the @code{Look_Ahead} call, the stream is physically positioned past the
14249 wide character sequence. Again this is to avoid the need for buffering
14250 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
14251 indication that this situation has occurred so that this is not visible
14252 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
14253 can be observed if the wide text file shares a stream with another file.
14255 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
14256 @subsection Reading and Writing Non-Regular Files
14259 As in the case of Text_IO, when a non-regular file is read, it is
14260 assumed that the file contains no page marks (any form characters are
14261 treated as data characters), and @code{End_Of_Page} always returns
14262 @code{False}. Similarly, the end of file indication is not sticky, so
14263 it is possible to read beyond an end of file.
14269 A stream file is a sequence of bytes, where individual elements are
14270 written to the file as described in the Ada Reference Manual. The type
14271 @code{Stream_Element} is simply a byte. There are two ways to read or
14272 write a stream file.
14276 The operations @code{Read} and @code{Write} directly read or write a
14277 sequence of stream elements with no control information.
14280 The stream attributes applied to a stream file transfer data in the
14281 manner described for stream attributes.
14284 @node Text Translation
14285 @section Text Translation
14288 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
14289 passed to Text_IO.Create and Text_IO.Open:
14290 @samp{Text_Translation=@var{Yes}} is the default, which means to
14291 translate LF to/from CR/LF on Windows systems.
14292 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
14293 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
14294 may be used to create Unix-style files on
14295 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
14299 @section Shared Files
14302 Section A.14 of the Ada Reference Manual allows implementations to
14303 provide a wide variety of behavior if an attempt is made to access the
14304 same external file with two or more internal files.
14306 To provide a full range of functionality, while at the same time
14307 minimizing the problems of portability caused by this implementation
14308 dependence, GNAT handles file sharing as follows:
14312 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
14313 to open two or more files with the same full name is considered an error
14314 and is not supported. The exception @code{Use_Error} will be
14315 raised. Note that a file that is not explicitly closed by the program
14316 remains open until the program terminates.
14319 If the form parameter @samp{shared=no} appears in the form string, the
14320 file can be opened or created with its own separate stream identifier,
14321 regardless of whether other files sharing the same external file are
14322 opened. The exact effect depends on how the C stream routines handle
14323 multiple accesses to the same external files using separate streams.
14326 If the form parameter @samp{shared=yes} appears in the form string for
14327 each of two or more files opened using the same full name, the same
14328 stream is shared between these files, and the semantics are as described
14329 in Ada Reference Manual, Section A.14.
14333 When a program that opens multiple files with the same name is ported
14334 from another Ada compiler to GNAT, the effect will be that
14335 @code{Use_Error} is raised.
14337 The documentation of the original compiler and the documentation of the
14338 program should then be examined to determine if file sharing was
14339 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
14340 and @code{Create} calls as required.
14342 When a program is ported from GNAT to some other Ada compiler, no
14343 special attention is required unless the @samp{shared=@var{xxx}} form
14344 parameter is used in the program. In this case, you must examine the
14345 documentation of the new compiler to see if it supports the required
14346 file sharing semantics, and form strings modified appropriately. Of
14347 course it may be the case that the program cannot be ported if the
14348 target compiler does not support the required functionality. The best
14349 approach in writing portable code is to avoid file sharing (and hence
14350 the use of the @samp{shared=@var{xxx}} parameter in the form string)
14353 One common use of file sharing in Ada 83 is the use of instantiations of
14354 Sequential_IO on the same file with different types, to achieve
14355 heterogeneous input-output. Although this approach will work in GNAT if
14356 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
14357 for this purpose (using the stream attributes)
14359 @node Filenames encoding
14360 @section Filenames encoding
14363 An encoding form parameter can be used to specify the filename
14364 encoding @samp{encoding=@var{xxx}}.
14368 If the form parameter @samp{encoding=utf8} appears in the form string, the
14369 filename must be encoded in UTF-8.
14372 If the form parameter @samp{encoding=8bits} appears in the form
14373 string, the filename must be a standard 8bits string.
14376 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
14377 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
14378 variable. And if not set @samp{utf8} is assumed.
14382 The current system Windows ANSI code page.
14387 This encoding form parameter is only supported on the Windows
14388 platform. On the other Operating Systems the run-time is supporting
14392 @section Open Modes
14395 @code{Open} and @code{Create} calls result in a call to @code{fopen}
14396 using the mode shown in the following table:
14399 @center @code{Open} and @code{Create} Call Modes
14401 @b{OPEN } @b{CREATE}
14402 Append_File "r+" "w+"
14404 Out_File (Direct_IO) "r+" "w"
14405 Out_File (all other cases) "w" "w"
14406 Inout_File "r+" "w+"
14410 If text file translation is required, then either @samp{b} or @samp{t}
14411 is added to the mode, depending on the setting of Text. Text file
14412 translation refers to the mapping of CR/LF sequences in an external file
14413 to LF characters internally. This mapping only occurs in DOS and
14414 DOS-like systems, and is not relevant to other systems.
14416 A special case occurs with Stream_IO@. As shown in the above table, the
14417 file is initially opened in @samp{r} or @samp{w} mode for the
14418 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
14419 subsequently requires switching from reading to writing or vice-versa,
14420 then the file is reopened in @samp{r+} mode to permit the required operation.
14422 @node Operations on C Streams
14423 @section Operations on C Streams
14424 The package @code{Interfaces.C_Streams} provides an Ada program with direct
14425 access to the C library functions for operations on C streams:
14427 @smallexample @c adanocomment
14428 package Interfaces.C_Streams is
14429 -- Note: the reason we do not use the types that are in
14430 -- Interfaces.C is that we want to avoid dragging in the
14431 -- code in this unit if possible.
14432 subtype chars is System.Address;
14433 -- Pointer to null-terminated array of characters
14434 subtype FILEs is System.Address;
14435 -- Corresponds to the C type FILE*
14436 subtype voids is System.Address;
14437 -- Corresponds to the C type void*
14438 subtype int is Integer;
14439 subtype long is Long_Integer;
14440 -- Note: the above types are subtypes deliberately, and it
14441 -- is part of this spec that the above correspondences are
14442 -- guaranteed. This means that it is legitimate to, for
14443 -- example, use Integer instead of int. We provide these
14444 -- synonyms for clarity, but in some cases it may be
14445 -- convenient to use the underlying types (for example to
14446 -- avoid an unnecessary dependency of a spec on the spec
14448 type size_t is mod 2 ** Standard'Address_Size;
14449 NULL_Stream : constant FILEs;
14450 -- Value returned (NULL in C) to indicate an
14451 -- fdopen/fopen/tmpfile error
14452 ----------------------------------
14453 -- Constants Defined in stdio.h --
14454 ----------------------------------
14455 EOF : constant int;
14456 -- Used by a number of routines to indicate error or
14458 IOFBF : constant int;
14459 IOLBF : constant int;
14460 IONBF : constant int;
14461 -- Used to indicate buffering mode for setvbuf call
14462 SEEK_CUR : constant int;
14463 SEEK_END : constant int;
14464 SEEK_SET : constant int;
14465 -- Used to indicate origin for fseek call
14466 function stdin return FILEs;
14467 function stdout return FILEs;
14468 function stderr return FILEs;
14469 -- Streams associated with standard files
14470 --------------------------
14471 -- Standard C functions --
14472 --------------------------
14473 -- The functions selected below are ones that are
14474 -- available in UNIX (but not necessarily in ANSI C).
14475 -- These are very thin interfaces
14476 -- which copy exactly the C headers. For more
14477 -- documentation on these functions, see the Microsoft C
14478 -- "Run-Time Library Reference" (Microsoft Press, 1990,
14479 -- ISBN 1-55615-225-6), which includes useful information
14480 -- on system compatibility.
14481 procedure clearerr (stream : FILEs);
14482 function fclose (stream : FILEs) return int;
14483 function fdopen (handle : int; mode : chars) return FILEs;
14484 function feof (stream : FILEs) return int;
14485 function ferror (stream : FILEs) return int;
14486 function fflush (stream : FILEs) return int;
14487 function fgetc (stream : FILEs) return int;
14488 function fgets (strng : chars; n : int; stream : FILEs)
14490 function fileno (stream : FILEs) return int;
14491 function fopen (filename : chars; Mode : chars)
14493 -- Note: to maintain target independence, use
14494 -- text_translation_required, a boolean variable defined in
14495 -- a-sysdep.c to deal with the target dependent text
14496 -- translation requirement. If this variable is set,
14497 -- then b/t should be appended to the standard mode
14498 -- argument to set the text translation mode off or on
14500 function fputc (C : int; stream : FILEs) return int;
14501 function fputs (Strng : chars; Stream : FILEs) return int;
14518 function ftell (stream : FILEs) return long;
14525 function isatty (handle : int) return int;
14526 procedure mktemp (template : chars);
14527 -- The return value (which is just a pointer to template)
14529 procedure rewind (stream : FILEs);
14530 function rmtmp return int;
14538 function tmpfile return FILEs;
14539 function ungetc (c : int; stream : FILEs) return int;
14540 function unlink (filename : chars) return int;
14541 ---------------------
14542 -- Extra functions --
14543 ---------------------
14544 -- These functions supply slightly thicker bindings than
14545 -- those above. They are derived from functions in the
14546 -- C Run-Time Library, but may do a bit more work than
14547 -- just directly calling one of the Library functions.
14548 function is_regular_file (handle : int) return int;
14549 -- Tests if given handle is for a regular file (result 1)
14550 -- or for a non-regular file (pipe or device, result 0).
14551 ---------------------------------
14552 -- Control of Text/Binary Mode --
14553 ---------------------------------
14554 -- If text_translation_required is true, then the following
14555 -- functions may be used to dynamically switch a file from
14556 -- binary to text mode or vice versa. These functions have
14557 -- no effect if text_translation_required is false (i.e.@: in
14558 -- normal UNIX mode). Use fileno to get a stream handle.
14559 procedure set_binary_mode (handle : int);
14560 procedure set_text_mode (handle : int);
14561 ----------------------------
14562 -- Full Path Name support --
14563 ----------------------------
14564 procedure full_name (nam : chars; buffer : chars);
14565 -- Given a NUL terminated string representing a file
14566 -- name, returns in buffer a NUL terminated string
14567 -- representing the full path name for the file name.
14568 -- On systems where it is relevant the drive is also
14569 -- part of the full path name. It is the responsibility
14570 -- of the caller to pass an actual parameter for buffer
14571 -- that is big enough for any full path name. Use
14572 -- max_path_len given below as the size of buffer.
14573 max_path_len : integer;
14574 -- Maximum length of an allowable full path name on the
14575 -- system, including a terminating NUL character.
14576 end Interfaces.C_Streams;
14579 @node Interfacing to C Streams
14580 @section Interfacing to C Streams
14583 The packages in this section permit interfacing Ada files to C Stream
14586 @smallexample @c ada
14587 with Interfaces.C_Streams;
14588 package Ada.Sequential_IO.C_Streams is
14589 function C_Stream (F : File_Type)
14590 return Interfaces.C_Streams.FILEs;
14592 (File : in out File_Type;
14593 Mode : in File_Mode;
14594 C_Stream : in Interfaces.C_Streams.FILEs;
14595 Form : in String := "");
14596 end Ada.Sequential_IO.C_Streams;
14598 with Interfaces.C_Streams;
14599 package Ada.Direct_IO.C_Streams is
14600 function C_Stream (F : File_Type)
14601 return Interfaces.C_Streams.FILEs;
14603 (File : in out File_Type;
14604 Mode : in File_Mode;
14605 C_Stream : in Interfaces.C_Streams.FILEs;
14606 Form : in String := "");
14607 end Ada.Direct_IO.C_Streams;
14609 with Interfaces.C_Streams;
14610 package Ada.Text_IO.C_Streams is
14611 function C_Stream (F : File_Type)
14612 return Interfaces.C_Streams.FILEs;
14614 (File : in out File_Type;
14615 Mode : in File_Mode;
14616 C_Stream : in Interfaces.C_Streams.FILEs;
14617 Form : in String := "");
14618 end Ada.Text_IO.C_Streams;
14620 with Interfaces.C_Streams;
14621 package Ada.Wide_Text_IO.C_Streams is
14622 function C_Stream (F : File_Type)
14623 return Interfaces.C_Streams.FILEs;
14625 (File : in out File_Type;
14626 Mode : in File_Mode;
14627 C_Stream : in Interfaces.C_Streams.FILEs;
14628 Form : in String := "");
14629 end Ada.Wide_Text_IO.C_Streams;
14631 with Interfaces.C_Streams;
14632 package Ada.Wide_Wide_Text_IO.C_Streams is
14633 function C_Stream (F : File_Type)
14634 return Interfaces.C_Streams.FILEs;
14636 (File : in out File_Type;
14637 Mode : in File_Mode;
14638 C_Stream : in Interfaces.C_Streams.FILEs;
14639 Form : in String := "");
14640 end Ada.Wide_Wide_Text_IO.C_Streams;
14642 with Interfaces.C_Streams;
14643 package Ada.Stream_IO.C_Streams is
14644 function C_Stream (F : File_Type)
14645 return Interfaces.C_Streams.FILEs;
14647 (File : in out File_Type;
14648 Mode : in File_Mode;
14649 C_Stream : in Interfaces.C_Streams.FILEs;
14650 Form : in String := "");
14651 end Ada.Stream_IO.C_Streams;
14655 In each of these six packages, the @code{C_Stream} function obtains the
14656 @code{FILE} pointer from a currently opened Ada file. It is then
14657 possible to use the @code{Interfaces.C_Streams} package to operate on
14658 this stream, or the stream can be passed to a C program which can
14659 operate on it directly. Of course the program is responsible for
14660 ensuring that only appropriate sequences of operations are executed.
14662 One particular use of relevance to an Ada program is that the
14663 @code{setvbuf} function can be used to control the buffering of the
14664 stream used by an Ada file. In the absence of such a call the standard
14665 default buffering is used.
14667 The @code{Open} procedures in these packages open a file giving an
14668 existing C Stream instead of a file name. Typically this stream is
14669 imported from a C program, allowing an Ada file to operate on an
14672 @node The GNAT Library
14673 @chapter The GNAT Library
14676 The GNAT library contains a number of general and special purpose packages.
14677 It represents functionality that the GNAT developers have found useful, and
14678 which is made available to GNAT users. The packages described here are fully
14679 supported, and upwards compatibility will be maintained in future releases,
14680 so you can use these facilities with the confidence that the same functionality
14681 will be available in future releases.
14683 The chapter here simply gives a brief summary of the facilities available.
14684 The full documentation is found in the spec file for the package. The full
14685 sources of these library packages, including both spec and body, are provided
14686 with all GNAT releases. For example, to find out the full specifications of
14687 the SPITBOL pattern matching capability, including a full tutorial and
14688 extensive examples, look in the @file{g-spipat.ads} file in the library.
14690 For each entry here, the package name (as it would appear in a @code{with}
14691 clause) is given, followed by the name of the corresponding spec file in
14692 parentheses. The packages are children in four hierarchies, @code{Ada},
14693 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
14694 GNAT-specific hierarchy.
14696 Note that an application program should only use packages in one of these
14697 four hierarchies if the package is defined in the Ada Reference Manual,
14698 or is listed in this section of the GNAT Programmers Reference Manual.
14699 All other units should be considered internal implementation units and
14700 should not be directly @code{with}'ed by application code. The use of
14701 a @code{with} statement that references one of these internal implementation
14702 units makes an application potentially dependent on changes in versions
14703 of GNAT, and will generate a warning message.
14706 * Ada.Characters.Latin_9 (a-chlat9.ads)::
14707 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
14708 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
14709 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
14710 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
14711 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
14712 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
14713 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
14714 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
14715 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
14716 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
14717 * Ada.Command_Line.Environment (a-colien.ads)::
14718 * Ada.Command_Line.Remove (a-colire.ads)::
14719 * Ada.Command_Line.Response_File (a-clrefi.ads)::
14720 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
14721 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
14722 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
14723 * Ada.Exceptions.Traceback (a-exctra.ads)::
14724 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
14725 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
14726 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
14727 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
14728 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
14729 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
14730 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
14731 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
14732 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
14733 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
14734 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
14735 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
14736 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
14737 * GNAT.Altivec (g-altive.ads)::
14738 * GNAT.Altivec.Conversions (g-altcon.ads)::
14739 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
14740 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
14741 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
14742 * GNAT.Array_Split (g-arrspl.ads)::
14743 * GNAT.AWK (g-awk.ads)::
14744 * GNAT.Bounded_Buffers (g-boubuf.ads)::
14745 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
14746 * GNAT.Bubble_Sort (g-bubsor.ads)::
14747 * GNAT.Bubble_Sort_A (g-busora.ads)::
14748 * GNAT.Bubble_Sort_G (g-busorg.ads)::
14749 * GNAT.Byte_Order_Mark (g-byorma.ads)::
14750 * GNAT.Byte_Swapping (g-bytswa.ads)::
14751 * GNAT.Calendar (g-calend.ads)::
14752 * GNAT.Calendar.Time_IO (g-catiio.ads)::
14753 * GNAT.Case_Util (g-casuti.ads)::
14754 * GNAT.CGI (g-cgi.ads)::
14755 * GNAT.CGI.Cookie (g-cgicoo.ads)::
14756 * GNAT.CGI.Debug (g-cgideb.ads)::
14757 * GNAT.Command_Line (g-comlin.ads)::
14758 * GNAT.Compiler_Version (g-comver.ads)::
14759 * GNAT.Ctrl_C (g-ctrl_c.ads)::
14760 * GNAT.CRC32 (g-crc32.ads)::
14761 * GNAT.Current_Exception (g-curexc.ads)::
14762 * GNAT.Debug_Pools (g-debpoo.ads)::
14763 * GNAT.Debug_Utilities (g-debuti.ads)::
14764 * GNAT.Decode_String (g-decstr.ads)::
14765 * GNAT.Decode_UTF8_String (g-deutst.ads)::
14766 * GNAT.Directory_Operations (g-dirope.ads)::
14767 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
14768 * GNAT.Dynamic_HTables (g-dynhta.ads)::
14769 * GNAT.Dynamic_Tables (g-dyntab.ads)::
14770 * GNAT.Encode_String (g-encstr.ads)::
14771 * GNAT.Encode_UTF8_String (g-enutst.ads)::
14772 * GNAT.Exception_Actions (g-excact.ads)::
14773 * GNAT.Exception_Traces (g-exctra.ads)::
14774 * GNAT.Exceptions (g-except.ads)::
14775 * GNAT.Expect (g-expect.ads)::
14776 * GNAT.Expect.TTY (g-exptty.ads)::
14777 * GNAT.Float_Control (g-flocon.ads)::
14778 * GNAT.Heap_Sort (g-heasor.ads)::
14779 * GNAT.Heap_Sort_A (g-hesora.ads)::
14780 * GNAT.Heap_Sort_G (g-hesorg.ads)::
14781 * GNAT.HTable (g-htable.ads)::
14782 * GNAT.IO (g-io.ads)::
14783 * GNAT.IO_Aux (g-io_aux.ads)::
14784 * GNAT.Lock_Files (g-locfil.ads)::
14785 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
14786 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
14787 * GNAT.MD5 (g-md5.ads)::
14788 * GNAT.Memory_Dump (g-memdum.ads)::
14789 * GNAT.Most_Recent_Exception (g-moreex.ads)::
14790 * GNAT.OS_Lib (g-os_lib.ads)::
14791 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
14792 * GNAT.Random_Numbers (g-rannum.ads)::
14793 * GNAT.Regexp (g-regexp.ads)::
14794 * GNAT.Registry (g-regist.ads)::
14795 * GNAT.Regpat (g-regpat.ads)::
14796 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
14797 * GNAT.Semaphores (g-semaph.ads)::
14798 * GNAT.Serial_Communications (g-sercom.ads)::
14799 * GNAT.SHA1 (g-sha1.ads)::
14800 * GNAT.SHA224 (g-sha224.ads)::
14801 * GNAT.SHA256 (g-sha256.ads)::
14802 * GNAT.SHA384 (g-sha384.ads)::
14803 * GNAT.SHA512 (g-sha512.ads)::
14804 * GNAT.Signals (g-signal.ads)::
14805 * GNAT.Sockets (g-socket.ads)::
14806 * GNAT.Source_Info (g-souinf.ads)::
14807 * GNAT.Spelling_Checker (g-speche.ads)::
14808 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
14809 * GNAT.Spitbol.Patterns (g-spipat.ads)::
14810 * GNAT.Spitbol (g-spitbo.ads)::
14811 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
14812 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
14813 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
14814 * GNAT.SSE (g-sse.ads)::
14815 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
14816 * GNAT.Strings (g-string.ads)::
14817 * GNAT.String_Split (g-strspl.ads)::
14818 * GNAT.Table (g-table.ads)::
14819 * GNAT.Task_Lock (g-tasloc.ads)::
14820 * GNAT.Threads (g-thread.ads)::
14821 * GNAT.Time_Stamp (g-timsta.ads)::
14822 * GNAT.Traceback (g-traceb.ads)::
14823 * GNAT.Traceback.Symbolic (g-trasym.ads)::
14824 * GNAT.UTF_32 (g-utf_32.ads)::
14825 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
14826 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
14827 * GNAT.Wide_String_Split (g-wistsp.ads)::
14828 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
14829 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
14830 * Interfaces.C.Extensions (i-cexten.ads)::
14831 * Interfaces.C.Streams (i-cstrea.ads)::
14832 * Interfaces.CPP (i-cpp.ads)::
14833 * Interfaces.Packed_Decimal (i-pacdec.ads)::
14834 * Interfaces.VxWorks (i-vxwork.ads)::
14835 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
14836 * System.Address_Image (s-addima.ads)::
14837 * System.Assertions (s-assert.ads)::
14838 * System.Memory (s-memory.ads)::
14839 * System.Partition_Interface (s-parint.ads)::
14840 * System.Pool_Global (s-pooglo.ads)::
14841 * System.Pool_Local (s-pooloc.ads)::
14842 * System.Restrictions (s-restri.ads)::
14843 * System.Rident (s-rident.ads)::
14844 * System.Strings.Stream_Ops (s-ststop.ads)::
14845 * System.Task_Info (s-tasinf.ads)::
14846 * System.Wch_Cnv (s-wchcnv.ads)::
14847 * System.Wch_Con (s-wchcon.ads)::
14850 @node Ada.Characters.Latin_9 (a-chlat9.ads)
14851 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14852 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14853 @cindex Latin_9 constants for Character
14856 This child of @code{Ada.Characters}
14857 provides a set of definitions corresponding to those in the
14858 RM-defined package @code{Ada.Characters.Latin_1} but with the
14859 few modifications required for @code{Latin-9}
14860 The provision of such a package
14861 is specifically authorized by the Ada Reference Manual
14864 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
14865 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14866 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14867 @cindex Latin_1 constants for Wide_Character
14870 This child of @code{Ada.Characters}
14871 provides a set of definitions corresponding to those in the
14872 RM-defined package @code{Ada.Characters.Latin_1} but with the
14873 types of the constants being @code{Wide_Character}
14874 instead of @code{Character}. The provision of such a package
14875 is specifically authorized by the Ada Reference Manual
14878 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
14879 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14880 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14881 @cindex Latin_9 constants for Wide_Character
14884 This child of @code{Ada.Characters}
14885 provides a set of definitions corresponding to those in the
14886 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14887 types of the constants being @code{Wide_Character}
14888 instead of @code{Character}. The provision of such a package
14889 is specifically authorized by the Ada Reference Manual
14892 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
14893 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14894 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14895 @cindex Latin_1 constants for Wide_Wide_Character
14898 This child of @code{Ada.Characters}
14899 provides a set of definitions corresponding to those in the
14900 RM-defined package @code{Ada.Characters.Latin_1} but with the
14901 types of the constants being @code{Wide_Wide_Character}
14902 instead of @code{Character}. The provision of such a package
14903 is specifically authorized by the Ada Reference Manual
14906 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
14907 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14908 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14909 @cindex Latin_9 constants for Wide_Wide_Character
14912 This child of @code{Ada.Characters}
14913 provides a set of definitions corresponding to those in the
14914 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14915 types of the constants being @code{Wide_Wide_Character}
14916 instead of @code{Character}. The provision of such a package
14917 is specifically authorized by the Ada Reference Manual
14920 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
14921 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14922 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14923 @cindex Formal container for doubly linked lists
14926 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14927 container for doubly linked lists, meant to facilitate formal verification of
14928 code using such containers.
14930 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
14931 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14932 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14933 @cindex Formal container for hashed maps
14936 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14937 container for hashed maps, meant to facilitate formal verification of
14938 code using such containers.
14940 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
14941 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14942 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14943 @cindex Formal container for hashed sets
14946 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14947 container for hashed sets, meant to facilitate formal verification of
14948 code using such containers.
14950 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
14951 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14952 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14953 @cindex Formal container for ordered maps
14956 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14957 container for ordered maps, meant to facilitate formal verification of
14958 code using such containers.
14960 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
14961 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14962 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14963 @cindex Formal container for ordered sets
14966 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14967 container for ordered sets, meant to facilitate formal verification of
14968 code using such containers.
14970 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
14971 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14972 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14973 @cindex Formal container for vectors
14976 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14977 container for vectors, meant to facilitate formal verification of
14978 code using such containers.
14980 @node Ada.Command_Line.Environment (a-colien.ads)
14981 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14982 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14983 @cindex Environment entries
14986 This child of @code{Ada.Command_Line}
14987 provides a mechanism for obtaining environment values on systems
14988 where this concept makes sense.
14990 @node Ada.Command_Line.Remove (a-colire.ads)
14991 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14992 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14993 @cindex Removing command line arguments
14994 @cindex Command line, argument removal
14997 This child of @code{Ada.Command_Line}
14998 provides a mechanism for logically removing
14999 arguments from the argument list. Once removed, an argument is not visible
15000 to further calls on the subprograms in @code{Ada.Command_Line} will not
15001 see the removed argument.
15003 @node Ada.Command_Line.Response_File (a-clrefi.ads)
15004 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15005 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15006 @cindex Response file for command line
15007 @cindex Command line, response file
15008 @cindex Command line, handling long command lines
15011 This child of @code{Ada.Command_Line} provides a mechanism facilities for
15012 getting command line arguments from a text file, called a "response file".
15013 Using a response file allow passing a set of arguments to an executable longer
15014 than the maximum allowed by the system on the command line.
15016 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
15017 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15018 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15019 @cindex C Streams, Interfacing with Direct_IO
15022 This package provides subprograms that allow interfacing between
15023 C streams and @code{Direct_IO}. The stream identifier can be
15024 extracted from a file opened on the Ada side, and an Ada file
15025 can be constructed from a stream opened on the C side.
15027 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
15028 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15029 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15030 @cindex Null_Occurrence, testing for
15033 This child subprogram provides a way of testing for the null
15034 exception occurrence (@code{Null_Occurrence}) without raising
15037 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
15038 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15039 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15040 @cindex Null_Occurrence, testing for
15043 This child subprogram is used for handling otherwise unhandled
15044 exceptions (hence the name last chance), and perform clean ups before
15045 terminating the program. Note that this subprogram never returns.
15047 @node Ada.Exceptions.Traceback (a-exctra.ads)
15048 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15049 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15050 @cindex Traceback for Exception Occurrence
15053 This child package provides the subprogram (@code{Tracebacks}) to
15054 give a traceback array of addresses based on an exception
15057 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
15058 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15059 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15060 @cindex C Streams, Interfacing with Sequential_IO
15063 This package provides subprograms that allow interfacing between
15064 C streams and @code{Sequential_IO}. The stream identifier can be
15065 extracted from a file opened on the Ada side, and an Ada file
15066 can be constructed from a stream opened on the C side.
15068 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
15069 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15070 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15071 @cindex C Streams, Interfacing with Stream_IO
15074 This package provides subprograms that allow interfacing between
15075 C streams and @code{Stream_IO}. The stream identifier can be
15076 extracted from a file opened on the Ada side, and an Ada file
15077 can be constructed from a stream opened on the C side.
15079 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
15080 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15081 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15082 @cindex @code{Unbounded_String}, IO support
15083 @cindex @code{Text_IO}, extensions for unbounded strings
15086 This package provides subprograms for Text_IO for unbounded
15087 strings, avoiding the necessity for an intermediate operation
15088 with ordinary strings.
15090 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
15091 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15092 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15093 @cindex @code{Unbounded_Wide_String}, IO support
15094 @cindex @code{Text_IO}, extensions for unbounded wide strings
15097 This package provides subprograms for Text_IO for unbounded
15098 wide strings, avoiding the necessity for an intermediate operation
15099 with ordinary wide strings.
15101 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
15102 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15103 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15104 @cindex @code{Unbounded_Wide_Wide_String}, IO support
15105 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
15108 This package provides subprograms for Text_IO for unbounded
15109 wide wide strings, avoiding the necessity for an intermediate operation
15110 with ordinary wide wide strings.
15112 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
15113 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15114 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15115 @cindex C Streams, Interfacing with @code{Text_IO}
15118 This package provides subprograms that allow interfacing between
15119 C streams and @code{Text_IO}. The stream identifier can be
15120 extracted from a file opened on the Ada side, and an Ada file
15121 can be constructed from a stream opened on the C side.
15123 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
15124 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15125 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15126 @cindex @code{Text_IO} resetting standard files
15129 This procedure is used to reset the status of the standard files used
15130 by Ada.Text_IO. This is useful in a situation (such as a restart in an
15131 embedded application) where the status of the files may change during
15132 execution (for example a standard input file may be redefined to be
15135 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
15136 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15137 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15138 @cindex Unicode categorization, Wide_Character
15141 This package provides subprograms that allow categorization of
15142 Wide_Character values according to Unicode categories.
15144 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
15145 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15146 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15147 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
15150 This package provides subprograms that allow interfacing between
15151 C streams and @code{Wide_Text_IO}. The stream identifier can be
15152 extracted from a file opened on the Ada side, and an Ada file
15153 can be constructed from a stream opened on the C side.
15155 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
15156 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15157 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15158 @cindex @code{Wide_Text_IO} resetting standard files
15161 This procedure is used to reset the status of the standard files used
15162 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
15163 embedded application) where the status of the files may change during
15164 execution (for example a standard input file may be redefined to be
15167 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
15168 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15169 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15170 @cindex Unicode categorization, Wide_Wide_Character
15173 This package provides subprograms that allow categorization of
15174 Wide_Wide_Character values according to Unicode categories.
15176 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
15177 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15178 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15179 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
15182 This package provides subprograms that allow interfacing between
15183 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
15184 extracted from a file opened on the Ada side, and an Ada file
15185 can be constructed from a stream opened on the C side.
15187 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
15188 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15189 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15190 @cindex @code{Wide_Wide_Text_IO} resetting standard files
15193 This procedure is used to reset the status of the standard files used
15194 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
15195 restart in an embedded application) where the status of the files may
15196 change during execution (for example a standard input file may be
15197 redefined to be interactive).
15199 @node GNAT.Altivec (g-altive.ads)
15200 @section @code{GNAT.Altivec} (@file{g-altive.ads})
15201 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
15205 This is the root package of the GNAT AltiVec binding. It provides
15206 definitions of constants and types common to all the versions of the
15209 @node GNAT.Altivec.Conversions (g-altcon.ads)
15210 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15211 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15215 This package provides the Vector/View conversion routines.
15217 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
15218 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15219 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15223 This package exposes the Ada interface to the AltiVec operations on
15224 vector objects. A soft emulation is included by default in the GNAT
15225 library. The hard binding is provided as a separate package. This unit
15226 is common to both bindings.
15228 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
15229 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15230 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15234 This package exposes the various vector types part of the Ada binding
15235 to AltiVec facilities.
15237 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
15238 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15239 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15243 This package provides public 'View' data types from/to which private
15244 vector representations can be converted via
15245 GNAT.Altivec.Conversions. This allows convenient access to individual
15246 vector elements and provides a simple way to initialize vector
15249 @node GNAT.Array_Split (g-arrspl.ads)
15250 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15251 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15252 @cindex Array splitter
15255 Useful array-manipulation routines: given a set of separators, split
15256 an array wherever the separators appear, and provide direct access
15257 to the resulting slices.
15259 @node GNAT.AWK (g-awk.ads)
15260 @section @code{GNAT.AWK} (@file{g-awk.ads})
15261 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
15266 Provides AWK-like parsing functions, with an easy interface for parsing one
15267 or more files containing formatted data. The file is viewed as a database
15268 where each record is a line and a field is a data element in this line.
15270 @node GNAT.Bounded_Buffers (g-boubuf.ads)
15271 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15272 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15274 @cindex Bounded Buffers
15277 Provides a concurrent generic bounded buffer abstraction. Instances are
15278 useful directly or as parts of the implementations of other abstractions,
15281 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
15282 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15283 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15288 Provides a thread-safe asynchronous intertask mailbox communication facility.
15290 @node GNAT.Bubble_Sort (g-bubsor.ads)
15291 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15292 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15294 @cindex Bubble sort
15297 Provides a general implementation of bubble sort usable for sorting arbitrary
15298 data items. Exchange and comparison procedures are provided by passing
15299 access-to-procedure values.
15301 @node GNAT.Bubble_Sort_A (g-busora.ads)
15302 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15303 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15305 @cindex Bubble sort
15308 Provides a general implementation of bubble sort usable for sorting arbitrary
15309 data items. Move and comparison procedures are provided by passing
15310 access-to-procedure values. This is an older version, retained for
15311 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
15313 @node GNAT.Bubble_Sort_G (g-busorg.ads)
15314 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15315 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15317 @cindex Bubble sort
15320 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
15321 are provided as generic parameters, this improves efficiency, especially
15322 if the procedures can be inlined, at the expense of duplicating code for
15323 multiple instantiations.
15325 @node GNAT.Byte_Order_Mark (g-byorma.ads)
15326 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15327 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15328 @cindex UTF-8 representation
15329 @cindex Wide characte representations
15332 Provides a routine which given a string, reads the start of the string to
15333 see whether it is one of the standard byte order marks (BOM's) which signal
15334 the encoding of the string. The routine includes detection of special XML
15335 sequences for various UCS input formats.
15337 @node GNAT.Byte_Swapping (g-bytswa.ads)
15338 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15339 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15340 @cindex Byte swapping
15344 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
15345 Machine-specific implementations are available in some cases.
15347 @node GNAT.Calendar (g-calend.ads)
15348 @section @code{GNAT.Calendar} (@file{g-calend.ads})
15349 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
15350 @cindex @code{Calendar}
15353 Extends the facilities provided by @code{Ada.Calendar} to include handling
15354 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
15355 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
15356 C @code{timeval} format.
15358 @node GNAT.Calendar.Time_IO (g-catiio.ads)
15359 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15360 @cindex @code{Calendar}
15362 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15364 @node GNAT.CRC32 (g-crc32.ads)
15365 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
15366 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
15368 @cindex Cyclic Redundancy Check
15371 This package implements the CRC-32 algorithm. For a full description
15372 of this algorithm see
15373 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
15374 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
15375 Aug.@: 1988. Sarwate, D.V@.
15377 @node GNAT.Case_Util (g-casuti.ads)
15378 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
15379 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
15380 @cindex Casing utilities
15381 @cindex Character handling (@code{GNAT.Case_Util})
15384 A set of simple routines for handling upper and lower casing of strings
15385 without the overhead of the full casing tables
15386 in @code{Ada.Characters.Handling}.
15388 @node GNAT.CGI (g-cgi.ads)
15389 @section @code{GNAT.CGI} (@file{g-cgi.ads})
15390 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
15391 @cindex CGI (Common Gateway Interface)
15394 This is a package for interfacing a GNAT program with a Web server via the
15395 Common Gateway Interface (CGI)@. Basically this package parses the CGI
15396 parameters, which are a set of key/value pairs sent by the Web server. It
15397 builds a table whose index is the key and provides some services to deal
15400 @node GNAT.CGI.Cookie (g-cgicoo.ads)
15401 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15402 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15403 @cindex CGI (Common Gateway Interface) cookie support
15404 @cindex Cookie support in CGI
15407 This is a package to interface a GNAT program with a Web server via the
15408 Common Gateway Interface (CGI). It exports services to deal with Web
15409 cookies (piece of information kept in the Web client software).
15411 @node GNAT.CGI.Debug (g-cgideb.ads)
15412 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15413 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15414 @cindex CGI (Common Gateway Interface) debugging
15417 This is a package to help debugging CGI (Common Gateway Interface)
15418 programs written in Ada.
15420 @node GNAT.Command_Line (g-comlin.ads)
15421 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
15422 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
15423 @cindex Command line
15426 Provides a high level interface to @code{Ada.Command_Line} facilities,
15427 including the ability to scan for named switches with optional parameters
15428 and expand file names using wild card notations.
15430 @node GNAT.Compiler_Version (g-comver.ads)
15431 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15432 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15433 @cindex Compiler Version
15434 @cindex Version, of compiler
15437 Provides a routine for obtaining the version of the compiler used to
15438 compile the program. More accurately this is the version of the binder
15439 used to bind the program (this will normally be the same as the version
15440 of the compiler if a consistent tool set is used to compile all units
15443 @node GNAT.Ctrl_C (g-ctrl_c.ads)
15444 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15445 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15449 Provides a simple interface to handle Ctrl-C keyboard events.
15451 @node GNAT.Current_Exception (g-curexc.ads)
15452 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15453 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15454 @cindex Current exception
15455 @cindex Exception retrieval
15458 Provides access to information on the current exception that has been raised
15459 without the need for using the Ada 95 / Ada 2005 exception choice parameter
15460 specification syntax.
15461 This is particularly useful in simulating typical facilities for
15462 obtaining information about exceptions provided by Ada 83 compilers.
15464 @node GNAT.Debug_Pools (g-debpoo.ads)
15465 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15466 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15468 @cindex Debug pools
15469 @cindex Memory corruption debugging
15472 Provide a debugging storage pools that helps tracking memory corruption
15473 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
15474 @value{EDITION} User's Guide}.
15476 @node GNAT.Debug_Utilities (g-debuti.ads)
15477 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15478 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15482 Provides a few useful utilities for debugging purposes, including conversion
15483 to and from string images of address values. Supports both C and Ada formats
15484 for hexadecimal literals.
15486 @node GNAT.Decode_String (g-decstr.ads)
15487 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
15488 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
15489 @cindex Decoding strings
15490 @cindex String decoding
15491 @cindex Wide character encoding
15496 A generic package providing routines for decoding wide character and wide wide
15497 character strings encoded as sequences of 8-bit characters using a specified
15498 encoding method. Includes validation routines, and also routines for stepping
15499 to next or previous encoded character in an encoded string.
15500 Useful in conjunction with Unicode character coding. Note there is a
15501 preinstantiation for UTF-8. See next entry.
15503 @node GNAT.Decode_UTF8_String (g-deutst.ads)
15504 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15505 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15506 @cindex Decoding strings
15507 @cindex Decoding UTF-8 strings
15508 @cindex UTF-8 string decoding
15509 @cindex Wide character decoding
15514 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
15516 @node GNAT.Directory_Operations (g-dirope.ads)
15517 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15518 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15519 @cindex Directory operations
15522 Provides a set of routines for manipulating directories, including changing
15523 the current directory, making new directories, and scanning the files in a
15526 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
15527 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15528 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15529 @cindex Directory operations iteration
15532 A child unit of GNAT.Directory_Operations providing additional operations
15533 for iterating through directories.
15535 @node GNAT.Dynamic_HTables (g-dynhta.ads)
15536 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15537 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15538 @cindex Hash tables
15541 A generic implementation of hash tables that can be used to hash arbitrary
15542 data. Provided in two forms, a simple form with built in hash functions,
15543 and a more complex form in which the hash function is supplied.
15546 This package provides a facility similar to that of @code{GNAT.HTable},
15547 except that this package declares a type that can be used to define
15548 dynamic instances of the hash table, while an instantiation of
15549 @code{GNAT.HTable} creates a single instance of the hash table.
15551 @node GNAT.Dynamic_Tables (g-dyntab.ads)
15552 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15553 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15554 @cindex Table implementation
15555 @cindex Arrays, extendable
15558 A generic package providing a single dimension array abstraction where the
15559 length of the array can be dynamically modified.
15562 This package provides a facility similar to that of @code{GNAT.Table},
15563 except that this package declares a type that can be used to define
15564 dynamic instances of the table, while an instantiation of
15565 @code{GNAT.Table} creates a single instance of the table type.
15567 @node GNAT.Encode_String (g-encstr.ads)
15568 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
15569 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
15570 @cindex Encoding strings
15571 @cindex String encoding
15572 @cindex Wide character encoding
15577 A generic package providing routines for encoding wide character and wide
15578 wide character strings as sequences of 8-bit characters using a specified
15579 encoding method. Useful in conjunction with Unicode character coding.
15580 Note there is a preinstantiation for UTF-8. See next entry.
15582 @node GNAT.Encode_UTF8_String (g-enutst.ads)
15583 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15584 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15585 @cindex Encoding strings
15586 @cindex Encoding UTF-8 strings
15587 @cindex UTF-8 string encoding
15588 @cindex Wide character encoding
15593 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
15595 @node GNAT.Exception_Actions (g-excact.ads)
15596 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15597 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15598 @cindex Exception actions
15601 Provides callbacks when an exception is raised. Callbacks can be registered
15602 for specific exceptions, or when any exception is raised. This
15603 can be used for instance to force a core dump to ease debugging.
15605 @node GNAT.Exception_Traces (g-exctra.ads)
15606 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15607 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15608 @cindex Exception traces
15612 Provides an interface allowing to control automatic output upon exception
15615 @node GNAT.Exceptions (g-except.ads)
15616 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
15617 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
15618 @cindex Exceptions, Pure
15619 @cindex Pure packages, exceptions
15622 Normally it is not possible to raise an exception with
15623 a message from a subprogram in a pure package, since the
15624 necessary types and subprograms are in @code{Ada.Exceptions}
15625 which is not a pure unit. @code{GNAT.Exceptions} provides a
15626 facility for getting around this limitation for a few
15627 predefined exceptions, and for example allow raising
15628 @code{Constraint_Error} with a message from a pure subprogram.
15630 @node GNAT.Expect (g-expect.ads)
15631 @section @code{GNAT.Expect} (@file{g-expect.ads})
15632 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
15635 Provides a set of subprograms similar to what is available
15636 with the standard Tcl Expect tool.
15637 It allows you to easily spawn and communicate with an external process.
15638 You can send commands or inputs to the process, and compare the output
15639 with some expected regular expression. Currently @code{GNAT.Expect}
15640 is implemented on all native GNAT ports except for OpenVMS@.
15641 It is not implemented for cross ports, and in particular is not
15642 implemented for VxWorks or LynxOS@.
15644 @node GNAT.Expect.TTY (g-exptty.ads)
15645 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15646 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15649 As GNAT.Expect but using pseudo-terminal.
15650 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
15651 ports except for OpenVMS@. It is not implemented for cross ports, and
15652 in particular is not implemented for VxWorks or LynxOS@.
15654 @node GNAT.Float_Control (g-flocon.ads)
15655 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
15656 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
15657 @cindex Floating-Point Processor
15660 Provides an interface for resetting the floating-point processor into the
15661 mode required for correct semantic operation in Ada. Some third party
15662 library calls may cause this mode to be modified, and the Reset procedure
15663 in this package can be used to reestablish the required mode.
15665 @node GNAT.Heap_Sort (g-heasor.ads)
15666 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15667 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15671 Provides a general implementation of heap sort usable for sorting arbitrary
15672 data items. Exchange and comparison procedures are provided by passing
15673 access-to-procedure values. The algorithm used is a modified heap sort
15674 that performs approximately N*log(N) comparisons in the worst case.
15676 @node GNAT.Heap_Sort_A (g-hesora.ads)
15677 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15678 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15682 Provides a general implementation of heap sort usable for sorting arbitrary
15683 data items. Move and comparison procedures are provided by passing
15684 access-to-procedure values. The algorithm used is a modified heap sort
15685 that performs approximately N*log(N) comparisons in the worst case.
15686 This differs from @code{GNAT.Heap_Sort} in having a less convenient
15687 interface, but may be slightly more efficient.
15689 @node GNAT.Heap_Sort_G (g-hesorg.ads)
15690 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15691 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15695 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
15696 are provided as generic parameters, this improves efficiency, especially
15697 if the procedures can be inlined, at the expense of duplicating code for
15698 multiple instantiations.
15700 @node GNAT.HTable (g-htable.ads)
15701 @section @code{GNAT.HTable} (@file{g-htable.ads})
15702 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
15703 @cindex Hash tables
15706 A generic implementation of hash tables that can be used to hash arbitrary
15707 data. Provides two approaches, one a simple static approach, and the other
15708 allowing arbitrary dynamic hash tables.
15710 @node GNAT.IO (g-io.ads)
15711 @section @code{GNAT.IO} (@file{g-io.ads})
15712 @cindex @code{GNAT.IO} (@file{g-io.ads})
15714 @cindex Input/Output facilities
15717 A simple preelaborable input-output package that provides a subset of
15718 simple Text_IO functions for reading characters and strings from
15719 Standard_Input, and writing characters, strings and integers to either
15720 Standard_Output or Standard_Error.
15722 @node GNAT.IO_Aux (g-io_aux.ads)
15723 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15724 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15726 @cindex Input/Output facilities
15728 Provides some auxiliary functions for use with Text_IO, including a test
15729 for whether a file exists, and functions for reading a line of text.
15731 @node GNAT.Lock_Files (g-locfil.ads)
15732 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15733 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15734 @cindex File locking
15735 @cindex Locking using files
15738 Provides a general interface for using files as locks. Can be used for
15739 providing program level synchronization.
15741 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
15742 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15743 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15744 @cindex Random number generation
15747 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
15748 a modified version of the Blum-Blum-Shub generator.
15750 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
15751 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15752 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15753 @cindex Random number generation
15756 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
15757 a modified version of the Blum-Blum-Shub generator.
15759 @node GNAT.MD5 (g-md5.ads)
15760 @section @code{GNAT.MD5} (@file{g-md5.ads})
15761 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
15762 @cindex Message Digest MD5
15765 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
15767 @node GNAT.Memory_Dump (g-memdum.ads)
15768 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15769 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15770 @cindex Dump Memory
15773 Provides a convenient routine for dumping raw memory to either the
15774 standard output or standard error files. Uses GNAT.IO for actual
15777 @node GNAT.Most_Recent_Exception (g-moreex.ads)
15778 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15779 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15780 @cindex Exception, obtaining most recent
15783 Provides access to the most recently raised exception. Can be used for
15784 various logging purposes, including duplicating functionality of some
15785 Ada 83 implementation dependent extensions.
15787 @node GNAT.OS_Lib (g-os_lib.ads)
15788 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15789 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15790 @cindex Operating System interface
15791 @cindex Spawn capability
15794 Provides a range of target independent operating system interface functions,
15795 including time/date management, file operations, subprocess management,
15796 including a portable spawn procedure, and access to environment variables
15797 and error return codes.
15799 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
15800 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15801 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15802 @cindex Hash functions
15805 Provides a generator of static minimal perfect hash functions. No
15806 collisions occur and each item can be retrieved from the table in one
15807 probe (perfect property). The hash table size corresponds to the exact
15808 size of the key set and no larger (minimal property). The key set has to
15809 be know in advance (static property). The hash functions are also order
15810 preserving. If w2 is inserted after w1 in the generator, their
15811 hashcode are in the same order. These hashing functions are very
15812 convenient for use with realtime applications.
15814 @node GNAT.Random_Numbers (g-rannum.ads)
15815 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15816 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15817 @cindex Random number generation
15820 Provides random number capabilities which extend those available in the
15821 standard Ada library and are more convenient to use.
15823 @node GNAT.Regexp (g-regexp.ads)
15824 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
15825 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
15826 @cindex Regular expressions
15827 @cindex Pattern matching
15830 A simple implementation of regular expressions, using a subset of regular
15831 expression syntax copied from familiar Unix style utilities. This is the
15832 simples of the three pattern matching packages provided, and is particularly
15833 suitable for ``file globbing'' applications.
15835 @node GNAT.Registry (g-regist.ads)
15836 @section @code{GNAT.Registry} (@file{g-regist.ads})
15837 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
15838 @cindex Windows Registry
15841 This is a high level binding to the Windows registry. It is possible to
15842 do simple things like reading a key value, creating a new key. For full
15843 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
15844 package provided with the Win32Ada binding
15846 @node GNAT.Regpat (g-regpat.ads)
15847 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
15848 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
15849 @cindex Regular expressions
15850 @cindex Pattern matching
15853 A complete implementation of Unix-style regular expression matching, copied
15854 from the original V7 style regular expression library written in C by
15855 Henry Spencer (and binary compatible with this C library).
15857 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
15858 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15859 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15860 @cindex Secondary Stack Info
15863 Provide the capability to query the high water mark of the current task's
15866 @node GNAT.Semaphores (g-semaph.ads)
15867 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
15868 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
15872 Provides classic counting and binary semaphores using protected types.
15874 @node GNAT.Serial_Communications (g-sercom.ads)
15875 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15876 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15877 @cindex Serial_Communications
15880 Provides a simple interface to send and receive data over a serial
15881 port. This is only supported on GNU/Linux and Windows.
15883 @node GNAT.SHA1 (g-sha1.ads)
15884 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
15885 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
15886 @cindex Secure Hash Algorithm SHA-1
15889 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
15892 @node GNAT.SHA224 (g-sha224.ads)
15893 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
15894 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
15895 @cindex Secure Hash Algorithm SHA-224
15898 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
15900 @node GNAT.SHA256 (g-sha256.ads)
15901 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
15902 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
15903 @cindex Secure Hash Algorithm SHA-256
15906 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
15908 @node GNAT.SHA384 (g-sha384.ads)
15909 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
15910 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
15911 @cindex Secure Hash Algorithm SHA-384
15914 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
15916 @node GNAT.SHA512 (g-sha512.ads)
15917 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
15918 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
15919 @cindex Secure Hash Algorithm SHA-512
15922 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
15924 @node GNAT.Signals (g-signal.ads)
15925 @section @code{GNAT.Signals} (@file{g-signal.ads})
15926 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
15930 Provides the ability to manipulate the blocked status of signals on supported
15933 @node GNAT.Sockets (g-socket.ads)
15934 @section @code{GNAT.Sockets} (@file{g-socket.ads})
15935 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
15939 A high level and portable interface to develop sockets based applications.
15940 This package is based on the sockets thin binding found in
15941 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
15942 on all native GNAT ports except for OpenVMS@. It is not implemented
15943 for the LynxOS@ cross port.
15945 @node GNAT.Source_Info (g-souinf.ads)
15946 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
15947 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
15948 @cindex Source Information
15951 Provides subprograms that give access to source code information known at
15952 compile time, such as the current file name and line number.
15954 @node GNAT.Spelling_Checker (g-speche.ads)
15955 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15956 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15957 @cindex Spell checking
15960 Provides a function for determining whether one string is a plausible
15961 near misspelling of another string.
15963 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
15964 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15965 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15966 @cindex Spell checking
15969 Provides a generic function that can be instantiated with a string type for
15970 determining whether one string is a plausible near misspelling of another
15973 @node GNAT.Spitbol.Patterns (g-spipat.ads)
15974 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15975 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15976 @cindex SPITBOL pattern matching
15977 @cindex Pattern matching
15980 A complete implementation of SNOBOL4 style pattern matching. This is the
15981 most elaborate of the pattern matching packages provided. It fully duplicates
15982 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
15983 efficient algorithm developed by Robert Dewar for the SPITBOL system.
15985 @node GNAT.Spitbol (g-spitbo.ads)
15986 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15987 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15988 @cindex SPITBOL interface
15991 The top level package of the collection of SPITBOL-style functionality, this
15992 package provides basic SNOBOL4 string manipulation functions, such as
15993 Pad, Reverse, Trim, Substr capability, as well as a generic table function
15994 useful for constructing arbitrary mappings from strings in the style of
15995 the SNOBOL4 TABLE function.
15997 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
15998 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15999 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16000 @cindex Sets of strings
16001 @cindex SPITBOL Tables
16004 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16005 for type @code{Standard.Boolean}, giving an implementation of sets of
16008 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
16009 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16010 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16011 @cindex Integer maps
16013 @cindex SPITBOL Tables
16016 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16017 for type @code{Standard.Integer}, giving an implementation of maps
16018 from string to integer values.
16020 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
16021 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16022 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16023 @cindex String maps
16025 @cindex SPITBOL Tables
16028 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
16029 a variable length string type, giving an implementation of general
16030 maps from strings to strings.
16032 @node GNAT.SSE (g-sse.ads)
16033 @section @code{GNAT.SSE} (@file{g-sse.ads})
16034 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
16037 Root of a set of units aimed at offering Ada bindings to a subset of
16038 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
16039 targets. It exposes vector component types together with a general
16040 introduction to the binding contents and use.
16042 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
16043 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16044 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16047 SSE vector types for use with SSE related intrinsics.
16049 @node GNAT.Strings (g-string.ads)
16050 @section @code{GNAT.Strings} (@file{g-string.ads})
16051 @cindex @code{GNAT.Strings} (@file{g-string.ads})
16054 Common String access types and related subprograms. Basically it
16055 defines a string access and an array of string access types.
16057 @node GNAT.String_Split (g-strspl.ads)
16058 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
16059 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
16060 @cindex String splitter
16063 Useful string manipulation routines: given a set of separators, split
16064 a string wherever the separators appear, and provide direct access
16065 to the resulting slices. This package is instantiated from
16066 @code{GNAT.Array_Split}.
16068 @node GNAT.Table (g-table.ads)
16069 @section @code{GNAT.Table} (@file{g-table.ads})
16070 @cindex @code{GNAT.Table} (@file{g-table.ads})
16071 @cindex Table implementation
16072 @cindex Arrays, extendable
16075 A generic package providing a single dimension array abstraction where the
16076 length of the array can be dynamically modified.
16079 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
16080 except that this package declares a single instance of the table type,
16081 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
16082 used to define dynamic instances of the table.
16084 @node GNAT.Task_Lock (g-tasloc.ads)
16085 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16086 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16087 @cindex Task synchronization
16088 @cindex Task locking
16092 A very simple facility for locking and unlocking sections of code using a
16093 single global task lock. Appropriate for use in situations where contention
16094 between tasks is very rarely expected.
16096 @node GNAT.Time_Stamp (g-timsta.ads)
16097 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16098 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16100 @cindex Current time
16103 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
16104 represents the current date and time in ISO 8601 format. This is a very simple
16105 routine with minimal code and there are no dependencies on any other unit.
16107 @node GNAT.Threads (g-thread.ads)
16108 @section @code{GNAT.Threads} (@file{g-thread.ads})
16109 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
16110 @cindex Foreign threads
16111 @cindex Threads, foreign
16114 Provides facilities for dealing with foreign threads which need to be known
16115 by the GNAT run-time system. Consult the documentation of this package for
16116 further details if your program has threads that are created by a non-Ada
16117 environment which then accesses Ada code.
16119 @node GNAT.Traceback (g-traceb.ads)
16120 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
16121 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
16122 @cindex Trace back facilities
16125 Provides a facility for obtaining non-symbolic traceback information, useful
16126 in various debugging situations.
16128 @node GNAT.Traceback.Symbolic (g-trasym.ads)
16129 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16130 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16131 @cindex Trace back facilities
16133 @node GNAT.UTF_32 (g-utf_32.ads)
16134 @section @code{GNAT.UTF_32} (@file{g-table.ads})
16135 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
16136 @cindex Wide character codes
16139 This is a package intended to be used in conjunction with the
16140 @code{Wide_Character} type in Ada 95 and the
16141 @code{Wide_Wide_Character} type in Ada 2005 (available
16142 in @code{GNAT} in Ada 2005 mode). This package contains
16143 Unicode categorization routines, as well as lexical
16144 categorization routines corresponding to the Ada 2005
16145 lexical rules for identifiers and strings, and also a
16146 lower case to upper case fold routine corresponding to
16147 the Ada 2005 rules for identifier equivalence.
16149 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
16150 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16151 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16152 @cindex Spell checking
16155 Provides a function for determining whether one wide wide string is a plausible
16156 near misspelling of another wide wide string, where the strings are represented
16157 using the UTF_32_String type defined in System.Wch_Cnv.
16159 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
16160 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16161 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16162 @cindex Spell checking
16165 Provides a function for determining whether one wide string is a plausible
16166 near misspelling of another wide string.
16168 @node GNAT.Wide_String_Split (g-wistsp.ads)
16169 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16170 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16171 @cindex Wide_String splitter
16174 Useful wide string manipulation routines: given a set of separators, split
16175 a wide string wherever the separators appear, and provide direct access
16176 to the resulting slices. This package is instantiated from
16177 @code{GNAT.Array_Split}.
16179 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
16180 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16181 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16182 @cindex Spell checking
16185 Provides a function for determining whether one wide wide string is a plausible
16186 near misspelling of another wide wide string.
16188 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
16189 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16190 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16191 @cindex Wide_Wide_String splitter
16194 Useful wide wide string manipulation routines: given a set of separators, split
16195 a wide wide string wherever the separators appear, and provide direct access
16196 to the resulting slices. This package is instantiated from
16197 @code{GNAT.Array_Split}.
16199 @node Interfaces.C.Extensions (i-cexten.ads)
16200 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16201 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16204 This package contains additional C-related definitions, intended
16205 for use with either manually or automatically generated bindings
16208 @node Interfaces.C.Streams (i-cstrea.ads)
16209 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16210 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16211 @cindex C streams, interfacing
16214 This package is a binding for the most commonly used operations
16217 @node Interfaces.CPP (i-cpp.ads)
16218 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
16219 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
16220 @cindex C++ interfacing
16221 @cindex Interfacing, to C++
16224 This package provides facilities for use in interfacing to C++. It
16225 is primarily intended to be used in connection with automated tools
16226 for the generation of C++ interfaces.
16228 @node Interfaces.Packed_Decimal (i-pacdec.ads)
16229 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16230 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16231 @cindex IBM Packed Format
16232 @cindex Packed Decimal
16235 This package provides a set of routines for conversions to and
16236 from a packed decimal format compatible with that used on IBM
16239 @node Interfaces.VxWorks (i-vxwork.ads)
16240 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16241 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16242 @cindex Interfacing to VxWorks
16243 @cindex VxWorks, interfacing
16246 This package provides a limited binding to the VxWorks API.
16247 In particular, it interfaces with the
16248 VxWorks hardware interrupt facilities.
16250 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
16251 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16252 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16253 @cindex Interfacing to VxWorks' I/O
16254 @cindex VxWorks, I/O interfacing
16255 @cindex VxWorks, Get_Immediate
16256 @cindex Get_Immediate, VxWorks
16259 This package provides a binding to the ioctl (IO/Control)
16260 function of VxWorks, defining a set of option values and
16261 function codes. A particular use of this package is
16262 to enable the use of Get_Immediate under VxWorks.
16264 @node System.Address_Image (s-addima.ads)
16265 @section @code{System.Address_Image} (@file{s-addima.ads})
16266 @cindex @code{System.Address_Image} (@file{s-addima.ads})
16267 @cindex Address image
16268 @cindex Image, of an address
16271 This function provides a useful debugging
16272 function that gives an (implementation dependent)
16273 string which identifies an address.
16275 @node System.Assertions (s-assert.ads)
16276 @section @code{System.Assertions} (@file{s-assert.ads})
16277 @cindex @code{System.Assertions} (@file{s-assert.ads})
16279 @cindex Assert_Failure, exception
16282 This package provides the declaration of the exception raised
16283 by an run-time assertion failure, as well as the routine that
16284 is used internally to raise this assertion.
16286 @node System.Memory (s-memory.ads)
16287 @section @code{System.Memory} (@file{s-memory.ads})
16288 @cindex @code{System.Memory} (@file{s-memory.ads})
16289 @cindex Memory allocation
16292 This package provides the interface to the low level routines used
16293 by the generated code for allocation and freeing storage for the
16294 default storage pool (analogous to the C routines malloc and free.
16295 It also provides a reallocation interface analogous to the C routine
16296 realloc. The body of this unit may be modified to provide alternative
16297 allocation mechanisms for the default pool, and in addition, direct
16298 calls to this unit may be made for low level allocation uses (for
16299 example see the body of @code{GNAT.Tables}).
16301 @node System.Partition_Interface (s-parint.ads)
16302 @section @code{System.Partition_Interface} (@file{s-parint.ads})
16303 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
16304 @cindex Partition interfacing functions
16307 This package provides facilities for partition interfacing. It
16308 is used primarily in a distribution context when using Annex E
16311 @node System.Pool_Global (s-pooglo.ads)
16312 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
16313 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
16314 @cindex Storage pool, global
16315 @cindex Global storage pool
16318 This package provides a storage pool that is equivalent to the default
16319 storage pool used for access types for which no pool is specifically
16320 declared. It uses malloc/free to allocate/free and does not attempt to
16321 do any automatic reclamation.
16323 @node System.Pool_Local (s-pooloc.ads)
16324 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
16325 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
16326 @cindex Storage pool, local
16327 @cindex Local storage pool
16330 This package provides a storage pool that is intended for use with locally
16331 defined access types. It uses malloc/free for allocate/free, and maintains
16332 a list of allocated blocks, so that all storage allocated for the pool can
16333 be freed automatically when the pool is finalized.
16335 @node System.Restrictions (s-restri.ads)
16336 @section @code{System.Restrictions} (@file{s-restri.ads})
16337 @cindex @code{System.Restrictions} (@file{s-restri.ads})
16338 @cindex Run-time restrictions access
16341 This package provides facilities for accessing at run time
16342 the status of restrictions specified at compile time for
16343 the partition. Information is available both with regard
16344 to actual restrictions specified, and with regard to
16345 compiler determined information on which restrictions
16346 are violated by one or more packages in the partition.
16348 @node System.Rident (s-rident.ads)
16349 @section @code{System.Rident} (@file{s-rident.ads})
16350 @cindex @code{System.Rident} (@file{s-rident.ads})
16351 @cindex Restrictions definitions
16354 This package provides definitions of the restrictions
16355 identifiers supported by GNAT, and also the format of
16356 the restrictions provided in package System.Restrictions.
16357 It is not normally necessary to @code{with} this generic package
16358 since the necessary instantiation is included in
16359 package System.Restrictions.
16361 @node System.Strings.Stream_Ops (s-ststop.ads)
16362 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16363 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16364 @cindex Stream operations
16365 @cindex String stream operations
16368 This package provides a set of stream subprograms for standard string types.
16369 It is intended primarily to support implicit use of such subprograms when
16370 stream attributes are applied to string types, but the subprograms in this
16371 package can be used directly by application programs.
16373 @node System.Task_Info (s-tasinf.ads)
16374 @section @code{System.Task_Info} (@file{s-tasinf.ads})
16375 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
16376 @cindex Task_Info pragma
16379 This package provides target dependent functionality that is used
16380 to support the @code{Task_Info} pragma
16382 @node System.Wch_Cnv (s-wchcnv.ads)
16383 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16384 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16385 @cindex Wide Character, Representation
16386 @cindex Wide String, Conversion
16387 @cindex Representation of wide characters
16390 This package provides routines for converting between
16391 wide and wide wide characters and a representation as a value of type
16392 @code{Standard.String}, using a specified wide character
16393 encoding method. It uses definitions in
16394 package @code{System.Wch_Con}.
16396 @node System.Wch_Con (s-wchcon.ads)
16397 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
16398 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
16401 This package provides definitions and descriptions of
16402 the various methods used for encoding wide characters
16403 in ordinary strings. These definitions are used by
16404 the package @code{System.Wch_Cnv}.
16406 @node Interfacing to Other Languages
16407 @chapter Interfacing to Other Languages
16409 The facilities in annex B of the Ada Reference Manual are fully
16410 implemented in GNAT, and in addition, a full interface to C++ is
16414 * Interfacing to C::
16415 * Interfacing to C++::
16416 * Interfacing to COBOL::
16417 * Interfacing to Fortran::
16418 * Interfacing to non-GNAT Ada code::
16421 @node Interfacing to C
16422 @section Interfacing to C
16425 Interfacing to C with GNAT can use one of two approaches:
16429 The types in the package @code{Interfaces.C} may be used.
16431 Standard Ada types may be used directly. This may be less portable to
16432 other compilers, but will work on all GNAT compilers, which guarantee
16433 correspondence between the C and Ada types.
16437 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
16438 effect, since this is the default. The following table shows the
16439 correspondence between Ada scalar types and the corresponding C types.
16444 @item Short_Integer
16446 @item Short_Short_Integer
16450 @item Long_Long_Integer
16458 @item Long_Long_Float
16459 This is the longest floating-point type supported by the hardware.
16463 Additionally, there are the following general correspondences between Ada
16467 Ada enumeration types map to C enumeration types directly if pragma
16468 @code{Convention C} is specified, which causes them to have int
16469 length. Without pragma @code{Convention C}, Ada enumeration types map to
16470 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
16471 @code{int}, respectively) depending on the number of values passed.
16472 This is the only case in which pragma @code{Convention C} affects the
16473 representation of an Ada type.
16476 Ada access types map to C pointers, except for the case of pointers to
16477 unconstrained types in Ada, which have no direct C equivalent.
16480 Ada arrays map directly to C arrays.
16483 Ada records map directly to C structures.
16486 Packed Ada records map to C structures where all members are bit fields
16487 of the length corresponding to the @code{@var{type}'Size} value in Ada.
16490 @node Interfacing to C++
16491 @section Interfacing to C++
16494 The interface to C++ makes use of the following pragmas, which are
16495 primarily intended to be constructed automatically using a binding generator
16496 tool, although it is possible to construct them by hand. No suitable binding
16497 generator tool is supplied with GNAT though.
16499 Using these pragmas it is possible to achieve complete
16500 inter-operability between Ada tagged types and C++ class definitions.
16501 See @ref{Implementation Defined Pragmas}, for more details.
16504 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
16505 The argument denotes an entity in the current declarative region that is
16506 declared as a tagged or untagged record type. It indicates that the type
16507 corresponds to an externally declared C++ class type, and is to be laid
16508 out the same way that C++ would lay out the type.
16510 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
16511 for backward compatibility but its functionality is available
16512 using pragma @code{Import} with @code{Convention} = @code{CPP}.
16514 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
16515 This pragma identifies an imported function (imported in the usual way
16516 with pragma @code{Import}) as corresponding to a C++ constructor.
16519 @node Interfacing to COBOL
16520 @section Interfacing to COBOL
16523 Interfacing to COBOL is achieved as described in section B.4 of
16524 the Ada Reference Manual.
16526 @node Interfacing to Fortran
16527 @section Interfacing to Fortran
16530 Interfacing to Fortran is achieved as described in section B.5 of the
16531 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
16532 multi-dimensional array causes the array to be stored in column-major
16533 order as required for convenient interface to Fortran.
16535 @node Interfacing to non-GNAT Ada code
16536 @section Interfacing to non-GNAT Ada code
16538 It is possible to specify the convention @code{Ada} in a pragma
16539 @code{Import} or pragma @code{Export}. However this refers to
16540 the calling conventions used by GNAT, which may or may not be
16541 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
16542 compiler to allow interoperation.
16544 If arguments types are kept simple, and if the foreign compiler generally
16545 follows system calling conventions, then it may be possible to integrate
16546 files compiled by other Ada compilers, provided that the elaboration
16547 issues are adequately addressed (for example by eliminating the
16548 need for any load time elaboration).
16550 In particular, GNAT running on VMS is designed to
16551 be highly compatible with the DEC Ada 83 compiler, so this is one
16552 case in which it is possible to import foreign units of this type,
16553 provided that the data items passed are restricted to simple scalar
16554 values or simple record types without variants, or simple array
16555 types with fixed bounds.
16557 @node Specialized Needs Annexes
16558 @chapter Specialized Needs Annexes
16561 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
16562 required in all implementations. However, as described in this chapter,
16563 GNAT implements all of these annexes:
16566 @item Systems Programming (Annex C)
16567 The Systems Programming Annex is fully implemented.
16569 @item Real-Time Systems (Annex D)
16570 The Real-Time Systems Annex is fully implemented.
16572 @item Distributed Systems (Annex E)
16573 Stub generation is fully implemented in the GNAT compiler. In addition,
16574 a complete compatible PCS is available as part of the GLADE system,
16575 a separate product. When the two
16576 products are used in conjunction, this annex is fully implemented.
16578 @item Information Systems (Annex F)
16579 The Information Systems annex is fully implemented.
16581 @item Numerics (Annex G)
16582 The Numerics Annex is fully implemented.
16584 @item Safety and Security / High-Integrity Systems (Annex H)
16585 The Safety and Security Annex (termed the High-Integrity Systems Annex
16586 in Ada 2005) is fully implemented.
16589 @node Implementation of Specific Ada Features
16590 @chapter Implementation of Specific Ada Features
16593 This chapter describes the GNAT implementation of several Ada language
16597 * Machine Code Insertions::
16598 * GNAT Implementation of Tasking::
16599 * GNAT Implementation of Shared Passive Packages::
16600 * Code Generation for Array Aggregates::
16601 * The Size of Discriminated Records with Default Discriminants::
16602 * Strict Conformance to the Ada Reference Manual::
16605 @node Machine Code Insertions
16606 @section Machine Code Insertions
16607 @cindex Machine Code insertions
16610 Package @code{Machine_Code} provides machine code support as described
16611 in the Ada Reference Manual in two separate forms:
16614 Machine code statements, consisting of qualified expressions that
16615 fit the requirements of RM section 13.8.
16617 An intrinsic callable procedure, providing an alternative mechanism of
16618 including machine instructions in a subprogram.
16622 The two features are similar, and both are closely related to the mechanism
16623 provided by the asm instruction in the GNU C compiler. Full understanding
16624 and use of the facilities in this package requires understanding the asm
16625 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
16626 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
16628 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
16629 semantic restrictions and effects as described below. Both are provided so
16630 that the procedure call can be used as a statement, and the function call
16631 can be used to form a code_statement.
16633 The first example given in the GCC documentation is the C @code{asm}
16636 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
16640 The equivalent can be written for GNAT as:
16642 @smallexample @c ada
16643 Asm ("fsinx %1 %0",
16644 My_Float'Asm_Output ("=f", result),
16645 My_Float'Asm_Input ("f", angle));
16649 The first argument to @code{Asm} is the assembler template, and is
16650 identical to what is used in GNU C@. This string must be a static
16651 expression. The second argument is the output operand list. It is
16652 either a single @code{Asm_Output} attribute reference, or a list of such
16653 references enclosed in parentheses (technically an array aggregate of
16656 The @code{Asm_Output} attribute denotes a function that takes two
16657 parameters. The first is a string, the second is the name of a variable
16658 of the type designated by the attribute prefix. The first (string)
16659 argument is required to be a static expression and designates the
16660 constraint for the parameter (e.g.@: what kind of register is
16661 required). The second argument is the variable to be updated with the
16662 result. The possible values for constraint are the same as those used in
16663 the RTL, and are dependent on the configuration file used to build the
16664 GCC back end. If there are no output operands, then this argument may
16665 either be omitted, or explicitly given as @code{No_Output_Operands}.
16667 The second argument of @code{@var{my_float}'Asm_Output} functions as
16668 though it were an @code{out} parameter, which is a little curious, but
16669 all names have the form of expressions, so there is no syntactic
16670 irregularity, even though normally functions would not be permitted
16671 @code{out} parameters. The third argument is the list of input
16672 operands. It is either a single @code{Asm_Input} attribute reference, or
16673 a list of such references enclosed in parentheses (technically an array
16674 aggregate of such references).
16676 The @code{Asm_Input} attribute denotes a function that takes two
16677 parameters. The first is a string, the second is an expression of the
16678 type designated by the prefix. The first (string) argument is required
16679 to be a static expression, and is the constraint for the parameter,
16680 (e.g.@: what kind of register is required). The second argument is the
16681 value to be used as the input argument. The possible values for the
16682 constant are the same as those used in the RTL, and are dependent on
16683 the configuration file used to built the GCC back end.
16685 If there are no input operands, this argument may either be omitted, or
16686 explicitly given as @code{No_Input_Operands}. The fourth argument, not
16687 present in the above example, is a list of register names, called the
16688 @dfn{clobber} argument. This argument, if given, must be a static string
16689 expression, and is a space or comma separated list of names of registers
16690 that must be considered destroyed as a result of the @code{Asm} call. If
16691 this argument is the null string (the default value), then the code
16692 generator assumes that no additional registers are destroyed.
16694 The fifth argument, not present in the above example, called the
16695 @dfn{volatile} argument, is by default @code{False}. It can be set to
16696 the literal value @code{True} to indicate to the code generator that all
16697 optimizations with respect to the instruction specified should be
16698 suppressed, and that in particular, for an instruction that has outputs,
16699 the instruction will still be generated, even if none of the outputs are
16700 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
16701 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
16702 Generally it is strongly advisable to use Volatile for any ASM statement
16703 that is missing either input or output operands, or when two or more ASM
16704 statements appear in sequence, to avoid unwanted optimizations. A warning
16705 is generated if this advice is not followed.
16707 The @code{Asm} subprograms may be used in two ways. First the procedure
16708 forms can be used anywhere a procedure call would be valid, and
16709 correspond to what the RM calls ``intrinsic'' routines. Such calls can
16710 be used to intersperse machine instructions with other Ada statements.
16711 Second, the function forms, which return a dummy value of the limited
16712 private type @code{Asm_Insn}, can be used in code statements, and indeed
16713 this is the only context where such calls are allowed. Code statements
16714 appear as aggregates of the form:
16716 @smallexample @c ada
16717 Asm_Insn'(Asm (@dots{}));
16718 Asm_Insn'(Asm_Volatile (@dots{}));
16722 In accordance with RM rules, such code statements are allowed only
16723 within subprograms whose entire body consists of such statements. It is
16724 not permissible to intermix such statements with other Ada statements.
16726 Typically the form using intrinsic procedure calls is more convenient
16727 and more flexible. The code statement form is provided to meet the RM
16728 suggestion that such a facility should be made available. The following
16729 is the exact syntax of the call to @code{Asm}. As usual, if named notation
16730 is used, the arguments may be given in arbitrary order, following the
16731 normal rules for use of positional and named arguments)
16735 [Template =>] static_string_EXPRESSION
16736 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
16737 [,[Inputs =>] INPUT_OPERAND_LIST ]
16738 [,[Clobber =>] static_string_EXPRESSION ]
16739 [,[Volatile =>] static_boolean_EXPRESSION] )
16741 OUTPUT_OPERAND_LIST ::=
16742 [PREFIX.]No_Output_Operands
16743 | OUTPUT_OPERAND_ATTRIBUTE
16744 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
16746 OUTPUT_OPERAND_ATTRIBUTE ::=
16747 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
16749 INPUT_OPERAND_LIST ::=
16750 [PREFIX.]No_Input_Operands
16751 | INPUT_OPERAND_ATTRIBUTE
16752 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
16754 INPUT_OPERAND_ATTRIBUTE ::=
16755 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
16759 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
16760 are declared in the package @code{Machine_Code} and must be referenced
16761 according to normal visibility rules. In particular if there is no
16762 @code{use} clause for this package, then appropriate package name
16763 qualification is required.
16765 @node GNAT Implementation of Tasking
16766 @section GNAT Implementation of Tasking
16769 This chapter outlines the basic GNAT approach to tasking (in particular,
16770 a multi-layered library for portability) and discusses issues related
16771 to compliance with the Real-Time Systems Annex.
16774 * Mapping Ada Tasks onto the Underlying Kernel Threads::
16775 * Ensuring Compliance with the Real-Time Annex::
16778 @node Mapping Ada Tasks onto the Underlying Kernel Threads
16779 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
16782 GNAT's run-time support comprises two layers:
16785 @item GNARL (GNAT Run-time Layer)
16786 @item GNULL (GNAT Low-level Library)
16790 In GNAT, Ada's tasking services rely on a platform and OS independent
16791 layer known as GNARL@. This code is responsible for implementing the
16792 correct semantics of Ada's task creation, rendezvous, protected
16795 GNARL decomposes Ada's tasking semantics into simpler lower level
16796 operations such as create a thread, set the priority of a thread,
16797 yield, create a lock, lock/unlock, etc. The spec for these low-level
16798 operations constitutes GNULLI, the GNULL Interface. This interface is
16799 directly inspired from the POSIX real-time API@.
16801 If the underlying executive or OS implements the POSIX standard
16802 faithfully, the GNULL Interface maps as is to the services offered by
16803 the underlying kernel. Otherwise, some target dependent glue code maps
16804 the services offered by the underlying kernel to the semantics expected
16807 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
16808 key point is that each Ada task is mapped on a thread in the underlying
16809 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
16811 In addition Ada task priorities map onto the underlying thread priorities.
16812 Mapping Ada tasks onto the underlying kernel threads has several advantages:
16816 The underlying scheduler is used to schedule the Ada tasks. This
16817 makes Ada tasks as efficient as kernel threads from a scheduling
16821 Interaction with code written in C containing threads is eased
16822 since at the lowest level Ada tasks and C threads map onto the same
16823 underlying kernel concept.
16826 When an Ada task is blocked during I/O the remaining Ada tasks are
16830 On multiprocessor systems Ada tasks can execute in parallel.
16834 Some threads libraries offer a mechanism to fork a new process, with the
16835 child process duplicating the threads from the parent.
16837 support this functionality when the parent contains more than one task.
16838 @cindex Forking a new process
16840 @node Ensuring Compliance with the Real-Time Annex
16841 @subsection Ensuring Compliance with the Real-Time Annex
16842 @cindex Real-Time Systems Annex compliance
16845 Although mapping Ada tasks onto
16846 the underlying threads has significant advantages, it does create some
16847 complications when it comes to respecting the scheduling semantics
16848 specified in the real-time annex (Annex D).
16850 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
16851 scheduling policy states:
16854 @emph{When the active priority of a ready task that is not running
16855 changes, or the setting of its base priority takes effect, the
16856 task is removed from the ready queue for its old active priority
16857 and is added at the tail of the ready queue for its new active
16858 priority, except in the case where the active priority is lowered
16859 due to the loss of inherited priority, in which case the task is
16860 added at the head of the ready queue for its new active priority.}
16864 While most kernels do put tasks at the end of the priority queue when
16865 a task changes its priority, (which respects the main
16866 FIFO_Within_Priorities requirement), almost none keep a thread at the
16867 beginning of its priority queue when its priority drops from the loss
16868 of inherited priority.
16870 As a result most vendors have provided incomplete Annex D implementations.
16872 The GNAT run-time, has a nice cooperative solution to this problem
16873 which ensures that accurate FIFO_Within_Priorities semantics are
16876 The principle is as follows. When an Ada task T is about to start
16877 running, it checks whether some other Ada task R with the same
16878 priority as T has been suspended due to the loss of priority
16879 inheritance. If this is the case, T yields and is placed at the end of
16880 its priority queue. When R arrives at the front of the queue it
16883 Note that this simple scheme preserves the relative order of the tasks
16884 that were ready to execute in the priority queue where R has been
16887 @node GNAT Implementation of Shared Passive Packages
16888 @section GNAT Implementation of Shared Passive Packages
16889 @cindex Shared passive packages
16892 GNAT fully implements the pragma @code{Shared_Passive} for
16893 @cindex pragma @code{Shared_Passive}
16894 the purpose of designating shared passive packages.
16895 This allows the use of passive partitions in the
16896 context described in the Ada Reference Manual; i.e., for communication
16897 between separate partitions of a distributed application using the
16898 features in Annex E.
16900 @cindex Distribution Systems Annex
16902 However, the implementation approach used by GNAT provides for more
16903 extensive usage as follows:
16906 @item Communication between separate programs
16908 This allows separate programs to access the data in passive
16909 partitions, using protected objects for synchronization where
16910 needed. The only requirement is that the two programs have a
16911 common shared file system. It is even possible for programs
16912 running on different machines with different architectures
16913 (e.g.@: different endianness) to communicate via the data in
16914 a passive partition.
16916 @item Persistence between program runs
16918 The data in a passive package can persist from one run of a
16919 program to another, so that a later program sees the final
16920 values stored by a previous run of the same program.
16925 The implementation approach used is to store the data in files. A
16926 separate stream file is created for each object in the package, and
16927 an access to an object causes the corresponding file to be read or
16930 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
16931 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
16932 set to the directory to be used for these files.
16933 The files in this directory
16934 have names that correspond to their fully qualified names. For
16935 example, if we have the package
16937 @smallexample @c ada
16939 pragma Shared_Passive (X);
16946 and the environment variable is set to @code{/stemp/}, then the files created
16947 will have the names:
16955 These files are created when a value is initially written to the object, and
16956 the files are retained until manually deleted. This provides the persistence
16957 semantics. If no file exists, it means that no partition has assigned a value
16958 to the variable; in this case the initial value declared in the package
16959 will be used. This model ensures that there are no issues in synchronizing
16960 the elaboration process, since elaboration of passive packages elaborates the
16961 initial values, but does not create the files.
16963 The files are written using normal @code{Stream_IO} access.
16964 If you want to be able
16965 to communicate between programs or partitions running on different
16966 architectures, then you should use the XDR versions of the stream attribute
16967 routines, since these are architecture independent.
16969 If active synchronization is required for access to the variables in the
16970 shared passive package, then as described in the Ada Reference Manual, the
16971 package may contain protected objects used for this purpose. In this case
16972 a lock file (whose name is @file{___lock} (three underscores)
16973 is created in the shared memory directory.
16974 @cindex @file{___lock} file (for shared passive packages)
16975 This is used to provide the required locking
16976 semantics for proper protected object synchronization.
16978 As of January 2003, GNAT supports shared passive packages on all platforms
16979 except for OpenVMS.
16981 @node Code Generation for Array Aggregates
16982 @section Code Generation for Array Aggregates
16985 * Static constant aggregates with static bounds::
16986 * Constant aggregates with unconstrained nominal types::
16987 * Aggregates with static bounds::
16988 * Aggregates with non-static bounds::
16989 * Aggregates in assignment statements::
16993 Aggregates have a rich syntax and allow the user to specify the values of
16994 complex data structures by means of a single construct. As a result, the
16995 code generated for aggregates can be quite complex and involve loops, case
16996 statements and multiple assignments. In the simplest cases, however, the
16997 compiler will recognize aggregates whose components and constraints are
16998 fully static, and in those cases the compiler will generate little or no
16999 executable code. The following is an outline of the code that GNAT generates
17000 for various aggregate constructs. For further details, you will find it
17001 useful to examine the output produced by the -gnatG flag to see the expanded
17002 source that is input to the code generator. You may also want to examine
17003 the assembly code generated at various levels of optimization.
17005 The code generated for aggregates depends on the context, the component values,
17006 and the type. In the context of an object declaration the code generated is
17007 generally simpler than in the case of an assignment. As a general rule, static
17008 component values and static subtypes also lead to simpler code.
17010 @node Static constant aggregates with static bounds
17011 @subsection Static constant aggregates with static bounds
17014 For the declarations:
17015 @smallexample @c ada
17016 type One_Dim is array (1..10) of integer;
17017 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
17021 GNAT generates no executable code: the constant ar0 is placed in static memory.
17022 The same is true for constant aggregates with named associations:
17024 @smallexample @c ada
17025 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
17026 Cr3 : constant One_Dim := (others => 7777);
17030 The same is true for multidimensional constant arrays such as:
17032 @smallexample @c ada
17033 type two_dim is array (1..3, 1..3) of integer;
17034 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
17038 The same is true for arrays of one-dimensional arrays: the following are
17041 @smallexample @c ada
17042 type ar1b is array (1..3) of boolean;
17043 type ar_ar is array (1..3) of ar1b;
17044 None : constant ar1b := (others => false); -- fully static
17045 None2 : constant ar_ar := (1..3 => None); -- fully static
17049 However, for multidimensional aggregates with named associations, GNAT will
17050 generate assignments and loops, even if all associations are static. The
17051 following two declarations generate a loop for the first dimension, and
17052 individual component assignments for the second dimension:
17054 @smallexample @c ada
17055 Zero1: constant two_dim := (1..3 => (1..3 => 0));
17056 Zero2: constant two_dim := (others => (others => 0));
17059 @node Constant aggregates with unconstrained nominal types
17060 @subsection Constant aggregates with unconstrained nominal types
17063 In such cases the aggregate itself establishes the subtype, so that
17064 associations with @code{others} cannot be used. GNAT determines the
17065 bounds for the actual subtype of the aggregate, and allocates the
17066 aggregate statically as well. No code is generated for the following:
17068 @smallexample @c ada
17069 type One_Unc is array (natural range <>) of integer;
17070 Cr_Unc : constant One_Unc := (12,24,36);
17073 @node Aggregates with static bounds
17074 @subsection Aggregates with static bounds
17077 In all previous examples the aggregate was the initial (and immutable) value
17078 of a constant. If the aggregate initializes a variable, then code is generated
17079 for it as a combination of individual assignments and loops over the target
17080 object. The declarations
17082 @smallexample @c ada
17083 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
17084 Cr_Var2 : One_Dim := (others > -1);
17088 generate the equivalent of
17090 @smallexample @c ada
17096 for I in Cr_Var2'range loop
17101 @node Aggregates with non-static bounds
17102 @subsection Aggregates with non-static bounds
17105 If the bounds of the aggregate are not statically compatible with the bounds
17106 of the nominal subtype of the target, then constraint checks have to be
17107 generated on the bounds. For a multidimensional array, constraint checks may
17108 have to be applied to sub-arrays individually, if they do not have statically
17109 compatible subtypes.
17111 @node Aggregates in assignment statements
17112 @subsection Aggregates in assignment statements
17115 In general, aggregate assignment requires the construction of a temporary,
17116 and a copy from the temporary to the target of the assignment. This is because
17117 it is not always possible to convert the assignment into a series of individual
17118 component assignments. For example, consider the simple case:
17120 @smallexample @c ada
17125 This cannot be converted into:
17127 @smallexample @c ada
17133 So the aggregate has to be built first in a separate location, and then
17134 copied into the target. GNAT recognizes simple cases where this intermediate
17135 step is not required, and the assignments can be performed in place, directly
17136 into the target. The following sufficient criteria are applied:
17140 The bounds of the aggregate are static, and the associations are static.
17142 The components of the aggregate are static constants, names of
17143 simple variables that are not renamings, or expressions not involving
17144 indexed components whose operands obey these rules.
17148 If any of these conditions are violated, the aggregate will be built in
17149 a temporary (created either by the front-end or the code generator) and then
17150 that temporary will be copied onto the target.
17152 @node The Size of Discriminated Records with Default Discriminants
17153 @section The Size of Discriminated Records with Default Discriminants
17156 If a discriminated type @code{T} has discriminants with default values, it is
17157 possible to declare an object of this type without providing an explicit
17160 @smallexample @c ada
17162 type Size is range 1..100;
17164 type Rec (D : Size := 15) is record
17165 Name : String (1..D);
17173 Such an object is said to be @emph{unconstrained}.
17174 The discriminant of the object
17175 can be modified by a full assignment to the object, as long as it preserves the
17176 relation between the value of the discriminant, and the value of the components
17179 @smallexample @c ada
17181 Word := (3, "yes");
17183 Word := (5, "maybe");
17185 Word := (5, "no"); -- raises Constraint_Error
17190 In order to support this behavior efficiently, an unconstrained object is
17191 given the maximum size that any value of the type requires. In the case
17192 above, @code{Word} has storage for the discriminant and for
17193 a @code{String} of length 100.
17194 It is important to note that unconstrained objects do not require dynamic
17195 allocation. It would be an improper implementation to place on the heap those
17196 components whose size depends on discriminants. (This improper implementation
17197 was used by some Ada83 compilers, where the @code{Name} component above
17199 been stored as a pointer to a dynamic string). Following the principle that
17200 dynamic storage management should never be introduced implicitly,
17201 an Ada compiler should reserve the full size for an unconstrained declared
17202 object, and place it on the stack.
17204 This maximum size approach
17205 has been a source of surprise to some users, who expect the default
17206 values of the discriminants to determine the size reserved for an
17207 unconstrained object: ``If the default is 15, why should the object occupy
17209 The answer, of course, is that the discriminant may be later modified,
17210 and its full range of values must be taken into account. This is why the
17215 type Rec (D : Positive := 15) is record
17216 Name : String (1..D);
17224 is flagged by the compiler with a warning:
17225 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
17226 because the required size includes @code{Positive'Last}
17227 bytes. As the first example indicates, the proper approach is to declare an
17228 index type of ``reasonable'' range so that unconstrained objects are not too
17231 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
17232 created in the heap by means of an allocator, then it is @emph{not}
17234 it is constrained by the default values of the discriminants, and those values
17235 cannot be modified by full assignment. This is because in the presence of
17236 aliasing all views of the object (which may be manipulated by different tasks,
17237 say) must be consistent, so it is imperative that the object, once created,
17240 @node Strict Conformance to the Ada Reference Manual
17241 @section Strict Conformance to the Ada Reference Manual
17244 The dynamic semantics defined by the Ada Reference Manual impose a set of
17245 run-time checks to be generated. By default, the GNAT compiler will insert many
17246 run-time checks into the compiled code, including most of those required by the
17247 Ada Reference Manual. However, there are three checks that are not enabled
17248 in the default mode for efficiency reasons: arithmetic overflow checking for
17249 integer operations (including division by zero), checks for access before
17250 elaboration on subprogram calls, and stack overflow checking (most operating
17251 systems do not perform this check by default).
17253 Strict conformance to the Ada Reference Manual can be achieved by adding
17254 three compiler options for overflow checking for integer operations
17255 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
17256 calls and generic instantiations (@option{-gnatE}), and stack overflow
17257 checking (@option{-fstack-check}).
17259 Note that the result of a floating point arithmetic operation in overflow and
17260 invalid situations, when the @code{Machine_Overflows} attribute of the result
17261 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
17262 case for machines compliant with the IEEE floating-point standard, but on
17263 machines that are not fully compliant with this standard, such as Alpha, the
17264 @option{-mieee} compiler flag must be used for achieving IEEE confirming
17265 behavior (although at the cost of a significant performance penalty), so
17266 infinite and NaN values are properly generated.
17269 @node Implementation of Ada 2012 Features
17270 @chapter Implementation of Ada 2012 Features
17271 @cindex Ada 2012 implementation status
17273 This chapter contains a complete list of Ada 2012 features that have been
17274 implemented as of GNAT version 6.4. Generally, these features are only
17275 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
17276 @cindex @option{-gnat12} option
17277 or if the configuration pragma @code{Ada_2012} is used.
17278 @cindex pragma @code{Ada_2012}
17279 @cindex configuration pragma @code{Ada_2012}
17280 @cindex @code{Ada_2012} configuration pragma
17281 However, new pragmas, attributes, and restrictions are
17282 unconditionally available, since the Ada 95 standard allows the addition of
17283 new pragmas, attributes, and restrictions (there are exceptions, which are
17284 documented in the individual descriptions), and also certain packages
17285 were made available in earlier versions of Ada.
17287 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
17288 This date shows the implementation date of the feature. Any wavefront
17289 subsequent to this date will contain the indicated feature, as will any
17290 subsequent releases. A date of 0000-00-00 means that GNAT has always
17291 implemented the feature, or implemented it as soon as it appeared as a
17292 binding interpretation.
17294 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
17295 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
17296 The features are ordered based on the relevant sections of the Ada
17297 Reference Manual (``RM''). When a given AI relates to multiple points
17298 in the RM, the earliest is used.
17300 A complete description of the AIs may be found in
17301 @url{www.ada-auth.org/ai05-summary.html}.
17306 @emph{AI-0176 Quantified expressions (2010-09-29)}
17307 @cindex AI-0176 (Ada 2012 feature)
17310 Both universally and existentially quantified expressions are implemented.
17311 They use the new syntax for iterators proposed in AI05-139-2, as well as
17312 the standard Ada loop syntax.
17315 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
17318 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
17319 @cindex AI-0079 (Ada 2012 feature)
17322 Wide characters in the unicode category @i{other_format} are now allowed in
17323 source programs between tokens, but not within a token such as an identifier.
17326 RM References: 2.01 (4/2) 2.02 (7)
17329 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
17330 @cindex AI-0091 (Ada 2012 feature)
17333 Wide characters in the unicode category @i{other_format} are not permitted
17334 within an identifier, since this can be a security problem. The error
17335 message for this case has been improved to be more specific, but GNAT has
17336 never allowed such characters to appear in identifiers.
17339 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)
17342 @emph{AI-0100 Placement of pragmas (2010-07-01)}
17343 @cindex AI-0100 (Ada 2012 feature)
17346 This AI is an earlier version of AI-163. It simplifies the rules
17347 for legal placement of pragmas. In the case of lists that allow pragmas, if
17348 the list may have no elements, then the list may consist solely of pragmas.
17351 RM References: 2.08 (7)
17354 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
17355 @cindex AI-0163 (Ada 2012 feature)
17358 A statement sequence may be composed entirely of pragmas. It is no longer
17359 necessary to add a dummy @code{null} statement to make the sequence legal.
17362 RM References: 2.08 (7) 2.08 (16)
17366 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
17367 @cindex AI-0080 (Ada 2012 feature)
17370 This is an editorial change only, described as non-testable in the AI.
17373 RM References: 3.01 (7)
17377 @emph{AI-0183 Aspect specifications (2010-08-16)}
17378 @cindex AI-0183 (Ada 2012 feature)
17381 Aspect specifications have been fully implemented except for pre and post-
17382 conditions, and type invariants, which have their own separate AI's. All
17383 forms of declarations listed in the AI are supported. The following is a
17384 list of the aspects supported (with GNAT implementation aspects marked)
17386 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
17387 @item @code{Ada_2005} @tab -- GNAT
17388 @item @code{Ada_2012} @tab -- GNAT
17389 @item @code{Address} @tab
17390 @item @code{Alignment} @tab
17391 @item @code{Atomic} @tab
17392 @item @code{Atomic_Components} @tab
17393 @item @code{Bit_Order} @tab
17394 @item @code{Component_Size} @tab
17395 @item @code{Discard_Names} @tab
17396 @item @code{External_Tag} @tab
17397 @item @code{Favor_Top_Level} @tab -- GNAT
17398 @item @code{Inline} @tab
17399 @item @code{Inline_Always} @tab -- GNAT
17400 @item @code{Invariant} @tab
17401 @item @code{Machine_Radix} @tab
17402 @item @code{No_Return} @tab
17403 @item @code{Object_Size} @tab -- GNAT
17404 @item @code{Pack} @tab
17405 @item @code{Persistent_BSS} @tab -- GNAT
17406 @item @code{Post} @tab
17407 @item @code{Pre} @tab
17408 @item @code{Predicate} @tab
17409 @item @code{Preelaborable_Initialization} @tab
17410 @item @code{Pure_Function} @tab -- GNAT
17411 @item @code{Remote_Access_Type} @tab -- GNAT
17412 @item @code{Shared} @tab -- GNAT
17413 @item @code{Size} @tab
17414 @item @code{Storage_Pool} @tab
17415 @item @code{Storage_Size} @tab
17416 @item @code{Stream_Size} @tab
17417 @item @code{Suppress} @tab
17418 @item @code{Suppress_Debug_Info} @tab -- GNAT
17419 @item @code{Test_Case} @tab -- GNAT
17420 @item @code{Unchecked_Union} @tab
17421 @item @code{Universal_Aliasing} @tab -- GNAT
17422 @item @code{Unmodified} @tab -- GNAT
17423 @item @code{Unreferenced} @tab -- GNAT
17424 @item @code{Unreferenced_Objects} @tab -- GNAT
17425 @item @code{Unsuppress} @tab
17426 @item @code{Value_Size} @tab -- GNAT
17427 @item @code{Volatile} @tab
17428 @item @code{Volatile_Components}
17429 @item @code{Warnings} @tab -- GNAT
17433 Note that for aspects with an expression, e.g. @code{Size}, the expression is
17434 treated like a default expression (visibility is analyzed at the point of
17435 occurrence of the aspect, but evaluation of the expression occurs at the
17436 freeze point of the entity involved.
17439 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
17440 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
17441 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
17442 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
17443 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
17448 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
17449 @cindex AI-0128 (Ada 2012 feature)
17452 If an equality operator ("=") is declared for a type, then the implicitly
17453 declared inequality operator ("/=") is a primitive operation of the type.
17454 This is the only reasonable interpretation, and is the one always implemented
17455 by GNAT, but the RM was not entirely clear in making this point.
17458 RM References: 3.02.03 (6) 6.06 (6)
17461 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
17462 @cindex AI-0003 (Ada 2012 feature)
17465 In Ada 2012, a qualified expression is considered to be syntactically a name,
17466 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
17467 useful in disambiguating some cases of overloading.
17470 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
17474 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
17475 @cindex AI-0120 (Ada 2012 feature)
17478 This is an RM editorial change only. The section that lists objects that are
17479 constant failed to include the current instance of a protected object
17480 within a protected function. This has always been treated as a constant
17484 RM References: 3.03 (21)
17487 @emph{AI-0008 General access to constrained objects (0000-00-00)}
17488 @cindex AI-0008 (Ada 2012 feature)
17491 The wording in the RM implied that if you have a general access to a
17492 constrained object, it could be used to modify the discriminants. This was
17493 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
17494 has always done so in this situation.
17497 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
17501 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
17502 @cindex AI-0093 (Ada 2012 feature)
17505 This is an editorial change only, to make more widespread use of the Ada 2012
17506 ``immutably limited''.
17509 RM References: 3.03 (23.4/3)
17514 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
17515 @cindex AI-0096 (Ada 2012 feature)
17518 In general it is illegal for a type derived from a formal limited type to be
17519 nonlimited. This AI makes an exception to this rule: derivation is legal
17520 if it appears in the private part of the generic, and the formal type is not
17521 tagged. If the type is tagged, the legality check must be applied to the
17522 private part of the package.
17525 RM References: 3.04 (5.1/2) 6.02 (7)
17529 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
17530 @cindex AI-0181 (Ada 2012 feature)
17533 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
17534 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
17535 @code{Image} and @code{Value} attributes for the character types. Strictly
17536 speaking this is an inconsistency with Ada 95, but in practice the use of
17537 these attributes is so obscure that it will not cause problems.
17540 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
17544 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
17545 @cindex AI-0182 (Ada 2012 feature)
17548 This AI allows @code{Character'Value} to accept the string @code{'?'} where
17549 @code{?} is any character including non-graphic control characters. GNAT has
17550 always accepted such strings. It also allows strings such as
17551 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
17552 permission and raises @code{Constraint_Error}, as is certainly still
17556 RM References: 3.05 (56/2)
17560 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
17561 @cindex AI-0214 (Ada 2012 feature)
17564 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
17565 to have default expressions by allowing them when the type is limited. It
17566 is often useful to define a default value for a discriminant even though
17567 it can't be changed by assignment.
17570 RM References: 3.07 (9.1/2) 3.07.02 (3)
17574 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
17575 @cindex AI-0102 (Ada 2012 feature)
17578 It is illegal to assign an anonymous access constant to an anonymous access
17579 variable. The RM did not have a clear rule to prevent this, but GNAT has
17580 always generated an error for this usage.
17583 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
17587 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
17588 @cindex AI-0158 (Ada 2012 feature)
17591 This AI extends the syntax of membership tests to simplify complex conditions
17592 that can be expressed as membership in a subset of values of any type. It
17593 introduces syntax for a list of expressions that may be used in loop contexts
17597 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
17601 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
17602 @cindex AI-0173 (Ada 2012 feature)
17605 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
17606 with the tag of an abstract type, and @code{False} otherwise.
17609 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
17614 @emph{AI-0076 function with controlling result (0000-00-00)}
17615 @cindex AI-0076 (Ada 2012 feature)
17618 This is an editorial change only. The RM defines calls with controlling
17619 results, but uses the term ``function with controlling result'' without an
17620 explicit definition.
17623 RM References: 3.09.02 (2/2)
17627 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
17628 @cindex AI-0126 (Ada 2012 feature)
17631 This AI clarifies dispatching rules, and simply confirms that dispatching
17632 executes the operation of the parent type when there is no explicitly or
17633 implicitly declared operation for the descendant type. This has always been
17634 the case in all versions of GNAT.
17637 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
17641 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
17642 @cindex AI-0097 (Ada 2012 feature)
17645 The RM as written implied that in some cases it was possible to create an
17646 object of an abstract type, by having an abstract extension inherit a non-
17647 abstract constructor from its parent type. This mistake has been corrected
17648 in GNAT and in the RM, and this construct is now illegal.
17651 RM References: 3.09.03 (4/2)
17655 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
17656 @cindex AI-0203 (Ada 2012 feature)
17659 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
17660 permitted such usage.
17663 RM References: 3.09.03 (8/3)
17667 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
17668 @cindex AI-0198 (Ada 2012 feature)
17671 This AI resolves a conflict between two rules involving inherited abstract
17672 operations and predefined operators. If a derived numeric type inherits
17673 an abstract operator, it overrides the predefined one. This interpretation
17674 was always the one implemented in GNAT.
17677 RM References: 3.09.03 (4/3)
17680 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
17681 @cindex AI-0073 (Ada 2012 feature)
17684 This AI covers a number of issues regarding returning abstract types. In
17685 particular generic functions cannot have abstract result types or access
17686 result types designated an abstract type. There are some other cases which
17687 are detailed in the AI. Note that this binding interpretation has not been
17688 retrofitted to operate before Ada 2012 mode, since it caused a significant
17689 number of regressions.
17692 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
17696 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
17697 @cindex AI-0070 (Ada 2012 feature)
17700 This is an editorial change only, there are no testable consequences short of
17701 checking for the absence of generated code for an interface declaration.
17704 RM References: 3.09.04 (18/2)
17708 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
17709 @cindex AI-0208 (Ada 2012 feature)
17712 The wording in the Ada 2005 RM concerning characteristics of incomplete views
17713 was incorrect and implied that some programs intended to be legal were now
17714 illegal. GNAT had never considered such programs illegal, so it has always
17715 implemented the intent of this AI.
17718 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
17722 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
17723 @cindex AI-0162 (Ada 2012 feature)
17726 Incomplete types are made more useful by allowing them to be completed by
17727 private types and private extensions.
17730 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
17735 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
17736 @cindex AI-0098 (Ada 2012 feature)
17739 An unintentional omission in the RM implied some inconsistent restrictions on
17740 the use of anonymous access to subprogram values. These restrictions were not
17741 intentional, and have never been enforced by GNAT.
17744 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
17748 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
17749 @cindex AI-0199 (Ada 2012 feature)
17752 A choice list in a record aggregate can include several components of
17753 (distinct) anonymous access types as long as they have matching designated
17757 RM References: 4.03.01 (16)
17761 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
17762 @cindex AI-0220 (Ada 2012 feature)
17765 This AI addresses a wording problem in the RM that appears to permit some
17766 complex cases of aggregates with non-static discriminants. GNAT has always
17767 implemented the intended semantics.
17770 RM References: 4.03.01 (17)
17773 @emph{AI-0147 Conditional expressions (2009-03-29)}
17774 @cindex AI-0147 (Ada 2012 feature)
17777 Conditional expressions are permitted. The form of such an expression is:
17780 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
17783 The parentheses can be omitted in contexts where parentheses are present
17784 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
17785 clause is omitted, @b{else True} is assumed;
17786 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
17787 @emph{(A implies B)} in standard logic.
17790 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
17791 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
17795 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
17796 @cindex AI-0037 (Ada 2012 feature)
17799 This AI confirms that an association of the form @code{Indx => <>} in an
17800 array aggregate must raise @code{Constraint_Error} if @code{Indx}
17801 is out of range. The RM specified a range check on other associations, but
17802 not when the value of the association was defaulted. GNAT has always inserted
17803 a constraint check on the index value.
17806 RM References: 4.03.03 (29)
17810 @emph{AI-0123 Composability of equality (2010-04-13)}
17811 @cindex AI-0123 (Ada 2012 feature)
17814 Equality of untagged record composes, so that the predefined equality for a
17815 composite type that includes a component of some untagged record type
17816 @code{R} uses the equality operation of @code{R} (which may be user-defined
17817 or predefined). This makes the behavior of untagged records identical to that
17818 of tagged types in this respect.
17820 This change is an incompatibility with previous versions of Ada, but it
17821 corrects a non-uniformity that was often a source of confusion. Analysis of
17822 a large number of industrial programs indicates that in those rare cases
17823 where a composite type had an untagged record component with a user-defined
17824 equality, either there was no use of the composite equality, or else the code
17825 expected the same composability as for tagged types, and thus had a bug that
17826 would be fixed by this change.
17829 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
17834 @emph{AI-0088 The value of exponentiation (0000-00-00)}
17835 @cindex AI-0088 (Ada 2012 feature)
17838 This AI clarifies the equivalence rule given for the dynamic semantics of
17839 exponentiation: the value of the operation can be obtained by repeated
17840 multiplication, but the operation can be implemented otherwise (for example
17841 using the familiar divide-by-two-and-square algorithm, even if this is less
17842 accurate), and does not imply repeated reads of a volatile base.
17845 RM References: 4.05.06 (11)
17848 @emph{AI-0188 Case expressions (2010-01-09)}
17849 @cindex AI-0188 (Ada 2012 feature)
17852 Case expressions are permitted. This allows use of constructs such as:
17854 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
17858 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
17861 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
17862 @cindex AI-0104 (Ada 2012 feature)
17865 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
17866 @code{Constraint_Error} because the default value of the allocated object is
17867 @b{null}. This useless construct is illegal in Ada 2012.
17870 RM References: 4.08 (2)
17873 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
17874 @cindex AI-0157 (Ada 2012 feature)
17877 Allocation and Deallocation from an empty storage pool (i.e. allocation or
17878 deallocation of a pointer for which a static storage size clause of zero
17879 has been given) is now illegal and is detected as such. GNAT
17880 previously gave a warning but not an error.
17883 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
17886 @emph{AI-0179 Statement not required after label (2010-04-10)}
17887 @cindex AI-0179 (Ada 2012 feature)
17890 It is not necessary to have a statement following a label, so a label
17891 can appear at the end of a statement sequence without the need for putting a
17892 null statement afterwards, but it is not allowable to have only labels and
17893 no real statements in a statement sequence.
17896 RM References: 5.01 (2)
17900 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
17901 @cindex AI-139-2 (Ada 2012 feature)
17904 The new syntax for iterating over arrays and containers is now implemented.
17905 Iteration over containers is for now limited to read-only iterators. Only
17906 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
17909 RM References: 5.05
17912 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
17913 @cindex AI-0134 (Ada 2012 feature)
17916 For full conformance, the profiles of anonymous-access-to-subprogram
17917 parameters must match. GNAT has always enforced this rule.
17920 RM References: 6.03.01 (18)
17923 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
17924 @cindex AI-0207 (Ada 2012 feature)
17927 This AI confirms that access_to_constant indication must match for mode
17928 conformance. This was implemented in GNAT when the qualifier was originally
17929 introduced in Ada 2005.
17932 RM References: 6.03.01 (16/2)
17936 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
17937 @cindex AI-0046 (Ada 2012 feature)
17940 For full conformance, in the case of access parameters, the null exclusion
17941 must match (either both or neither must have @code{@b{not null}}).
17944 RM References: 6.03.02 (18)
17948 @emph{AI-0118 The association of parameter associations (0000-00-00)}
17949 @cindex AI-0118 (Ada 2012 feature)
17952 This AI clarifies the rules for named associations in subprogram calls and
17953 generic instantiations. The rules have been in place since Ada 83.
17956 RM References: 6.04.01 (2) 12.03 (9)
17960 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
17961 @cindex AI-0196 (Ada 2012 feature)
17964 Null exclusion checks are not made for @code{@b{out}} parameters when
17965 evaluating the actual parameters. GNAT has never generated these checks.
17968 RM References: 6.04.01 (13)
17971 @emph{AI-0015 Constant return objects (0000-00-00)}
17972 @cindex AI-0015 (Ada 2012 feature)
17975 The return object declared in an @i{extended_return_statement} may be
17976 declared constant. This was always intended, and GNAT has always allowed it.
17979 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
17984 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
17985 @cindex AI-0032 (Ada 2012 feature)
17988 If a function returns a class-wide type, the object of an extended return
17989 statement can be declared with a specific type that is covered by the class-
17990 wide type. This has been implemented in GNAT since the introduction of
17991 extended returns. Note AI-0103 complements this AI by imposing matching
17992 rules for constrained return types.
17995 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
17999 @emph{AI-0103 Static matching for extended return (2010-07-23)}
18000 @cindex AI-0103 (Ada 2012 feature)
18003 If the return subtype of a function is an elementary type or a constrained
18004 type, the subtype indication in an extended return statement must match
18005 statically this return subtype.
18008 RM References: 6.05 (5.2/2)
18012 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
18013 @cindex AI-0058 (Ada 2012 feature)
18016 The RM had some incorrect wording implying wrong treatment of abnormal
18017 completion in an extended return. GNAT has always implemented the intended
18018 correct semantics as described by this AI.
18021 RM References: 6.05 (22/2)
18025 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
18026 @cindex AI-0050 (Ada 2012 feature)
18029 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
18030 not take advantage of these incorrect permissions in any case.
18033 RM References: 6.05 (24/2)
18037 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
18038 @cindex AI-0125 (Ada 2012 feature)
18041 In Ada 2012, the declaration of a primitive operation of a type extension
18042 or private extension can also override an inherited primitive that is not
18043 visible at the point of this declaration.
18046 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
18049 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
18050 @cindex AI-0062 (Ada 2012 feature)
18053 A full constant may have a null exclusion even if its associated deferred
18054 constant does not. GNAT has always allowed this.
18057 RM References: 7.04 (6/2) 7.04 (7.1/2)
18061 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
18062 @cindex AI-0178 (Ada 2012 feature)
18065 This AI clarifies the role of incomplete views and plugs an omission in the
18066 RM. GNAT always correctly restricted the use of incomplete views and types.
18069 RM References: 7.05 (3/2) 7.05 (6/2)
18072 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
18073 @cindex AI-0087 (Ada 2012 feature)
18076 The actual for a formal nonlimited derived type cannot be limited. In
18077 particular, a formal derived type that extends a limited interface but which
18078 is not explicitly limited cannot be instantiated with a limited type.
18081 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
18084 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
18085 @cindex AI-0099 (Ada 2012 feature)
18088 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
18089 and therefore depends on the run-time characteristics of an object (i.e. its
18090 tag) and not on its nominal type. As the AI indicates: ``we do not expect
18091 this to affect any implementation''.
18094 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
18099 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
18100 @cindex AI-0064 (Ada 2012 feature)
18103 This is an editorial change only. The intended behavior is already checked
18104 by an existing ACATS test, which GNAT has always executed correctly.
18107 RM References: 7.06.01 (17.1/1)
18110 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
18111 @cindex AI-0026 (Ada 2012 feature)
18114 Record representation clauses concerning Unchecked_Union types cannot mention
18115 the discriminant of the type. The type of a component declared in the variant
18116 part of an Unchecked_Union cannot be controlled, have controlled components,
18117 nor have protected or task parts. If an Unchecked_Union type is declared
18118 within the body of a generic unit or its descendants, then the type of a
18119 component declared in the variant part cannot be a formal private type or a
18120 formal private extension declared within the same generic unit.
18123 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
18127 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
18128 @cindex AI-0205 (Ada 2012 feature)
18131 This AI corrects a simple omission in the RM. Return objects have always
18132 been visible within an extended return statement.
18135 RM References: 8.03 (17)
18139 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
18140 @cindex AI-0042 (Ada 2012 feature)
18143 This AI fixes a wording gap in the RM. An operation of a synchronized
18144 interface can be implemented by a protected or task entry, but the abstract
18145 operation is not being overridden in the usual sense, and it must be stated
18146 separately that this implementation is legal. This has always been the case
18150 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
18153 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
18154 @cindex AI-0030 (Ada 2012 feature)
18157 Requeue is permitted to a protected, synchronized or task interface primitive
18158 providing it is known that the overriding operation is an entry. Otherwise
18159 the requeue statement has the same effect as a procedure call. Use of pragma
18160 @code{Implemented} provides a way to impose a static requirement on the
18161 overriding operation by adhering to one of the implementation kinds: entry,
18162 protected procedure or any of the above.
18165 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
18166 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
18170 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
18171 @cindex AI-0201 (Ada 2012 feature)
18174 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
18175 attribute, then individual components may not be addressable by independent
18176 tasks. However, if the representation clause has no effect (is confirming),
18177 then independence is not compromised. Furthermore, in GNAT, specification of
18178 other appropriately addressable component sizes (e.g. 16 for 8-bit
18179 characters) also preserves independence. GNAT now gives very clear warnings
18180 both for the declaration of such a type, and for any assignment to its components.
18183 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
18186 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
18187 @cindex AI-0009 (Ada 2012 feature)
18190 This AI introduces the new pragmas @code{Independent} and
18191 @code{Independent_Components},
18192 which control guaranteeing independence of access to objects and components.
18193 The AI also requires independence not unaffected by confirming rep clauses.
18196 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
18197 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
18201 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
18202 @cindex AI-0072 (Ada 2012 feature)
18205 This AI clarifies that task signalling for reading @code{'Terminated} only
18206 occurs if the result is True. GNAT semantics has always been consistent with
18207 this notion of task signalling.
18210 RM References: 9.10 (6.1/1)
18213 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
18214 @cindex AI-0108 (Ada 2012 feature)
18217 This AI confirms that an incomplete type from a limited view does not have
18218 discriminants. This has always been the case in GNAT.
18221 RM References: 10.01.01 (12.3/2)
18224 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
18225 @cindex AI-0129 (Ada 2012 feature)
18228 This AI clarifies the description of limited views: a limited view of a
18229 package includes only one view of a type that has an incomplete declaration
18230 and a full declaration (there is no possible ambiguity in a client package).
18231 This AI also fixes an omission: a nested package in the private part has no
18232 limited view. GNAT always implemented this correctly.
18235 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
18240 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
18241 @cindex AI-0077 (Ada 2012 feature)
18244 This AI clarifies that a declaration does not include a context clause,
18245 and confirms that it is illegal to have a context in which both a limited
18246 and a nonlimited view of a package are accessible. Such double visibility
18247 was always rejected by GNAT.
18250 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
18253 @emph{AI-0122 Private with and children of generics (0000-00-00)}
18254 @cindex AI-0122 (Ada 2012 feature)
18257 This AI clarifies the visibility of private children of generic units within
18258 instantiations of a parent. GNAT has always handled this correctly.
18261 RM References: 10.01.02 (12/2)
18266 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
18267 @cindex AI-0040 (Ada 2012 feature)
18270 This AI confirms that a limited with clause in a child unit cannot name
18271 an ancestor of the unit. This has always been checked in GNAT.
18274 RM References: 10.01.02 (20/2)
18277 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
18278 @cindex AI-0132 (Ada 2012 feature)
18281 This AI fills a gap in the description of library unit pragmas. The pragma
18282 clearly must apply to a library unit, even if it does not carry the name
18283 of the enclosing unit. GNAT has always enforced the required check.
18286 RM References: 10.01.05 (7)
18290 @emph{AI-0034 Categorization of limited views (0000-00-00)}
18291 @cindex AI-0034 (Ada 2012 feature)
18294 The RM makes certain limited with clauses illegal because of categorization
18295 considerations, when the corresponding normal with would be legal. This is
18296 not intended, and GNAT has always implemented the recommended behavior.
18299 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
18303 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
18304 @cindex AI-0035 (Ada 2012 feature)
18307 This AI remedies some inconsistencies in the legality rules for Pure units.
18308 Derived access types are legal in a pure unit (on the assumption that the
18309 rule for a zero storage pool size has been enforced on the ancestor type).
18310 The rules are enforced in generic instances and in subunits. GNAT has always
18311 implemented the recommended behavior.
18314 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)
18318 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
18319 @cindex AI-0219 (Ada 2012 feature)
18322 This AI refines the rules for the cases with limited parameters which do not
18323 allow the implementations to omit ``redundant''. GNAT now properly conforms
18324 to the requirements of this binding interpretation.
18327 RM References: 10.02.01 (18/2)
18330 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
18331 @cindex AI-0043 (Ada 2012 feature)
18334 This AI covers various omissions in the RM regarding the raising of
18335 exceptions. GNAT has always implemented the intended semantics.
18338 RM References: 11.04.01 (10.1/2) 11 (2)
18342 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
18343 @cindex AI-0200 (Ada 2012 feature)
18346 This AI plugs a gap in the RM which appeared to allow some obviously intended
18347 illegal instantiations. GNAT has never allowed these instantiations.
18350 RM References: 12.07 (16)
18354 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
18355 @cindex AI-0112 (Ada 2012 feature)
18358 This AI concerns giving names to various representation aspects, but the
18359 practical effect is simply to make the use of duplicate
18360 @code{Atomic}[@code{_Components}],
18361 @code{Volatile}[@code{_Components}] and
18362 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
18363 now performs this required check.
18366 RM References: 13.01 (8)
18369 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
18370 @cindex AI-0106 (Ada 2012 feature)
18373 The RM appeared to allow representation pragmas on generic formal parameters,
18374 but this was not intended, and GNAT has never permitted this usage.
18377 RM References: 13.01 (9.1/1)
18381 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
18382 @cindex AI-0012 (Ada 2012 feature)
18385 It is now illegal to give an inappropriate component size or a pragma
18386 @code{Pack} that attempts to change the component size in the case of atomic
18387 or aliased components. Previously GNAT ignored such an attempt with a
18391 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
18395 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
18396 @cindex AI-0039 (Ada 2012 feature)
18399 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
18400 for stream attributes, but these were never useful and are now illegal. GNAT
18401 has always regarded such expressions as illegal.
18404 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
18408 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
18409 @cindex AI-0095 (Ada 2012 feature)
18412 The prefix of @code{'Address} cannot statically denote a subprogram with
18413 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
18414 @code{Program_Error} if the prefix denotes a subprogram with convention
18418 RM References: 13.03 (11/1)
18422 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
18423 @cindex AI-0116 (Ada 2012 feature)
18426 This AI requires that the alignment of a class-wide object be no greater
18427 than the alignment of any type in the class. GNAT has always followed this
18431 RM References: 13.03 (29) 13.11 (16)
18435 @emph{AI-0146 Type invariants (2009-09-21)}
18436 @cindex AI-0146 (Ada 2012 feature)
18439 Type invariants may be specified for private types using the aspect notation.
18440 Aspect @code{Invariant} may be specified for any private type,
18441 @code{Invariant'Class} can
18442 only be specified for tagged types, and is inherited by any descendent of the
18443 tagged types. The invariant is a boolean expression that is tested for being
18444 true in the following situations: conversions to the private type, object
18445 declarations for the private type that are default initialized, and
18447 parameters and returned result on return from any primitive operation for
18448 the type that is visible to a client.
18451 RM References: 13.03.03 (00)
18454 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
18455 @cindex AI-0078 (Ada 2012 feature)
18458 In Ada 2012, compilers are required to support unchecked conversion where the
18459 target alignment is a multiple of the source alignment. GNAT always supported
18460 this case (and indeed all cases of differing alignments, doing copies where
18461 required if the alignment was reduced).
18464 RM References: 13.09 (7)
18468 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
18469 @cindex AI-0195 (Ada 2012 feature)
18472 The handling of invalid values is now designated to be implementation
18473 defined. This is a documentation change only, requiring Annex M in the GNAT
18474 Reference Manual to document this handling.
18475 In GNAT, checks for invalid values are made
18476 only when necessary to avoid erroneous behavior. Operations like assignments
18477 which cannot cause erroneous behavior ignore the possibility of invalid
18478 values and do not do a check. The date given above applies only to the
18479 documentation change, this behavior has always been implemented by GNAT.
18482 RM References: 13.09.01 (10)
18485 @emph{AI-0193 Alignment of allocators (2010-09-16)}
18486 @cindex AI-0193 (Ada 2012 feature)
18489 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
18490 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
18494 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
18495 13.11.01 (2) 13.11.01 (3)
18499 @emph{AI-0177 Parameterized expressions (2010-07-10)}
18500 @cindex AI-0177 (Ada 2012 feature)
18503 The new Ada 2012 notion of parameterized expressions is implemented. The form
18506 @i{function specification} @b{is} (@i{expression})
18510 This is exactly equivalent to the
18511 corresponding function body that returns the expression, but it can appear
18512 in a package spec. Note that the expression must be parenthesized.
18515 RM References: 13.11.01 (3/2)
18518 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
18519 @cindex AI-0033 (Ada 2012 feature)
18522 Neither of these two pragmas may appear within a generic template, because
18523 the generic might be instantiated at other than the library level.
18526 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
18530 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
18531 @cindex AI-0161 (Ada 2012 feature)
18534 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
18535 of the default stream attributes for elementary types. If this restriction is
18536 in force, then it is necessary to provide explicit subprograms for any
18537 stream attributes used.
18540 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
18543 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
18544 @cindex AI-0194 (Ada 2012 feature)
18547 The @code{Stream_Size} attribute returns the default number of bits in the
18548 stream representation of the given type.
18549 This value is not affected by the presence
18550 of stream subprogram attributes for the type. GNAT has always implemented
18551 this interpretation.
18554 RM References: 13.13.02 (1.2/2)
18557 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
18558 @cindex AI-0109 (Ada 2012 feature)
18561 This AI is an editorial change only. It removes the need for a tag check
18562 that can never fail.
18565 RM References: 13.13.02 (34/2)
18568 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
18569 @cindex AI-0007 (Ada 2012 feature)
18572 The RM as written appeared to limit the possibilities of declaring read
18573 attribute procedures for private scalar types. This limitation was not
18574 intended, and has never been enforced by GNAT.
18577 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
18581 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
18582 @cindex AI-0065 (Ada 2012 feature)
18585 This AI clarifies the fact that all remote access types support external
18586 streaming. This fixes an obvious oversight in the definition of the
18587 language, and GNAT always implemented the intended correct rules.
18590 RM References: 13.13.02 (52/2)
18593 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
18594 @cindex AI-0019 (Ada 2012 feature)
18597 The RM suggests that primitive subprograms of a specific tagged type are
18598 frozen when the tagged type is frozen. This would be an incompatible change
18599 and is not intended. GNAT has never attempted this kind of freezing and its
18600 behavior is consistent with the recommendation of this AI.
18603 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)
18606 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
18607 @cindex AI-0017 (Ada 2012 feature)
18610 So-called ``Taft-amendment types'' (i.e., types that are completed in package
18611 bodies) are not frozen by the occurrence of bodies in the
18612 enclosing declarative part. GNAT always implemented this properly.
18615 RM References: 13.14 (3/1)
18619 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
18620 @cindex AI-0060 (Ada 2012 feature)
18623 This AI extends the definition of remote access types to include access
18624 to limited, synchronized, protected or task class-wide interface types.
18625 GNAT already implemented this extension.
18628 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
18631 @emph{AI-0114 Classification of letters (0000-00-00)}
18632 @cindex AI-0114 (Ada 2012 feature)
18635 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
18636 181 (@code{MICRO SIGN}), and
18637 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
18638 lower case letters by Unicode.
18639 However, they are not allowed in identifiers, and they
18640 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
18641 This behavior is consistent with that defined in Ada 95.
18644 RM References: A.03.02 (59) A.04.06 (7)
18648 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
18649 @cindex AI-0185 (Ada 2012 feature)
18652 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
18653 classification functions for @code{Wide_Character} and
18654 @code{Wide_Wide_Character}, as well as providing
18655 case folding routines for @code{Wide_[Wide_]Character} and
18656 @code{Wide_[Wide_]String}.
18659 RM References: A.03.05 (0) A.03.06 (0)
18663 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
18664 @cindex AI-0031 (Ada 2012 feature)
18667 A new version of @code{Find_Token} is added to all relevant string packages,
18668 with an extra parameter @code{From}. Instead of starting at the first
18669 character of the string, the search for a matching Token starts at the
18670 character indexed by the value of @code{From}.
18671 These procedures are available in all versions of Ada
18672 but if used in versions earlier than Ada 2012 they will generate a warning
18673 that an Ada 2012 subprogram is being used.
18676 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
18681 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
18682 @cindex AI-0056 (Ada 2012 feature)
18685 The wording in the Ada 2005 RM implied an incompatible handling of the
18686 @code{Index} functions, resulting in raising an exception instead of
18687 returning zero in some situations.
18688 This was not intended and has been corrected.
18689 GNAT always returned zero, and is thus consistent with this AI.
18692 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
18696 @emph{AI-0137 String encoding package (2010-03-25)}
18697 @cindex AI-0137 (Ada 2012 feature)
18700 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
18701 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
18702 and @code{Wide_Wide_Strings} have been
18703 implemented. These packages (whose documentation can be found in the spec
18704 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
18705 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
18706 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
18707 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
18708 UTF-16), as well as conversions between the different UTF encodings. With
18709 the exception of @code{Wide_Wide_Strings}, these packages are available in
18710 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
18711 The @code{Wide_Wide_Strings package}
18712 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
18713 mode since it uses @code{Wide_Wide_Character}).
18716 RM References: A.04.11
18719 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
18720 @cindex AI-0038 (Ada 2012 feature)
18723 These are minor errors in the description on three points. The intent on
18724 all these points has always been clear, and GNAT has always implemented the
18725 correct intended semantics.
18728 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)
18731 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
18732 @cindex AI-0044 (Ada 2012 feature)
18735 This AI places restrictions on allowed instantiations of generic containers.
18736 These restrictions are not checked by the compiler, so there is nothing to
18737 change in the implementation. This affects only the RM documentation.
18740 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)
18743 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
18744 @cindex AI-0127 (Ada 2012 feature)
18747 This package provides an interface for identifying the current locale.
18750 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
18751 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
18756 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
18757 @cindex AI-0002 (Ada 2012 feature)
18760 The compiler is not required to support exporting an Ada subprogram with
18761 convention C if there are parameters or a return type of an unconstrained
18762 array type (such as @code{String}). GNAT allows such declarations but
18763 generates warnings. It is possible, but complicated, to write the
18764 corresponding C code and certainly such code would be specific to GNAT and
18768 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
18772 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
18773 @cindex AI05-0216 (Ada 2012 feature)
18776 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
18777 forbid tasks declared locally within subprograms, or functions returning task
18778 objects, and that is the implementation that GNAT has always provided.
18779 However the language in the RM was not sufficiently clear on this point.
18780 Thus this is a documentation change in the RM only.
18783 RM References: D.07 (3/3)
18786 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
18787 @cindex AI-0211 (Ada 2012 feature)
18790 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
18791 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
18794 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
18797 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
18798 @cindex AI-0190 (Ada 2012 feature)
18801 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
18802 used to control storage pools globally.
18803 In particular, you can force every access
18804 type that is used for allocation (@b{new}) to have an explicit storage pool,
18805 or you can declare a pool globally to be used for all access types that lack
18809 RM References: D.07 (8)
18812 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
18813 @cindex AI-0189 (Ada 2012 feature)
18816 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
18817 which says that no dynamic allocation will occur once elaboration is
18819 In general this requires a run-time check, which is not required, and which
18820 GNAT does not attempt. But the static cases of allocators in a task body or
18821 in the body of the main program are detected and flagged at compile or bind
18825 RM References: D.07 (19.1/2) H.04 (23.3/2)
18828 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
18829 @cindex AI-0171 (Ada 2012 feature)
18832 A new package @code{System.Multiprocessors} is added, together with the
18833 definition of pragma @code{CPU} for controlling task affinity. A new no
18834 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
18835 is added to the Ravenscar profile.
18838 RM References: D.13.01 (4/2) D.16
18842 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
18843 @cindex AI-0210 (Ada 2012 feature)
18846 This is a documentation only issue regarding wording of metric requirements,
18847 that does not affect the implementation of the compiler.
18850 RM References: D.15 (24/2)
18854 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
18855 @cindex AI-0206 (Ada 2012 feature)
18858 Remote types packages are now allowed to depend on preelaborated packages.
18859 This was formerly considered illegal.
18862 RM References: E.02.02 (6)
18867 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
18868 @cindex AI-0152 (Ada 2012 feature)
18871 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
18872 where the type of the returned value is an anonymous access type.
18875 RM References: H.04 (8/1)
18879 @node Obsolescent Features
18880 @chapter Obsolescent Features
18883 This chapter describes features that are provided by GNAT, but are
18884 considered obsolescent since there are preferred ways of achieving
18885 the same effect. These features are provided solely for historical
18886 compatibility purposes.
18889 * pragma No_Run_Time::
18890 * pragma Ravenscar::
18891 * pragma Restricted_Run_Time::
18894 @node pragma No_Run_Time
18895 @section pragma No_Run_Time
18897 The pragma @code{No_Run_Time} is used to achieve an affect similar
18898 to the use of the "Zero Foot Print" configurable run time, but without
18899 requiring a specially configured run time. The result of using this
18900 pragma, which must be used for all units in a partition, is to restrict
18901 the use of any language features requiring run-time support code. The
18902 preferred usage is to use an appropriately configured run-time that
18903 includes just those features that are to be made accessible.
18905 @node pragma Ravenscar
18906 @section pragma Ravenscar
18908 The pragma @code{Ravenscar} has exactly the same effect as pragma
18909 @code{Profile (Ravenscar)}. The latter usage is preferred since it
18910 is part of the new Ada 2005 standard.
18912 @node pragma Restricted_Run_Time
18913 @section pragma Restricted_Run_Time
18915 The pragma @code{Restricted_Run_Time} has exactly the same effect as
18916 pragma @code{Profile (Restricted)}. The latter usage is
18917 preferred since the Ada 2005 pragma @code{Profile} is intended for
18918 this kind of implementation dependent addition.
18921 @c GNU Free Documentation License
18923 @node Index,,GNU Free Documentation License, Top