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-2012, 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 * Standard and 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 Contract_Case::
124 * Pragma Convention_Identifier::
126 * Pragma CPP_Constructor::
127 * Pragma CPP_Virtual::
128 * Pragma CPP_Vtable::
130 * Pragma Debug_Policy::
131 * Pragma Detect_Blocking::
132 * Pragma Elaboration_Checks::
134 * Pragma Export_Exception::
135 * Pragma Export_Function::
136 * Pragma Export_Object::
137 * Pragma Export_Procedure::
138 * Pragma Export_Value::
139 * Pragma Export_Valued_Procedure::
140 * Pragma Extend_System::
141 * Pragma Extensions_Allowed::
143 * Pragma External_Name_Casing::
145 * Pragma Favor_Top_Level::
146 * Pragma Finalize_Storage_Only::
147 * Pragma Float_Representation::
149 * Pragma Implemented::
150 * Pragma Implicit_Packing::
151 * Pragma Import_Exception::
152 * Pragma Import_Function::
153 * Pragma Import_Object::
154 * Pragma Import_Procedure::
155 * Pragma Import_Valued_Procedure::
156 * Pragma Initialize_Scalars::
157 * Pragma Inline_Always::
158 * Pragma Inline_Generic::
160 * Pragma Interface_Name::
161 * Pragma Interrupt_Handler::
162 * Pragma Interrupt_State::
164 * Pragma Keep_Names::
167 * Pragma Linker_Alias::
168 * Pragma Linker_Constructor::
169 * Pragma Linker_Destructor::
170 * Pragma Linker_Section::
171 * Pragma Long_Float::
172 * Pragma Machine_Attribute::
174 * Pragma Main_Storage::
177 * Pragma No_Strict_Aliasing ::
178 * Pragma Normalize_Scalars::
179 * Pragma Obsolescent::
180 * Pragma Optimize_Alignment::
182 * Pragma Overflow_Checks::
184 * Pragma Persistent_BSS::
186 * Pragma Postcondition::
187 * Pragma Precondition::
188 * Pragma Profile (Ravenscar)::
189 * Pragma Profile (Restricted)::
190 * Pragma Psect_Object::
191 * Pragma Pure_Function::
192 * Pragma Remote_Access_Type::
193 * Pragma Restriction_Warnings::
195 * Pragma Short_Circuit_And_Or::
196 * Pragma Short_Descriptors::
197 * Pragma Simple_Storage_Pool_Type::
198 * Pragma Source_File_Name::
199 * Pragma Source_File_Name_Project::
200 * Pragma Source_Reference::
201 * Pragma Static_Elaboration_Desired::
202 * Pragma Stream_Convert::
203 * Pragma Style_Checks::
206 * Pragma Suppress_All::
207 * Pragma Suppress_Exception_Locations::
208 * Pragma Suppress_Initialization::
211 * Pragma Task_Storage::
213 * Pragma Thread_Local_Storage::
214 * Pragma Time_Slice::
216 * Pragma Unchecked_Union::
217 * Pragma Unimplemented_Unit::
218 * Pragma Universal_Aliasing ::
219 * Pragma Universal_Data::
220 * Pragma Unmodified::
221 * Pragma Unreferenced::
222 * Pragma Unreferenced_Objects::
223 * Pragma Unreserve_All_Interrupts::
224 * Pragma Unsuppress::
225 * Pragma Use_VADS_Size::
226 * Pragma Validity_Checks::
229 * Pragma Weak_External::
230 * Pragma Wide_Character_Encoding::
232 Implementation Defined Attributes
243 * Default_Bit_Order::
255 * Has_Access_Values::
256 * Has_Discriminants::
263 * Max_Interrupt_Priority::
265 * Maximum_Alignment::
269 * Passed_By_Reference::
275 * Scalar_Storage_Order::
276 * Simple_Storage_Pool::
280 * System_Allocator_Alignment::
286 * Unconstrained_Array::
287 * Universal_Literal_String::
288 * Unrestricted_Access::
295 Standard and Implementation Defined Restrictions
297 * Partition-Wide Restrictions::
298 * Program Unit Level Restrictions::
300 Partition-Wide Restrictions
302 * Immediate_Reclamation::
303 * Max_Asynchronous_Select_Nesting::
304 * Max_Entry_Queue_Length::
305 * Max_Protected_Entries::
306 * Max_Select_Alternatives::
307 * Max_Storage_At_Blocking::
310 * No_Abort_Statements::
311 * No_Access_Parameter_Allocators::
312 * No_Access_Subprograms::
314 * No_Anonymous_Allocators::
317 * No_Default_Initialization::
320 * No_Direct_Boolean_Operators::
322 * No_Dispatching_Calls::
323 * No_Dynamic_Attachment::
324 * No_Dynamic_Priorities::
325 * No_Entry_Calls_In_Elaboration_Code::
326 * No_Enumeration_Maps::
327 * No_Exception_Handlers::
328 * No_Exception_Propagation::
329 * No_Exception_Registration::
333 * No_Floating_Point::
334 * No_Implicit_Conditionals::
335 * No_Implicit_Dynamic_Code::
336 * No_Implicit_Heap_Allocations::
337 * No_Implicit_Loops::
338 * No_Initialize_Scalars::
340 * No_Local_Allocators::
341 * No_Local_Protected_Objects::
342 * No_Local_Timing_Events::
343 * No_Nested_Finalization::
344 * No_Protected_Type_Allocators::
345 * No_Protected_Types::
348 * No_Relative_Delay::
349 * No_Requeue_Statements::
350 * No_Secondary_Stack::
351 * No_Select_Statements::
352 * No_Specific_Termination_Handlers::
353 * No_Specification_of_Aspect::
354 * No_Standard_Allocators_After_Elaboration::
355 * No_Standard_Storage_Pools::
356 * No_Stream_Optimizations::
358 * No_Task_Allocators::
359 * No_Task_Attributes_Package::
360 * No_Task_Hierarchy::
361 * No_Task_Termination::
363 * No_Terminate_Alternatives::
364 * No_Unchecked_Access::
366 * Static_Priorities::
367 * Static_Storage_Size::
369 Program Unit Level Restrictions
371 * No_Elaboration_Code::
373 * No_Implementation_Aspect_Specifications::
374 * No_Implementation_Attributes::
375 * No_Implementation_Identifiers::
376 * No_Implementation_Pragmas::
377 * No_Implementation_Restrictions::
378 * No_Implementation_Units::
379 * No_Implicit_Aliasing::
380 * No_Obsolescent_Features::
381 * No_Wide_Characters::
384 The Implementation of Standard I/O
386 * Standard I/O Packages::
392 * Wide_Wide_Text_IO::
396 * Filenames encoding::
398 * Operations on C Streams::
399 * Interfacing to C Streams::
403 * Ada.Characters.Latin_9 (a-chlat9.ads)::
404 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
405 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
406 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
407 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
408 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
409 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
410 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
411 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
412 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
413 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
414 * Ada.Command_Line.Environment (a-colien.ads)::
415 * Ada.Command_Line.Remove (a-colire.ads)::
416 * Ada.Command_Line.Response_File (a-clrefi.ads)::
417 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
418 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
419 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
420 * Ada.Exceptions.Traceback (a-exctra.ads)::
421 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
422 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
423 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
424 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
425 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
426 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
427 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
428 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
429 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
430 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
431 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
432 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
433 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
434 * GNAT.Altivec (g-altive.ads)::
435 * GNAT.Altivec.Conversions (g-altcon.ads)::
436 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
437 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
438 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
439 * GNAT.Array_Split (g-arrspl.ads)::
440 * GNAT.AWK (g-awk.ads)::
441 * GNAT.Bounded_Buffers (g-boubuf.ads)::
442 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
443 * GNAT.Bubble_Sort (g-bubsor.ads)::
444 * GNAT.Bubble_Sort_A (g-busora.ads)::
445 * GNAT.Bubble_Sort_G (g-busorg.ads)::
446 * GNAT.Byte_Order_Mark (g-byorma.ads)::
447 * GNAT.Byte_Swapping (g-bytswa.ads)::
448 * GNAT.Calendar (g-calend.ads)::
449 * GNAT.Calendar.Time_IO (g-catiio.ads)::
450 * GNAT.Case_Util (g-casuti.ads)::
451 * GNAT.CGI (g-cgi.ads)::
452 * GNAT.CGI.Cookie (g-cgicoo.ads)::
453 * GNAT.CGI.Debug (g-cgideb.ads)::
454 * GNAT.Command_Line (g-comlin.ads)::
455 * GNAT.Compiler_Version (g-comver.ads)::
456 * GNAT.Ctrl_C (g-ctrl_c.ads)::
457 * GNAT.CRC32 (g-crc32.ads)::
458 * GNAT.Current_Exception (g-curexc.ads)::
459 * GNAT.Debug_Pools (g-debpoo.ads)::
460 * GNAT.Debug_Utilities (g-debuti.ads)::
461 * GNAT.Decode_String (g-decstr.ads)::
462 * GNAT.Decode_UTF8_String (g-deutst.ads)::
463 * GNAT.Directory_Operations (g-dirope.ads)::
464 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
465 * GNAT.Dynamic_HTables (g-dynhta.ads)::
466 * GNAT.Dynamic_Tables (g-dyntab.ads)::
467 * GNAT.Encode_String (g-encstr.ads)::
468 * GNAT.Encode_UTF8_String (g-enutst.ads)::
469 * GNAT.Exception_Actions (g-excact.ads)::
470 * GNAT.Exception_Traces (g-exctra.ads)::
471 * GNAT.Exceptions (g-except.ads)::
472 * GNAT.Expect (g-expect.ads)::
473 * GNAT.Expect.TTY (g-exptty.ads)::
474 * GNAT.Float_Control (g-flocon.ads)::
475 * GNAT.Heap_Sort (g-heasor.ads)::
476 * GNAT.Heap_Sort_A (g-hesora.ads)::
477 * GNAT.Heap_Sort_G (g-hesorg.ads)::
478 * GNAT.HTable (g-htable.ads)::
479 * GNAT.IO (g-io.ads)::
480 * GNAT.IO_Aux (g-io_aux.ads)::
481 * GNAT.Lock_Files (g-locfil.ads)::
482 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
483 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
484 * GNAT.MD5 (g-md5.ads)::
485 * GNAT.Memory_Dump (g-memdum.ads)::
486 * GNAT.Most_Recent_Exception (g-moreex.ads)::
487 * GNAT.OS_Lib (g-os_lib.ads)::
488 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
489 * GNAT.Random_Numbers (g-rannum.ads)::
490 * GNAT.Regexp (g-regexp.ads)::
491 * GNAT.Registry (g-regist.ads)::
492 * GNAT.Regpat (g-regpat.ads)::
493 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
494 * GNAT.Semaphores (g-semaph.ads)::
495 * GNAT.Serial_Communications (g-sercom.ads)::
496 * GNAT.SHA1 (g-sha1.ads)::
497 * GNAT.SHA224 (g-sha224.ads)::
498 * GNAT.SHA256 (g-sha256.ads)::
499 * GNAT.SHA384 (g-sha384.ads)::
500 * GNAT.SHA512 (g-sha512.ads)::
501 * GNAT.Signals (g-signal.ads)::
502 * GNAT.Sockets (g-socket.ads)::
503 * GNAT.Source_Info (g-souinf.ads)::
504 * GNAT.Spelling_Checker (g-speche.ads)::
505 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
506 * GNAT.Spitbol.Patterns (g-spipat.ads)::
507 * GNAT.Spitbol (g-spitbo.ads)::
508 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
509 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
510 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
511 * GNAT.SSE (g-sse.ads)::
512 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
513 * GNAT.Strings (g-string.ads)::
514 * GNAT.String_Split (g-strspl.ads)::
515 * GNAT.Table (g-table.ads)::
516 * GNAT.Task_Lock (g-tasloc.ads)::
517 * GNAT.Threads (g-thread.ads)::
518 * GNAT.Time_Stamp (g-timsta.ads)::
519 * GNAT.Traceback (g-traceb.ads)::
520 * GNAT.Traceback.Symbolic (g-trasym.ads)::
521 * GNAT.UTF_32 (g-utf_32.ads)::
522 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
523 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
524 * GNAT.Wide_String_Split (g-wistsp.ads)::
525 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
526 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
527 * Interfaces.C.Extensions (i-cexten.ads)::
528 * Interfaces.C.Streams (i-cstrea.ads)::
529 * Interfaces.CPP (i-cpp.ads)::
530 * Interfaces.Packed_Decimal (i-pacdec.ads)::
531 * Interfaces.VxWorks (i-vxwork.ads)::
532 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
533 * System.Address_Image (s-addima.ads)::
534 * System.Assertions (s-assert.ads)::
535 * System.Memory (s-memory.ads)::
536 * System.Partition_Interface (s-parint.ads)::
537 * System.Pool_Global (s-pooglo.ads)::
538 * System.Pool_Local (s-pooloc.ads)::
539 * System.Restrictions (s-restri.ads)::
540 * System.Rident (s-rident.ads)::
541 * System.Strings.Stream_Ops (s-ststop.ads)::
542 * System.Task_Info (s-tasinf.ads)::
543 * System.Wch_Cnv (s-wchcnv.ads)::
544 * System.Wch_Con (s-wchcon.ads)::
548 * Text_IO Stream Pointer Positioning::
549 * Text_IO Reading and Writing Non-Regular Files::
551 * Treating Text_IO Files as Streams::
552 * Text_IO Extensions::
553 * Text_IO Facilities for Unbounded Strings::
557 * Wide_Text_IO Stream Pointer Positioning::
558 * Wide_Text_IO Reading and Writing Non-Regular Files::
562 * Wide_Wide_Text_IO Stream Pointer Positioning::
563 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
565 Interfacing to Other Languages
568 * Interfacing to C++::
569 * Interfacing to COBOL::
570 * Interfacing to Fortran::
571 * Interfacing to non-GNAT Ada code::
573 Specialized Needs Annexes
575 Implementation of Specific Ada Features
576 * Machine Code Insertions::
577 * GNAT Implementation of Tasking::
578 * GNAT Implementation of Shared Passive Packages::
579 * Code Generation for Array Aggregates::
580 * The Size of Discriminated Records with Default Discriminants::
581 * Strict Conformance to the Ada Reference Manual::
583 Implementation of Ada 2012 Features
587 GNU Free Documentation License
594 @node About This Guide
595 @unnumbered About This Guide
598 This manual contains useful information in writing programs using the
599 @value{EDITION} compiler. It includes information on implementation dependent
600 characteristics of @value{EDITION}, including all the information required by
601 Annex M of the Ada language standard.
603 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
604 Ada 83 compatibility mode.
605 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
606 but you can override with a compiler switch
607 to explicitly specify the language version.
608 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
609 @value{EDITION} User's Guide}, for details on these switches.)
610 Throughout this manual, references to ``Ada'' without a year suffix
611 apply to both the Ada 95 and Ada 2005 versions of the language.
613 Ada is designed to be highly portable.
614 In general, a program will have the same effect even when compiled by
615 different compilers on different platforms.
616 However, since Ada is designed to be used in a
617 wide variety of applications, it also contains a number of system
618 dependent features to be used in interfacing to the external world.
619 @cindex Implementation-dependent features
622 Note: Any program that makes use of implementation-dependent features
623 may be non-portable. You should follow good programming practice and
624 isolate and clearly document any sections of your program that make use
625 of these features in a non-portable manner.
628 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
629 ``GNAT'' in the remainder of this document.
633 * What This Reference Manual Contains::
635 * Related Information::
638 @node What This Reference Manual Contains
639 @unnumberedsec What This Reference Manual Contains
642 This reference manual contains the following chapters:
646 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
647 pragmas, which can be used to extend and enhance the functionality of the
651 @ref{Implementation Defined Attributes}, lists GNAT
652 implementation-dependent attributes, which can be used to extend and
653 enhance the functionality of the compiler.
656 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
657 implementation-dependent restrictions, which can be used to extend and
658 enhance the functionality of the compiler.
661 @ref{Implementation Advice}, provides information on generally
662 desirable behavior which are not requirements that all compilers must
663 follow since it cannot be provided on all systems, or which may be
664 undesirable on some systems.
667 @ref{Implementation Defined Characteristics}, provides a guide to
668 minimizing implementation dependent features.
671 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
672 implemented by GNAT, and how they can be imported into user
673 application programs.
676 @ref{Representation Clauses and Pragmas}, describes in detail the
677 way that GNAT represents data, and in particular the exact set
678 of representation clauses and pragmas that is accepted.
681 @ref{Standard Library Routines}, provides a listing of packages and a
682 brief description of the functionality that is provided by Ada's
683 extensive set of standard library routines as implemented by GNAT@.
686 @ref{The Implementation of Standard I/O}, details how the GNAT
687 implementation of the input-output facilities.
690 @ref{The GNAT Library}, is a catalog of packages that complement
691 the Ada predefined library.
694 @ref{Interfacing to Other Languages}, describes how programs
695 written in Ada using GNAT can be interfaced to other programming
698 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
699 of the specialized needs annexes.
702 @ref{Implementation of Specific Ada Features}, discusses issues related
703 to GNAT's implementation of machine code insertions, tasking, and several
707 @ref{Implementation of Ada 2012 Features}, describes the status of the
708 GNAT implementation of the Ada 2012 language standard.
711 @ref{Obsolescent Features} documents implementation dependent features,
712 including pragmas and attributes, which are considered obsolescent, since
713 there are other preferred ways of achieving the same results. These
714 obsolescent forms are retained for backwards compatibility.
718 @cindex Ada 95 Language Reference Manual
719 @cindex Ada 2005 Language Reference Manual
721 This reference manual assumes a basic familiarity with the Ada 95 language, as
722 described in the International Standard ANSI/ISO/IEC-8652:1995,
724 It does not require knowledge of the new features introduced by Ada 2005,
725 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
727 Both reference manuals are included in the GNAT documentation
731 @unnumberedsec Conventions
732 @cindex Conventions, typographical
733 @cindex Typographical conventions
736 Following are examples of the typographical and graphic conventions used
741 @code{Functions}, @code{utility program names}, @code{standard names},
748 @file{File names}, @samp{button names}, and @samp{field names}.
751 @code{Variables}, @env{environment variables}, and @var{metasyntactic
758 [optional information or parameters]
761 Examples are described by text
763 and then shown this way.
768 Commands that are entered by the user are preceded in this manual by the
769 characters @samp{$ } (dollar sign followed by space). If your system uses this
770 sequence as a prompt, then the commands will appear exactly as you see them
771 in the manual. If your system uses some other prompt, then the command will
772 appear with the @samp{$} replaced by whatever prompt character you are using.
774 @node Related Information
775 @unnumberedsec Related Information
777 See the following documents for further information on GNAT:
781 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
782 @value{EDITION} User's Guide}, which provides information on how to use the
783 GNAT compiler system.
786 @cite{Ada 95 Reference Manual}, which contains all reference
787 material for the Ada 95 programming language.
790 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
791 of the Ada 95 standard. The annotations describe
792 detailed aspects of the design decision, and in particular contain useful
793 sections on Ada 83 compatibility.
796 @cite{Ada 2005 Reference Manual}, which contains all reference
797 material for the Ada 2005 programming language.
800 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
801 of the Ada 2005 standard. The annotations describe
802 detailed aspects of the design decision, and in particular contain useful
803 sections on Ada 83 and Ada 95 compatibility.
806 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
807 which contains specific information on compatibility between GNAT and
811 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
812 describes in detail the pragmas and attributes provided by the DEC Ada 83
817 @node Implementation Defined Pragmas
818 @chapter Implementation Defined Pragmas
821 Ada defines a set of pragmas that can be used to supply additional
822 information to the compiler. These language defined pragmas are
823 implemented in GNAT and work as described in the Ada Reference Manual.
825 In addition, Ada allows implementations to define additional pragmas
826 whose meaning is defined by the implementation. GNAT provides a number
827 of these implementation-defined pragmas, which can be used to extend
828 and enhance the functionality of the compiler. This section of the GNAT
829 Reference Manual describes these additional pragmas.
831 Note that any program using these pragmas might not be portable to other
832 compilers (although GNAT implements this set of pragmas on all
833 platforms). Therefore if portability to other compilers is an important
834 consideration, the use of these pragmas should be minimized.
837 * Pragma Abort_Defer::
846 * Pragma Assertion_Policy::
847 * Pragma Assume_No_Invalid_Values::
849 * Pragma C_Pass_By_Copy::
851 * Pragma Check_Name::
852 * Pragma Check_Policy::
854 * Pragma Common_Object::
855 * Pragma Compile_Time_Error::
856 * Pragma Compile_Time_Warning::
857 * Pragma Compiler_Unit::
858 * Pragma Complete_Representation::
859 * Pragma Complex_Representation::
860 * Pragma Component_Alignment::
861 * Pragma Contract_Case::
862 * Pragma Convention_Identifier::
864 * Pragma CPP_Constructor::
865 * Pragma CPP_Virtual::
866 * Pragma CPP_Vtable::
868 * Pragma Debug_Policy::
869 * Pragma Detect_Blocking::
870 * Pragma Elaboration_Checks::
872 * Pragma Export_Exception::
873 * Pragma Export_Function::
874 * Pragma Export_Object::
875 * Pragma Export_Procedure::
876 * Pragma Export_Value::
877 * Pragma Export_Valued_Procedure::
878 * Pragma Extend_System::
879 * Pragma Extensions_Allowed::
881 * Pragma External_Name_Casing::
883 * Pragma Favor_Top_Level::
884 * Pragma Finalize_Storage_Only::
885 * Pragma Float_Representation::
887 * Pragma Implemented::
888 * Pragma Implicit_Packing::
889 * Pragma Import_Exception::
890 * Pragma Import_Function::
891 * Pragma Import_Object::
892 * Pragma Import_Procedure::
893 * Pragma Import_Valued_Procedure::
894 * Pragma Initialize_Scalars::
895 * Pragma Inline_Always::
896 * Pragma Inline_Generic::
898 * Pragma Interface_Name::
899 * Pragma Interrupt_Handler::
900 * Pragma Interrupt_State::
902 * Pragma Keep_Names::
905 * Pragma Linker_Alias::
906 * Pragma Linker_Constructor::
907 * Pragma Linker_Destructor::
908 * Pragma Linker_Section::
909 * Pragma Long_Float::
910 * Pragma Machine_Attribute::
912 * Pragma Main_Storage::
915 * Pragma No_Strict_Aliasing::
916 * Pragma Normalize_Scalars::
917 * Pragma Obsolescent::
918 * Pragma Optimize_Alignment::
920 * Pragma Overflow_Checks::
922 * Pragma Persistent_BSS::
924 * Pragma Postcondition::
925 * Pragma Precondition::
926 * Pragma Profile (Ravenscar)::
927 * Pragma Profile (Restricted)::
928 * Pragma Psect_Object::
929 * Pragma Pure_Function::
930 * Pragma Remote_Access_Type::
931 * Pragma Restriction_Warnings::
933 * Pragma Short_Circuit_And_Or::
934 * Pragma Short_Descriptors::
935 * Pragma Simple_Storage_Pool_Type::
936 * Pragma Source_File_Name::
937 * Pragma Source_File_Name_Project::
938 * Pragma Source_Reference::
939 * Pragma Static_Elaboration_Desired::
940 * Pragma Stream_Convert::
941 * Pragma Style_Checks::
944 * Pragma Suppress_All::
945 * Pragma Suppress_Exception_Locations::
946 * Pragma Suppress_Initialization::
949 * Pragma Task_Storage::
951 * Pragma Thread_Local_Storage::
952 * Pragma Time_Slice::
954 * Pragma Unchecked_Union::
955 * Pragma Unimplemented_Unit::
956 * Pragma Universal_Aliasing ::
957 * Pragma Universal_Data::
958 * Pragma Unmodified::
959 * Pragma Unreferenced::
960 * Pragma Unreferenced_Objects::
961 * Pragma Unreserve_All_Interrupts::
962 * Pragma Unsuppress::
963 * Pragma Use_VADS_Size::
964 * Pragma Validity_Checks::
967 * Pragma Weak_External::
968 * Pragma Wide_Character_Encoding::
971 @node Pragma Abort_Defer
972 @unnumberedsec Pragma Abort_Defer
974 @cindex Deferring aborts
982 This pragma must appear at the start of the statement sequence of a
983 handled sequence of statements (right after the @code{begin}). It has
984 the effect of deferring aborts for the sequence of statements (but not
985 for the declarations or handlers, if any, associated with this statement
989 @unnumberedsec Pragma Ada_83
998 A configuration pragma that establishes Ada 83 mode for the unit to
999 which it applies, regardless of the mode set by the command line
1000 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1001 the syntax and semantics of Ada 83, as defined in the original Ada
1002 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1003 and Ada 2005 are not recognized, optional package bodies are allowed,
1004 and generics may name types with unknown discriminants without using
1005 the @code{(<>)} notation. In addition, some but not all of the additional
1006 restrictions of Ada 83 are enforced.
1008 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1009 Ada 83 code to be compiled and adapted to GNAT with less effort.
1010 Secondly, it aids in keeping code backwards compatible with Ada 83.
1011 However, there is no guarantee that code that is processed correctly
1012 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1013 83 compiler, since GNAT does not enforce all the additional checks
1017 @unnumberedsec Pragma Ada_95
1021 @smallexample @c ada
1026 A configuration pragma that establishes Ada 95 mode for the unit to which
1027 it applies, regardless of the mode set by the command line switches.
1028 This mode is set automatically for the @code{Ada} and @code{System}
1029 packages and their children, so you need not specify it in these
1030 contexts. This pragma is useful when writing a reusable component that
1031 itself uses Ada 95 features, but which is intended to be usable from
1032 either Ada 83 or Ada 95 programs.
1035 @unnumberedsec Pragma Ada_05
1039 @smallexample @c ada
1044 A configuration pragma that establishes Ada 2005 mode for the unit to which
1045 it applies, regardless of the mode set by the command line switches.
1046 This pragma is useful when writing a reusable component that
1047 itself uses Ada 2005 features, but which is intended to be usable from
1048 either Ada 83 or Ada 95 programs.
1050 @node Pragma Ada_2005
1051 @unnumberedsec Pragma Ada_2005
1055 @smallexample @c ada
1060 This configuration pragma is a synonym for pragma Ada_05 and has the
1061 same syntax and effect.
1064 @unnumberedsec Pragma Ada_12
1068 @smallexample @c ada
1073 A configuration pragma that establishes Ada 2012 mode for the unit to which
1074 it applies, regardless of the mode set by the command line switches.
1075 This mode is set automatically for the @code{Ada} and @code{System}
1076 packages and their children, so you need not specify it in these
1077 contexts. This pragma is useful when writing a reusable component that
1078 itself uses Ada 2012 features, but which is intended to be usable from
1079 Ada 83, Ada 95, or Ada 2005 programs.
1081 @node Pragma Ada_2012
1082 @unnumberedsec Pragma Ada_2012
1086 @smallexample @c ada
1091 This configuration pragma is a synonym for pragma Ada_12 and has the
1092 same syntax and effect.
1094 @node Pragma Annotate
1095 @unnumberedsec Pragma Annotate
1099 @smallexample @c ada
1100 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1102 ARG ::= NAME | EXPRESSION
1106 This pragma is used to annotate programs. @var{identifier} identifies
1107 the type of annotation. GNAT verifies that it is an identifier, but does
1108 not otherwise analyze it. The second optional identifier is also left
1109 unanalyzed, and by convention is used to control the action of the tool to
1110 which the annotation is addressed. The remaining @var{arg} arguments
1111 can be either string literals or more generally expressions.
1112 String literals are assumed to be either of type
1113 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1114 depending on the character literals they contain.
1115 All other kinds of arguments are analyzed as expressions, and must be
1118 The analyzed pragma is retained in the tree, but not otherwise processed
1119 by any part of the GNAT compiler, except to generate corresponding note
1120 lines in the generated ALI file. For the format of these note lines, see
1121 the compiler source file lib-writ.ads. This pragma is intended for use by
1122 external tools, including ASIS@. The use of pragma Annotate does not
1123 affect the compilation process in any way. This pragma may be used as
1124 a configuration pragma.
1127 @unnumberedsec Pragma Assert
1131 @smallexample @c ada
1134 [, string_EXPRESSION]);
1138 The effect of this pragma depends on whether the corresponding command
1139 line switch is set to activate assertions. The pragma expands into code
1140 equivalent to the following:
1142 @smallexample @c ada
1143 if assertions-enabled then
1144 if not boolean_EXPRESSION then
1145 System.Assertions.Raise_Assert_Failure
1146 (string_EXPRESSION);
1152 The string argument, if given, is the message that will be associated
1153 with the exception occurrence if the exception is raised. If no second
1154 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1155 where @var{file} is the name of the source file containing the assert,
1156 and @var{nnn} is the line number of the assert. A pragma is not a
1157 statement, so if a statement sequence contains nothing but a pragma
1158 assert, then a null statement is required in addition, as in:
1160 @smallexample @c ada
1163 pragma Assert (K > 3, "Bad value for K");
1169 Note that, as with the @code{if} statement to which it is equivalent, the
1170 type of the expression is either @code{Standard.Boolean}, or any type derived
1171 from this standard type.
1173 If assertions are disabled (switch @option{-gnata} not used), then there
1174 is no run-time effect (and in particular, any side effects from the
1175 expression will not occur at run time). (The expression is still
1176 analyzed at compile time, and may cause types to be frozen if they are
1177 mentioned here for the first time).
1179 If assertions are enabled, then the given expression is tested, and if
1180 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1181 which results in the raising of @code{Assert_Failure} with the given message.
1183 You should generally avoid side effects in the expression arguments of
1184 this pragma, because these side effects will turn on and off with the
1185 setting of the assertions mode, resulting in assertions that have an
1186 effect on the program. However, the expressions are analyzed for
1187 semantic correctness whether or not assertions are enabled, so turning
1188 assertions on and off cannot affect the legality of a program.
1190 Note that the implementation defined policy @code{DISABLE}, given in a
1191 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1193 Note: this is a standard language-defined pragma in versions
1194 of Ada from 2005 on. In GNAT, it is implemented in all versions
1195 of Ada, and the DISABLE policy is an implementation-defined
1199 @node Pragma Assertion_Policy
1200 @unnumberedsec Pragma Assertion_Policy
1201 @findex Debug_Policy
1205 @smallexample @c ada
1206 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1210 If the argument is @code{CHECK}, then assertions are enabled.
1211 If the argument is @code{IGNORE}, then assertions are ignored.
1212 This pragma overrides the effect of the @option{-gnata} switch on the
1215 Assertions are of three kinds:
1219 Pragma @code{Assert}.
1221 In Ada 2012, all assertions defined in the RM as aspects: preconditions,
1222 postconditions, type invariants and (sub)type predicates.
1224 Corresponding pragmas for type invariants and (sub)type predicates.
1227 The implementation defined policy @code{DISABLE} is like
1228 @code{IGNORE} except that it completely disables semantic
1229 checking of the argument to @code{pragma Assert}. This may
1230 be useful when the pragma argument references subprograms
1231 in a with'ed package which is replaced by a dummy package
1232 for the final build.
1234 Note: this is a standard language-defined pragma in versions
1235 of Ada from 2005 on. In GNAT, it is implemented in all versions
1236 of Ada, and the DISABLE policy is an implementation-defined
1239 @node Pragma Assume_No_Invalid_Values
1240 @unnumberedsec Pragma Assume_No_Invalid_Values
1241 @findex Assume_No_Invalid_Values
1242 @cindex Invalid representations
1243 @cindex Invalid values
1246 @smallexample @c ada
1247 pragma Assume_No_Invalid_Values (On | Off);
1251 This is a configuration pragma that controls the assumptions made by the
1252 compiler about the occurrence of invalid representations (invalid values)
1255 The default behavior (corresponding to an Off argument for this pragma), is
1256 to assume that values may in general be invalid unless the compiler can
1257 prove they are valid. Consider the following example:
1259 @smallexample @c ada
1260 V1 : Integer range 1 .. 10;
1261 V2 : Integer range 11 .. 20;
1263 for J in V2 .. V1 loop
1269 if V1 and V2 have valid values, then the loop is known at compile
1270 time not to execute since the lower bound must be greater than the
1271 upper bound. However in default mode, no such assumption is made,
1272 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1273 is given, the compiler will assume that any occurrence of a variable
1274 other than in an explicit @code{'Valid} test always has a valid
1275 value, and the loop above will be optimized away.
1277 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1278 you know your code is free of uninitialized variables and other
1279 possible sources of invalid representations, and may result in
1280 more efficient code. A program that accesses an invalid representation
1281 with this pragma in effect is erroneous, so no guarantees can be made
1284 It is peculiar though permissible to use this pragma in conjunction
1285 with validity checking (-gnatVa). In such cases, accessing invalid
1286 values will generally give an exception, though formally the program
1287 is erroneous so there are no guarantees that this will always be the
1288 case, and it is recommended that these two options not be used together.
1290 @node Pragma Ast_Entry
1291 @unnumberedsec Pragma Ast_Entry
1296 @smallexample @c ada
1297 pragma AST_Entry (entry_IDENTIFIER);
1301 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1302 argument is the simple name of a single entry; at most one @code{AST_Entry}
1303 pragma is allowed for any given entry. This pragma must be used in
1304 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1305 the entry declaration and in the same task type specification or single task
1306 as the entry to which it applies. This pragma specifies that the given entry
1307 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1308 resulting from an OpenVMS system service call. The pragma does not affect
1309 normal use of the entry. For further details on this pragma, see the
1310 DEC Ada Language Reference Manual, section 9.12a.
1312 @node Pragma C_Pass_By_Copy
1313 @unnumberedsec Pragma C_Pass_By_Copy
1314 @cindex Passing by copy
1315 @findex C_Pass_By_Copy
1318 @smallexample @c ada
1319 pragma C_Pass_By_Copy
1320 ([Max_Size =>] static_integer_EXPRESSION);
1324 Normally the default mechanism for passing C convention records to C
1325 convention subprograms is to pass them by reference, as suggested by RM
1326 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1327 this default, by requiring that record formal parameters be passed by
1328 copy if all of the following conditions are met:
1332 The size of the record type does not exceed the value specified for
1335 The record type has @code{Convention C}.
1337 The formal parameter has this record type, and the subprogram has a
1338 foreign (non-Ada) convention.
1342 If these conditions are met the argument is passed by copy, i.e.@: in a
1343 manner consistent with what C expects if the corresponding formal in the
1344 C prototype is a struct (rather than a pointer to a struct).
1346 You can also pass records by copy by specifying the convention
1347 @code{C_Pass_By_Copy} for the record type, or by using the extended
1348 @code{Import} and @code{Export} pragmas, which allow specification of
1349 passing mechanisms on a parameter by parameter basis.
1352 @unnumberedsec Pragma Check
1354 @cindex Named assertions
1358 @smallexample @c ada
1360 [Name =>] Identifier,
1361 [Check =>] Boolean_EXPRESSION
1362 [, [Message =>] string_EXPRESSION] );
1366 This pragma is similar to the predefined pragma @code{Assert} except that an
1367 extra identifier argument is present. In conjunction with pragma
1368 @code{Check_Policy}, this can be used to define groups of assertions that can
1369 be independently controlled. The identifier @code{Assertion} is special, it
1370 refers to the normal set of pragma @code{Assert} statements. The identifiers
1371 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1372 names, so these three names would normally not be used directly in a pragma
1375 Checks introduced by this pragma are normally deactivated by default. They can
1376 be activated either by the command line option @option{-gnata}, which turns on
1377 all checks, or individually controlled using pragma @code{Check_Policy}.
1379 @node Pragma Check_Name
1380 @unnumberedsec Pragma Check_Name
1381 @cindex Defining check names
1382 @cindex Check names, defining
1386 @smallexample @c ada
1387 pragma Check_Name (check_name_IDENTIFIER);
1391 This is a configuration pragma that defines a new implementation
1392 defined check name (unless IDENTIFIER matches one of the predefined
1393 check names, in which case the pragma has no effect). Check names
1394 are global to a partition, so if two or more configuration pragmas
1395 are present in a partition mentioning the same name, only one new
1396 check name is introduced.
1398 An implementation defined check name introduced with this pragma may
1399 be used in only three contexts: @code{pragma Suppress},
1400 @code{pragma Unsuppress},
1401 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1402 any of these three cases, the check name must be visible. A check
1403 name is visible if it is in the configuration pragmas applying to
1404 the current unit, or if it appears at the start of any unit that
1405 is part of the dependency set of the current unit (e.g., units that
1406 are mentioned in @code{with} clauses).
1408 @node Pragma Check_Policy
1409 @unnumberedsec Pragma Check_Policy
1410 @cindex Controlling assertions
1411 @cindex Assertions, control
1412 @cindex Check pragma control
1413 @cindex Named assertions
1417 @smallexample @c ada
1419 ([Name =>] Identifier,
1420 [Policy =>] POLICY_IDENTIFIER);
1422 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1426 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1427 except that it controls sets of named assertions introduced using the
1428 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1429 @code{Assertion_Policy}) can be used within a declarative part, in which case
1430 it controls the status to the end of the corresponding construct (in a manner
1431 identical to pragma @code{Suppress)}.
1433 The identifier given as the first argument corresponds to a name used in
1434 associated @code{Check} pragmas. For example, if the pragma:
1436 @smallexample @c ada
1437 pragma Check_Policy (Critical_Error, OFF);
1441 is given, then subsequent @code{Check} pragmas whose first argument is also
1442 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1443 controls the behavior of normal assertions (thus a pragma
1444 @code{Check_Policy} with this identifier is similar to the normal
1445 @code{Assertion_Policy} pragma except that it can appear within a
1448 The special identifiers @code{Precondition} and @code{Postcondition} control
1449 the status of preconditions and postconditions given as pragmas.
1450 If a @code{Precondition} pragma
1451 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1452 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1453 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1454 are recognized. Note that preconditions and postconditions given as aspects
1455 are controlled differently, either by the @code{Assertion_Policy} pragma or
1456 by the @code{Check_Policy} pragma with identifier @code{Assertion}.
1458 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1459 to turn on corresponding checks. The default for a set of checks for which no
1460 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1461 @option{-gnata} is given, which turns on all checks by default.
1463 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1464 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1465 compatibility with the standard @code{Assertion_Policy} pragma.
1467 The implementation defined policy @code{DISABLE} is like
1468 @code{OFF} except that it completely disables semantic
1469 checking of the argument to the corresponding class of
1470 pragmas. This may be useful when the pragma arguments reference
1471 subprograms in a with'ed package which is replaced by a dummy package
1472 for the final build.
1474 @node Pragma Comment
1475 @unnumberedsec Pragma Comment
1480 @smallexample @c ada
1481 pragma Comment (static_string_EXPRESSION);
1485 This is almost identical in effect to pragma @code{Ident}. It allows the
1486 placement of a comment into the object file and hence into the
1487 executable file if the operating system permits such usage. The
1488 difference is that @code{Comment}, unlike @code{Ident}, has
1489 no limitations on placement of the pragma (it can be placed
1490 anywhere in the main source unit), and if more than one pragma
1491 is used, all comments are retained.
1493 @node Pragma Common_Object
1494 @unnumberedsec Pragma Common_Object
1495 @findex Common_Object
1499 @smallexample @c ada
1500 pragma Common_Object (
1501 [Internal =>] LOCAL_NAME
1502 [, [External =>] EXTERNAL_SYMBOL]
1503 [, [Size =>] EXTERNAL_SYMBOL] );
1507 | static_string_EXPRESSION
1511 This pragma enables the shared use of variables stored in overlaid
1512 linker areas corresponding to the use of @code{COMMON}
1513 in Fortran. The single
1514 object @var{LOCAL_NAME} is assigned to the area designated by
1515 the @var{External} argument.
1516 You may define a record to correspond to a series
1517 of fields. The @var{Size} argument
1518 is syntax checked in GNAT, but otherwise ignored.
1520 @code{Common_Object} is not supported on all platforms. If no
1521 support is available, then the code generator will issue a message
1522 indicating that the necessary attribute for implementation of this
1523 pragma is not available.
1525 @node Pragma Compile_Time_Error
1526 @unnumberedsec Pragma Compile_Time_Error
1527 @findex Compile_Time_Error
1531 @smallexample @c ada
1532 pragma Compile_Time_Error
1533 (boolean_EXPRESSION, static_string_EXPRESSION);
1537 This pragma can be used to generate additional compile time
1539 is particularly useful in generics, where errors can be issued for
1540 specific problematic instantiations. The first parameter is a boolean
1541 expression. The pragma is effective only if the value of this expression
1542 is known at compile time, and has the value True. The set of expressions
1543 whose values are known at compile time includes all static boolean
1544 expressions, and also other values which the compiler can determine
1545 at compile time (e.g., the size of a record type set by an explicit
1546 size representation clause, or the value of a variable which was
1547 initialized to a constant and is known not to have been modified).
1548 If these conditions are met, an error message is generated using
1549 the value given as the second argument. This string value may contain
1550 embedded ASCII.LF characters to break the message into multiple lines.
1552 @node Pragma Compile_Time_Warning
1553 @unnumberedsec Pragma Compile_Time_Warning
1554 @findex Compile_Time_Warning
1558 @smallexample @c ada
1559 pragma Compile_Time_Warning
1560 (boolean_EXPRESSION, static_string_EXPRESSION);
1564 Same as pragma Compile_Time_Error, except a warning is issued instead
1565 of an error message. Note that if this pragma is used in a package that
1566 is with'ed by a client, the client will get the warning even though it
1567 is issued by a with'ed package (normally warnings in with'ed units are
1568 suppressed, but this is a special exception to that rule).
1570 One typical use is within a generic where compile time known characteristics
1571 of formal parameters are tested, and warnings given appropriately. Another use
1572 with a first parameter of True is to warn a client about use of a package,
1573 for example that it is not fully implemented.
1575 @node Pragma Compiler_Unit
1576 @unnumberedsec Pragma Compiler_Unit
1577 @findex Compiler_Unit
1581 @smallexample @c ada
1582 pragma Compiler_Unit;
1586 This pragma is intended only for internal use in the GNAT run-time library.
1587 It indicates that the unit is used as part of the compiler build. The effect
1588 is to disallow constructs (raise with message, conditional expressions etc)
1589 that would cause trouble when bootstrapping using an older version of GNAT.
1590 For the exact list of restrictions, see the compiler sources and references
1591 to Is_Compiler_Unit.
1593 @node Pragma Complete_Representation
1594 @unnumberedsec Pragma Complete_Representation
1595 @findex Complete_Representation
1599 @smallexample @c ada
1600 pragma Complete_Representation;
1604 This pragma must appear immediately within a record representation
1605 clause. Typical placements are before the first component clause
1606 or after the last component clause. The effect is to give an error
1607 message if any component is missing a component clause. This pragma
1608 may be used to ensure that a record representation clause is
1609 complete, and that this invariant is maintained if fields are
1610 added to the record in the future.
1612 @node Pragma Complex_Representation
1613 @unnumberedsec Pragma Complex_Representation
1614 @findex Complex_Representation
1618 @smallexample @c ada
1619 pragma Complex_Representation
1620 ([Entity =>] LOCAL_NAME);
1624 The @var{Entity} argument must be the name of a record type which has
1625 two fields of the same floating-point type. The effect of this pragma is
1626 to force gcc to use the special internal complex representation form for
1627 this record, which may be more efficient. Note that this may result in
1628 the code for this type not conforming to standard ABI (application
1629 binary interface) requirements for the handling of record types. For
1630 example, in some environments, there is a requirement for passing
1631 records by pointer, and the use of this pragma may result in passing
1632 this type in floating-point registers.
1634 @node Pragma Component_Alignment
1635 @unnumberedsec Pragma Component_Alignment
1636 @cindex Alignments of components
1637 @findex Component_Alignment
1641 @smallexample @c ada
1642 pragma Component_Alignment (
1643 [Form =>] ALIGNMENT_CHOICE
1644 [, [Name =>] type_LOCAL_NAME]);
1646 ALIGNMENT_CHOICE ::=
1654 Specifies the alignment of components in array or record types.
1655 The meaning of the @var{Form} argument is as follows:
1658 @findex Component_Size
1659 @item Component_Size
1660 Aligns scalar components and subcomponents of the array or record type
1661 on boundaries appropriate to their inherent size (naturally
1662 aligned). For example, 1-byte components are aligned on byte boundaries,
1663 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1664 integer components are aligned on 4-byte boundaries and so on. These
1665 alignment rules correspond to the normal rules for C compilers on all
1666 machines except the VAX@.
1668 @findex Component_Size_4
1669 @item Component_Size_4
1670 Naturally aligns components with a size of four or fewer
1671 bytes. Components that are larger than 4 bytes are placed on the next
1674 @findex Storage_Unit
1676 Specifies that array or record components are byte aligned, i.e.@:
1677 aligned on boundaries determined by the value of the constant
1678 @code{System.Storage_Unit}.
1682 Specifies that array or record components are aligned on default
1683 boundaries, appropriate to the underlying hardware or operating system or
1684 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1685 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1686 the @code{Default} choice is the same as @code{Component_Size} (natural
1691 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1692 refer to a local record or array type, and the specified alignment
1693 choice applies to the specified type. The use of
1694 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1695 @code{Component_Alignment} pragma to be ignored. The use of
1696 @code{Component_Alignment} together with a record representation clause
1697 is only effective for fields not specified by the representation clause.
1699 If the @code{Name} parameter is absent, the pragma can be used as either
1700 a configuration pragma, in which case it applies to one or more units in
1701 accordance with the normal rules for configuration pragmas, or it can be
1702 used within a declarative part, in which case it applies to types that
1703 are declared within this declarative part, or within any nested scope
1704 within this declarative part. In either case it specifies the alignment
1705 to be applied to any record or array type which has otherwise standard
1708 If the alignment for a record or array type is not specified (using
1709 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1710 clause), the GNAT uses the default alignment as described previously.
1712 @node Pragma Contract_Case
1713 @unnumberedsec Pragma Contract_Case
1714 @cindex Contract cases
1715 @findex Contract_Case
1719 @smallexample @c ada
1720 pragma Contract_Case (
1721 [Name =>] static_string_Expression
1722 ,[Mode =>] (Nominal | Robustness)
1723 [, Requires => Boolean_Expression]
1724 [, Ensures => Boolean_Expression]);
1728 The @code{Contract_Case} pragma allows defining fine-grain specifications
1729 that can complement or replace the contract given by a precondition and a
1730 postcondition. Additionally, the @code{Contract_Case} pragma can be used
1731 by testing and formal verification tools. The compiler checks its validity and,
1732 depending on the assertion policy at the point of declaration of the pragma,
1733 it may insert a check in the executable. For code generation, the contract
1736 @smallexample @c ada
1737 pragma Contract_Case (
1747 @smallexample @c ada
1748 pragma Postcondition (not R'Old or else E);
1752 which is also equivalent to (in Ada 2012)
1754 @smallexample @c ada
1755 pragma Postcondition (if R'Old then E);
1759 expressing that, whenever condition @code{R} is satisfied on entry to the
1760 subprogram, condition @code{E} should be fulfilled on exit to the subprogram.
1762 A precondition @code{P} and postcondition @code{Q} can also be
1763 expressed as contract cases:
1765 @smallexample @c ada
1766 pragma Contract_Case (
1767 Name => "Replace precondition",
1771 pragma Contract_Case (
1772 Name => "Replace postcondition",
1778 @code{Contract_Case} pragmas may only appear immediately following the
1779 (separate) declaration of a subprogram in a package declaration, inside
1780 a package spec unit. Only other pragmas may intervene (that is appear
1781 between the subprogram declaration and a contract case).
1783 The compiler checks that boolean expressions given in @code{Requires} and
1784 @code{Ensures} are valid, where the rules for @code{Requires} are the
1785 same as the rule for an expression in @code{Precondition} and the rules
1786 for @code{Ensures} are the same as the rule for an expression in
1787 @code{Postcondition}. In particular, attributes @code{'Old} and
1788 @code{'Result} can only be used within the @code{Ensures}
1789 expression. The following is an example of use within a package spec:
1791 @smallexample @c ada
1792 package Math_Functions is
1794 function Sqrt (Arg : Float) return Float;
1795 pragma Contract_Case (Name => "Small argument",
1797 Requires => Arg < 100,
1798 Ensures => Sqrt'Result < 10);
1804 The meaning of a contract case is that, whenever the associated subprogram is
1805 executed in a context where @code{Requires} holds, then @code{Ensures}
1806 should hold when the subprogram returns. Mode @code{Nominal} indicates
1807 that the input context should also satisfy the precondition of the
1808 subprogram, and the output context should also satisfy its
1809 postcondition. More @code{Robustness} indicates that the precondition and
1810 postcondition of the subprogram should be ignored for this contract case,
1811 which is mostly useful when testing such a contract using a testing tool
1812 that understands contract cases.
1814 @node Pragma Convention_Identifier
1815 @unnumberedsec Pragma Convention_Identifier
1816 @findex Convention_Identifier
1817 @cindex Conventions, synonyms
1821 @smallexample @c ada
1822 pragma Convention_Identifier (
1823 [Name =>] IDENTIFIER,
1824 [Convention =>] convention_IDENTIFIER);
1828 This pragma provides a mechanism for supplying synonyms for existing
1829 convention identifiers. The @code{Name} identifier can subsequently
1830 be used as a synonym for the given convention in other pragmas (including
1831 for example pragma @code{Import} or another @code{Convention_Identifier}
1832 pragma). As an example of the use of this, suppose you had legacy code
1833 which used Fortran77 as the identifier for Fortran. Then the pragma:
1835 @smallexample @c ada
1836 pragma Convention_Identifier (Fortran77, Fortran);
1840 would allow the use of the convention identifier @code{Fortran77} in
1841 subsequent code, avoiding the need to modify the sources. As another
1842 example, you could use this to parameterize convention requirements
1843 according to systems. Suppose you needed to use @code{Stdcall} on
1844 windows systems, and @code{C} on some other system, then you could
1845 define a convention identifier @code{Library} and use a single
1846 @code{Convention_Identifier} pragma to specify which convention
1847 would be used system-wide.
1849 @node Pragma CPP_Class
1850 @unnumberedsec Pragma CPP_Class
1852 @cindex Interfacing with C++
1856 @smallexample @c ada
1857 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1861 The argument denotes an entity in the current declarative region that is
1862 declared as a record type. It indicates that the type corresponds to an
1863 externally declared C++ class type, and is to be laid out the same way
1864 that C++ would lay out the type. If the C++ class has virtual primitives
1865 then the record must be declared as a tagged record type.
1867 Types for which @code{CPP_Class} is specified do not have assignment or
1868 equality operators defined (such operations can be imported or declared
1869 as subprograms as required). Initialization is allowed only by constructor
1870 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1871 limited if not explicitly declared as limited or derived from a limited
1872 type, and an error is issued in that case.
1874 See @ref{Interfacing to C++} for related information.
1876 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1877 for backward compatibility but its functionality is available
1878 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1880 @node Pragma CPP_Constructor
1881 @unnumberedsec Pragma CPP_Constructor
1882 @cindex Interfacing with C++
1883 @findex CPP_Constructor
1887 @smallexample @c ada
1888 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1889 [, [External_Name =>] static_string_EXPRESSION ]
1890 [, [Link_Name =>] static_string_EXPRESSION ]);
1894 This pragma identifies an imported function (imported in the usual way
1895 with pragma @code{Import}) as corresponding to a C++ constructor. If
1896 @code{External_Name} and @code{Link_Name} are not specified then the
1897 @code{Entity} argument is a name that must have been previously mentioned
1898 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1899 must be of one of the following forms:
1903 @code{function @var{Fname} return @var{T}}
1907 @code{function @var{Fname} return @var{T}'Class}
1910 @code{function @var{Fname} (@dots{}) return @var{T}}
1914 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1918 where @var{T} is a limited record type imported from C++ with pragma
1919 @code{Import} and @code{Convention} = @code{CPP}.
1921 The first two forms import the default constructor, used when an object
1922 of type @var{T} is created on the Ada side with no explicit constructor.
1923 The latter two forms cover all the non-default constructors of the type.
1924 See the @value{EDITION} User's Guide for details.
1926 If no constructors are imported, it is impossible to create any objects
1927 on the Ada side and the type is implicitly declared abstract.
1929 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1930 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
1932 See @ref{Interfacing to C++} for more related information.
1934 Note: The use of functions returning class-wide types for constructors is
1935 currently obsolete. They are supported for backward compatibility. The
1936 use of functions returning the type T leave the Ada sources more clear
1937 because the imported C++ constructors always return an object of type T;
1938 that is, they never return an object whose type is a descendant of type T.
1940 @node Pragma CPP_Virtual
1941 @unnumberedsec Pragma CPP_Virtual
1942 @cindex Interfacing to C++
1945 This pragma is now obsolete has has no effect because GNAT generates
1946 the same object layout than the G++ compiler.
1948 See @ref{Interfacing to C++} for related information.
1950 @node Pragma CPP_Vtable
1951 @unnumberedsec Pragma CPP_Vtable
1952 @cindex Interfacing with C++
1955 This pragma is now obsolete has has no effect because GNAT generates
1956 the same object layout than the G++ compiler.
1958 See @ref{Interfacing to C++} for related information.
1961 @unnumberedsec Pragma Debug
1966 @smallexample @c ada
1967 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1969 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1971 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1975 The procedure call argument has the syntactic form of an expression, meeting
1976 the syntactic requirements for pragmas.
1978 If debug pragmas are not enabled or if the condition is present and evaluates
1979 to False, this pragma has no effect. If debug pragmas are enabled, the
1980 semantics of the pragma is exactly equivalent to the procedure call statement
1981 corresponding to the argument with a terminating semicolon. Pragmas are
1982 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1983 intersperse calls to debug procedures in the middle of declarations. Debug
1984 pragmas can be enabled either by use of the command line switch @option{-gnata}
1985 or by use of the configuration pragma @code{Debug_Policy}.
1987 @node Pragma Debug_Policy
1988 @unnumberedsec Pragma Debug_Policy
1989 @findex Debug_Policy
1993 @smallexample @c ada
1994 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
1998 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1999 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
2000 This pragma overrides the effect of the @option{-gnata} switch on the
2003 The implementation defined policy @code{DISABLE} is like
2004 @code{IGNORE} except that it completely disables semantic
2005 checking of the argument to @code{pragma Debug}. This may
2006 be useful when the pragma argument references subprograms
2007 in a with'ed package which is replaced by a dummy package
2008 for the final build.
2010 @node Pragma Detect_Blocking
2011 @unnumberedsec Pragma Detect_Blocking
2012 @findex Detect_Blocking
2016 @smallexample @c ada
2017 pragma Detect_Blocking;
2021 This is a configuration pragma that forces the detection of potentially
2022 blocking operations within a protected operation, and to raise Program_Error
2025 @node Pragma Elaboration_Checks
2026 @unnumberedsec Pragma Elaboration_Checks
2027 @cindex Elaboration control
2028 @findex Elaboration_Checks
2032 @smallexample @c ada
2033 pragma Elaboration_Checks (Dynamic | Static);
2037 This is a configuration pragma that provides control over the
2038 elaboration model used by the compilation affected by the
2039 pragma. If the parameter is @code{Dynamic},
2040 then the dynamic elaboration
2041 model described in the Ada Reference Manual is used, as though
2042 the @option{-gnatE} switch had been specified on the command
2043 line. If the parameter is @code{Static}, then the default GNAT static
2044 model is used. This configuration pragma overrides the setting
2045 of the command line. For full details on the elaboration models
2046 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2047 gnat_ugn, @value{EDITION} User's Guide}.
2049 @node Pragma Eliminate
2050 @unnumberedsec Pragma Eliminate
2051 @cindex Elimination of unused subprograms
2056 @smallexample @c ada
2057 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2058 [Source_Location =>] STRING_LITERAL);
2062 The string literal given for the source location is a string which
2063 specifies the line number of the occurrence of the entity, using
2064 the syntax for SOURCE_TRACE given below:
2066 @smallexample @c ada
2067 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2072 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2074 LINE_NUMBER ::= DIGIT @{DIGIT@}
2078 Spaces around the colon in a @code{Source_Reference} are optional.
2080 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2081 explicit subprogram declaration, where the @code{entity} name in this
2082 designator appears on the source line specified by the source location.
2084 The source trace that is given as the @code{Source_Location} shall obey the
2085 following rules. The @code{FILE_NAME} is the short name (with no directory
2086 information) of an Ada source file, given using exactly the required syntax
2087 for the underlying file system (e.g. case is important if the underlying
2088 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2089 number of the occurrence of the @code{entity}
2090 as a decimal literal without an exponent or point. If an @code{entity} is not
2091 declared in a generic instantiation (this includes generic subprogram
2092 instances), the source trace includes only one source reference. If an entity
2093 is declared inside a generic instantiation, its source trace (when parsing
2094 from left to right) starts with the source location of the declaration of the
2095 entity in the generic unit and ends with the source location of the
2096 instantiation (it is given in square brackets). This approach is recursively
2097 used in case of nested instantiations: the rightmost (nested most deeply in
2098 square brackets) element of the source trace is the location of the outermost
2099 instantiation, the next to left element is the location of the next (first
2100 nested) instantiation in the code of the corresponding generic unit, and so
2101 on, and the leftmost element (that is out of any square brackets) is the
2102 location of the declaration of the entity to eliminate in a generic unit.
2104 Note that the @code{Source_Location} argument specifies which of a set of
2105 similarly named entities is being eliminated, dealing both with overloading,
2106 and also appearence of the same entity name in different scopes.
2108 This pragma indicates that the given entity is not used in the program to be
2109 compiled and built. The effect of the pragma is to allow the compiler to
2110 eliminate the code or data associated with the named entity. Any reference to
2111 an eliminated entity causes a compile-time or link-time error.
2113 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2114 in a system-independent manner, with unused entities eliminated, without
2115 needing to modify the source text. Normally the required set of
2116 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2118 Any source file change that removes, splits, or
2119 adds lines may make the set of Eliminate pragmas invalid because their
2120 @code{Source_Location} argument values may get out of date.
2122 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2123 operation. In this case all the subprograms to which the given operation can
2124 dispatch are considered to be unused (are never called as a result of a direct
2125 or a dispatching call).
2127 @node Pragma Export_Exception
2128 @unnumberedsec Pragma Export_Exception
2130 @findex Export_Exception
2134 @smallexample @c ada
2135 pragma Export_Exception (
2136 [Internal =>] LOCAL_NAME
2137 [, [External =>] EXTERNAL_SYMBOL]
2138 [, [Form =>] Ada | VMS]
2139 [, [Code =>] static_integer_EXPRESSION]);
2143 | static_string_EXPRESSION
2147 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2148 causes the specified exception to be propagated outside of the Ada program,
2149 so that it can be handled by programs written in other OpenVMS languages.
2150 This pragma establishes an external name for an Ada exception and makes the
2151 name available to the OpenVMS Linker as a global symbol. For further details
2152 on this pragma, see the
2153 DEC Ada Language Reference Manual, section 13.9a3.2.
2155 @node Pragma Export_Function
2156 @unnumberedsec Pragma Export_Function
2157 @cindex Argument passing mechanisms
2158 @findex Export_Function
2163 @smallexample @c ada
2164 pragma Export_Function (
2165 [Internal =>] LOCAL_NAME
2166 [, [External =>] EXTERNAL_SYMBOL]
2167 [, [Parameter_Types =>] PARAMETER_TYPES]
2168 [, [Result_Type =>] result_SUBTYPE_MARK]
2169 [, [Mechanism =>] MECHANISM]
2170 [, [Result_Mechanism =>] MECHANISM_NAME]);
2174 | static_string_EXPRESSION
2179 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2183 | subtype_Name ' Access
2187 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2189 MECHANISM_ASSOCIATION ::=
2190 [formal_parameter_NAME =>] MECHANISM_NAME
2195 | Descriptor [([Class =>] CLASS_NAME)]
2196 | Short_Descriptor [([Class =>] CLASS_NAME)]
2198 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2202 Use this pragma to make a function externally callable and optionally
2203 provide information on mechanisms to be used for passing parameter and
2204 result values. We recommend, for the purposes of improving portability,
2205 this pragma always be used in conjunction with a separate pragma
2206 @code{Export}, which must precede the pragma @code{Export_Function}.
2207 GNAT does not require a separate pragma @code{Export}, but if none is
2208 present, @code{Convention Ada} is assumed, which is usually
2209 not what is wanted, so it is usually appropriate to use this
2210 pragma in conjunction with a @code{Export} or @code{Convention}
2211 pragma that specifies the desired foreign convention.
2212 Pragma @code{Export_Function}
2213 (and @code{Export}, if present) must appear in the same declarative
2214 region as the function to which they apply.
2216 @var{internal_name} must uniquely designate the function to which the
2217 pragma applies. If more than one function name exists of this name in
2218 the declarative part you must use the @code{Parameter_Types} and
2219 @code{Result_Type} parameters is mandatory to achieve the required
2220 unique designation. @var{subtype_mark}s in these parameters must
2221 exactly match the subtypes in the corresponding function specification,
2222 using positional notation to match parameters with subtype marks.
2223 The form with an @code{'Access} attribute can be used to match an
2224 anonymous access parameter.
2227 @cindex Passing by descriptor
2228 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2229 The default behavior for Export_Function is to accept either 64bit or
2230 32bit descriptors unless short_descriptor is specified, then only 32bit
2231 descriptors are accepted.
2233 @cindex Suppressing external name
2234 Special treatment is given if the EXTERNAL is an explicit null
2235 string or a static string expressions that evaluates to the null
2236 string. In this case, no external name is generated. This form
2237 still allows the specification of parameter mechanisms.
2239 @node Pragma Export_Object
2240 @unnumberedsec Pragma Export_Object
2241 @findex Export_Object
2245 @smallexample @c ada
2246 pragma Export_Object
2247 [Internal =>] LOCAL_NAME
2248 [, [External =>] EXTERNAL_SYMBOL]
2249 [, [Size =>] EXTERNAL_SYMBOL]
2253 | static_string_EXPRESSION
2257 This pragma designates an object as exported, and apart from the
2258 extended rules for external symbols, is identical in effect to the use of
2259 the normal @code{Export} pragma applied to an object. You may use a
2260 separate Export pragma (and you probably should from the point of view
2261 of portability), but it is not required. @var{Size} is syntax checked,
2262 but otherwise ignored by GNAT@.
2264 @node Pragma Export_Procedure
2265 @unnumberedsec Pragma Export_Procedure
2266 @findex Export_Procedure
2270 @smallexample @c ada
2271 pragma Export_Procedure (
2272 [Internal =>] LOCAL_NAME
2273 [, [External =>] EXTERNAL_SYMBOL]
2274 [, [Parameter_Types =>] PARAMETER_TYPES]
2275 [, [Mechanism =>] MECHANISM]);
2279 | static_string_EXPRESSION
2284 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2288 | subtype_Name ' Access
2292 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2294 MECHANISM_ASSOCIATION ::=
2295 [formal_parameter_NAME =>] MECHANISM_NAME
2300 | Descriptor [([Class =>] CLASS_NAME)]
2301 | Short_Descriptor [([Class =>] CLASS_NAME)]
2303 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2307 This pragma is identical to @code{Export_Function} except that it
2308 applies to a procedure rather than a function and the parameters
2309 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2310 GNAT does not require a separate pragma @code{Export}, but if none is
2311 present, @code{Convention Ada} is assumed, which is usually
2312 not what is wanted, so it is usually appropriate to use this
2313 pragma in conjunction with a @code{Export} or @code{Convention}
2314 pragma that specifies the desired foreign convention.
2317 @cindex Passing by descriptor
2318 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2319 The default behavior for Export_Procedure is to accept either 64bit or
2320 32bit descriptors unless short_descriptor is specified, then only 32bit
2321 descriptors are accepted.
2323 @cindex Suppressing external name
2324 Special treatment is given if the EXTERNAL is an explicit null
2325 string or a static string expressions that evaluates to the null
2326 string. In this case, no external name is generated. This form
2327 still allows the specification of parameter mechanisms.
2329 @node Pragma Export_Value
2330 @unnumberedsec Pragma Export_Value
2331 @findex Export_Value
2335 @smallexample @c ada
2336 pragma Export_Value (
2337 [Value =>] static_integer_EXPRESSION,
2338 [Link_Name =>] static_string_EXPRESSION);
2342 This pragma serves to export a static integer value for external use.
2343 The first argument specifies the value to be exported. The Link_Name
2344 argument specifies the symbolic name to be associated with the integer
2345 value. This pragma is useful for defining a named static value in Ada
2346 that can be referenced in assembly language units to be linked with
2347 the application. This pragma is currently supported only for the
2348 AAMP target and is ignored for other targets.
2350 @node Pragma Export_Valued_Procedure
2351 @unnumberedsec Pragma Export_Valued_Procedure
2352 @findex Export_Valued_Procedure
2356 @smallexample @c ada
2357 pragma Export_Valued_Procedure (
2358 [Internal =>] LOCAL_NAME
2359 [, [External =>] EXTERNAL_SYMBOL]
2360 [, [Parameter_Types =>] PARAMETER_TYPES]
2361 [, [Mechanism =>] MECHANISM]);
2365 | static_string_EXPRESSION
2370 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2374 | subtype_Name ' Access
2378 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2380 MECHANISM_ASSOCIATION ::=
2381 [formal_parameter_NAME =>] MECHANISM_NAME
2386 | Descriptor [([Class =>] CLASS_NAME)]
2387 | Short_Descriptor [([Class =>] CLASS_NAME)]
2389 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2393 This pragma is identical to @code{Export_Procedure} except that the
2394 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2395 mode @code{OUT}, and externally the subprogram is treated as a function
2396 with this parameter as the result of the function. GNAT provides for
2397 this capability to allow the use of @code{OUT} and @code{IN OUT}
2398 parameters in interfacing to external functions (which are not permitted
2400 GNAT does not require a separate pragma @code{Export}, but if none is
2401 present, @code{Convention Ada} is assumed, which is almost certainly
2402 not what is wanted since the whole point of this pragma is to interface
2403 with foreign language functions, so it is usually appropriate to use this
2404 pragma in conjunction with a @code{Export} or @code{Convention}
2405 pragma that specifies the desired foreign convention.
2408 @cindex Passing by descriptor
2409 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2410 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2411 32bit descriptors unless short_descriptor is specified, then only 32bit
2412 descriptors are accepted.
2414 @cindex Suppressing external name
2415 Special treatment is given if the EXTERNAL is an explicit null
2416 string or a static string expressions that evaluates to the null
2417 string. In this case, no external name is generated. This form
2418 still allows the specification of parameter mechanisms.
2420 @node Pragma Extend_System
2421 @unnumberedsec Pragma Extend_System
2422 @cindex @code{system}, extending
2424 @findex Extend_System
2428 @smallexample @c ada
2429 pragma Extend_System ([Name =>] IDENTIFIER);
2433 This pragma is used to provide backwards compatibility with other
2434 implementations that extend the facilities of package @code{System}. In
2435 GNAT, @code{System} contains only the definitions that are present in
2436 the Ada RM@. However, other implementations, notably the DEC Ada 83
2437 implementation, provide many extensions to package @code{System}.
2439 For each such implementation accommodated by this pragma, GNAT provides a
2440 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2441 implementation, which provides the required additional definitions. You
2442 can use this package in two ways. You can @code{with} it in the normal
2443 way and access entities either by selection or using a @code{use}
2444 clause. In this case no special processing is required.
2446 However, if existing code contains references such as
2447 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2448 definitions provided in package @code{System}, you may use this pragma
2449 to extend visibility in @code{System} in a non-standard way that
2450 provides greater compatibility with the existing code. Pragma
2451 @code{Extend_System} is a configuration pragma whose single argument is
2452 the name of the package containing the extended definition
2453 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2454 control of this pragma will be processed using special visibility
2455 processing that looks in package @code{System.Aux_@var{xxx}} where
2456 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2457 package @code{System}, but not found in package @code{System}.
2459 You can use this pragma either to access a predefined @code{System}
2460 extension supplied with the compiler, for example @code{Aux_DEC} or
2461 you can construct your own extension unit following the above
2462 definition. Note that such a package is a child of @code{System}
2463 and thus is considered part of the implementation. To compile
2464 it you will have to use the appropriate switch for compiling
2466 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2469 @node Pragma Extensions_Allowed
2470 @unnumberedsec Pragma Extensions_Allowed
2471 @cindex Ada Extensions
2472 @cindex GNAT Extensions
2473 @findex Extensions_Allowed
2477 @smallexample @c ada
2478 pragma Extensions_Allowed (On | Off);
2482 This configuration pragma enables or disables the implementation
2483 extension mode (the use of Off as a parameter cancels the effect
2484 of the @option{-gnatX} command switch).
2486 In extension mode, the latest version of the Ada language is
2487 implemented (currently Ada 2012), and in addition a small number
2488 of GNAT specific extensions are recognized as follows:
2491 @item Constrained attribute for generic objects
2492 The @code{Constrained} attribute is permitted for objects of
2493 generic types. The result indicates if the corresponding actual
2498 @node Pragma External
2499 @unnumberedsec Pragma External
2504 @smallexample @c ada
2506 [ Convention =>] convention_IDENTIFIER,
2507 [ Entity =>] LOCAL_NAME
2508 [, [External_Name =>] static_string_EXPRESSION ]
2509 [, [Link_Name =>] static_string_EXPRESSION ]);
2513 This pragma is identical in syntax and semantics to pragma
2514 @code{Export} as defined in the Ada Reference Manual. It is
2515 provided for compatibility with some Ada 83 compilers that
2516 used this pragma for exactly the same purposes as pragma
2517 @code{Export} before the latter was standardized.
2519 @node Pragma External_Name_Casing
2520 @unnumberedsec Pragma External_Name_Casing
2521 @cindex Dec Ada 83 casing compatibility
2522 @cindex External Names, casing
2523 @cindex Casing of External names
2524 @findex External_Name_Casing
2528 @smallexample @c ada
2529 pragma External_Name_Casing (
2530 Uppercase | Lowercase
2531 [, Uppercase | Lowercase | As_Is]);
2535 This pragma provides control over the casing of external names associated
2536 with Import and Export pragmas. There are two cases to consider:
2539 @item Implicit external names
2540 Implicit external names are derived from identifiers. The most common case
2541 arises when a standard Ada Import or Export pragma is used with only two
2544 @smallexample @c ada
2545 pragma Import (C, C_Routine);
2549 Since Ada is a case-insensitive language, the spelling of the identifier in
2550 the Ada source program does not provide any information on the desired
2551 casing of the external name, and so a convention is needed. In GNAT the
2552 default treatment is that such names are converted to all lower case
2553 letters. This corresponds to the normal C style in many environments.
2554 The first argument of pragma @code{External_Name_Casing} can be used to
2555 control this treatment. If @code{Uppercase} is specified, then the name
2556 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2557 then the normal default of all lower case letters will be used.
2559 This same implicit treatment is also used in the case of extended DEC Ada 83
2560 compatible Import and Export pragmas where an external name is explicitly
2561 specified using an identifier rather than a string.
2563 @item Explicit external names
2564 Explicit external names are given as string literals. The most common case
2565 arises when a standard Ada Import or Export pragma is used with three
2568 @smallexample @c ada
2569 pragma Import (C, C_Routine, "C_routine");
2573 In this case, the string literal normally provides the exact casing required
2574 for the external name. The second argument of pragma
2575 @code{External_Name_Casing} may be used to modify this behavior.
2576 If @code{Uppercase} is specified, then the name
2577 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2578 then the name will be forced to all lowercase letters. A specification of
2579 @code{As_Is} provides the normal default behavior in which the casing is
2580 taken from the string provided.
2584 This pragma may appear anywhere that a pragma is valid. In particular, it
2585 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2586 case it applies to all subsequent compilations, or it can be used as a program
2587 unit pragma, in which case it only applies to the current unit, or it can
2588 be used more locally to control individual Import/Export pragmas.
2590 It is primarily intended for use with OpenVMS systems, where many
2591 compilers convert all symbols to upper case by default. For interfacing to
2592 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2595 @smallexample @c ada
2596 pragma External_Name_Casing (Uppercase, Uppercase);
2600 to enforce the upper casing of all external symbols.
2602 @node Pragma Fast_Math
2603 @unnumberedsec Pragma Fast_Math
2608 @smallexample @c ada
2613 This is a configuration pragma which activates a mode in which speed is
2614 considered more important for floating-point operations than absolutely
2615 accurate adherence to the requirements of the standard. Currently the
2616 following operations are affected:
2619 @item Complex Multiplication
2620 The normal simple formula for complex multiplication can result in intermediate
2621 overflows for numbers near the end of the range. The Ada standard requires that
2622 this situation be detected and corrected by scaling, but in Fast_Math mode such
2623 cases will simply result in overflow. Note that to take advantage of this you
2624 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2625 under control of the pragma, rather than use the preinstantiated versions.
2628 @node Pragma Favor_Top_Level
2629 @unnumberedsec Pragma Favor_Top_Level
2630 @findex Favor_Top_Level
2634 @smallexample @c ada
2635 pragma Favor_Top_Level (type_NAME);
2639 The named type must be an access-to-subprogram type. This pragma is an
2640 efficiency hint to the compiler, regarding the use of 'Access or
2641 'Unrestricted_Access on nested (non-library-level) subprograms. The
2642 pragma means that nested subprograms are not used with this type, or
2643 are rare, so that the generated code should be efficient in the
2644 top-level case. When this pragma is used, dynamically generated
2645 trampolines may be used on some targets for nested subprograms.
2646 See also the No_Implicit_Dynamic_Code restriction.
2648 @node Pragma Finalize_Storage_Only
2649 @unnumberedsec Pragma Finalize_Storage_Only
2650 @findex Finalize_Storage_Only
2654 @smallexample @c ada
2655 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2659 This pragma allows the compiler not to emit a Finalize call for objects
2660 defined at the library level. This is mostly useful for types where
2661 finalization is only used to deal with storage reclamation since in most
2662 environments it is not necessary to reclaim memory just before terminating
2663 execution, hence the name.
2665 @node Pragma Float_Representation
2666 @unnumberedsec Pragma Float_Representation
2668 @findex Float_Representation
2672 @smallexample @c ada
2673 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2675 FLOAT_REP ::= VAX_Float | IEEE_Float
2679 In the one argument form, this pragma is a configuration pragma which
2680 allows control over the internal representation chosen for the predefined
2681 floating point types declared in the packages @code{Standard} and
2682 @code{System}. On all systems other than OpenVMS, the argument must
2683 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2684 argument may be @code{VAX_Float} to specify the use of the VAX float
2685 format for the floating-point types in Standard. This requires that
2686 the standard runtime libraries be recompiled.
2688 The two argument form specifies the representation to be used for
2689 the specified floating-point type. On all systems other than OpenVMS,
2691 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2692 argument may be @code{VAX_Float} to specify the use of the VAX float
2697 For digits values up to 6, F float format will be used.
2699 For digits values from 7 to 9, D float format will be used.
2701 For digits values from 10 to 15, G float format will be used.
2703 Digits values above 15 are not allowed.
2707 @unnumberedsec Pragma Ident
2712 @smallexample @c ada
2713 pragma Ident (static_string_EXPRESSION);
2717 This pragma provides a string identification in the generated object file,
2718 if the system supports the concept of this kind of identification string.
2719 This pragma is allowed only in the outermost declarative part or
2720 declarative items of a compilation unit. If more than one @code{Ident}
2721 pragma is given, only the last one processed is effective.
2723 On OpenVMS systems, the effect of the pragma is identical to the effect of
2724 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2725 maximum allowed length is 31 characters, so if it is important to
2726 maintain compatibility with this compiler, you should obey this length
2729 @node Pragma Implemented
2730 @unnumberedsec Pragma Implemented
2735 @smallexample @c ada
2736 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2738 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2742 This is an Ada 2012 representation pragma which applies to protected, task
2743 and synchronized interface primitives. The use of pragma Implemented provides
2744 a way to impose a static requirement on the overriding operation by adhering
2745 to one of the three implementation kids: entry, protected procedure or any of
2748 @smallexample @c ada
2749 type Synch_Iface is synchronized interface;
2750 procedure Prim_Op (Obj : in out Iface) is abstract;
2751 pragma Implemented (Prim_Op, By_Protected_Procedure);
2753 protected type Prot_1 is new Synch_Iface with
2754 procedure Prim_Op; -- Legal
2757 protected type Prot_2 is new Synch_Iface with
2758 entry Prim_Op; -- Illegal
2761 task type Task_Typ is new Synch_Iface with
2762 entry Prim_Op; -- Illegal
2767 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2768 Implemented determines the runtime behavior of the requeue. Implementation kind
2769 By_Entry guarantees that the action of requeueing will proceed from an entry to
2770 another entry. Implementation kind By_Protected_Procedure transforms the
2771 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2772 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2773 the target's overriding subprogram kind.
2775 @node Pragma Implicit_Packing
2776 @unnumberedsec Pragma Implicit_Packing
2777 @findex Implicit_Packing
2781 @smallexample @c ada
2782 pragma Implicit_Packing;
2786 This is a configuration pragma that requests implicit packing for packed
2787 arrays for which a size clause is given but no explicit pragma Pack or
2788 specification of Component_Size is present. It also applies to records
2789 where no record representation clause is present. Consider this example:
2791 @smallexample @c ada
2792 type R is array (0 .. 7) of Boolean;
2797 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2798 does not change the layout of a composite object. So the Size clause in the
2799 above example is normally rejected, since the default layout of the array uses
2800 8-bit components, and thus the array requires a minimum of 64 bits.
2802 If this declaration is compiled in a region of code covered by an occurrence
2803 of the configuration pragma Implicit_Packing, then the Size clause in this
2804 and similar examples will cause implicit packing and thus be accepted. For
2805 this implicit packing to occur, the type in question must be an array of small
2806 components whose size is known at compile time, and the Size clause must
2807 specify the exact size that corresponds to the length of the array multiplied
2808 by the size in bits of the component type.
2809 @cindex Array packing
2811 Similarly, the following example shows the use in the record case
2813 @smallexample @c ada
2815 a, b, c, d, e, f, g, h : boolean;
2822 Without a pragma Pack, each Boolean field requires 8 bits, so the
2823 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2824 sufficient. The use of pragma Implicit_Packing allows this record
2825 declaration to compile without an explicit pragma Pack.
2826 @node Pragma Import_Exception
2827 @unnumberedsec Pragma Import_Exception
2829 @findex Import_Exception
2833 @smallexample @c ada
2834 pragma Import_Exception (
2835 [Internal =>] LOCAL_NAME
2836 [, [External =>] EXTERNAL_SYMBOL]
2837 [, [Form =>] Ada | VMS]
2838 [, [Code =>] static_integer_EXPRESSION]);
2842 | static_string_EXPRESSION
2846 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2847 It allows OpenVMS conditions (for example, from OpenVMS system services or
2848 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2849 The pragma specifies that the exception associated with an exception
2850 declaration in an Ada program be defined externally (in non-Ada code).
2851 For further details on this pragma, see the
2852 DEC Ada Language Reference Manual, section 13.9a.3.1.
2854 @node Pragma Import_Function
2855 @unnumberedsec Pragma Import_Function
2856 @findex Import_Function
2860 @smallexample @c ada
2861 pragma Import_Function (
2862 [Internal =>] LOCAL_NAME,
2863 [, [External =>] EXTERNAL_SYMBOL]
2864 [, [Parameter_Types =>] PARAMETER_TYPES]
2865 [, [Result_Type =>] SUBTYPE_MARK]
2866 [, [Mechanism =>] MECHANISM]
2867 [, [Result_Mechanism =>] MECHANISM_NAME]
2868 [, [First_Optional_Parameter =>] IDENTIFIER]);
2872 | static_string_EXPRESSION
2876 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2880 | subtype_Name ' Access
2884 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2886 MECHANISM_ASSOCIATION ::=
2887 [formal_parameter_NAME =>] MECHANISM_NAME
2892 | Descriptor [([Class =>] CLASS_NAME)]
2893 | Short_Descriptor [([Class =>] CLASS_NAME)]
2895 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2899 This pragma is used in conjunction with a pragma @code{Import} to
2900 specify additional information for an imported function. The pragma
2901 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2902 @code{Import_Function} pragma and both must appear in the same
2903 declarative part as the function specification.
2905 The @var{Internal} argument must uniquely designate
2906 the function to which the
2907 pragma applies. If more than one function name exists of this name in
2908 the declarative part you must use the @code{Parameter_Types} and
2909 @var{Result_Type} parameters to achieve the required unique
2910 designation. Subtype marks in these parameters must exactly match the
2911 subtypes in the corresponding function specification, using positional
2912 notation to match parameters with subtype marks.
2913 The form with an @code{'Access} attribute can be used to match an
2914 anonymous access parameter.
2916 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2917 parameters to specify passing mechanisms for the
2918 parameters and result. If you specify a single mechanism name, it
2919 applies to all parameters. Otherwise you may specify a mechanism on a
2920 parameter by parameter basis using either positional or named
2921 notation. If the mechanism is not specified, the default mechanism
2925 @cindex Passing by descriptor
2926 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2927 The default behavior for Import_Function is to pass a 64bit descriptor
2928 unless short_descriptor is specified, then a 32bit descriptor is passed.
2930 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2931 It specifies that the designated parameter and all following parameters
2932 are optional, meaning that they are not passed at the generated code
2933 level (this is distinct from the notion of optional parameters in Ada
2934 where the parameters are passed anyway with the designated optional
2935 parameters). All optional parameters must be of mode @code{IN} and have
2936 default parameter values that are either known at compile time
2937 expressions, or uses of the @code{'Null_Parameter} attribute.
2939 @node Pragma Import_Object
2940 @unnumberedsec Pragma Import_Object
2941 @findex Import_Object
2945 @smallexample @c ada
2946 pragma Import_Object
2947 [Internal =>] LOCAL_NAME
2948 [, [External =>] EXTERNAL_SYMBOL]
2949 [, [Size =>] EXTERNAL_SYMBOL]);
2953 | static_string_EXPRESSION
2957 This pragma designates an object as imported, and apart from the
2958 extended rules for external symbols, is identical in effect to the use of
2959 the normal @code{Import} pragma applied to an object. Unlike the
2960 subprogram case, you need not use a separate @code{Import} pragma,
2961 although you may do so (and probably should do so from a portability
2962 point of view). @var{size} is syntax checked, but otherwise ignored by
2965 @node Pragma Import_Procedure
2966 @unnumberedsec Pragma Import_Procedure
2967 @findex Import_Procedure
2971 @smallexample @c ada
2972 pragma Import_Procedure (
2973 [Internal =>] LOCAL_NAME
2974 [, [External =>] EXTERNAL_SYMBOL]
2975 [, [Parameter_Types =>] PARAMETER_TYPES]
2976 [, [Mechanism =>] MECHANISM]
2977 [, [First_Optional_Parameter =>] IDENTIFIER]);
2981 | static_string_EXPRESSION
2985 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2989 | subtype_Name ' Access
2993 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2995 MECHANISM_ASSOCIATION ::=
2996 [formal_parameter_NAME =>] MECHANISM_NAME
3001 | Descriptor [([Class =>] CLASS_NAME)]
3002 | Short_Descriptor [([Class =>] CLASS_NAME)]
3004 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3008 This pragma is identical to @code{Import_Function} except that it
3009 applies to a procedure rather than a function and the parameters
3010 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3012 @node Pragma Import_Valued_Procedure
3013 @unnumberedsec Pragma Import_Valued_Procedure
3014 @findex Import_Valued_Procedure
3018 @smallexample @c ada
3019 pragma Import_Valued_Procedure (
3020 [Internal =>] LOCAL_NAME
3021 [, [External =>] EXTERNAL_SYMBOL]
3022 [, [Parameter_Types =>] PARAMETER_TYPES]
3023 [, [Mechanism =>] MECHANISM]
3024 [, [First_Optional_Parameter =>] IDENTIFIER]);
3028 | static_string_EXPRESSION
3032 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3036 | subtype_Name ' Access
3040 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3042 MECHANISM_ASSOCIATION ::=
3043 [formal_parameter_NAME =>] MECHANISM_NAME
3048 | Descriptor [([Class =>] CLASS_NAME)]
3049 | Short_Descriptor [([Class =>] CLASS_NAME)]
3051 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3055 This pragma is identical to @code{Import_Procedure} except that the
3056 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3057 mode @code{OUT}, and externally the subprogram is treated as a function
3058 with this parameter as the result of the function. The purpose of this
3059 capability is to allow the use of @code{OUT} and @code{IN OUT}
3060 parameters in interfacing to external functions (which are not permitted
3061 in Ada functions). You may optionally use the @code{Mechanism}
3062 parameters to specify passing mechanisms for the parameters.
3063 If you specify a single mechanism name, it applies to all parameters.
3064 Otherwise you may specify a mechanism on a parameter by parameter
3065 basis using either positional or named notation. If the mechanism is not
3066 specified, the default mechanism is used.
3068 Note that it is important to use this pragma in conjunction with a separate
3069 pragma Import that specifies the desired convention, since otherwise the
3070 default convention is Ada, which is almost certainly not what is required.
3072 @node Pragma Initialize_Scalars
3073 @unnumberedsec Pragma Initialize_Scalars
3074 @findex Initialize_Scalars
3075 @cindex debugging with Initialize_Scalars
3079 @smallexample @c ada
3080 pragma Initialize_Scalars;
3084 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3085 two important differences. First, there is no requirement for the pragma
3086 to be used uniformly in all units of a partition, in particular, it is fine
3087 to use this just for some or all of the application units of a partition,
3088 without needing to recompile the run-time library.
3090 In the case where some units are compiled with the pragma, and some without,
3091 then a declaration of a variable where the type is defined in package
3092 Standard or is locally declared will always be subject to initialization,
3093 as will any declaration of a scalar variable. For composite variables,
3094 whether the variable is initialized may also depend on whether the package
3095 in which the type of the variable is declared is compiled with the pragma.
3097 The other important difference is that you can control the value used
3098 for initializing scalar objects. At bind time, you can select several
3099 options for initialization. You can
3100 initialize with invalid values (similar to Normalize_Scalars, though for
3101 Initialize_Scalars it is not always possible to determine the invalid
3102 values in complex cases like signed component fields with non-standard
3103 sizes). You can also initialize with high or
3104 low values, or with a specified bit pattern. See the @value{EDITION}
3105 User's Guide for binder options for specifying these cases.
3107 This means that you can compile a program, and then without having to
3108 recompile the program, you can run it with different values being used
3109 for initializing otherwise uninitialized values, to test if your program
3110 behavior depends on the choice. Of course the behavior should not change,
3111 and if it does, then most likely you have an erroneous reference to an
3112 uninitialized value.
3114 It is even possible to change the value at execution time eliminating even
3115 the need to rebind with a different switch using an environment variable.
3116 See the @value{EDITION} User's Guide for details.
3118 Note that pragma @code{Initialize_Scalars} is particularly useful in
3119 conjunction with the enhanced validity checking that is now provided
3120 in GNAT, which checks for invalid values under more conditions.
3121 Using this feature (see description of the @option{-gnatV} flag in the
3122 @value{EDITION} User's Guide) in conjunction with
3123 pragma @code{Initialize_Scalars}
3124 provides a powerful new tool to assist in the detection of problems
3125 caused by uninitialized variables.
3127 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3128 effect on the generated code. This may cause your code to be
3129 substantially larger. It may also cause an increase in the amount
3130 of stack required, so it is probably a good idea to turn on stack
3131 checking (see description of stack checking in the @value{EDITION}
3132 User's Guide) when using this pragma.
3134 @node Pragma Inline_Always
3135 @unnumberedsec Pragma Inline_Always
3136 @findex Inline_Always
3140 @smallexample @c ada
3141 pragma Inline_Always (NAME [, NAME]);
3145 Similar to pragma @code{Inline} except that inlining is not subject to
3146 the use of option @option{-gnatn} and the inlining happens regardless of
3147 whether this option is used.
3149 @node Pragma Inline_Generic
3150 @unnumberedsec Pragma Inline_Generic
3151 @findex Inline_Generic
3155 @smallexample @c ada
3156 pragma Inline_Generic (generic_package_NAME);
3160 This is implemented for compatibility with DEC Ada 83 and is recognized,
3161 but otherwise ignored, by GNAT@. All generic instantiations are inlined
3162 by default when using GNAT@.
3164 @node Pragma Interface
3165 @unnumberedsec Pragma Interface
3170 @smallexample @c ada
3172 [Convention =>] convention_identifier,
3173 [Entity =>] local_NAME
3174 [, [External_Name =>] static_string_expression]
3175 [, [Link_Name =>] static_string_expression]);
3179 This pragma is identical in syntax and semantics to
3180 the standard Ada pragma @code{Import}. It is provided for compatibility
3181 with Ada 83. The definition is upwards compatible both with pragma
3182 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3183 with some extended implementations of this pragma in certain Ada 83
3184 implementations. The only difference between pragma @code{Interface}
3185 and pragma @code{Import} is that there is special circuitry to allow
3186 both pragmas to appear for the same subprogram entity (normally it
3187 is illegal to have multiple @code{Import} pragmas. This is useful in
3188 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3191 @node Pragma Interface_Name
3192 @unnumberedsec Pragma Interface_Name
3193 @findex Interface_Name
3197 @smallexample @c ada
3198 pragma Interface_Name (
3199 [Entity =>] LOCAL_NAME
3200 [, [External_Name =>] static_string_EXPRESSION]
3201 [, [Link_Name =>] static_string_EXPRESSION]);
3205 This pragma provides an alternative way of specifying the interface name
3206 for an interfaced subprogram, and is provided for compatibility with Ada
3207 83 compilers that use the pragma for this purpose. You must provide at
3208 least one of @var{External_Name} or @var{Link_Name}.
3210 @node Pragma Interrupt_Handler
3211 @unnumberedsec Pragma Interrupt_Handler
3212 @findex Interrupt_Handler
3216 @smallexample @c ada
3217 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3221 This program unit pragma is supported for parameterless protected procedures
3222 as described in Annex C of the Ada Reference Manual. On the AAMP target
3223 the pragma can also be specified for nonprotected parameterless procedures
3224 that are declared at the library level (which includes procedures
3225 declared at the top level of a library package). In the case of AAMP,
3226 when this pragma is applied to a nonprotected procedure, the instruction
3227 @code{IERET} is generated for returns from the procedure, enabling
3228 maskable interrupts, in place of the normal return instruction.
3230 @node Pragma Interrupt_State
3231 @unnumberedsec Pragma Interrupt_State
3232 @findex Interrupt_State
3236 @smallexample @c ada
3237 pragma Interrupt_State
3239 [State =>] SYSTEM | RUNTIME | USER);
3243 Normally certain interrupts are reserved to the implementation. Any attempt
3244 to attach an interrupt causes Program_Error to be raised, as described in
3245 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3246 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3247 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3248 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3249 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3250 Ada exceptions, or used to implement run-time functions such as the
3251 @code{abort} statement and stack overflow checking.
3253 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3254 such uses of interrupts. It subsumes the functionality of pragma
3255 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3256 available on Windows or VMS. On all other platforms than VxWorks,
3257 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3258 and may be used to mark interrupts required by the board support package
3261 Interrupts can be in one of three states:
3265 The interrupt is reserved (no Ada handler can be installed), and the
3266 Ada run-time may not install a handler. As a result you are guaranteed
3267 standard system default action if this interrupt is raised.
3271 The interrupt is reserved (no Ada handler can be installed). The run time
3272 is allowed to install a handler for internal control purposes, but is
3273 not required to do so.
3277 The interrupt is unreserved. The user may install a handler to provide
3282 These states are the allowed values of the @code{State} parameter of the
3283 pragma. The @code{Name} parameter is a value of the type
3284 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3285 @code{Ada.Interrupts.Names}.
3287 This is a configuration pragma, and the binder will check that there
3288 are no inconsistencies between different units in a partition in how a
3289 given interrupt is specified. It may appear anywhere a pragma is legal.
3291 The effect is to move the interrupt to the specified state.
3293 By declaring interrupts to be SYSTEM, you guarantee the standard system
3294 action, such as a core dump.
3296 By declaring interrupts to be USER, you guarantee that you can install
3299 Note that certain signals on many operating systems cannot be caught and
3300 handled by applications. In such cases, the pragma is ignored. See the
3301 operating system documentation, or the value of the array @code{Reserved}
3302 declared in the spec of package @code{System.OS_Interface}.
3304 Overriding the default state of signals used by the Ada runtime may interfere
3305 with an application's runtime behavior in the cases of the synchronous signals,
3306 and in the case of the signal used to implement the @code{abort} statement.
3308 @node Pragma Invariant
3309 @unnumberedsec Pragma Invariant
3314 @smallexample @c ada
3316 ([Entity =>] private_type_LOCAL_NAME,
3317 [Check =>] EXPRESSION
3318 [,[Message =>] String_Expression]);
3322 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3323 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3324 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3325 requires the use of the aspect syntax, which is not available except in 2012
3326 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3327 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3328 note that the aspect Invariant is a synonym in GNAT for the aspect
3329 Type_Invariant, but there is no pragma Type_Invariant.
3331 The pragma must appear within the visible part of the package specification,
3332 after the type to which its Entity argument appears. As with the Invariant
3333 aspect, the Check expression is not analyzed until the end of the visible
3334 part of the package, so it may contain forward references. The Message
3335 argument, if present, provides the exception message used if the invariant
3336 is violated. If no Message parameter is provided, a default message that
3337 identifies the line on which the pragma appears is used.
3339 It is permissible to have multiple Invariants for the same type entity, in
3340 which case they are and'ed together. It is permissible to use this pragma
3341 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3342 invariant pragma for the same entity.
3344 For further details on the use of this pragma, see the Ada 2012 documentation
3345 of the Type_Invariant aspect.
3347 @node Pragma Keep_Names
3348 @unnumberedsec Pragma Keep_Names
3353 @smallexample @c ada
3354 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3358 The @var{LOCAL_NAME} argument
3359 must refer to an enumeration first subtype
3360 in the current declarative part. The effect is to retain the enumeration
3361 literal names for use by @code{Image} and @code{Value} even if a global
3362 @code{Discard_Names} pragma applies. This is useful when you want to
3363 generally suppress enumeration literal names and for example you therefore
3364 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3365 want to retain the names for specific enumeration types.
3367 @node Pragma License
3368 @unnumberedsec Pragma License
3370 @cindex License checking
3374 @smallexample @c ada
3375 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3379 This pragma is provided to allow automated checking for appropriate license
3380 conditions with respect to the standard and modified GPL@. A pragma
3381 @code{License}, which is a configuration pragma that typically appears at
3382 the start of a source file or in a separate @file{gnat.adc} file, specifies
3383 the licensing conditions of a unit as follows:
3387 This is used for a unit that can be freely used with no license restrictions.
3388 Examples of such units are public domain units, and units from the Ada
3392 This is used for a unit that is licensed under the unmodified GPL, and which
3393 therefore cannot be @code{with}'ed by a restricted unit.
3396 This is used for a unit licensed under the GNAT modified GPL that includes
3397 a special exception paragraph that specifically permits the inclusion of
3398 the unit in programs without requiring the entire program to be released
3402 This is used for a unit that is restricted in that it is not permitted to
3403 depend on units that are licensed under the GPL@. Typical examples are
3404 proprietary code that is to be released under more restrictive license
3405 conditions. Note that restricted units are permitted to @code{with} units
3406 which are licensed under the modified GPL (this is the whole point of the
3412 Normally a unit with no @code{License} pragma is considered to have an
3413 unknown license, and no checking is done. However, standard GNAT headers
3414 are recognized, and license information is derived from them as follows.
3418 A GNAT license header starts with a line containing 78 hyphens. The following
3419 comment text is searched for the appearance of any of the following strings.
3421 If the string ``GNU General Public License'' is found, then the unit is assumed
3422 to have GPL license, unless the string ``As a special exception'' follows, in
3423 which case the license is assumed to be modified GPL@.
3425 If one of the strings
3426 ``This specification is adapted from the Ada Semantic Interface'' or
3427 ``This specification is derived from the Ada Reference Manual'' is found
3428 then the unit is assumed to be unrestricted.
3432 These default actions means that a program with a restricted license pragma
3433 will automatically get warnings if a GPL unit is inappropriately
3434 @code{with}'ed. For example, the program:
3436 @smallexample @c ada
3439 procedure Secret_Stuff is
3445 if compiled with pragma @code{License} (@code{Restricted}) in a
3446 @file{gnat.adc} file will generate the warning:
3451 >>> license of withed unit "Sem_Ch3" is incompatible
3453 2. with GNAT.Sockets;
3454 3. procedure Secret_Stuff is
3458 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3459 compiler and is licensed under the
3460 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3461 run time, and is therefore licensed under the modified GPL@.
3463 @node Pragma Link_With
3464 @unnumberedsec Pragma Link_With
3469 @smallexample @c ada
3470 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3474 This pragma is provided for compatibility with certain Ada 83 compilers.
3475 It has exactly the same effect as pragma @code{Linker_Options} except
3476 that spaces occurring within one of the string expressions are treated
3477 as separators. For example, in the following case:
3479 @smallexample @c ada
3480 pragma Link_With ("-labc -ldef");
3484 results in passing the strings @code{-labc} and @code{-ldef} as two
3485 separate arguments to the linker. In addition pragma Link_With allows
3486 multiple arguments, with the same effect as successive pragmas.
3488 @node Pragma Linker_Alias
3489 @unnumberedsec Pragma Linker_Alias
3490 @findex Linker_Alias
3494 @smallexample @c ada
3495 pragma Linker_Alias (
3496 [Entity =>] LOCAL_NAME,
3497 [Target =>] static_string_EXPRESSION);
3501 @var{LOCAL_NAME} must refer to an object that is declared at the library
3502 level. This pragma establishes the given entity as a linker alias for the
3503 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3504 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3505 @var{static_string_EXPRESSION} in the object file, that is to say no space
3506 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3507 to the same address as @var{static_string_EXPRESSION} by the linker.
3509 The actual linker name for the target must be used (e.g.@: the fully
3510 encoded name with qualification in Ada, or the mangled name in C++),
3511 or it must be declared using the C convention with @code{pragma Import}
3512 or @code{pragma Export}.
3514 Not all target machines support this pragma. On some of them it is accepted
3515 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3517 @smallexample @c ada
3518 -- Example of the use of pragma Linker_Alias
3522 pragma Export (C, i);
3524 new_name_for_i : Integer;
3525 pragma Linker_Alias (new_name_for_i, "i");
3529 @node Pragma Linker_Constructor
3530 @unnumberedsec Pragma Linker_Constructor
3531 @findex Linker_Constructor
3535 @smallexample @c ada
3536 pragma Linker_Constructor (procedure_LOCAL_NAME);
3540 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3541 is declared at the library level. A procedure to which this pragma is
3542 applied will be treated as an initialization routine by the linker.
3543 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3544 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3545 of the executable is called (or immediately after the shared library is
3546 loaded if the procedure is linked in a shared library), in particular
3547 before the Ada run-time environment is set up.
3549 Because of these specific contexts, the set of operations such a procedure
3550 can perform is very limited and the type of objects it can manipulate is
3551 essentially restricted to the elementary types. In particular, it must only
3552 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3554 This pragma is used by GNAT to implement auto-initialization of shared Stand
3555 Alone Libraries, which provides a related capability without the restrictions
3556 listed above. Where possible, the use of Stand Alone Libraries is preferable
3557 to the use of this pragma.
3559 @node Pragma Linker_Destructor
3560 @unnumberedsec Pragma Linker_Destructor
3561 @findex Linker_Destructor
3565 @smallexample @c ada
3566 pragma Linker_Destructor (procedure_LOCAL_NAME);
3570 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3571 is declared at the library level. A procedure to which this pragma is
3572 applied will be treated as a finalization routine by the linker.
3573 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3574 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3575 of the executable has exited (or immediately before the shared library
3576 is unloaded if the procedure is linked in a shared library), in particular
3577 after the Ada run-time environment is shut down.
3579 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3580 because of these specific contexts.
3582 @node Pragma Linker_Section
3583 @unnumberedsec Pragma Linker_Section
3584 @findex Linker_Section
3588 @smallexample @c ada
3589 pragma Linker_Section (
3590 [Entity =>] LOCAL_NAME,
3591 [Section =>] static_string_EXPRESSION);
3595 @var{LOCAL_NAME} must refer to an object that is declared at the library
3596 level. This pragma specifies the name of the linker section for the given
3597 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3598 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3599 section of the executable (assuming the linker doesn't rename the section).
3601 The compiler normally places library-level objects in standard sections
3602 depending on their type: procedures and functions generally go in the
3603 @code{.text} section, initialized variables in the @code{.data} section
3604 and uninitialized variables in the @code{.bss} section.
3606 Other, special sections may exist on given target machines to map special
3607 hardware, for example I/O ports or flash memory. This pragma is a means to
3608 defer the final layout of the executable to the linker, thus fully working
3609 at the symbolic level with the compiler.
3611 Some file formats do not support arbitrary sections so not all target
3612 machines support this pragma. The use of this pragma may cause a program
3613 execution to be erroneous if it is used to place an entity into an
3614 inappropriate section (e.g.@: a modified variable into the @code{.text}
3615 section). See also @code{pragma Persistent_BSS}.
3617 @smallexample @c ada
3618 -- Example of the use of pragma Linker_Section
3622 pragma Volatile (Port_A);
3623 pragma Linker_Section (Port_A, ".bss.port_a");
3626 pragma Volatile (Port_B);
3627 pragma Linker_Section (Port_B, ".bss.port_b");
3631 @node Pragma Long_Float
3632 @unnumberedsec Pragma Long_Float
3638 @smallexample @c ada
3639 pragma Long_Float (FLOAT_FORMAT);
3641 FLOAT_FORMAT ::= D_Float | G_Float
3645 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3646 It allows control over the internal representation chosen for the predefined
3647 type @code{Long_Float} and for floating point type representations with
3648 @code{digits} specified in the range 7 through 15.
3649 For further details on this pragma, see the
3650 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3651 this pragma, the standard runtime libraries must be recompiled.
3653 @node Pragma Machine_Attribute
3654 @unnumberedsec Pragma Machine_Attribute
3655 @findex Machine_Attribute
3659 @smallexample @c ada
3660 pragma Machine_Attribute (
3661 [Entity =>] LOCAL_NAME,
3662 [Attribute_Name =>] static_string_EXPRESSION
3663 [, [Info =>] static_EXPRESSION] );
3667 Machine-dependent attributes can be specified for types and/or
3668 declarations. This pragma is semantically equivalent to
3669 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3670 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3671 in GNU C, where @code{@var{attribute_name}} is recognized by the
3672 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3673 specific macro. A string literal for the optional parameter @var{info}
3674 is transformed into an identifier, which may make this pragma unusable
3675 for some attributes. @xref{Target Attributes,, Defining target-specific
3676 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3677 Internals}, further information.
3680 @unnumberedsec Pragma Main
3686 @smallexample @c ada
3688 (MAIN_OPTION [, MAIN_OPTION]);
3691 [Stack_Size =>] static_integer_EXPRESSION
3692 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3693 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3697 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3698 no effect in GNAT, other than being syntax checked.
3700 @node Pragma Main_Storage
3701 @unnumberedsec Pragma Main_Storage
3703 @findex Main_Storage
3707 @smallexample @c ada
3709 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3711 MAIN_STORAGE_OPTION ::=
3712 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3713 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3717 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3718 no effect in GNAT, other than being syntax checked. Note that the pragma
3719 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3721 @node Pragma No_Body
3722 @unnumberedsec Pragma No_Body
3727 @smallexample @c ada
3732 There are a number of cases in which a package spec does not require a body,
3733 and in fact a body is not permitted. GNAT will not permit the spec to be
3734 compiled if there is a body around. The pragma No_Body allows you to provide
3735 a body file, even in a case where no body is allowed. The body file must
3736 contain only comments and a single No_Body pragma. This is recognized by
3737 the compiler as indicating that no body is logically present.
3739 This is particularly useful during maintenance when a package is modified in
3740 such a way that a body needed before is no longer needed. The provision of a
3741 dummy body with a No_Body pragma ensures that there is no interference from
3742 earlier versions of the package body.
3744 @node Pragma No_Return
3745 @unnumberedsec Pragma No_Return
3750 @smallexample @c ada
3751 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3755 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3756 declarations in the current declarative part. A procedure to which this
3757 pragma is applied may not contain any explicit @code{return} statements.
3758 In addition, if the procedure contains any implicit returns from falling
3759 off the end of a statement sequence, then execution of that implicit
3760 return will cause Program_Error to be raised.
3762 One use of this pragma is to identify procedures whose only purpose is to raise
3763 an exception. Another use of this pragma is to suppress incorrect warnings
3764 about missing returns in functions, where the last statement of a function
3765 statement sequence is a call to such a procedure.
3767 Note that in Ada 2005 mode, this pragma is part of the language, and is
3768 identical in effect to the pragma as implemented in Ada 95 mode.
3770 @node Pragma No_Strict_Aliasing
3771 @unnumberedsec Pragma No_Strict_Aliasing
3772 @findex No_Strict_Aliasing
3776 @smallexample @c ada
3777 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3781 @var{type_LOCAL_NAME} must refer to an access type
3782 declaration in the current declarative part. The effect is to inhibit
3783 strict aliasing optimization for the given type. The form with no
3784 arguments is a configuration pragma which applies to all access types
3785 declared in units to which the pragma applies. For a detailed
3786 description of the strict aliasing optimization, and the situations
3787 in which it must be suppressed, see @ref{Optimization and Strict
3788 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3790 This pragma currently has no effects on access to unconstrained array types.
3792 @node Pragma Normalize_Scalars
3793 @unnumberedsec Pragma Normalize_Scalars
3794 @findex Normalize_Scalars
3798 @smallexample @c ada
3799 pragma Normalize_Scalars;
3803 This is a language defined pragma which is fully implemented in GNAT@. The
3804 effect is to cause all scalar objects that are not otherwise initialized
3805 to be initialized. The initial values are implementation dependent and
3809 @item Standard.Character
3811 Objects whose root type is Standard.Character are initialized to
3812 Character'Last unless the subtype range excludes NUL (in which case
3813 NUL is used). This choice will always generate an invalid value if
3816 @item Standard.Wide_Character
3818 Objects whose root type is Standard.Wide_Character are initialized to
3819 Wide_Character'Last unless the subtype range excludes NUL (in which case
3820 NUL is used). This choice will always generate an invalid value if
3823 @item Standard.Wide_Wide_Character
3825 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3826 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3827 which case NUL is used). This choice will always generate an invalid value if
3832 Objects of an integer type are treated differently depending on whether
3833 negative values are present in the subtype. If no negative values are
3834 present, then all one bits is used as the initial value except in the
3835 special case where zero is excluded from the subtype, in which case
3836 all zero bits are used. This choice will always generate an invalid
3837 value if one exists.
3839 For subtypes with negative values present, the largest negative number
3840 is used, except in the unusual case where this largest negative number
3841 is in the subtype, and the largest positive number is not, in which case
3842 the largest positive value is used. This choice will always generate
3843 an invalid value if one exists.
3845 @item Floating-Point Types
3846 Objects of all floating-point types are initialized to all 1-bits. For
3847 standard IEEE format, this corresponds to a NaN (not a number) which is
3848 indeed an invalid value.
3850 @item Fixed-Point Types
3851 Objects of all fixed-point types are treated as described above for integers,
3852 with the rules applying to the underlying integer value used to represent
3853 the fixed-point value.
3856 Objects of a modular type are initialized to all one bits, except in
3857 the special case where zero is excluded from the subtype, in which
3858 case all zero bits are used. This choice will always generate an
3859 invalid value if one exists.
3861 @item Enumeration types
3862 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3863 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3864 whose Pos value is zero, in which case a code of zero is used. This choice
3865 will always generate an invalid value if one exists.
3869 @node Pragma Obsolescent
3870 @unnumberedsec Pragma Obsolescent
3875 @smallexample @c ada
3878 pragma Obsolescent (
3879 [Message =>] static_string_EXPRESSION
3880 [,[Version =>] Ada_05]]);
3882 pragma Obsolescent (
3884 [,[Message =>] static_string_EXPRESSION
3885 [,[Version =>] Ada_05]] );
3889 This pragma can occur immediately following a declaration of an entity,
3890 including the case of a record component. If no Entity argument is present,
3891 then this declaration is the one to which the pragma applies. If an Entity
3892 parameter is present, it must either match the name of the entity in this
3893 declaration, or alternatively, the pragma can immediately follow an enumeration
3894 type declaration, where the Entity argument names one of the enumeration
3897 This pragma is used to indicate that the named entity
3898 is considered obsolescent and should not be used. Typically this is
3899 used when an API must be modified by eventually removing or modifying
3900 existing subprograms or other entities. The pragma can be used at an
3901 intermediate stage when the entity is still present, but will be
3904 The effect of this pragma is to output a warning message on a reference to
3905 an entity thus marked that the subprogram is obsolescent if the appropriate
3906 warning option in the compiler is activated. If the Message parameter is
3907 present, then a second warning message is given containing this text. In
3908 addition, a reference to the entity is considered to be a violation of pragma
3909 Restrictions (No_Obsolescent_Features).
3911 This pragma can also be used as a program unit pragma for a package,
3912 in which case the entity name is the name of the package, and the
3913 pragma indicates that the entire package is considered
3914 obsolescent. In this case a client @code{with}'ing such a package
3915 violates the restriction, and the @code{with} statement is
3916 flagged with warnings if the warning option is set.
3918 If the Version parameter is present (which must be exactly
3919 the identifier Ada_05, no other argument is allowed), then the
3920 indication of obsolescence applies only when compiling in Ada 2005
3921 mode. This is primarily intended for dealing with the situations
3922 in the predefined library where subprograms or packages
3923 have become defined as obsolescent in Ada 2005
3924 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3926 The following examples show typical uses of this pragma:
3928 @smallexample @c ada
3930 pragma Obsolescent (p, Message => "use pp instead of p");
3935 pragma Obsolescent ("use q2new instead");
3937 type R is new integer;
3940 Message => "use RR in Ada 2005",
3950 type E is (a, bc, 'd', quack);
3951 pragma Obsolescent (Entity => bc)
3952 pragma Obsolescent (Entity => 'd')
3955 (a, b : character) return character;
3956 pragma Obsolescent (Entity => "+");
3961 Note that, as for all pragmas, if you use a pragma argument identifier,
3962 then all subsequent parameters must also use a pragma argument identifier.
3963 So if you specify "Entity =>" for the Entity argument, and a Message
3964 argument is present, it must be preceded by "Message =>".
3966 @node Pragma Optimize_Alignment
3967 @unnumberedsec Pragma Optimize_Alignment
3968 @findex Optimize_Alignment
3969 @cindex Alignment, default settings
3973 @smallexample @c ada
3974 pragma Optimize_Alignment (TIME | SPACE | OFF);
3978 This is a configuration pragma which affects the choice of default alignments
3979 for types where no alignment is explicitly specified. There is a time/space
3980 trade-off in the selection of these values. Large alignments result in more
3981 efficient code, at the expense of larger data space, since sizes have to be
3982 increased to match these alignments. Smaller alignments save space, but the
3983 access code is slower. The normal choice of default alignments (which is what
3984 you get if you do not use this pragma, or if you use an argument of OFF),
3985 tries to balance these two requirements.
3987 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3988 First any packed record is given an alignment of 1. Second, if a size is given
3989 for the type, then the alignment is chosen to avoid increasing this size. For
3992 @smallexample @c ada
4002 In the default mode, this type gets an alignment of 4, so that access to the
4003 Integer field X are efficient. But this means that objects of the type end up
4004 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4005 allowed to be bigger than the size of the type, but it can waste space if for
4006 example fields of type R appear in an enclosing record. If the above type is
4007 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4009 Specifying TIME causes larger default alignments to be chosen in the case of
4010 small types with sizes that are not a power of 2. For example, consider:
4012 @smallexample @c ada
4024 The default alignment for this record is normally 1, but if this type is
4025 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4026 to 4, which wastes space for objects of the type, since they are now 4 bytes
4027 long, but results in more efficient access when the whole record is referenced.
4029 As noted above, this is a configuration pragma, and there is a requirement
4030 that all units in a partition be compiled with a consistent setting of the
4031 optimization setting. This would normally be achieved by use of a configuration
4032 pragma file containing the appropriate setting. The exception to this rule is
4033 that units with an explicit configuration pragma in the same file as the source
4034 unit are excluded from the consistency check, as are all predefined units. The
4035 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4036 pragma appears at the start of the file.
4038 @node Pragma Ordered
4039 @unnumberedsec Pragma Ordered
4041 @findex pragma @code{Ordered}
4045 @smallexample @c ada
4046 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4050 Most enumeration types are from a conceptual point of view unordered.
4051 For example, consider:
4053 @smallexample @c ada
4054 type Color is (Red, Blue, Green, Yellow);
4058 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4059 but really these relations make no sense; the enumeration type merely
4060 specifies a set of possible colors, and the order is unimportant.
4062 For unordered enumeration types, it is generally a good idea if
4063 clients avoid comparisons (other than equality or inequality) and
4064 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4065 other than the unit where the type is declared, its body, and its subunits.)
4066 For example, if code buried in some client says:
4068 @smallexample @c ada
4069 if Current_Color < Yellow then ...
4070 if Current_Color in Blue .. Green then ...
4074 then the client code is relying on the order, which is undesirable.
4075 It makes the code hard to read and creates maintenance difficulties if
4076 entries have to be added to the enumeration type. Instead,
4077 the code in the client should list the possibilities, or an
4078 appropriate subtype should be declared in the unit that declares
4079 the original enumeration type. E.g., the following subtype could
4080 be declared along with the type @code{Color}:
4082 @smallexample @c ada
4083 subtype RBG is Color range Red .. Green;
4087 and then the client could write:
4089 @smallexample @c ada
4090 if Current_Color in RBG then ...
4091 if Current_Color = Blue or Current_Color = Green then ...
4095 However, some enumeration types are legitimately ordered from a conceptual
4096 point of view. For example, if you declare:
4098 @smallexample @c ada
4099 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4103 then the ordering imposed by the language is reasonable, and
4104 clients can depend on it, writing for example:
4106 @smallexample @c ada
4107 if D in Mon .. Fri then ...
4112 The pragma @option{Ordered} is provided to mark enumeration types that
4113 are conceptually ordered, alerting the reader that clients may depend
4114 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4115 rather than one to mark them as unordered, since in our experience,
4116 the great majority of enumeration types are conceptually unordered.
4118 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4119 and @code{Wide_Wide_Character}
4120 are considered to be ordered types, so each is declared with a
4121 pragma @code{Ordered} in package @code{Standard}.
4123 Normally pragma @code{Ordered} serves only as documentation and a guide for
4124 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4125 requests warnings for inappropriate uses (comparisons and explicit
4126 subranges) for unordered types. If this switch is used, then any
4127 enumeration type not marked with pragma @code{Ordered} will be considered
4128 as unordered, and will generate warnings for inappropriate uses.
4130 For additional information please refer to the description of the
4131 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4133 @node Pragma Overflow_Checks
4134 @unnumberedsec Pragma Overflow_Checks
4135 @findex Overflow checks
4136 @findex pragma @code{Overflow_Checks}
4140 @smallexample @c ada
4141 pragma Overflow_Checks
4143 [,[Assertions =>] MODE]);
4145 MODE ::= SUPPRESSED | CHECKED | MINIMIZED | ELIMINATED
4149 This pragma sets the current overflow mode to the given mode. For details
4150 of the meaning of these modes, please refer to the
4151 ``Overflow Check Handling in GNAT'' appendix in the
4152 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4153 the given mode applies to all expressions. If both parameters are present,
4154 the @code{General} mode applies to expressions outside assertions, and
4155 the @code{Eliminated} mode applies to expressions within assertions.
4157 The case of the @code{MODE} parameter is ignored,
4158 so @code{MINIMIZED}, @code{Minimized} and
4159 @code{minimized} all have the same effect.
4161 The @code{Overflow_Checks} pragma has the same scoping and placement
4162 rules as pragma @code{Suppress}, so it can occur either as a
4163 configuration pragma, specifying a default for the whole
4164 program, or in a declarative scope, where it applies to the
4165 remaining declarations and statements in that scope.
4167 The pragma @code{Suppress (Overflow_Check)} sets mode
4169 @smallexample @c ada
4170 General => Suppressed
4174 suppressing all overflow checking within and outside
4177 The pragam @code{Unsuppress (Overflow_Check)} sets mode
4179 @smallexample @c ada
4184 which causes overflow checking of all intermediate overflows.
4185 This applies both inside and outside assertions.
4188 @node Pragma Passive
4189 @unnumberedsec Pragma Passive
4194 @smallexample @c ada
4195 pragma Passive [(Semaphore | No)];
4199 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
4200 compatibility with DEC Ada 83 implementations, where it is used within a
4201 task definition to request that a task be made passive. If the argument
4202 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4203 treats the pragma as an assertion that the containing task is passive
4204 and that optimization of context switch with this task is permitted and
4205 desired. If the argument @code{No} is present, the task must not be
4206 optimized. GNAT does not attempt to optimize any tasks in this manner
4207 (since protected objects are available in place of passive tasks).
4209 @node Pragma Persistent_BSS
4210 @unnumberedsec Pragma Persistent_BSS
4211 @findex Persistent_BSS
4215 @smallexample @c ada
4216 pragma Persistent_BSS [(LOCAL_NAME)]
4220 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4221 section. On some targets the linker and loader provide for special
4222 treatment of this section, allowing a program to be reloaded without
4223 affecting the contents of this data (hence the name persistent).
4225 There are two forms of usage. If an argument is given, it must be the
4226 local name of a library level object, with no explicit initialization
4227 and whose type is potentially persistent. If no argument is given, then
4228 the pragma is a configuration pragma, and applies to all library level
4229 objects with no explicit initialization of potentially persistent types.
4231 A potentially persistent type is a scalar type, or a non-tagged,
4232 non-discriminated record, all of whose components have no explicit
4233 initialization and are themselves of a potentially persistent type,
4234 or an array, all of whose constraints are static, and whose component
4235 type is potentially persistent.
4237 If this pragma is used on a target where this feature is not supported,
4238 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4240 @node Pragma Polling
4241 @unnumberedsec Pragma Polling
4246 @smallexample @c ada
4247 pragma Polling (ON | OFF);
4251 This pragma controls the generation of polling code. This is normally off.
4252 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4253 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
4254 runtime library, and can be found in file @file{a-excpol.adb}.
4256 Pragma @code{Polling} can appear as a configuration pragma (for example it
4257 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4258 can be used in the statement or declaration sequence to control polling
4261 A call to the polling routine is generated at the start of every loop and
4262 at the start of every subprogram call. This guarantees that the @code{Poll}
4263 routine is called frequently, and places an upper bound (determined by
4264 the complexity of the code) on the period between two @code{Poll} calls.
4266 The primary purpose of the polling interface is to enable asynchronous
4267 aborts on targets that cannot otherwise support it (for example Windows
4268 NT), but it may be used for any other purpose requiring periodic polling.
4269 The standard version is null, and can be replaced by a user program. This
4270 will require re-compilation of the @code{Ada.Exceptions} package that can
4271 be found in files @file{a-except.ads} and @file{a-except.adb}.
4273 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
4274 distribution) is used to enable the asynchronous abort capability on
4275 targets that do not normally support the capability. The version of
4276 @code{Poll} in this file makes a call to the appropriate runtime routine
4277 to test for an abort condition.
4279 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4280 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4283 @node Pragma Postcondition
4284 @unnumberedsec Pragma Postcondition
4285 @cindex Postconditions
4286 @cindex Checks, postconditions
4287 @findex Postconditions
4291 @smallexample @c ada
4292 pragma Postcondition (
4293 [Check =>] Boolean_Expression
4294 [,[Message =>] String_Expression]);
4298 The @code{Postcondition} pragma allows specification of automatic
4299 postcondition checks for subprograms. These checks are similar to
4300 assertions, but are automatically inserted just prior to the return
4301 statements of the subprogram with which they are associated (including
4302 implicit returns at the end of procedure bodies and associated
4303 exception handlers).
4305 In addition, the boolean expression which is the condition which
4306 must be true may contain references to function'Result in the case
4307 of a function to refer to the returned value.
4309 @code{Postcondition} pragmas may appear either immediately following the
4310 (separate) declaration of a subprogram, or at the start of the
4311 declarations of a subprogram body. Only other pragmas may intervene
4312 (that is appear between the subprogram declaration and its
4313 postconditions, or appear before the postcondition in the
4314 declaration sequence in a subprogram body). In the case of a
4315 postcondition appearing after a subprogram declaration, the
4316 formal arguments of the subprogram are visible, and can be
4317 referenced in the postcondition expressions.
4319 The postconditions are collected and automatically tested just
4320 before any return (implicit or explicit) in the subprogram body.
4321 A postcondition is only recognized if postconditions are active
4322 at the time the pragma is encountered. The compiler switch @option{gnata}
4323 turns on all postconditions by default, and pragma @code{Check_Policy}
4324 with an identifier of @code{Postcondition} can also be used to
4325 control whether postconditions are active.
4327 The general approach is that postconditions are placed in the spec
4328 if they represent functional aspects which make sense to the client.
4329 For example we might have:
4331 @smallexample @c ada
4332 function Direction return Integer;
4333 pragma Postcondition
4334 (Direction'Result = +1
4336 Direction'Result = -1);
4340 which serves to document that the result must be +1 or -1, and
4341 will test that this is the case at run time if postcondition
4344 Postconditions within the subprogram body can be used to
4345 check that some internal aspect of the implementation,
4346 not visible to the client, is operating as expected.
4347 For instance if a square root routine keeps an internal
4348 counter of the number of times it is called, then we
4349 might have the following postcondition:
4351 @smallexample @c ada
4352 Sqrt_Calls : Natural := 0;
4354 function Sqrt (Arg : Float) return Float is
4355 pragma Postcondition
4356 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4362 As this example, shows, the use of the @code{Old} attribute
4363 is often useful in postconditions to refer to the state on
4364 entry to the subprogram.
4366 Note that postconditions are only checked on normal returns
4367 from the subprogram. If an abnormal return results from
4368 raising an exception, then the postconditions are not checked.
4370 If a postcondition fails, then the exception
4371 @code{System.Assertions.Assert_Failure} is raised. If
4372 a message argument was supplied, then the given string
4373 will be used as the exception message. If no message
4374 argument was supplied, then the default message has
4375 the form "Postcondition failed at file:line". The
4376 exception is raised in the context of the subprogram
4377 body, so it is possible to catch postcondition failures
4378 within the subprogram body itself.
4380 Within a package spec, normal visibility rules
4381 in Ada would prevent forward references within a
4382 postcondition pragma to functions defined later in
4383 the same package. This would introduce undesirable
4384 ordering constraints. To avoid this problem, all
4385 postcondition pragmas are analyzed at the end of
4386 the package spec, allowing forward references.
4388 The following example shows that this even allows
4389 mutually recursive postconditions as in:
4391 @smallexample @c ada
4392 package Parity_Functions is
4393 function Odd (X : Natural) return Boolean;
4394 pragma Postcondition
4398 (x /= 0 and then Even (X - 1))));
4400 function Even (X : Natural) return Boolean;
4401 pragma Postcondition
4405 (x /= 1 and then Odd (X - 1))));
4407 end Parity_Functions;
4411 There are no restrictions on the complexity or form of
4412 conditions used within @code{Postcondition} pragmas.
4413 The following example shows that it is even possible
4414 to verify performance behavior.
4416 @smallexample @c ada
4419 Performance : constant Float;
4420 -- Performance constant set by implementation
4421 -- to match target architecture behavior.
4423 procedure Treesort (Arg : String);
4424 -- Sorts characters of argument using N*logN sort
4425 pragma Postcondition
4426 (Float (Clock - Clock'Old) <=
4427 Float (Arg'Length) *
4428 log (Float (Arg'Length)) *
4434 Note: postcondition pragmas associated with subprograms that are
4435 marked as Inline_Always, or those marked as Inline with front-end
4436 inlining (-gnatN option set) are accepted and legality-checked
4437 by the compiler, but are ignored at run-time even if postcondition
4438 checking is enabled.
4440 @node Pragma Precondition
4441 @unnumberedsec Pragma Precondition
4442 @cindex Preconditions
4443 @cindex Checks, preconditions
4444 @findex Preconditions
4448 @smallexample @c ada
4449 pragma Precondition (
4450 [Check =>] Boolean_Expression
4451 [,[Message =>] String_Expression]);
4455 The @code{Precondition} pragma is similar to @code{Postcondition}
4456 except that the corresponding checks take place immediately upon
4457 entry to the subprogram, and if a precondition fails, the exception
4458 is raised in the context of the caller, and the attribute 'Result
4459 cannot be used within the precondition expression.
4461 Otherwise, the placement and visibility rules are identical to those
4462 described for postconditions. The following is an example of use
4463 within a package spec:
4465 @smallexample @c ada
4466 package Math_Functions is
4468 function Sqrt (Arg : Float) return Float;
4469 pragma Precondition (Arg >= 0.0)
4475 @code{Precondition} pragmas may appear either immediately following the
4476 (separate) declaration of a subprogram, or at the start of the
4477 declarations of a subprogram body. Only other pragmas may intervene
4478 (that is appear between the subprogram declaration and its
4479 postconditions, or appear before the postcondition in the
4480 declaration sequence in a subprogram body).
4482 Note: postcondition pragmas associated with subprograms that are
4483 marked as Inline_Always, or those marked as Inline with front-end
4484 inlining (-gnatN option set) are accepted and legality-checked
4485 by the compiler, but are ignored at run-time even if postcondition
4486 checking is enabled.
4488 @node Pragma Profile (Ravenscar)
4489 @unnumberedsec Pragma Profile (Ravenscar)
4494 @smallexample @c ada
4495 pragma Profile (Ravenscar);
4499 A configuration pragma that establishes the following set of configuration
4503 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4504 [RM D.2.2] Tasks are dispatched following a preemptive
4505 priority-ordered scheduling policy.
4507 @item Locking_Policy (Ceiling_Locking)
4508 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4509 the ceiling priority of the corresponding protected object.
4511 @c @item Detect_Blocking
4512 @c This pragma forces the detection of potentially blocking operations within a
4513 @c protected operation, and to raise Program_Error if that happens.
4517 plus the following set of restrictions:
4520 @item Max_Entry_Queue_Length => 1
4521 No task can be queued on a protected entry.
4522 @item Max_Protected_Entries => 1
4523 @item Max_Task_Entries => 0
4524 No rendezvous statements are allowed.
4525 @item No_Abort_Statements
4526 @item No_Dynamic_Attachment
4527 @item No_Dynamic_Priorities
4528 @item No_Implicit_Heap_Allocations
4529 @item No_Local_Protected_Objects
4530 @item No_Local_Timing_Events
4531 @item No_Protected_Type_Allocators
4532 @item No_Relative_Delay
4533 @item No_Requeue_Statements
4534 @item No_Select_Statements
4535 @item No_Specific_Termination_Handlers
4536 @item No_Task_Allocators
4537 @item No_Task_Hierarchy
4538 @item No_Task_Termination
4539 @item Simple_Barriers
4543 The Ravenscar profile also includes the following restrictions that specify
4544 that there are no semantic dependences on the corresponding predefined
4548 @item No_Dependence => Ada.Asynchronous_Task_Control
4549 @item No_Dependence => Ada.Calendar
4550 @item No_Dependence => Ada.Execution_Time.Group_Budget
4551 @item No_Dependence => Ada.Execution_Time.Timers
4552 @item No_Dependence => Ada.Task_Attributes
4553 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4558 This set of configuration pragmas and restrictions correspond to the
4559 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4560 published by the @cite{International Real-Time Ada Workshop}, 1997,
4561 and whose most recent description is available at
4562 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4564 The original definition of the profile was revised at subsequent IRTAW
4565 meetings. It has been included in the ISO
4566 @cite{Guide for the Use of the Ada Programming Language in High
4567 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4568 the next revision of the standard. The formal definition given by
4569 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4570 AI-305) available at
4571 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4572 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4574 The above set is a superset of the restrictions provided by pragma
4575 @code{Profile (Restricted)}, it includes six additional restrictions
4576 (@code{Simple_Barriers}, @code{No_Select_Statements},
4577 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4578 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4579 that pragma @code{Profile (Ravenscar)}, like the pragma
4580 @code{Profile (Restricted)},
4581 automatically causes the use of a simplified,
4582 more efficient version of the tasking run-time system.
4584 @node Pragma Profile (Restricted)
4585 @unnumberedsec Pragma Profile (Restricted)
4586 @findex Restricted Run Time
4590 @smallexample @c ada
4591 pragma Profile (Restricted);
4595 A configuration pragma that establishes the following set of restrictions:
4598 @item No_Abort_Statements
4599 @item No_Entry_Queue
4600 @item No_Task_Hierarchy
4601 @item No_Task_Allocators
4602 @item No_Dynamic_Priorities
4603 @item No_Terminate_Alternatives
4604 @item No_Dynamic_Attachment
4605 @item No_Protected_Type_Allocators
4606 @item No_Local_Protected_Objects
4607 @item No_Requeue_Statements
4608 @item No_Task_Attributes_Package
4609 @item Max_Asynchronous_Select_Nesting = 0
4610 @item Max_Task_Entries = 0
4611 @item Max_Protected_Entries = 1
4612 @item Max_Select_Alternatives = 0
4616 This set of restrictions causes the automatic selection of a simplified
4617 version of the run time that provides improved performance for the
4618 limited set of tasking functionality permitted by this set of restrictions.
4620 @node Pragma Psect_Object
4621 @unnumberedsec Pragma Psect_Object
4622 @findex Psect_Object
4626 @smallexample @c ada
4627 pragma Psect_Object (
4628 [Internal =>] LOCAL_NAME,
4629 [, [External =>] EXTERNAL_SYMBOL]
4630 [, [Size =>] EXTERNAL_SYMBOL]);
4634 | static_string_EXPRESSION
4638 This pragma is identical in effect to pragma @code{Common_Object}.
4640 @node Pragma Pure_Function
4641 @unnumberedsec Pragma Pure_Function
4642 @findex Pure_Function
4646 @smallexample @c ada
4647 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4651 This pragma appears in the same declarative part as a function
4652 declaration (or a set of function declarations if more than one
4653 overloaded declaration exists, in which case the pragma applies
4654 to all entities). It specifies that the function @code{Entity} is
4655 to be considered pure for the purposes of code generation. This means
4656 that the compiler can assume that there are no side effects, and
4657 in particular that two calls with identical arguments produce the
4658 same result. It also means that the function can be used in an
4661 Note that, quite deliberately, there are no static checks to try
4662 to ensure that this promise is met, so @code{Pure_Function} can be used
4663 with functions that are conceptually pure, even if they do modify
4664 global variables. For example, a square root function that is
4665 instrumented to count the number of times it is called is still
4666 conceptually pure, and can still be optimized, even though it
4667 modifies a global variable (the count). Memo functions are another
4668 example (where a table of previous calls is kept and consulted to
4669 avoid re-computation).
4671 Note also that the normal rules excluding optimization of subprograms
4672 in pure units (when parameter types are descended from System.Address,
4673 or when the full view of a parameter type is limited), do not apply
4674 for the Pure_Function case. If you explicitly specify Pure_Function,
4675 the compiler may optimize away calls with identical arguments, and
4676 if that results in unexpected behavior, the proper action is not to
4677 use the pragma for subprograms that are not (conceptually) pure.
4680 Note: Most functions in a @code{Pure} package are automatically pure, and
4681 there is no need to use pragma @code{Pure_Function} for such functions. One
4682 exception is any function that has at least one formal of type
4683 @code{System.Address} or a type derived from it. Such functions are not
4684 considered pure by default, since the compiler assumes that the
4685 @code{Address} parameter may be functioning as a pointer and that the
4686 referenced data may change even if the address value does not.
4687 Similarly, imported functions are not considered to be pure by default,
4688 since there is no way of checking that they are in fact pure. The use
4689 of pragma @code{Pure_Function} for such a function will override these default
4690 assumption, and cause the compiler to treat a designated subprogram as pure
4693 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4694 applies to the underlying renamed function. This can be used to
4695 disambiguate cases of overloading where some but not all functions
4696 in a set of overloaded functions are to be designated as pure.
4698 If pragma @code{Pure_Function} is applied to a library level function, the
4699 function is also considered pure from an optimization point of view, but the
4700 unit is not a Pure unit in the categorization sense. So for example, a function
4701 thus marked is free to @code{with} non-pure units.
4703 @node Pragma Remote_Access_Type
4704 @unnumberedsec Pragma Remote_Access_Type
4705 @findex Remote_Access_Type
4709 @smallexample @c ada
4710 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
4714 This pragma appears in the formal part of a generic declaration.
4715 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
4716 the use of a remote access to class-wide type as actual for a formal
4719 When this pragma applies to a formal access type @code{Entity}, that
4720 type is treated as a remote access to class-wide type in the generic.
4721 It must be a formal general access type, and its designated type must
4722 be the class-wide type of a formal tagged limited private type from the
4723 same generic declaration.
4725 In the generic unit, the formal type is subject to all restrictions
4726 pertaining to remote access to class-wide types. At instantiation, the
4727 actual type must be a remote access to class-wide type.
4729 @node Pragma Restriction_Warnings
4730 @unnumberedsec Pragma Restriction_Warnings
4731 @findex Restriction_Warnings
4735 @smallexample @c ada
4736 pragma Restriction_Warnings
4737 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4741 This pragma allows a series of restriction identifiers to be
4742 specified (the list of allowed identifiers is the same as for
4743 pragma @code{Restrictions}). For each of these identifiers
4744 the compiler checks for violations of the restriction, but
4745 generates a warning message rather than an error message
4746 if the restriction is violated.
4749 @unnumberedsec Pragma Shared
4753 This pragma is provided for compatibility with Ada 83. The syntax and
4754 semantics are identical to pragma Atomic.
4756 @node Pragma Short_Circuit_And_Or
4757 @unnumberedsec Pragma Short_Circuit_And_Or
4758 @findex Short_Circuit_And_Or
4761 This configuration pragma causes any occurrence of the AND operator applied to
4762 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4763 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4764 may be useful in the context of certification protocols requiring the use of
4765 short-circuited logical operators. If this configuration pragma occurs locally
4766 within the file being compiled, it applies only to the file being compiled.
4767 There is no requirement that all units in a partition use this option.
4769 @node Pragma Short_Descriptors
4770 @unnumberedsec Pragma Short_Descriptors
4771 @findex Short_Descriptors
4775 @smallexample @c ada
4776 pragma Short_Descriptors
4780 In VMS versions of the compiler, this configuration pragma causes all
4781 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4782 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4783 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4786 @node Pragma Simple_Storage_Pool_Type
4787 @unnumberedsec Pragma Simple_Storage_Pool_Type
4788 @findex Simple_Storage_Pool_Type
4789 @cindex Storage pool, simple
4790 @cindex Simple storage pool
4794 @smallexample @c ada
4795 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
4799 A type can be established as a ``simple storage pool type'' by applying
4800 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
4801 A type named in the pragma must be a library-level immutably limited record
4802 type or limited tagged type declared immediately within a package declaration.
4803 The type can also be a limited private type whose full type is allowed as
4804 a simple storage pool type.
4806 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
4807 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
4808 are subtype conformant with the following subprogram declarations:
4810 @smallexample @c ada
4813 Storage_Address : out System.Address;
4814 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4815 Alignment : System.Storage_Elements.Storage_Count);
4817 procedure Deallocate
4819 Storage_Address : System.Address;
4820 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4821 Alignment : System.Storage_Elements.Storage_Count);
4823 function Storage_Size (Pool : SSP)
4824 return System.Storage_Elements.Storage_Count;
4828 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
4829 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
4830 applying an unchecked deallocation has no effect other than to set its actual
4831 parameter to null. If @code{Storage_Size} is not declared, then the
4832 @code{Storage_Size} attribute applied to an access type associated with
4833 a pool object of type SSP returns zero. Additional operations can be declared
4834 for a simple storage pool type (such as for supporting a mark/release
4835 storage-management discipline).
4837 An object of a simple storage pool type can be associated with an access
4838 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
4840 @smallexample @c ada
4842 My_Pool : My_Simple_Storage_Pool_Type;
4844 type Acc is access My_Data_Type;
4846 for Acc'Simple_Storage_Pool use My_Pool;
4851 See attribute @code{Simple_Storage_Pool} for further details.
4853 @node Pragma Source_File_Name
4854 @unnumberedsec Pragma Source_File_Name
4855 @findex Source_File_Name
4859 @smallexample @c ada
4860 pragma Source_File_Name (
4861 [Unit_Name =>] unit_NAME,
4862 Spec_File_Name => STRING_LITERAL,
4863 [Index => INTEGER_LITERAL]);
4865 pragma Source_File_Name (
4866 [Unit_Name =>] unit_NAME,
4867 Body_File_Name => STRING_LITERAL,
4868 [Index => INTEGER_LITERAL]);
4872 Use this to override the normal naming convention. It is a configuration
4873 pragma, and so has the usual applicability of configuration pragmas
4874 (i.e.@: it applies to either an entire partition, or to all units in a
4875 compilation, or to a single unit, depending on how it is used.
4876 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4877 the second argument is required, and indicates whether this is the file
4878 name for the spec or for the body.
4880 The optional Index argument should be used when a file contains multiple
4881 units, and when you do not want to use @code{gnatchop} to separate then
4882 into multiple files (which is the recommended procedure to limit the
4883 number of recompilations that are needed when some sources change).
4884 For instance, if the source file @file{source.ada} contains
4886 @smallexample @c ada
4898 you could use the following configuration pragmas:
4900 @smallexample @c ada
4901 pragma Source_File_Name
4902 (B, Spec_File_Name => "source.ada", Index => 1);
4903 pragma Source_File_Name
4904 (A, Body_File_Name => "source.ada", Index => 2);
4907 Note that the @code{gnatname} utility can also be used to generate those
4908 configuration pragmas.
4910 Another form of the @code{Source_File_Name} pragma allows
4911 the specification of patterns defining alternative file naming schemes
4912 to apply to all files.
4914 @smallexample @c ada
4915 pragma Source_File_Name
4916 ( [Spec_File_Name =>] STRING_LITERAL
4917 [,[Casing =>] CASING_SPEC]
4918 [,[Dot_Replacement =>] STRING_LITERAL]);
4920 pragma Source_File_Name
4921 ( [Body_File_Name =>] STRING_LITERAL
4922 [,[Casing =>] CASING_SPEC]
4923 [,[Dot_Replacement =>] STRING_LITERAL]);
4925 pragma Source_File_Name
4926 ( [Subunit_File_Name =>] STRING_LITERAL
4927 [,[Casing =>] CASING_SPEC]
4928 [,[Dot_Replacement =>] STRING_LITERAL]);
4930 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4934 The first argument is a pattern that contains a single asterisk indicating
4935 the point at which the unit name is to be inserted in the pattern string
4936 to form the file name. The second argument is optional. If present it
4937 specifies the casing of the unit name in the resulting file name string.
4938 The default is lower case. Finally the third argument allows for systematic
4939 replacement of any dots in the unit name by the specified string literal.
4941 Note that Source_File_Name pragmas should not be used if you are using
4942 project files. The reason for this rule is that the project manager is not
4943 aware of these pragmas, and so other tools that use the projet file would not
4944 be aware of the intended naming conventions. If you are using project files,
4945 file naming is controlled by Source_File_Name_Project pragmas, which are
4946 usually supplied automatically by the project manager. A pragma
4947 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
4949 For more details on the use of the @code{Source_File_Name} pragma,
4950 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4951 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4954 @node Pragma Source_File_Name_Project
4955 @unnumberedsec Pragma Source_File_Name_Project
4956 @findex Source_File_Name_Project
4959 This pragma has the same syntax and semantics as pragma Source_File_Name.
4960 It is only allowed as a stand alone configuration pragma.
4961 It cannot appear after a @ref{Pragma Source_File_Name}, and
4962 most importantly, once pragma Source_File_Name_Project appears,
4963 no further Source_File_Name pragmas are allowed.
4965 The intention is that Source_File_Name_Project pragmas are always
4966 generated by the Project Manager in a manner consistent with the naming
4967 specified in a project file, and when naming is controlled in this manner,
4968 it is not permissible to attempt to modify this naming scheme using
4969 Source_File_Name or Source_File_Name_Project pragmas (which would not be
4970 known to the project manager).
4972 @node Pragma Source_Reference
4973 @unnumberedsec Pragma Source_Reference
4974 @findex Source_Reference
4978 @smallexample @c ada
4979 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4983 This pragma must appear as the first line of a source file.
4984 @var{integer_literal} is the logical line number of the line following
4985 the pragma line (for use in error messages and debugging
4986 information). @var{string_literal} is a static string constant that
4987 specifies the file name to be used in error messages and debugging
4988 information. This is most notably used for the output of @code{gnatchop}
4989 with the @option{-r} switch, to make sure that the original unchopped
4990 source file is the one referred to.
4992 The second argument must be a string literal, it cannot be a static
4993 string expression other than a string literal. This is because its value
4994 is needed for error messages issued by all phases of the compiler.
4996 @node Pragma Static_Elaboration_Desired
4997 @unnumberedsec Pragma Static_Elaboration_Desired
4998 @findex Static_Elaboration_Desired
5002 @smallexample @c ada
5003 pragma Static_Elaboration_Desired;
5007 This pragma is used to indicate that the compiler should attempt to initialize
5008 statically the objects declared in the library unit to which the pragma applies,
5009 when these objects are initialized (explicitly or implicitly) by an aggregate.
5010 In the absence of this pragma, aggregates in object declarations are expanded
5011 into assignments and loops, even when the aggregate components are static
5012 constants. When the aggregate is present the compiler builds a static expression
5013 that requires no run-time code, so that the initialized object can be placed in
5014 read-only data space. If the components are not static, or the aggregate has
5015 more that 100 components, the compiler emits a warning that the pragma cannot
5016 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
5017 construction of larger aggregates with static components that include an others
5020 @node Pragma Stream_Convert
5021 @unnumberedsec Pragma Stream_Convert
5022 @findex Stream_Convert
5026 @smallexample @c ada
5027 pragma Stream_Convert (
5028 [Entity =>] type_LOCAL_NAME,
5029 [Read =>] function_NAME,
5030 [Write =>] function_NAME);
5034 This pragma provides an efficient way of providing stream functions for
5035 types defined in packages. Not only is it simpler to use than declaring
5036 the necessary functions with attribute representation clauses, but more
5037 significantly, it allows the declaration to made in such a way that the
5038 stream packages are not loaded unless they are needed. The use of
5039 the Stream_Convert pragma adds no overhead at all, unless the stream
5040 attributes are actually used on the designated type.
5042 The first argument specifies the type for which stream functions are
5043 provided. The second parameter provides a function used to read values
5044 of this type. It must name a function whose argument type may be any
5045 subtype, and whose returned type must be the type given as the first
5046 argument to the pragma.
5048 The meaning of the @var{Read}
5049 parameter is that if a stream attribute directly
5050 or indirectly specifies reading of the type given as the first parameter,
5051 then a value of the type given as the argument to the Read function is
5052 read from the stream, and then the Read function is used to convert this
5053 to the required target type.
5055 Similarly the @var{Write} parameter specifies how to treat write attributes
5056 that directly or indirectly apply to the type given as the first parameter.
5057 It must have an input parameter of the type specified by the first parameter,
5058 and the return type must be the same as the input type of the Read function.
5059 The effect is to first call the Write function to convert to the given stream
5060 type, and then write the result type to the stream.
5062 The Read and Write functions must not be overloaded subprograms. If necessary
5063 renamings can be supplied to meet this requirement.
5064 The usage of this attribute is best illustrated by a simple example, taken
5065 from the GNAT implementation of package Ada.Strings.Unbounded:
5067 @smallexample @c ada
5068 function To_Unbounded (S : String)
5069 return Unbounded_String
5070 renames To_Unbounded_String;
5072 pragma Stream_Convert
5073 (Unbounded_String, To_Unbounded, To_String);
5077 The specifications of the referenced functions, as given in the Ada
5078 Reference Manual are:
5080 @smallexample @c ada
5081 function To_Unbounded_String (Source : String)
5082 return Unbounded_String;
5084 function To_String (Source : Unbounded_String)
5089 The effect is that if the value of an unbounded string is written to a stream,
5090 then the representation of the item in the stream is in the same format that
5091 would be used for @code{Standard.String'Output}, and this same representation
5092 is expected when a value of this type is read from the stream. Note that the
5093 value written always includes the bounds, even for Unbounded_String'Write,
5094 since Unbounded_String is not an array type.
5096 @node Pragma Style_Checks
5097 @unnumberedsec Pragma Style_Checks
5098 @findex Style_Checks
5102 @smallexample @c ada
5103 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
5104 On | Off [, LOCAL_NAME]);
5108 This pragma is used in conjunction with compiler switches to control the
5109 built in style checking provided by GNAT@. The compiler switches, if set,
5110 provide an initial setting for the switches, and this pragma may be used
5111 to modify these settings, or the settings may be provided entirely by
5112 the use of the pragma. This pragma can be used anywhere that a pragma
5113 is legal, including use as a configuration pragma (including use in
5114 the @file{gnat.adc} file).
5116 The form with a string literal specifies which style options are to be
5117 activated. These are additive, so they apply in addition to any previously
5118 set style check options. The codes for the options are the same as those
5119 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
5120 For example the following two methods can be used to enable
5125 @smallexample @c ada
5126 pragma Style_Checks ("l");
5131 gcc -c -gnatyl @dots{}
5136 The form ALL_CHECKS activates all standard checks (its use is equivalent
5137 to the use of the @code{gnaty} switch with no options. @xref{Top,
5138 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
5139 @value{EDITION} User's Guide}, for details.)
5141 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
5142 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
5143 options (i.e. equivalent to -gnatyg).
5145 The forms with @code{Off} and @code{On}
5146 can be used to temporarily disable style checks
5147 as shown in the following example:
5149 @smallexample @c ada
5153 pragma Style_Checks ("k"); -- requires keywords in lower case
5154 pragma Style_Checks (Off); -- turn off style checks
5155 NULL; -- this will not generate an error message
5156 pragma Style_Checks (On); -- turn style checks back on
5157 NULL; -- this will generate an error message
5161 Finally the two argument form is allowed only if the first argument is
5162 @code{On} or @code{Off}. The effect is to turn of semantic style checks
5163 for the specified entity, as shown in the following example:
5165 @smallexample @c ada
5169 pragma Style_Checks ("r"); -- require consistency of identifier casing
5171 Rf1 : Integer := ARG; -- incorrect, wrong case
5172 pragma Style_Checks (Off, Arg);
5173 Rf2 : Integer := ARG; -- OK, no error
5176 @node Pragma Subtitle
5177 @unnumberedsec Pragma Subtitle
5182 @smallexample @c ada
5183 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5187 This pragma is recognized for compatibility with other Ada compilers
5188 but is ignored by GNAT@.
5190 @node Pragma Suppress
5191 @unnumberedsec Pragma Suppress
5196 @smallexample @c ada
5197 pragma Suppress (Identifier [, [On =>] Name]);
5201 This is a standard pragma, and supports all the check names required in
5202 the RM. It is included here because GNAT recognizes one additional check
5203 name: @code{Alignment_Check} which can be used to suppress alignment checks
5204 on addresses used in address clauses. Such checks can also be suppressed
5205 by suppressing range checks, but the specific use of @code{Alignment_Check}
5206 allows suppression of alignment checks without suppressing other range checks.
5208 Note that pragma Suppress gives the compiler permission to omit
5209 checks, but does not require the compiler to omit checks. The compiler
5210 will generate checks if they are essentially free, even when they are
5211 suppressed. In particular, if the compiler can prove that a certain
5212 check will necessarily fail, it will generate code to do an
5213 unconditional ``raise'', even if checks are suppressed. The compiler
5216 Of course, run-time checks are omitted whenever the compiler can prove
5217 that they will not fail, whether or not checks are suppressed.
5219 @node Pragma Suppress_All
5220 @unnumberedsec Pragma Suppress_All
5221 @findex Suppress_All
5225 @smallexample @c ada
5226 pragma Suppress_All;
5230 This pragma can appear anywhere within a unit.
5231 The effect is to apply @code{Suppress (All_Checks)} to the unit
5232 in which it appears. This pragma is implemented for compatibility with DEC
5233 Ada 83 usage where it appears at the end of a unit, and for compatibility
5234 with Rational Ada, where it appears as a program unit pragma.
5235 The use of the standard Ada pragma @code{Suppress (All_Checks)}
5236 as a normal configuration pragma is the preferred usage in GNAT@.
5238 @node Pragma Suppress_Exception_Locations
5239 @unnumberedsec Pragma Suppress_Exception_Locations
5240 @findex Suppress_Exception_Locations
5244 @smallexample @c ada
5245 pragma Suppress_Exception_Locations;
5249 In normal mode, a raise statement for an exception by default generates
5250 an exception message giving the file name and line number for the location
5251 of the raise. This is useful for debugging and logging purposes, but this
5252 entails extra space for the strings for the messages. The configuration
5253 pragma @code{Suppress_Exception_Locations} can be used to suppress the
5254 generation of these strings, with the result that space is saved, but the
5255 exception message for such raises is null. This configuration pragma may
5256 appear in a global configuration pragma file, or in a specific unit as
5257 usual. It is not required that this pragma be used consistently within
5258 a partition, so it is fine to have some units within a partition compiled
5259 with this pragma and others compiled in normal mode without it.
5261 @node Pragma Suppress_Initialization
5262 @unnumberedsec Pragma Suppress_Initialization
5263 @findex Suppress_Initialization
5264 @cindex Suppressing initialization
5265 @cindex Initialization, suppression of
5269 @smallexample @c ada
5270 pragma Suppress_Initialization ([Entity =>] subtype_Name);
5274 Here subtype_Name is the name introduced by a type declaration
5275 or subtype declaration.
5276 This pragma suppresses any implicit or explicit initialization
5277 for all variables of the given type or subtype,
5278 including initialization resulting from the use of pragmas
5279 Normalize_Scalars or Initialize_Scalars.
5281 This is considered a representation item, so it cannot be given after
5282 the type is frozen. It applies to all subsequent object declarations,
5283 and also any allocator that creates objects of the type.
5285 If the pragma is given for the first subtype, then it is considered
5286 to apply to the base type and all its subtypes. If the pragma is given
5287 for other than a first subtype, then it applies only to the given subtype.
5288 The pragma may not be given after the type is frozen.
5290 @node Pragma Task_Info
5291 @unnumberedsec Pragma Task_Info
5296 @smallexample @c ada
5297 pragma Task_Info (EXPRESSION);
5301 This pragma appears within a task definition (like pragma
5302 @code{Priority}) and applies to the task in which it appears. The
5303 argument must be of type @code{System.Task_Info.Task_Info_Type}.
5304 The @code{Task_Info} pragma provides system dependent control over
5305 aspects of tasking implementation, for example, the ability to map
5306 tasks to specific processors. For details on the facilities available
5307 for the version of GNAT that you are using, see the documentation
5308 in the spec of package System.Task_Info in the runtime
5311 @node Pragma Task_Name
5312 @unnumberedsec Pragma Task_Name
5317 @smallexample @c ada
5318 pragma Task_Name (string_EXPRESSION);
5322 This pragma appears within a task definition (like pragma
5323 @code{Priority}) and applies to the task in which it appears. The
5324 argument must be of type String, and provides a name to be used for
5325 the task instance when the task is created. Note that this expression
5326 is not required to be static, and in particular, it can contain
5327 references to task discriminants. This facility can be used to
5328 provide different names for different tasks as they are created,
5329 as illustrated in the example below.
5331 The task name is recorded internally in the run-time structures
5332 and is accessible to tools like the debugger. In addition the
5333 routine @code{Ada.Task_Identification.Image} will return this
5334 string, with a unique task address appended.
5336 @smallexample @c ada
5337 -- Example of the use of pragma Task_Name
5339 with Ada.Task_Identification;
5340 use Ada.Task_Identification;
5341 with Text_IO; use Text_IO;
5344 type Astring is access String;
5346 task type Task_Typ (Name : access String) is
5347 pragma Task_Name (Name.all);
5350 task body Task_Typ is
5351 Nam : constant String := Image (Current_Task);
5353 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5356 type Ptr_Task is access Task_Typ;
5357 Task_Var : Ptr_Task;
5361 new Task_Typ (new String'("This is task 1"));
5363 new Task_Typ (new String'("This is task 2"));
5367 @node Pragma Task_Storage
5368 @unnumberedsec Pragma Task_Storage
5369 @findex Task_Storage
5372 @smallexample @c ada
5373 pragma Task_Storage (
5374 [Task_Type =>] LOCAL_NAME,
5375 [Top_Guard =>] static_integer_EXPRESSION);
5379 This pragma specifies the length of the guard area for tasks. The guard
5380 area is an additional storage area allocated to a task. A value of zero
5381 means that either no guard area is created or a minimal guard area is
5382 created, depending on the target. This pragma can appear anywhere a
5383 @code{Storage_Size} attribute definition clause is allowed for a task
5386 @node Pragma Test_Case
5387 @unnumberedsec Pragma Test_Case
5393 @smallexample @c ada
5395 [Name =>] static_string_Expression
5396 ,[Mode =>] (Nominal | Robustness)
5397 [, Requires => Boolean_Expression]
5398 [, Ensures => Boolean_Expression]);
5402 The @code{Test_Case} pragma allows defining fine-grain specifications
5403 for use by testing tools. Its syntax is similar to the syntax of the
5404 @code{Contract_Case} pragma, which is used for both testing and
5405 formal verification.
5406 The compiler checks the validity of the @code{Test_Case} pragma, but its
5407 presence does not lead to any modification of the code generated by the
5408 compiler, contrary to the treatment of the @code{Contract_Case} pragma.
5410 @code{Test_Case} pragmas may only appear immediately following the
5411 (separate) declaration of a subprogram in a package declaration, inside
5412 a package spec unit. Only other pragmas may intervene (that is appear
5413 between the subprogram declaration and a test case).
5415 The compiler checks that boolean expressions given in @code{Requires} and
5416 @code{Ensures} are valid, where the rules for @code{Requires} are the
5417 same as the rule for an expression in @code{Precondition} and the rules
5418 for @code{Ensures} are the same as the rule for an expression in
5419 @code{Postcondition}. In particular, attributes @code{'Old} and
5420 @code{'Result} can only be used within the @code{Ensures}
5421 expression. The following is an example of use within a package spec:
5423 @smallexample @c ada
5424 package Math_Functions is
5426 function Sqrt (Arg : Float) return Float;
5427 pragma Test_Case (Name => "Test 1",
5429 Requires => Arg < 10000,
5430 Ensures => Sqrt'Result < 10);
5436 The meaning of a test case is that there is at least one context where
5437 @code{Requires} holds such that, if the associated subprogram is executed in
5438 that context, then @code{Ensures} holds when the subprogram returns.
5439 Mode @code{Nominal} indicates that the input context should also satisfy the
5440 precondition of the subprogram, and the output context should also satisfy its
5441 postcondition. More @code{Robustness} indicates that the precondition and
5442 postcondition of the subprogram should be ignored for this test case.
5444 @node Pragma Thread_Local_Storage
5445 @unnumberedsec Pragma Thread_Local_Storage
5446 @findex Thread_Local_Storage
5447 @cindex Task specific storage
5448 @cindex TLS (Thread Local Storage)
5451 @smallexample @c ada
5452 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5456 This pragma specifies that the specified entity, which must be
5457 a variable declared in a library level package, is to be marked as
5458 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5459 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5460 (and hence each Ada task) to see a distinct copy of the variable.
5462 The variable may not have default initialization, and if there is
5463 an explicit initialization, it must be either @code{null} for an
5464 access variable, or a static expression for a scalar variable.
5465 This provides a low level mechanism similar to that provided by
5466 the @code{Ada.Task_Attributes} package, but much more efficient
5467 and is also useful in writing interface code that will interact
5468 with foreign threads.
5470 If this pragma is used on a system where @code{TLS} is not supported,
5471 then an error message will be generated and the program will be rejected.
5473 @node Pragma Time_Slice
5474 @unnumberedsec Pragma Time_Slice
5479 @smallexample @c ada
5480 pragma Time_Slice (static_duration_EXPRESSION);
5484 For implementations of GNAT on operating systems where it is possible
5485 to supply a time slice value, this pragma may be used for this purpose.
5486 It is ignored if it is used in a system that does not allow this control,
5487 or if it appears in other than the main program unit.
5489 Note that the effect of this pragma is identical to the effect of the
5490 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5493 @unnumberedsec Pragma Title
5498 @smallexample @c ada
5499 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5502 [Title =>] STRING_LITERAL,
5503 | [Subtitle =>] STRING_LITERAL
5507 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5508 pragma used in DEC Ada 83 implementations to provide a title and/or
5509 subtitle for the program listing. The program listing generated by GNAT
5510 does not have titles or subtitles.
5512 Unlike other pragmas, the full flexibility of named notation is allowed
5513 for this pragma, i.e.@: the parameters may be given in any order if named
5514 notation is used, and named and positional notation can be mixed
5515 following the normal rules for procedure calls in Ada.
5517 @node Pragma Unchecked_Union
5518 @unnumberedsec Pragma Unchecked_Union
5520 @findex Unchecked_Union
5524 @smallexample @c ada
5525 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5529 This pragma is used to specify a representation of a record type that is
5530 equivalent to a C union. It was introduced as a GNAT implementation defined
5531 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5532 pragma, making it language defined, and GNAT fully implements this extended
5533 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5534 details, consult the Ada 2005 Reference Manual, section B.3.3.
5536 @node Pragma Unimplemented_Unit
5537 @unnumberedsec Pragma Unimplemented_Unit
5538 @findex Unimplemented_Unit
5542 @smallexample @c ada
5543 pragma Unimplemented_Unit;
5547 If this pragma occurs in a unit that is processed by the compiler, GNAT
5548 aborts with the message @samp{@var{xxx} not implemented}, where
5549 @var{xxx} is the name of the current compilation unit. This pragma is
5550 intended to allow the compiler to handle unimplemented library units in
5553 The abort only happens if code is being generated. Thus you can use
5554 specs of unimplemented packages in syntax or semantic checking mode.
5556 @node Pragma Universal_Aliasing
5557 @unnumberedsec Pragma Universal_Aliasing
5558 @findex Universal_Aliasing
5562 @smallexample @c ada
5563 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5567 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5568 declarative part. The effect is to inhibit strict type-based aliasing
5569 optimization for the given type. In other words, the effect is as though
5570 access types designating this type were subject to pragma No_Strict_Aliasing.
5571 For a detailed description of the strict aliasing optimization, and the
5572 situations in which it must be suppressed, @xref{Optimization and Strict
5573 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5575 @node Pragma Universal_Data
5576 @unnumberedsec Pragma Universal_Data
5577 @findex Universal_Data
5581 @smallexample @c ada
5582 pragma Universal_Data [(library_unit_Name)];
5586 This pragma is supported only for the AAMP target and is ignored for
5587 other targets. The pragma specifies that all library-level objects
5588 (Counter 0 data) associated with the library unit are to be accessed
5589 and updated using universal addressing (24-bit addresses for AAMP5)
5590 rather than the default of 16-bit Data Environment (DENV) addressing.
5591 Use of this pragma will generally result in less efficient code for
5592 references to global data associated with the library unit, but
5593 allows such data to be located anywhere in memory. This pragma is
5594 a library unit pragma, but can also be used as a configuration pragma
5595 (including use in the @file{gnat.adc} file). The functionality
5596 of this pragma is also available by applying the -univ switch on the
5597 compilations of units where universal addressing of the data is desired.
5599 @node Pragma Unmodified
5600 @unnumberedsec Pragma Unmodified
5602 @cindex Warnings, unmodified
5606 @smallexample @c ada
5607 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5611 This pragma signals that the assignable entities (variables,
5612 @code{out} parameters, @code{in out} parameters) whose names are listed are
5613 deliberately not assigned in the current source unit. This
5614 suppresses warnings about the
5615 entities being referenced but not assigned, and in addition a warning will be
5616 generated if one of these entities is in fact assigned in the
5617 same unit as the pragma (or in the corresponding body, or one
5620 This is particularly useful for clearly signaling that a particular
5621 parameter is not modified, even though the spec suggests that it might
5624 @node Pragma Unreferenced
5625 @unnumberedsec Pragma Unreferenced
5626 @findex Unreferenced
5627 @cindex Warnings, unreferenced
5631 @smallexample @c ada
5632 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5633 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5637 This pragma signals that the entities whose names are listed are
5638 deliberately not referenced in the current source unit. This
5639 suppresses warnings about the
5640 entities being unreferenced, and in addition a warning will be
5641 generated if one of these entities is in fact subsequently referenced in the
5642 same unit as the pragma (or in the corresponding body, or one
5645 This is particularly useful for clearly signaling that a particular
5646 parameter is not referenced in some particular subprogram implementation
5647 and that this is deliberate. It can also be useful in the case of
5648 objects declared only for their initialization or finalization side
5651 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5652 current scope, then the entity most recently declared is the one to which
5653 the pragma applies. Note that in the case of accept formals, the pragma
5654 Unreferenced may appear immediately after the keyword @code{do} which
5655 allows the indication of whether or not accept formals are referenced
5656 or not to be given individually for each accept statement.
5658 The left hand side of an assignment does not count as a reference for the
5659 purpose of this pragma. Thus it is fine to assign to an entity for which
5660 pragma Unreferenced is given.
5662 Note that if a warning is desired for all calls to a given subprogram,
5663 regardless of whether they occur in the same unit as the subprogram
5664 declaration, then this pragma should not be used (calls from another
5665 unit would not be flagged); pragma Obsolescent can be used instead
5666 for this purpose, see @xref{Pragma Obsolescent}.
5668 The second form of pragma @code{Unreferenced} is used within a context
5669 clause. In this case the arguments must be unit names of units previously
5670 mentioned in @code{with} clauses (similar to the usage of pragma
5671 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5672 units and unreferenced entities within these units.
5674 @node Pragma Unreferenced_Objects
5675 @unnumberedsec Pragma Unreferenced_Objects
5676 @findex Unreferenced_Objects
5677 @cindex Warnings, unreferenced
5681 @smallexample @c ada
5682 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5686 This pragma signals that for the types or subtypes whose names are
5687 listed, objects which are declared with one of these types or subtypes may
5688 not be referenced, and if no references appear, no warnings are given.
5690 This is particularly useful for objects which are declared solely for their
5691 initialization and finalization effect. Such variables are sometimes referred
5692 to as RAII variables (Resource Acquisition Is Initialization). Using this
5693 pragma on the relevant type (most typically a limited controlled type), the
5694 compiler will automatically suppress unwanted warnings about these variables
5695 not being referenced.
5697 @node Pragma Unreserve_All_Interrupts
5698 @unnumberedsec Pragma Unreserve_All_Interrupts
5699 @findex Unreserve_All_Interrupts
5703 @smallexample @c ada
5704 pragma Unreserve_All_Interrupts;
5708 Normally certain interrupts are reserved to the implementation. Any attempt
5709 to attach an interrupt causes Program_Error to be raised, as described in
5710 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5711 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5712 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5713 interrupt execution.
5715 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5716 a program, then all such interrupts are unreserved. This allows the
5717 program to handle these interrupts, but disables their standard
5718 functions. For example, if this pragma is used, then pressing
5719 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5720 a program can then handle the @code{SIGINT} interrupt as it chooses.
5722 For a full list of the interrupts handled in a specific implementation,
5723 see the source code for the spec of @code{Ada.Interrupts.Names} in
5724 file @file{a-intnam.ads}. This is a target dependent file that contains the
5725 list of interrupts recognized for a given target. The documentation in
5726 this file also specifies what interrupts are affected by the use of
5727 the @code{Unreserve_All_Interrupts} pragma.
5729 For a more general facility for controlling what interrupts can be
5730 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5731 of the @code{Unreserve_All_Interrupts} pragma.
5733 @node Pragma Unsuppress
5734 @unnumberedsec Pragma Unsuppress
5739 @smallexample @c ada
5740 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5744 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5745 there is no corresponding pragma @code{Suppress} in effect, it has no
5746 effect. The range of the effect is the same as for pragma
5747 @code{Suppress}. The meaning of the arguments is identical to that used
5748 in pragma @code{Suppress}.
5750 One important application is to ensure that checks are on in cases where
5751 code depends on the checks for its correct functioning, so that the code
5752 will compile correctly even if the compiler switches are set to suppress
5755 @node Pragma Use_VADS_Size
5756 @unnumberedsec Pragma Use_VADS_Size
5757 @cindex @code{Size}, VADS compatibility
5758 @findex Use_VADS_Size
5762 @smallexample @c ada
5763 pragma Use_VADS_Size;
5767 This is a configuration pragma. In a unit to which it applies, any use
5768 of the 'Size attribute is automatically interpreted as a use of the
5769 'VADS_Size attribute. Note that this may result in incorrect semantic
5770 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5771 the handling of existing code which depends on the interpretation of Size
5772 as implemented in the VADS compiler. See description of the VADS_Size
5773 attribute for further details.
5775 @node Pragma Validity_Checks
5776 @unnumberedsec Pragma Validity_Checks
5777 @findex Validity_Checks
5781 @smallexample @c ada
5782 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5786 This pragma is used in conjunction with compiler switches to control the
5787 built-in validity checking provided by GNAT@. The compiler switches, if set
5788 provide an initial setting for the switches, and this pragma may be used
5789 to modify these settings, or the settings may be provided entirely by
5790 the use of the pragma. This pragma can be used anywhere that a pragma
5791 is legal, including use as a configuration pragma (including use in
5792 the @file{gnat.adc} file).
5794 The form with a string literal specifies which validity options are to be
5795 activated. The validity checks are first set to include only the default
5796 reference manual settings, and then a string of letters in the string
5797 specifies the exact set of options required. The form of this string
5798 is exactly as described for the @option{-gnatVx} compiler switch (see the
5799 @value{EDITION} User's Guide for details). For example the following two
5800 methods can be used to enable validity checking for mode @code{in} and
5801 @code{in out} subprogram parameters:
5805 @smallexample @c ada
5806 pragma Validity_Checks ("im");
5811 gcc -c -gnatVim @dots{}
5816 The form ALL_CHECKS activates all standard checks (its use is equivalent
5817 to the use of the @code{gnatva} switch.
5819 The forms with @code{Off} and @code{On}
5820 can be used to temporarily disable validity checks
5821 as shown in the following example:
5823 @smallexample @c ada
5827 pragma Validity_Checks ("c"); -- validity checks for copies
5828 pragma Validity_Checks (Off); -- turn off validity checks
5829 A := B; -- B will not be validity checked
5830 pragma Validity_Checks (On); -- turn validity checks back on
5831 A := C; -- C will be validity checked
5834 @node Pragma Volatile
5835 @unnumberedsec Pragma Volatile
5840 @smallexample @c ada
5841 pragma Volatile (LOCAL_NAME);
5845 This pragma is defined by the Ada Reference Manual, and the GNAT
5846 implementation is fully conformant with this definition. The reason it
5847 is mentioned in this section is that a pragma of the same name was supplied
5848 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5849 implementation of pragma Volatile is upwards compatible with the
5850 implementation in DEC Ada 83.
5852 @node Pragma Warnings
5853 @unnumberedsec Pragma Warnings
5858 @smallexample @c ada
5859 pragma Warnings (On | Off);
5860 pragma Warnings (On | Off, LOCAL_NAME);
5861 pragma Warnings (static_string_EXPRESSION);
5862 pragma Warnings (On | Off, static_string_EXPRESSION);
5866 Normally warnings are enabled, with the output being controlled by
5867 the command line switch. Warnings (@code{Off}) turns off generation of
5868 warnings until a Warnings (@code{On}) is encountered or the end of the
5869 current unit. If generation of warnings is turned off using this
5870 pragma, then no warning messages are output, regardless of the
5871 setting of the command line switches.
5873 The form with a single argument may be used as a configuration pragma.
5875 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5876 the specified entity. This suppression is effective from the point where
5877 it occurs till the end of the extended scope of the variable (similar to
5878 the scope of @code{Suppress}).
5880 The form with a single static_string_EXPRESSION argument provides more precise
5881 control over which warnings are active. The string is a list of letters
5882 specifying which warnings are to be activated and which deactivated. The
5883 code for these letters is the same as the string used in the command
5884 line switch controlling warnings. For a brief summary, use the gnatmake
5885 command with no arguments, which will generate usage information containing
5886 the list of warnings switches supported. For
5887 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5891 The specified warnings will be in effect until the end of the program
5892 or another pragma Warnings is encountered. The effect of the pragma is
5893 cumulative. Initially the set of warnings is the standard default set
5894 as possibly modified by compiler switches. Then each pragma Warning
5895 modifies this set of warnings as specified. This form of the pragma may
5896 also be used as a configuration pragma.
5898 The fourth form, with an @code{On|Off} parameter and a string, is used to
5899 control individual messages, based on their text. The string argument
5900 is a pattern that is used to match against the text of individual
5901 warning messages (not including the initial "warning: " tag).
5903 The pattern may contain asterisks, which match zero or more characters in
5904 the message. For example, you can use
5905 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5906 message @code{warning: 960 bits of "a" unused}. No other regular
5907 expression notations are permitted. All characters other than asterisk in
5908 these three specific cases are treated as literal characters in the match.
5910 There are two ways to use the pragma in this form. The OFF form can be used as a
5911 configuration pragma. The effect is to suppress all warnings (if any)
5912 that match the pattern string throughout the compilation.
5914 The second usage is to suppress a warning locally, and in this case, two
5915 pragmas must appear in sequence:
5917 @smallexample @c ada
5918 pragma Warnings (Off, Pattern);
5919 @dots{} code where given warning is to be suppressed
5920 pragma Warnings (On, Pattern);
5924 In this usage, the pattern string must match in the Off and On pragmas,
5925 and at least one matching warning must be suppressed.
5927 Note: to write a string that will match any warning, use the string
5928 @code{"***"}. It will not work to use a single asterisk or two asterisks
5929 since this looks like an operator name. This form with three asterisks
5930 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
5931 matching @code{pragma Warnings (On, "***")} will be required. This can be
5932 helpful in avoiding forgetting to turn warnings back on.
5934 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5935 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5936 be useful in checking whether obsolete pragmas in existing programs are hiding
5939 Note: pragma Warnings does not affect the processing of style messages. See
5940 separate entry for pragma Style_Checks for control of style messages.
5942 @node Pragma Weak_External
5943 @unnumberedsec Pragma Weak_External
5944 @findex Weak_External
5948 @smallexample @c ada
5949 pragma Weak_External ([Entity =>] LOCAL_NAME);
5953 @var{LOCAL_NAME} must refer to an object that is declared at the library
5954 level. This pragma specifies that the given entity should be marked as a
5955 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5956 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5957 of a regular symbol, that is to say a symbol that does not have to be
5958 resolved by the linker if used in conjunction with a pragma Import.
5960 When a weak symbol is not resolved by the linker, its address is set to
5961 zero. This is useful in writing interfaces to external modules that may
5962 or may not be linked in the final executable, for example depending on
5963 configuration settings.
5965 If a program references at run time an entity to which this pragma has been
5966 applied, and the corresponding symbol was not resolved at link time, then
5967 the execution of the program is erroneous. It is not erroneous to take the
5968 Address of such an entity, for example to guard potential references,
5969 as shown in the example below.
5971 Some file formats do not support weak symbols so not all target machines
5972 support this pragma.
5974 @smallexample @c ada
5975 -- Example of the use of pragma Weak_External
5977 package External_Module is
5979 pragma Import (C, key);
5980 pragma Weak_External (key);
5981 function Present return boolean;
5982 end External_Module;
5984 with System; use System;
5985 package body External_Module is
5986 function Present return boolean is
5988 return key'Address /= System.Null_Address;
5990 end External_Module;
5993 @node Pragma Wide_Character_Encoding
5994 @unnumberedsec Pragma Wide_Character_Encoding
5995 @findex Wide_Character_Encoding
5999 @smallexample @c ada
6000 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
6004 This pragma specifies the wide character encoding to be used in program
6005 source text appearing subsequently. It is a configuration pragma, but may
6006 also be used at any point that a pragma is allowed, and it is permissible
6007 to have more than one such pragma in a file, allowing multiple encodings
6008 to appear within the same file.
6010 The argument can be an identifier or a character literal. In the identifier
6011 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
6012 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
6013 case it is correspondingly one of the characters @samp{h}, @samp{u},
6014 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
6016 Note that when the pragma is used within a file, it affects only the
6017 encoding within that file, and does not affect withed units, specs,
6020 @node Implementation Defined Attributes
6021 @chapter Implementation Defined Attributes
6022 Ada defines (throughout the Ada reference manual,
6023 summarized in Annex K),
6024 a set of attributes that provide useful additional functionality in all
6025 areas of the language. These language defined attributes are implemented
6026 in GNAT and work as described in the Ada Reference Manual.
6028 In addition, Ada allows implementations to define additional
6029 attributes whose meaning is defined by the implementation. GNAT provides
6030 a number of these implementation-dependent attributes which can be used
6031 to extend and enhance the functionality of the compiler. This section of
6032 the GNAT reference manual describes these additional attributes.
6034 Note that any program using these attributes may not be portable to
6035 other compilers (although GNAT implements this set of attributes on all
6036 platforms). Therefore if portability to other compilers is an important
6037 consideration, you should minimize the use of these attributes.
6047 * Compiler_Version::
6049 * Default_Bit_Order::
6061 * Has_Access_Values::
6062 * Has_Discriminants::
6069 * Max_Interrupt_Priority::
6071 * Maximum_Alignment::
6075 * Passed_By_Reference::
6082 * Scalar_Storage_Order::
6083 * Simple_Storage_Pool::
6087 * System_Allocator_Alignment::
6093 * Unconstrained_Array::
6094 * Universal_Literal_String::
6095 * Unrestricted_Access::
6104 @unnumberedsec Abort_Signal
6105 @findex Abort_Signal
6107 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
6108 prefix) provides the entity for the special exception used to signal
6109 task abort or asynchronous transfer of control. Normally this attribute
6110 should only be used in the tasking runtime (it is highly peculiar, and
6111 completely outside the normal semantics of Ada, for a user program to
6112 intercept the abort exception).
6115 @unnumberedsec Address_Size
6116 @cindex Size of @code{Address}
6117 @findex Address_Size
6119 @code{Standard'Address_Size} (@code{Standard} is the only allowed
6120 prefix) is a static constant giving the number of bits in an
6121 @code{Address}. It is the same value as System.Address'Size,
6122 but has the advantage of being static, while a direct
6123 reference to System.Address'Size is non-static because Address
6127 @unnumberedsec Asm_Input
6130 The @code{Asm_Input} attribute denotes a function that takes two
6131 parameters. The first is a string, the second is an expression of the
6132 type designated by the prefix. The first (string) argument is required
6133 to be a static expression, and is the constraint for the parameter,
6134 (e.g.@: what kind of register is required). The second argument is the
6135 value to be used as the input argument. The possible values for the
6136 constant are the same as those used in the RTL, and are dependent on
6137 the configuration file used to built the GCC back end.
6138 @ref{Machine Code Insertions}
6141 @unnumberedsec Asm_Output
6144 The @code{Asm_Output} attribute denotes a function that takes two
6145 parameters. The first is a string, the second is the name of a variable
6146 of the type designated by the attribute prefix. The first (string)
6147 argument is required to be a static expression and designates the
6148 constraint for the parameter (e.g.@: what kind of register is
6149 required). The second argument is the variable to be updated with the
6150 result. The possible values for constraint are the same as those used in
6151 the RTL, and are dependent on the configuration file used to build the
6152 GCC back end. If there are no output operands, then this argument may
6153 either be omitted, or explicitly given as @code{No_Output_Operands}.
6154 @ref{Machine Code Insertions}
6157 @unnumberedsec AST_Entry
6161 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
6162 the name of an entry, it yields a value of the predefined type AST_Handler
6163 (declared in the predefined package System, as extended by the use of
6164 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
6165 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
6166 Language Reference Manual}, section 9.12a.
6171 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
6172 offset within the storage unit (byte) that contains the first bit of
6173 storage allocated for the object. The value of this attribute is of the
6174 type @code{Universal_Integer}, and is always a non-negative number not
6175 exceeding the value of @code{System.Storage_Unit}.
6177 For an object that is a variable or a constant allocated in a register,
6178 the value is zero. (The use of this attribute does not force the
6179 allocation of a variable to memory).
6181 For an object that is a formal parameter, this attribute applies
6182 to either the matching actual parameter or to a copy of the
6183 matching actual parameter.
6185 For an access object the value is zero. Note that
6186 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
6187 designated object. Similarly for a record component
6188 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
6189 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
6190 are subject to index checks.
6192 This attribute is designed to be compatible with the DEC Ada 83 definition
6193 and implementation of the @code{Bit} attribute.
6196 @unnumberedsec Bit_Position
6197 @findex Bit_Position
6199 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
6200 of the fields of the record type, yields the bit
6201 offset within the record contains the first bit of
6202 storage allocated for the object. The value of this attribute is of the
6203 type @code{Universal_Integer}. The value depends only on the field
6204 @var{C} and is independent of the alignment of
6205 the containing record @var{R}.
6207 @node Compiler_Version
6208 @unnumberedsec Compiler_Version
6209 @findex Compiler_Version
6211 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
6212 prefix) yields a static string identifying the version of the compiler
6213 being used to compile the unit containing the attribute reference. A
6214 typical result would be something like "@value{EDITION} @i{version} (20090221)".
6217 @unnumberedsec Code_Address
6218 @findex Code_Address
6219 @cindex Subprogram address
6220 @cindex Address of subprogram code
6223 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
6224 intended effect seems to be to provide
6225 an address value which can be used to call the subprogram by means of
6226 an address clause as in the following example:
6228 @smallexample @c ada
6229 procedure K is @dots{}
6232 for L'Address use K'Address;
6233 pragma Import (Ada, L);
6237 A call to @code{L} is then expected to result in a call to @code{K}@.
6238 In Ada 83, where there were no access-to-subprogram values, this was
6239 a common work-around for getting the effect of an indirect call.
6240 GNAT implements the above use of @code{Address} and the technique
6241 illustrated by the example code works correctly.
6243 However, for some purposes, it is useful to have the address of the start
6244 of the generated code for the subprogram. On some architectures, this is
6245 not necessarily the same as the @code{Address} value described above.
6246 For example, the @code{Address} value may reference a subprogram
6247 descriptor rather than the subprogram itself.
6249 The @code{'Code_Address} attribute, which can only be applied to
6250 subprogram entities, always returns the address of the start of the
6251 generated code of the specified subprogram, which may or may not be
6252 the same value as is returned by the corresponding @code{'Address}
6255 @node Default_Bit_Order
6256 @unnumberedsec Default_Bit_Order
6258 @cindex Little endian
6259 @findex Default_Bit_Order
6261 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
6262 permissible prefix), provides the value @code{System.Default_Bit_Order}
6263 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
6264 @code{Low_Order_First}). This is used to construct the definition of
6265 @code{Default_Bit_Order} in package @code{System}.
6267 @node Descriptor_Size
6268 @unnumberedsec Descriptor_Size
6271 @findex Descriptor_Size
6273 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
6274 descriptor allocated for a type. The result is non-zero only for unconstrained
6275 array types and the returned value is of type universal integer. In GNAT, an
6276 array descriptor contains bounds information and is located immediately before
6277 the first element of the array.
6279 @smallexample @c ada
6280 type Unconstr_Array is array (Positive range <>) of Boolean;
6281 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
6285 The attribute takes into account any additional padding due to type alignment.
6286 In the example above, the descriptor contains two values of type
6287 @code{Positive} representing the low and high bound. Since @code{Positive} has
6288 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
6289 Positive'Size + 2} or 64 bits.
6292 @unnumberedsec Elaborated
6295 The prefix of the @code{'Elaborated} attribute must be a unit name. The
6296 value is a Boolean which indicates whether or not the given unit has been
6297 elaborated. This attribute is primarily intended for internal use by the
6298 generated code for dynamic elaboration checking, but it can also be used
6299 in user programs. The value will always be True once elaboration of all
6300 units has been completed. An exception is for units which need no
6301 elaboration, the value is always False for such units.
6304 @unnumberedsec Elab_Body
6307 This attribute can only be applied to a program unit name. It returns
6308 the entity for the corresponding elaboration procedure for elaborating
6309 the body of the referenced unit. This is used in the main generated
6310 elaboration procedure by the binder and is not normally used in any
6311 other context. However, there may be specialized situations in which it
6312 is useful to be able to call this elaboration procedure from Ada code,
6313 e.g.@: if it is necessary to do selective re-elaboration to fix some
6317 @unnumberedsec Elab_Spec
6320 This attribute can only be applied to a program unit name. It returns
6321 the entity for the corresponding elaboration procedure for elaborating
6322 the spec of the referenced unit. This is used in the main
6323 generated elaboration procedure by the binder and is not normally used
6324 in any other context. However, there may be specialized situations in
6325 which it is useful to be able to call this elaboration procedure from
6326 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6329 @node Elab_Subp_Body
6330 @unnumberedsec Elab_Subp_Body
6331 @findex Elab_Subp_Body
6333 This attribute can only be applied to a library level subprogram
6334 name and is only allowed in CodePeer mode. It returns the entity
6335 for the corresponding elaboration procedure for elaborating the body
6336 of the referenced subprogram unit. This is used in the main generated
6337 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6342 @cindex Ada 83 attributes
6345 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6346 the Ada 83 reference manual for an exact description of the semantics of
6350 @unnumberedsec Enabled
6353 The @code{Enabled} attribute allows an application program to check at compile
6354 time to see if the designated check is currently enabled. The prefix is a
6355 simple identifier, referencing any predefined check name (other than
6356 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6357 no argument is given for the attribute, the check is for the general state
6358 of the check, if an argument is given, then it is an entity name, and the
6359 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6360 given naming the entity (if not, then the argument is ignored).
6362 Note that instantiations inherit the check status at the point of the
6363 instantiation, so a useful idiom is to have a library package that
6364 introduces a check name with @code{pragma Check_Name}, and then contains
6365 generic packages or subprograms which use the @code{Enabled} attribute
6366 to see if the check is enabled. A user of this package can then issue
6367 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6368 the package or subprogram, controlling whether the check will be present.
6371 @unnumberedsec Enum_Rep
6372 @cindex Representation of enums
6375 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6376 function with the following spec:
6378 @smallexample @c ada
6379 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6380 return @i{Universal_Integer};
6384 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6385 enumeration type or to a non-overloaded enumeration
6386 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6387 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6388 enumeration literal or object.
6390 The function returns the representation value for the given enumeration
6391 value. This will be equal to value of the @code{Pos} attribute in the
6392 absence of an enumeration representation clause. This is a static
6393 attribute (i.e.@: the result is static if the argument is static).
6395 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6396 in which case it simply returns the integer value. The reason for this
6397 is to allow it to be used for @code{(<>)} discrete formal arguments in
6398 a generic unit that can be instantiated with either enumeration types
6399 or integer types. Note that if @code{Enum_Rep} is used on a modular
6400 type whose upper bound exceeds the upper bound of the largest signed
6401 integer type, and the argument is a variable, so that the universal
6402 integer calculation is done at run time, then the call to @code{Enum_Rep}
6403 may raise @code{Constraint_Error}.
6406 @unnumberedsec Enum_Val
6407 @cindex Representation of enums
6410 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6411 function with the following spec:
6413 @smallexample @c ada
6414 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6415 return @var{S}'Base};
6419 The function returns the enumeration value whose representation matches the
6420 argument, or raises Constraint_Error if no enumeration literal of the type
6421 has the matching value.
6422 This will be equal to value of the @code{Val} attribute in the
6423 absence of an enumeration representation clause. This is a static
6424 attribute (i.e.@: the result is static if the argument is static).
6427 @unnumberedsec Epsilon
6428 @cindex Ada 83 attributes
6431 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6432 the Ada 83 reference manual for an exact description of the semantics of
6436 @unnumberedsec Fixed_Value
6439 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6440 function with the following specification:
6442 @smallexample @c ada
6443 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6448 The value returned is the fixed-point value @var{V} such that
6450 @smallexample @c ada
6451 @var{V} = Arg * @var{S}'Small
6455 The effect is thus similar to first converting the argument to the
6456 integer type used to represent @var{S}, and then doing an unchecked
6457 conversion to the fixed-point type. The difference is
6458 that there are full range checks, to ensure that the result is in range.
6459 This attribute is primarily intended for use in implementation of the
6460 input-output functions for fixed-point values.
6462 @node Has_Access_Values
6463 @unnumberedsec Has_Access_Values
6464 @cindex Access values, testing for
6465 @findex Has_Access_Values
6467 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6468 is a Boolean value which is True if the is an access type, or is a composite
6469 type with a component (at any nesting depth) that is an access type, and is
6471 The intended use of this attribute is in conjunction with generic
6472 definitions. If the attribute is applied to a generic private type, it
6473 indicates whether or not the corresponding actual type has access values.
6475 @node Has_Discriminants
6476 @unnumberedsec Has_Discriminants
6477 @cindex Discriminants, testing for
6478 @findex Has_Discriminants
6480 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6481 is a Boolean value which is True if the type has discriminants, and False
6482 otherwise. The intended use of this attribute is in conjunction with generic
6483 definitions. If the attribute is applied to a generic private type, it
6484 indicates whether or not the corresponding actual type has discriminants.
6490 The @code{Img} attribute differs from @code{Image} in that it may be
6491 applied to objects as well as types, in which case it gives the
6492 @code{Image} for the subtype of the object. This is convenient for
6495 @smallexample @c ada
6496 Put_Line ("X = " & X'Img);
6500 has the same meaning as the more verbose:
6502 @smallexample @c ada
6503 Put_Line ("X = " & @var{T}'Image (X));
6507 where @var{T} is the (sub)type of the object @code{X}.
6510 @unnumberedsec Integer_Value
6511 @findex Integer_Value
6513 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6514 function with the following spec:
6516 @smallexample @c ada
6517 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6522 The value returned is the integer value @var{V}, such that
6524 @smallexample @c ada
6525 Arg = @var{V} * @var{T}'Small
6529 where @var{T} is the type of @code{Arg}.
6530 The effect is thus similar to first doing an unchecked conversion from
6531 the fixed-point type to its corresponding implementation type, and then
6532 converting the result to the target integer type. The difference is
6533 that there are full range checks, to ensure that the result is in range.
6534 This attribute is primarily intended for use in implementation of the
6535 standard input-output functions for fixed-point values.
6538 @unnumberedsec Invalid_Value
6539 @findex Invalid_Value
6541 For every scalar type S, S'Invalid_Value returns an undefined value of the
6542 type. If possible this value is an invalid representation for the type. The
6543 value returned is identical to the value used to initialize an otherwise
6544 uninitialized value of the type if pragma Initialize_Scalars is used,
6545 including the ability to modify the value with the binder -Sxx flag and
6546 relevant environment variables at run time.
6549 @unnumberedsec Large
6550 @cindex Ada 83 attributes
6553 The @code{Large} attribute is provided for compatibility with Ada 83. See
6554 the Ada 83 reference manual for an exact description of the semantics of
6558 @unnumberedsec Machine_Size
6559 @findex Machine_Size
6561 This attribute is identical to the @code{Object_Size} attribute. It is
6562 provided for compatibility with the DEC Ada 83 attribute of this name.
6565 @unnumberedsec Mantissa
6566 @cindex Ada 83 attributes
6569 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6570 the Ada 83 reference manual for an exact description of the semantics of
6573 @node Max_Interrupt_Priority
6574 @unnumberedsec Max_Interrupt_Priority
6575 @cindex Interrupt priority, maximum
6576 @findex Max_Interrupt_Priority
6578 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6579 permissible prefix), provides the same value as
6580 @code{System.Max_Interrupt_Priority}.
6583 @unnumberedsec Max_Priority
6584 @cindex Priority, maximum
6585 @findex Max_Priority
6587 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6588 prefix) provides the same value as @code{System.Max_Priority}.
6590 @node Maximum_Alignment
6591 @unnumberedsec Maximum_Alignment
6592 @cindex Alignment, maximum
6593 @findex Maximum_Alignment
6595 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6596 permissible prefix) provides the maximum useful alignment value for the
6597 target. This is a static value that can be used to specify the alignment
6598 for an object, guaranteeing that it is properly aligned in all
6601 @node Mechanism_Code
6602 @unnumberedsec Mechanism_Code
6603 @cindex Return values, passing mechanism
6604 @cindex Parameters, passing mechanism
6605 @findex Mechanism_Code
6607 @code{@var{function}'Mechanism_Code} yields an integer code for the
6608 mechanism used for the result of function, and
6609 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6610 used for formal parameter number @var{n} (a static integer value with 1
6611 meaning the first parameter) of @var{subprogram}. The code returned is:
6619 by descriptor (default descriptor class)
6621 by descriptor (UBS: unaligned bit string)
6623 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6625 by descriptor (UBA: unaligned bit array)
6627 by descriptor (S: string, also scalar access type parameter)
6629 by descriptor (SB: string with arbitrary bounds)
6631 by descriptor (A: contiguous array)
6633 by descriptor (NCA: non-contiguous array)
6637 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6640 @node Null_Parameter
6641 @unnumberedsec Null_Parameter
6642 @cindex Zero address, passing
6643 @findex Null_Parameter
6645 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6646 type or subtype @var{T} allocated at machine address zero. The attribute
6647 is allowed only as the default expression of a formal parameter, or as
6648 an actual expression of a subprogram call. In either case, the
6649 subprogram must be imported.
6651 The identity of the object is represented by the address zero in the
6652 argument list, independent of the passing mechanism (explicit or
6655 This capability is needed to specify that a zero address should be
6656 passed for a record or other composite object passed by reference.
6657 There is no way of indicating this without the @code{Null_Parameter}
6661 @unnumberedsec Object_Size
6662 @cindex Size, used for objects
6665 The size of an object is not necessarily the same as the size of the type
6666 of an object. This is because by default object sizes are increased to be
6667 a multiple of the alignment of the object. For example,
6668 @code{Natural'Size} is
6669 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6670 Similarly, a record containing an integer and a character:
6672 @smallexample @c ada
6680 will have a size of 40 (that is @code{Rec'Size} will be 40). The
6681 alignment will be 4, because of the
6682 integer field, and so the default size of record objects for this type
6683 will be 64 (8 bytes).
6685 @node Passed_By_Reference
6686 @unnumberedsec Passed_By_Reference
6687 @cindex Parameters, when passed by reference
6688 @findex Passed_By_Reference
6690 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6691 a value of type @code{Boolean} value that is @code{True} if the type is
6692 normally passed by reference and @code{False} if the type is normally
6693 passed by copy in calls. For scalar types, the result is always @code{False}
6694 and is static. For non-scalar types, the result is non-static.
6697 @unnumberedsec Pool_Address
6698 @cindex Parameters, when passed by reference
6699 @findex Pool_Address
6701 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6702 of X within its storage pool. This is the same as
6703 @code{@var{X}'Address}, except that for an unconstrained array whose
6704 bounds are allocated just before the first component,
6705 @code{@var{X}'Pool_Address} returns the address of those bounds,
6706 whereas @code{@var{X}'Address} returns the address of the first
6709 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6710 the object is allocated'', which could be a user-defined storage pool,
6711 the global heap, on the stack, or in a static memory area. For an
6712 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6713 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6716 @unnumberedsec Range_Length
6717 @findex Range_Length
6719 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6720 the number of values represented by the subtype (zero for a null
6721 range). The result is static for static subtypes. @code{Range_Length}
6722 applied to the index subtype of a one dimensional array always gives the
6723 same result as @code{Range} applied to the array itself.
6729 The @code{System.Address'Ref}
6730 (@code{System.Address} is the only permissible prefix)
6731 denotes a function identical to
6732 @code{System.Storage_Elements.To_Address} except that
6733 it is a static attribute. See @ref{To_Address} for more details.
6736 @unnumberedsec Result
6739 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6740 for a function. The prefix must be the name of the corresponding function. This
6741 is used to refer to the result of the function in the postcondition expression.
6742 For a further discussion of the use of this attribute and examples of its use,
6743 see the description of pragma Postcondition.
6746 @unnumberedsec Safe_Emax
6747 @cindex Ada 83 attributes
6750 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6751 the Ada 83 reference manual for an exact description of the semantics of
6755 @unnumberedsec Safe_Large
6756 @cindex Ada 83 attributes
6759 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6760 the Ada 83 reference manual for an exact description of the semantics of
6763 @node Scalar_Storage_Order
6764 @unnumberedsec Scalar_Storage_Order
6766 @cindex Scalar storage order
6767 @findex Scalar_Storage_Order
6769 For every array or record type @var{S}, the representation attribute
6770 @code{Scalar_Storage_Order} denotes the order in which storage elements
6771 that make up scalar components are ordered within S. Other properties are
6772 as for standard representation attribute @code{Bit_Order}, as defined by
6773 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
6775 If @code{@var{S}'Scalar_Storage_Order} is specified explicitly, it shall be
6776 equal to @code{@var{S}'Bit_Order}. Note: This means that if a
6777 @code{Scalar_Storage_Order} attribute definition clause is not confirming,
6778 then the type's @code{Bit_Order} shall be specified explicitly and set to
6781 If a component of S has itself a record or array type, then it shall also
6782 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
6783 if the component does not start on a byte boundary, then the scalar storage
6784 order specified for S and for the nested component type shall be identical.
6786 No component of a type that has a @code{Scalar_Storage_Order} attribute
6787 definition may be aliased.
6789 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
6790 with a value equal to @code{System.Default_Bit_Order}) has no effect.
6792 If the opposite storage order is specified, then whenever the value of
6793 a scalar component of S is read, the storage elements of the enclosing
6794 machine scalar are first reversed (before retrieving the component value,
6795 possibly applying some shift and mask operatings on the enclosing machine
6796 scalar), and the opposite operation is done for writes.
6798 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
6799 are relaxed. Instead, the following rules apply:
6802 @item the underlying storage elements are those at positions
6803 @code{(position + first_bit / storage_element_size) ..
6804 (position + (last_bit + storage_element_size - 1) /
6805 storage_element_size)}
6806 @item the sequence of underlying storage elements shall have
6807 a size no greater than the largest machine scalar
6808 @item the enclosing machine scalar is defined as the smallest machine
6809 scalar starting at a position no greater than
6810 @code{position + first_bit / storage_element_size} and covering
6811 storage elements at least up to @code{position + (last_bit +
6812 storage_element_size - 1) / storage_element_size}
6813 @item the position of the component is interpreted relative to that machine
6818 @node Simple_Storage_Pool
6819 @unnumberedsec Simple_Storage_Pool
6820 @cindex Storage pool, simple
6821 @cindex Simple storage pool
6822 @findex Simple_Storage_Pool
6824 For every nonformal, nonderived access-to-object type @var{Acc}, the
6825 representation attribute @code{Simple_Storage_Pool} may be specified
6826 via an attribute_definition_clause (or by specifying the equivalent aspect):
6828 @smallexample @c ada
6830 My_Pool : My_Simple_Storage_Pool_Type;
6832 type Acc is access My_Data_Type;
6834 for Acc'Simple_Storage_Pool use My_Pool;
6839 The name given in an attribute_definition_clause for the
6840 @code{Simple_Storage_Pool} attribute shall denote a variable of
6841 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
6843 The use of this attribute is only allowed for a prefix denoting a type
6844 for which it has been specified. The type of the attribute is the type
6845 of the variable specified as the simple storage pool of the access type,
6846 and the attribute denotes that variable.
6848 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
6849 for the same access type.
6851 If the @code{Simple_Storage_Pool} attribute has been specified for an access
6852 type, then applying the @code{Storage_Pool} attribute to the type is flagged
6853 with a warning and its evaluation raises the exception @code{Program_Error}.
6855 If the Simple_Storage_Pool attribute has been specified for an access
6856 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
6857 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
6858 which is intended to indicate the number of storage elements reserved for
6859 the simple storage pool. If the Storage_Size function has not been defined
6860 for the simple storage pool type, then this attribute returns zero.
6862 If an access type @var{S} has a specified simple storage pool of type
6863 @var{SSP}, then the evaluation of an allocator for that access type calls
6864 the primitive @code{Allocate} procedure for type @var{SSP}, passing
6865 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
6866 semantics of such allocators is the same as those defined for allocators
6867 in section 13.11 of the Ada Reference Manual, with the term
6868 ``simple storage pool'' substituted for ``storage pool''.
6870 If an access type @var{S} has a specified simple storage pool of type
6871 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
6872 for that access type invokes the primitive @code{Deallocate} procedure
6873 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
6874 parameter. The detailed semantics of such unchecked deallocations is the same
6875 as defined in section 13.11.2 of the Ada Reference Manual, except that the
6876 term ``simple storage pool'' is substituted for ``storage pool''.
6879 @unnumberedsec Small
6880 @cindex Ada 83 attributes
6883 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6885 GNAT also allows this attribute to be applied to floating-point types
6886 for compatibility with Ada 83. See
6887 the Ada 83 reference manual for an exact description of the semantics of
6888 this attribute when applied to floating-point types.
6891 @unnumberedsec Storage_Unit
6892 @findex Storage_Unit
6894 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6895 prefix) provides the same value as @code{System.Storage_Unit}.
6898 @unnumberedsec Stub_Type
6901 The GNAT implementation of remote access-to-classwide types is
6902 organized as described in AARM section E.4 (20.t): a value of an RACW type
6903 (designating a remote object) is represented as a normal access
6904 value, pointing to a "stub" object which in turn contains the
6905 necessary information to contact the designated remote object. A
6906 call on any dispatching operation of such a stub object does the
6907 remote call, if necessary, using the information in the stub object
6908 to locate the target partition, etc.
6910 For a prefix @code{T} that denotes a remote access-to-classwide type,
6911 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6913 By construction, the layout of @code{T'Stub_Type} is identical to that of
6914 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6915 unit @code{System.Partition_Interface}. Use of this attribute will create
6916 an implicit dependency on this unit.
6918 @node System_Allocator_Alignment
6919 @unnumberedsec System_Allocator_Alignment
6920 @cindex Alignment, allocator
6921 @findex System_Allocator_Alignment
6923 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
6924 permissible prefix) provides the observable guaranted to be honored by
6925 the system allocator (malloc). This is a static value that can be used
6926 in user storage pools based on malloc either to reject allocation
6927 with alignment too large or to enable a realignment circuitry if the
6928 alignment request is larger than this value.
6931 @unnumberedsec Target_Name
6934 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6935 prefix) provides a static string value that identifies the target
6936 for the current compilation. For GCC implementations, this is the
6937 standard gcc target name without the terminating slash (for
6938 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6944 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6945 provides the same value as @code{System.Tick},
6948 @unnumberedsec To_Address
6951 The @code{System'To_Address}
6952 (@code{System} is the only permissible prefix)
6953 denotes a function identical to
6954 @code{System.Storage_Elements.To_Address} except that
6955 it is a static attribute. This means that if its argument is
6956 a static expression, then the result of the attribute is a
6957 static expression. The result is that such an expression can be
6958 used in contexts (e.g.@: preelaborable packages) which require a
6959 static expression and where the function call could not be used
6960 (since the function call is always non-static, even if its
6961 argument is static).
6964 @unnumberedsec Type_Class
6967 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6968 the value of the type class for the full type of @var{type}. If
6969 @var{type} is a generic formal type, the value is the value for the
6970 corresponding actual subtype. The value of this attribute is of type
6971 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6973 @smallexample @c ada
6975 (Type_Class_Enumeration,
6977 Type_Class_Fixed_Point,
6978 Type_Class_Floating_Point,
6983 Type_Class_Address);
6987 Protected types yield the value @code{Type_Class_Task}, which thus
6988 applies to all concurrent types. This attribute is designed to
6989 be compatible with the DEC Ada 83 attribute of the same name.
6992 @unnumberedsec UET_Address
6995 The @code{UET_Address} attribute can only be used for a prefix which
6996 denotes a library package. It yields the address of the unit exception
6997 table when zero cost exception handling is used. This attribute is
6998 intended only for use within the GNAT implementation. See the unit
6999 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
7000 for details on how this attribute is used in the implementation.
7002 @node Unconstrained_Array
7003 @unnumberedsec Unconstrained_Array
7004 @findex Unconstrained_Array
7006 The @code{Unconstrained_Array} attribute can be used with a prefix that
7007 denotes any type or subtype. It is a static attribute that yields
7008 @code{True} if the prefix designates an unconstrained array,
7009 and @code{False} otherwise. In a generic instance, the result is
7010 still static, and yields the result of applying this test to the
7013 @node Universal_Literal_String
7014 @unnumberedsec Universal_Literal_String
7015 @cindex Named numbers, representation of
7016 @findex Universal_Literal_String
7018 The prefix of @code{Universal_Literal_String} must be a named
7019 number. The static result is the string consisting of the characters of
7020 the number as defined in the original source. This allows the user
7021 program to access the actual text of named numbers without intermediate
7022 conversions and without the need to enclose the strings in quotes (which
7023 would preclude their use as numbers).
7025 For example, the following program prints the first 50 digits of pi:
7027 @smallexample @c ada
7028 with Text_IO; use Text_IO;
7032 Put (Ada.Numerics.Pi'Universal_Literal_String);
7036 @node Unrestricted_Access
7037 @unnumberedsec Unrestricted_Access
7038 @cindex @code{Access}, unrestricted
7039 @findex Unrestricted_Access
7041 The @code{Unrestricted_Access} attribute is similar to @code{Access}
7042 except that all accessibility and aliased view checks are omitted. This
7043 is a user-beware attribute. It is similar to
7044 @code{Address}, for which it is a desirable replacement where the value
7045 desired is an access type. In other words, its effect is identical to
7046 first applying the @code{Address} attribute and then doing an unchecked
7047 conversion to a desired access type. In GNAT, but not necessarily in
7048 other implementations, the use of static chains for inner level
7049 subprograms means that @code{Unrestricted_Access} applied to a
7050 subprogram yields a value that can be called as long as the subprogram
7051 is in scope (normal Ada accessibility rules restrict this usage).
7053 It is possible to use @code{Unrestricted_Access} for any type, but care
7054 must be exercised if it is used to create pointers to unconstrained
7055 objects. In this case, the resulting pointer has the same scope as the
7056 context of the attribute, and may not be returned to some enclosing
7057 scope. For instance, a function cannot use @code{Unrestricted_Access}
7058 to create a unconstrained pointer and then return that value to the
7062 @unnumberedsec Valid_Scalars
7063 @findex Valid_Scalars
7065 The @code{'Valid_Scalars} attribute is intended to make it easier to
7066 check the validity of scalar subcomponents of composite objects. It
7067 is defined for any prefix @code{X} that denotes an object.
7068 The value of this attribute is of the predefined type Boolean.
7069 @code{X'Valid_Scalars} yields True if and only if evaluation of
7070 @code{P'Valid} yields True for every scalar part P of X or if X has
7071 no scalar parts. It is not specified in what order the scalar parts
7072 are checked, nor whether any more are checked after any one of them
7073 is determined to be invalid. If the prefix @code{X} is of a class-wide
7074 type @code{T'Class} (where @code{T} is the associated specific type),
7075 or if the prefix @code{X} is of a specific tagged type @code{T}, then
7076 only the scalar parts of components of @code{T} are traversed; in other
7077 words, components of extensions of @code{T} are not traversed even if
7078 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
7079 be determined at compile time that the prefix of the attribute has no
7080 scalar parts (e.g., if the prefix is of an access type, an interface type,
7081 an undiscriminated task type, or an undiscriminated protected type).
7084 @unnumberedsec VADS_Size
7085 @cindex @code{Size}, VADS compatibility
7088 The @code{'VADS_Size} attribute is intended to make it easier to port
7089 legacy code which relies on the semantics of @code{'Size} as implemented
7090 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
7091 same semantic interpretation. In particular, @code{'VADS_Size} applied
7092 to a predefined or other primitive type with no Size clause yields the
7093 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
7094 typical machines). In addition @code{'VADS_Size} applied to an object
7095 gives the result that would be obtained by applying the attribute to
7096 the corresponding type.
7099 @unnumberedsec Value_Size
7100 @cindex @code{Size}, setting for not-first subtype
7102 @code{@var{type}'Value_Size} is the number of bits required to represent
7103 a value of the given subtype. It is the same as @code{@var{type}'Size},
7104 but, unlike @code{Size}, may be set for non-first subtypes.
7107 @unnumberedsec Wchar_T_Size
7108 @findex Wchar_T_Size
7109 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
7110 prefix) provides the size in bits of the C @code{wchar_t} type
7111 primarily for constructing the definition of this type in
7112 package @code{Interfaces.C}.
7115 @unnumberedsec Word_Size
7117 @code{Standard'Word_Size} (@code{Standard} is the only permissible
7118 prefix) provides the value @code{System.Word_Size}.
7120 @node Standard and Implementation Defined Restrictions
7121 @chapter Standard and Implementation Defined Restrictions
7124 All RM defined Restriction identifiers are implemented:
7127 @item language-defined restrictions (see 13.12.1)
7128 @item tasking restrictions (see D.7)
7129 @item high integrity restrictions (see H.4)
7133 GNAT implements additional restriction identifiers. All restrictions, whether
7134 language defined or GNAT-specific, are listed in the following.
7137 * Partition-Wide Restrictions::
7138 * Program Unit Level Restrictions::
7141 @node Partition-Wide Restrictions
7142 @section Partition-Wide Restrictions
7144 There are two separate lists of restriction identifiers. The first
7145 set requires consistency throughout a partition (in other words, if the
7146 restriction identifier is used for any compilation unit in the partition,
7147 then all compilation units in the partition must obey the restriction).
7150 * Immediate_Reclamation::
7151 * Max_Asynchronous_Select_Nesting::
7152 * Max_Entry_Queue_Length::
7153 * Max_Protected_Entries::
7154 * Max_Select_Alternatives::
7155 * Max_Storage_At_Blocking::
7156 * Max_Task_Entries::
7158 * No_Abort_Statements::
7159 * No_Access_Parameter_Allocators::
7160 * No_Access_Subprograms::
7162 * No_Anonymous_Allocators::
7165 * No_Default_Initialization::
7168 * No_Direct_Boolean_Operators::
7170 * No_Dispatching_Calls::
7171 * No_Dynamic_Attachment::
7172 * No_Dynamic_Priorities::
7173 * No_Entry_Calls_In_Elaboration_Code::
7174 * No_Enumeration_Maps::
7175 * No_Exception_Handlers::
7176 * No_Exception_Propagation::
7177 * No_Exception_Registration::
7181 * No_Floating_Point::
7182 * No_Implicit_Conditionals::
7183 * No_Implicit_Dynamic_Code::
7184 * No_Implicit_Heap_Allocations::
7185 * No_Implicit_Loops::
7186 * No_Initialize_Scalars::
7188 * No_Local_Allocators::
7189 * No_Local_Protected_Objects::
7190 * No_Local_Timing_Events::
7191 * No_Nested_Finalization::
7192 * No_Protected_Type_Allocators::
7193 * No_Protected_Types::
7196 * No_Relative_Delay::
7197 * No_Requeue_Statements::
7198 * No_Secondary_Stack::
7199 * No_Select_Statements::
7200 * No_Specific_Termination_Handlers::
7201 * No_Specification_of_Aspect::
7202 * No_Standard_Allocators_After_Elaboration::
7203 * No_Standard_Storage_Pools::
7204 * No_Stream_Optimizations::
7206 * No_Task_Allocators::
7207 * No_Task_Attributes_Package::
7208 * No_Task_Hierarchy::
7209 * No_Task_Termination::
7211 * No_Terminate_Alternatives::
7212 * No_Unchecked_Access::
7214 * Static_Priorities::
7215 * Static_Storage_Size::
7218 @node Immediate_Reclamation
7219 @unnumberedsubsec Immediate_Reclamation
7220 @findex Immediate_Reclamation
7221 [RM H.4] This restriction ensures that, except for storage occupied by
7222 objects created by allocators and not deallocated via unchecked
7223 deallocation, any storage reserved at run time for an object is
7224 immediately reclaimed when the object no longer exists.
7226 @node Max_Asynchronous_Select_Nesting
7227 @unnumberedsubsec Max_Asynchronous_Select_Nesting
7228 @findex Max_Asynchronous_Select_Nesting
7229 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
7230 selects. Violations of this restriction with a value of zero are
7231 detected at compile time. Violations of this restriction with values
7232 other than zero cause Storage_Error to be raised.
7234 @node Max_Entry_Queue_Length
7235 @unnumberedsubsec Max_Entry_Queue_Length
7236 @findex Max_Entry_Queue_Length
7237 [RM D.7] This restriction is a declaration that any protected entry compiled in
7238 the scope of the restriction has at most the specified number of
7239 tasks waiting on the entry at any one time, and so no queue is required.
7240 Note that this restriction is checked at run time. Violation of this
7241 restriction results in the raising of Program_Error exception at the point of
7244 @node Max_Protected_Entries
7245 @unnumberedsubsec Max_Protected_Entries
7246 @findex Max_Protected_Entries
7247 [RM D.7] Specifies the maximum number of entries per protected type. The
7248 bounds of every entry family of a protected unit shall be static, or shall be
7249 defined by a discriminant of a subtype whose corresponding bound is static.
7251 @node Max_Select_Alternatives
7252 @unnumberedsubsec Max_Select_Alternatives
7253 @findex Max_Select_Alternatives
7254 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
7256 @node Max_Storage_At_Blocking
7257 @unnumberedsubsec Max_Storage_At_Blocking
7258 @findex Max_Storage_At_Blocking
7259 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
7260 Storage_Size that can be retained by a blocked task. A violation of this
7261 restriction causes Storage_Error to be raised.
7263 @node Max_Task_Entries
7264 @unnumberedsubsec Max_Task_Entries
7265 @findex Max_Task_Entries
7266 [RM D.7] Specifies the maximum number of entries
7267 per task. The bounds of every entry family
7268 of a task unit shall be static, or shall be
7269 defined by a discriminant of a subtype whose
7270 corresponding bound is static.
7273 @unnumberedsubsec Max_Tasks
7275 [RM D.7] Specifies the maximum number of task that may be created, not
7276 counting the creation of the environment task. Violations of this
7277 restriction with a value of zero are detected at compile
7278 time. Violations of this restriction with values other than zero cause
7279 Storage_Error to be raised.
7281 @node No_Abort_Statements
7282 @unnumberedsubsec No_Abort_Statements
7283 @findex No_Abort_Statements
7284 [RM D.7] There are no abort_statements, and there are
7285 no calls to Task_Identification.Abort_Task.
7287 @node No_Access_Parameter_Allocators
7288 @unnumberedsubsec No_Access_Parameter_Allocators
7289 @findex No_Access_Parameter_Allocators
7290 [RM H.4] This restriction ensures at compile time that there are no
7291 occurrences of an allocator as the actual parameter to an access
7294 @node No_Access_Subprograms
7295 @unnumberedsubsec No_Access_Subprograms
7296 @findex No_Access_Subprograms
7297 [RM H.4] This restriction ensures at compile time that there are no
7298 declarations of access-to-subprogram types.
7301 @unnumberedsubsec No_Allocators
7302 @findex No_Allocators
7303 [RM H.4] This restriction ensures at compile time that there are no
7304 occurrences of an allocator.
7306 @node No_Anonymous_Allocators
7307 @unnumberedsubsec No_Anonymous_Allocators
7308 @findex No_Anonymous_Allocators
7309 [RM H.4] This restriction ensures at compile time that there are no
7310 occurrences of an allocator of anonymous access type.
7313 @unnumberedsubsec No_Calendar
7315 [GNAT] This restriction ensures at compile time that there is no implicit or
7316 explicit dependence on the package @code{Ada.Calendar}.
7318 @node No_Coextensions
7319 @unnumberedsubsec No_Coextensions
7320 @findex No_Coextensions
7321 [RM H.4] This restriction ensures at compile time that there are no
7322 coextensions. See 3.10.2.
7324 @node No_Default_Initialization
7325 @unnumberedsubsec No_Default_Initialization
7326 @findex No_Default_Initialization
7328 [GNAT] This restriction prohibits any instance of default initialization
7329 of variables. The binder implements a consistency rule which prevents
7330 any unit compiled without the restriction from with'ing a unit with the
7331 restriction (this allows the generation of initialization procedures to
7332 be skipped, since you can be sure that no call is ever generated to an
7333 initialization procedure in a unit with the restriction active). If used
7334 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
7335 is to prohibit all cases of variables declared without a specific
7336 initializer (including the case of OUT scalar parameters).
7339 @unnumberedsubsec No_Delay
7341 [RM H.4] This restriction ensures at compile time that there are no
7342 delay statements and no dependences on package Calendar.
7345 @unnumberedsubsec No_Dependence
7346 @findex No_Dependence
7347 [RM 13.12.1] This restriction checks at compile time that there are no
7348 dependence on a library unit.
7350 @node No_Direct_Boolean_Operators
7351 @unnumberedsubsec No_Direct_Boolean_Operators
7352 @findex No_Direct_Boolean_Operators
7353 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
7354 operands of type Boolean (or any type derived
7355 from Boolean). This is intended for use in safety critical programs
7356 where the certification protocol requires the use of short-circuit
7357 (and then, or else) forms for all composite boolean operations.
7360 @unnumberedsubsec No_Dispatch
7362 [RM H.4] This restriction ensures at compile time that there are no
7363 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
7365 @node No_Dispatching_Calls
7366 @unnumberedsubsec No_Dispatching_Calls
7367 @findex No_Dispatching_Calls
7368 [GNAT] This restriction ensures at compile time that the code generated by the
7369 compiler involves no dispatching calls. The use of this restriction allows the
7370 safe use of record extensions, classwide membership tests and other classwide
7371 features not involving implicit dispatching. This restriction ensures that
7372 the code contains no indirect calls through a dispatching mechanism. Note that
7373 this includes internally-generated calls created by the compiler, for example
7374 in the implementation of class-wide objects assignments. The
7375 membership test is allowed in the presence of this restriction, because its
7376 implementation requires no dispatching.
7377 This restriction is comparable to the official Ada restriction
7378 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7379 all classwide constructs that do not imply dispatching.
7380 The following example indicates constructs that violate this restriction.
7384 type T is tagged record
7387 procedure P (X : T);
7389 type DT is new T with record
7390 More_Data : Natural;
7392 procedure Q (X : DT);
7396 procedure Example is
7397 procedure Test (O : T'Class) is
7398 N : Natural := O'Size;-- Error: Dispatching call
7399 C : T'Class := O; -- Error: implicit Dispatching Call
7401 if O in DT'Class then -- OK : Membership test
7402 Q (DT (O)); -- OK : Type conversion plus direct call
7404 P (O); -- Error: Dispatching call
7410 P (Obj); -- OK : Direct call
7411 P (T (Obj)); -- OK : Type conversion plus direct call
7412 P (T'Class (Obj)); -- Error: Dispatching call
7414 Test (Obj); -- OK : Type conversion
7416 if Obj in T'Class then -- OK : Membership test
7422 @node No_Dynamic_Attachment
7423 @unnumberedsubsec No_Dynamic_Attachment
7424 @findex No_Dynamic_Attachment
7425 [RM D.7] This restriction ensures that there is no call to any of the
7426 operations defined in package Ada.Interrupts
7427 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
7428 Detach_Handler, and Reference).
7430 @node No_Dynamic_Priorities
7431 @unnumberedsubsec No_Dynamic_Priorities
7432 @findex No_Dynamic_Priorities
7433 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
7435 @node No_Entry_Calls_In_Elaboration_Code
7436 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
7437 @findex No_Entry_Calls_In_Elaboration_Code
7438 [GNAT] This restriction ensures at compile time that no task or protected entry
7439 calls are made during elaboration code. As a result of the use of this
7440 restriction, the compiler can assume that no code past an accept statement
7441 in a task can be executed at elaboration time.
7443 @node No_Enumeration_Maps
7444 @unnumberedsubsec No_Enumeration_Maps
7445 @findex No_Enumeration_Maps
7446 [GNAT] This restriction ensures at compile time that no operations requiring
7447 enumeration maps are used (that is Image and Value attributes applied
7448 to enumeration types).
7450 @node No_Exception_Handlers
7451 @unnumberedsubsec No_Exception_Handlers
7452 @findex No_Exception_Handlers
7453 [GNAT] This restriction ensures at compile time that there are no explicit
7454 exception handlers. It also indicates that no exception propagation will
7455 be provided. In this mode, exceptions may be raised but will result in
7456 an immediate call to the last chance handler, a routine that the user
7457 must define with the following profile:
7459 @smallexample @c ada
7460 procedure Last_Chance_Handler
7461 (Source_Location : System.Address; Line : Integer);
7462 pragma Export (C, Last_Chance_Handler,
7463 "__gnat_last_chance_handler");
7466 The parameter is a C null-terminated string representing a message to be
7467 associated with the exception (typically the source location of the raise
7468 statement generated by the compiler). The Line parameter when nonzero
7469 represents the line number in the source program where the raise occurs.
7471 @node No_Exception_Propagation
7472 @unnumberedsubsec No_Exception_Propagation
7473 @findex No_Exception_Propagation
7474 [GNAT] This restriction guarantees that exceptions are never propagated
7475 to an outer subprogram scope. The only case in which an exception may
7476 be raised is when the handler is statically in the same subprogram, so
7477 that the effect of a raise is essentially like a goto statement. Any
7478 other raise statement (implicit or explicit) will be considered
7479 unhandled. Exception handlers are allowed, but may not contain an
7480 exception occurrence identifier (exception choice). In addition, use of
7481 the package GNAT.Current_Exception is not permitted, and reraise
7482 statements (raise with no operand) are not permitted.
7484 @node No_Exception_Registration
7485 @unnumberedsubsec No_Exception_Registration
7486 @findex No_Exception_Registration
7487 [GNAT] This restriction ensures at compile time that no stream operations for
7488 types Exception_Id or Exception_Occurrence are used. This also makes it
7489 impossible to pass exceptions to or from a partition with this restriction
7490 in a distributed environment. If this exception is active, then the generated
7491 code is simplified by omitting the otherwise-required global registration
7492 of exceptions when they are declared.
7495 @unnumberedsubsec No_Exceptions
7496 @findex No_Exceptions
7497 [RM H.4] This restriction ensures at compile time that there are no
7498 raise statements and no exception handlers.
7500 @node No_Finalization
7501 @unnumberedsubsec No_Finalization
7502 @findex No_Finalization
7503 [GNAT] This restriction disables the language features described in
7504 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
7505 performed by the compiler to support these features. The following types
7506 are no longer considered controlled when this restriction is in effect:
7509 @code{Ada.Finalization.Controlled}
7511 @code{Ada.Finalization.Limited_Controlled}
7513 Derivations from @code{Controlled} or @code{Limited_Controlled}
7521 Array and record types with controlled components
7523 The compiler no longer generates code to initialize, finalize or adjust an
7524 object or a nested component, either declared on the stack or on the heap. The
7525 deallocation of a controlled object no longer finalizes its contents.
7527 @node No_Fixed_Point
7528 @unnumberedsubsec No_Fixed_Point
7529 @findex No_Fixed_Point
7530 [RM H.4] This restriction ensures at compile time that there are no
7531 occurrences of fixed point types and operations.
7533 @node No_Floating_Point
7534 @unnumberedsubsec No_Floating_Point
7535 @findex No_Floating_Point
7536 [RM H.4] This restriction ensures at compile time that there are no
7537 occurrences of floating point types and operations.
7539 @node No_Implicit_Conditionals
7540 @unnumberedsubsec No_Implicit_Conditionals
7541 @findex No_Implicit_Conditionals
7542 [GNAT] This restriction ensures that the generated code does not contain any
7543 implicit conditionals, either by modifying the generated code where possible,
7544 or by rejecting any construct that would otherwise generate an implicit
7545 conditional. Note that this check does not include run time constraint
7546 checks, which on some targets may generate implicit conditionals as
7547 well. To control the latter, constraint checks can be suppressed in the
7548 normal manner. Constructs generating implicit conditionals include comparisons
7549 of composite objects and the Max/Min attributes.
7551 @node No_Implicit_Dynamic_Code
7552 @unnumberedsubsec No_Implicit_Dynamic_Code
7553 @findex No_Implicit_Dynamic_Code
7555 [GNAT] This restriction prevents the compiler from building ``trampolines''.
7556 This is a structure that is built on the stack and contains dynamic
7557 code to be executed at run time. On some targets, a trampoline is
7558 built for the following features: @code{Access},
7559 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
7560 nested task bodies; primitive operations of nested tagged types.
7561 Trampolines do not work on machines that prevent execution of stack
7562 data. For example, on windows systems, enabling DEP (data execution
7563 protection) will cause trampolines to raise an exception.
7564 Trampolines are also quite slow at run time.
7566 On many targets, trampolines have been largely eliminated. Look at the
7567 version of system.ads for your target --- if it has
7568 Always_Compatible_Rep equal to False, then trampolines are largely
7569 eliminated. In particular, a trampoline is built for the following
7570 features: @code{Address} of a nested subprogram;
7571 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
7572 but only if pragma Favor_Top_Level applies, or the access type has a
7573 foreign-language convention; primitive operations of nested tagged
7576 @node No_Implicit_Heap_Allocations
7577 @unnumberedsubsec No_Implicit_Heap_Allocations
7578 @findex No_Implicit_Heap_Allocations
7579 [RM D.7] No constructs are allowed to cause implicit heap allocation.
7581 @node No_Implicit_Loops
7582 @unnumberedsubsec No_Implicit_Loops
7583 @findex No_Implicit_Loops
7584 [GNAT] This restriction ensures that the generated code does not contain any
7585 implicit @code{for} loops, either by modifying
7586 the generated code where possible,
7587 or by rejecting any construct that would otherwise generate an implicit
7588 @code{for} loop. If this restriction is active, it is possible to build
7589 large array aggregates with all static components without generating an
7590 intermediate temporary, and without generating a loop to initialize individual
7591 components. Otherwise, a loop is created for arrays larger than about 5000
7594 @node No_Initialize_Scalars
7595 @unnumberedsubsec No_Initialize_Scalars
7596 @findex No_Initialize_Scalars
7597 [GNAT] This restriction ensures that no unit in the partition is compiled with
7598 pragma Initialize_Scalars. This allows the generation of more efficient
7599 code, and in particular eliminates dummy null initialization routines that
7600 are otherwise generated for some record and array types.
7603 @unnumberedsubsec No_IO
7605 [RM H.4] This restriction ensures at compile time that there are no
7606 dependences on any of the library units Sequential_IO, Direct_IO,
7607 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
7609 @node No_Local_Allocators
7610 @unnumberedsubsec No_Local_Allocators
7611 @findex No_Local_Allocators
7612 [RM H.4] This restriction ensures at compile time that there are no
7613 occurrences of an allocator in subprograms, generic subprograms, tasks,
7616 @node No_Local_Protected_Objects
7617 @unnumberedsubsec No_Local_Protected_Objects
7618 @findex No_Local_Protected_Objects
7619 [RM D.7] This restriction ensures at compile time that protected objects are
7620 only declared at the library level.
7622 @node No_Local_Timing_Events
7623 @unnumberedsubsec No_Local_Timing_Events
7624 @findex No_Local_Timing_Events
7625 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
7626 declared at the library level.
7628 @node No_Nested_Finalization
7629 @unnumberedsubsec No_Nested_Finalization
7630 @findex No_Nested_Finalization
7631 [RM D.7] All objects requiring finalization are declared at the library level.
7633 @node No_Protected_Type_Allocators
7634 @unnumberedsubsec No_Protected_Type_Allocators
7635 @findex No_Protected_Type_Allocators
7636 [RM D.7] This restriction ensures at compile time that there are no allocator
7637 expressions that attempt to allocate protected objects.
7639 @node No_Protected_Types
7640 @unnumberedsubsec No_Protected_Types
7641 @findex No_Protected_Types
7642 [RM H.4] This restriction ensures at compile time that there are no
7643 declarations of protected types or protected objects.
7646 @unnumberedsubsec No_Recursion
7647 @findex No_Recursion
7648 [RM H.4] A program execution is erroneous if a subprogram is invoked as
7649 part of its execution.
7652 @unnumberedsubsec No_Reentrancy
7653 @findex No_Reentrancy
7654 [RM H.4] A program execution is erroneous if a subprogram is executed by
7655 two tasks at the same time.
7657 @node No_Relative_Delay
7658 @unnumberedsubsec No_Relative_Delay
7659 @findex No_Relative_Delay
7660 [RM D.7] This restriction ensures at compile time that there are no delay
7661 relative statements and prevents expressions such as @code{delay 1.23;} from
7662 appearing in source code.
7664 @node No_Requeue_Statements
7665 @unnumberedsubsec No_Requeue_Statements
7666 @findex No_Requeue_Statements
7667 [RM D.7] This restriction ensures at compile time that no requeue statements
7668 are permitted and prevents keyword @code{requeue} from being used in source
7671 @node No_Secondary_Stack
7672 @unnumberedsubsec No_Secondary_Stack
7673 @findex No_Secondary_Stack
7674 [GNAT] This restriction ensures at compile time that the generated code
7675 does not contain any reference to the secondary stack. The secondary
7676 stack is used to implement functions returning unconstrained objects
7677 (arrays or records) on some targets.
7679 @node No_Select_Statements
7680 @unnumberedsubsec No_Select_Statements
7681 @findex No_Select_Statements
7682 [RM D.7] This restriction ensures at compile time no select statements of any
7683 kind are permitted, that is the keyword @code{select} may not appear.
7685 @node No_Specific_Termination_Handlers
7686 @unnumberedsubsec No_Specific_Termination_Handlers
7687 @findex No_Specific_Termination_Handlers
7688 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
7689 or to Ada.Task_Termination.Specific_Handler.
7691 @node No_Specification_of_Aspect
7692 @unnumberedsubsec No_Specification_of_Aspect
7693 @findex No_Specification_of_Aspect
7694 [RM 13.12.1] This restriction checks at compile time that no aspect
7695 specification, attribute definition clause, or pragma is given for a
7698 @node No_Standard_Allocators_After_Elaboration
7699 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
7700 @findex No_Standard_Allocators_After_Elaboration
7701 [RM D.7] Specifies that an allocator using a standard storage pool
7702 should never be evaluated at run time after the elaboration of the
7703 library items of the partition has completed. Otherwise, Storage_Error
7706 @node No_Standard_Storage_Pools
7707 @unnumberedsubsec No_Standard_Storage_Pools
7708 @findex No_Standard_Storage_Pools
7709 [GNAT] This restriction ensures at compile time that no access types
7710 use the standard default storage pool. Any access type declared must
7711 have an explicit Storage_Pool attribute defined specifying a
7712 user-defined storage pool.
7714 @node No_Stream_Optimizations
7715 @unnumberedsubsec No_Stream_Optimizations
7716 @findex No_Stream_Optimizations
7717 [GNAT] This restriction affects the performance of stream operations on types
7718 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
7719 compiler uses block reads and writes when manipulating @code{String} objects
7720 due to their supperior performance. When this restriction is in effect, the
7721 compiler performs all IO operations on a per-character basis.
7724 @unnumberedsubsec No_Streams
7726 [GNAT] This restriction ensures at compile/bind time that there are no
7727 stream objects created and no use of stream attributes.
7728 This restriction does not forbid dependences on the package
7729 @code{Ada.Streams}. So it is permissible to with
7730 @code{Ada.Streams} (or another package that does so itself)
7731 as long as no actual stream objects are created and no
7732 stream attributes are used.
7734 Note that the use of restriction allows optimization of tagged types,
7735 since they do not need to worry about dispatching stream operations.
7736 To take maximum advantage of this space-saving optimization, any
7737 unit declaring a tagged type should be compiled with the restriction,
7738 though this is not required.
7740 @node No_Task_Allocators
7741 @unnumberedsubsec No_Task_Allocators
7742 @findex No_Task_Allocators
7743 [RM D.7] There are no allocators for task types
7744 or types containing task subcomponents.
7746 @node No_Task_Attributes_Package
7747 @unnumberedsubsec No_Task_Attributes_Package
7748 @findex No_Task_Attributes_Package
7749 [GNAT] This restriction ensures at compile time that there are no implicit or
7750 explicit dependencies on the package @code{Ada.Task_Attributes}.
7752 @node No_Task_Hierarchy
7753 @unnumberedsubsec No_Task_Hierarchy
7754 @findex No_Task_Hierarchy
7755 [RM D.7] All (non-environment) tasks depend
7756 directly on the environment task of the partition.
7758 @node No_Task_Termination
7759 @unnumberedsubsec No_Task_Termination
7760 @findex No_Task_Termination
7761 [RM D.7] Tasks which terminate are erroneous.
7764 @unnumberedsubsec No_Tasking
7766 [GNAT] This restriction prevents the declaration of tasks or task types
7767 throughout the partition. It is similar in effect to the use of
7768 @code{Max_Tasks => 0} except that violations are caught at compile time
7769 and cause an error message to be output either by the compiler or
7772 @node No_Terminate_Alternatives
7773 @unnumberedsubsec No_Terminate_Alternatives
7774 @findex No_Terminate_Alternatives
7775 [RM D.7] There are no selective accepts with terminate alternatives.
7777 @node No_Unchecked_Access
7778 @unnumberedsubsec No_Unchecked_Access
7779 @findex No_Unchecked_Access
7780 [RM H.4] This restriction ensures at compile time that there are no
7781 occurrences of the Unchecked_Access attribute.
7783 @node Simple_Barriers
7784 @unnumberedsubsec Simple_Barriers
7785 @findex Simple_Barriers
7786 [RM D.7] This restriction ensures at compile time that barriers in entry
7787 declarations for protected types are restricted to either static boolean
7788 expressions or references to simple boolean variables defined in the private
7789 part of the protected type. No other form of entry barriers is permitted.
7791 @node Static_Priorities
7792 @unnumberedsubsec Static_Priorities
7793 @findex Static_Priorities
7794 [GNAT] This restriction ensures at compile time that all priority expressions
7795 are static, and that there are no dependences on the package
7796 @code{Ada.Dynamic_Priorities}.
7798 @node Static_Storage_Size
7799 @unnumberedsubsec Static_Storage_Size
7800 @findex Static_Storage_Size
7801 [GNAT] This restriction ensures at compile time that any expression appearing
7802 in a Storage_Size pragma or attribute definition clause is static.
7804 @node Program Unit Level Restrictions
7805 @section Program Unit Level Restrictions
7808 The second set of restriction identifiers
7809 does not require partition-wide consistency.
7810 The restriction may be enforced for a single
7811 compilation unit without any effect on any of the
7812 other compilation units in the partition.
7815 * No_Elaboration_Code::
7817 * No_Implementation_Aspect_Specifications::
7818 * No_Implementation_Attributes::
7819 * No_Implementation_Identifiers::
7820 * No_Implementation_Pragmas::
7821 * No_Implementation_Restrictions::
7822 * No_Implementation_Units::
7823 * No_Implicit_Aliasing::
7824 * No_Obsolescent_Features::
7825 * No_Wide_Characters::
7829 @node No_Elaboration_Code
7830 @unnumberedsubsec No_Elaboration_Code
7831 @findex No_Elaboration_Code
7832 [GNAT] This restriction ensures at compile time that no elaboration code is
7833 generated. Note that this is not the same condition as is enforced
7834 by pragma @code{Preelaborate}. There are cases in which pragma
7835 @code{Preelaborate} still permits code to be generated (e.g.@: code
7836 to initialize a large array to all zeroes), and there are cases of units
7837 which do not meet the requirements for pragma @code{Preelaborate},
7838 but for which no elaboration code is generated. Generally, it is
7839 the case that preelaborable units will meet the restrictions, with
7840 the exception of large aggregates initialized with an others_clause,
7841 and exception declarations (which generate calls to a run-time
7842 registry procedure). This restriction is enforced on
7843 a unit by unit basis, it need not be obeyed consistently
7844 throughout a partition.
7846 In the case of aggregates with others, if the aggregate has a dynamic
7847 size, there is no way to eliminate the elaboration code (such dynamic
7848 bounds would be incompatible with @code{Preelaborate} in any case). If
7849 the bounds are static, then use of this restriction actually modifies
7850 the code choice of the compiler to avoid generating a loop, and instead
7851 generate the aggregate statically if possible, no matter how many times
7852 the data for the others clause must be repeatedly generated.
7854 It is not possible to precisely document
7855 the constructs which are compatible with this restriction, since,
7856 unlike most other restrictions, this is not a restriction on the
7857 source code, but a restriction on the generated object code. For
7858 example, if the source contains a declaration:
7861 Val : constant Integer := X;
7865 where X is not a static constant, it may be possible, depending
7866 on complex optimization circuitry, for the compiler to figure
7867 out the value of X at compile time, in which case this initialization
7868 can be done by the loader, and requires no initialization code. It
7869 is not possible to document the precise conditions under which the
7870 optimizer can figure this out.
7872 Note that this the implementation of this restriction requires full
7873 code generation. If it is used in conjunction with "semantics only"
7874 checking, then some cases of violations may be missed.
7876 @node No_Entry_Queue
7877 @unnumberedsubsec No_Entry_Queue
7878 @findex No_Entry_Queue
7879 [GNAT] This restriction is a declaration that any protected entry compiled in
7880 the scope of the restriction has at most one task waiting on the entry
7881 at any one time, and so no queue is required. This restriction is not
7882 checked at compile time. A program execution is erroneous if an attempt
7883 is made to queue a second task on such an entry.
7885 @node No_Implementation_Aspect_Specifications
7886 @unnumberedsubsec No_Implementation_Aspect_Specifications
7887 @findex No_Implementation_Aspect_Specifications
7888 [RM 13.12.1] This restriction checks at compile time that no
7889 GNAT-defined aspects are present. With this restriction, the only
7890 aspects that can be used are those defined in the Ada Reference Manual.
7892 @node No_Implementation_Attributes
7893 @unnumberedsubsec No_Implementation_Attributes
7894 @findex No_Implementation_Attributes
7895 [RM 13.12.1] This restriction checks at compile time that no
7896 GNAT-defined attributes are present. With this restriction, the only
7897 attributes that can be used are those defined in the Ada Reference
7900 @node No_Implementation_Identifiers
7901 @unnumberedsubsec No_Implementation_Identifiers
7902 @findex No_Implementation_Identifiers
7903 [RM 13.12.1] This restriction checks at compile time that no
7904 implementation-defined identifiers occur within language-defined
7907 @node No_Implementation_Pragmas
7908 @unnumberedsubsec No_Implementation_Pragmas
7909 @findex No_Implementation_Pragmas
7910 [RM 13.12.1] This restriction checks at compile time that no
7911 GNAT-defined pragmas are present. With this restriction, the only
7912 pragmas that can be used are those defined in the Ada Reference Manual.
7914 @node No_Implementation_Restrictions
7915 @unnumberedsubsec No_Implementation_Restrictions
7916 @findex No_Implementation_Restrictions
7917 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
7918 identifiers (other than @code{No_Implementation_Restrictions} itself)
7919 are present. With this restriction, the only other restriction identifiers
7920 that can be used are those defined in the Ada Reference Manual.
7922 @node No_Implementation_Units
7923 @unnumberedsubsec No_Implementation_Units
7924 @findex No_Implementation_Units
7925 [RM 13.12.1] This restriction checks at compile time that there is no
7926 mention in the context clause of any implementation-defined descendants
7927 of packages Ada, Interfaces, or System.
7929 @node No_Implicit_Aliasing
7930 @unnumberedsubsec No_Implicit_Aliasing
7931 @findex No_Implicit_Aliasing
7932 [GNAT] This restriction, which is not required to be partition-wide consistent,
7933 requires an explicit aliased keyword for an object to which 'Access,
7934 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
7935 the 'Unrestricted_Access attribute for objects. Note: the reason that
7936 Unrestricted_Access is forbidden is that it would require the prefix
7937 to be aliased, and in such cases, it can always be replaced by
7938 the standard attribute Unchecked_Access which is preferable.
7940 @node No_Obsolescent_Features
7941 @unnumberedsubsec No_Obsolescent_Features
7942 @findex No_Obsolescent_Features
7943 [RM 13.12.1] This restriction checks at compile time that no obsolescent
7944 features are used, as defined in Annex J of the Ada Reference Manual.
7946 @node No_Wide_Characters
7947 @unnumberedsubsec No_Wide_Characters
7948 @findex No_Wide_Characters
7949 [GNAT] This restriction ensures at compile time that no uses of the types
7950 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7952 appear, and that no wide or wide wide string or character literals
7953 appear in the program (that is literals representing characters not in
7954 type @code{Character}.
7957 @unnumberedsubsec SPARK
7959 [GNAT] This restriction checks at compile time that some constructs
7960 forbidden in SPARK are not present. The SPARK version used as a
7961 reference is the same as the Ada mode for the unit, so a unit compiled
7962 in Ada 95 mode with SPARK restrictions will be checked for constructs
7963 forbidden in SPARK 95. Error messages related to SPARK restriction have
7967 violation of restriction "SPARK" at <file>
7971 This is not a replacement for the semantic checks performed by the
7972 SPARK Examiner tool, as the compiler only deals currently with code,
7973 not at all with SPARK annotations and does not guarantee catching all
7974 cases of constructs forbidden by SPARK.
7976 Thus it may well be the case that code which
7977 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
7978 e.g. due to the different visibility rules of the Examiner based on
7979 SPARK @code{inherit} annotations.
7981 This restriction can be useful in providing an initial filter for
7982 code developed using SPARK, or in examining legacy code to see how far
7983 it is from meeting SPARK restrictions.
7985 @c ------------------------
7986 @node Implementation Advice
7987 @chapter Implementation Advice
7989 The main text of the Ada Reference Manual describes the required
7990 behavior of all Ada compilers, and the GNAT compiler conforms to
7993 In addition, there are sections throughout the Ada Reference Manual headed
7994 by the phrase ``Implementation advice''. These sections are not normative,
7995 i.e., they do not specify requirements that all compilers must
7996 follow. Rather they provide advice on generally desirable behavior. You
7997 may wonder why they are not requirements. The most typical answer is
7998 that they describe behavior that seems generally desirable, but cannot
7999 be provided on all systems, or which may be undesirable on some systems.
8001 As far as practical, GNAT follows the implementation advice sections in
8002 the Ada Reference Manual. This chapter contains a table giving the
8003 reference manual section number, paragraph number and several keywords
8004 for each advice. Each entry consists of the text of the advice followed
8005 by the GNAT interpretation of this advice. Most often, this simply says
8006 ``followed'', which means that GNAT follows the advice. However, in a
8007 number of cases, GNAT deliberately deviates from this advice, in which
8008 case the text describes what GNAT does and why.
8010 @cindex Error detection
8011 @unnumberedsec 1.1.3(20): Error Detection
8014 If an implementation detects the use of an unsupported Specialized Needs
8015 Annex feature at run time, it should raise @code{Program_Error} if
8018 Not relevant. All specialized needs annex features are either supported,
8019 or diagnosed at compile time.
8022 @unnumberedsec 1.1.3(31): Child Units
8025 If an implementation wishes to provide implementation-defined
8026 extensions to the functionality of a language-defined library unit, it
8027 should normally do so by adding children to the library unit.
8031 @cindex Bounded errors
8032 @unnumberedsec 1.1.5(12): Bounded Errors
8035 If an implementation detects a bounded error or erroneous
8036 execution, it should raise @code{Program_Error}.
8038 Followed in all cases in which the implementation detects a bounded
8039 error or erroneous execution. Not all such situations are detected at
8043 @unnumberedsec 2.8(16): Pragmas
8046 Normally, implementation-defined pragmas should have no semantic effect
8047 for error-free programs; that is, if the implementation-defined pragmas
8048 are removed from a working program, the program should still be legal,
8049 and should still have the same semantics.
8051 The following implementation defined pragmas are exceptions to this
8063 @item CPP_Constructor
8067 @item Interface_Name
8069 @item Machine_Attribute
8071 @item Unimplemented_Unit
8073 @item Unchecked_Union
8078 In each of the above cases, it is essential to the purpose of the pragma
8079 that this advice not be followed. For details see the separate section
8080 on implementation defined pragmas.
8082 @unnumberedsec 2.8(17-19): Pragmas
8085 Normally, an implementation should not define pragmas that can
8086 make an illegal program legal, except as follows:
8090 A pragma used to complete a declaration, such as a pragma @code{Import};
8094 A pragma used to configure the environment by adding, removing, or
8095 replacing @code{library_items}.
8097 See response to paragraph 16 of this same section.
8099 @cindex Character Sets
8100 @cindex Alternative Character Sets
8101 @unnumberedsec 3.5.2(5): Alternative Character Sets
8104 If an implementation supports a mode with alternative interpretations
8105 for @code{Character} and @code{Wide_Character}, the set of graphic
8106 characters of @code{Character} should nevertheless remain a proper
8107 subset of the set of graphic characters of @code{Wide_Character}. Any
8108 character set ``localizations'' should be reflected in the results of
8109 the subprograms defined in the language-defined package
8110 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
8111 an alternative interpretation of @code{Character}, the implementation should
8112 also support a corresponding change in what is a legal
8113 @code{identifier_letter}.
8115 Not all wide character modes follow this advice, in particular the JIS
8116 and IEC modes reflect standard usage in Japan, and in these encoding,
8117 the upper half of the Latin-1 set is not part of the wide-character
8118 subset, since the most significant bit is used for wide character
8119 encoding. However, this only applies to the external forms. Internally
8120 there is no such restriction.
8122 @cindex Integer types
8123 @unnumberedsec 3.5.4(28): Integer Types
8127 An implementation should support @code{Long_Integer} in addition to
8128 @code{Integer} if the target machine supports 32-bit (or longer)
8129 arithmetic. No other named integer subtypes are recommended for package
8130 @code{Standard}. Instead, appropriate named integer subtypes should be
8131 provided in the library package @code{Interfaces} (see B.2).
8133 @code{Long_Integer} is supported. Other standard integer types are supported
8134 so this advice is not fully followed. These types
8135 are supported for convenient interface to C, and so that all hardware
8136 types of the machine are easily available.
8137 @unnumberedsec 3.5.4(29): Integer Types
8141 An implementation for a two's complement machine should support
8142 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
8143 implementation should support a non-binary modules up to @code{Integer'Last}.
8147 @cindex Enumeration values
8148 @unnumberedsec 3.5.5(8): Enumeration Values
8151 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
8152 subtype, if the value of the operand does not correspond to the internal
8153 code for any enumeration literal of its type (perhaps due to an
8154 un-initialized variable), then the implementation should raise
8155 @code{Program_Error}. This is particularly important for enumeration
8156 types with noncontiguous internal codes specified by an
8157 enumeration_representation_clause.
8162 @unnumberedsec 3.5.7(17): Float Types
8165 An implementation should support @code{Long_Float} in addition to
8166 @code{Float} if the target machine supports 11 or more digits of
8167 precision. No other named floating point subtypes are recommended for
8168 package @code{Standard}. Instead, appropriate named floating point subtypes
8169 should be provided in the library package @code{Interfaces} (see B.2).
8171 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
8172 former provides improved compatibility with other implementations
8173 supporting this type. The latter corresponds to the highest precision
8174 floating-point type supported by the hardware. On most machines, this
8175 will be the same as @code{Long_Float}, but on some machines, it will
8176 correspond to the IEEE extended form. The notable case is all ia32
8177 (x86) implementations, where @code{Long_Long_Float} corresponds to
8178 the 80-bit extended precision format supported in hardware on this
8179 processor. Note that the 128-bit format on SPARC is not supported,
8180 since this is a software rather than a hardware format.
8182 @cindex Multidimensional arrays
8183 @cindex Arrays, multidimensional
8184 @unnumberedsec 3.6.2(11): Multidimensional Arrays
8187 An implementation should normally represent multidimensional arrays in
8188 row-major order, consistent with the notation used for multidimensional
8189 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
8190 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
8191 column-major order should be used instead (see B.5, ``Interfacing with
8196 @findex Duration'Small
8197 @unnumberedsec 9.6(30-31): Duration'Small
8200 Whenever possible in an implementation, the value of @code{Duration'Small}
8201 should be no greater than 100 microseconds.
8203 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
8207 The time base for @code{delay_relative_statements} should be monotonic;
8208 it need not be the same time base as used for @code{Calendar.Clock}.
8212 @unnumberedsec 10.2.1(12): Consistent Representation
8215 In an implementation, a type declared in a pre-elaborated package should
8216 have the same representation in every elaboration of a given version of
8217 the package, whether the elaborations occur in distinct executions of
8218 the same program, or in executions of distinct programs or partitions
8219 that include the given version.
8221 Followed, except in the case of tagged types. Tagged types involve
8222 implicit pointers to a local copy of a dispatch table, and these pointers
8223 have representations which thus depend on a particular elaboration of the
8224 package. It is not easy to see how it would be possible to follow this
8225 advice without severely impacting efficiency of execution.
8227 @cindex Exception information
8228 @unnumberedsec 11.4.1(19): Exception Information
8231 @code{Exception_Message} by default and @code{Exception_Information}
8232 should produce information useful for
8233 debugging. @code{Exception_Message} should be short, about one
8234 line. @code{Exception_Information} can be long. @code{Exception_Message}
8235 should not include the
8236 @code{Exception_Name}. @code{Exception_Information} should include both
8237 the @code{Exception_Name} and the @code{Exception_Message}.
8239 Followed. For each exception that doesn't have a specified
8240 @code{Exception_Message}, the compiler generates one containing the location
8241 of the raise statement. This location has the form ``file:line'', where
8242 file is the short file name (without path information) and line is the line
8243 number in the file. Note that in the case of the Zero Cost Exception
8244 mechanism, these messages become redundant with the Exception_Information that
8245 contains a full backtrace of the calling sequence, so they are disabled.
8246 To disable explicitly the generation of the source location message, use the
8247 Pragma @code{Discard_Names}.
8249 @cindex Suppression of checks
8250 @cindex Checks, suppression of
8251 @unnumberedsec 11.5(28): Suppression of Checks
8254 The implementation should minimize the code executed for checks that
8255 have been suppressed.
8259 @cindex Representation clauses
8260 @unnumberedsec 13.1 (21-24): Representation Clauses
8263 The recommended level of support for all representation items is
8264 qualified as follows:
8268 An implementation need not support representation items containing
8269 non-static expressions, except that an implementation should support a
8270 representation item for a given entity if each non-static expression in
8271 the representation item is a name that statically denotes a constant
8272 declared before the entity.
8274 Followed. In fact, GNAT goes beyond the recommended level of support
8275 by allowing nonstatic expressions in some representation clauses even
8276 without the need to declare constants initialized with the values of
8280 @smallexample @c ada
8283 for Y'Address use X'Address;>>
8288 An implementation need not support a specification for the @code{Size}
8289 for a given composite subtype, nor the size or storage place for an
8290 object (including a component) of a given composite subtype, unless the
8291 constraints on the subtype and its composite subcomponents (if any) are
8292 all static constraints.
8294 Followed. Size Clauses are not permitted on non-static components, as
8299 An aliased component, or a component whose type is by-reference, should
8300 always be allocated at an addressable location.
8304 @cindex Packed types
8305 @unnumberedsec 13.2(6-8): Packed Types
8308 If a type is packed, then the implementation should try to minimize
8309 storage allocated to objects of the type, possibly at the expense of
8310 speed of accessing components, subject to reasonable complexity in
8311 addressing calculations.
8315 The recommended level of support pragma @code{Pack} is:
8317 For a packed record type, the components should be packed as tightly as
8318 possible subject to the Sizes of the component subtypes, and subject to
8319 any @code{record_representation_clause} that applies to the type; the
8320 implementation may, but need not, reorder components or cross aligned
8321 word boundaries to improve the packing. A component whose @code{Size} is
8322 greater than the word size may be allocated an integral number of words.
8324 Followed. Tight packing of arrays is supported for all component sizes
8325 up to 64-bits. If the array component size is 1 (that is to say, if
8326 the component is a boolean type or an enumeration type with two values)
8327 then values of the type are implicitly initialized to zero. This
8328 happens both for objects of the packed type, and for objects that have a
8329 subcomponent of the packed type.
8333 An implementation should support Address clauses for imported
8337 @cindex @code{Address} clauses
8338 @unnumberedsec 13.3(14-19): Address Clauses
8342 For an array @var{X}, @code{@var{X}'Address} should point at the first
8343 component of the array, and not at the array bounds.
8349 The recommended level of support for the @code{Address} attribute is:
8351 @code{@var{X}'Address} should produce a useful result if @var{X} is an
8352 object that is aliased or of a by-reference type, or is an entity whose
8353 @code{Address} has been specified.
8355 Followed. A valid address will be produced even if none of those
8356 conditions have been met. If necessary, the object is forced into
8357 memory to ensure the address is valid.
8361 An implementation should support @code{Address} clauses for imported
8368 Objects (including subcomponents) that are aliased or of a by-reference
8369 type should be allocated on storage element boundaries.
8375 If the @code{Address} of an object is specified, or it is imported or exported,
8376 then the implementation should not perform optimizations based on
8377 assumptions of no aliases.
8381 @cindex @code{Alignment} clauses
8382 @unnumberedsec 13.3(29-35): Alignment Clauses
8385 The recommended level of support for the @code{Alignment} attribute for
8388 An implementation should support specified Alignments that are factors
8389 and multiples of the number of storage elements per word, subject to the
8396 An implementation need not support specified @code{Alignment}s for
8397 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
8398 loaded and stored by available machine instructions.
8404 An implementation need not support specified @code{Alignment}s that are
8405 greater than the maximum @code{Alignment} the implementation ever returns by
8412 The recommended level of support for the @code{Alignment} attribute for
8415 Same as above, for subtypes, but in addition:
8421 For stand-alone library-level objects of statically constrained
8422 subtypes, the implementation should support all @code{Alignment}s
8423 supported by the target linker. For example, page alignment is likely to
8424 be supported for such objects, but not for subtypes.
8428 @cindex @code{Size} clauses
8429 @unnumberedsec 13.3(42-43): Size Clauses
8432 The recommended level of support for the @code{Size} attribute of
8435 A @code{Size} clause should be supported for an object if the specified
8436 @code{Size} is at least as large as its subtype's @code{Size}, and
8437 corresponds to a size in storage elements that is a multiple of the
8438 object's @code{Alignment} (if the @code{Alignment} is nonzero).
8442 @unnumberedsec 13.3(50-56): Size Clauses
8445 If the @code{Size} of a subtype is specified, and allows for efficient
8446 independent addressability (see 9.10) on the target architecture, then
8447 the @code{Size} of the following objects of the subtype should equal the
8448 @code{Size} of the subtype:
8450 Aliased objects (including components).
8456 @code{Size} clause on a composite subtype should not affect the
8457 internal layout of components.
8459 Followed. But note that this can be overridden by use of the implementation
8460 pragma Implicit_Packing in the case of packed arrays.
8464 The recommended level of support for the @code{Size} attribute of subtypes is:
8468 The @code{Size} (if not specified) of a static discrete or fixed point
8469 subtype should be the number of bits needed to represent each value
8470 belonging to the subtype using an unbiased representation, leaving space
8471 for a sign bit only if the subtype contains negative values. If such a
8472 subtype is a first subtype, then an implementation should support a
8473 specified @code{Size} for it that reflects this representation.
8479 For a subtype implemented with levels of indirection, the @code{Size}
8480 should include the size of the pointers, but not the size of what they
8485 @cindex @code{Component_Size} clauses
8486 @unnumberedsec 13.3(71-73): Component Size Clauses
8489 The recommended level of support for the @code{Component_Size}
8494 An implementation need not support specified @code{Component_Sizes} that are
8495 less than the @code{Size} of the component subtype.
8501 An implementation should support specified @code{Component_Size}s that
8502 are factors and multiples of the word size. For such
8503 @code{Component_Size}s, the array should contain no gaps between
8504 components. For other @code{Component_Size}s (if supported), the array
8505 should contain no gaps between components when packing is also
8506 specified; the implementation should forbid this combination in cases
8507 where it cannot support a no-gaps representation.
8511 @cindex Enumeration representation clauses
8512 @cindex Representation clauses, enumeration
8513 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
8516 The recommended level of support for enumeration representation clauses
8519 An implementation need not support enumeration representation clauses
8520 for boolean types, but should at minimum support the internal codes in
8521 the range @code{System.Min_Int.System.Max_Int}.
8525 @cindex Record representation clauses
8526 @cindex Representation clauses, records
8527 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
8530 The recommended level of support for
8531 @*@code{record_representation_clauses} is:
8533 An implementation should support storage places that can be extracted
8534 with a load, mask, shift sequence of machine code, and set with a load,
8535 shift, mask, store sequence, given the available machine instructions
8542 A storage place should be supported if its size is equal to the
8543 @code{Size} of the component subtype, and it starts and ends on a
8544 boundary that obeys the @code{Alignment} of the component subtype.
8550 If the default bit ordering applies to the declaration of a given type,
8551 then for a component whose subtype's @code{Size} is less than the word
8552 size, any storage place that does not cross an aligned word boundary
8553 should be supported.
8559 An implementation may reserve a storage place for the tag field of a
8560 tagged type, and disallow other components from overlapping that place.
8562 Followed. The storage place for the tag field is the beginning of the tagged
8563 record, and its size is Address'Size. GNAT will reject an explicit component
8564 clause for the tag field.
8568 An implementation need not support a @code{component_clause} for a
8569 component of an extension part if the storage place is not after the
8570 storage places of all components of the parent type, whether or not
8571 those storage places had been specified.
8573 Followed. The above advice on record representation clauses is followed,
8574 and all mentioned features are implemented.
8576 @cindex Storage place attributes
8577 @unnumberedsec 13.5.2(5): Storage Place Attributes
8580 If a component is represented using some form of pointer (such as an
8581 offset) to the actual data of the component, and this data is contiguous
8582 with the rest of the object, then the storage place attributes should
8583 reflect the place of the actual data, not the pointer. If a component is
8584 allocated discontinuously from the rest of the object, then a warning
8585 should be generated upon reference to one of its storage place
8588 Followed. There are no such components in GNAT@.
8590 @cindex Bit ordering
8591 @unnumberedsec 13.5.3(7-8): Bit Ordering
8594 The recommended level of support for the non-default bit ordering is:
8598 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
8599 should support the non-default bit ordering in addition to the default
8602 Followed. Word size does not equal storage size in this implementation.
8603 Thus non-default bit ordering is not supported.
8605 @cindex @code{Address}, as private type
8606 @unnumberedsec 13.7(37): Address as Private
8609 @code{Address} should be of a private type.
8613 @cindex Operations, on @code{Address}
8614 @cindex @code{Address}, operations of
8615 @unnumberedsec 13.7.1(16): Address Operations
8618 Operations in @code{System} and its children should reflect the target
8619 environment semantics as closely as is reasonable. For example, on most
8620 machines, it makes sense for address arithmetic to ``wrap around''.
8621 Operations that do not make sense should raise @code{Program_Error}.
8623 Followed. Address arithmetic is modular arithmetic that wraps around. No
8624 operation raises @code{Program_Error}, since all operations make sense.
8626 @cindex Unchecked conversion
8627 @unnumberedsec 13.9(14-17): Unchecked Conversion
8630 The @code{Size} of an array object should not include its bounds; hence,
8631 the bounds should not be part of the converted data.
8637 The implementation should not generate unnecessary run-time checks to
8638 ensure that the representation of @var{S} is a representation of the
8639 target type. It should take advantage of the permission to return by
8640 reference when possible. Restrictions on unchecked conversions should be
8641 avoided unless required by the target environment.
8643 Followed. There are no restrictions on unchecked conversion. A warning is
8644 generated if the source and target types do not have the same size since
8645 the semantics in this case may be target dependent.
8649 The recommended level of support for unchecked conversions is:
8653 Unchecked conversions should be supported and should be reversible in
8654 the cases where this clause defines the result. To enable meaningful use
8655 of unchecked conversion, a contiguous representation should be used for
8656 elementary subtypes, for statically constrained array subtypes whose
8657 component subtype is one of the subtypes described in this paragraph,
8658 and for record subtypes without discriminants whose component subtypes
8659 are described in this paragraph.
8663 @cindex Heap usage, implicit
8664 @unnumberedsec 13.11(23-25): Implicit Heap Usage
8667 An implementation should document any cases in which it dynamically
8668 allocates heap storage for a purpose other than the evaluation of an
8671 Followed, the only other points at which heap storage is dynamically
8672 allocated are as follows:
8676 At initial elaboration time, to allocate dynamically sized global
8680 To allocate space for a task when a task is created.
8683 To extend the secondary stack dynamically when needed. The secondary
8684 stack is used for returning variable length results.
8689 A default (implementation-provided) storage pool for an
8690 access-to-constant type should not have overhead to support deallocation of
8697 A storage pool for an anonymous access type should be created at the
8698 point of an allocator for the type, and be reclaimed when the designated
8699 object becomes inaccessible.
8703 @cindex Unchecked deallocation
8704 @unnumberedsec 13.11.2(17): Unchecked De-allocation
8707 For a standard storage pool, @code{Free} should actually reclaim the
8712 @cindex Stream oriented attributes
8713 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
8716 If a stream element is the same size as a storage element, then the
8717 normal in-memory representation should be used by @code{Read} and
8718 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
8719 should use the smallest number of stream elements needed to represent
8720 all values in the base range of the scalar type.
8723 Followed. By default, GNAT uses the interpretation suggested by AI-195,
8724 which specifies using the size of the first subtype.
8725 However, such an implementation is based on direct binary
8726 representations and is therefore target- and endianness-dependent.
8727 To address this issue, GNAT also supplies an alternate implementation
8728 of the stream attributes @code{Read} and @code{Write},
8729 which uses the target-independent XDR standard representation
8731 @cindex XDR representation
8732 @cindex @code{Read} attribute
8733 @cindex @code{Write} attribute
8734 @cindex Stream oriented attributes
8735 The XDR implementation is provided as an alternative body of the
8736 @code{System.Stream_Attributes} package, in the file
8737 @file{s-stratt-xdr.adb} in the GNAT library.
8738 There is no @file{s-stratt-xdr.ads} file.
8739 In order to install the XDR implementation, do the following:
8741 @item Replace the default implementation of the
8742 @code{System.Stream_Attributes} package with the XDR implementation.
8743 For example on a Unix platform issue the commands:
8745 $ mv s-stratt.adb s-stratt-default.adb
8746 $ mv s-stratt-xdr.adb s-stratt.adb
8750 Rebuild the GNAT run-time library as documented in
8751 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
8754 @unnumberedsec A.1(52): Names of Predefined Numeric Types
8757 If an implementation provides additional named predefined integer types,
8758 then the names should end with @samp{Integer} as in
8759 @samp{Long_Integer}. If an implementation provides additional named
8760 predefined floating point types, then the names should end with
8761 @samp{Float} as in @samp{Long_Float}.
8765 @findex Ada.Characters.Handling
8766 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
8769 If an implementation provides a localized definition of @code{Character}
8770 or @code{Wide_Character}, then the effects of the subprograms in
8771 @code{Characters.Handling} should reflect the localizations. See also
8774 Followed. GNAT provides no such localized definitions.
8776 @cindex Bounded-length strings
8777 @unnumberedsec A.4.4(106): Bounded-Length String Handling
8780 Bounded string objects should not be implemented by implicit pointers
8781 and dynamic allocation.
8783 Followed. No implicit pointers or dynamic allocation are used.
8785 @cindex Random number generation
8786 @unnumberedsec A.5.2(46-47): Random Number Generation
8789 Any storage associated with an object of type @code{Generator} should be
8790 reclaimed on exit from the scope of the object.
8796 If the generator period is sufficiently long in relation to the number
8797 of distinct initiator values, then each possible value of
8798 @code{Initiator} passed to @code{Reset} should initiate a sequence of
8799 random numbers that does not, in a practical sense, overlap the sequence
8800 initiated by any other value. If this is not possible, then the mapping
8801 between initiator values and generator states should be a rapidly
8802 varying function of the initiator value.
8804 Followed. The generator period is sufficiently long for the first
8805 condition here to hold true.
8807 @findex Get_Immediate
8808 @unnumberedsec A.10.7(23): @code{Get_Immediate}
8811 The @code{Get_Immediate} procedures should be implemented with
8812 unbuffered input. For a device such as a keyboard, input should be
8813 @dfn{available} if a key has already been typed, whereas for a disk
8814 file, input should always be available except at end of file. For a file
8815 associated with a keyboard-like device, any line-editing features of the
8816 underlying operating system should be disabled during the execution of
8817 @code{Get_Immediate}.
8819 Followed on all targets except VxWorks. For VxWorks, there is no way to
8820 provide this functionality that does not result in the input buffer being
8821 flushed before the @code{Get_Immediate} call. A special unit
8822 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
8826 @unnumberedsec B.1(39-41): Pragma @code{Export}
8829 If an implementation supports pragma @code{Export} to a given language,
8830 then it should also allow the main subprogram to be written in that
8831 language. It should support some mechanism for invoking the elaboration
8832 of the Ada library units included in the system, and for invoking the
8833 finalization of the environment task. On typical systems, the
8834 recommended mechanism is to provide two subprograms whose link names are
8835 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
8836 elaboration code for library units. @code{adafinal} should contain the
8837 finalization code. These subprograms should have no effect the second
8838 and subsequent time they are called.
8844 Automatic elaboration of pre-elaborated packages should be
8845 provided when pragma @code{Export} is supported.
8847 Followed when the main program is in Ada. If the main program is in a
8848 foreign language, then
8849 @code{adainit} must be called to elaborate pre-elaborated
8854 For each supported convention @var{L} other than @code{Intrinsic}, an
8855 implementation should support @code{Import} and @code{Export} pragmas
8856 for objects of @var{L}-compatible types and for subprograms, and pragma
8857 @code{Convention} for @var{L}-eligible types and for subprograms,
8858 presuming the other language has corresponding features. Pragma
8859 @code{Convention} need not be supported for scalar types.
8863 @cindex Package @code{Interfaces}
8865 @unnumberedsec B.2(12-13): Package @code{Interfaces}
8868 For each implementation-defined convention identifier, there should be a
8869 child package of package Interfaces with the corresponding name. This
8870 package should contain any declarations that would be useful for
8871 interfacing to the language (implementation) represented by the
8872 convention. Any declarations useful for interfacing to any language on
8873 the given hardware architecture should be provided directly in
8876 Followed. An additional package not defined
8877 in the Ada Reference Manual is @code{Interfaces.CPP}, used
8878 for interfacing to C++.
8882 An implementation supporting an interface to C, COBOL, or Fortran should
8883 provide the corresponding package or packages described in the following
8886 Followed. GNAT provides all the packages described in this section.
8888 @cindex C, interfacing with
8889 @unnumberedsec B.3(63-71): Interfacing with C
8892 An implementation should support the following interface correspondences
8899 An Ada procedure corresponds to a void-returning C function.
8905 An Ada function corresponds to a non-void C function.
8911 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
8918 An Ada @code{in} parameter of an access-to-object type with designated
8919 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
8920 where @var{t} is the C type corresponding to the Ada type @var{T}.
8926 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
8927 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
8928 argument to a C function, where @var{t} is the C type corresponding to
8929 the Ada type @var{T}. In the case of an elementary @code{out} or
8930 @code{in out} parameter, a pointer to a temporary copy is used to
8931 preserve by-copy semantics.
8937 An Ada parameter of a record type @var{T}, of any mode, is passed as a
8938 @code{@var{t}*} argument to a C function, where @var{t} is the C
8939 structure corresponding to the Ada type @var{T}.
8941 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
8942 pragma, or Convention, or by explicitly specifying the mechanism for a given
8943 call using an extended import or export pragma.
8947 An Ada parameter of an array type with component type @var{T}, of any
8948 mode, is passed as a @code{@var{t}*} argument to a C function, where
8949 @var{t} is the C type corresponding to the Ada type @var{T}.
8955 An Ada parameter of an access-to-subprogram type is passed as a pointer
8956 to a C function whose prototype corresponds to the designated
8957 subprogram's specification.
8961 @cindex COBOL, interfacing with
8962 @unnumberedsec B.4(95-98): Interfacing with COBOL
8965 An Ada implementation should support the following interface
8966 correspondences between Ada and COBOL@.
8972 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
8973 the COBOL type corresponding to @var{T}.
8979 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
8980 the corresponding COBOL type.
8986 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
8987 COBOL type corresponding to the Ada parameter type; for scalars, a local
8988 copy is used if necessary to ensure by-copy semantics.
8992 @cindex Fortran, interfacing with
8993 @unnumberedsec B.5(22-26): Interfacing with Fortran
8996 An Ada implementation should support the following interface
8997 correspondences between Ada and Fortran:
9003 An Ada procedure corresponds to a Fortran subroutine.
9009 An Ada function corresponds to a Fortran function.
9015 An Ada parameter of an elementary, array, or record type @var{T} is
9016 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
9017 the Fortran type corresponding to the Ada type @var{T}, and where the
9018 INTENT attribute of the corresponding dummy argument matches the Ada
9019 formal parameter mode; the Fortran implementation's parameter passing
9020 conventions are used. For elementary types, a local copy is used if
9021 necessary to ensure by-copy semantics.
9027 An Ada parameter of an access-to-subprogram type is passed as a
9028 reference to a Fortran procedure whose interface corresponds to the
9029 designated subprogram's specification.
9033 @cindex Machine operations
9034 @unnumberedsec C.1(3-5): Access to Machine Operations
9037 The machine code or intrinsic support should allow access to all
9038 operations normally available to assembly language programmers for the
9039 target environment, including privileged instructions, if any.
9045 The interfacing pragmas (see Annex B) should support interface to
9046 assembler; the default assembler should be associated with the
9047 convention identifier @code{Assembler}.
9053 If an entity is exported to assembly language, then the implementation
9054 should allocate it at an addressable location, and should ensure that it
9055 is retained by the linking process, even if not otherwise referenced
9056 from the Ada code. The implementation should assume that any call to a
9057 machine code or assembler subprogram is allowed to read or update every
9058 object that is specified as exported.
9062 @unnumberedsec C.1(10-16): Access to Machine Operations
9065 The implementation should ensure that little or no overhead is
9066 associated with calling intrinsic and machine-code subprograms.
9068 Followed for both intrinsics and machine-code subprograms.
9072 It is recommended that intrinsic subprograms be provided for convenient
9073 access to any machine operations that provide special capabilities or
9074 efficiency and that are not otherwise available through the language
9077 Followed. A full set of machine operation intrinsic subprograms is provided.
9081 Atomic read-modify-write operations---e.g.@:, test and set, compare and
9082 swap, decrement and test, enqueue/dequeue.
9084 Followed on any target supporting such operations.
9088 Standard numeric functions---e.g.@:, sin, log.
9090 Followed on any target supporting such operations.
9094 String manipulation operations---e.g.@:, translate and test.
9096 Followed on any target supporting such operations.
9100 Vector operations---e.g.@:, compare vector against thresholds.
9102 Followed on any target supporting such operations.
9106 Direct operations on I/O ports.
9108 Followed on any target supporting such operations.
9110 @cindex Interrupt support
9111 @unnumberedsec C.3(28): Interrupt Support
9114 If the @code{Ceiling_Locking} policy is not in effect, the
9115 implementation should provide means for the application to specify which
9116 interrupts are to be blocked during protected actions, if the underlying
9117 system allows for a finer-grain control of interrupt blocking.
9119 Followed. The underlying system does not allow for finer-grain control
9120 of interrupt blocking.
9122 @cindex Protected procedure handlers
9123 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
9126 Whenever possible, the implementation should allow interrupt handlers to
9127 be called directly by the hardware.
9129 Followed on any target where the underlying operating system permits
9134 Whenever practical, violations of any
9135 implementation-defined restrictions should be detected before run time.
9137 Followed. Compile time warnings are given when possible.
9139 @cindex Package @code{Interrupts}
9141 @unnumberedsec C.3.2(25): Package @code{Interrupts}
9145 If implementation-defined forms of interrupt handler procedures are
9146 supported, such as protected procedures with parameters, then for each
9147 such form of a handler, a type analogous to @code{Parameterless_Handler}
9148 should be specified in a child package of @code{Interrupts}, with the
9149 same operations as in the predefined package Interrupts.
9153 @cindex Pre-elaboration requirements
9154 @unnumberedsec C.4(14): Pre-elaboration Requirements
9157 It is recommended that pre-elaborated packages be implemented in such a
9158 way that there should be little or no code executed at run time for the
9159 elaboration of entities not already covered by the Implementation
9162 Followed. Executable code is generated in some cases, e.g.@: loops
9163 to initialize large arrays.
9165 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
9168 If the pragma applies to an entity, then the implementation should
9169 reduce the amount of storage used for storing names associated with that
9174 @cindex Package @code{Task_Attributes}
9175 @findex Task_Attributes
9176 @unnumberedsec C.7.2(30): The Package Task_Attributes
9179 Some implementations are targeted to domains in which memory use at run
9180 time must be completely deterministic. For such implementations, it is
9181 recommended that the storage for task attributes will be pre-allocated
9182 statically and not from the heap. This can be accomplished by either
9183 placing restrictions on the number and the size of the task's
9184 attributes, or by using the pre-allocated storage for the first @var{N}
9185 attribute objects, and the heap for the others. In the latter case,
9186 @var{N} should be documented.
9188 Not followed. This implementation is not targeted to such a domain.
9190 @cindex Locking Policies
9191 @unnumberedsec D.3(17): Locking Policies
9195 The implementation should use names that end with @samp{_Locking} for
9196 locking policies defined by the implementation.
9198 Followed. Two implementation-defined locking policies are defined,
9199 whose names (@code{Inheritance_Locking} and
9200 @code{Concurrent_Readers_Locking}) follow this suggestion.
9202 @cindex Entry queuing policies
9203 @unnumberedsec D.4(16): Entry Queuing Policies
9206 Names that end with @samp{_Queuing} should be used
9207 for all implementation-defined queuing policies.
9209 Followed. No such implementation-defined queuing policies exist.
9211 @cindex Preemptive abort
9212 @unnumberedsec D.6(9-10): Preemptive Abort
9215 Even though the @code{abort_statement} is included in the list of
9216 potentially blocking operations (see 9.5.1), it is recommended that this
9217 statement be implemented in a way that never requires the task executing
9218 the @code{abort_statement} to block.
9224 On a multi-processor, the delay associated with aborting a task on
9225 another processor should be bounded; the implementation should use
9226 periodic polling, if necessary, to achieve this.
9230 @cindex Tasking restrictions
9231 @unnumberedsec D.7(21): Tasking Restrictions
9234 When feasible, the implementation should take advantage of the specified
9235 restrictions to produce a more efficient implementation.
9237 GNAT currently takes advantage of these restrictions by providing an optimized
9238 run time when the Ravenscar profile and the GNAT restricted run time set
9239 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
9240 pragma @code{Profile (Restricted)} for more details.
9242 @cindex Time, monotonic
9243 @unnumberedsec D.8(47-49): Monotonic Time
9246 When appropriate, implementations should provide configuration
9247 mechanisms to change the value of @code{Tick}.
9249 Such configuration mechanisms are not appropriate to this implementation
9250 and are thus not supported.
9254 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
9255 be implemented as transformations of the same time base.
9261 It is recommended that the @dfn{best} time base which exists in
9262 the underlying system be available to the application through
9263 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
9267 @cindex Partition communication subsystem
9269 @unnumberedsec E.5(28-29): Partition Communication Subsystem
9272 Whenever possible, the PCS on the called partition should allow for
9273 multiple tasks to call the RPC-receiver with different messages and
9274 should allow them to block until the corresponding subprogram body
9277 Followed by GLADE, a separately supplied PCS that can be used with
9282 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
9283 should raise @code{Storage_Error} if it runs out of space trying to
9284 write the @code{Item} into the stream.
9286 Followed by GLADE, a separately supplied PCS that can be used with
9289 @cindex COBOL support
9290 @unnumberedsec F(7): COBOL Support
9293 If COBOL (respectively, C) is widely supported in the target
9294 environment, implementations supporting the Information Systems Annex
9295 should provide the child package @code{Interfaces.COBOL} (respectively,
9296 @code{Interfaces.C}) specified in Annex B and should support a
9297 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
9298 pragmas (see Annex B), thus allowing Ada programs to interface with
9299 programs written in that language.
9303 @cindex Decimal radix support
9304 @unnumberedsec F.1(2): Decimal Radix Support
9307 Packed decimal should be used as the internal representation for objects
9308 of subtype @var{S} when @var{S}'Machine_Radix = 10.
9310 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
9314 @unnumberedsec G: Numerics
9317 If Fortran (respectively, C) is widely supported in the target
9318 environment, implementations supporting the Numerics Annex
9319 should provide the child package @code{Interfaces.Fortran} (respectively,
9320 @code{Interfaces.C}) specified in Annex B and should support a
9321 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
9322 pragmas (see Annex B), thus allowing Ada programs to interface with
9323 programs written in that language.
9327 @cindex Complex types
9328 @unnumberedsec G.1.1(56-58): Complex Types
9331 Because the usual mathematical meaning of multiplication of a complex
9332 operand and a real operand is that of the scaling of both components of
9333 the former by the latter, an implementation should not perform this
9334 operation by first promoting the real operand to complex type and then
9335 performing a full complex multiplication. In systems that, in the
9336 future, support an Ada binding to IEC 559:1989, the latter technique
9337 will not generate the required result when one of the components of the
9338 complex operand is infinite. (Explicit multiplication of the infinite
9339 component by the zero component obtained during promotion yields a NaN
9340 that propagates into the final result.) Analogous advice applies in the
9341 case of multiplication of a complex operand and a pure-imaginary
9342 operand, and in the case of division of a complex operand by a real or
9343 pure-imaginary operand.
9349 Similarly, because the usual mathematical meaning of addition of a
9350 complex operand and a real operand is that the imaginary operand remains
9351 unchanged, an implementation should not perform this operation by first
9352 promoting the real operand to complex type and then performing a full
9353 complex addition. In implementations in which the @code{Signed_Zeros}
9354 attribute of the component type is @code{True} (and which therefore
9355 conform to IEC 559:1989 in regard to the handling of the sign of zero in
9356 predefined arithmetic operations), the latter technique will not
9357 generate the required result when the imaginary component of the complex
9358 operand is a negatively signed zero. (Explicit addition of the negative
9359 zero to the zero obtained during promotion yields a positive zero.)
9360 Analogous advice applies in the case of addition of a complex operand
9361 and a pure-imaginary operand, and in the case of subtraction of a
9362 complex operand and a real or pure-imaginary operand.
9368 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
9369 attempt to provide a rational treatment of the signs of zero results and
9370 result components. As one example, the result of the @code{Argument}
9371 function should have the sign of the imaginary component of the
9372 parameter @code{X} when the point represented by that parameter lies on
9373 the positive real axis; as another, the sign of the imaginary component
9374 of the @code{Compose_From_Polar} function should be the same as
9375 (respectively, the opposite of) that of the @code{Argument} parameter when that
9376 parameter has a value of zero and the @code{Modulus} parameter has a
9377 nonnegative (respectively, negative) value.
9381 @cindex Complex elementary functions
9382 @unnumberedsec G.1.2(49): Complex Elementary Functions
9385 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
9386 @code{True} should attempt to provide a rational treatment of the signs
9387 of zero results and result components. For example, many of the complex
9388 elementary functions have components that are odd functions of one of
9389 the parameter components; in these cases, the result component should
9390 have the sign of the parameter component at the origin. Other complex
9391 elementary functions have zero components whose sign is opposite that of
9392 a parameter component at the origin, or is always positive or always
9397 @cindex Accuracy requirements
9398 @unnumberedsec G.2.4(19): Accuracy Requirements
9401 The versions of the forward trigonometric functions without a
9402 @code{Cycle} parameter should not be implemented by calling the
9403 corresponding version with a @code{Cycle} parameter of
9404 @code{2.0*Numerics.Pi}, since this will not provide the required
9405 accuracy in some portions of the domain. For the same reason, the
9406 version of @code{Log} without a @code{Base} parameter should not be
9407 implemented by calling the corresponding version with a @code{Base}
9408 parameter of @code{Numerics.e}.
9412 @cindex Complex arithmetic accuracy
9413 @cindex Accuracy, complex arithmetic
9414 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
9418 The version of the @code{Compose_From_Polar} function without a
9419 @code{Cycle} parameter should not be implemented by calling the
9420 corresponding version with a @code{Cycle} parameter of
9421 @code{2.0*Numerics.Pi}, since this will not provide the required
9422 accuracy in some portions of the domain.
9426 @c -----------------------------------------
9427 @node Implementation Defined Characteristics
9428 @chapter Implementation Defined Characteristics
9431 In addition to the implementation dependent pragmas and attributes, and the
9432 implementation advice, there are a number of other Ada features that are
9433 potentially implementation dependent and are designated as
9434 implementation-defined. These are mentioned throughout the Ada Reference
9435 Manual, and are summarized in Annex M@.
9437 A requirement for conforming Ada compilers is that they provide
9438 documentation describing how the implementation deals with each of these
9439 issues. In this chapter, you will find each point in Annex M listed
9440 followed by a description in italic font of how GNAT
9441 handles the implementation dependence.
9443 You can use this chapter as a guide to minimizing implementation
9444 dependent features in your programs if portability to other compilers
9445 and other operating systems is an important consideration. The numbers
9446 in each section below correspond to the paragraph number in the Ada
9452 @strong{2}. Whether or not each recommendation given in Implementation
9453 Advice is followed. See 1.1.2(37).
9456 @xref{Implementation Advice}.
9461 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
9464 The complexity of programs that can be processed is limited only by the
9465 total amount of available virtual memory, and disk space for the
9466 generated object files.
9471 @strong{4}. Variations from the standard that are impractical to avoid
9472 given the implementation's execution environment. See 1.1.3(6).
9475 There are no variations from the standard.
9480 @strong{5}. Which @code{code_statement}s cause external
9481 interactions. See 1.1.3(10).
9484 Any @code{code_statement} can potentially cause external interactions.
9489 @strong{6}. The coded representation for the text of an Ada
9490 program. See 2.1(4).
9493 See separate section on source representation.
9498 @strong{7}. The control functions allowed in comments. See 2.1(14).
9501 See separate section on source representation.
9506 @strong{8}. The representation for an end of line. See 2.2(2).
9509 See separate section on source representation.
9514 @strong{9}. Maximum supported line length and lexical element
9515 length. See 2.2(15).
9518 The maximum line length is 255 characters and the maximum length of a
9519 lexical element is also 255 characters.
9524 @strong{10}. Implementation defined pragmas. See 2.8(14).
9528 @xref{Implementation Defined Pragmas}.
9533 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
9536 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
9537 parameter, checks that the optimization flag is set, and aborts if it is
9543 @strong{12}. The sequence of characters of the value returned by
9544 @code{@var{S}'Image} when some of the graphic characters of
9545 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
9549 The sequence of characters is as defined by the wide character encoding
9550 method used for the source. See section on source representation for
9556 @strong{13}. The predefined integer types declared in
9557 @code{Standard}. See 3.5.4(25).
9561 @item Short_Short_Integer
9564 (Short) 16 bit signed
9568 64 bit signed (on most 64 bit targets, depending on the C definition of long).
9569 32 bit signed (all other targets)
9570 @item Long_Long_Integer
9577 @strong{14}. Any nonstandard integer types and the operators defined
9578 for them. See 3.5.4(26).
9581 There are no nonstandard integer types.
9586 @strong{15}. Any nonstandard real types and the operators defined for
9590 There are no nonstandard real types.
9595 @strong{16}. What combinations of requested decimal precision and range
9596 are supported for floating point types. See 3.5.7(7).
9599 The precision and range is as defined by the IEEE standard.
9604 @strong{17}. The predefined floating point types declared in
9605 @code{Standard}. See 3.5.7(16).
9612 (Short) 32 bit IEEE short
9615 @item Long_Long_Float
9616 64 bit IEEE long (80 bit IEEE long on x86 processors)
9622 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
9625 @code{Fine_Delta} is 2**(@minus{}63)
9630 @strong{19}. What combinations of small, range, and digits are
9631 supported for fixed point types. See 3.5.9(10).
9634 Any combinations are permitted that do not result in a small less than
9635 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
9636 If the mantissa is larger than 53 bits on machines where Long_Long_Float
9637 is 64 bits (true of all architectures except ia32), then the output from
9638 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
9639 is because floating-point conversions are used to convert fixed point.
9644 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
9645 within an unnamed @code{block_statement}. See 3.9(10).
9648 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
9649 decimal integer are allocated.
9654 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
9657 @xref{Implementation Defined Attributes}.
9662 @strong{22}. Any implementation-defined time types. See 9.6(6).
9665 There are no implementation-defined time types.
9670 @strong{23}. The time base associated with relative delays.
9673 See 9.6(20). The time base used is that provided by the C library
9674 function @code{gettimeofday}.
9679 @strong{24}. The time base of the type @code{Calendar.Time}. See
9683 The time base used is that provided by the C library function
9684 @code{gettimeofday}.
9689 @strong{25}. The time zone used for package @code{Calendar}
9690 operations. See 9.6(24).
9693 The time zone used by package @code{Calendar} is the current system time zone
9694 setting for local time, as accessed by the C library function
9700 @strong{26}. Any limit on @code{delay_until_statements} of
9701 @code{select_statements}. See 9.6(29).
9704 There are no such limits.
9709 @strong{27}. Whether or not two non-overlapping parts of a composite
9710 object are independently addressable, in the case where packing, record
9711 layout, or @code{Component_Size} is specified for the object. See
9715 Separate components are independently addressable if they do not share
9716 overlapping storage units.
9721 @strong{28}. The representation for a compilation. See 10.1(2).
9724 A compilation is represented by a sequence of files presented to the
9725 compiler in a single invocation of the @command{gcc} command.
9730 @strong{29}. Any restrictions on compilations that contain multiple
9731 compilation_units. See 10.1(4).
9734 No single file can contain more than one compilation unit, but any
9735 sequence of files can be presented to the compiler as a single
9741 @strong{30}. The mechanisms for creating an environment and for adding
9742 and replacing compilation units. See 10.1.4(3).
9745 See separate section on compilation model.
9750 @strong{31}. The manner of explicitly assigning library units to a
9751 partition. See 10.2(2).
9754 If a unit contains an Ada main program, then the Ada units for the partition
9755 are determined by recursive application of the rules in the Ada Reference
9756 Manual section 10.2(2-6). In other words, the Ada units will be those that
9757 are needed by the main program, and then this definition of need is applied
9758 recursively to those units, and the partition contains the transitive
9759 closure determined by this relationship. In short, all the necessary units
9760 are included, with no need to explicitly specify the list. If additional
9761 units are required, e.g.@: by foreign language units, then all units must be
9762 mentioned in the context clause of one of the needed Ada units.
9764 If the partition contains no main program, or if the main program is in
9765 a language other than Ada, then GNAT
9766 provides the binder options @option{-z} and @option{-n} respectively, and in
9767 this case a list of units can be explicitly supplied to the binder for
9768 inclusion in the partition (all units needed by these units will also
9769 be included automatically). For full details on the use of these
9770 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
9771 @value{EDITION} User's Guide}.
9776 @strong{32}. The implementation-defined means, if any, of specifying
9777 which compilation units are needed by a given compilation unit. See
9781 The units needed by a given compilation unit are as defined in
9782 the Ada Reference Manual section 10.2(2-6). There are no
9783 implementation-defined pragmas or other implementation-defined
9784 means for specifying needed units.
9789 @strong{33}. The manner of designating the main subprogram of a
9790 partition. See 10.2(7).
9793 The main program is designated by providing the name of the
9794 corresponding @file{ALI} file as the input parameter to the binder.
9799 @strong{34}. The order of elaboration of @code{library_items}. See
9803 The first constraint on ordering is that it meets the requirements of
9804 Chapter 10 of the Ada Reference Manual. This still leaves some
9805 implementation dependent choices, which are resolved by first
9806 elaborating bodies as early as possible (i.e., in preference to specs
9807 where there is a choice), and second by evaluating the immediate with
9808 clauses of a unit to determine the probably best choice, and
9809 third by elaborating in alphabetical order of unit names
9810 where a choice still remains.
9815 @strong{35}. Parameter passing and function return for the main
9816 subprogram. See 10.2(21).
9819 The main program has no parameters. It may be a procedure, or a function
9820 returning an integer type. In the latter case, the returned integer
9821 value is the return code of the program (overriding any value that
9822 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
9827 @strong{36}. The mechanisms for building and running partitions. See
9831 GNAT itself supports programs with only a single partition. The GNATDIST
9832 tool provided with the GLADE package (which also includes an implementation
9833 of the PCS) provides a completely flexible method for building and running
9834 programs consisting of multiple partitions. See the separate GLADE manual
9840 @strong{37}. The details of program execution, including program
9841 termination. See 10.2(25).
9844 See separate section on compilation model.
9849 @strong{38}. The semantics of any non-active partitions supported by the
9850 implementation. See 10.2(28).
9853 Passive partitions are supported on targets where shared memory is
9854 provided by the operating system. See the GLADE reference manual for
9860 @strong{39}. The information returned by @code{Exception_Message}. See
9864 Exception message returns the null string unless a specific message has
9865 been passed by the program.
9870 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
9871 declared within an unnamed @code{block_statement}. See 11.4.1(12).
9874 Blocks have implementation defined names of the form @code{B@var{nnn}}
9875 where @var{nnn} is an integer.
9880 @strong{41}. The information returned by
9881 @code{Exception_Information}. See 11.4.1(13).
9884 @code{Exception_Information} returns a string in the following format:
9887 @emph{Exception_Name:} nnnnn
9888 @emph{Message:} mmmmm
9890 @emph{Call stack traceback locations:}
9891 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
9899 @code{nnnn} is the fully qualified name of the exception in all upper
9900 case letters. This line is always present.
9903 @code{mmmm} is the message (this line present only if message is non-null)
9906 @code{ppp} is the Process Id value as a decimal integer (this line is
9907 present only if the Process Id is nonzero). Currently we are
9908 not making use of this field.
9911 The Call stack traceback locations line and the following values
9912 are present only if at least one traceback location was recorded.
9913 The values are given in C style format, with lower case letters
9914 for a-f, and only as many digits present as are necessary.
9918 The line terminator sequence at the end of each line, including
9919 the last line is a single @code{LF} character (@code{16#0A#}).
9924 @strong{42}. Implementation-defined check names. See 11.5(27).
9927 The implementation defined check name Alignment_Check controls checking of
9928 address clause values for proper alignment (that is, the address supplied
9929 must be consistent with the alignment of the type).
9931 In addition, a user program can add implementation-defined check names
9932 by means of the pragma Check_Name.
9937 @strong{43}. The interpretation of each aspect of representation. See
9941 See separate section on data representations.
9946 @strong{44}. Any restrictions placed upon representation items. See
9950 See separate section on data representations.
9955 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
9959 Size for an indefinite subtype is the maximum possible size, except that
9960 for the case of a subprogram parameter, the size of the parameter object
9966 @strong{46}. The default external representation for a type tag. See
9970 The default external representation for a type tag is the fully expanded
9971 name of the type in upper case letters.
9976 @strong{47}. What determines whether a compilation unit is the same in
9977 two different partitions. See 13.3(76).
9980 A compilation unit is the same in two different partitions if and only
9981 if it derives from the same source file.
9986 @strong{48}. Implementation-defined components. See 13.5.1(15).
9989 The only implementation defined component is the tag for a tagged type,
9990 which contains a pointer to the dispatching table.
9995 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
9996 ordering. See 13.5.3(5).
9999 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
10000 implementation, so no non-default bit ordering is supported. The default
10001 bit ordering corresponds to the natural endianness of the target architecture.
10006 @strong{50}. The contents of the visible part of package @code{System}
10007 and its language-defined children. See 13.7(2).
10010 See the definition of these packages in files @file{system.ads} and
10011 @file{s-stoele.ads}.
10016 @strong{51}. The contents of the visible part of package
10017 @code{System.Machine_Code}, and the meaning of
10018 @code{code_statements}. See 13.8(7).
10021 See the definition and documentation in file @file{s-maccod.ads}.
10026 @strong{52}. The effect of unchecked conversion. See 13.9(11).
10029 Unchecked conversion between types of the same size
10030 results in an uninterpreted transmission of the bits from one type
10031 to the other. If the types are of unequal sizes, then in the case of
10032 discrete types, a shorter source is first zero or sign extended as
10033 necessary, and a shorter target is simply truncated on the left.
10034 For all non-discrete types, the source is first copied if necessary
10035 to ensure that the alignment requirements of the target are met, then
10036 a pointer is constructed to the source value, and the result is obtained
10037 by dereferencing this pointer after converting it to be a pointer to the
10038 target type. Unchecked conversions where the target subtype is an
10039 unconstrained array are not permitted. If the target alignment is
10040 greater than the source alignment, then a copy of the result is
10041 made with appropriate alignment
10046 @strong{53}. The semantics of operations on invalid representations.
10050 For assignments and other operations where the use of invalid values cannot
10051 result in erroneous behavior, the compiler ignores the possibility of invalid
10052 values. An exception is raised at the point where an invalid value would
10053 result in erroneous behavior. For example executing:
10055 @smallexample @c ada
10056 procedure invalidvals is
10058 Y : Natural range 1 .. 10;
10059 for Y'Address use X'Address;
10060 Z : Natural range 1 .. 10;
10061 A : array (Natural range 1 .. 10) of Integer;
10063 Z := Y; -- no exception
10064 A (Z) := 3; -- exception raised;
10069 As indicated, an exception is raised on the array assignment, but not
10070 on the simple assignment of the invalid negative value from Y to Z.
10075 @strong{53}. The manner of choosing a storage pool for an access type
10076 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
10079 There are 3 different standard pools used by the compiler when
10080 @code{Storage_Pool} is not specified depending whether the type is local
10081 to a subprogram or defined at the library level and whether
10082 @code{Storage_Size}is specified or not. See documentation in the runtime
10083 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
10084 @code{System.Pool_Local} in files @file{s-poosiz.ads},
10085 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
10086 default pools used.
10091 @strong{54}. Whether or not the implementation provides user-accessible
10092 names for the standard pool type(s). See 13.11(17).
10096 See documentation in the sources of the run time mentioned in paragraph
10097 @strong{53} . All these pools are accessible by means of @code{with}'ing
10103 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
10106 @code{Storage_Size} is measured in storage units, and refers to the
10107 total space available for an access type collection, or to the primary
10108 stack space for a task.
10113 @strong{56}. Implementation-defined aspects of storage pools. See
10117 See documentation in the sources of the run time mentioned in paragraph
10118 @strong{53} for details on GNAT-defined aspects of storage pools.
10123 @strong{57}. The set of restrictions allowed in a pragma
10124 @code{Restrictions}. See 13.12(7).
10127 @xref{Standard and Implementation Defined Restrictions}.
10132 @strong{58}. The consequences of violating limitations on
10133 @code{Restrictions} pragmas. See 13.12(9).
10136 Restrictions that can be checked at compile time result in illegalities
10137 if violated. Currently there are no other consequences of violating
10143 @strong{59}. The representation used by the @code{Read} and
10144 @code{Write} attributes of elementary types in terms of stream
10145 elements. See 13.13.2(9).
10148 The representation is the in-memory representation of the base type of
10149 the type, using the number of bits corresponding to the
10150 @code{@var{type}'Size} value, and the natural ordering of the machine.
10155 @strong{60}. The names and characteristics of the numeric subtypes
10156 declared in the visible part of package @code{Standard}. See A.1(3).
10159 See items describing the integer and floating-point types supported.
10164 @strong{61}. The accuracy actually achieved by the elementary
10165 functions. See A.5.1(1).
10168 The elementary functions correspond to the functions available in the C
10169 library. Only fast math mode is implemented.
10174 @strong{62}. The sign of a zero result from some of the operators or
10175 functions in @code{Numerics.Generic_Elementary_Functions}, when
10176 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
10179 The sign of zeroes follows the requirements of the IEEE 754 standard on
10185 @strong{63}. The value of
10186 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
10189 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10194 @strong{64}. The value of
10195 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
10198 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10203 @strong{65}. The algorithms for random number generation. See
10207 The algorithm is the Mersenne Twister, as documented in the source file
10208 @file{s-rannum.adb}. This version of the algorithm has a period of
10214 @strong{66}. The string representation of a random number generator's
10215 state. See A.5.2(38).
10218 The value returned by the Image function is the concatenation of
10219 the fixed-width decimal representations of the 624 32-bit integers
10220 of the state vector.
10225 @strong{67}. The minimum time interval between calls to the
10226 time-dependent Reset procedure that are guaranteed to initiate different
10227 random number sequences. See A.5.2(45).
10230 The minimum period between reset calls to guarantee distinct series of
10231 random numbers is one microsecond.
10236 @strong{68}. The values of the @code{Model_Mantissa},
10237 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
10238 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
10239 Annex is not supported. See A.5.3(72).
10242 Run the compiler with @option{-gnatS} to produce a listing of package
10243 @code{Standard}, has the values of all numeric attributes.
10248 @strong{69}. Any implementation-defined characteristics of the
10249 input-output packages. See A.7(14).
10252 There are no special implementation defined characteristics for these
10258 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
10262 All type representations are contiguous, and the @code{Buffer_Size} is
10263 the value of @code{@var{type}'Size} rounded up to the next storage unit
10269 @strong{71}. External files for standard input, standard output, and
10270 standard error See A.10(5).
10273 These files are mapped onto the files provided by the C streams
10274 libraries. See source file @file{i-cstrea.ads} for further details.
10279 @strong{72}. The accuracy of the value produced by @code{Put}. See
10283 If more digits are requested in the output than are represented by the
10284 precision of the value, zeroes are output in the corresponding least
10285 significant digit positions.
10290 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
10291 @code{Command_Name}. See A.15(1).
10294 These are mapped onto the @code{argv} and @code{argc} parameters of the
10295 main program in the natural manner.
10300 @strong{74}. The interpretation of the @code{Form} parameter in procedure
10301 @code{Create_Directory}. See A.16(56).
10304 The @code{Form} parameter is not used.
10309 @strong{75}. The interpretation of the @code{Form} parameter in procedure
10310 @code{Create_Path}. See A.16(60).
10313 The @code{Form} parameter is not used.
10318 @strong{76}. The interpretation of the @code{Form} parameter in procedure
10319 @code{Copy_File}. See A.16(68).
10322 The @code{Form} parameter is case-insensitive.
10324 Two fields are recognized in the @code{Form} parameter:
10328 @item preserve=<value>
10335 <value> starts immediately after the character '=' and ends with the
10336 character immediately preceding the next comma (',') or with the last
10337 character of the parameter.
10339 The only possible values for preserve= are:
10343 @item no_attributes
10344 Do not try to preserve any file attributes. This is the default if no
10345 preserve= is found in Form.
10347 @item all_attributes
10348 Try to preserve all file attributes (timestamps, access rights).
10351 Preserve the timestamp of the copied file, but not the other file attributes.
10356 The only possible values for mode= are:
10361 Only do the copy if the destination file does not already exist. If it already
10362 exists, Copy_File fails.
10365 Copy the file in all cases. Overwrite an already existing destination file.
10368 Append the original file to the destination file. If the destination file does
10369 not exist, the destination file is a copy of the source file. When mode=append,
10370 the field preserve=, if it exists, is not taken into account.
10375 If the Form parameter includes one or both of the fields and the value or
10376 values are incorrect, Copy_file fails with Use_Error.
10378 Examples of correct Forms:
10381 Form => "preserve=no_attributes,mode=overwrite" (the default)
10382 Form => "mode=append"
10383 Form => "mode=copy, preserve=all_attributes"
10387 Examples of incorrect Forms
10390 Form => "preserve=junk"
10391 Form => "mode=internal, preserve=timestamps"
10397 @strong{77}. Implementation-defined convention names. See B.1(11).
10400 The following convention names are supported
10405 @item Ada_Pass_By_Copy
10406 Allowed for any types except by-reference types such as limited
10407 records. Compatible with convention Ada, but causes any parameters
10408 with this convention to be passed by copy.
10409 @item Ada_Pass_By_Reference
10410 Allowed for any types except by-copy types such as scalars.
10411 Compatible with convention Ada, but causes any parameters
10412 with this convention to be passed by reference.
10416 Synonym for Assembler
10418 Synonym for Assembler
10421 @item C_Pass_By_Copy
10422 Allowed only for record types, like C, but also notes that record
10423 is to be passed by copy rather than reference.
10426 @item C_Plus_Plus (or CPP)
10429 Treated the same as C
10431 Treated the same as C
10435 For support of pragma @code{Import} with convention Intrinsic, see
10436 separate section on Intrinsic Subprograms.
10438 Stdcall (used for Windows implementations only). This convention correspond
10439 to the WINAPI (previously called Pascal convention) C/C++ convention under
10440 Windows. A routine with this convention cleans the stack before
10441 exit. This pragma cannot be applied to a dispatching call.
10443 Synonym for Stdcall
10445 Synonym for Stdcall
10447 Stubbed is a special convention used to indicate that the body of the
10448 subprogram will be entirely ignored. Any call to the subprogram
10449 is converted into a raise of the @code{Program_Error} exception. If a
10450 pragma @code{Import} specifies convention @code{stubbed} then no body need
10451 be present at all. This convention is useful during development for the
10452 inclusion of subprograms whose body has not yet been written.
10456 In addition, all otherwise unrecognized convention names are also
10457 treated as being synonymous with convention C@. In all implementations
10458 except for VMS, use of such other names results in a warning. In VMS
10459 implementations, these names are accepted silently.
10464 @strong{78}. The meaning of link names. See B.1(36).
10467 Link names are the actual names used by the linker.
10472 @strong{79}. The manner of choosing link names when neither the link
10473 name nor the address of an imported or exported entity is specified. See
10477 The default linker name is that which would be assigned by the relevant
10478 external language, interpreting the Ada name as being in all lower case
10484 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
10487 The string passed to @code{Linker_Options} is presented uninterpreted as
10488 an argument to the link command, unless it contains ASCII.NUL characters.
10489 NUL characters if they appear act as argument separators, so for example
10491 @smallexample @c ada
10492 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
10496 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
10497 linker. The order of linker options is preserved for a given unit. The final
10498 list of options passed to the linker is in reverse order of the elaboration
10499 order. For example, linker options for a body always appear before the options
10500 from the corresponding package spec.
10505 @strong{81}. The contents of the visible part of package
10506 @code{Interfaces} and its language-defined descendants. See B.2(1).
10509 See files with prefix @file{i-} in the distributed library.
10514 @strong{82}. Implementation-defined children of package
10515 @code{Interfaces}. The contents of the visible part of package
10516 @code{Interfaces}. See B.2(11).
10519 See files with prefix @file{i-} in the distributed library.
10524 @strong{83}. The types @code{Floating}, @code{Long_Floating},
10525 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
10526 @code{COBOL_Character}; and the initialization of the variables
10527 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
10528 @code{Interfaces.COBOL}. See B.4(50).
10534 @item Long_Floating
10535 (Floating) Long_Float
10540 @item Decimal_Element
10542 @item COBOL_Character
10547 For initialization, see the file @file{i-cobol.ads} in the distributed library.
10552 @strong{84}. Support for access to machine instructions. See C.1(1).
10555 See documentation in file @file{s-maccod.ads} in the distributed library.
10560 @strong{85}. Implementation-defined aspects of access to machine
10561 operations. See C.1(9).
10564 See documentation in file @file{s-maccod.ads} in the distributed library.
10569 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
10572 Interrupts are mapped to signals or conditions as appropriate. See
10574 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
10575 on the interrupts supported on a particular target.
10580 @strong{87}. Implementation-defined aspects of pre-elaboration. See
10584 GNAT does not permit a partition to be restarted without reloading,
10585 except under control of the debugger.
10590 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
10593 Pragma @code{Discard_Names} causes names of enumeration literals to
10594 be suppressed. In the presence of this pragma, the Image attribute
10595 provides the image of the Pos of the literal, and Value accepts
10601 @strong{89}. The result of the @code{Task_Identification.Image}
10602 attribute. See C.7.1(7).
10605 The result of this attribute is a string that identifies
10606 the object or component that denotes a given task. If a variable @code{Var}
10607 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
10609 is the hexadecimal representation of the virtual address of the corresponding
10610 task control block. If the variable is an array of tasks, the image of each
10611 task will have the form of an indexed component indicating the position of a
10612 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
10613 component of a record, the image of the task will have the form of a selected
10614 component. These rules are fully recursive, so that the image of a task that
10615 is a subcomponent of a composite object corresponds to the expression that
10616 designates this task.
10618 If a task is created by an allocator, its image depends on the context. If the
10619 allocator is part of an object declaration, the rules described above are used
10620 to construct its image, and this image is not affected by subsequent
10621 assignments. If the allocator appears within an expression, the image
10622 includes only the name of the task type.
10624 If the configuration pragma Discard_Names is present, or if the restriction
10625 No_Implicit_Heap_Allocation is in effect, the image reduces to
10626 the numeric suffix, that is to say the hexadecimal representation of the
10627 virtual address of the control block of the task.
10631 @strong{90}. The value of @code{Current_Task} when in a protected entry
10632 or interrupt handler. See C.7.1(17).
10635 Protected entries or interrupt handlers can be executed by any
10636 convenient thread, so the value of @code{Current_Task} is undefined.
10641 @strong{91}. The effect of calling @code{Current_Task} from an entry
10642 body or interrupt handler. See C.7.1(19).
10645 The effect of calling @code{Current_Task} from an entry body or
10646 interrupt handler is to return the identification of the task currently
10647 executing the code.
10652 @strong{92}. Implementation-defined aspects of
10653 @code{Task_Attributes}. See C.7.2(19).
10656 There are no implementation-defined aspects of @code{Task_Attributes}.
10661 @strong{93}. Values of all @code{Metrics}. See D(2).
10664 The metrics information for GNAT depends on the performance of the
10665 underlying operating system. The sources of the run-time for tasking
10666 implementation, together with the output from @option{-gnatG} can be
10667 used to determine the exact sequence of operating systems calls made
10668 to implement various tasking constructs. Together with appropriate
10669 information on the performance of the underlying operating system,
10670 on the exact target in use, this information can be used to determine
10671 the required metrics.
10676 @strong{94}. The declarations of @code{Any_Priority} and
10677 @code{Priority}. See D.1(11).
10680 See declarations in file @file{system.ads}.
10685 @strong{95}. Implementation-defined execution resources. See D.1(15).
10688 There are no implementation-defined execution resources.
10693 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
10694 access to a protected object keeps its processor busy. See D.2.1(3).
10697 On a multi-processor, a task that is waiting for access to a protected
10698 object does not keep its processor busy.
10703 @strong{97}. The affect of implementation defined execution resources
10704 on task dispatching. See D.2.1(9).
10707 Tasks map to threads in the threads package used by GNAT@. Where possible
10708 and appropriate, these threads correspond to native threads of the
10709 underlying operating system.
10714 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
10715 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
10718 There are no implementation-defined policy-identifiers allowed in this
10724 @strong{99}. Implementation-defined aspects of priority inversion. See
10728 Execution of a task cannot be preempted by the implementation processing
10729 of delay expirations for lower priority tasks.
10734 @strong{100}. Implementation-defined task dispatching. See D.2.2(18).
10737 The policy is the same as that of the underlying threads implementation.
10742 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
10743 in a pragma @code{Locking_Policy}. See D.3(4).
10746 The two implementation defined policies permitted in GNAT are
10747 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
10748 targets that support the @code{Inheritance_Locking} policy, locking is
10749 implemented by inheritance, i.e.@: the task owning the lock operates
10750 at a priority equal to the highest priority of any task currently
10751 requesting the lock. On targets that support the
10752 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
10753 read/write lock allowing multiple propected object functions to enter
10759 @strong{102}. Default ceiling priorities. See D.3(10).
10762 The ceiling priority of protected objects of the type
10763 @code{System.Interrupt_Priority'Last} as described in the Ada
10764 Reference Manual D.3(10),
10769 @strong{103}. The ceiling of any protected object used internally by
10770 the implementation. See D.3(16).
10773 The ceiling priority of internal protected objects is
10774 @code{System.Priority'Last}.
10779 @strong{104}. Implementation-defined queuing policies. See D.4(1).
10782 There are no implementation-defined queuing policies.
10787 @strong{105}. On a multiprocessor, any conditions that cause the
10788 completion of an aborted construct to be delayed later than what is
10789 specified for a single processor. See D.6(3).
10792 The semantics for abort on a multi-processor is the same as on a single
10793 processor, there are no further delays.
10798 @strong{106}. Any operations that implicitly require heap storage
10799 allocation. See D.7(8).
10802 The only operation that implicitly requires heap storage allocation is
10808 @strong{107}. Implementation-defined aspects of pragma
10809 @code{Restrictions}. See D.7(20).
10812 There are no such implementation-defined aspects.
10817 @strong{108}. Implementation-defined aspects of package
10818 @code{Real_Time}. See D.8(17).
10821 There are no implementation defined aspects of package @code{Real_Time}.
10826 @strong{109}. Implementation-defined aspects of
10827 @code{delay_statements}. See D.9(8).
10830 Any difference greater than one microsecond will cause the task to be
10831 delayed (see D.9(7)).
10836 @strong{110}. The upper bound on the duration of interrupt blocking
10837 caused by the implementation. See D.12(5).
10840 The upper bound is determined by the underlying operating system. In
10841 no cases is it more than 10 milliseconds.
10846 @strong{111}. The means for creating and executing distributed
10847 programs. See E(5).
10850 The GLADE package provides a utility GNATDIST for creating and executing
10851 distributed programs. See the GLADE reference manual for further details.
10856 @strong{112}. Any events that can result in a partition becoming
10857 inaccessible. See E.1(7).
10860 See the GLADE reference manual for full details on such events.
10865 @strong{113}. The scheduling policies, treatment of priorities, and
10866 management of shared resources between partitions in certain cases. See
10870 See the GLADE reference manual for full details on these aspects of
10871 multi-partition execution.
10876 @strong{114}. Events that cause the version of a compilation unit to
10877 change. See E.3(5).
10880 Editing the source file of a compilation unit, or the source files of
10881 any units on which it is dependent in a significant way cause the version
10882 to change. No other actions cause the version number to change. All changes
10883 are significant except those which affect only layout, capitalization or
10889 @strong{115}. Whether the execution of the remote subprogram is
10890 immediately aborted as a result of cancellation. See E.4(13).
10893 See the GLADE reference manual for details on the effect of abort in
10894 a distributed application.
10899 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
10902 See the GLADE reference manual for a full description of all implementation
10903 defined aspects of the PCS@.
10908 @strong{117}. Implementation-defined interfaces in the PCS@. See
10912 See the GLADE reference manual for a full description of all
10913 implementation defined interfaces.
10918 @strong{118}. The values of named numbers in the package
10919 @code{Decimal}. See F.2(7).
10931 @item Max_Decimal_Digits
10938 @strong{119}. The value of @code{Max_Picture_Length} in the package
10939 @code{Text_IO.Editing}. See F.3.3(16).
10947 @strong{120}. The value of @code{Max_Picture_Length} in the package
10948 @code{Wide_Text_IO.Editing}. See F.3.4(5).
10956 @strong{121}. The accuracy actually achieved by the complex elementary
10957 functions and by other complex arithmetic operations. See G.1(1).
10960 Standard library functions are used for the complex arithmetic
10961 operations. Only fast math mode is currently supported.
10966 @strong{122}. The sign of a zero result (or a component thereof) from
10967 any operator or function in @code{Numerics.Generic_Complex_Types}, when
10968 @code{Real'Signed_Zeros} is True. See G.1.1(53).
10971 The signs of zero values are as recommended by the relevant
10972 implementation advice.
10977 @strong{123}. The sign of a zero result (or a component thereof) from
10978 any operator or function in
10979 @code{Numerics.Generic_Complex_Elementary_Functions}, when
10980 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
10983 The signs of zero values are as recommended by the relevant
10984 implementation advice.
10989 @strong{124}. Whether the strict mode or the relaxed mode is the
10990 default. See G.2(2).
10993 The strict mode is the default. There is no separate relaxed mode. GNAT
10994 provides a highly efficient implementation of strict mode.
10999 @strong{125}. The result interval in certain cases of fixed-to-float
11000 conversion. See G.2.1(10).
11003 For cases where the result interval is implementation dependent, the
11004 accuracy is that provided by performing all operations in 64-bit IEEE
11005 floating-point format.
11010 @strong{126}. The result of a floating point arithmetic operation in
11011 overflow situations, when the @code{Machine_Overflows} attribute of the
11012 result type is @code{False}. See G.2.1(13).
11015 Infinite and NaN values are produced as dictated by the IEEE
11016 floating-point standard.
11018 Note that on machines that are not fully compliant with the IEEE
11019 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
11020 must be used for achieving IEEE conforming behavior (although at the cost
11021 of a significant performance penalty), so infinite and NaN values are
11022 properly generated.
11027 @strong{127}. The result interval for division (or exponentiation by a
11028 negative exponent), when the floating point hardware implements division
11029 as multiplication by a reciprocal. See G.2.1(16).
11032 Not relevant, division is IEEE exact.
11037 @strong{128}. The definition of close result set, which determines the
11038 accuracy of certain fixed point multiplications and divisions. See
11042 Operations in the close result set are performed using IEEE long format
11043 floating-point arithmetic. The input operands are converted to
11044 floating-point, the operation is done in floating-point, and the result
11045 is converted to the target type.
11050 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
11051 point multiplication or division for which the result shall be in the
11052 perfect result set. See G.2.3(22).
11055 The result is only defined to be in the perfect result set if the result
11056 can be computed by a single scaling operation involving a scale factor
11057 representable in 64-bits.
11062 @strong{130}. The result of a fixed point arithmetic operation in
11063 overflow situations, when the @code{Machine_Overflows} attribute of the
11064 result type is @code{False}. See G.2.3(27).
11067 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
11073 @strong{131}. The result of an elementary function reference in
11074 overflow situations, when the @code{Machine_Overflows} attribute of the
11075 result type is @code{False}. See G.2.4(4).
11078 IEEE infinite and Nan values are produced as appropriate.
11083 @strong{132}. The value of the angle threshold, within which certain
11084 elementary functions, complex arithmetic operations, and complex
11085 elementary functions yield results conforming to a maximum relative
11086 error bound. See G.2.4(10).
11089 Information on this subject is not yet available.
11094 @strong{133}. The accuracy of certain elementary functions for
11095 parameters beyond the angle threshold. See G.2.4(10).
11098 Information on this subject is not yet available.
11103 @strong{134}. The result of a complex arithmetic operation or complex
11104 elementary function reference in overflow situations, when the
11105 @code{Machine_Overflows} attribute of the corresponding real type is
11106 @code{False}. See G.2.6(5).
11109 IEEE infinite and Nan values are produced as appropriate.
11114 @strong{135}. The accuracy of certain complex arithmetic operations and
11115 certain complex elementary functions for parameters (or components
11116 thereof) beyond the angle threshold. See G.2.6(8).
11119 Information on those subjects is not yet available.
11124 @strong{136}. Information regarding bounded errors and erroneous
11125 execution. See H.2(1).
11128 Information on this subject is not yet available.
11133 @strong{137}. Implementation-defined aspects of pragma
11134 @code{Inspection_Point}. See H.3.2(8).
11137 Pragma @code{Inspection_Point} ensures that the variable is live and can
11138 be examined by the debugger at the inspection point.
11143 @strong{138}. Implementation-defined aspects of pragma
11144 @code{Restrictions}. See H.4(25).
11147 There are no implementation-defined aspects of pragma @code{Restrictions}. The
11148 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
11149 generated code. Checks must suppressed by use of pragma @code{Suppress}.
11154 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
11158 There are no restrictions on pragma @code{Restrictions}.
11160 @node Intrinsic Subprograms
11161 @chapter Intrinsic Subprograms
11162 @cindex Intrinsic Subprograms
11165 * Intrinsic Operators::
11166 * Enclosing_Entity::
11167 * Exception_Information::
11168 * Exception_Message::
11172 * Shifts and Rotates::
11173 * Source_Location::
11177 GNAT allows a user application program to write the declaration:
11179 @smallexample @c ada
11180 pragma Import (Intrinsic, name);
11184 providing that the name corresponds to one of the implemented intrinsic
11185 subprograms in GNAT, and that the parameter profile of the referenced
11186 subprogram meets the requirements. This chapter describes the set of
11187 implemented intrinsic subprograms, and the requirements on parameter profiles.
11188 Note that no body is supplied; as with other uses of pragma Import, the
11189 body is supplied elsewhere (in this case by the compiler itself). Note
11190 that any use of this feature is potentially non-portable, since the
11191 Ada standard does not require Ada compilers to implement this feature.
11193 @node Intrinsic Operators
11194 @section Intrinsic Operators
11195 @cindex Intrinsic operator
11198 All the predefined numeric operators in package Standard
11199 in @code{pragma Import (Intrinsic,..)}
11200 declarations. In the binary operator case, the operands must have the same
11201 size. The operand or operands must also be appropriate for
11202 the operator. For example, for addition, the operands must
11203 both be floating-point or both be fixed-point, and the
11204 right operand for @code{"**"} must have a root type of
11205 @code{Standard.Integer'Base}.
11206 You can use an intrinsic operator declaration as in the following example:
11208 @smallexample @c ada
11209 type Int1 is new Integer;
11210 type Int2 is new Integer;
11212 function "+" (X1 : Int1; X2 : Int2) return Int1;
11213 function "+" (X1 : Int1; X2 : Int2) return Int2;
11214 pragma Import (Intrinsic, "+");
11218 This declaration would permit ``mixed mode'' arithmetic on items
11219 of the differing types @code{Int1} and @code{Int2}.
11220 It is also possible to specify such operators for private types, if the
11221 full views are appropriate arithmetic types.
11223 @node Enclosing_Entity
11224 @section Enclosing_Entity
11225 @cindex Enclosing_Entity
11227 This intrinsic subprogram is used in the implementation of the
11228 library routine @code{GNAT.Source_Info}. The only useful use of the
11229 intrinsic import in this case is the one in this unit, so an
11230 application program should simply call the function
11231 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
11232 the current subprogram, package, task, entry, or protected subprogram.
11234 @node Exception_Information
11235 @section Exception_Information
11236 @cindex Exception_Information'
11238 This intrinsic subprogram is used in the implementation of the
11239 library routine @code{GNAT.Current_Exception}. The only useful
11240 use of the intrinsic import in this case is the one in this unit,
11241 so an application program should simply call the function
11242 @code{GNAT.Current_Exception.Exception_Information} to obtain
11243 the exception information associated with the current exception.
11245 @node Exception_Message
11246 @section Exception_Message
11247 @cindex Exception_Message
11249 This intrinsic subprogram is used in the implementation of the
11250 library routine @code{GNAT.Current_Exception}. The only useful
11251 use of the intrinsic import in this case is the one in this unit,
11252 so an application program should simply call the function
11253 @code{GNAT.Current_Exception.Exception_Message} to obtain
11254 the message associated with the current exception.
11256 @node Exception_Name
11257 @section Exception_Name
11258 @cindex Exception_Name
11260 This intrinsic subprogram is used in the implementation of the
11261 library routine @code{GNAT.Current_Exception}. The only useful
11262 use of the intrinsic import in this case is the one in this unit,
11263 so an application program should simply call the function
11264 @code{GNAT.Current_Exception.Exception_Name} to obtain
11265 the name of the current exception.
11271 This intrinsic subprogram is used in the implementation of the
11272 library routine @code{GNAT.Source_Info}. The only useful use of the
11273 intrinsic import in this case is the one in this unit, so an
11274 application program should simply call the function
11275 @code{GNAT.Source_Info.File} to obtain the name of the current
11282 This intrinsic subprogram is used in the implementation of the
11283 library routine @code{GNAT.Source_Info}. The only useful use of the
11284 intrinsic import in this case is the one in this unit, so an
11285 application program should simply call the function
11286 @code{GNAT.Source_Info.Line} to obtain the number of the current
11289 @node Shifts and Rotates
11290 @section Shifts and Rotates
11292 @cindex Shift_Right
11293 @cindex Shift_Right_Arithmetic
11294 @cindex Rotate_Left
11295 @cindex Rotate_Right
11297 In standard Ada, the shift and rotate functions are available only
11298 for the predefined modular types in package @code{Interfaces}. However, in
11299 GNAT it is possible to define these functions for any integer
11300 type (signed or modular), as in this example:
11302 @smallexample @c ada
11303 function Shift_Left
11310 The function name must be one of
11311 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
11312 Rotate_Right. T must be an integer type. T'Size must be
11313 8, 16, 32 or 64 bits; if T is modular, the modulus
11314 must be 2**8, 2**16, 2**32 or 2**64.
11315 The result type must be the same as the type of @code{Value}.
11316 The shift amount must be Natural.
11317 The formal parameter names can be anything.
11319 @node Source_Location
11320 @section Source_Location
11321 @cindex Source_Location
11323 This intrinsic subprogram is used in the implementation of the
11324 library routine @code{GNAT.Source_Info}. The only useful use of the
11325 intrinsic import in this case is the one in this unit, so an
11326 application program should simply call the function
11327 @code{GNAT.Source_Info.Source_Location} to obtain the current
11328 source file location.
11330 @node Representation Clauses and Pragmas
11331 @chapter Representation Clauses and Pragmas
11332 @cindex Representation Clauses
11335 * Alignment Clauses::
11337 * Storage_Size Clauses::
11338 * Size of Variant Record Objects::
11339 * Biased Representation ::
11340 * Value_Size and Object_Size Clauses::
11341 * Component_Size Clauses::
11342 * Bit_Order Clauses::
11343 * Effect of Bit_Order on Byte Ordering::
11344 * Pragma Pack for Arrays::
11345 * Pragma Pack for Records::
11346 * Record Representation Clauses::
11347 * Enumeration Clauses::
11348 * Address Clauses::
11349 * Effect of Convention on Representation::
11350 * Determining the Representations chosen by GNAT::
11354 @cindex Representation Clause
11355 @cindex Representation Pragma
11356 @cindex Pragma, representation
11357 This section describes the representation clauses accepted by GNAT, and
11358 their effect on the representation of corresponding data objects.
11360 GNAT fully implements Annex C (Systems Programming). This means that all
11361 the implementation advice sections in chapter 13 are fully implemented.
11362 However, these sections only require a minimal level of support for
11363 representation clauses. GNAT provides much more extensive capabilities,
11364 and this section describes the additional capabilities provided.
11366 @node Alignment Clauses
11367 @section Alignment Clauses
11368 @cindex Alignment Clause
11371 GNAT requires that all alignment clauses specify a power of 2, and all
11372 default alignments are always a power of 2. The default alignment
11373 values are as follows:
11376 @item @emph{Primitive Types}.
11377 For primitive types, the alignment is the minimum of the actual size of
11378 objects of the type divided by @code{Storage_Unit},
11379 and the maximum alignment supported by the target.
11380 (This maximum alignment is given by the GNAT-specific attribute
11381 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
11382 @cindex @code{Maximum_Alignment} attribute
11383 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
11384 default alignment will be 8 on any target that supports alignments
11385 this large, but on some targets, the maximum alignment may be smaller
11386 than 8, in which case objects of type @code{Long_Float} will be maximally
11389 @item @emph{Arrays}.
11390 For arrays, the alignment is equal to the alignment of the component type
11391 for the normal case where no packing or component size is given. If the
11392 array is packed, and the packing is effective (see separate section on
11393 packed arrays), then the alignment will be one for long packed arrays,
11394 or arrays whose length is not known at compile time. For short packed
11395 arrays, which are handled internally as modular types, the alignment
11396 will be as described for primitive types, e.g.@: a packed array of length
11397 31 bits will have an object size of four bytes, and an alignment of 4.
11399 @item @emph{Records}.
11400 For the normal non-packed case, the alignment of a record is equal to
11401 the maximum alignment of any of its components. For tagged records, this
11402 includes the implicit access type used for the tag. If a pragma @code{Pack}
11403 is used and all components are packable (see separate section on pragma
11404 @code{Pack}), then the resulting alignment is 1, unless the layout of the
11405 record makes it profitable to increase it.
11407 A special case is when:
11410 the size of the record is given explicitly, or a
11411 full record representation clause is given, and
11413 the size of the record is 2, 4, or 8 bytes.
11416 In this case, an alignment is chosen to match the
11417 size of the record. For example, if we have:
11419 @smallexample @c ada
11420 type Small is record
11423 for Small'Size use 16;
11427 then the default alignment of the record type @code{Small} is 2, not 1. This
11428 leads to more efficient code when the record is treated as a unit, and also
11429 allows the type to specified as @code{Atomic} on architectures requiring
11435 An alignment clause may specify a larger alignment than the default value
11436 up to some maximum value dependent on the target (obtainable by using the
11437 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
11438 a smaller alignment than the default value for enumeration, integer and
11439 fixed point types, as well as for record types, for example
11441 @smallexample @c ada
11446 for V'alignment use 1;
11450 @cindex Alignment, default
11451 The default alignment for the type @code{V} is 4, as a result of the
11452 Integer field in the record, but it is permissible, as shown, to
11453 override the default alignment of the record with a smaller value.
11456 @section Size Clauses
11457 @cindex Size Clause
11460 The default size for a type @code{T} is obtainable through the
11461 language-defined attribute @code{T'Size} and also through the
11462 equivalent GNAT-defined attribute @code{T'Value_Size}.
11463 For objects of type @code{T}, GNAT will generally increase the type size
11464 so that the object size (obtainable through the GNAT-defined attribute
11465 @code{T'Object_Size})
11466 is a multiple of @code{T'Alignment * Storage_Unit}.
11469 @smallexample @c ada
11470 type Smallint is range 1 .. 6;
11479 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
11480 as specified by the RM rules,
11481 but objects of this type will have a size of 8
11482 (@code{Smallint'Object_Size} = 8),
11483 since objects by default occupy an integral number
11484 of storage units. On some targets, notably older
11485 versions of the Digital Alpha, the size of stand
11486 alone objects of this type may be 32, reflecting
11487 the inability of the hardware to do byte load/stores.
11489 Similarly, the size of type @code{Rec} is 40 bits
11490 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
11491 the alignment is 4, so objects of this type will have
11492 their size increased to 64 bits so that it is a multiple
11493 of the alignment (in bits). This decision is
11494 in accordance with the specific Implementation Advice in RM 13.3(43):
11497 A @code{Size} clause should be supported for an object if the specified
11498 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
11499 to a size in storage elements that is a multiple of the object's
11500 @code{Alignment} (if the @code{Alignment} is nonzero).
11504 An explicit size clause may be used to override the default size by
11505 increasing it. For example, if we have:
11507 @smallexample @c ada
11508 type My_Boolean is new Boolean;
11509 for My_Boolean'Size use 32;
11513 then values of this type will always be 32 bits long. In the case of
11514 discrete types, the size can be increased up to 64 bits, with the effect
11515 that the entire specified field is used to hold the value, sign- or
11516 zero-extended as appropriate. If more than 64 bits is specified, then
11517 padding space is allocated after the value, and a warning is issued that
11518 there are unused bits.
11520 Similarly the size of records and arrays may be increased, and the effect
11521 is to add padding bits after the value. This also causes a warning message
11524 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
11525 Size in bits, this corresponds to an object of size 256 megabytes (minus
11526 one). This limitation is true on all targets. The reason for this
11527 limitation is that it improves the quality of the code in many cases
11528 if it is known that a Size value can be accommodated in an object of
11531 @node Storage_Size Clauses
11532 @section Storage_Size Clauses
11533 @cindex Storage_Size Clause
11536 For tasks, the @code{Storage_Size} clause specifies the amount of space
11537 to be allocated for the task stack. This cannot be extended, and if the
11538 stack is exhausted, then @code{Storage_Error} will be raised (if stack
11539 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
11540 or a @code{Storage_Size} pragma in the task definition to set the
11541 appropriate required size. A useful technique is to include in every
11542 task definition a pragma of the form:
11544 @smallexample @c ada
11545 pragma Storage_Size (Default_Stack_Size);
11549 Then @code{Default_Stack_Size} can be defined in a global package, and
11550 modified as required. Any tasks requiring stack sizes different from the
11551 default can have an appropriate alternative reference in the pragma.
11553 You can also use the @option{-d} binder switch to modify the default stack
11556 For access types, the @code{Storage_Size} clause specifies the maximum
11557 space available for allocation of objects of the type. If this space is
11558 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
11559 In the case where the access type is declared local to a subprogram, the
11560 use of a @code{Storage_Size} clause triggers automatic use of a special
11561 predefined storage pool (@code{System.Pool_Size}) that ensures that all
11562 space for the pool is automatically reclaimed on exit from the scope in
11563 which the type is declared.
11565 A special case recognized by the compiler is the specification of a
11566 @code{Storage_Size} of zero for an access type. This means that no
11567 items can be allocated from the pool, and this is recognized at compile
11568 time, and all the overhead normally associated with maintaining a fixed
11569 size storage pool is eliminated. Consider the following example:
11571 @smallexample @c ada
11573 type R is array (Natural) of Character;
11574 type P is access all R;
11575 for P'Storage_Size use 0;
11576 -- Above access type intended only for interfacing purposes
11580 procedure g (m : P);
11581 pragma Import (C, g);
11592 As indicated in this example, these dummy storage pools are often useful in
11593 connection with interfacing where no object will ever be allocated. If you
11594 compile the above example, you get the warning:
11597 p.adb:16:09: warning: allocation from empty storage pool
11598 p.adb:16:09: warning: Storage_Error will be raised at run time
11602 Of course in practice, there will not be any explicit allocators in the
11603 case of such an access declaration.
11605 @node Size of Variant Record Objects
11606 @section Size of Variant Record Objects
11607 @cindex Size, variant record objects
11608 @cindex Variant record objects, size
11611 In the case of variant record objects, there is a question whether Size gives
11612 information about a particular variant, or the maximum size required
11613 for any variant. Consider the following program
11615 @smallexample @c ada
11616 with Text_IO; use Text_IO;
11618 type R1 (A : Boolean := False) is record
11620 when True => X : Character;
11621 when False => null;
11629 Put_Line (Integer'Image (V1'Size));
11630 Put_Line (Integer'Image (V2'Size));
11635 Here we are dealing with a variant record, where the True variant
11636 requires 16 bits, and the False variant requires 8 bits.
11637 In the above example, both V1 and V2 contain the False variant,
11638 which is only 8 bits long. However, the result of running the
11647 The reason for the difference here is that the discriminant value of
11648 V1 is fixed, and will always be False. It is not possible to assign
11649 a True variant value to V1, therefore 8 bits is sufficient. On the
11650 other hand, in the case of V2, the initial discriminant value is
11651 False (from the default), but it is possible to assign a True
11652 variant value to V2, therefore 16 bits must be allocated for V2
11653 in the general case, even fewer bits may be needed at any particular
11654 point during the program execution.
11656 As can be seen from the output of this program, the @code{'Size}
11657 attribute applied to such an object in GNAT gives the actual allocated
11658 size of the variable, which is the largest size of any of the variants.
11659 The Ada Reference Manual is not completely clear on what choice should
11660 be made here, but the GNAT behavior seems most consistent with the
11661 language in the RM@.
11663 In some cases, it may be desirable to obtain the size of the current
11664 variant, rather than the size of the largest variant. This can be
11665 achieved in GNAT by making use of the fact that in the case of a
11666 subprogram parameter, GNAT does indeed return the size of the current
11667 variant (because a subprogram has no way of knowing how much space
11668 is actually allocated for the actual).
11670 Consider the following modified version of the above program:
11672 @smallexample @c ada
11673 with Text_IO; use Text_IO;
11675 type R1 (A : Boolean := False) is record
11677 when True => X : Character;
11678 when False => null;
11684 function Size (V : R1) return Integer is
11690 Put_Line (Integer'Image (V2'Size));
11691 Put_Line (Integer'IMage (Size (V2)));
11693 Put_Line (Integer'Image (V2'Size));
11694 Put_Line (Integer'IMage (Size (V2)));
11699 The output from this program is
11709 Here we see that while the @code{'Size} attribute always returns
11710 the maximum size, regardless of the current variant value, the
11711 @code{Size} function does indeed return the size of the current
11714 @node Biased Representation
11715 @section Biased Representation
11716 @cindex Size for biased representation
11717 @cindex Biased representation
11720 In the case of scalars with a range starting at other than zero, it is
11721 possible in some cases to specify a size smaller than the default minimum
11722 value, and in such cases, GNAT uses an unsigned biased representation,
11723 in which zero is used to represent the lower bound, and successive values
11724 represent successive values of the type.
11726 For example, suppose we have the declaration:
11728 @smallexample @c ada
11729 type Small is range -7 .. -4;
11730 for Small'Size use 2;
11734 Although the default size of type @code{Small} is 4, the @code{Size}
11735 clause is accepted by GNAT and results in the following representation
11739 -7 is represented as 2#00#
11740 -6 is represented as 2#01#
11741 -5 is represented as 2#10#
11742 -4 is represented as 2#11#
11746 Biased representation is only used if the specified @code{Size} clause
11747 cannot be accepted in any other manner. These reduced sizes that force
11748 biased representation can be used for all discrete types except for
11749 enumeration types for which a representation clause is given.
11751 @node Value_Size and Object_Size Clauses
11752 @section Value_Size and Object_Size Clauses
11754 @findex Object_Size
11755 @cindex Size, of objects
11758 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
11759 number of bits required to hold values of type @code{T}.
11760 Although this interpretation was allowed in Ada 83, it was not required,
11761 and this requirement in practice can cause some significant difficulties.
11762 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
11763 However, in Ada 95 and Ada 2005,
11764 @code{Natural'Size} is
11765 typically 31. This means that code may change in behavior when moving
11766 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
11768 @smallexample @c ada
11769 type Rec is record;
11775 at 0 range 0 .. Natural'Size - 1;
11776 at 0 range Natural'Size .. 2 * Natural'Size - 1;
11781 In the above code, since the typical size of @code{Natural} objects
11782 is 32 bits and @code{Natural'Size} is 31, the above code can cause
11783 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
11784 there are cases where the fact that the object size can exceed the
11785 size of the type causes surprises.
11787 To help get around this problem GNAT provides two implementation
11788 defined attributes, @code{Value_Size} and @code{Object_Size}. When
11789 applied to a type, these attributes yield the size of the type
11790 (corresponding to the RM defined size attribute), and the size of
11791 objects of the type respectively.
11793 The @code{Object_Size} is used for determining the default size of
11794 objects and components. This size value can be referred to using the
11795 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
11796 the basis of the determination of the size. The backend is free to
11797 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
11798 character might be stored in 32 bits on a machine with no efficient
11799 byte access instructions such as the Alpha.
11801 The default rules for the value of @code{Object_Size} for
11802 discrete types are as follows:
11806 The @code{Object_Size} for base subtypes reflect the natural hardware
11807 size in bits (run the compiler with @option{-gnatS} to find those values
11808 for numeric types). Enumeration types and fixed-point base subtypes have
11809 8, 16, 32 or 64 bits for this size, depending on the range of values
11813 The @code{Object_Size} of a subtype is the same as the
11814 @code{Object_Size} of
11815 the type from which it is obtained.
11818 The @code{Object_Size} of a derived base type is copied from the parent
11819 base type, and the @code{Object_Size} of a derived first subtype is copied
11820 from the parent first subtype.
11824 The @code{Value_Size} attribute
11825 is the (minimum) number of bits required to store a value
11827 This value is used to determine how tightly to pack
11828 records or arrays with components of this type, and also affects
11829 the semantics of unchecked conversion (unchecked conversions where
11830 the @code{Value_Size} values differ generate a warning, and are potentially
11833 The default rules for the value of @code{Value_Size} are as follows:
11837 The @code{Value_Size} for a base subtype is the minimum number of bits
11838 required to store all values of the type (including the sign bit
11839 only if negative values are possible).
11842 If a subtype statically matches the first subtype of a given type, then it has
11843 by default the same @code{Value_Size} as the first subtype. This is a
11844 consequence of RM 13.1(14) (``if two subtypes statically match,
11845 then their subtype-specific aspects are the same''.)
11848 All other subtypes have a @code{Value_Size} corresponding to the minimum
11849 number of bits required to store all values of the subtype. For
11850 dynamic bounds, it is assumed that the value can range down or up
11851 to the corresponding bound of the ancestor
11855 The RM defined attribute @code{Size} corresponds to the
11856 @code{Value_Size} attribute.
11858 The @code{Size} attribute may be defined for a first-named subtype. This sets
11859 the @code{Value_Size} of
11860 the first-named subtype to the given value, and the
11861 @code{Object_Size} of this first-named subtype to the given value padded up
11862 to an appropriate boundary. It is a consequence of the default rules
11863 above that this @code{Object_Size} will apply to all further subtypes. On the
11864 other hand, @code{Value_Size} is affected only for the first subtype, any
11865 dynamic subtypes obtained from it directly, and any statically matching
11866 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
11868 @code{Value_Size} and
11869 @code{Object_Size} may be explicitly set for any subtype using
11870 an attribute definition clause. Note that the use of these attributes
11871 can cause the RM 13.1(14) rule to be violated. If two access types
11872 reference aliased objects whose subtypes have differing @code{Object_Size}
11873 values as a result of explicit attribute definition clauses, then it
11874 is erroneous to convert from one access subtype to the other.
11876 At the implementation level, Esize stores the Object_Size and the
11877 RM_Size field stores the @code{Value_Size} (and hence the value of the
11878 @code{Size} attribute,
11879 which, as noted above, is equivalent to @code{Value_Size}).
11881 To get a feel for the difference, consider the following examples (note
11882 that in each case the base is @code{Short_Short_Integer} with a size of 8):
11885 Object_Size Value_Size
11887 type x1 is range 0 .. 5; 8 3
11889 type x2 is range 0 .. 5;
11890 for x2'size use 12; 16 12
11892 subtype x3 is x2 range 0 .. 3; 16 2
11894 subtype x4 is x2'base range 0 .. 10; 8 4
11896 subtype x5 is x2 range 0 .. dynamic; 16 3*
11898 subtype x6 is x2'base range 0 .. dynamic; 8 3*
11903 Note: the entries marked ``3*'' are not actually specified by the Ada
11904 Reference Manual, but it seems in the spirit of the RM rules to allocate
11905 the minimum number of bits (here 3, given the range for @code{x2})
11906 known to be large enough to hold the given range of values.
11908 So far, so good, but GNAT has to obey the RM rules, so the question is
11909 under what conditions must the RM @code{Size} be used.
11910 The following is a list
11911 of the occasions on which the RM @code{Size} must be used:
11915 Component size for packed arrays or records
11918 Value of the attribute @code{Size} for a type
11921 Warning about sizes not matching for unchecked conversion
11925 For record types, the @code{Object_Size} is always a multiple of the
11926 alignment of the type (this is true for all types). In some cases the
11927 @code{Value_Size} can be smaller. Consider:
11937 On a typical 32-bit architecture, the X component will be four bytes, and
11938 require four-byte alignment, and the Y component will be one byte. In this
11939 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
11940 required to store a value of this type, and for example, it is permissible
11941 to have a component of type R in an outer array whose component size is
11942 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
11943 since it must be rounded up so that this value is a multiple of the
11944 alignment (4 bytes = 32 bits).
11947 For all other types, the @code{Object_Size}
11948 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
11949 Only @code{Size} may be specified for such types.
11951 @node Component_Size Clauses
11952 @section Component_Size Clauses
11953 @cindex Component_Size Clause
11956 Normally, the value specified in a component size clause must be consistent
11957 with the subtype of the array component with regard to size and alignment.
11958 In other words, the value specified must be at least equal to the size
11959 of this subtype, and must be a multiple of the alignment value.
11961 In addition, component size clauses are allowed which cause the array
11962 to be packed, by specifying a smaller value. A first case is for
11963 component size values in the range 1 through 63. The value specified
11964 must not be smaller than the Size of the subtype. GNAT will accurately
11965 honor all packing requests in this range. For example, if we have:
11967 @smallexample @c ada
11968 type r is array (1 .. 8) of Natural;
11969 for r'Component_Size use 31;
11973 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
11974 Of course access to the components of such an array is considerably
11975 less efficient than if the natural component size of 32 is used.
11976 A second case is when the subtype of the component is a record type
11977 padded because of its default alignment. For example, if we have:
11979 @smallexample @c ada
11986 type a is array (1 .. 8) of r;
11987 for a'Component_Size use 72;
11991 then the resulting array has a length of 72 bytes, instead of 96 bytes
11992 if the alignment of the record (4) was obeyed.
11994 Note that there is no point in giving both a component size clause
11995 and a pragma Pack for the same array type. if such duplicate
11996 clauses are given, the pragma Pack will be ignored.
11998 @node Bit_Order Clauses
11999 @section Bit_Order Clauses
12000 @cindex Bit_Order Clause
12001 @cindex bit ordering
12002 @cindex ordering, of bits
12005 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
12006 attribute. The specification may either correspond to the default bit
12007 order for the target, in which case the specification has no effect and
12008 places no additional restrictions, or it may be for the non-standard
12009 setting (that is the opposite of the default).
12011 In the case where the non-standard value is specified, the effect is
12012 to renumber bits within each byte, but the ordering of bytes is not
12013 affected. There are certain
12014 restrictions placed on component clauses as follows:
12018 @item Components fitting within a single storage unit.
12020 These are unrestricted, and the effect is merely to renumber bits. For
12021 example if we are on a little-endian machine with @code{Low_Order_First}
12022 being the default, then the following two declarations have exactly
12025 @smallexample @c ada
12028 B : Integer range 1 .. 120;
12032 A at 0 range 0 .. 0;
12033 B at 0 range 1 .. 7;
12038 B : Integer range 1 .. 120;
12041 for R2'Bit_Order use High_Order_First;
12044 A at 0 range 7 .. 7;
12045 B at 0 range 0 .. 6;
12050 The useful application here is to write the second declaration with the
12051 @code{Bit_Order} attribute definition clause, and know that it will be treated
12052 the same, regardless of whether the target is little-endian or big-endian.
12054 @item Components occupying an integral number of bytes.
12056 These are components that exactly fit in two or more bytes. Such component
12057 declarations are allowed, but have no effect, since it is important to realize
12058 that the @code{Bit_Order} specification does not affect the ordering of bytes.
12059 In particular, the following attempt at getting an endian-independent integer
12062 @smallexample @c ada
12067 for R2'Bit_Order use High_Order_First;
12070 A at 0 range 0 .. 31;
12075 This declaration will result in a little-endian integer on a
12076 little-endian machine, and a big-endian integer on a big-endian machine.
12077 If byte flipping is required for interoperability between big- and
12078 little-endian machines, this must be explicitly programmed. This capability
12079 is not provided by @code{Bit_Order}.
12081 @item Components that are positioned across byte boundaries
12083 but do not occupy an integral number of bytes. Given that bytes are not
12084 reordered, such fields would occupy a non-contiguous sequence of bits
12085 in memory, requiring non-trivial code to reassemble. They are for this
12086 reason not permitted, and any component clause specifying such a layout
12087 will be flagged as illegal by GNAT@.
12092 Since the misconception that Bit_Order automatically deals with all
12093 endian-related incompatibilities is a common one, the specification of
12094 a component field that is an integral number of bytes will always
12095 generate a warning. This warning may be suppressed using @code{pragma
12096 Warnings (Off)} if desired. The following section contains additional
12097 details regarding the issue of byte ordering.
12099 @node Effect of Bit_Order on Byte Ordering
12100 @section Effect of Bit_Order on Byte Ordering
12101 @cindex byte ordering
12102 @cindex ordering, of bytes
12105 In this section we will review the effect of the @code{Bit_Order} attribute
12106 definition clause on byte ordering. Briefly, it has no effect at all, but
12107 a detailed example will be helpful. Before giving this
12108 example, let us review the precise
12109 definition of the effect of defining @code{Bit_Order}. The effect of a
12110 non-standard bit order is described in section 15.5.3 of the Ada
12114 2 A bit ordering is a method of interpreting the meaning of
12115 the storage place attributes.
12119 To understand the precise definition of storage place attributes in
12120 this context, we visit section 13.5.1 of the manual:
12123 13 A record_representation_clause (without the mod_clause)
12124 specifies the layout. The storage place attributes (see 13.5.2)
12125 are taken from the values of the position, first_bit, and last_bit
12126 expressions after normalizing those values so that first_bit is
12127 less than Storage_Unit.
12131 The critical point here is that storage places are taken from
12132 the values after normalization, not before. So the @code{Bit_Order}
12133 interpretation applies to normalized values. The interpretation
12134 is described in the later part of the 15.5.3 paragraph:
12137 2 A bit ordering is a method of interpreting the meaning of
12138 the storage place attributes. High_Order_First (known in the
12139 vernacular as ``big endian'') means that the first bit of a
12140 storage element (bit 0) is the most significant bit (interpreting
12141 the sequence of bits that represent a component as an unsigned
12142 integer value). Low_Order_First (known in the vernacular as
12143 ``little endian'') means the opposite: the first bit is the
12148 Note that the numbering is with respect to the bits of a storage
12149 unit. In other words, the specification affects only the numbering
12150 of bits within a single storage unit.
12152 We can make the effect clearer by giving an example.
12154 Suppose that we have an external device which presents two bytes, the first
12155 byte presented, which is the first (low addressed byte) of the two byte
12156 record is called Master, and the second byte is called Slave.
12158 The left most (most significant bit is called Control for each byte, and
12159 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
12160 (least significant) bit.
12162 On a big-endian machine, we can write the following representation clause
12164 @smallexample @c ada
12165 type Data is record
12166 Master_Control : Bit;
12174 Slave_Control : Bit;
12184 for Data use record
12185 Master_Control at 0 range 0 .. 0;
12186 Master_V1 at 0 range 1 .. 1;
12187 Master_V2 at 0 range 2 .. 2;
12188 Master_V3 at 0 range 3 .. 3;
12189 Master_V4 at 0 range 4 .. 4;
12190 Master_V5 at 0 range 5 .. 5;
12191 Master_V6 at 0 range 6 .. 6;
12192 Master_V7 at 0 range 7 .. 7;
12193 Slave_Control at 1 range 0 .. 0;
12194 Slave_V1 at 1 range 1 .. 1;
12195 Slave_V2 at 1 range 2 .. 2;
12196 Slave_V3 at 1 range 3 .. 3;
12197 Slave_V4 at 1 range 4 .. 4;
12198 Slave_V5 at 1 range 5 .. 5;
12199 Slave_V6 at 1 range 6 .. 6;
12200 Slave_V7 at 1 range 7 .. 7;
12205 Now if we move this to a little endian machine, then the bit ordering within
12206 the byte is backwards, so we have to rewrite the record rep clause as:
12208 @smallexample @c ada
12209 for Data use record
12210 Master_Control at 0 range 7 .. 7;
12211 Master_V1 at 0 range 6 .. 6;
12212 Master_V2 at 0 range 5 .. 5;
12213 Master_V3 at 0 range 4 .. 4;
12214 Master_V4 at 0 range 3 .. 3;
12215 Master_V5 at 0 range 2 .. 2;
12216 Master_V6 at 0 range 1 .. 1;
12217 Master_V7 at 0 range 0 .. 0;
12218 Slave_Control at 1 range 7 .. 7;
12219 Slave_V1 at 1 range 6 .. 6;
12220 Slave_V2 at 1 range 5 .. 5;
12221 Slave_V3 at 1 range 4 .. 4;
12222 Slave_V4 at 1 range 3 .. 3;
12223 Slave_V5 at 1 range 2 .. 2;
12224 Slave_V6 at 1 range 1 .. 1;
12225 Slave_V7 at 1 range 0 .. 0;
12230 It is a nuisance to have to rewrite the clause, especially if
12231 the code has to be maintained on both machines. However,
12232 this is a case that we can handle with the
12233 @code{Bit_Order} attribute if it is implemented.
12234 Note that the implementation is not required on byte addressed
12235 machines, but it is indeed implemented in GNAT.
12236 This means that we can simply use the
12237 first record clause, together with the declaration
12239 @smallexample @c ada
12240 for Data'Bit_Order use High_Order_First;
12244 and the effect is what is desired, namely the layout is exactly the same,
12245 independent of whether the code is compiled on a big-endian or little-endian
12248 The important point to understand is that byte ordering is not affected.
12249 A @code{Bit_Order} attribute definition never affects which byte a field
12250 ends up in, only where it ends up in that byte.
12251 To make this clear, let us rewrite the record rep clause of the previous
12254 @smallexample @c ada
12255 for Data'Bit_Order use High_Order_First;
12256 for Data use record
12257 Master_Control at 0 range 0 .. 0;
12258 Master_V1 at 0 range 1 .. 1;
12259 Master_V2 at 0 range 2 .. 2;
12260 Master_V3 at 0 range 3 .. 3;
12261 Master_V4 at 0 range 4 .. 4;
12262 Master_V5 at 0 range 5 .. 5;
12263 Master_V6 at 0 range 6 .. 6;
12264 Master_V7 at 0 range 7 .. 7;
12265 Slave_Control at 0 range 8 .. 8;
12266 Slave_V1 at 0 range 9 .. 9;
12267 Slave_V2 at 0 range 10 .. 10;
12268 Slave_V3 at 0 range 11 .. 11;
12269 Slave_V4 at 0 range 12 .. 12;
12270 Slave_V5 at 0 range 13 .. 13;
12271 Slave_V6 at 0 range 14 .. 14;
12272 Slave_V7 at 0 range 15 .. 15;
12277 This is exactly equivalent to saying (a repeat of the first example):
12279 @smallexample @c ada
12280 for Data'Bit_Order use High_Order_First;
12281 for Data use record
12282 Master_Control at 0 range 0 .. 0;
12283 Master_V1 at 0 range 1 .. 1;
12284 Master_V2 at 0 range 2 .. 2;
12285 Master_V3 at 0 range 3 .. 3;
12286 Master_V4 at 0 range 4 .. 4;
12287 Master_V5 at 0 range 5 .. 5;
12288 Master_V6 at 0 range 6 .. 6;
12289 Master_V7 at 0 range 7 .. 7;
12290 Slave_Control at 1 range 0 .. 0;
12291 Slave_V1 at 1 range 1 .. 1;
12292 Slave_V2 at 1 range 2 .. 2;
12293 Slave_V3 at 1 range 3 .. 3;
12294 Slave_V4 at 1 range 4 .. 4;
12295 Slave_V5 at 1 range 5 .. 5;
12296 Slave_V6 at 1 range 6 .. 6;
12297 Slave_V7 at 1 range 7 .. 7;
12302 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
12303 field. The storage place attributes are obtained by normalizing the
12304 values given so that the @code{First_Bit} value is less than 8. After
12305 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
12306 we specified in the other case.
12308 Now one might expect that the @code{Bit_Order} attribute might affect
12309 bit numbering within the entire record component (two bytes in this
12310 case, thus affecting which byte fields end up in), but that is not
12311 the way this feature is defined, it only affects numbering of bits,
12312 not which byte they end up in.
12314 Consequently it never makes sense to specify a starting bit number
12315 greater than 7 (for a byte addressable field) if an attribute
12316 definition for @code{Bit_Order} has been given, and indeed it
12317 may be actively confusing to specify such a value, so the compiler
12318 generates a warning for such usage.
12320 If you do need to control byte ordering then appropriate conditional
12321 values must be used. If in our example, the slave byte came first on
12322 some machines we might write:
12324 @smallexample @c ada
12325 Master_Byte_First constant Boolean := @dots{};
12327 Master_Byte : constant Natural :=
12328 1 - Boolean'Pos (Master_Byte_First);
12329 Slave_Byte : constant Natural :=
12330 Boolean'Pos (Master_Byte_First);
12332 for Data'Bit_Order use High_Order_First;
12333 for Data use record
12334 Master_Control at Master_Byte range 0 .. 0;
12335 Master_V1 at Master_Byte range 1 .. 1;
12336 Master_V2 at Master_Byte range 2 .. 2;
12337 Master_V3 at Master_Byte range 3 .. 3;
12338 Master_V4 at Master_Byte range 4 .. 4;
12339 Master_V5 at Master_Byte range 5 .. 5;
12340 Master_V6 at Master_Byte range 6 .. 6;
12341 Master_V7 at Master_Byte range 7 .. 7;
12342 Slave_Control at Slave_Byte range 0 .. 0;
12343 Slave_V1 at Slave_Byte range 1 .. 1;
12344 Slave_V2 at Slave_Byte range 2 .. 2;
12345 Slave_V3 at Slave_Byte range 3 .. 3;
12346 Slave_V4 at Slave_Byte range 4 .. 4;
12347 Slave_V5 at Slave_Byte range 5 .. 5;
12348 Slave_V6 at Slave_Byte range 6 .. 6;
12349 Slave_V7 at Slave_Byte range 7 .. 7;
12354 Now to switch between machines, all that is necessary is
12355 to set the boolean constant @code{Master_Byte_First} in
12356 an appropriate manner.
12358 @node Pragma Pack for Arrays
12359 @section Pragma Pack for Arrays
12360 @cindex Pragma Pack (for arrays)
12363 Pragma @code{Pack} applied to an array has no effect unless the component type
12364 is packable. For a component type to be packable, it must be one of the
12371 Any type whose size is specified with a size clause
12373 Any packed array type with a static size
12375 Any record type padded because of its default alignment
12379 For all these cases, if the component subtype size is in the range
12380 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
12381 component size were specified giving the component subtype size.
12382 For example if we have:
12384 @smallexample @c ada
12385 type r is range 0 .. 17;
12387 type ar is array (1 .. 8) of r;
12392 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
12393 and the size of the array @code{ar} will be exactly 40 bits.
12395 Note that in some cases this rather fierce approach to packing can produce
12396 unexpected effects. For example, in Ada 95 and Ada 2005,
12397 subtype @code{Natural} typically has a size of 31, meaning that if you
12398 pack an array of @code{Natural}, you get 31-bit
12399 close packing, which saves a few bits, but results in far less efficient
12400 access. Since many other Ada compilers will ignore such a packing request,
12401 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
12402 might not be what is intended. You can easily remove this warning by
12403 using an explicit @code{Component_Size} setting instead, which never generates
12404 a warning, since the intention of the programmer is clear in this case.
12406 GNAT treats packed arrays in one of two ways. If the size of the array is
12407 known at compile time and is less than 64 bits, then internally the array
12408 is represented as a single modular type, of exactly the appropriate number
12409 of bits. If the length is greater than 63 bits, or is not known at compile
12410 time, then the packed array is represented as an array of bytes, and the
12411 length is always a multiple of 8 bits.
12413 Note that to represent a packed array as a modular type, the alignment must
12414 be suitable for the modular type involved. For example, on typical machines
12415 a 32-bit packed array will be represented by a 32-bit modular integer with
12416 an alignment of four bytes. If you explicitly override the default alignment
12417 with an alignment clause that is too small, the modular representation
12418 cannot be used. For example, consider the following set of declarations:
12420 @smallexample @c ada
12421 type R is range 1 .. 3;
12422 type S is array (1 .. 31) of R;
12423 for S'Component_Size use 2;
12425 for S'Alignment use 1;
12429 If the alignment clause were not present, then a 62-bit modular
12430 representation would be chosen (typically with an alignment of 4 or 8
12431 bytes depending on the target). But the default alignment is overridden
12432 with the explicit alignment clause. This means that the modular
12433 representation cannot be used, and instead the array of bytes
12434 representation must be used, meaning that the length must be a multiple
12435 of 8. Thus the above set of declarations will result in a diagnostic
12436 rejecting the size clause and noting that the minimum size allowed is 64.
12438 @cindex Pragma Pack (for type Natural)
12439 @cindex Pragma Pack warning
12441 One special case that is worth noting occurs when the base type of the
12442 component size is 8/16/32 and the subtype is one bit less. Notably this
12443 occurs with subtype @code{Natural}. Consider:
12445 @smallexample @c ada
12446 type Arr is array (1 .. 32) of Natural;
12451 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
12452 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
12453 Ada 83 compilers did not attempt 31 bit packing.
12455 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
12456 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
12457 substantial unintended performance penalty when porting legacy Ada 83 code.
12458 To help prevent this, GNAT generates a warning in such cases. If you really
12459 want 31 bit packing in a case like this, you can set the component size
12462 @smallexample @c ada
12463 type Arr is array (1 .. 32) of Natural;
12464 for Arr'Component_Size use 31;
12468 Here 31-bit packing is achieved as required, and no warning is generated,
12469 since in this case the programmer intention is clear.
12471 @node Pragma Pack for Records
12472 @section Pragma Pack for Records
12473 @cindex Pragma Pack (for records)
12476 Pragma @code{Pack} applied to a record will pack the components to reduce
12477 wasted space from alignment gaps and by reducing the amount of space
12478 taken by components. We distinguish between @emph{packable} components and
12479 @emph{non-packable} components.
12480 Components of the following types are considered packable:
12483 All primitive types are packable.
12486 Small packed arrays, whose size does not exceed 64 bits, and where the
12487 size is statically known at compile time, are represented internally
12488 as modular integers, and so they are also packable.
12493 All packable components occupy the exact number of bits corresponding to
12494 their @code{Size} value, and are packed with no padding bits, i.e.@: they
12495 can start on an arbitrary bit boundary.
12497 All other types are non-packable, they occupy an integral number of
12499 are placed at a boundary corresponding to their alignment requirements.
12501 For example, consider the record
12503 @smallexample @c ada
12504 type Rb1 is array (1 .. 13) of Boolean;
12507 type Rb2 is array (1 .. 65) of Boolean;
12522 The representation for the record x2 is as follows:
12524 @smallexample @c ada
12525 for x2'Size use 224;
12527 l1 at 0 range 0 .. 0;
12528 l2 at 0 range 1 .. 64;
12529 l3 at 12 range 0 .. 31;
12530 l4 at 16 range 0 .. 0;
12531 l5 at 16 range 1 .. 13;
12532 l6 at 18 range 0 .. 71;
12537 Studying this example, we see that the packable fields @code{l1}
12539 of length equal to their sizes, and placed at specific bit boundaries (and
12540 not byte boundaries) to
12541 eliminate padding. But @code{l3} is of a non-packable float type, so
12542 it is on the next appropriate alignment boundary.
12544 The next two fields are fully packable, so @code{l4} and @code{l5} are
12545 minimally packed with no gaps. However, type @code{Rb2} is a packed
12546 array that is longer than 64 bits, so it is itself non-packable. Thus
12547 the @code{l6} field is aligned to the next byte boundary, and takes an
12548 integral number of bytes, i.e.@: 72 bits.
12550 @node Record Representation Clauses
12551 @section Record Representation Clauses
12552 @cindex Record Representation Clause
12555 Record representation clauses may be given for all record types, including
12556 types obtained by record extension. Component clauses are allowed for any
12557 static component. The restrictions on component clauses depend on the type
12560 @cindex Component Clause
12561 For all components of an elementary type, the only restriction on component
12562 clauses is that the size must be at least the 'Size value of the type
12563 (actually the Value_Size). There are no restrictions due to alignment,
12564 and such components may freely cross storage boundaries.
12566 Packed arrays with a size up to and including 64 bits are represented
12567 internally using a modular type with the appropriate number of bits, and
12568 thus the same lack of restriction applies. For example, if you declare:
12570 @smallexample @c ada
12571 type R is array (1 .. 49) of Boolean;
12577 then a component clause for a component of type R may start on any
12578 specified bit boundary, and may specify a value of 49 bits or greater.
12580 For packed bit arrays that are longer than 64 bits, there are two
12581 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
12582 including the important case of single bits or boolean values, then
12583 there are no limitations on placement of such components, and they
12584 may start and end at arbitrary bit boundaries.
12586 If the component size is not a power of 2 (e.g.@: 3 or 5), then
12587 an array of this type longer than 64 bits must always be placed on
12588 on a storage unit (byte) boundary and occupy an integral number
12589 of storage units (bytes). Any component clause that does not
12590 meet this requirement will be rejected.
12592 Any aliased component, or component of an aliased type, must
12593 have its normal alignment and size. A component clause that
12594 does not meet this requirement will be rejected.
12596 The tag field of a tagged type always occupies an address sized field at
12597 the start of the record. No component clause may attempt to overlay this
12598 tag. When a tagged type appears as a component, the tag field must have
12601 In the case of a record extension T1, of a type T, no component clause applied
12602 to the type T1 can specify a storage location that would overlap the first
12603 T'Size bytes of the record.
12605 For all other component types, including non-bit-packed arrays,
12606 the component can be placed at an arbitrary bit boundary,
12607 so for example, the following is permitted:
12609 @smallexample @c ada
12610 type R is array (1 .. 10) of Boolean;
12619 G at 0 range 0 .. 0;
12620 H at 0 range 1 .. 1;
12621 L at 0 range 2 .. 81;
12622 R at 0 range 82 .. 161;
12627 Note: the above rules apply to recent releases of GNAT 5.
12628 In GNAT 3, there are more severe restrictions on larger components.
12629 For non-primitive types, including packed arrays with a size greater than
12630 64 bits, component clauses must respect the alignment requirement of the
12631 type, in particular, always starting on a byte boundary, and the length
12632 must be a multiple of the storage unit.
12634 @node Enumeration Clauses
12635 @section Enumeration Clauses
12637 The only restriction on enumeration clauses is that the range of values
12638 must be representable. For the signed case, if one or more of the
12639 representation values are negative, all values must be in the range:
12641 @smallexample @c ada
12642 System.Min_Int .. System.Max_Int
12646 For the unsigned case, where all values are nonnegative, the values must
12649 @smallexample @c ada
12650 0 .. System.Max_Binary_Modulus;
12654 A @emph{confirming} representation clause is one in which the values range
12655 from 0 in sequence, i.e.@: a clause that confirms the default representation
12656 for an enumeration type.
12657 Such a confirming representation
12658 is permitted by these rules, and is specially recognized by the compiler so
12659 that no extra overhead results from the use of such a clause.
12661 If an array has an index type which is an enumeration type to which an
12662 enumeration clause has been applied, then the array is stored in a compact
12663 manner. Consider the declarations:
12665 @smallexample @c ada
12666 type r is (A, B, C);
12667 for r use (A => 1, B => 5, C => 10);
12668 type t is array (r) of Character;
12672 The array type t corresponds to a vector with exactly three elements and
12673 has a default size equal to @code{3*Character'Size}. This ensures efficient
12674 use of space, but means that accesses to elements of the array will incur
12675 the overhead of converting representation values to the corresponding
12676 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
12678 @node Address Clauses
12679 @section Address Clauses
12680 @cindex Address Clause
12682 The reference manual allows a general restriction on representation clauses,
12683 as found in RM 13.1(22):
12686 An implementation need not support representation
12687 items containing nonstatic expressions, except that
12688 an implementation should support a representation item
12689 for a given entity if each nonstatic expression in the
12690 representation item is a name that statically denotes
12691 a constant declared before the entity.
12695 In practice this is applicable only to address clauses, since this is the
12696 only case in which a non-static expression is permitted by the syntax. As
12697 the AARM notes in sections 13.1 (22.a-22.h):
12700 22.a Reason: This is to avoid the following sort of thing:
12702 22.b X : Integer := F(@dots{});
12703 Y : Address := G(@dots{});
12704 for X'Address use Y;
12706 22.c In the above, we have to evaluate the
12707 initialization expression for X before we
12708 know where to put the result. This seems
12709 like an unreasonable implementation burden.
12711 22.d The above code should instead be written
12714 22.e Y : constant Address := G(@dots{});
12715 X : Integer := F(@dots{});
12716 for X'Address use Y;
12718 22.f This allows the expression ``Y'' to be safely
12719 evaluated before X is created.
12721 22.g The constant could be a formal parameter of mode in.
12723 22.h An implementation can support other nonstatic
12724 expressions if it wants to. Expressions of type
12725 Address are hardly ever static, but their value
12726 might be known at compile time anyway in many
12731 GNAT does indeed permit many additional cases of non-static expressions. In
12732 particular, if the type involved is elementary there are no restrictions
12733 (since in this case, holding a temporary copy of the initialization value,
12734 if one is present, is inexpensive). In addition, if there is no implicit or
12735 explicit initialization, then there are no restrictions. GNAT will reject
12736 only the case where all three of these conditions hold:
12741 The type of the item is non-elementary (e.g.@: a record or array).
12744 There is explicit or implicit initialization required for the object.
12745 Note that access values are always implicitly initialized.
12748 The address value is non-static. Here GNAT is more permissive than the
12749 RM, and allows the address value to be the address of a previously declared
12750 stand-alone variable, as long as it does not itself have an address clause.
12752 @smallexample @c ada
12753 Anchor : Some_Initialized_Type;
12754 Overlay : Some_Initialized_Type;
12755 for Overlay'Address use Anchor'Address;
12759 However, the prefix of the address clause cannot be an array component, or
12760 a component of a discriminated record.
12765 As noted above in section 22.h, address values are typically non-static. In
12766 particular the To_Address function, even if applied to a literal value, is
12767 a non-static function call. To avoid this minor annoyance, GNAT provides
12768 the implementation defined attribute 'To_Address. The following two
12769 expressions have identical values:
12773 @smallexample @c ada
12774 To_Address (16#1234_0000#)
12775 System'To_Address (16#1234_0000#);
12779 except that the second form is considered to be a static expression, and
12780 thus when used as an address clause value is always permitted.
12783 Additionally, GNAT treats as static an address clause that is an
12784 unchecked_conversion of a static integer value. This simplifies the porting
12785 of legacy code, and provides a portable equivalent to the GNAT attribute
12788 Another issue with address clauses is the interaction with alignment
12789 requirements. When an address clause is given for an object, the address
12790 value must be consistent with the alignment of the object (which is usually
12791 the same as the alignment of the type of the object). If an address clause
12792 is given that specifies an inappropriately aligned address value, then the
12793 program execution is erroneous.
12795 Since this source of erroneous behavior can have unfortunate effects, GNAT
12796 checks (at compile time if possible, generating a warning, or at execution
12797 time with a run-time check) that the alignment is appropriate. If the
12798 run-time check fails, then @code{Program_Error} is raised. This run-time
12799 check is suppressed if range checks are suppressed, or if the special GNAT
12800 check Alignment_Check is suppressed, or if
12801 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
12803 Finally, GNAT does not permit overlaying of objects of controlled types or
12804 composite types containing a controlled component. In most cases, the compiler
12805 can detect an attempt at such overlays and will generate a warning at compile
12806 time and a Program_Error exception at run time.
12809 An address clause cannot be given for an exported object. More
12810 understandably the real restriction is that objects with an address
12811 clause cannot be exported. This is because such variables are not
12812 defined by the Ada program, so there is no external object to export.
12815 It is permissible to give an address clause and a pragma Import for the
12816 same object. In this case, the variable is not really defined by the
12817 Ada program, so there is no external symbol to be linked. The link name
12818 and the external name are ignored in this case. The reason that we allow this
12819 combination is that it provides a useful idiom to avoid unwanted
12820 initializations on objects with address clauses.
12822 When an address clause is given for an object that has implicit or
12823 explicit initialization, then by default initialization takes place. This
12824 means that the effect of the object declaration is to overwrite the
12825 memory at the specified address. This is almost always not what the
12826 programmer wants, so GNAT will output a warning:
12836 for Ext'Address use System'To_Address (16#1234_1234#);
12838 >>> warning: implicit initialization of "Ext" may
12839 modify overlaid storage
12840 >>> warning: use pragma Import for "Ext" to suppress
12841 initialization (RM B(24))
12847 As indicated by the warning message, the solution is to use a (dummy) pragma
12848 Import to suppress this initialization. The pragma tell the compiler that the
12849 object is declared and initialized elsewhere. The following package compiles
12850 without warnings (and the initialization is suppressed):
12852 @smallexample @c ada
12860 for Ext'Address use System'To_Address (16#1234_1234#);
12861 pragma Import (Ada, Ext);
12866 A final issue with address clauses involves their use for overlaying
12867 variables, as in the following example:
12868 @cindex Overlaying of objects
12870 @smallexample @c ada
12873 for B'Address use A'Address;
12877 or alternatively, using the form recommended by the RM:
12879 @smallexample @c ada
12881 Addr : constant Address := A'Address;
12883 for B'Address use Addr;
12887 In both of these cases, @code{A}
12888 and @code{B} become aliased to one another via the
12889 address clause. This use of address clauses to overlay
12890 variables, achieving an effect similar to unchecked
12891 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
12892 the effect is implementation defined. Furthermore, the
12893 Ada RM specifically recommends that in a situation
12894 like this, @code{B} should be subject to the following
12895 implementation advice (RM 13.3(19)):
12898 19 If the Address of an object is specified, or it is imported
12899 or exported, then the implementation should not perform
12900 optimizations based on assumptions of no aliases.
12904 GNAT follows this recommendation, and goes further by also applying
12905 this recommendation to the overlaid variable (@code{A}
12906 in the above example) in this case. This means that the overlay
12907 works "as expected", in that a modification to one of the variables
12908 will affect the value of the other.
12910 @node Effect of Convention on Representation
12911 @section Effect of Convention on Representation
12912 @cindex Convention, effect on representation
12915 Normally the specification of a foreign language convention for a type or
12916 an object has no effect on the chosen representation. In particular, the
12917 representation chosen for data in GNAT generally meets the standard system
12918 conventions, and for example records are laid out in a manner that is
12919 consistent with C@. This means that specifying convention C (for example)
12922 There are four exceptions to this general rule:
12926 @item Convention Fortran and array subtypes
12927 If pragma Convention Fortran is specified for an array subtype, then in
12928 accordance with the implementation advice in section 3.6.2(11) of the
12929 Ada Reference Manual, the array will be stored in a Fortran-compatible
12930 column-major manner, instead of the normal default row-major order.
12932 @item Convention C and enumeration types
12933 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
12934 to accommodate all values of the type. For example, for the enumeration
12937 @smallexample @c ada
12938 type Color is (Red, Green, Blue);
12942 8 bits is sufficient to store all values of the type, so by default, objects
12943 of type @code{Color} will be represented using 8 bits. However, normal C
12944 convention is to use 32 bits for all enum values in C, since enum values
12945 are essentially of type int. If pragma @code{Convention C} is specified for an
12946 Ada enumeration type, then the size is modified as necessary (usually to
12947 32 bits) to be consistent with the C convention for enum values.
12949 Note that this treatment applies only to types. If Convention C is given for
12950 an enumeration object, where the enumeration type is not Convention C, then
12951 Object_Size bits are allocated. For example, for a normal enumeration type,
12952 with less than 256 elements, only 8 bits will be allocated for the object.
12953 Since this may be a surprise in terms of what C expects, GNAT will issue a
12954 warning in this situation. The warning can be suppressed by giving an explicit
12955 size clause specifying the desired size.
12957 @item Convention C/Fortran and Boolean types
12958 In C, the usual convention for boolean values, that is values used for
12959 conditions, is that zero represents false, and nonzero values represent
12960 true. In Ada, the normal convention is that two specific values, typically
12961 0/1, are used to represent false/true respectively.
12963 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
12964 value represents true).
12966 To accommodate the Fortran and C conventions, if a pragma Convention specifies
12967 C or Fortran convention for a derived Boolean, as in the following example:
12969 @smallexample @c ada
12970 type C_Switch is new Boolean;
12971 pragma Convention (C, C_Switch);
12975 then the GNAT generated code will treat any nonzero value as true. For truth
12976 values generated by GNAT, the conventional value 1 will be used for True, but
12977 when one of these values is read, any nonzero value is treated as True.
12979 @item Access types on OpenVMS
12980 For 64-bit OpenVMS systems, access types (other than those for unconstrained
12981 arrays) are 64-bits long. An exception to this rule is for the case of
12982 C-convention access types where there is no explicit size clause present (or
12983 inherited for derived types). In this case, GNAT chooses to make these
12984 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
12985 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
12989 @node Determining the Representations chosen by GNAT
12990 @section Determining the Representations chosen by GNAT
12991 @cindex Representation, determination of
12992 @cindex @option{-gnatR} switch
12995 Although the descriptions in this section are intended to be complete, it is
12996 often easier to simply experiment to see what GNAT accepts and what the
12997 effect is on the layout of types and objects.
12999 As required by the Ada RM, if a representation clause is not accepted, then
13000 it must be rejected as illegal by the compiler. However, when a
13001 representation clause or pragma is accepted, there can still be questions
13002 of what the compiler actually does. For example, if a partial record
13003 representation clause specifies the location of some components and not
13004 others, then where are the non-specified components placed? Or if pragma
13005 @code{Pack} is used on a record, then exactly where are the resulting
13006 fields placed? The section on pragma @code{Pack} in this chapter can be
13007 used to answer the second question, but it is often easier to just see
13008 what the compiler does.
13010 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
13011 with this option, then the compiler will output information on the actual
13012 representations chosen, in a format similar to source representation
13013 clauses. For example, if we compile the package:
13015 @smallexample @c ada
13017 type r (x : boolean) is tagged record
13019 when True => S : String (1 .. 100);
13020 when False => null;
13024 type r2 is new r (false) with record
13029 y2 at 16 range 0 .. 31;
13036 type x1 is array (1 .. 10) of x;
13037 for x1'component_size use 11;
13039 type ia is access integer;
13041 type Rb1 is array (1 .. 13) of Boolean;
13044 type Rb2 is array (1 .. 65) of Boolean;
13060 using the switch @option{-gnatR} we obtain the following output:
13063 Representation information for unit q
13064 -------------------------------------
13067 for r'Alignment use 4;
13069 x at 4 range 0 .. 7;
13070 _tag at 0 range 0 .. 31;
13071 s at 5 range 0 .. 799;
13074 for r2'Size use 160;
13075 for r2'Alignment use 4;
13077 x at 4 range 0 .. 7;
13078 _tag at 0 range 0 .. 31;
13079 _parent at 0 range 0 .. 63;
13080 y2 at 16 range 0 .. 31;
13084 for x'Alignment use 1;
13086 y at 0 range 0 .. 7;
13089 for x1'Size use 112;
13090 for x1'Alignment use 1;
13091 for x1'Component_Size use 11;
13093 for rb1'Size use 13;
13094 for rb1'Alignment use 2;
13095 for rb1'Component_Size use 1;
13097 for rb2'Size use 72;
13098 for rb2'Alignment use 1;
13099 for rb2'Component_Size use 1;
13101 for x2'Size use 224;
13102 for x2'Alignment use 4;
13104 l1 at 0 range 0 .. 0;
13105 l2 at 0 range 1 .. 64;
13106 l3 at 12 range 0 .. 31;
13107 l4 at 16 range 0 .. 0;
13108 l5 at 16 range 1 .. 13;
13109 l6 at 18 range 0 .. 71;
13114 The Size values are actually the Object_Size, i.e.@: the default size that
13115 will be allocated for objects of the type.
13116 The ?? size for type r indicates that we have a variant record, and the
13117 actual size of objects will depend on the discriminant value.
13119 The Alignment values show the actual alignment chosen by the compiler
13120 for each record or array type.
13122 The record representation clause for type r shows where all fields
13123 are placed, including the compiler generated tag field (whose location
13124 cannot be controlled by the programmer).
13126 The record representation clause for the type extension r2 shows all the
13127 fields present, including the parent field, which is a copy of the fields
13128 of the parent type of r2, i.e.@: r1.
13130 The component size and size clauses for types rb1 and rb2 show
13131 the exact effect of pragma @code{Pack} on these arrays, and the record
13132 representation clause for type x2 shows how pragma @code{Pack} affects
13135 In some cases, it may be useful to cut and paste the representation clauses
13136 generated by the compiler into the original source to fix and guarantee
13137 the actual representation to be used.
13139 @node Standard Library Routines
13140 @chapter Standard Library Routines
13143 The Ada Reference Manual contains in Annex A a full description of an
13144 extensive set of standard library routines that can be used in any Ada
13145 program, and which must be provided by all Ada compilers. They are
13146 analogous to the standard C library used by C programs.
13148 GNAT implements all of the facilities described in annex A, and for most
13149 purposes the description in the Ada Reference Manual, or appropriate Ada
13150 text book, will be sufficient for making use of these facilities.
13152 In the case of the input-output facilities,
13153 @xref{The Implementation of Standard I/O},
13154 gives details on exactly how GNAT interfaces to the
13155 file system. For the remaining packages, the Ada Reference Manual
13156 should be sufficient. The following is a list of the packages included,
13157 together with a brief description of the functionality that is provided.
13159 For completeness, references are included to other predefined library
13160 routines defined in other sections of the Ada Reference Manual (these are
13161 cross-indexed from Annex A).
13165 This is a parent package for all the standard library packages. It is
13166 usually included implicitly in your program, and itself contains no
13167 useful data or routines.
13169 @item Ada.Calendar (9.6)
13170 @code{Calendar} provides time of day access, and routines for
13171 manipulating times and durations.
13173 @item Ada.Characters (A.3.1)
13174 This is a dummy parent package that contains no useful entities
13176 @item Ada.Characters.Handling (A.3.2)
13177 This package provides some basic character handling capabilities,
13178 including classification functions for classes of characters (e.g.@: test
13179 for letters, or digits).
13181 @item Ada.Characters.Latin_1 (A.3.3)
13182 This package includes a complete set of definitions of the characters
13183 that appear in type CHARACTER@. It is useful for writing programs that
13184 will run in international environments. For example, if you want an
13185 upper case E with an acute accent in a string, it is often better to use
13186 the definition of @code{UC_E_Acute} in this package. Then your program
13187 will print in an understandable manner even if your environment does not
13188 support these extended characters.
13190 @item Ada.Command_Line (A.15)
13191 This package provides access to the command line parameters and the name
13192 of the current program (analogous to the use of @code{argc} and @code{argv}
13193 in C), and also allows the exit status for the program to be set in a
13194 system-independent manner.
13196 @item Ada.Decimal (F.2)
13197 This package provides constants describing the range of decimal numbers
13198 implemented, and also a decimal divide routine (analogous to the COBOL
13199 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
13201 @item Ada.Direct_IO (A.8.4)
13202 This package provides input-output using a model of a set of records of
13203 fixed-length, containing an arbitrary definite Ada type, indexed by an
13204 integer record number.
13206 @item Ada.Dynamic_Priorities (D.5)
13207 This package allows the priorities of a task to be adjusted dynamically
13208 as the task is running.
13210 @item Ada.Exceptions (11.4.1)
13211 This package provides additional information on exceptions, and also
13212 contains facilities for treating exceptions as data objects, and raising
13213 exceptions with associated messages.
13215 @item Ada.Finalization (7.6)
13216 This package contains the declarations and subprograms to support the
13217 use of controlled types, providing for automatic initialization and
13218 finalization (analogous to the constructors and destructors of C++)
13220 @item Ada.Interrupts (C.3.2)
13221 This package provides facilities for interfacing to interrupts, which
13222 includes the set of signals or conditions that can be raised and
13223 recognized as interrupts.
13225 @item Ada.Interrupts.Names (C.3.2)
13226 This package provides the set of interrupt names (actually signal
13227 or condition names) that can be handled by GNAT@.
13229 @item Ada.IO_Exceptions (A.13)
13230 This package defines the set of exceptions that can be raised by use of
13231 the standard IO packages.
13234 This package contains some standard constants and exceptions used
13235 throughout the numerics packages. Note that the constants pi and e are
13236 defined here, and it is better to use these definitions than rolling
13239 @item Ada.Numerics.Complex_Elementary_Functions
13240 Provides the implementation of standard elementary functions (such as
13241 log and trigonometric functions) operating on complex numbers using the
13242 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
13243 created by the package @code{Numerics.Complex_Types}.
13245 @item Ada.Numerics.Complex_Types
13246 This is a predefined instantiation of
13247 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
13248 build the type @code{Complex} and @code{Imaginary}.
13250 @item Ada.Numerics.Discrete_Random
13251 This generic package provides a random number generator suitable for generating
13252 uniformly distributed values of a specified discrete subtype.
13254 @item Ada.Numerics.Float_Random
13255 This package provides a random number generator suitable for generating
13256 uniformly distributed floating point values in the unit interval.
13258 @item Ada.Numerics.Generic_Complex_Elementary_Functions
13259 This is a generic version of the package that provides the
13260 implementation of standard elementary functions (such as log and
13261 trigonometric functions) for an arbitrary complex type.
13263 The following predefined instantiations of this package are provided:
13267 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
13269 @code{Ada.Numerics.Complex_Elementary_Functions}
13271 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
13274 @item Ada.Numerics.Generic_Complex_Types
13275 This is a generic package that allows the creation of complex types,
13276 with associated complex arithmetic operations.
13278 The following predefined instantiations of this package exist
13281 @code{Ada.Numerics.Short_Complex_Complex_Types}
13283 @code{Ada.Numerics.Complex_Complex_Types}
13285 @code{Ada.Numerics.Long_Complex_Complex_Types}
13288 @item Ada.Numerics.Generic_Elementary_Functions
13289 This is a generic package that provides the implementation of standard
13290 elementary functions (such as log an trigonometric functions) for an
13291 arbitrary float type.
13293 The following predefined instantiations of this package exist
13297 @code{Ada.Numerics.Short_Elementary_Functions}
13299 @code{Ada.Numerics.Elementary_Functions}
13301 @code{Ada.Numerics.Long_Elementary_Functions}
13304 @item Ada.Real_Time (D.8)
13305 This package provides facilities similar to those of @code{Calendar}, but
13306 operating with a finer clock suitable for real time control. Note that
13307 annex D requires that there be no backward clock jumps, and GNAT generally
13308 guarantees this behavior, but of course if the external clock on which
13309 the GNAT runtime depends is deliberately reset by some external event,
13310 then such a backward jump may occur.
13312 @item Ada.Sequential_IO (A.8.1)
13313 This package provides input-output facilities for sequential files,
13314 which can contain a sequence of values of a single type, which can be
13315 any Ada type, including indefinite (unconstrained) types.
13317 @item Ada.Storage_IO (A.9)
13318 This package provides a facility for mapping arbitrary Ada types to and
13319 from a storage buffer. It is primarily intended for the creation of new
13322 @item Ada.Streams (13.13.1)
13323 This is a generic package that provides the basic support for the
13324 concept of streams as used by the stream attributes (@code{Input},
13325 @code{Output}, @code{Read} and @code{Write}).
13327 @item Ada.Streams.Stream_IO (A.12.1)
13328 This package is a specialization of the type @code{Streams} defined in
13329 package @code{Streams} together with a set of operations providing
13330 Stream_IO capability. The Stream_IO model permits both random and
13331 sequential access to a file which can contain an arbitrary set of values
13332 of one or more Ada types.
13334 @item Ada.Strings (A.4.1)
13335 This package provides some basic constants used by the string handling
13338 @item Ada.Strings.Bounded (A.4.4)
13339 This package provides facilities for handling variable length
13340 strings. The bounded model requires a maximum length. It is thus
13341 somewhat more limited than the unbounded model, but avoids the use of
13342 dynamic allocation or finalization.
13344 @item Ada.Strings.Fixed (A.4.3)
13345 This package provides facilities for handling fixed length strings.
13347 @item Ada.Strings.Maps (A.4.2)
13348 This package provides facilities for handling character mappings and
13349 arbitrarily defined subsets of characters. For instance it is useful in
13350 defining specialized translation tables.
13352 @item Ada.Strings.Maps.Constants (A.4.6)
13353 This package provides a standard set of predefined mappings and
13354 predefined character sets. For example, the standard upper to lower case
13355 conversion table is found in this package. Note that upper to lower case
13356 conversion is non-trivial if you want to take the entire set of
13357 characters, including extended characters like E with an acute accent,
13358 into account. You should use the mappings in this package (rather than
13359 adding 32 yourself) to do case mappings.
13361 @item Ada.Strings.Unbounded (A.4.5)
13362 This package provides facilities for handling variable length
13363 strings. The unbounded model allows arbitrary length strings, but
13364 requires the use of dynamic allocation and finalization.
13366 @item Ada.Strings.Wide_Bounded (A.4.7)
13367 @itemx Ada.Strings.Wide_Fixed (A.4.7)
13368 @itemx Ada.Strings.Wide_Maps (A.4.7)
13369 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
13370 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
13371 These packages provide analogous capabilities to the corresponding
13372 packages without @samp{Wide_} in the name, but operate with the types
13373 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
13374 and @code{Character}.
13376 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
13377 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
13378 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
13379 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
13380 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
13381 These packages provide analogous capabilities to the corresponding
13382 packages without @samp{Wide_} in the name, but operate with the types
13383 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
13384 of @code{String} and @code{Character}.
13386 @item Ada.Synchronous_Task_Control (D.10)
13387 This package provides some standard facilities for controlling task
13388 communication in a synchronous manner.
13391 This package contains definitions for manipulation of the tags of tagged
13394 @item Ada.Task_Attributes
13395 This package provides the capability of associating arbitrary
13396 task-specific data with separate tasks.
13399 This package provides basic text input-output capabilities for
13400 character, string and numeric data. The subpackages of this
13401 package are listed next.
13403 @item Ada.Text_IO.Decimal_IO
13404 Provides input-output facilities for decimal fixed-point types
13406 @item Ada.Text_IO.Enumeration_IO
13407 Provides input-output facilities for enumeration types.
13409 @item Ada.Text_IO.Fixed_IO
13410 Provides input-output facilities for ordinary fixed-point types.
13412 @item Ada.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_Text_IO}
13420 @code{Float_Text_IO}
13422 @code{Long_Float_Text_IO}
13425 @item Ada.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_Text_IO}
13432 @item Short_Integer
13433 @code{Ada.Short_Integer_Text_IO}
13435 @code{Ada.Integer_Text_IO}
13437 @code{Ada.Long_Integer_Text_IO}
13438 @item Long_Long_Integer
13439 @code{Ada.Long_Long_Integer_Text_IO}
13442 @item Ada.Text_IO.Modular_IO
13443 Provides input-output facilities for modular (unsigned) types
13445 @item Ada.Text_IO.Complex_IO (G.1.3)
13446 This package provides basic text input-output capabilities for complex
13449 @item Ada.Text_IO.Editing (F.3.3)
13450 This package contains routines for edited output, analogous to the use
13451 of pictures in COBOL@. The picture formats used by this package are a
13452 close copy of the facility in COBOL@.
13454 @item Ada.Text_IO.Text_Streams (A.12.2)
13455 This package provides a facility that allows Text_IO files to be treated
13456 as streams, so that the stream attributes can be used for writing
13457 arbitrary data, including binary data, to Text_IO files.
13459 @item Ada.Unchecked_Conversion (13.9)
13460 This generic package allows arbitrary conversion from one type to
13461 another of the same size, providing for breaking the type safety in
13462 special circumstances.
13464 If the types have the same Size (more accurately the same Value_Size),
13465 then the effect is simply to transfer the bits from the source to the
13466 target type without any modification. This usage is well defined, and
13467 for simple types whose representation is typically the same across
13468 all implementations, gives a portable method of performing such
13471 If the types do not have the same size, then the result is implementation
13472 defined, and thus may be non-portable. The following describes how GNAT
13473 handles such unchecked conversion cases.
13475 If the types are of different sizes, and are both discrete types, then
13476 the effect is of a normal type conversion without any constraint checking.
13477 In particular if the result type has a larger size, the result will be
13478 zero or sign extended. If the result type has a smaller size, the result
13479 will be truncated by ignoring high order bits.
13481 If the types are of different sizes, and are not both discrete types,
13482 then the conversion works as though pointers were created to the source
13483 and target, and the pointer value is converted. The effect is that bits
13484 are copied from successive low order storage units and bits of the source
13485 up to the length of the target type.
13487 A warning is issued if the lengths differ, since the effect in this
13488 case is implementation dependent, and the above behavior may not match
13489 that of some other compiler.
13491 A pointer to one type may be converted to a pointer to another type using
13492 unchecked conversion. The only case in which the effect is undefined is
13493 when one or both pointers are pointers to unconstrained array types. In
13494 this case, the bounds information may get incorrectly transferred, and in
13495 particular, GNAT uses double size pointers for such types, and it is
13496 meaningless to convert between such pointer types. GNAT will issue a
13497 warning if the alignment of the target designated type is more strict
13498 than the alignment of the source designated type (since the result may
13499 be unaligned in this case).
13501 A pointer other than a pointer to an unconstrained array type may be
13502 converted to and from System.Address. Such usage is common in Ada 83
13503 programs, but note that Ada.Address_To_Access_Conversions is the
13504 preferred method of performing such conversions in Ada 95 and Ada 2005.
13506 unchecked conversion nor Ada.Address_To_Access_Conversions should be
13507 used in conjunction with pointers to unconstrained objects, since
13508 the bounds information cannot be handled correctly in this case.
13510 @item Ada.Unchecked_Deallocation (13.11.2)
13511 This generic package allows explicit freeing of storage previously
13512 allocated by use of an allocator.
13514 @item Ada.Wide_Text_IO (A.11)
13515 This package is similar to @code{Ada.Text_IO}, except that the external
13516 file supports wide character representations, and the internal types are
13517 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13518 and @code{String}. It contains generic subpackages listed next.
13520 @item Ada.Wide_Text_IO.Decimal_IO
13521 Provides input-output facilities for decimal fixed-point types
13523 @item Ada.Wide_Text_IO.Enumeration_IO
13524 Provides input-output facilities for enumeration types.
13526 @item Ada.Wide_Text_IO.Fixed_IO
13527 Provides input-output facilities for ordinary fixed-point types.
13529 @item Ada.Wide_Text_IO.Float_IO
13530 Provides input-output facilities for float types. The following
13531 predefined instantiations of this generic package are available:
13535 @code{Short_Float_Wide_Text_IO}
13537 @code{Float_Wide_Text_IO}
13539 @code{Long_Float_Wide_Text_IO}
13542 @item Ada.Wide_Text_IO.Integer_IO
13543 Provides input-output facilities for integer types. The following
13544 predefined instantiations of this generic package are available:
13547 @item Short_Short_Integer
13548 @code{Ada.Short_Short_Integer_Wide_Text_IO}
13549 @item Short_Integer
13550 @code{Ada.Short_Integer_Wide_Text_IO}
13552 @code{Ada.Integer_Wide_Text_IO}
13554 @code{Ada.Long_Integer_Wide_Text_IO}
13555 @item Long_Long_Integer
13556 @code{Ada.Long_Long_Integer_Wide_Text_IO}
13559 @item Ada.Wide_Text_IO.Modular_IO
13560 Provides input-output facilities for modular (unsigned) types
13562 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
13563 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13564 external file supports wide character representations.
13566 @item Ada.Wide_Text_IO.Editing (F.3.4)
13567 This package is similar to @code{Ada.Text_IO.Editing}, except that the
13568 types are @code{Wide_Character} and @code{Wide_String} instead of
13569 @code{Character} and @code{String}.
13571 @item Ada.Wide_Text_IO.Streams (A.12.3)
13572 This package is similar to @code{Ada.Text_IO.Streams}, except that the
13573 types are @code{Wide_Character} and @code{Wide_String} instead of
13574 @code{Character} and @code{String}.
13576 @item Ada.Wide_Wide_Text_IO (A.11)
13577 This package is similar to @code{Ada.Text_IO}, except that the external
13578 file supports wide character representations, and the internal types are
13579 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13580 and @code{String}. It contains generic subpackages listed next.
13582 @item Ada.Wide_Wide_Text_IO.Decimal_IO
13583 Provides input-output facilities for decimal fixed-point types
13585 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
13586 Provides input-output facilities for enumeration types.
13588 @item Ada.Wide_Wide_Text_IO.Fixed_IO
13589 Provides input-output facilities for ordinary fixed-point types.
13591 @item Ada.Wide_Wide_Text_IO.Float_IO
13592 Provides input-output facilities for float types. The following
13593 predefined instantiations of this generic package are available:
13597 @code{Short_Float_Wide_Wide_Text_IO}
13599 @code{Float_Wide_Wide_Text_IO}
13601 @code{Long_Float_Wide_Wide_Text_IO}
13604 @item Ada.Wide_Wide_Text_IO.Integer_IO
13605 Provides input-output facilities for integer types. The following
13606 predefined instantiations of this generic package are available:
13609 @item Short_Short_Integer
13610 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
13611 @item Short_Integer
13612 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
13614 @code{Ada.Integer_Wide_Wide_Text_IO}
13616 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
13617 @item Long_Long_Integer
13618 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
13621 @item Ada.Wide_Wide_Text_IO.Modular_IO
13622 Provides input-output facilities for modular (unsigned) types
13624 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
13625 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13626 external file supports wide character representations.
13628 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
13629 This package is similar to @code{Ada.Text_IO.Editing}, except that the
13630 types are @code{Wide_Character} and @code{Wide_String} instead of
13631 @code{Character} and @code{String}.
13633 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
13634 This package is similar to @code{Ada.Text_IO.Streams}, except that the
13635 types are @code{Wide_Character} and @code{Wide_String} instead of
13636 @code{Character} and @code{String}.
13639 @node The Implementation of Standard I/O
13640 @chapter The Implementation of Standard I/O
13643 GNAT implements all the required input-output facilities described in
13644 A.6 through A.14. These sections of the Ada Reference Manual describe the
13645 required behavior of these packages from the Ada point of view, and if
13646 you are writing a portable Ada program that does not need to know the
13647 exact manner in which Ada maps to the outside world when it comes to
13648 reading or writing external files, then you do not need to read this
13649 chapter. As long as your files are all regular files (not pipes or
13650 devices), and as long as you write and read the files only from Ada, the
13651 description in the Ada Reference Manual is sufficient.
13653 However, if you want to do input-output to pipes or other devices, such
13654 as the keyboard or screen, or if the files you are dealing with are
13655 either generated by some other language, or to be read by some other
13656 language, then you need to know more about the details of how the GNAT
13657 implementation of these input-output facilities behaves.
13659 In this chapter we give a detailed description of exactly how GNAT
13660 interfaces to the file system. As always, the sources of the system are
13661 available to you for answering questions at an even more detailed level,
13662 but for most purposes the information in this chapter will suffice.
13664 Another reason that you may need to know more about how input-output is
13665 implemented arises when you have a program written in mixed languages
13666 where, for example, files are shared between the C and Ada sections of
13667 the same program. GNAT provides some additional facilities, in the form
13668 of additional child library packages, that facilitate this sharing, and
13669 these additional facilities are also described in this chapter.
13672 * Standard I/O Packages::
13678 * Wide_Wide_Text_IO::
13680 * Text Translation::
13682 * Filenames encoding::
13684 * Operations on C Streams::
13685 * Interfacing to C Streams::
13688 @node Standard I/O Packages
13689 @section Standard I/O Packages
13692 The Standard I/O packages described in Annex A for
13698 Ada.Text_IO.Complex_IO
13700 Ada.Text_IO.Text_Streams
13704 Ada.Wide_Text_IO.Complex_IO
13706 Ada.Wide_Text_IO.Text_Streams
13708 Ada.Wide_Wide_Text_IO
13710 Ada.Wide_Wide_Text_IO.Complex_IO
13712 Ada.Wide_Wide_Text_IO.Text_Streams
13722 are implemented using the C
13723 library streams facility; where
13727 All files are opened using @code{fopen}.
13729 All input/output operations use @code{fread}/@code{fwrite}.
13733 There is no internal buffering of any kind at the Ada library level. The only
13734 buffering is that provided at the system level in the implementation of the
13735 library routines that support streams. This facilitates shared use of these
13736 streams by mixed language programs. Note though that system level buffering is
13737 explicitly enabled at elaboration of the standard I/O packages and that can
13738 have an impact on mixed language programs, in particular those using I/O before
13739 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
13740 the Ada elaboration routine before performing any I/O or when impractical,
13741 flush the common I/O streams and in particular Standard_Output before
13742 elaborating the Ada code.
13745 @section FORM Strings
13748 The format of a FORM string in GNAT is:
13751 "keyword=value,keyword=value,@dots{},keyword=value"
13755 where letters may be in upper or lower case, and there are no spaces
13756 between values. The order of the entries is not important. Currently
13757 the following keywords defined.
13760 TEXT_TRANSLATION=[YES|NO]
13762 WCEM=[n|h|u|s|e|8|b]
13763 ENCODING=[UTF8|8BITS]
13767 The use of these parameters is described later in this section. If an
13768 unrecognized keyword appears in a form string, it is silently ignored
13769 and not considered invalid.
13775 Direct_IO can only be instantiated for definite types. This is a
13776 restriction of the Ada language, which means that the records are fixed
13777 length (the length being determined by @code{@var{type}'Size}, rounded
13778 up to the next storage unit boundary if necessary).
13780 The records of a Direct_IO file are simply written to the file in index
13781 sequence, with the first record starting at offset zero, and subsequent
13782 records following. There is no control information of any kind. For
13783 example, if 32-bit integers are being written, each record takes
13784 4-bytes, so the record at index @var{K} starts at offset
13785 (@var{K}@minus{}1)*4.
13787 There is no limit on the size of Direct_IO files, they are expanded as
13788 necessary to accommodate whatever records are written to the file.
13790 @node Sequential_IO
13791 @section Sequential_IO
13794 Sequential_IO may be instantiated with either a definite (constrained)
13795 or indefinite (unconstrained) type.
13797 For the definite type case, the elements written to the file are simply
13798 the memory images of the data values with no control information of any
13799 kind. The resulting file should be read using the same type, no validity
13800 checking is performed on input.
13802 For the indefinite type case, the elements written consist of two
13803 parts. First is the size of the data item, written as the memory image
13804 of a @code{Interfaces.C.size_t} value, followed by the memory image of
13805 the data value. The resulting file can only be read using the same
13806 (unconstrained) type. Normal assignment checks are performed on these
13807 read operations, and if these checks fail, @code{Data_Error} is
13808 raised. In particular, in the array case, the lengths must match, and in
13809 the variant record case, if the variable for a particular read operation
13810 is constrained, the discriminants must match.
13812 Note that it is not possible to use Sequential_IO to write variable
13813 length array items, and then read the data back into different length
13814 arrays. For example, the following will raise @code{Data_Error}:
13816 @smallexample @c ada
13817 package IO is new Sequential_IO (String);
13822 IO.Write (F, "hello!")
13823 IO.Reset (F, Mode=>In_File);
13830 On some Ada implementations, this will print @code{hell}, but the program is
13831 clearly incorrect, since there is only one element in the file, and that
13832 element is the string @code{hello!}.
13834 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
13835 using Stream_IO, and this is the preferred mechanism. In particular, the
13836 above program fragment rewritten to use Stream_IO will work correctly.
13842 Text_IO files consist of a stream of characters containing the following
13843 special control characters:
13846 LF (line feed, 16#0A#) Line Mark
13847 FF (form feed, 16#0C#) Page Mark
13851 A canonical Text_IO file is defined as one in which the following
13852 conditions are met:
13856 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
13860 The character @code{FF} is used only as a page mark, i.e.@: to mark the
13861 end of a page and consequently can appear only immediately following a
13862 @code{LF} (line mark) character.
13865 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
13866 (line mark, page mark). In the former case, the page mark is implicitly
13867 assumed to be present.
13871 A file written using Text_IO will be in canonical form provided that no
13872 explicit @code{LF} or @code{FF} characters are written using @code{Put}
13873 or @code{Put_Line}. There will be no @code{FF} character at the end of
13874 the file unless an explicit @code{New_Page} operation was performed
13875 before closing the file.
13877 A canonical Text_IO file that is a regular file (i.e., not a device or a
13878 pipe) can be read using any of the routines in Text_IO@. The
13879 semantics in this case will be exactly as defined in the Ada Reference
13880 Manual, and all the routines in Text_IO are fully implemented.
13882 A text file that does not meet the requirements for a canonical Text_IO
13883 file has one of the following:
13887 The file contains @code{FF} characters not immediately following a
13888 @code{LF} character.
13891 The file contains @code{LF} or @code{FF} characters written by
13892 @code{Put} or @code{Put_Line}, which are not logically considered to be
13893 line marks or page marks.
13896 The file ends in a character other than @code{LF} or @code{FF},
13897 i.e.@: there is no explicit line mark or page mark at the end of the file.
13901 Text_IO can be used to read such non-standard text files but subprograms
13902 to do with line or page numbers do not have defined meanings. In
13903 particular, a @code{FF} character that does not follow a @code{LF}
13904 character may or may not be treated as a page mark from the point of
13905 view of page and line numbering. Every @code{LF} character is considered
13906 to end a line, and there is an implied @code{LF} character at the end of
13910 * Text_IO Stream Pointer Positioning::
13911 * Text_IO Reading and Writing Non-Regular Files::
13913 * Treating Text_IO Files as Streams::
13914 * Text_IO Extensions::
13915 * Text_IO Facilities for Unbounded Strings::
13918 @node Text_IO Stream Pointer Positioning
13919 @subsection Stream Pointer Positioning
13922 @code{Ada.Text_IO} has a definition of current position for a file that
13923 is being read. No internal buffering occurs in Text_IO, and usually the
13924 physical position in the stream used to implement the file corresponds
13925 to this logical position defined by Text_IO@. There are two exceptions:
13929 After a call to @code{End_Of_Page} that returns @code{True}, the stream
13930 is positioned past the @code{LF} (line mark) that precedes the page
13931 mark. Text_IO maintains an internal flag so that subsequent read
13932 operations properly handle the logical position which is unchanged by
13933 the @code{End_Of_Page} call.
13936 After a call to @code{End_Of_File} that returns @code{True}, if the
13937 Text_IO file was positioned before the line mark at the end of file
13938 before the call, then the logical position is unchanged, but the stream
13939 is physically positioned right at the end of file (past the line mark,
13940 and past a possible page mark following the line mark. Again Text_IO
13941 maintains internal flags so that subsequent read operations properly
13942 handle the logical position.
13946 These discrepancies have no effect on the observable behavior of
13947 Text_IO, but if a single Ada stream is shared between a C program and
13948 Ada program, or shared (using @samp{shared=yes} in the form string)
13949 between two Ada files, then the difference may be observable in some
13952 @node Text_IO Reading and Writing Non-Regular Files
13953 @subsection Reading and Writing Non-Regular Files
13956 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
13957 can be used for reading and writing. Writing is not affected and the
13958 sequence of characters output is identical to the normal file case, but
13959 for reading, the behavior of Text_IO is modified to avoid undesirable
13960 look-ahead as follows:
13962 An input file that is not a regular file is considered to have no page
13963 marks. Any @code{Ascii.FF} characters (the character normally used for a
13964 page mark) appearing in the file are considered to be data
13965 characters. In particular:
13969 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
13970 following a line mark. If a page mark appears, it will be treated as a
13974 This avoids the need to wait for an extra character to be typed or
13975 entered from the pipe to complete one of these operations.
13978 @code{End_Of_Page} always returns @code{False}
13981 @code{End_Of_File} will return @code{False} if there is a page mark at
13982 the end of the file.
13986 Output to non-regular files is the same as for regular files. Page marks
13987 may be written to non-regular files using @code{New_Page}, but as noted
13988 above they will not be treated as page marks on input if the output is
13989 piped to another Ada program.
13991 Another important discrepancy when reading non-regular files is that the end
13992 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
13993 pressing the @key{EOT} key,
13995 is signaled once (i.e.@: the test @code{End_Of_File}
13996 will yield @code{True}, or a read will
13997 raise @code{End_Error}), but then reading can resume
13998 to read data past that end of
13999 file indication, until another end of file indication is entered.
14001 @node Get_Immediate
14002 @subsection Get_Immediate
14003 @cindex Get_Immediate
14006 Get_Immediate returns the next character (including control characters)
14007 from the input file. In particular, Get_Immediate will return LF or FF
14008 characters used as line marks or page marks. Such operations leave the
14009 file positioned past the control character, and it is thus not treated
14010 as having its normal function. This means that page, line and column
14011 counts after this kind of Get_Immediate call are set as though the mark
14012 did not occur. In the case where a Get_Immediate leaves the file
14013 positioned between the line mark and page mark (which is not normally
14014 possible), it is undefined whether the FF character will be treated as a
14017 @node Treating Text_IO Files as Streams
14018 @subsection Treating Text_IO Files as Streams
14019 @cindex Stream files
14022 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
14023 as a stream. Data written to a Text_IO file in this stream mode is
14024 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
14025 16#0C# (@code{FF}), the resulting file may have non-standard
14026 format. Similarly if read operations are used to read from a Text_IO
14027 file treated as a stream, then @code{LF} and @code{FF} characters may be
14028 skipped and the effect is similar to that described above for
14029 @code{Get_Immediate}.
14031 @node Text_IO Extensions
14032 @subsection Text_IO Extensions
14033 @cindex Text_IO extensions
14036 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
14037 to the standard @code{Text_IO} package:
14040 @item function File_Exists (Name : String) return Boolean;
14041 Determines if a file of the given name exists.
14043 @item function Get_Line return String;
14044 Reads a string from the standard input file. The value returned is exactly
14045 the length of the line that was read.
14047 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
14048 Similar, except that the parameter File specifies the file from which
14049 the string is to be read.
14053 @node Text_IO Facilities for Unbounded Strings
14054 @subsection Text_IO Facilities for Unbounded Strings
14055 @cindex Text_IO for unbounded strings
14056 @cindex Unbounded_String, Text_IO operations
14059 The package @code{Ada.Strings.Unbounded.Text_IO}
14060 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
14061 subprograms useful for Text_IO operations on unbounded strings:
14065 @item function Get_Line (File : File_Type) return Unbounded_String;
14066 Reads a line from the specified file
14067 and returns the result as an unbounded string.
14069 @item procedure Put (File : File_Type; U : Unbounded_String);
14070 Writes the value of the given unbounded string to the specified file
14071 Similar to the effect of
14072 @code{Put (To_String (U))} except that an extra copy is avoided.
14074 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
14075 Writes the value of the given unbounded string to the specified file,
14076 followed by a @code{New_Line}.
14077 Similar to the effect of @code{Put_Line (To_String (U))} except
14078 that an extra copy is avoided.
14082 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
14083 and is optional. If the parameter is omitted, then the standard input or
14084 output file is referenced as appropriate.
14086 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
14087 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
14088 @code{Wide_Text_IO} functionality for unbounded wide strings.
14090 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
14091 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
14092 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
14095 @section Wide_Text_IO
14098 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
14099 both input and output files may contain special sequences that represent
14100 wide character values. The encoding scheme for a given file may be
14101 specified using a FORM parameter:
14108 as part of the FORM string (WCEM = wide character encoding method),
14109 where @var{x} is one of the following characters
14115 Upper half encoding
14127 The encoding methods match those that
14128 can be used in a source
14129 program, but there is no requirement that the encoding method used for
14130 the source program be the same as the encoding method used for files,
14131 and different files may use different encoding methods.
14133 The default encoding method for the standard files, and for opened files
14134 for which no WCEM parameter is given in the FORM string matches the
14135 wide character encoding specified for the main program (the default
14136 being brackets encoding if no coding method was specified with -gnatW).
14140 In this encoding, a wide character is represented by a five character
14148 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
14149 characters (using upper case letters) of the wide character code. For
14150 example, ESC A345 is used to represent the wide character with code
14151 16#A345#. This scheme is compatible with use of the full
14152 @code{Wide_Character} set.
14154 @item Upper Half Coding
14155 The wide character with encoding 16#abcd#, where the upper bit is on
14156 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
14157 16#cd#. The second byte may never be a format control character, but is
14158 not required to be in the upper half. This method can be also used for
14159 shift-JIS or EUC where the internal coding matches the external coding.
14161 @item Shift JIS Coding
14162 A wide character is represented by a two character sequence 16#ab# and
14163 16#cd#, with the restrictions described for upper half encoding as
14164 described above. The internal character code is the corresponding JIS
14165 character according to the standard algorithm for Shift-JIS
14166 conversion. Only characters defined in the JIS code set table can be
14167 used with this encoding method.
14170 A wide character is represented by a two character sequence 16#ab# and
14171 16#cd#, with both characters being in the upper half. The internal
14172 character code is the corresponding JIS character according to the EUC
14173 encoding algorithm. Only characters defined in the JIS code set table
14174 can be used with this encoding method.
14177 A wide character is represented using
14178 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14179 10646-1/Am.2. Depending on the character value, the representation
14180 is a one, two, or three byte sequence:
14183 16#0000#-16#007f#: 2#0xxxxxxx#
14184 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
14185 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14189 where the @var{xxx} bits correspond to the left-padded bits of the
14190 16-bit character value. Note that all lower half ASCII characters
14191 are represented as ASCII bytes and all upper half characters and
14192 other wide characters are represented as sequences of upper-half
14193 (The full UTF-8 scheme allows for encoding 31-bit characters as
14194 6-byte sequences, but in this implementation, all UTF-8 sequences
14195 of four or more bytes length will raise a Constraint_Error, as
14196 will all invalid UTF-8 sequences.)
14198 @item Brackets Coding
14199 In this encoding, a wide character is represented by the following eight
14200 character sequence:
14207 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
14208 characters (using uppercase letters) of the wide character code. For
14209 example, @code{["A345"]} is used to represent the wide character with code
14211 This scheme is compatible with use of the full Wide_Character set.
14212 On input, brackets coding can also be used for upper half characters,
14213 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14214 is only used for wide characters with a code greater than @code{16#FF#}.
14216 Note that brackets coding is not normally used in the context of
14217 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
14218 a portable way of encoding source files. In the context of Wide_Text_IO
14219 or Wide_Wide_Text_IO, it can only be used if the file does not contain
14220 any instance of the left bracket character other than to encode wide
14221 character values using the brackets encoding method. In practice it is
14222 expected that some standard wide character encoding method such
14223 as UTF-8 will be used for text input output.
14225 If brackets notation is used, then any occurrence of a left bracket
14226 in the input file which is not the start of a valid wide character
14227 sequence will cause Constraint_Error to be raised. It is possible to
14228 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
14229 input will interpret this as a left bracket.
14231 However, when a left bracket is output, it will be output as a left bracket
14232 and not as ["5B"]. We make this decision because for normal use of
14233 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
14234 brackets. For example, if we write:
14237 Put_Line ("Start of output [first run]");
14241 we really do not want to have the left bracket in this message clobbered so
14242 that the output reads:
14245 Start of output ["5B"]first run]
14249 In practice brackets encoding is reasonably useful for normal Put_Line use
14250 since we won't get confused between left brackets and wide character
14251 sequences in the output. But for input, or when files are written out
14252 and read back in, it really makes better sense to use one of the standard
14253 encoding methods such as UTF-8.
14258 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
14259 not all wide character
14260 values can be represented. An attempt to output a character that cannot
14261 be represented using the encoding scheme for the file causes
14262 Constraint_Error to be raised. An invalid wide character sequence on
14263 input also causes Constraint_Error to be raised.
14266 * Wide_Text_IO Stream Pointer Positioning::
14267 * Wide_Text_IO Reading and Writing Non-Regular Files::
14270 @node Wide_Text_IO Stream Pointer Positioning
14271 @subsection Stream Pointer Positioning
14274 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14275 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14278 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
14279 normal lower ASCII set (i.e.@: a character in the range:
14281 @smallexample @c ada
14282 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
14286 then although the logical position of the file pointer is unchanged by
14287 the @code{Look_Ahead} call, the stream is physically positioned past the
14288 wide character sequence. Again this is to avoid the need for buffering
14289 or backup, and all @code{Wide_Text_IO} routines check the internal
14290 indication that this situation has occurred so that this is not visible
14291 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
14292 can be observed if the wide text file shares a stream with another file.
14294 @node Wide_Text_IO Reading and Writing Non-Regular Files
14295 @subsection Reading and Writing Non-Regular Files
14298 As in the case of Text_IO, when a non-regular file is read, it is
14299 assumed that the file contains no page marks (any form characters are
14300 treated as data characters), and @code{End_Of_Page} always returns
14301 @code{False}. Similarly, the end of file indication is not sticky, so
14302 it is possible to read beyond an end of file.
14304 @node Wide_Wide_Text_IO
14305 @section Wide_Wide_Text_IO
14308 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
14309 both input and output files may contain special sequences that represent
14310 wide wide character values. The encoding scheme for a given file may be
14311 specified using a FORM parameter:
14318 as part of the FORM string (WCEM = wide character encoding method),
14319 where @var{x} is one of the following characters
14325 Upper half encoding
14337 The encoding methods match those that
14338 can be used in a source
14339 program, but there is no requirement that the encoding method used for
14340 the source program be the same as the encoding method used for files,
14341 and different files may use different encoding methods.
14343 The default encoding method for the standard files, and for opened files
14344 for which no WCEM parameter is given in the FORM string matches the
14345 wide character encoding specified for the main program (the default
14346 being brackets encoding if no coding method was specified with -gnatW).
14351 A wide character is represented using
14352 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14353 10646-1/Am.2. Depending on the character value, the representation
14354 is a one, two, three, or four byte sequence:
14357 16#000000#-16#00007f#: 2#0xxxxxxx#
14358 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
14359 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14360 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
14364 where the @var{xxx} bits correspond to the left-padded bits of the
14365 21-bit character value. Note that all lower half ASCII characters
14366 are represented as ASCII bytes and all upper half characters and
14367 other wide characters are represented as sequences of upper-half
14370 @item Brackets Coding
14371 In this encoding, a wide wide character is represented by the following eight
14372 character sequence if is in wide character range
14378 and by the following ten character sequence if not
14381 [ " a b c d e f " ]
14385 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
14386 are the four or six hexadecimal
14387 characters (using uppercase letters) of the wide wide character code. For
14388 example, @code{["01A345"]} is used to represent the wide wide character
14389 with code @code{16#01A345#}.
14391 This scheme is compatible with use of the full Wide_Wide_Character set.
14392 On input, brackets coding can also be used for upper half characters,
14393 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14394 is only used for wide characters with a code greater than @code{16#FF#}.
14399 If is also possible to use the other Wide_Character encoding methods,
14400 such as Shift-JIS, but the other schemes cannot support the full range
14401 of wide wide characters.
14402 An attempt to output a character that cannot
14403 be represented using the encoding scheme for the file causes
14404 Constraint_Error to be raised. An invalid wide character sequence on
14405 input also causes Constraint_Error to be raised.
14408 * Wide_Wide_Text_IO Stream Pointer Positioning::
14409 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
14412 @node Wide_Wide_Text_IO Stream Pointer Positioning
14413 @subsection Stream Pointer Positioning
14416 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14417 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14420 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
14421 normal lower ASCII set (i.e.@: a character in the range:
14423 @smallexample @c ada
14424 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
14428 then although the logical position of the file pointer is unchanged by
14429 the @code{Look_Ahead} call, the stream is physically positioned past the
14430 wide character sequence. Again this is to avoid the need for buffering
14431 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
14432 indication that this situation has occurred so that this is not visible
14433 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
14434 can be observed if the wide text file shares a stream with another file.
14436 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
14437 @subsection Reading and Writing Non-Regular Files
14440 As in the case of Text_IO, when a non-regular file is read, it is
14441 assumed that the file contains no page marks (any form characters are
14442 treated as data characters), and @code{End_Of_Page} always returns
14443 @code{False}. Similarly, the end of file indication is not sticky, so
14444 it is possible to read beyond an end of file.
14450 A stream file is a sequence of bytes, where individual elements are
14451 written to the file as described in the Ada Reference Manual. The type
14452 @code{Stream_Element} is simply a byte. There are two ways to read or
14453 write a stream file.
14457 The operations @code{Read} and @code{Write} directly read or write a
14458 sequence of stream elements with no control information.
14461 The stream attributes applied to a stream file transfer data in the
14462 manner described for stream attributes.
14465 @node Text Translation
14466 @section Text Translation
14469 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
14470 passed to Text_IO.Create and Text_IO.Open:
14471 @samp{Text_Translation=@var{Yes}} is the default, which means to
14472 translate LF to/from CR/LF on Windows systems.
14473 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
14474 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
14475 may be used to create Unix-style files on
14476 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
14480 @section Shared Files
14483 Section A.14 of the Ada Reference Manual allows implementations to
14484 provide a wide variety of behavior if an attempt is made to access the
14485 same external file with two or more internal files.
14487 To provide a full range of functionality, while at the same time
14488 minimizing the problems of portability caused by this implementation
14489 dependence, GNAT handles file sharing as follows:
14493 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
14494 to open two or more files with the same full name is considered an error
14495 and is not supported. The exception @code{Use_Error} will be
14496 raised. Note that a file that is not explicitly closed by the program
14497 remains open until the program terminates.
14500 If the form parameter @samp{shared=no} appears in the form string, the
14501 file can be opened or created with its own separate stream identifier,
14502 regardless of whether other files sharing the same external file are
14503 opened. The exact effect depends on how the C stream routines handle
14504 multiple accesses to the same external files using separate streams.
14507 If the form parameter @samp{shared=yes} appears in the form string for
14508 each of two or more files opened using the same full name, the same
14509 stream is shared between these files, and the semantics are as described
14510 in Ada Reference Manual, Section A.14.
14514 When a program that opens multiple files with the same name is ported
14515 from another Ada compiler to GNAT, the effect will be that
14516 @code{Use_Error} is raised.
14518 The documentation of the original compiler and the documentation of the
14519 program should then be examined to determine if file sharing was
14520 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
14521 and @code{Create} calls as required.
14523 When a program is ported from GNAT to some other Ada compiler, no
14524 special attention is required unless the @samp{shared=@var{xxx}} form
14525 parameter is used in the program. In this case, you must examine the
14526 documentation of the new compiler to see if it supports the required
14527 file sharing semantics, and form strings modified appropriately. Of
14528 course it may be the case that the program cannot be ported if the
14529 target compiler does not support the required functionality. The best
14530 approach in writing portable code is to avoid file sharing (and hence
14531 the use of the @samp{shared=@var{xxx}} parameter in the form string)
14534 One common use of file sharing in Ada 83 is the use of instantiations of
14535 Sequential_IO on the same file with different types, to achieve
14536 heterogeneous input-output. Although this approach will work in GNAT if
14537 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
14538 for this purpose (using the stream attributes)
14540 @node Filenames encoding
14541 @section Filenames encoding
14544 An encoding form parameter can be used to specify the filename
14545 encoding @samp{encoding=@var{xxx}}.
14549 If the form parameter @samp{encoding=utf8} appears in the form string, the
14550 filename must be encoded in UTF-8.
14553 If the form parameter @samp{encoding=8bits} appears in the form
14554 string, the filename must be a standard 8bits string.
14557 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
14558 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
14559 variable. And if not set @samp{utf8} is assumed.
14563 The current system Windows ANSI code page.
14568 This encoding form parameter is only supported on the Windows
14569 platform. On the other Operating Systems the run-time is supporting
14573 @section Open Modes
14576 @code{Open} and @code{Create} calls result in a call to @code{fopen}
14577 using the mode shown in the following table:
14580 @center @code{Open} and @code{Create} Call Modes
14582 @b{OPEN } @b{CREATE}
14583 Append_File "r+" "w+"
14585 Out_File (Direct_IO) "r+" "w"
14586 Out_File (all other cases) "w" "w"
14587 Inout_File "r+" "w+"
14591 If text file translation is required, then either @samp{b} or @samp{t}
14592 is added to the mode, depending on the setting of Text. Text file
14593 translation refers to the mapping of CR/LF sequences in an external file
14594 to LF characters internally. This mapping only occurs in DOS and
14595 DOS-like systems, and is not relevant to other systems.
14597 A special case occurs with Stream_IO@. As shown in the above table, the
14598 file is initially opened in @samp{r} or @samp{w} mode for the
14599 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
14600 subsequently requires switching from reading to writing or vice-versa,
14601 then the file is reopened in @samp{r+} mode to permit the required operation.
14603 @node Operations on C Streams
14604 @section Operations on C Streams
14605 The package @code{Interfaces.C_Streams} provides an Ada program with direct
14606 access to the C library functions for operations on C streams:
14608 @smallexample @c adanocomment
14609 package Interfaces.C_Streams is
14610 -- Note: the reason we do not use the types that are in
14611 -- Interfaces.C is that we want to avoid dragging in the
14612 -- code in this unit if possible.
14613 subtype chars is System.Address;
14614 -- Pointer to null-terminated array of characters
14615 subtype FILEs is System.Address;
14616 -- Corresponds to the C type FILE*
14617 subtype voids is System.Address;
14618 -- Corresponds to the C type void*
14619 subtype int is Integer;
14620 subtype long is Long_Integer;
14621 -- Note: the above types are subtypes deliberately, and it
14622 -- is part of this spec that the above correspondences are
14623 -- guaranteed. This means that it is legitimate to, for
14624 -- example, use Integer instead of int. We provide these
14625 -- synonyms for clarity, but in some cases it may be
14626 -- convenient to use the underlying types (for example to
14627 -- avoid an unnecessary dependency of a spec on the spec
14629 type size_t is mod 2 ** Standard'Address_Size;
14630 NULL_Stream : constant FILEs;
14631 -- Value returned (NULL in C) to indicate an
14632 -- fdopen/fopen/tmpfile error
14633 ----------------------------------
14634 -- Constants Defined in stdio.h --
14635 ----------------------------------
14636 EOF : constant int;
14637 -- Used by a number of routines to indicate error or
14639 IOFBF : constant int;
14640 IOLBF : constant int;
14641 IONBF : constant int;
14642 -- Used to indicate buffering mode for setvbuf call
14643 SEEK_CUR : constant int;
14644 SEEK_END : constant int;
14645 SEEK_SET : constant int;
14646 -- Used to indicate origin for fseek call
14647 function stdin return FILEs;
14648 function stdout return FILEs;
14649 function stderr return FILEs;
14650 -- Streams associated with standard files
14651 --------------------------
14652 -- Standard C functions --
14653 --------------------------
14654 -- The functions selected below are ones that are
14655 -- available in UNIX (but not necessarily in ANSI C).
14656 -- These are very thin interfaces
14657 -- which copy exactly the C headers. For more
14658 -- documentation on these functions, see the Microsoft C
14659 -- "Run-Time Library Reference" (Microsoft Press, 1990,
14660 -- ISBN 1-55615-225-6), which includes useful information
14661 -- on system compatibility.
14662 procedure clearerr (stream : FILEs);
14663 function fclose (stream : FILEs) return int;
14664 function fdopen (handle : int; mode : chars) return FILEs;
14665 function feof (stream : FILEs) return int;
14666 function ferror (stream : FILEs) return int;
14667 function fflush (stream : FILEs) return int;
14668 function fgetc (stream : FILEs) return int;
14669 function fgets (strng : chars; n : int; stream : FILEs)
14671 function fileno (stream : FILEs) return int;
14672 function fopen (filename : chars; Mode : chars)
14674 -- Note: to maintain target independence, use
14675 -- text_translation_required, a boolean variable defined in
14676 -- a-sysdep.c to deal with the target dependent text
14677 -- translation requirement. If this variable is set,
14678 -- then b/t should be appended to the standard mode
14679 -- argument to set the text translation mode off or on
14681 function fputc (C : int; stream : FILEs) return int;
14682 function fputs (Strng : chars; Stream : FILEs) return int;
14699 function ftell (stream : FILEs) return long;
14706 function isatty (handle : int) return int;
14707 procedure mktemp (template : chars);
14708 -- The return value (which is just a pointer to template)
14710 procedure rewind (stream : FILEs);
14711 function rmtmp return int;
14719 function tmpfile return FILEs;
14720 function ungetc (c : int; stream : FILEs) return int;
14721 function unlink (filename : chars) return int;
14722 ---------------------
14723 -- Extra functions --
14724 ---------------------
14725 -- These functions supply slightly thicker bindings than
14726 -- those above. They are derived from functions in the
14727 -- C Run-Time Library, but may do a bit more work than
14728 -- just directly calling one of the Library functions.
14729 function is_regular_file (handle : int) return int;
14730 -- Tests if given handle is for a regular file (result 1)
14731 -- or for a non-regular file (pipe or device, result 0).
14732 ---------------------------------
14733 -- Control of Text/Binary Mode --
14734 ---------------------------------
14735 -- If text_translation_required is true, then the following
14736 -- functions may be used to dynamically switch a file from
14737 -- binary to text mode or vice versa. These functions have
14738 -- no effect if text_translation_required is false (i.e.@: in
14739 -- normal UNIX mode). Use fileno to get a stream handle.
14740 procedure set_binary_mode (handle : int);
14741 procedure set_text_mode (handle : int);
14742 ----------------------------
14743 -- Full Path Name support --
14744 ----------------------------
14745 procedure full_name (nam : chars; buffer : chars);
14746 -- Given a NUL terminated string representing a file
14747 -- name, returns in buffer a NUL terminated string
14748 -- representing the full path name for the file name.
14749 -- On systems where it is relevant the drive is also
14750 -- part of the full path name. It is the responsibility
14751 -- of the caller to pass an actual parameter for buffer
14752 -- that is big enough for any full path name. Use
14753 -- max_path_len given below as the size of buffer.
14754 max_path_len : integer;
14755 -- Maximum length of an allowable full path name on the
14756 -- system, including a terminating NUL character.
14757 end Interfaces.C_Streams;
14760 @node Interfacing to C Streams
14761 @section Interfacing to C Streams
14764 The packages in this section permit interfacing Ada files to C Stream
14767 @smallexample @c ada
14768 with Interfaces.C_Streams;
14769 package Ada.Sequential_IO.C_Streams is
14770 function C_Stream (F : File_Type)
14771 return Interfaces.C_Streams.FILEs;
14773 (File : in out File_Type;
14774 Mode : in File_Mode;
14775 C_Stream : in Interfaces.C_Streams.FILEs;
14776 Form : in String := "");
14777 end Ada.Sequential_IO.C_Streams;
14779 with Interfaces.C_Streams;
14780 package Ada.Direct_IO.C_Streams is
14781 function C_Stream (F : File_Type)
14782 return Interfaces.C_Streams.FILEs;
14784 (File : in out File_Type;
14785 Mode : in File_Mode;
14786 C_Stream : in Interfaces.C_Streams.FILEs;
14787 Form : in String := "");
14788 end Ada.Direct_IO.C_Streams;
14790 with Interfaces.C_Streams;
14791 package Ada.Text_IO.C_Streams is
14792 function C_Stream (F : File_Type)
14793 return Interfaces.C_Streams.FILEs;
14795 (File : in out File_Type;
14796 Mode : in File_Mode;
14797 C_Stream : in Interfaces.C_Streams.FILEs;
14798 Form : in String := "");
14799 end Ada.Text_IO.C_Streams;
14801 with Interfaces.C_Streams;
14802 package Ada.Wide_Text_IO.C_Streams is
14803 function C_Stream (F : File_Type)
14804 return Interfaces.C_Streams.FILEs;
14806 (File : in out File_Type;
14807 Mode : in File_Mode;
14808 C_Stream : in Interfaces.C_Streams.FILEs;
14809 Form : in String := "");
14810 end Ada.Wide_Text_IO.C_Streams;
14812 with Interfaces.C_Streams;
14813 package Ada.Wide_Wide_Text_IO.C_Streams is
14814 function C_Stream (F : File_Type)
14815 return Interfaces.C_Streams.FILEs;
14817 (File : in out File_Type;
14818 Mode : in File_Mode;
14819 C_Stream : in Interfaces.C_Streams.FILEs;
14820 Form : in String := "");
14821 end Ada.Wide_Wide_Text_IO.C_Streams;
14823 with Interfaces.C_Streams;
14824 package Ada.Stream_IO.C_Streams is
14825 function C_Stream (F : File_Type)
14826 return Interfaces.C_Streams.FILEs;
14828 (File : in out File_Type;
14829 Mode : in File_Mode;
14830 C_Stream : in Interfaces.C_Streams.FILEs;
14831 Form : in String := "");
14832 end Ada.Stream_IO.C_Streams;
14836 In each of these six packages, the @code{C_Stream} function obtains the
14837 @code{FILE} pointer from a currently opened Ada file. It is then
14838 possible to use the @code{Interfaces.C_Streams} package to operate on
14839 this stream, or the stream can be passed to a C program which can
14840 operate on it directly. Of course the program is responsible for
14841 ensuring that only appropriate sequences of operations are executed.
14843 One particular use of relevance to an Ada program is that the
14844 @code{setvbuf} function can be used to control the buffering of the
14845 stream used by an Ada file. In the absence of such a call the standard
14846 default buffering is used.
14848 The @code{Open} procedures in these packages open a file giving an
14849 existing C Stream instead of a file name. Typically this stream is
14850 imported from a C program, allowing an Ada file to operate on an
14853 @node The GNAT Library
14854 @chapter The GNAT Library
14857 The GNAT library contains a number of general and special purpose packages.
14858 It represents functionality that the GNAT developers have found useful, and
14859 which is made available to GNAT users. The packages described here are fully
14860 supported, and upwards compatibility will be maintained in future releases,
14861 so you can use these facilities with the confidence that the same functionality
14862 will be available in future releases.
14864 The chapter here simply gives a brief summary of the facilities available.
14865 The full documentation is found in the spec file for the package. The full
14866 sources of these library packages, including both spec and body, are provided
14867 with all GNAT releases. For example, to find out the full specifications of
14868 the SPITBOL pattern matching capability, including a full tutorial and
14869 extensive examples, look in the @file{g-spipat.ads} file in the library.
14871 For each entry here, the package name (as it would appear in a @code{with}
14872 clause) is given, followed by the name of the corresponding spec file in
14873 parentheses. The packages are children in four hierarchies, @code{Ada},
14874 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
14875 GNAT-specific hierarchy.
14877 Note that an application program should only use packages in one of these
14878 four hierarchies if the package is defined in the Ada Reference Manual,
14879 or is listed in this section of the GNAT Programmers Reference Manual.
14880 All other units should be considered internal implementation units and
14881 should not be directly @code{with}'ed by application code. The use of
14882 a @code{with} statement that references one of these internal implementation
14883 units makes an application potentially dependent on changes in versions
14884 of GNAT, and will generate a warning message.
14887 * Ada.Characters.Latin_9 (a-chlat9.ads)::
14888 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
14889 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
14890 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
14891 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
14892 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
14893 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
14894 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
14895 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
14896 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
14897 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
14898 * Ada.Command_Line.Environment (a-colien.ads)::
14899 * Ada.Command_Line.Remove (a-colire.ads)::
14900 * Ada.Command_Line.Response_File (a-clrefi.ads)::
14901 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
14902 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
14903 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
14904 * Ada.Exceptions.Traceback (a-exctra.ads)::
14905 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
14906 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
14907 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
14908 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
14909 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
14910 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
14911 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
14912 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
14913 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
14914 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
14915 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
14916 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
14917 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
14918 * GNAT.Altivec (g-altive.ads)::
14919 * GNAT.Altivec.Conversions (g-altcon.ads)::
14920 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
14921 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
14922 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
14923 * GNAT.Array_Split (g-arrspl.ads)::
14924 * GNAT.AWK (g-awk.ads)::
14925 * GNAT.Bounded_Buffers (g-boubuf.ads)::
14926 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
14927 * GNAT.Bubble_Sort (g-bubsor.ads)::
14928 * GNAT.Bubble_Sort_A (g-busora.ads)::
14929 * GNAT.Bubble_Sort_G (g-busorg.ads)::
14930 * GNAT.Byte_Order_Mark (g-byorma.ads)::
14931 * GNAT.Byte_Swapping (g-bytswa.ads)::
14932 * GNAT.Calendar (g-calend.ads)::
14933 * GNAT.Calendar.Time_IO (g-catiio.ads)::
14934 * GNAT.Case_Util (g-casuti.ads)::
14935 * GNAT.CGI (g-cgi.ads)::
14936 * GNAT.CGI.Cookie (g-cgicoo.ads)::
14937 * GNAT.CGI.Debug (g-cgideb.ads)::
14938 * GNAT.Command_Line (g-comlin.ads)::
14939 * GNAT.Compiler_Version (g-comver.ads)::
14940 * GNAT.Ctrl_C (g-ctrl_c.ads)::
14941 * GNAT.CRC32 (g-crc32.ads)::
14942 * GNAT.Current_Exception (g-curexc.ads)::
14943 * GNAT.Debug_Pools (g-debpoo.ads)::
14944 * GNAT.Debug_Utilities (g-debuti.ads)::
14945 * GNAT.Decode_String (g-decstr.ads)::
14946 * GNAT.Decode_UTF8_String (g-deutst.ads)::
14947 * GNAT.Directory_Operations (g-dirope.ads)::
14948 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
14949 * GNAT.Dynamic_HTables (g-dynhta.ads)::
14950 * GNAT.Dynamic_Tables (g-dyntab.ads)::
14951 * GNAT.Encode_String (g-encstr.ads)::
14952 * GNAT.Encode_UTF8_String (g-enutst.ads)::
14953 * GNAT.Exception_Actions (g-excact.ads)::
14954 * GNAT.Exception_Traces (g-exctra.ads)::
14955 * GNAT.Exceptions (g-except.ads)::
14956 * GNAT.Expect (g-expect.ads)::
14957 * GNAT.Expect.TTY (g-exptty.ads)::
14958 * GNAT.Float_Control (g-flocon.ads)::
14959 * GNAT.Heap_Sort (g-heasor.ads)::
14960 * GNAT.Heap_Sort_A (g-hesora.ads)::
14961 * GNAT.Heap_Sort_G (g-hesorg.ads)::
14962 * GNAT.HTable (g-htable.ads)::
14963 * GNAT.IO (g-io.ads)::
14964 * GNAT.IO_Aux (g-io_aux.ads)::
14965 * GNAT.Lock_Files (g-locfil.ads)::
14966 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
14967 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
14968 * GNAT.MD5 (g-md5.ads)::
14969 * GNAT.Memory_Dump (g-memdum.ads)::
14970 * GNAT.Most_Recent_Exception (g-moreex.ads)::
14971 * GNAT.OS_Lib (g-os_lib.ads)::
14972 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
14973 * GNAT.Random_Numbers (g-rannum.ads)::
14974 * GNAT.Regexp (g-regexp.ads)::
14975 * GNAT.Registry (g-regist.ads)::
14976 * GNAT.Regpat (g-regpat.ads)::
14977 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
14978 * GNAT.Semaphores (g-semaph.ads)::
14979 * GNAT.Serial_Communications (g-sercom.ads)::
14980 * GNAT.SHA1 (g-sha1.ads)::
14981 * GNAT.SHA224 (g-sha224.ads)::
14982 * GNAT.SHA256 (g-sha256.ads)::
14983 * GNAT.SHA384 (g-sha384.ads)::
14984 * GNAT.SHA512 (g-sha512.ads)::
14985 * GNAT.Signals (g-signal.ads)::
14986 * GNAT.Sockets (g-socket.ads)::
14987 * GNAT.Source_Info (g-souinf.ads)::
14988 * GNAT.Spelling_Checker (g-speche.ads)::
14989 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
14990 * GNAT.Spitbol.Patterns (g-spipat.ads)::
14991 * GNAT.Spitbol (g-spitbo.ads)::
14992 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
14993 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
14994 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
14995 * GNAT.SSE (g-sse.ads)::
14996 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
14997 * GNAT.Strings (g-string.ads)::
14998 * GNAT.String_Split (g-strspl.ads)::
14999 * GNAT.Table (g-table.ads)::
15000 * GNAT.Task_Lock (g-tasloc.ads)::
15001 * GNAT.Threads (g-thread.ads)::
15002 * GNAT.Time_Stamp (g-timsta.ads)::
15003 * GNAT.Traceback (g-traceb.ads)::
15004 * GNAT.Traceback.Symbolic (g-trasym.ads)::
15005 * GNAT.UTF_32 (g-utf_32.ads)::
15006 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
15007 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
15008 * GNAT.Wide_String_Split (g-wistsp.ads)::
15009 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
15010 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
15011 * Interfaces.C.Extensions (i-cexten.ads)::
15012 * Interfaces.C.Streams (i-cstrea.ads)::
15013 * Interfaces.CPP (i-cpp.ads)::
15014 * Interfaces.Packed_Decimal (i-pacdec.ads)::
15015 * Interfaces.VxWorks (i-vxwork.ads)::
15016 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
15017 * System.Address_Image (s-addima.ads)::
15018 * System.Assertions (s-assert.ads)::
15019 * System.Memory (s-memory.ads)::
15020 * System.Partition_Interface (s-parint.ads)::
15021 * System.Pool_Global (s-pooglo.ads)::
15022 * System.Pool_Local (s-pooloc.ads)::
15023 * System.Restrictions (s-restri.ads)::
15024 * System.Rident (s-rident.ads)::
15025 * System.Strings.Stream_Ops (s-ststop.ads)::
15026 * System.Task_Info (s-tasinf.ads)::
15027 * System.Wch_Cnv (s-wchcnv.ads)::
15028 * System.Wch_Con (s-wchcon.ads)::
15031 @node Ada.Characters.Latin_9 (a-chlat9.ads)
15032 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15033 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15034 @cindex Latin_9 constants for Character
15037 This child of @code{Ada.Characters}
15038 provides a set of definitions corresponding to those in the
15039 RM-defined package @code{Ada.Characters.Latin_1} but with the
15040 few modifications required for @code{Latin-9}
15041 The provision of such a package
15042 is specifically authorized by the Ada Reference Manual
15045 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
15046 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15047 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15048 @cindex Latin_1 constants for Wide_Character
15051 This child of @code{Ada.Characters}
15052 provides a set of definitions corresponding to those in the
15053 RM-defined package @code{Ada.Characters.Latin_1} but with the
15054 types of the constants being @code{Wide_Character}
15055 instead of @code{Character}. The provision of such a package
15056 is specifically authorized by the Ada Reference Manual
15059 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
15060 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15061 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15062 @cindex Latin_9 constants for Wide_Character
15065 This child of @code{Ada.Characters}
15066 provides a set of definitions corresponding to those in the
15067 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15068 types of the constants being @code{Wide_Character}
15069 instead of @code{Character}. The provision of such a package
15070 is specifically authorized by the Ada Reference Manual
15073 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
15074 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15075 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15076 @cindex Latin_1 constants for Wide_Wide_Character
15079 This child of @code{Ada.Characters}
15080 provides a set of definitions corresponding to those in the
15081 RM-defined package @code{Ada.Characters.Latin_1} but with the
15082 types of the constants being @code{Wide_Wide_Character}
15083 instead of @code{Character}. The provision of such a package
15084 is specifically authorized by the Ada Reference Manual
15087 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
15088 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15089 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15090 @cindex Latin_9 constants for Wide_Wide_Character
15093 This child of @code{Ada.Characters}
15094 provides a set of definitions corresponding to those in the
15095 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15096 types of the constants being @code{Wide_Wide_Character}
15097 instead of @code{Character}. The provision of such a package
15098 is specifically authorized by the Ada Reference Manual
15101 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
15102 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15103 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15104 @cindex Formal container for doubly linked lists
15107 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15108 container for doubly linked lists, meant to facilitate formal verification of
15109 code using such containers.
15111 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
15112 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15113 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15114 @cindex Formal container for hashed maps
15117 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15118 container for hashed maps, meant to facilitate formal verification of
15119 code using such containers.
15121 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
15122 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15123 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15124 @cindex Formal container for hashed sets
15127 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15128 container for hashed sets, meant to facilitate formal verification of
15129 code using such containers.
15131 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
15132 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15133 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15134 @cindex Formal container for ordered maps
15137 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15138 container for ordered maps, meant to facilitate formal verification of
15139 code using such containers.
15141 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
15142 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15143 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15144 @cindex Formal container for ordered sets
15147 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15148 container for ordered sets, meant to facilitate formal verification of
15149 code using such containers.
15151 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
15152 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15153 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15154 @cindex Formal container for vectors
15157 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15158 container for vectors, meant to facilitate formal verification of
15159 code using such containers.
15161 @node Ada.Command_Line.Environment (a-colien.ads)
15162 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15163 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15164 @cindex Environment entries
15167 This child of @code{Ada.Command_Line}
15168 provides a mechanism for obtaining environment values on systems
15169 where this concept makes sense.
15171 @node Ada.Command_Line.Remove (a-colire.ads)
15172 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15173 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15174 @cindex Removing command line arguments
15175 @cindex Command line, argument removal
15178 This child of @code{Ada.Command_Line}
15179 provides a mechanism for logically removing
15180 arguments from the argument list. Once removed, an argument is not visible
15181 to further calls on the subprograms in @code{Ada.Command_Line} will not
15182 see the removed argument.
15184 @node Ada.Command_Line.Response_File (a-clrefi.ads)
15185 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15186 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15187 @cindex Response file for command line
15188 @cindex Command line, response file
15189 @cindex Command line, handling long command lines
15192 This child of @code{Ada.Command_Line} provides a mechanism facilities for
15193 getting command line arguments from a text file, called a "response file".
15194 Using a response file allow passing a set of arguments to an executable longer
15195 than the maximum allowed by the system on the command line.
15197 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
15198 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15199 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15200 @cindex C Streams, Interfacing with Direct_IO
15203 This package provides subprograms that allow interfacing between
15204 C streams and @code{Direct_IO}. The stream identifier can be
15205 extracted from a file opened on the Ada side, and an Ada file
15206 can be constructed from a stream opened on the C side.
15208 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
15209 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15210 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15211 @cindex Null_Occurrence, testing for
15214 This child subprogram provides a way of testing for the null
15215 exception occurrence (@code{Null_Occurrence}) without raising
15218 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
15219 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15220 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15221 @cindex Null_Occurrence, testing for
15224 This child subprogram is used for handling otherwise unhandled
15225 exceptions (hence the name last chance), and perform clean ups before
15226 terminating the program. Note that this subprogram never returns.
15228 @node Ada.Exceptions.Traceback (a-exctra.ads)
15229 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15230 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15231 @cindex Traceback for Exception Occurrence
15234 This child package provides the subprogram (@code{Tracebacks}) to
15235 give a traceback array of addresses based on an exception
15238 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
15239 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15240 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15241 @cindex C Streams, Interfacing with Sequential_IO
15244 This package provides subprograms that allow interfacing between
15245 C streams and @code{Sequential_IO}. The stream identifier can be
15246 extracted from a file opened on the Ada side, and an Ada file
15247 can be constructed from a stream opened on the C side.
15249 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
15250 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15251 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15252 @cindex C Streams, Interfacing with Stream_IO
15255 This package provides subprograms that allow interfacing between
15256 C streams and @code{Stream_IO}. The stream identifier can be
15257 extracted from a file opened on the Ada side, and an Ada file
15258 can be constructed from a stream opened on the C side.
15260 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
15261 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15262 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15263 @cindex @code{Unbounded_String}, IO support
15264 @cindex @code{Text_IO}, extensions for unbounded strings
15267 This package provides subprograms for Text_IO for unbounded
15268 strings, avoiding the necessity for an intermediate operation
15269 with ordinary strings.
15271 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
15272 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15273 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15274 @cindex @code{Unbounded_Wide_String}, IO support
15275 @cindex @code{Text_IO}, extensions for unbounded wide strings
15278 This package provides subprograms for Text_IO for unbounded
15279 wide strings, avoiding the necessity for an intermediate operation
15280 with ordinary wide strings.
15282 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
15283 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15284 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15285 @cindex @code{Unbounded_Wide_Wide_String}, IO support
15286 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
15289 This package provides subprograms for Text_IO for unbounded
15290 wide wide strings, avoiding the necessity for an intermediate operation
15291 with ordinary wide wide strings.
15293 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
15294 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15295 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15296 @cindex C Streams, Interfacing with @code{Text_IO}
15299 This package provides subprograms that allow interfacing between
15300 C streams and @code{Text_IO}. The stream identifier can be
15301 extracted from a file opened on the Ada side, and an Ada file
15302 can be constructed from a stream opened on the C side.
15304 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
15305 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15306 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15307 @cindex @code{Text_IO} resetting standard files
15310 This procedure is used to reset the status of the standard files used
15311 by Ada.Text_IO. This is useful in a situation (such as a restart in an
15312 embedded application) where the status of the files may change during
15313 execution (for example a standard input file may be redefined to be
15316 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
15317 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15318 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15319 @cindex Unicode categorization, Wide_Character
15322 This package provides subprograms that allow categorization of
15323 Wide_Character values according to Unicode categories.
15325 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
15326 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15327 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15328 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
15331 This package provides subprograms that allow interfacing between
15332 C streams and @code{Wide_Text_IO}. The stream identifier can be
15333 extracted from a file opened on the Ada side, and an Ada file
15334 can be constructed from a stream opened on the C side.
15336 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
15337 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15338 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15339 @cindex @code{Wide_Text_IO} resetting standard files
15342 This procedure is used to reset the status of the standard files used
15343 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
15344 embedded application) where the status of the files may change during
15345 execution (for example a standard input file may be redefined to be
15348 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
15349 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15350 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15351 @cindex Unicode categorization, Wide_Wide_Character
15354 This package provides subprograms that allow categorization of
15355 Wide_Wide_Character values according to Unicode categories.
15357 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
15358 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15359 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15360 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
15363 This package provides subprograms that allow interfacing between
15364 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
15365 extracted from a file opened on the Ada side, and an Ada file
15366 can be constructed from a stream opened on the C side.
15368 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
15369 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15370 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15371 @cindex @code{Wide_Wide_Text_IO} resetting standard files
15374 This procedure is used to reset the status of the standard files used
15375 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
15376 restart in an embedded application) where the status of the files may
15377 change during execution (for example a standard input file may be
15378 redefined to be interactive).
15380 @node GNAT.Altivec (g-altive.ads)
15381 @section @code{GNAT.Altivec} (@file{g-altive.ads})
15382 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
15386 This is the root package of the GNAT AltiVec binding. It provides
15387 definitions of constants and types common to all the versions of the
15390 @node GNAT.Altivec.Conversions (g-altcon.ads)
15391 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15392 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15396 This package provides the Vector/View conversion routines.
15398 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
15399 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15400 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15404 This package exposes the Ada interface to the AltiVec operations on
15405 vector objects. A soft emulation is included by default in the GNAT
15406 library. The hard binding is provided as a separate package. This unit
15407 is common to both bindings.
15409 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
15410 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15411 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15415 This package exposes the various vector types part of the Ada binding
15416 to AltiVec facilities.
15418 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
15419 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15420 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15424 This package provides public 'View' data types from/to which private
15425 vector representations can be converted via
15426 GNAT.Altivec.Conversions. This allows convenient access to individual
15427 vector elements and provides a simple way to initialize vector
15430 @node GNAT.Array_Split (g-arrspl.ads)
15431 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15432 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15433 @cindex Array splitter
15436 Useful array-manipulation routines: given a set of separators, split
15437 an array wherever the separators appear, and provide direct access
15438 to the resulting slices.
15440 @node GNAT.AWK (g-awk.ads)
15441 @section @code{GNAT.AWK} (@file{g-awk.ads})
15442 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
15447 Provides AWK-like parsing functions, with an easy interface for parsing one
15448 or more files containing formatted data. The file is viewed as a database
15449 where each record is a line and a field is a data element in this line.
15451 @node GNAT.Bounded_Buffers (g-boubuf.ads)
15452 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15453 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15455 @cindex Bounded Buffers
15458 Provides a concurrent generic bounded buffer abstraction. Instances are
15459 useful directly or as parts of the implementations of other abstractions,
15462 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
15463 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15464 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15469 Provides a thread-safe asynchronous intertask mailbox communication facility.
15471 @node GNAT.Bubble_Sort (g-bubsor.ads)
15472 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15473 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15475 @cindex Bubble sort
15478 Provides a general implementation of bubble sort usable for sorting arbitrary
15479 data items. Exchange and comparison procedures are provided by passing
15480 access-to-procedure values.
15482 @node GNAT.Bubble_Sort_A (g-busora.ads)
15483 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15484 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15486 @cindex Bubble sort
15489 Provides a general implementation of bubble sort usable for sorting arbitrary
15490 data items. Move and comparison procedures are provided by passing
15491 access-to-procedure values. This is an older version, retained for
15492 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
15494 @node GNAT.Bubble_Sort_G (g-busorg.ads)
15495 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15496 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15498 @cindex Bubble sort
15501 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
15502 are provided as generic parameters, this improves efficiency, especially
15503 if the procedures can be inlined, at the expense of duplicating code for
15504 multiple instantiations.
15506 @node GNAT.Byte_Order_Mark (g-byorma.ads)
15507 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15508 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15509 @cindex UTF-8 representation
15510 @cindex Wide characte representations
15513 Provides a routine which given a string, reads the start of the string to
15514 see whether it is one of the standard byte order marks (BOM's) which signal
15515 the encoding of the string. The routine includes detection of special XML
15516 sequences for various UCS input formats.
15518 @node GNAT.Byte_Swapping (g-bytswa.ads)
15519 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15520 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15521 @cindex Byte swapping
15525 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
15526 Machine-specific implementations are available in some cases.
15528 @node GNAT.Calendar (g-calend.ads)
15529 @section @code{GNAT.Calendar} (@file{g-calend.ads})
15530 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
15531 @cindex @code{Calendar}
15534 Extends the facilities provided by @code{Ada.Calendar} to include handling
15535 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
15536 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
15537 C @code{timeval} format.
15539 @node GNAT.Calendar.Time_IO (g-catiio.ads)
15540 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15541 @cindex @code{Calendar}
15543 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15545 @node GNAT.CRC32 (g-crc32.ads)
15546 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
15547 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
15549 @cindex Cyclic Redundancy Check
15552 This package implements the CRC-32 algorithm. For a full description
15553 of this algorithm see
15554 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
15555 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
15556 Aug.@: 1988. Sarwate, D.V@.
15558 @node GNAT.Case_Util (g-casuti.ads)
15559 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
15560 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
15561 @cindex Casing utilities
15562 @cindex Character handling (@code{GNAT.Case_Util})
15565 A set of simple routines for handling upper and lower casing of strings
15566 without the overhead of the full casing tables
15567 in @code{Ada.Characters.Handling}.
15569 @node GNAT.CGI (g-cgi.ads)
15570 @section @code{GNAT.CGI} (@file{g-cgi.ads})
15571 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
15572 @cindex CGI (Common Gateway Interface)
15575 This is a package for interfacing a GNAT program with a Web server via the
15576 Common Gateway Interface (CGI)@. Basically this package parses the CGI
15577 parameters, which are a set of key/value pairs sent by the Web server. It
15578 builds a table whose index is the key and provides some services to deal
15581 @node GNAT.CGI.Cookie (g-cgicoo.ads)
15582 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15583 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15584 @cindex CGI (Common Gateway Interface) cookie support
15585 @cindex Cookie support in CGI
15588 This is a package to interface a GNAT program with a Web server via the
15589 Common Gateway Interface (CGI). It exports services to deal with Web
15590 cookies (piece of information kept in the Web client software).
15592 @node GNAT.CGI.Debug (g-cgideb.ads)
15593 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15594 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15595 @cindex CGI (Common Gateway Interface) debugging
15598 This is a package to help debugging CGI (Common Gateway Interface)
15599 programs written in Ada.
15601 @node GNAT.Command_Line (g-comlin.ads)
15602 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
15603 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
15604 @cindex Command line
15607 Provides a high level interface to @code{Ada.Command_Line} facilities,
15608 including the ability to scan for named switches with optional parameters
15609 and expand file names using wild card notations.
15611 @node GNAT.Compiler_Version (g-comver.ads)
15612 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15613 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15614 @cindex Compiler Version
15615 @cindex Version, of compiler
15618 Provides a routine for obtaining the version of the compiler used to
15619 compile the program. More accurately this is the version of the binder
15620 used to bind the program (this will normally be the same as the version
15621 of the compiler if a consistent tool set is used to compile all units
15624 @node GNAT.Ctrl_C (g-ctrl_c.ads)
15625 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15626 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15630 Provides a simple interface to handle Ctrl-C keyboard events.
15632 @node GNAT.Current_Exception (g-curexc.ads)
15633 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15634 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15635 @cindex Current exception
15636 @cindex Exception retrieval
15639 Provides access to information on the current exception that has been raised
15640 without the need for using the Ada 95 / Ada 2005 exception choice parameter
15641 specification syntax.
15642 This is particularly useful in simulating typical facilities for
15643 obtaining information about exceptions provided by Ada 83 compilers.
15645 @node GNAT.Debug_Pools (g-debpoo.ads)
15646 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15647 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15649 @cindex Debug pools
15650 @cindex Memory corruption debugging
15653 Provide a debugging storage pools that helps tracking memory corruption
15654 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
15655 @value{EDITION} User's Guide}.
15657 @node GNAT.Debug_Utilities (g-debuti.ads)
15658 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15659 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15663 Provides a few useful utilities for debugging purposes, including conversion
15664 to and from string images of address values. Supports both C and Ada formats
15665 for hexadecimal literals.
15667 @node GNAT.Decode_String (g-decstr.ads)
15668 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
15669 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
15670 @cindex Decoding strings
15671 @cindex String decoding
15672 @cindex Wide character encoding
15677 A generic package providing routines for decoding wide character and wide wide
15678 character strings encoded as sequences of 8-bit characters using a specified
15679 encoding method. Includes validation routines, and also routines for stepping
15680 to next or previous encoded character in an encoded string.
15681 Useful in conjunction with Unicode character coding. Note there is a
15682 preinstantiation for UTF-8. See next entry.
15684 @node GNAT.Decode_UTF8_String (g-deutst.ads)
15685 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15686 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15687 @cindex Decoding strings
15688 @cindex Decoding UTF-8 strings
15689 @cindex UTF-8 string decoding
15690 @cindex Wide character decoding
15695 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
15697 @node GNAT.Directory_Operations (g-dirope.ads)
15698 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15699 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15700 @cindex Directory operations
15703 Provides a set of routines for manipulating directories, including changing
15704 the current directory, making new directories, and scanning the files in a
15707 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
15708 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15709 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15710 @cindex Directory operations iteration
15713 A child unit of GNAT.Directory_Operations providing additional operations
15714 for iterating through directories.
15716 @node GNAT.Dynamic_HTables (g-dynhta.ads)
15717 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15718 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15719 @cindex Hash tables
15722 A generic implementation of hash tables that can be used to hash arbitrary
15723 data. Provided in two forms, a simple form with built in hash functions,
15724 and a more complex form in which the hash function is supplied.
15727 This package provides a facility similar to that of @code{GNAT.HTable},
15728 except that this package declares a type that can be used to define
15729 dynamic instances of the hash table, while an instantiation of
15730 @code{GNAT.HTable} creates a single instance of the hash table.
15732 @node GNAT.Dynamic_Tables (g-dyntab.ads)
15733 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15734 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15735 @cindex Table implementation
15736 @cindex Arrays, extendable
15739 A generic package providing a single dimension array abstraction where the
15740 length of the array can be dynamically modified.
15743 This package provides a facility similar to that of @code{GNAT.Table},
15744 except that this package declares a type that can be used to define
15745 dynamic instances of the table, while an instantiation of
15746 @code{GNAT.Table} creates a single instance of the table type.
15748 @node GNAT.Encode_String (g-encstr.ads)
15749 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
15750 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
15751 @cindex Encoding strings
15752 @cindex String encoding
15753 @cindex Wide character encoding
15758 A generic package providing routines for encoding wide character and wide
15759 wide character strings as sequences of 8-bit characters using a specified
15760 encoding method. Useful in conjunction with Unicode character coding.
15761 Note there is a preinstantiation for UTF-8. See next entry.
15763 @node GNAT.Encode_UTF8_String (g-enutst.ads)
15764 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15765 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15766 @cindex Encoding strings
15767 @cindex Encoding UTF-8 strings
15768 @cindex UTF-8 string encoding
15769 @cindex Wide character encoding
15774 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
15776 @node GNAT.Exception_Actions (g-excact.ads)
15777 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15778 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15779 @cindex Exception actions
15782 Provides callbacks when an exception is raised. Callbacks can be registered
15783 for specific exceptions, or when any exception is raised. This
15784 can be used for instance to force a core dump to ease debugging.
15786 @node GNAT.Exception_Traces (g-exctra.ads)
15787 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15788 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15789 @cindex Exception traces
15793 Provides an interface allowing to control automatic output upon exception
15796 @node GNAT.Exceptions (g-except.ads)
15797 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
15798 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
15799 @cindex Exceptions, Pure
15800 @cindex Pure packages, exceptions
15803 Normally it is not possible to raise an exception with
15804 a message from a subprogram in a pure package, since the
15805 necessary types and subprograms are in @code{Ada.Exceptions}
15806 which is not a pure unit. @code{GNAT.Exceptions} provides a
15807 facility for getting around this limitation for a few
15808 predefined exceptions, and for example allow raising
15809 @code{Constraint_Error} with a message from a pure subprogram.
15811 @node GNAT.Expect (g-expect.ads)
15812 @section @code{GNAT.Expect} (@file{g-expect.ads})
15813 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
15816 Provides a set of subprograms similar to what is available
15817 with the standard Tcl Expect tool.
15818 It allows you to easily spawn and communicate with an external process.
15819 You can send commands or inputs to the process, and compare the output
15820 with some expected regular expression. Currently @code{GNAT.Expect}
15821 is implemented on all native GNAT ports except for OpenVMS@.
15822 It is not implemented for cross ports, and in particular is not
15823 implemented for VxWorks or LynxOS@.
15825 @node GNAT.Expect.TTY (g-exptty.ads)
15826 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15827 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15830 As GNAT.Expect but using pseudo-terminal.
15831 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
15832 ports except for OpenVMS@. It is not implemented for cross ports, and
15833 in particular is not implemented for VxWorks or LynxOS@.
15835 @node GNAT.Float_Control (g-flocon.ads)
15836 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
15837 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
15838 @cindex Floating-Point Processor
15841 Provides an interface for resetting the floating-point processor into the
15842 mode required for correct semantic operation in Ada. Some third party
15843 library calls may cause this mode to be modified, and the Reset procedure
15844 in this package can be used to reestablish the required mode.
15846 @node GNAT.Heap_Sort (g-heasor.ads)
15847 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15848 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15852 Provides a general implementation of heap sort usable for sorting arbitrary
15853 data items. Exchange and comparison procedures are provided by passing
15854 access-to-procedure values. The algorithm used is a modified heap sort
15855 that performs approximately N*log(N) comparisons in the worst case.
15857 @node GNAT.Heap_Sort_A (g-hesora.ads)
15858 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15859 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15863 Provides a general implementation of heap sort usable for sorting arbitrary
15864 data items. Move and comparison procedures are provided by passing
15865 access-to-procedure values. The algorithm used is a modified heap sort
15866 that performs approximately N*log(N) comparisons in the worst case.
15867 This differs from @code{GNAT.Heap_Sort} in having a less convenient
15868 interface, but may be slightly more efficient.
15870 @node GNAT.Heap_Sort_G (g-hesorg.ads)
15871 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15872 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15876 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
15877 are provided as generic parameters, this improves efficiency, especially
15878 if the procedures can be inlined, at the expense of duplicating code for
15879 multiple instantiations.
15881 @node GNAT.HTable (g-htable.ads)
15882 @section @code{GNAT.HTable} (@file{g-htable.ads})
15883 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
15884 @cindex Hash tables
15887 A generic implementation of hash tables that can be used to hash arbitrary
15888 data. Provides two approaches, one a simple static approach, and the other
15889 allowing arbitrary dynamic hash tables.
15891 @node GNAT.IO (g-io.ads)
15892 @section @code{GNAT.IO} (@file{g-io.ads})
15893 @cindex @code{GNAT.IO} (@file{g-io.ads})
15895 @cindex Input/Output facilities
15898 A simple preelaborable input-output package that provides a subset of
15899 simple Text_IO functions for reading characters and strings from
15900 Standard_Input, and writing characters, strings and integers to either
15901 Standard_Output or Standard_Error.
15903 @node GNAT.IO_Aux (g-io_aux.ads)
15904 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15905 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15907 @cindex Input/Output facilities
15909 Provides some auxiliary functions for use with Text_IO, including a test
15910 for whether a file exists, and functions for reading a line of text.
15912 @node GNAT.Lock_Files (g-locfil.ads)
15913 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15914 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15915 @cindex File locking
15916 @cindex Locking using files
15919 Provides a general interface for using files as locks. Can be used for
15920 providing program level synchronization.
15922 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
15923 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15924 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15925 @cindex Random number generation
15928 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
15929 a modified version of the Blum-Blum-Shub generator.
15931 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
15932 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15933 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15934 @cindex Random number generation
15937 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
15938 a modified version of the Blum-Blum-Shub generator.
15940 @node GNAT.MD5 (g-md5.ads)
15941 @section @code{GNAT.MD5} (@file{g-md5.ads})
15942 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
15943 @cindex Message Digest MD5
15946 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
15948 @node GNAT.Memory_Dump (g-memdum.ads)
15949 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15950 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15951 @cindex Dump Memory
15954 Provides a convenient routine for dumping raw memory to either the
15955 standard output or standard error files. Uses GNAT.IO for actual
15958 @node GNAT.Most_Recent_Exception (g-moreex.ads)
15959 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15960 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15961 @cindex Exception, obtaining most recent
15964 Provides access to the most recently raised exception. Can be used for
15965 various logging purposes, including duplicating functionality of some
15966 Ada 83 implementation dependent extensions.
15968 @node GNAT.OS_Lib (g-os_lib.ads)
15969 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15970 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15971 @cindex Operating System interface
15972 @cindex Spawn capability
15975 Provides a range of target independent operating system interface functions,
15976 including time/date management, file operations, subprocess management,
15977 including a portable spawn procedure, and access to environment variables
15978 and error return codes.
15980 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
15981 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15982 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15983 @cindex Hash functions
15986 Provides a generator of static minimal perfect hash functions. No
15987 collisions occur and each item can be retrieved from the table in one
15988 probe (perfect property). The hash table size corresponds to the exact
15989 size of the key set and no larger (minimal property). The key set has to
15990 be know in advance (static property). The hash functions are also order
15991 preserving. If w2 is inserted after w1 in the generator, their
15992 hashcode are in the same order. These hashing functions are very
15993 convenient for use with realtime applications.
15995 @node GNAT.Random_Numbers (g-rannum.ads)
15996 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15997 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15998 @cindex Random number generation
16001 Provides random number capabilities which extend those available in the
16002 standard Ada library and are more convenient to use.
16004 @node GNAT.Regexp (g-regexp.ads)
16005 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
16006 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
16007 @cindex Regular expressions
16008 @cindex Pattern matching
16011 A simple implementation of regular expressions, using a subset of regular
16012 expression syntax copied from familiar Unix style utilities. This is the
16013 simples of the three pattern matching packages provided, and is particularly
16014 suitable for ``file globbing'' applications.
16016 @node GNAT.Registry (g-regist.ads)
16017 @section @code{GNAT.Registry} (@file{g-regist.ads})
16018 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
16019 @cindex Windows Registry
16022 This is a high level binding to the Windows registry. It is possible to
16023 do simple things like reading a key value, creating a new key. For full
16024 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
16025 package provided with the Win32Ada binding
16027 @node GNAT.Regpat (g-regpat.ads)
16028 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
16029 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
16030 @cindex Regular expressions
16031 @cindex Pattern matching
16034 A complete implementation of Unix-style regular expression matching, copied
16035 from the original V7 style regular expression library written in C by
16036 Henry Spencer (and binary compatible with this C library).
16038 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
16039 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16040 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16041 @cindex Secondary Stack Info
16044 Provide the capability to query the high water mark of the current task's
16047 @node GNAT.Semaphores (g-semaph.ads)
16048 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
16049 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
16053 Provides classic counting and binary semaphores using protected types.
16055 @node GNAT.Serial_Communications (g-sercom.ads)
16056 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16057 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16058 @cindex Serial_Communications
16061 Provides a simple interface to send and receive data over a serial
16062 port. This is only supported on GNU/Linux and Windows.
16064 @node GNAT.SHA1 (g-sha1.ads)
16065 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
16066 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
16067 @cindex Secure Hash Algorithm SHA-1
16070 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
16073 @node GNAT.SHA224 (g-sha224.ads)
16074 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
16075 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
16076 @cindex Secure Hash Algorithm SHA-224
16079 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
16081 @node GNAT.SHA256 (g-sha256.ads)
16082 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
16083 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
16084 @cindex Secure Hash Algorithm SHA-256
16087 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
16089 @node GNAT.SHA384 (g-sha384.ads)
16090 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
16091 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
16092 @cindex Secure Hash Algorithm SHA-384
16095 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
16097 @node GNAT.SHA512 (g-sha512.ads)
16098 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
16099 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
16100 @cindex Secure Hash Algorithm SHA-512
16103 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
16105 @node GNAT.Signals (g-signal.ads)
16106 @section @code{GNAT.Signals} (@file{g-signal.ads})
16107 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
16111 Provides the ability to manipulate the blocked status of signals on supported
16114 @node GNAT.Sockets (g-socket.ads)
16115 @section @code{GNAT.Sockets} (@file{g-socket.ads})
16116 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
16120 A high level and portable interface to develop sockets based applications.
16121 This package is based on the sockets thin binding found in
16122 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
16123 on all native GNAT ports except for OpenVMS@. It is not implemented
16124 for the LynxOS@ cross port.
16126 @node GNAT.Source_Info (g-souinf.ads)
16127 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
16128 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
16129 @cindex Source Information
16132 Provides subprograms that give access to source code information known at
16133 compile time, such as the current file name and line number.
16135 @node GNAT.Spelling_Checker (g-speche.ads)
16136 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16137 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16138 @cindex Spell checking
16141 Provides a function for determining whether one string is a plausible
16142 near misspelling of another string.
16144 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
16145 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16146 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16147 @cindex Spell checking
16150 Provides a generic function that can be instantiated with a string type for
16151 determining whether one string is a plausible near misspelling of another
16154 @node GNAT.Spitbol.Patterns (g-spipat.ads)
16155 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16156 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16157 @cindex SPITBOL pattern matching
16158 @cindex Pattern matching
16161 A complete implementation of SNOBOL4 style pattern matching. This is the
16162 most elaborate of the pattern matching packages provided. It fully duplicates
16163 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
16164 efficient algorithm developed by Robert Dewar for the SPITBOL system.
16166 @node GNAT.Spitbol (g-spitbo.ads)
16167 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16168 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16169 @cindex SPITBOL interface
16172 The top level package of the collection of SPITBOL-style functionality, this
16173 package provides basic SNOBOL4 string manipulation functions, such as
16174 Pad, Reverse, Trim, Substr capability, as well as a generic table function
16175 useful for constructing arbitrary mappings from strings in the style of
16176 the SNOBOL4 TABLE function.
16178 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
16179 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16180 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16181 @cindex Sets of strings
16182 @cindex SPITBOL Tables
16185 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16186 for type @code{Standard.Boolean}, giving an implementation of sets of
16189 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
16190 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16191 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16192 @cindex Integer maps
16194 @cindex SPITBOL Tables
16197 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16198 for type @code{Standard.Integer}, giving an implementation of maps
16199 from string to integer values.
16201 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
16202 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16203 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16204 @cindex String maps
16206 @cindex SPITBOL Tables
16209 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
16210 a variable length string type, giving an implementation of general
16211 maps from strings to strings.
16213 @node GNAT.SSE (g-sse.ads)
16214 @section @code{GNAT.SSE} (@file{g-sse.ads})
16215 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
16218 Root of a set of units aimed at offering Ada bindings to a subset of
16219 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
16220 targets. It exposes vector component types together with a general
16221 introduction to the binding contents and use.
16223 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
16224 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16225 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16228 SSE vector types for use with SSE related intrinsics.
16230 @node GNAT.Strings (g-string.ads)
16231 @section @code{GNAT.Strings} (@file{g-string.ads})
16232 @cindex @code{GNAT.Strings} (@file{g-string.ads})
16235 Common String access types and related subprograms. Basically it
16236 defines a string access and an array of string access types.
16238 @node GNAT.String_Split (g-strspl.ads)
16239 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
16240 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
16241 @cindex String splitter
16244 Useful string manipulation routines: given a set of separators, split
16245 a string wherever the separators appear, and provide direct access
16246 to the resulting slices. This package is instantiated from
16247 @code{GNAT.Array_Split}.
16249 @node GNAT.Table (g-table.ads)
16250 @section @code{GNAT.Table} (@file{g-table.ads})
16251 @cindex @code{GNAT.Table} (@file{g-table.ads})
16252 @cindex Table implementation
16253 @cindex Arrays, extendable
16256 A generic package providing a single dimension array abstraction where the
16257 length of the array can be dynamically modified.
16260 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
16261 except that this package declares a single instance of the table type,
16262 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
16263 used to define dynamic instances of the table.
16265 @node GNAT.Task_Lock (g-tasloc.ads)
16266 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16267 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16268 @cindex Task synchronization
16269 @cindex Task locking
16273 A very simple facility for locking and unlocking sections of code using a
16274 single global task lock. Appropriate for use in situations where contention
16275 between tasks is very rarely expected.
16277 @node GNAT.Time_Stamp (g-timsta.ads)
16278 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16279 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16281 @cindex Current time
16284 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
16285 represents the current date and time in ISO 8601 format. This is a very simple
16286 routine with minimal code and there are no dependencies on any other unit.
16288 @node GNAT.Threads (g-thread.ads)
16289 @section @code{GNAT.Threads} (@file{g-thread.ads})
16290 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
16291 @cindex Foreign threads
16292 @cindex Threads, foreign
16295 Provides facilities for dealing with foreign threads which need to be known
16296 by the GNAT run-time system. Consult the documentation of this package for
16297 further details if your program has threads that are created by a non-Ada
16298 environment which then accesses Ada code.
16300 @node GNAT.Traceback (g-traceb.ads)
16301 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
16302 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
16303 @cindex Trace back facilities
16306 Provides a facility for obtaining non-symbolic traceback information, useful
16307 in various debugging situations.
16309 @node GNAT.Traceback.Symbolic (g-trasym.ads)
16310 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16311 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16312 @cindex Trace back facilities
16314 @node GNAT.UTF_32 (g-utf_32.ads)
16315 @section @code{GNAT.UTF_32} (@file{g-table.ads})
16316 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
16317 @cindex Wide character codes
16320 This is a package intended to be used in conjunction with the
16321 @code{Wide_Character} type in Ada 95 and the
16322 @code{Wide_Wide_Character} type in Ada 2005 (available
16323 in @code{GNAT} in Ada 2005 mode). This package contains
16324 Unicode categorization routines, as well as lexical
16325 categorization routines corresponding to the Ada 2005
16326 lexical rules for identifiers and strings, and also a
16327 lower case to upper case fold routine corresponding to
16328 the Ada 2005 rules for identifier equivalence.
16330 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
16331 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16332 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16333 @cindex Spell checking
16336 Provides a function for determining whether one wide wide string is a plausible
16337 near misspelling of another wide wide string, where the strings are represented
16338 using the UTF_32_String type defined in System.Wch_Cnv.
16340 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
16341 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16342 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16343 @cindex Spell checking
16346 Provides a function for determining whether one wide string is a plausible
16347 near misspelling of another wide string.
16349 @node GNAT.Wide_String_Split (g-wistsp.ads)
16350 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16351 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16352 @cindex Wide_String splitter
16355 Useful wide string manipulation routines: given a set of separators, split
16356 a wide string wherever the separators appear, and provide direct access
16357 to the resulting slices. This package is instantiated from
16358 @code{GNAT.Array_Split}.
16360 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
16361 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16362 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16363 @cindex Spell checking
16366 Provides a function for determining whether one wide wide string is a plausible
16367 near misspelling of another wide wide string.
16369 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
16370 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16371 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16372 @cindex Wide_Wide_String splitter
16375 Useful wide wide string manipulation routines: given a set of separators, split
16376 a wide wide string wherever the separators appear, and provide direct access
16377 to the resulting slices. This package is instantiated from
16378 @code{GNAT.Array_Split}.
16380 @node Interfaces.C.Extensions (i-cexten.ads)
16381 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16382 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16385 This package contains additional C-related definitions, intended
16386 for use with either manually or automatically generated bindings
16389 @node Interfaces.C.Streams (i-cstrea.ads)
16390 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16391 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16392 @cindex C streams, interfacing
16395 This package is a binding for the most commonly used operations
16398 @node Interfaces.CPP (i-cpp.ads)
16399 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
16400 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
16401 @cindex C++ interfacing
16402 @cindex Interfacing, to C++
16405 This package provides facilities for use in interfacing to C++. It
16406 is primarily intended to be used in connection with automated tools
16407 for the generation of C++ interfaces.
16409 @node Interfaces.Packed_Decimal (i-pacdec.ads)
16410 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16411 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16412 @cindex IBM Packed Format
16413 @cindex Packed Decimal
16416 This package provides a set of routines for conversions to and
16417 from a packed decimal format compatible with that used on IBM
16420 @node Interfaces.VxWorks (i-vxwork.ads)
16421 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16422 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16423 @cindex Interfacing to VxWorks
16424 @cindex VxWorks, interfacing
16427 This package provides a limited binding to the VxWorks API.
16428 In particular, it interfaces with the
16429 VxWorks hardware interrupt facilities.
16431 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
16432 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16433 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16434 @cindex Interfacing to VxWorks' I/O
16435 @cindex VxWorks, I/O interfacing
16436 @cindex VxWorks, Get_Immediate
16437 @cindex Get_Immediate, VxWorks
16440 This package provides a binding to the ioctl (IO/Control)
16441 function of VxWorks, defining a set of option values and
16442 function codes. A particular use of this package is
16443 to enable the use of Get_Immediate under VxWorks.
16445 @node System.Address_Image (s-addima.ads)
16446 @section @code{System.Address_Image} (@file{s-addima.ads})
16447 @cindex @code{System.Address_Image} (@file{s-addima.ads})
16448 @cindex Address image
16449 @cindex Image, of an address
16452 This function provides a useful debugging
16453 function that gives an (implementation dependent)
16454 string which identifies an address.
16456 @node System.Assertions (s-assert.ads)
16457 @section @code{System.Assertions} (@file{s-assert.ads})
16458 @cindex @code{System.Assertions} (@file{s-assert.ads})
16460 @cindex Assert_Failure, exception
16463 This package provides the declaration of the exception raised
16464 by an run-time assertion failure, as well as the routine that
16465 is used internally to raise this assertion.
16467 @node System.Memory (s-memory.ads)
16468 @section @code{System.Memory} (@file{s-memory.ads})
16469 @cindex @code{System.Memory} (@file{s-memory.ads})
16470 @cindex Memory allocation
16473 This package provides the interface to the low level routines used
16474 by the generated code for allocation and freeing storage for the
16475 default storage pool (analogous to the C routines malloc and free.
16476 It also provides a reallocation interface analogous to the C routine
16477 realloc. The body of this unit may be modified to provide alternative
16478 allocation mechanisms for the default pool, and in addition, direct
16479 calls to this unit may be made for low level allocation uses (for
16480 example see the body of @code{GNAT.Tables}).
16482 @node System.Partition_Interface (s-parint.ads)
16483 @section @code{System.Partition_Interface} (@file{s-parint.ads})
16484 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
16485 @cindex Partition interfacing functions
16488 This package provides facilities for partition interfacing. It
16489 is used primarily in a distribution context when using Annex E
16492 @node System.Pool_Global (s-pooglo.ads)
16493 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
16494 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
16495 @cindex Storage pool, global
16496 @cindex Global storage pool
16499 This package provides a storage pool that is equivalent to the default
16500 storage pool used for access types for which no pool is specifically
16501 declared. It uses malloc/free to allocate/free and does not attempt to
16502 do any automatic reclamation.
16504 @node System.Pool_Local (s-pooloc.ads)
16505 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
16506 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
16507 @cindex Storage pool, local
16508 @cindex Local storage pool
16511 This package provides a storage pool that is intended for use with locally
16512 defined access types. It uses malloc/free for allocate/free, and maintains
16513 a list of allocated blocks, so that all storage allocated for the pool can
16514 be freed automatically when the pool is finalized.
16516 @node System.Restrictions (s-restri.ads)
16517 @section @code{System.Restrictions} (@file{s-restri.ads})
16518 @cindex @code{System.Restrictions} (@file{s-restri.ads})
16519 @cindex Run-time restrictions access
16522 This package provides facilities for accessing at run time
16523 the status of restrictions specified at compile time for
16524 the partition. Information is available both with regard
16525 to actual restrictions specified, and with regard to
16526 compiler determined information on which restrictions
16527 are violated by one or more packages in the partition.
16529 @node System.Rident (s-rident.ads)
16530 @section @code{System.Rident} (@file{s-rident.ads})
16531 @cindex @code{System.Rident} (@file{s-rident.ads})
16532 @cindex Restrictions definitions
16535 This package provides definitions of the restrictions
16536 identifiers supported by GNAT, and also the format of
16537 the restrictions provided in package System.Restrictions.
16538 It is not normally necessary to @code{with} this generic package
16539 since the necessary instantiation is included in
16540 package System.Restrictions.
16542 @node System.Strings.Stream_Ops (s-ststop.ads)
16543 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16544 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16545 @cindex Stream operations
16546 @cindex String stream operations
16549 This package provides a set of stream subprograms for standard string types.
16550 It is intended primarily to support implicit use of such subprograms when
16551 stream attributes are applied to string types, but the subprograms in this
16552 package can be used directly by application programs.
16554 @node System.Task_Info (s-tasinf.ads)
16555 @section @code{System.Task_Info} (@file{s-tasinf.ads})
16556 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
16557 @cindex Task_Info pragma
16560 This package provides target dependent functionality that is used
16561 to support the @code{Task_Info} pragma
16563 @node System.Wch_Cnv (s-wchcnv.ads)
16564 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16565 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16566 @cindex Wide Character, Representation
16567 @cindex Wide String, Conversion
16568 @cindex Representation of wide characters
16571 This package provides routines for converting between
16572 wide and wide wide characters and a representation as a value of type
16573 @code{Standard.String}, using a specified wide character
16574 encoding method. It uses definitions in
16575 package @code{System.Wch_Con}.
16577 @node System.Wch_Con (s-wchcon.ads)
16578 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
16579 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
16582 This package provides definitions and descriptions of
16583 the various methods used for encoding wide characters
16584 in ordinary strings. These definitions are used by
16585 the package @code{System.Wch_Cnv}.
16587 @node Interfacing to Other Languages
16588 @chapter Interfacing to Other Languages
16590 The facilities in annex B of the Ada Reference Manual are fully
16591 implemented in GNAT, and in addition, a full interface to C++ is
16595 * Interfacing to C::
16596 * Interfacing to C++::
16597 * Interfacing to COBOL::
16598 * Interfacing to Fortran::
16599 * Interfacing to non-GNAT Ada code::
16602 @node Interfacing to C
16603 @section Interfacing to C
16606 Interfacing to C with GNAT can use one of two approaches:
16610 The types in the package @code{Interfaces.C} may be used.
16612 Standard Ada types may be used directly. This may be less portable to
16613 other compilers, but will work on all GNAT compilers, which guarantee
16614 correspondence between the C and Ada types.
16618 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
16619 effect, since this is the default. The following table shows the
16620 correspondence between Ada scalar types and the corresponding C types.
16625 @item Short_Integer
16627 @item Short_Short_Integer
16631 @item Long_Long_Integer
16639 @item Long_Long_Float
16640 This is the longest floating-point type supported by the hardware.
16644 Additionally, there are the following general correspondences between Ada
16648 Ada enumeration types map to C enumeration types directly if pragma
16649 @code{Convention C} is specified, which causes them to have int
16650 length. Without pragma @code{Convention C}, Ada enumeration types map to
16651 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
16652 @code{int}, respectively) depending on the number of values passed.
16653 This is the only case in which pragma @code{Convention C} affects the
16654 representation of an Ada type.
16657 Ada access types map to C pointers, except for the case of pointers to
16658 unconstrained types in Ada, which have no direct C equivalent.
16661 Ada arrays map directly to C arrays.
16664 Ada records map directly to C structures.
16667 Packed Ada records map to C structures where all members are bit fields
16668 of the length corresponding to the @code{@var{type}'Size} value in Ada.
16671 @node Interfacing to C++
16672 @section Interfacing to C++
16675 The interface to C++ makes use of the following pragmas, which are
16676 primarily intended to be constructed automatically using a binding generator
16677 tool, although it is possible to construct them by hand.
16679 Using these pragmas it is possible to achieve complete
16680 inter-operability between Ada tagged types and C++ class definitions.
16681 See @ref{Implementation Defined Pragmas}, for more details.
16684 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
16685 The argument denotes an entity in the current declarative region that is
16686 declared as a tagged or untagged record type. It indicates that the type
16687 corresponds to an externally declared C++ class type, and is to be laid
16688 out the same way that C++ would lay out the type.
16690 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
16691 for backward compatibility but its functionality is available
16692 using pragma @code{Import} with @code{Convention} = @code{CPP}.
16694 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
16695 This pragma identifies an imported function (imported in the usual way
16696 with pragma @code{Import}) as corresponding to a C++ constructor.
16699 In addition, C++ exceptions are propagated and can be handled in an
16700 @code{others} choice of an exception handler. The corresponding Ada
16701 occurrence has no message, and the simple name of the exception identity
16702 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
16703 tasks works properly when such foreign exceptions are propagated.
16705 @node Interfacing to COBOL
16706 @section Interfacing to COBOL
16709 Interfacing to COBOL is achieved as described in section B.4 of
16710 the Ada Reference Manual.
16712 @node Interfacing to Fortran
16713 @section Interfacing to Fortran
16716 Interfacing to Fortran is achieved as described in section B.5 of the
16717 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
16718 multi-dimensional array causes the array to be stored in column-major
16719 order as required for convenient interface to Fortran.
16721 @node Interfacing to non-GNAT Ada code
16722 @section Interfacing to non-GNAT Ada code
16724 It is possible to specify the convention @code{Ada} in a pragma
16725 @code{Import} or pragma @code{Export}. However this refers to
16726 the calling conventions used by GNAT, which may or may not be
16727 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
16728 compiler to allow interoperation.
16730 If arguments types are kept simple, and if the foreign compiler generally
16731 follows system calling conventions, then it may be possible to integrate
16732 files compiled by other Ada compilers, provided that the elaboration
16733 issues are adequately addressed (for example by eliminating the
16734 need for any load time elaboration).
16736 In particular, GNAT running on VMS is designed to
16737 be highly compatible with the DEC Ada 83 compiler, so this is one
16738 case in which it is possible to import foreign units of this type,
16739 provided that the data items passed are restricted to simple scalar
16740 values or simple record types without variants, or simple array
16741 types with fixed bounds.
16743 @node Specialized Needs Annexes
16744 @chapter Specialized Needs Annexes
16747 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
16748 required in all implementations. However, as described in this chapter,
16749 GNAT implements all of these annexes:
16752 @item Systems Programming (Annex C)
16753 The Systems Programming Annex is fully implemented.
16755 @item Real-Time Systems (Annex D)
16756 The Real-Time Systems Annex is fully implemented.
16758 @item Distributed Systems (Annex E)
16759 Stub generation is fully implemented in the GNAT compiler. In addition,
16760 a complete compatible PCS is available as part of the GLADE system,
16761 a separate product. When the two
16762 products are used in conjunction, this annex is fully implemented.
16764 @item Information Systems (Annex F)
16765 The Information Systems annex is fully implemented.
16767 @item Numerics (Annex G)
16768 The Numerics Annex is fully implemented.
16770 @item Safety and Security / High-Integrity Systems (Annex H)
16771 The Safety and Security Annex (termed the High-Integrity Systems Annex
16772 in Ada 2005) is fully implemented.
16775 @node Implementation of Specific Ada Features
16776 @chapter Implementation of Specific Ada Features
16779 This chapter describes the GNAT implementation of several Ada language
16783 * Machine Code Insertions::
16784 * GNAT Implementation of Tasking::
16785 * GNAT Implementation of Shared Passive Packages::
16786 * Code Generation for Array Aggregates::
16787 * The Size of Discriminated Records with Default Discriminants::
16788 * Strict Conformance to the Ada Reference Manual::
16791 @node Machine Code Insertions
16792 @section Machine Code Insertions
16793 @cindex Machine Code insertions
16796 Package @code{Machine_Code} provides machine code support as described
16797 in the Ada Reference Manual in two separate forms:
16800 Machine code statements, consisting of qualified expressions that
16801 fit the requirements of RM section 13.8.
16803 An intrinsic callable procedure, providing an alternative mechanism of
16804 including machine instructions in a subprogram.
16808 The two features are similar, and both are closely related to the mechanism
16809 provided by the asm instruction in the GNU C compiler. Full understanding
16810 and use of the facilities in this package requires understanding the asm
16811 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
16812 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
16814 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
16815 semantic restrictions and effects as described below. Both are provided so
16816 that the procedure call can be used as a statement, and the function call
16817 can be used to form a code_statement.
16819 The first example given in the GCC documentation is the C @code{asm}
16822 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
16826 The equivalent can be written for GNAT as:
16828 @smallexample @c ada
16829 Asm ("fsinx %1 %0",
16830 My_Float'Asm_Output ("=f", result),
16831 My_Float'Asm_Input ("f", angle));
16835 The first argument to @code{Asm} is the assembler template, and is
16836 identical to what is used in GNU C@. This string must be a static
16837 expression. The second argument is the output operand list. It is
16838 either a single @code{Asm_Output} attribute reference, or a list of such
16839 references enclosed in parentheses (technically an array aggregate of
16842 The @code{Asm_Output} attribute denotes a function that takes two
16843 parameters. The first is a string, the second is the name of a variable
16844 of the type designated by the attribute prefix. The first (string)
16845 argument is required to be a static expression and designates the
16846 constraint for the parameter (e.g.@: what kind of register is
16847 required). The second argument is the variable to be updated with the
16848 result. The possible values for constraint are the same as those used in
16849 the RTL, and are dependent on the configuration file used to build the
16850 GCC back end. If there are no output operands, then this argument may
16851 either be omitted, or explicitly given as @code{No_Output_Operands}.
16853 The second argument of @code{@var{my_float}'Asm_Output} functions as
16854 though it were an @code{out} parameter, which is a little curious, but
16855 all names have the form of expressions, so there is no syntactic
16856 irregularity, even though normally functions would not be permitted
16857 @code{out} parameters. The third argument is the list of input
16858 operands. It is either a single @code{Asm_Input} attribute reference, or
16859 a list of such references enclosed in parentheses (technically an array
16860 aggregate of such references).
16862 The @code{Asm_Input} attribute denotes a function that takes two
16863 parameters. The first is a string, the second is an expression of the
16864 type designated by the prefix. The first (string) argument is required
16865 to be a static expression, and is the constraint for the parameter,
16866 (e.g.@: what kind of register is required). The second argument is the
16867 value to be used as the input argument. The possible values for the
16868 constant are the same as those used in the RTL, and are dependent on
16869 the configuration file used to built the GCC back end.
16871 If there are no input operands, this argument may either be omitted, or
16872 explicitly given as @code{No_Input_Operands}. The fourth argument, not
16873 present in the above example, is a list of register names, called the
16874 @dfn{clobber} argument. This argument, if given, must be a static string
16875 expression, and is a space or comma separated list of names of registers
16876 that must be considered destroyed as a result of the @code{Asm} call. If
16877 this argument is the null string (the default value), then the code
16878 generator assumes that no additional registers are destroyed.
16880 The fifth argument, not present in the above example, called the
16881 @dfn{volatile} argument, is by default @code{False}. It can be set to
16882 the literal value @code{True} to indicate to the code generator that all
16883 optimizations with respect to the instruction specified should be
16884 suppressed, and that in particular, for an instruction that has outputs,
16885 the instruction will still be generated, even if none of the outputs are
16886 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
16887 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
16888 Generally it is strongly advisable to use Volatile for any ASM statement
16889 that is missing either input or output operands, or when two or more ASM
16890 statements appear in sequence, to avoid unwanted optimizations. A warning
16891 is generated if this advice is not followed.
16893 The @code{Asm} subprograms may be used in two ways. First the procedure
16894 forms can be used anywhere a procedure call would be valid, and
16895 correspond to what the RM calls ``intrinsic'' routines. Such calls can
16896 be used to intersperse machine instructions with other Ada statements.
16897 Second, the function forms, which return a dummy value of the limited
16898 private type @code{Asm_Insn}, can be used in code statements, and indeed
16899 this is the only context where such calls are allowed. Code statements
16900 appear as aggregates of the form:
16902 @smallexample @c ada
16903 Asm_Insn'(Asm (@dots{}));
16904 Asm_Insn'(Asm_Volatile (@dots{}));
16908 In accordance with RM rules, such code statements are allowed only
16909 within subprograms whose entire body consists of such statements. It is
16910 not permissible to intermix such statements with other Ada statements.
16912 Typically the form using intrinsic procedure calls is more convenient
16913 and more flexible. The code statement form is provided to meet the RM
16914 suggestion that such a facility should be made available. The following
16915 is the exact syntax of the call to @code{Asm}. As usual, if named notation
16916 is used, the arguments may be given in arbitrary order, following the
16917 normal rules for use of positional and named arguments)
16921 [Template =>] static_string_EXPRESSION
16922 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
16923 [,[Inputs =>] INPUT_OPERAND_LIST ]
16924 [,[Clobber =>] static_string_EXPRESSION ]
16925 [,[Volatile =>] static_boolean_EXPRESSION] )
16927 OUTPUT_OPERAND_LIST ::=
16928 [PREFIX.]No_Output_Operands
16929 | OUTPUT_OPERAND_ATTRIBUTE
16930 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
16932 OUTPUT_OPERAND_ATTRIBUTE ::=
16933 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
16935 INPUT_OPERAND_LIST ::=
16936 [PREFIX.]No_Input_Operands
16937 | INPUT_OPERAND_ATTRIBUTE
16938 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
16940 INPUT_OPERAND_ATTRIBUTE ::=
16941 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
16945 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
16946 are declared in the package @code{Machine_Code} and must be referenced
16947 according to normal visibility rules. In particular if there is no
16948 @code{use} clause for this package, then appropriate package name
16949 qualification is required.
16951 @node GNAT Implementation of Tasking
16952 @section GNAT Implementation of Tasking
16955 This chapter outlines the basic GNAT approach to tasking (in particular,
16956 a multi-layered library for portability) and discusses issues related
16957 to compliance with the Real-Time Systems Annex.
16960 * Mapping Ada Tasks onto the Underlying Kernel Threads::
16961 * Ensuring Compliance with the Real-Time Annex::
16964 @node Mapping Ada Tasks onto the Underlying Kernel Threads
16965 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
16968 GNAT's run-time support comprises two layers:
16971 @item GNARL (GNAT Run-time Layer)
16972 @item GNULL (GNAT Low-level Library)
16976 In GNAT, Ada's tasking services rely on a platform and OS independent
16977 layer known as GNARL@. This code is responsible for implementing the
16978 correct semantics of Ada's task creation, rendezvous, protected
16981 GNARL decomposes Ada's tasking semantics into simpler lower level
16982 operations such as create a thread, set the priority of a thread,
16983 yield, create a lock, lock/unlock, etc. The spec for these low-level
16984 operations constitutes GNULLI, the GNULL Interface. This interface is
16985 directly inspired from the POSIX real-time API@.
16987 If the underlying executive or OS implements the POSIX standard
16988 faithfully, the GNULL Interface maps as is to the services offered by
16989 the underlying kernel. Otherwise, some target dependent glue code maps
16990 the services offered by the underlying kernel to the semantics expected
16993 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
16994 key point is that each Ada task is mapped on a thread in the underlying
16995 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
16997 In addition Ada task priorities map onto the underlying thread priorities.
16998 Mapping Ada tasks onto the underlying kernel threads has several advantages:
17002 The underlying scheduler is used to schedule the Ada tasks. This
17003 makes Ada tasks as efficient as kernel threads from a scheduling
17007 Interaction with code written in C containing threads is eased
17008 since at the lowest level Ada tasks and C threads map onto the same
17009 underlying kernel concept.
17012 When an Ada task is blocked during I/O the remaining Ada tasks are
17016 On multiprocessor systems Ada tasks can execute in parallel.
17020 Some threads libraries offer a mechanism to fork a new process, with the
17021 child process duplicating the threads from the parent.
17023 support this functionality when the parent contains more than one task.
17024 @cindex Forking a new process
17026 @node Ensuring Compliance with the Real-Time Annex
17027 @subsection Ensuring Compliance with the Real-Time Annex
17028 @cindex Real-Time Systems Annex compliance
17031 Although mapping Ada tasks onto
17032 the underlying threads has significant advantages, it does create some
17033 complications when it comes to respecting the scheduling semantics
17034 specified in the real-time annex (Annex D).
17036 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
17037 scheduling policy states:
17040 @emph{When the active priority of a ready task that is not running
17041 changes, or the setting of its base priority takes effect, the
17042 task is removed from the ready queue for its old active priority
17043 and is added at the tail of the ready queue for its new active
17044 priority, except in the case where the active priority is lowered
17045 due to the loss of inherited priority, in which case the task is
17046 added at the head of the ready queue for its new active priority.}
17050 While most kernels do put tasks at the end of the priority queue when
17051 a task changes its priority, (which respects the main
17052 FIFO_Within_Priorities requirement), almost none keep a thread at the
17053 beginning of its priority queue when its priority drops from the loss
17054 of inherited priority.
17056 As a result most vendors have provided incomplete Annex D implementations.
17058 The GNAT run-time, has a nice cooperative solution to this problem
17059 which ensures that accurate FIFO_Within_Priorities semantics are
17062 The principle is as follows. When an Ada task T is about to start
17063 running, it checks whether some other Ada task R with the same
17064 priority as T has been suspended due to the loss of priority
17065 inheritance. If this is the case, T yields and is placed at the end of
17066 its priority queue. When R arrives at the front of the queue it
17069 Note that this simple scheme preserves the relative order of the tasks
17070 that were ready to execute in the priority queue where R has been
17073 @node GNAT Implementation of Shared Passive Packages
17074 @section GNAT Implementation of Shared Passive Packages
17075 @cindex Shared passive packages
17078 GNAT fully implements the pragma @code{Shared_Passive} for
17079 @cindex pragma @code{Shared_Passive}
17080 the purpose of designating shared passive packages.
17081 This allows the use of passive partitions in the
17082 context described in the Ada Reference Manual; i.e., for communication
17083 between separate partitions of a distributed application using the
17084 features in Annex E.
17086 @cindex Distribution Systems Annex
17088 However, the implementation approach used by GNAT provides for more
17089 extensive usage as follows:
17092 @item Communication between separate programs
17094 This allows separate programs to access the data in passive
17095 partitions, using protected objects for synchronization where
17096 needed. The only requirement is that the two programs have a
17097 common shared file system. It is even possible for programs
17098 running on different machines with different architectures
17099 (e.g.@: different endianness) to communicate via the data in
17100 a passive partition.
17102 @item Persistence between program runs
17104 The data in a passive package can persist from one run of a
17105 program to another, so that a later program sees the final
17106 values stored by a previous run of the same program.
17111 The implementation approach used is to store the data in files. A
17112 separate stream file is created for each object in the package, and
17113 an access to an object causes the corresponding file to be read or
17116 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
17117 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
17118 set to the directory to be used for these files.
17119 The files in this directory
17120 have names that correspond to their fully qualified names. For
17121 example, if we have the package
17123 @smallexample @c ada
17125 pragma Shared_Passive (X);
17132 and the environment variable is set to @code{/stemp/}, then the files created
17133 will have the names:
17141 These files are created when a value is initially written to the object, and
17142 the files are retained until manually deleted. This provides the persistence
17143 semantics. If no file exists, it means that no partition has assigned a value
17144 to the variable; in this case the initial value declared in the package
17145 will be used. This model ensures that there are no issues in synchronizing
17146 the elaboration process, since elaboration of passive packages elaborates the
17147 initial values, but does not create the files.
17149 The files are written using normal @code{Stream_IO} access.
17150 If you want to be able
17151 to communicate between programs or partitions running on different
17152 architectures, then you should use the XDR versions of the stream attribute
17153 routines, since these are architecture independent.
17155 If active synchronization is required for access to the variables in the
17156 shared passive package, then as described in the Ada Reference Manual, the
17157 package may contain protected objects used for this purpose. In this case
17158 a lock file (whose name is @file{___lock} (three underscores)
17159 is created in the shared memory directory.
17160 @cindex @file{___lock} file (for shared passive packages)
17161 This is used to provide the required locking
17162 semantics for proper protected object synchronization.
17164 As of January 2003, GNAT supports shared passive packages on all platforms
17165 except for OpenVMS.
17167 @node Code Generation for Array Aggregates
17168 @section Code Generation for Array Aggregates
17171 * Static constant aggregates with static bounds::
17172 * Constant aggregates with unconstrained nominal types::
17173 * Aggregates with static bounds::
17174 * Aggregates with non-static bounds::
17175 * Aggregates in assignment statements::
17179 Aggregates have a rich syntax and allow the user to specify the values of
17180 complex data structures by means of a single construct. As a result, the
17181 code generated for aggregates can be quite complex and involve loops, case
17182 statements and multiple assignments. In the simplest cases, however, the
17183 compiler will recognize aggregates whose components and constraints are
17184 fully static, and in those cases the compiler will generate little or no
17185 executable code. The following is an outline of the code that GNAT generates
17186 for various aggregate constructs. For further details, you will find it
17187 useful to examine the output produced by the -gnatG flag to see the expanded
17188 source that is input to the code generator. You may also want to examine
17189 the assembly code generated at various levels of optimization.
17191 The code generated for aggregates depends on the context, the component values,
17192 and the type. In the context of an object declaration the code generated is
17193 generally simpler than in the case of an assignment. As a general rule, static
17194 component values and static subtypes also lead to simpler code.
17196 @node Static constant aggregates with static bounds
17197 @subsection Static constant aggregates with static bounds
17200 For the declarations:
17201 @smallexample @c ada
17202 type One_Dim is array (1..10) of integer;
17203 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
17207 GNAT generates no executable code: the constant ar0 is placed in static memory.
17208 The same is true for constant aggregates with named associations:
17210 @smallexample @c ada
17211 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
17212 Cr3 : constant One_Dim := (others => 7777);
17216 The same is true for multidimensional constant arrays such as:
17218 @smallexample @c ada
17219 type two_dim is array (1..3, 1..3) of integer;
17220 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
17224 The same is true for arrays of one-dimensional arrays: the following are
17227 @smallexample @c ada
17228 type ar1b is array (1..3) of boolean;
17229 type ar_ar is array (1..3) of ar1b;
17230 None : constant ar1b := (others => false); -- fully static
17231 None2 : constant ar_ar := (1..3 => None); -- fully static
17235 However, for multidimensional aggregates with named associations, GNAT will
17236 generate assignments and loops, even if all associations are static. The
17237 following two declarations generate a loop for the first dimension, and
17238 individual component assignments for the second dimension:
17240 @smallexample @c ada
17241 Zero1: constant two_dim := (1..3 => (1..3 => 0));
17242 Zero2: constant two_dim := (others => (others => 0));
17245 @node Constant aggregates with unconstrained nominal types
17246 @subsection Constant aggregates with unconstrained nominal types
17249 In such cases the aggregate itself establishes the subtype, so that
17250 associations with @code{others} cannot be used. GNAT determines the
17251 bounds for the actual subtype of the aggregate, and allocates the
17252 aggregate statically as well. No code is generated for the following:
17254 @smallexample @c ada
17255 type One_Unc is array (natural range <>) of integer;
17256 Cr_Unc : constant One_Unc := (12,24,36);
17259 @node Aggregates with static bounds
17260 @subsection Aggregates with static bounds
17263 In all previous examples the aggregate was the initial (and immutable) value
17264 of a constant. If the aggregate initializes a variable, then code is generated
17265 for it as a combination of individual assignments and loops over the target
17266 object. The declarations
17268 @smallexample @c ada
17269 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
17270 Cr_Var2 : One_Dim := (others > -1);
17274 generate the equivalent of
17276 @smallexample @c ada
17282 for I in Cr_Var2'range loop
17287 @node Aggregates with non-static bounds
17288 @subsection Aggregates with non-static bounds
17291 If the bounds of the aggregate are not statically compatible with the bounds
17292 of the nominal subtype of the target, then constraint checks have to be
17293 generated on the bounds. For a multidimensional array, constraint checks may
17294 have to be applied to sub-arrays individually, if they do not have statically
17295 compatible subtypes.
17297 @node Aggregates in assignment statements
17298 @subsection Aggregates in assignment statements
17301 In general, aggregate assignment requires the construction of a temporary,
17302 and a copy from the temporary to the target of the assignment. This is because
17303 it is not always possible to convert the assignment into a series of individual
17304 component assignments. For example, consider the simple case:
17306 @smallexample @c ada
17311 This cannot be converted into:
17313 @smallexample @c ada
17319 So the aggregate has to be built first in a separate location, and then
17320 copied into the target. GNAT recognizes simple cases where this intermediate
17321 step is not required, and the assignments can be performed in place, directly
17322 into the target. The following sufficient criteria are applied:
17326 The bounds of the aggregate are static, and the associations are static.
17328 The components of the aggregate are static constants, names of
17329 simple variables that are not renamings, or expressions not involving
17330 indexed components whose operands obey these rules.
17334 If any of these conditions are violated, the aggregate will be built in
17335 a temporary (created either by the front-end or the code generator) and then
17336 that temporary will be copied onto the target.
17338 @node The Size of Discriminated Records with Default Discriminants
17339 @section The Size of Discriminated Records with Default Discriminants
17342 If a discriminated type @code{T} has discriminants with default values, it is
17343 possible to declare an object of this type without providing an explicit
17346 @smallexample @c ada
17348 type Size is range 1..100;
17350 type Rec (D : Size := 15) is record
17351 Name : String (1..D);
17359 Such an object is said to be @emph{unconstrained}.
17360 The discriminant of the object
17361 can be modified by a full assignment to the object, as long as it preserves the
17362 relation between the value of the discriminant, and the value of the components
17365 @smallexample @c ada
17367 Word := (3, "yes");
17369 Word := (5, "maybe");
17371 Word := (5, "no"); -- raises Constraint_Error
17376 In order to support this behavior efficiently, an unconstrained object is
17377 given the maximum size that any value of the type requires. In the case
17378 above, @code{Word} has storage for the discriminant and for
17379 a @code{String} of length 100.
17380 It is important to note that unconstrained objects do not require dynamic
17381 allocation. It would be an improper implementation to place on the heap those
17382 components whose size depends on discriminants. (This improper implementation
17383 was used by some Ada83 compilers, where the @code{Name} component above
17385 been stored as a pointer to a dynamic string). Following the principle that
17386 dynamic storage management should never be introduced implicitly,
17387 an Ada compiler should reserve the full size for an unconstrained declared
17388 object, and place it on the stack.
17390 This maximum size approach
17391 has been a source of surprise to some users, who expect the default
17392 values of the discriminants to determine the size reserved for an
17393 unconstrained object: ``If the default is 15, why should the object occupy
17395 The answer, of course, is that the discriminant may be later modified,
17396 and its full range of values must be taken into account. This is why the
17401 type Rec (D : Positive := 15) is record
17402 Name : String (1..D);
17410 is flagged by the compiler with a warning:
17411 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
17412 because the required size includes @code{Positive'Last}
17413 bytes. As the first example indicates, the proper approach is to declare an
17414 index type of ``reasonable'' range so that unconstrained objects are not too
17417 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
17418 created in the heap by means of an allocator, then it is @emph{not}
17420 it is constrained by the default values of the discriminants, and those values
17421 cannot be modified by full assignment. This is because in the presence of
17422 aliasing all views of the object (which may be manipulated by different tasks,
17423 say) must be consistent, so it is imperative that the object, once created,
17426 @node Strict Conformance to the Ada Reference Manual
17427 @section Strict Conformance to the Ada Reference Manual
17430 The dynamic semantics defined by the Ada Reference Manual impose a set of
17431 run-time checks to be generated. By default, the GNAT compiler will insert many
17432 run-time checks into the compiled code, including most of those required by the
17433 Ada Reference Manual. However, there are three checks that are not enabled
17434 in the default mode for efficiency reasons: arithmetic overflow checking for
17435 integer operations (including division by zero), checks for access before
17436 elaboration on subprogram calls, and stack overflow checking (most operating
17437 systems do not perform this check by default).
17439 Strict conformance to the Ada Reference Manual can be achieved by adding
17440 three compiler options for overflow checking for integer operations
17441 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
17442 calls and generic instantiations (@option{-gnatE}), and stack overflow
17443 checking (@option{-fstack-check}).
17445 Note that the result of a floating point arithmetic operation in overflow and
17446 invalid situations, when the @code{Machine_Overflows} attribute of the result
17447 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
17448 case for machines compliant with the IEEE floating-point standard, but on
17449 machines that are not fully compliant with this standard, such as Alpha, the
17450 @option{-mieee} compiler flag must be used for achieving IEEE confirming
17451 behavior (although at the cost of a significant performance penalty), so
17452 infinite and NaN values are properly generated.
17455 @node Implementation of Ada 2012 Features
17456 @chapter Implementation of Ada 2012 Features
17457 @cindex Ada 2012 implementation status
17459 This chapter contains a complete list of Ada 2012 features that have been
17460 implemented as of GNAT version 6.4. Generally, these features are only
17461 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
17462 @cindex @option{-gnat12} option
17463 or if the configuration pragma @code{Ada_2012} is used.
17464 @cindex pragma @code{Ada_2012}
17465 @cindex configuration pragma @code{Ada_2012}
17466 @cindex @code{Ada_2012} configuration pragma
17467 However, new pragmas, attributes, and restrictions are
17468 unconditionally available, since the Ada 95 standard allows the addition of
17469 new pragmas, attributes, and restrictions (there are exceptions, which are
17470 documented in the individual descriptions), and also certain packages
17471 were made available in earlier versions of Ada.
17473 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
17474 This date shows the implementation date of the feature. Any wavefront
17475 subsequent to this date will contain the indicated feature, as will any
17476 subsequent releases. A date of 0000-00-00 means that GNAT has always
17477 implemented the feature, or implemented it as soon as it appeared as a
17478 binding interpretation.
17480 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
17481 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
17482 The features are ordered based on the relevant sections of the Ada
17483 Reference Manual (``RM''). When a given AI relates to multiple points
17484 in the RM, the earliest is used.
17486 A complete description of the AIs may be found in
17487 @url{www.ada-auth.org/ai05-summary.html}.
17492 @emph{AI-0176 Quantified expressions (2010-09-29)}
17493 @cindex AI-0176 (Ada 2012 feature)
17496 Both universally and existentially quantified expressions are implemented.
17497 They use the new syntax for iterators proposed in AI05-139-2, as well as
17498 the standard Ada loop syntax.
17501 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
17504 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
17505 @cindex AI-0079 (Ada 2012 feature)
17508 Wide characters in the unicode category @i{other_format} are now allowed in
17509 source programs between tokens, but not within a token such as an identifier.
17512 RM References: 2.01 (4/2) 2.02 (7)
17515 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
17516 @cindex AI-0091 (Ada 2012 feature)
17519 Wide characters in the unicode category @i{other_format} are not permitted
17520 within an identifier, since this can be a security problem. The error
17521 message for this case has been improved to be more specific, but GNAT has
17522 never allowed such characters to appear in identifiers.
17525 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)
17528 @emph{AI-0100 Placement of pragmas (2010-07-01)}
17529 @cindex AI-0100 (Ada 2012 feature)
17532 This AI is an earlier version of AI-163. It simplifies the rules
17533 for legal placement of pragmas. In the case of lists that allow pragmas, if
17534 the list may have no elements, then the list may consist solely of pragmas.
17537 RM References: 2.08 (7)
17540 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
17541 @cindex AI-0163 (Ada 2012 feature)
17544 A statement sequence may be composed entirely of pragmas. It is no longer
17545 necessary to add a dummy @code{null} statement to make the sequence legal.
17548 RM References: 2.08 (7) 2.08 (16)
17552 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
17553 @cindex AI-0080 (Ada 2012 feature)
17556 This is an editorial change only, described as non-testable in the AI.
17559 RM References: 3.01 (7)
17563 @emph{AI-0183 Aspect specifications (2010-08-16)}
17564 @cindex AI-0183 (Ada 2012 feature)
17567 Aspect specifications have been fully implemented except for pre and post-
17568 conditions, and type invariants, which have their own separate AI's. All
17569 forms of declarations listed in the AI are supported. The following is a
17570 list of the aspects supported (with GNAT implementation aspects marked)
17572 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
17573 @item @code{Ada_2005} @tab -- GNAT
17574 @item @code{Ada_2012} @tab -- GNAT
17575 @item @code{Address} @tab
17576 @item @code{Alignment} @tab
17577 @item @code{Atomic} @tab
17578 @item @code{Atomic_Components} @tab
17579 @item @code{Bit_Order} @tab
17580 @item @code{Component_Size} @tab
17581 @item @code{Contract_Case} @tab -- GNAT
17582 @item @code{Discard_Names} @tab
17583 @item @code{External_Tag} @tab
17584 @item @code{Favor_Top_Level} @tab -- GNAT
17585 @item @code{Inline} @tab
17586 @item @code{Inline_Always} @tab -- GNAT
17587 @item @code{Invariant} @tab -- GNAT
17588 @item @code{Machine_Radix} @tab
17589 @item @code{No_Return} @tab
17590 @item @code{Object_Size} @tab -- GNAT
17591 @item @code{Pack} @tab
17592 @item @code{Persistent_BSS} @tab -- GNAT
17593 @item @code{Post} @tab
17594 @item @code{Pre} @tab
17595 @item @code{Predicate} @tab
17596 @item @code{Preelaborable_Initialization} @tab
17597 @item @code{Pure_Function} @tab -- GNAT
17598 @item @code{Remote_Access_Type} @tab -- GNAT
17599 @item @code{Shared} @tab -- GNAT
17600 @item @code{Size} @tab
17601 @item @code{Storage_Pool} @tab
17602 @item @code{Storage_Size} @tab
17603 @item @code{Stream_Size} @tab
17604 @item @code{Suppress} @tab
17605 @item @code{Suppress_Debug_Info} @tab -- GNAT
17606 @item @code{Test_Case} @tab -- GNAT
17607 @item @code{Type_Invariant} @tab
17608 @item @code{Unchecked_Union} @tab
17609 @item @code{Universal_Aliasing} @tab -- GNAT
17610 @item @code{Unmodified} @tab -- GNAT
17611 @item @code{Unreferenced} @tab -- GNAT
17612 @item @code{Unreferenced_Objects} @tab -- GNAT
17613 @item @code{Unsuppress} @tab
17614 @item @code{Value_Size} @tab -- GNAT
17615 @item @code{Volatile} @tab
17616 @item @code{Volatile_Components}
17617 @item @code{Warnings} @tab -- GNAT
17621 Note that for aspects with an expression, e.g. @code{Size}, the expression is
17622 treated like a default expression (visibility is analyzed at the point of
17623 occurrence of the aspect, but evaluation of the expression occurs at the
17624 freeze point of the entity involved.
17627 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
17628 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
17629 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
17630 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
17631 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
17636 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
17637 @cindex AI-0128 (Ada 2012 feature)
17640 If an equality operator ("=") is declared for a type, then the implicitly
17641 declared inequality operator ("/=") is a primitive operation of the type.
17642 This is the only reasonable interpretation, and is the one always implemented
17643 by GNAT, but the RM was not entirely clear in making this point.
17646 RM References: 3.02.03 (6) 6.06 (6)
17649 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
17650 @cindex AI-0003 (Ada 2012 feature)
17653 In Ada 2012, a qualified expression is considered to be syntactically a name,
17654 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
17655 useful in disambiguating some cases of overloading.
17658 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
17662 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
17663 @cindex AI-0120 (Ada 2012 feature)
17666 This is an RM editorial change only. The section that lists objects that are
17667 constant failed to include the current instance of a protected object
17668 within a protected function. This has always been treated as a constant
17672 RM References: 3.03 (21)
17675 @emph{AI-0008 General access to constrained objects (0000-00-00)}
17676 @cindex AI-0008 (Ada 2012 feature)
17679 The wording in the RM implied that if you have a general access to a
17680 constrained object, it could be used to modify the discriminants. This was
17681 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
17682 has always done so in this situation.
17685 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
17689 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
17690 @cindex AI-0093 (Ada 2012 feature)
17693 This is an editorial change only, to make more widespread use of the Ada 2012
17694 ``immutably limited''.
17697 RM References: 3.03 (23.4/3)
17702 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
17703 @cindex AI-0096 (Ada 2012 feature)
17706 In general it is illegal for a type derived from a formal limited type to be
17707 nonlimited. This AI makes an exception to this rule: derivation is legal
17708 if it appears in the private part of the generic, and the formal type is not
17709 tagged. If the type is tagged, the legality check must be applied to the
17710 private part of the package.
17713 RM References: 3.04 (5.1/2) 6.02 (7)
17717 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
17718 @cindex AI-0181 (Ada 2012 feature)
17721 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
17722 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
17723 @code{Image} and @code{Value} attributes for the character types. Strictly
17724 speaking this is an inconsistency with Ada 95, but in practice the use of
17725 these attributes is so obscure that it will not cause problems.
17728 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
17732 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
17733 @cindex AI-0182 (Ada 2012 feature)
17736 This AI allows @code{Character'Value} to accept the string @code{'?'} where
17737 @code{?} is any character including non-graphic control characters. GNAT has
17738 always accepted such strings. It also allows strings such as
17739 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
17740 permission and raises @code{Constraint_Error}, as is certainly still
17744 RM References: 3.05 (56/2)
17748 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
17749 @cindex AI-0214 (Ada 2012 feature)
17752 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
17753 to have default expressions by allowing them when the type is limited. It
17754 is often useful to define a default value for a discriminant even though
17755 it can't be changed by assignment.
17758 RM References: 3.07 (9.1/2) 3.07.02 (3)
17762 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
17763 @cindex AI-0102 (Ada 2012 feature)
17766 It is illegal to assign an anonymous access constant to an anonymous access
17767 variable. The RM did not have a clear rule to prevent this, but GNAT has
17768 always generated an error for this usage.
17771 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
17775 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
17776 @cindex AI-0158 (Ada 2012 feature)
17779 This AI extends the syntax of membership tests to simplify complex conditions
17780 that can be expressed as membership in a subset of values of any type. It
17781 introduces syntax for a list of expressions that may be used in loop contexts
17785 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
17789 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
17790 @cindex AI-0173 (Ada 2012 feature)
17793 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
17794 with the tag of an abstract type, and @code{False} otherwise.
17797 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
17802 @emph{AI-0076 function with controlling result (0000-00-00)}
17803 @cindex AI-0076 (Ada 2012 feature)
17806 This is an editorial change only. The RM defines calls with controlling
17807 results, but uses the term ``function with controlling result'' without an
17808 explicit definition.
17811 RM References: 3.09.02 (2/2)
17815 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
17816 @cindex AI-0126 (Ada 2012 feature)
17819 This AI clarifies dispatching rules, and simply confirms that dispatching
17820 executes the operation of the parent type when there is no explicitly or
17821 implicitly declared operation for the descendant type. This has always been
17822 the case in all versions of GNAT.
17825 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
17829 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
17830 @cindex AI-0097 (Ada 2012 feature)
17833 The RM as written implied that in some cases it was possible to create an
17834 object of an abstract type, by having an abstract extension inherit a non-
17835 abstract constructor from its parent type. This mistake has been corrected
17836 in GNAT and in the RM, and this construct is now illegal.
17839 RM References: 3.09.03 (4/2)
17843 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
17844 @cindex AI-0203 (Ada 2012 feature)
17847 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
17848 permitted such usage.
17851 RM References: 3.09.03 (8/3)
17855 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
17856 @cindex AI-0198 (Ada 2012 feature)
17859 This AI resolves a conflict between two rules involving inherited abstract
17860 operations and predefined operators. If a derived numeric type inherits
17861 an abstract operator, it overrides the predefined one. This interpretation
17862 was always the one implemented in GNAT.
17865 RM References: 3.09.03 (4/3)
17868 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
17869 @cindex AI-0073 (Ada 2012 feature)
17872 This AI covers a number of issues regarding returning abstract types. In
17873 particular generic functions cannot have abstract result types or access
17874 result types designated an abstract type. There are some other cases which
17875 are detailed in the AI. Note that this binding interpretation has not been
17876 retrofitted to operate before Ada 2012 mode, since it caused a significant
17877 number of regressions.
17880 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
17884 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
17885 @cindex AI-0070 (Ada 2012 feature)
17888 This is an editorial change only, there are no testable consequences short of
17889 checking for the absence of generated code for an interface declaration.
17892 RM References: 3.09.04 (18/2)
17896 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
17897 @cindex AI-0208 (Ada 2012 feature)
17900 The wording in the Ada 2005 RM concerning characteristics of incomplete views
17901 was incorrect and implied that some programs intended to be legal were now
17902 illegal. GNAT had never considered such programs illegal, so it has always
17903 implemented the intent of this AI.
17906 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
17910 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
17911 @cindex AI-0162 (Ada 2012 feature)
17914 Incomplete types are made more useful by allowing them to be completed by
17915 private types and private extensions.
17918 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
17923 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
17924 @cindex AI-0098 (Ada 2012 feature)
17927 An unintentional omission in the RM implied some inconsistent restrictions on
17928 the use of anonymous access to subprogram values. These restrictions were not
17929 intentional, and have never been enforced by GNAT.
17932 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
17936 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
17937 @cindex AI-0199 (Ada 2012 feature)
17940 A choice list in a record aggregate can include several components of
17941 (distinct) anonymous access types as long as they have matching designated
17945 RM References: 4.03.01 (16)
17949 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
17950 @cindex AI-0220 (Ada 2012 feature)
17953 This AI addresses a wording problem in the RM that appears to permit some
17954 complex cases of aggregates with non-static discriminants. GNAT has always
17955 implemented the intended semantics.
17958 RM References: 4.03.01 (17)
17961 @emph{AI-0147 Conditional expressions (2009-03-29)}
17962 @cindex AI-0147 (Ada 2012 feature)
17965 Conditional expressions are permitted. The form of such an expression is:
17968 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
17971 The parentheses can be omitted in contexts where parentheses are present
17972 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
17973 clause is omitted, @b{else True} is assumed;
17974 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
17975 @emph{(A implies B)} in standard logic.
17978 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
17979 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
17983 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
17984 @cindex AI-0037 (Ada 2012 feature)
17987 This AI confirms that an association of the form @code{Indx => <>} in an
17988 array aggregate must raise @code{Constraint_Error} if @code{Indx}
17989 is out of range. The RM specified a range check on other associations, but
17990 not when the value of the association was defaulted. GNAT has always inserted
17991 a constraint check on the index value.
17994 RM References: 4.03.03 (29)
17998 @emph{AI-0123 Composability of equality (2010-04-13)}
17999 @cindex AI-0123 (Ada 2012 feature)
18002 Equality of untagged record composes, so that the predefined equality for a
18003 composite type that includes a component of some untagged record type
18004 @code{R} uses the equality operation of @code{R} (which may be user-defined
18005 or predefined). This makes the behavior of untagged records identical to that
18006 of tagged types in this respect.
18008 This change is an incompatibility with previous versions of Ada, but it
18009 corrects a non-uniformity that was often a source of confusion. Analysis of
18010 a large number of industrial programs indicates that in those rare cases
18011 where a composite type had an untagged record component with a user-defined
18012 equality, either there was no use of the composite equality, or else the code
18013 expected the same composability as for tagged types, and thus had a bug that
18014 would be fixed by this change.
18017 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
18022 @emph{AI-0088 The value of exponentiation (0000-00-00)}
18023 @cindex AI-0088 (Ada 2012 feature)
18026 This AI clarifies the equivalence rule given for the dynamic semantics of
18027 exponentiation: the value of the operation can be obtained by repeated
18028 multiplication, but the operation can be implemented otherwise (for example
18029 using the familiar divide-by-two-and-square algorithm, even if this is less
18030 accurate), and does not imply repeated reads of a volatile base.
18033 RM References: 4.05.06 (11)
18036 @emph{AI-0188 Case expressions (2010-01-09)}
18037 @cindex AI-0188 (Ada 2012 feature)
18040 Case expressions are permitted. This allows use of constructs such as:
18042 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
18046 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
18049 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
18050 @cindex AI-0104 (Ada 2012 feature)
18053 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
18054 @code{Constraint_Error} because the default value of the allocated object is
18055 @b{null}. This useless construct is illegal in Ada 2012.
18058 RM References: 4.08 (2)
18061 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
18062 @cindex AI-0157 (Ada 2012 feature)
18065 Allocation and Deallocation from an empty storage pool (i.e. allocation or
18066 deallocation of a pointer for which a static storage size clause of zero
18067 has been given) is now illegal and is detected as such. GNAT
18068 previously gave a warning but not an error.
18071 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
18074 @emph{AI-0179 Statement not required after label (2010-04-10)}
18075 @cindex AI-0179 (Ada 2012 feature)
18078 It is not necessary to have a statement following a label, so a label
18079 can appear at the end of a statement sequence without the need for putting a
18080 null statement afterwards, but it is not allowable to have only labels and
18081 no real statements in a statement sequence.
18084 RM References: 5.01 (2)
18088 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
18089 @cindex AI-139-2 (Ada 2012 feature)
18092 The new syntax for iterating over arrays and containers is now implemented.
18093 Iteration over containers is for now limited to read-only iterators. Only
18094 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
18097 RM References: 5.05
18100 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
18101 @cindex AI-0134 (Ada 2012 feature)
18104 For full conformance, the profiles of anonymous-access-to-subprogram
18105 parameters must match. GNAT has always enforced this rule.
18108 RM References: 6.03.01 (18)
18111 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
18112 @cindex AI-0207 (Ada 2012 feature)
18115 This AI confirms that access_to_constant indication must match for mode
18116 conformance. This was implemented in GNAT when the qualifier was originally
18117 introduced in Ada 2005.
18120 RM References: 6.03.01 (16/2)
18124 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
18125 @cindex AI-0046 (Ada 2012 feature)
18128 For full conformance, in the case of access parameters, the null exclusion
18129 must match (either both or neither must have @code{@b{not null}}).
18132 RM References: 6.03.02 (18)
18136 @emph{AI-0118 The association of parameter associations (0000-00-00)}
18137 @cindex AI-0118 (Ada 2012 feature)
18140 This AI clarifies the rules for named associations in subprogram calls and
18141 generic instantiations. The rules have been in place since Ada 83.
18144 RM References: 6.04.01 (2) 12.03 (9)
18148 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
18149 @cindex AI-0196 (Ada 2012 feature)
18152 Null exclusion checks are not made for @code{@b{out}} parameters when
18153 evaluating the actual parameters. GNAT has never generated these checks.
18156 RM References: 6.04.01 (13)
18159 @emph{AI-0015 Constant return objects (0000-00-00)}
18160 @cindex AI-0015 (Ada 2012 feature)
18163 The return object declared in an @i{extended_return_statement} may be
18164 declared constant. This was always intended, and GNAT has always allowed it.
18167 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
18172 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
18173 @cindex AI-0032 (Ada 2012 feature)
18176 If a function returns a class-wide type, the object of an extended return
18177 statement can be declared with a specific type that is covered by the class-
18178 wide type. This has been implemented in GNAT since the introduction of
18179 extended returns. Note AI-0103 complements this AI by imposing matching
18180 rules for constrained return types.
18183 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
18187 @emph{AI-0103 Static matching for extended return (2010-07-23)}
18188 @cindex AI-0103 (Ada 2012 feature)
18191 If the return subtype of a function is an elementary type or a constrained
18192 type, the subtype indication in an extended return statement must match
18193 statically this return subtype.
18196 RM References: 6.05 (5.2/2)
18200 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
18201 @cindex AI-0058 (Ada 2012 feature)
18204 The RM had some incorrect wording implying wrong treatment of abnormal
18205 completion in an extended return. GNAT has always implemented the intended
18206 correct semantics as described by this AI.
18209 RM References: 6.05 (22/2)
18213 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
18214 @cindex AI-0050 (Ada 2012 feature)
18217 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
18218 not take advantage of these incorrect permissions in any case.
18221 RM References: 6.05 (24/2)
18225 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
18226 @cindex AI-0125 (Ada 2012 feature)
18229 In Ada 2012, the declaration of a primitive operation of a type extension
18230 or private extension can also override an inherited primitive that is not
18231 visible at the point of this declaration.
18234 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
18237 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
18238 @cindex AI-0062 (Ada 2012 feature)
18241 A full constant may have a null exclusion even if its associated deferred
18242 constant does not. GNAT has always allowed this.
18245 RM References: 7.04 (6/2) 7.04 (7.1/2)
18249 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
18250 @cindex AI-0178 (Ada 2012 feature)
18253 This AI clarifies the role of incomplete views and plugs an omission in the
18254 RM. GNAT always correctly restricted the use of incomplete views and types.
18257 RM References: 7.05 (3/2) 7.05 (6/2)
18260 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
18261 @cindex AI-0087 (Ada 2012 feature)
18264 The actual for a formal nonlimited derived type cannot be limited. In
18265 particular, a formal derived type that extends a limited interface but which
18266 is not explicitly limited cannot be instantiated with a limited type.
18269 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
18272 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
18273 @cindex AI-0099 (Ada 2012 feature)
18276 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
18277 and therefore depends on the run-time characteristics of an object (i.e. its
18278 tag) and not on its nominal type. As the AI indicates: ``we do not expect
18279 this to affect any implementation''.
18282 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
18287 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
18288 @cindex AI-0064 (Ada 2012 feature)
18291 This is an editorial change only. The intended behavior is already checked
18292 by an existing ACATS test, which GNAT has always executed correctly.
18295 RM References: 7.06.01 (17.1/1)
18298 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
18299 @cindex AI-0026 (Ada 2012 feature)
18302 Record representation clauses concerning Unchecked_Union types cannot mention
18303 the discriminant of the type. The type of a component declared in the variant
18304 part of an Unchecked_Union cannot be controlled, have controlled components,
18305 nor have protected or task parts. If an Unchecked_Union type is declared
18306 within the body of a generic unit or its descendants, then the type of a
18307 component declared in the variant part cannot be a formal private type or a
18308 formal private extension declared within the same generic unit.
18311 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
18315 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
18316 @cindex AI-0205 (Ada 2012 feature)
18319 This AI corrects a simple omission in the RM. Return objects have always
18320 been visible within an extended return statement.
18323 RM References: 8.03 (17)
18327 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
18328 @cindex AI-0042 (Ada 2012 feature)
18331 This AI fixes a wording gap in the RM. An operation of a synchronized
18332 interface can be implemented by a protected or task entry, but the abstract
18333 operation is not being overridden in the usual sense, and it must be stated
18334 separately that this implementation is legal. This has always been the case
18338 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
18341 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
18342 @cindex AI-0030 (Ada 2012 feature)
18345 Requeue is permitted to a protected, synchronized or task interface primitive
18346 providing it is known that the overriding operation is an entry. Otherwise
18347 the requeue statement has the same effect as a procedure call. Use of pragma
18348 @code{Implemented} provides a way to impose a static requirement on the
18349 overriding operation by adhering to one of the implementation kinds: entry,
18350 protected procedure or any of the above.
18353 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
18354 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
18358 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
18359 @cindex AI-0201 (Ada 2012 feature)
18362 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
18363 attribute, then individual components may not be addressable by independent
18364 tasks. However, if the representation clause has no effect (is confirming),
18365 then independence is not compromised. Furthermore, in GNAT, specification of
18366 other appropriately addressable component sizes (e.g. 16 for 8-bit
18367 characters) also preserves independence. GNAT now gives very clear warnings
18368 both for the declaration of such a type, and for any assignment to its components.
18371 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
18374 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
18375 @cindex AI-0009 (Ada 2012 feature)
18378 This AI introduces the new pragmas @code{Independent} and
18379 @code{Independent_Components},
18380 which control guaranteeing independence of access to objects and components.
18381 The AI also requires independence not unaffected by confirming rep clauses.
18384 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
18385 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
18389 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
18390 @cindex AI-0072 (Ada 2012 feature)
18393 This AI clarifies that task signalling for reading @code{'Terminated} only
18394 occurs if the result is True. GNAT semantics has always been consistent with
18395 this notion of task signalling.
18398 RM References: 9.10 (6.1/1)
18401 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
18402 @cindex AI-0108 (Ada 2012 feature)
18405 This AI confirms that an incomplete type from a limited view does not have
18406 discriminants. This has always been the case in GNAT.
18409 RM References: 10.01.01 (12.3/2)
18412 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
18413 @cindex AI-0129 (Ada 2012 feature)
18416 This AI clarifies the description of limited views: a limited view of a
18417 package includes only one view of a type that has an incomplete declaration
18418 and a full declaration (there is no possible ambiguity in a client package).
18419 This AI also fixes an omission: a nested package in the private part has no
18420 limited view. GNAT always implemented this correctly.
18423 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
18428 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
18429 @cindex AI-0077 (Ada 2012 feature)
18432 This AI clarifies that a declaration does not include a context clause,
18433 and confirms that it is illegal to have a context in which both a limited
18434 and a nonlimited view of a package are accessible. Such double visibility
18435 was always rejected by GNAT.
18438 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
18441 @emph{AI-0122 Private with and children of generics (0000-00-00)}
18442 @cindex AI-0122 (Ada 2012 feature)
18445 This AI clarifies the visibility of private children of generic units within
18446 instantiations of a parent. GNAT has always handled this correctly.
18449 RM References: 10.01.02 (12/2)
18454 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
18455 @cindex AI-0040 (Ada 2012 feature)
18458 This AI confirms that a limited with clause in a child unit cannot name
18459 an ancestor of the unit. This has always been checked in GNAT.
18462 RM References: 10.01.02 (20/2)
18465 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
18466 @cindex AI-0132 (Ada 2012 feature)
18469 This AI fills a gap in the description of library unit pragmas. The pragma
18470 clearly must apply to a library unit, even if it does not carry the name
18471 of the enclosing unit. GNAT has always enforced the required check.
18474 RM References: 10.01.05 (7)
18478 @emph{AI-0034 Categorization of limited views (0000-00-00)}
18479 @cindex AI-0034 (Ada 2012 feature)
18482 The RM makes certain limited with clauses illegal because of categorization
18483 considerations, when the corresponding normal with would be legal. This is
18484 not intended, and GNAT has always implemented the recommended behavior.
18487 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
18491 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
18492 @cindex AI-0035 (Ada 2012 feature)
18495 This AI remedies some inconsistencies in the legality rules for Pure units.
18496 Derived access types are legal in a pure unit (on the assumption that the
18497 rule for a zero storage pool size has been enforced on the ancestor type).
18498 The rules are enforced in generic instances and in subunits. GNAT has always
18499 implemented the recommended behavior.
18502 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)
18506 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
18507 @cindex AI-0219 (Ada 2012 feature)
18510 This AI refines the rules for the cases with limited parameters which do not
18511 allow the implementations to omit ``redundant''. GNAT now properly conforms
18512 to the requirements of this binding interpretation.
18515 RM References: 10.02.01 (18/2)
18518 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
18519 @cindex AI-0043 (Ada 2012 feature)
18522 This AI covers various omissions in the RM regarding the raising of
18523 exceptions. GNAT has always implemented the intended semantics.
18526 RM References: 11.04.01 (10.1/2) 11 (2)
18530 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
18531 @cindex AI-0200 (Ada 2012 feature)
18534 This AI plugs a gap in the RM which appeared to allow some obviously intended
18535 illegal instantiations. GNAT has never allowed these instantiations.
18538 RM References: 12.07 (16)
18542 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
18543 @cindex AI-0112 (Ada 2012 feature)
18546 This AI concerns giving names to various representation aspects, but the
18547 practical effect is simply to make the use of duplicate
18548 @code{Atomic}[@code{_Components}],
18549 @code{Volatile}[@code{_Components}] and
18550 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
18551 now performs this required check.
18554 RM References: 13.01 (8)
18557 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
18558 @cindex AI-0106 (Ada 2012 feature)
18561 The RM appeared to allow representation pragmas on generic formal parameters,
18562 but this was not intended, and GNAT has never permitted this usage.
18565 RM References: 13.01 (9.1/1)
18569 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
18570 @cindex AI-0012 (Ada 2012 feature)
18573 It is now illegal to give an inappropriate component size or a pragma
18574 @code{Pack} that attempts to change the component size in the case of atomic
18575 or aliased components. Previously GNAT ignored such an attempt with a
18579 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
18583 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
18584 @cindex AI-0039 (Ada 2012 feature)
18587 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
18588 for stream attributes, but these were never useful and are now illegal. GNAT
18589 has always regarded such expressions as illegal.
18592 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
18596 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
18597 @cindex AI-0095 (Ada 2012 feature)
18600 The prefix of @code{'Address} cannot statically denote a subprogram with
18601 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
18602 @code{Program_Error} if the prefix denotes a subprogram with convention
18606 RM References: 13.03 (11/1)
18610 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
18611 @cindex AI-0116 (Ada 2012 feature)
18614 This AI requires that the alignment of a class-wide object be no greater
18615 than the alignment of any type in the class. GNAT has always followed this
18619 RM References: 13.03 (29) 13.11 (16)
18623 @emph{AI-0146 Type invariants (2009-09-21)}
18624 @cindex AI-0146 (Ada 2012 feature)
18627 Type invariants may be specified for private types using the aspect notation.
18628 Aspect @code{Type_Invariant} may be specified for any private type,
18629 @code{Type_Invariant'Class} can
18630 only be specified for tagged types, and is inherited by any descendent of the
18631 tagged types. The invariant is a boolean expression that is tested for being
18632 true in the following situations: conversions to the private type, object
18633 declarations for the private type that are default initialized, and
18635 parameters and returned result on return from any primitive operation for
18636 the type that is visible to a client.
18637 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
18638 @code{Invariant'Class} for @code{Type_Invariant'Class}.
18641 RM References: 13.03.03 (00)
18644 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
18645 @cindex AI-0078 (Ada 2012 feature)
18648 In Ada 2012, compilers are required to support unchecked conversion where the
18649 target alignment is a multiple of the source alignment. GNAT always supported
18650 this case (and indeed all cases of differing alignments, doing copies where
18651 required if the alignment was reduced).
18654 RM References: 13.09 (7)
18658 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
18659 @cindex AI-0195 (Ada 2012 feature)
18662 The handling of invalid values is now designated to be implementation
18663 defined. This is a documentation change only, requiring Annex M in the GNAT
18664 Reference Manual to document this handling.
18665 In GNAT, checks for invalid values are made
18666 only when necessary to avoid erroneous behavior. Operations like assignments
18667 which cannot cause erroneous behavior ignore the possibility of invalid
18668 values and do not do a check. The date given above applies only to the
18669 documentation change, this behavior has always been implemented by GNAT.
18672 RM References: 13.09.01 (10)
18675 @emph{AI-0193 Alignment of allocators (2010-09-16)}
18676 @cindex AI-0193 (Ada 2012 feature)
18679 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
18680 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
18684 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
18685 13.11.01 (2) 13.11.01 (3)
18689 @emph{AI-0177 Parameterized expressions (2010-07-10)}
18690 @cindex AI-0177 (Ada 2012 feature)
18693 The new Ada 2012 notion of parameterized expressions is implemented. The form
18696 @i{function specification} @b{is} (@i{expression})
18700 This is exactly equivalent to the
18701 corresponding function body that returns the expression, but it can appear
18702 in a package spec. Note that the expression must be parenthesized.
18705 RM References: 13.11.01 (3/2)
18708 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
18709 @cindex AI-0033 (Ada 2012 feature)
18712 Neither of these two pragmas may appear within a generic template, because
18713 the generic might be instantiated at other than the library level.
18716 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
18720 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
18721 @cindex AI-0161 (Ada 2012 feature)
18724 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
18725 of the default stream attributes for elementary types. If this restriction is
18726 in force, then it is necessary to provide explicit subprograms for any
18727 stream attributes used.
18730 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
18733 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
18734 @cindex AI-0194 (Ada 2012 feature)
18737 The @code{Stream_Size} attribute returns the default number of bits in the
18738 stream representation of the given type.
18739 This value is not affected by the presence
18740 of stream subprogram attributes for the type. GNAT has always implemented
18741 this interpretation.
18744 RM References: 13.13.02 (1.2/2)
18747 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
18748 @cindex AI-0109 (Ada 2012 feature)
18751 This AI is an editorial change only. It removes the need for a tag check
18752 that can never fail.
18755 RM References: 13.13.02 (34/2)
18758 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
18759 @cindex AI-0007 (Ada 2012 feature)
18762 The RM as written appeared to limit the possibilities of declaring read
18763 attribute procedures for private scalar types. This limitation was not
18764 intended, and has never been enforced by GNAT.
18767 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
18771 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
18772 @cindex AI-0065 (Ada 2012 feature)
18775 This AI clarifies the fact that all remote access types support external
18776 streaming. This fixes an obvious oversight in the definition of the
18777 language, and GNAT always implemented the intended correct rules.
18780 RM References: 13.13.02 (52/2)
18783 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
18784 @cindex AI-0019 (Ada 2012 feature)
18787 The RM suggests that primitive subprograms of a specific tagged type are
18788 frozen when the tagged type is frozen. This would be an incompatible change
18789 and is not intended. GNAT has never attempted this kind of freezing and its
18790 behavior is consistent with the recommendation of this AI.
18793 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)
18796 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
18797 @cindex AI-0017 (Ada 2012 feature)
18800 So-called ``Taft-amendment types'' (i.e., types that are completed in package
18801 bodies) are not frozen by the occurrence of bodies in the
18802 enclosing declarative part. GNAT always implemented this properly.
18805 RM References: 13.14 (3/1)
18809 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
18810 @cindex AI-0060 (Ada 2012 feature)
18813 This AI extends the definition of remote access types to include access
18814 to limited, synchronized, protected or task class-wide interface types.
18815 GNAT already implemented this extension.
18818 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
18821 @emph{AI-0114 Classification of letters (0000-00-00)}
18822 @cindex AI-0114 (Ada 2012 feature)
18825 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
18826 181 (@code{MICRO SIGN}), and
18827 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
18828 lower case letters by Unicode.
18829 However, they are not allowed in identifiers, and they
18830 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
18831 This behavior is consistent with that defined in Ada 95.
18834 RM References: A.03.02 (59) A.04.06 (7)
18838 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
18839 @cindex AI-0185 (Ada 2012 feature)
18842 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
18843 classification functions for @code{Wide_Character} and
18844 @code{Wide_Wide_Character}, as well as providing
18845 case folding routines for @code{Wide_[Wide_]Character} and
18846 @code{Wide_[Wide_]String}.
18849 RM References: A.03.05 (0) A.03.06 (0)
18853 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
18854 @cindex AI-0031 (Ada 2012 feature)
18857 A new version of @code{Find_Token} is added to all relevant string packages,
18858 with an extra parameter @code{From}. Instead of starting at the first
18859 character of the string, the search for a matching Token starts at the
18860 character indexed by the value of @code{From}.
18861 These procedures are available in all versions of Ada
18862 but if used in versions earlier than Ada 2012 they will generate a warning
18863 that an Ada 2012 subprogram is being used.
18866 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
18871 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
18872 @cindex AI-0056 (Ada 2012 feature)
18875 The wording in the Ada 2005 RM implied an incompatible handling of the
18876 @code{Index} functions, resulting in raising an exception instead of
18877 returning zero in some situations.
18878 This was not intended and has been corrected.
18879 GNAT always returned zero, and is thus consistent with this AI.
18882 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
18886 @emph{AI-0137 String encoding package (2010-03-25)}
18887 @cindex AI-0137 (Ada 2012 feature)
18890 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
18891 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
18892 and @code{Wide_Wide_Strings} have been
18893 implemented. These packages (whose documentation can be found in the spec
18894 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
18895 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
18896 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
18897 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
18898 UTF-16), as well as conversions between the different UTF encodings. With
18899 the exception of @code{Wide_Wide_Strings}, these packages are available in
18900 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
18901 The @code{Wide_Wide_Strings package}
18902 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
18903 mode since it uses @code{Wide_Wide_Character}).
18906 RM References: A.04.11
18909 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
18910 @cindex AI-0038 (Ada 2012 feature)
18913 These are minor errors in the description on three points. The intent on
18914 all these points has always been clear, and GNAT has always implemented the
18915 correct intended semantics.
18918 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)
18921 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
18922 @cindex AI-0044 (Ada 2012 feature)
18925 This AI places restrictions on allowed instantiations of generic containers.
18926 These restrictions are not checked by the compiler, so there is nothing to
18927 change in the implementation. This affects only the RM documentation.
18930 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)
18933 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
18934 @cindex AI-0127 (Ada 2012 feature)
18937 This package provides an interface for identifying the current locale.
18940 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
18941 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
18946 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
18947 @cindex AI-0002 (Ada 2012 feature)
18950 The compiler is not required to support exporting an Ada subprogram with
18951 convention C if there are parameters or a return type of an unconstrained
18952 array type (such as @code{String}). GNAT allows such declarations but
18953 generates warnings. It is possible, but complicated, to write the
18954 corresponding C code and certainly such code would be specific to GNAT and
18958 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
18962 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
18963 @cindex AI05-0216 (Ada 2012 feature)
18966 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
18967 forbid tasks declared locally within subprograms, or functions returning task
18968 objects, and that is the implementation that GNAT has always provided.
18969 However the language in the RM was not sufficiently clear on this point.
18970 Thus this is a documentation change in the RM only.
18973 RM References: D.07 (3/3)
18976 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
18977 @cindex AI-0211 (Ada 2012 feature)
18980 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
18981 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
18984 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
18987 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
18988 @cindex AI-0190 (Ada 2012 feature)
18991 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
18992 used to control storage pools globally.
18993 In particular, you can force every access
18994 type that is used for allocation (@b{new}) to have an explicit storage pool,
18995 or you can declare a pool globally to be used for all access types that lack
18999 RM References: D.07 (8)
19002 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
19003 @cindex AI-0189 (Ada 2012 feature)
19006 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
19007 which says that no dynamic allocation will occur once elaboration is
19009 In general this requires a run-time check, which is not required, and which
19010 GNAT does not attempt. But the static cases of allocators in a task body or
19011 in the body of the main program are detected and flagged at compile or bind
19015 RM References: D.07 (19.1/2) H.04 (23.3/2)
19018 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
19019 @cindex AI-0171 (Ada 2012 feature)
19022 A new package @code{System.Multiprocessors} is added, together with the
19023 definition of pragma @code{CPU} for controlling task affinity. A new no
19024 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
19025 is added to the Ravenscar profile.
19028 RM References: D.13.01 (4/2) D.16
19032 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
19033 @cindex AI-0210 (Ada 2012 feature)
19036 This is a documentation only issue regarding wording of metric requirements,
19037 that does not affect the implementation of the compiler.
19040 RM References: D.15 (24/2)
19044 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
19045 @cindex AI-0206 (Ada 2012 feature)
19048 Remote types packages are now allowed to depend on preelaborated packages.
19049 This was formerly considered illegal.
19052 RM References: E.02.02 (6)
19057 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
19058 @cindex AI-0152 (Ada 2012 feature)
19061 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
19062 where the type of the returned value is an anonymous access type.
19065 RM References: H.04 (8/1)
19069 @node Obsolescent Features
19070 @chapter Obsolescent Features
19073 This chapter describes features that are provided by GNAT, but are
19074 considered obsolescent since there are preferred ways of achieving
19075 the same effect. These features are provided solely for historical
19076 compatibility purposes.
19079 * pragma No_Run_Time::
19080 * pragma Ravenscar::
19081 * pragma Restricted_Run_Time::
19084 @node pragma No_Run_Time
19085 @section pragma No_Run_Time
19087 The pragma @code{No_Run_Time} is used to achieve an affect similar
19088 to the use of the "Zero Foot Print" configurable run time, but without
19089 requiring a specially configured run time. The result of using this
19090 pragma, which must be used for all units in a partition, is to restrict
19091 the use of any language features requiring run-time support code. The
19092 preferred usage is to use an appropriately configured run-time that
19093 includes just those features that are to be made accessible.
19095 @node pragma Ravenscar
19096 @section pragma Ravenscar
19098 The pragma @code{Ravenscar} has exactly the same effect as pragma
19099 @code{Profile (Ravenscar)}. The latter usage is preferred since it
19100 is part of the new Ada 2005 standard.
19102 @node pragma Restricted_Run_Time
19103 @section pragma Restricted_Run_Time
19105 The pragma @code{Restricted_Run_Time} has exactly the same effect as
19106 pragma @code{Profile (Restricted)}. The latter usage is
19107 preferred since the Ada 2005 pragma @code{Profile} is intended for
19108 this kind of implementation dependent addition.
19111 @c GNU Free Documentation License
19113 @node Index,,GNU Free Documentation License, Top