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::
110 * Pragma Attribute_Definition::
112 * Pragma C_Pass_By_Copy::
114 * Pragma Check_Name::
115 * Pragma Check_Policy::
117 * Pragma Common_Object::
118 * Pragma Compile_Time_Error::
119 * Pragma Compile_Time_Warning::
120 * Pragma Compiler_Unit::
121 * Pragma Complete_Representation::
122 * Pragma Complex_Representation::
123 * Pragma Component_Alignment::
124 * Pragma Contract_Case::
125 * Pragma Convention_Identifier::
127 * Pragma CPP_Constructor::
128 * Pragma CPP_Virtual::
129 * Pragma CPP_Vtable::
131 * Pragma Debug_Policy::
132 * Pragma Detect_Blocking::
133 * Pragma Elaboration_Checks::
135 * Pragma Export_Exception::
136 * Pragma Export_Function::
137 * Pragma Export_Object::
138 * Pragma Export_Procedure::
139 * Pragma Export_Value::
140 * Pragma Export_Valued_Procedure::
141 * Pragma Extend_System::
142 * Pragma Extensions_Allowed::
144 * Pragma External_Name_Casing::
146 * Pragma Favor_Top_Level::
147 * Pragma Finalize_Storage_Only::
148 * Pragma Float_Representation::
150 * Pragma Implemented::
151 * Pragma Implicit_Packing::
152 * Pragma Import_Exception::
153 * Pragma Import_Function::
154 * Pragma Import_Object::
155 * Pragma Import_Procedure::
156 * Pragma Import_Valued_Procedure::
157 * Pragma Initialize_Scalars::
158 * Pragma Inline_Always::
159 * Pragma Inline_Generic::
161 * Pragma Interface_Name::
162 * Pragma Interrupt_Handler::
163 * Pragma Interrupt_State::
165 * Pragma Keep_Names::
168 * Pragma Linker_Alias::
169 * Pragma Linker_Constructor::
170 * Pragma Linker_Destructor::
171 * Pragma Linker_Section::
172 * Pragma Long_Float::
173 * Pragma Machine_Attribute::
175 * Pragma Main_Storage::
178 * Pragma No_Strict_Aliasing ::
179 * Pragma Normalize_Scalars::
180 * Pragma Obsolescent::
181 * Pragma Optimize_Alignment::
183 * Pragma Overflow_Checks::
185 * Pragma Persistent_BSS::
187 * Pragma Postcondition::
188 * Pragma Precondition::
189 * Pragma Profile (Ravenscar)::
190 * Pragma Profile (Restricted)::
191 * Pragma Psect_Object::
192 * Pragma Pure_Function::
193 * Pragma Remote_Access_Type::
194 * Pragma Restriction_Warnings::
196 * Pragma Short_Circuit_And_Or::
197 * Pragma Short_Descriptors::
198 * Pragma Simple_Storage_Pool_Type::
199 * Pragma Source_File_Name::
200 * Pragma Source_File_Name_Project::
201 * Pragma Source_Reference::
202 * Pragma Static_Elaboration_Desired::
203 * Pragma Stream_Convert::
204 * Pragma Style_Checks::
207 * Pragma Suppress_All::
208 * Pragma Suppress_Exception_Locations::
209 * Pragma Suppress_Initialization::
212 * Pragma Task_Storage::
214 * Pragma Thread_Local_Storage::
215 * Pragma Time_Slice::
217 * Pragma Unchecked_Union::
218 * Pragma Unimplemented_Unit::
219 * Pragma Universal_Aliasing ::
220 * Pragma Universal_Data::
221 * Pragma Unmodified::
222 * Pragma Unreferenced::
223 * Pragma Unreferenced_Objects::
224 * Pragma Unreserve_All_Interrupts::
225 * Pragma Unsuppress::
226 * Pragma Use_VADS_Size::
227 * Pragma Validity_Checks::
230 * Pragma Weak_External::
231 * Pragma Wide_Character_Encoding::
233 Implementation Defined Attributes
244 * Default_Bit_Order::
256 * Has_Access_Values::
257 * Has_Discriminants::
264 * Max_Interrupt_Priority::
266 * Maximum_Alignment::
270 * Passed_By_Reference::
276 * Scalar_Storage_Order::
277 * Simple_Storage_Pool::
281 * System_Allocator_Alignment::
287 * Unconstrained_Array::
288 * Universal_Literal_String::
289 * Unrestricted_Access::
296 Standard and Implementation Defined Restrictions
298 * Partition-Wide Restrictions::
299 * Program Unit Level Restrictions::
301 Partition-Wide Restrictions
303 * Immediate_Reclamation::
304 * Max_Asynchronous_Select_Nesting::
305 * Max_Entry_Queue_Length::
306 * Max_Protected_Entries::
307 * Max_Select_Alternatives::
308 * Max_Storage_At_Blocking::
311 * No_Abort_Statements::
312 * No_Access_Parameter_Allocators::
313 * No_Access_Subprograms::
315 * No_Anonymous_Allocators::
318 * No_Default_Initialization::
321 * No_Direct_Boolean_Operators::
323 * No_Dispatching_Calls::
324 * No_Dynamic_Attachment::
325 * No_Dynamic_Priorities::
326 * No_Entry_Calls_In_Elaboration_Code::
327 * No_Enumeration_Maps::
328 * No_Exception_Handlers::
329 * No_Exception_Propagation::
330 * No_Exception_Registration::
334 * No_Floating_Point::
335 * No_Implicit_Conditionals::
336 * No_Implicit_Dynamic_Code::
337 * No_Implicit_Heap_Allocations::
338 * No_Implicit_Loops::
339 * No_Initialize_Scalars::
341 * No_Local_Allocators::
342 * No_Local_Protected_Objects::
343 * No_Local_Timing_Events::
344 * No_Nested_Finalization::
345 * No_Protected_Type_Allocators::
346 * No_Protected_Types::
349 * No_Relative_Delay::
350 * No_Requeue_Statements::
351 * No_Secondary_Stack::
352 * No_Select_Statements::
353 * No_Specific_Termination_Handlers::
354 * No_Specification_of_Aspect::
355 * No_Standard_Allocators_After_Elaboration::
356 * No_Standard_Storage_Pools::
357 * No_Stream_Optimizations::
359 * No_Task_Allocators::
360 * No_Task_Attributes_Package::
361 * No_Task_Hierarchy::
362 * No_Task_Termination::
364 * No_Terminate_Alternatives::
365 * No_Unchecked_Access::
367 * Static_Priorities::
368 * Static_Storage_Size::
370 Program Unit Level Restrictions
372 * No_Elaboration_Code::
374 * No_Implementation_Aspect_Specifications::
375 * No_Implementation_Attributes::
376 * No_Implementation_Identifiers::
377 * No_Implementation_Pragmas::
378 * No_Implementation_Restrictions::
379 * No_Implementation_Units::
380 * No_Implicit_Aliasing::
381 * No_Obsolescent_Features::
382 * No_Wide_Characters::
385 The Implementation of Standard I/O
387 * Standard I/O Packages::
393 * Wide_Wide_Text_IO::
397 * Filenames encoding::
399 * Operations on C Streams::
400 * Interfacing to C Streams::
404 * Ada.Characters.Latin_9 (a-chlat9.ads)::
405 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
406 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
407 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
408 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
409 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
410 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
411 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
412 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
413 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
414 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
415 * Ada.Command_Line.Environment (a-colien.ads)::
416 * Ada.Command_Line.Remove (a-colire.ads)::
417 * Ada.Command_Line.Response_File (a-clrefi.ads)::
418 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
419 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
420 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
421 * Ada.Exceptions.Traceback (a-exctra.ads)::
422 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
423 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
424 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
425 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
426 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
427 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
428 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
429 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
430 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
431 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
432 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
433 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
434 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
435 * GNAT.Altivec (g-altive.ads)::
436 * GNAT.Altivec.Conversions (g-altcon.ads)::
437 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
438 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
439 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
440 * GNAT.Array_Split (g-arrspl.ads)::
441 * GNAT.AWK (g-awk.ads)::
442 * GNAT.Bounded_Buffers (g-boubuf.ads)::
443 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
444 * GNAT.Bubble_Sort (g-bubsor.ads)::
445 * GNAT.Bubble_Sort_A (g-busora.ads)::
446 * GNAT.Bubble_Sort_G (g-busorg.ads)::
447 * GNAT.Byte_Order_Mark (g-byorma.ads)::
448 * GNAT.Byte_Swapping (g-bytswa.ads)::
449 * GNAT.Calendar (g-calend.ads)::
450 * GNAT.Calendar.Time_IO (g-catiio.ads)::
451 * GNAT.Case_Util (g-casuti.ads)::
452 * GNAT.CGI (g-cgi.ads)::
453 * GNAT.CGI.Cookie (g-cgicoo.ads)::
454 * GNAT.CGI.Debug (g-cgideb.ads)::
455 * GNAT.Command_Line (g-comlin.ads)::
456 * GNAT.Compiler_Version (g-comver.ads)::
457 * GNAT.Ctrl_C (g-ctrl_c.ads)::
458 * GNAT.CRC32 (g-crc32.ads)::
459 * GNAT.Current_Exception (g-curexc.ads)::
460 * GNAT.Debug_Pools (g-debpoo.ads)::
461 * GNAT.Debug_Utilities (g-debuti.ads)::
462 * GNAT.Decode_String (g-decstr.ads)::
463 * GNAT.Decode_UTF8_String (g-deutst.ads)::
464 * GNAT.Directory_Operations (g-dirope.ads)::
465 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
466 * GNAT.Dynamic_HTables (g-dynhta.ads)::
467 * GNAT.Dynamic_Tables (g-dyntab.ads)::
468 * GNAT.Encode_String (g-encstr.ads)::
469 * GNAT.Encode_UTF8_String (g-enutst.ads)::
470 * GNAT.Exception_Actions (g-excact.ads)::
471 * GNAT.Exception_Traces (g-exctra.ads)::
472 * GNAT.Exceptions (g-except.ads)::
473 * GNAT.Expect (g-expect.ads)::
474 * GNAT.Expect.TTY (g-exptty.ads)::
475 * GNAT.Float_Control (g-flocon.ads)::
476 * GNAT.Heap_Sort (g-heasor.ads)::
477 * GNAT.Heap_Sort_A (g-hesora.ads)::
478 * GNAT.Heap_Sort_G (g-hesorg.ads)::
479 * GNAT.HTable (g-htable.ads)::
480 * GNAT.IO (g-io.ads)::
481 * GNAT.IO_Aux (g-io_aux.ads)::
482 * GNAT.Lock_Files (g-locfil.ads)::
483 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
484 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
485 * GNAT.MD5 (g-md5.ads)::
486 * GNAT.Memory_Dump (g-memdum.ads)::
487 * GNAT.Most_Recent_Exception (g-moreex.ads)::
488 * GNAT.OS_Lib (g-os_lib.ads)::
489 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
490 * GNAT.Random_Numbers (g-rannum.ads)::
491 * GNAT.Regexp (g-regexp.ads)::
492 * GNAT.Registry (g-regist.ads)::
493 * GNAT.Regpat (g-regpat.ads)::
494 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
495 * GNAT.Semaphores (g-semaph.ads)::
496 * GNAT.Serial_Communications (g-sercom.ads)::
497 * GNAT.SHA1 (g-sha1.ads)::
498 * GNAT.SHA224 (g-sha224.ads)::
499 * GNAT.SHA256 (g-sha256.ads)::
500 * GNAT.SHA384 (g-sha384.ads)::
501 * GNAT.SHA512 (g-sha512.ads)::
502 * GNAT.Signals (g-signal.ads)::
503 * GNAT.Sockets (g-socket.ads)::
504 * GNAT.Source_Info (g-souinf.ads)::
505 * GNAT.Spelling_Checker (g-speche.ads)::
506 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
507 * GNAT.Spitbol.Patterns (g-spipat.ads)::
508 * GNAT.Spitbol (g-spitbo.ads)::
509 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
510 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
511 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
512 * GNAT.SSE (g-sse.ads)::
513 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
514 * GNAT.Strings (g-string.ads)::
515 * GNAT.String_Split (g-strspl.ads)::
516 * GNAT.Table (g-table.ads)::
517 * GNAT.Task_Lock (g-tasloc.ads)::
518 * GNAT.Threads (g-thread.ads)::
519 * GNAT.Time_Stamp (g-timsta.ads)::
520 * GNAT.Traceback (g-traceb.ads)::
521 * GNAT.Traceback.Symbolic (g-trasym.ads)::
522 * GNAT.UTF_32 (g-utf_32.ads)::
523 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
524 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
525 * GNAT.Wide_String_Split (g-wistsp.ads)::
526 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
527 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
528 * Interfaces.C.Extensions (i-cexten.ads)::
529 * Interfaces.C.Streams (i-cstrea.ads)::
530 * Interfaces.CPP (i-cpp.ads)::
531 * Interfaces.Packed_Decimal (i-pacdec.ads)::
532 * Interfaces.VxWorks (i-vxwork.ads)::
533 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
534 * System.Address_Image (s-addima.ads)::
535 * System.Assertions (s-assert.ads)::
536 * System.Memory (s-memory.ads)::
537 * System.Partition_Interface (s-parint.ads)::
538 * System.Pool_Global (s-pooglo.ads)::
539 * System.Pool_Local (s-pooloc.ads)::
540 * System.Restrictions (s-restri.ads)::
541 * System.Rident (s-rident.ads)::
542 * System.Strings.Stream_Ops (s-ststop.ads)::
543 * System.Task_Info (s-tasinf.ads)::
544 * System.Wch_Cnv (s-wchcnv.ads)::
545 * System.Wch_Con (s-wchcon.ads)::
549 * Text_IO Stream Pointer Positioning::
550 * Text_IO Reading and Writing Non-Regular Files::
552 * Treating Text_IO Files as Streams::
553 * Text_IO Extensions::
554 * Text_IO Facilities for Unbounded Strings::
558 * Wide_Text_IO Stream Pointer Positioning::
559 * Wide_Text_IO Reading and Writing Non-Regular Files::
563 * Wide_Wide_Text_IO Stream Pointer Positioning::
564 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
566 Interfacing to Other Languages
569 * Interfacing to C++::
570 * Interfacing to COBOL::
571 * Interfacing to Fortran::
572 * Interfacing to non-GNAT Ada code::
574 Specialized Needs Annexes
576 Implementation of Specific Ada Features
577 * Machine Code Insertions::
578 * GNAT Implementation of Tasking::
579 * GNAT Implementation of Shared Passive Packages::
580 * Code Generation for Array Aggregates::
581 * The Size of Discriminated Records with Default Discriminants::
582 * Strict Conformance to the Ada Reference Manual::
584 Implementation of Ada 2012 Features
588 GNU Free Documentation License
595 @node About This Guide
596 @unnumbered About This Guide
599 This manual contains useful information in writing programs using the
600 @value{EDITION} compiler. It includes information on implementation dependent
601 characteristics of @value{EDITION}, including all the information required by
602 Annex M of the Ada language standard.
604 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
605 Ada 83 compatibility mode.
606 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
607 but you can override with a compiler switch
608 to explicitly specify the language version.
609 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
610 @value{EDITION} User's Guide}, for details on these switches.)
611 Throughout this manual, references to ``Ada'' without a year suffix
612 apply to both the Ada 95 and Ada 2005 versions of the language.
614 Ada is designed to be highly portable.
615 In general, a program will have the same effect even when compiled by
616 different compilers on different platforms.
617 However, since Ada is designed to be used in a
618 wide variety of applications, it also contains a number of system
619 dependent features to be used in interfacing to the external world.
620 @cindex Implementation-dependent features
623 Note: Any program that makes use of implementation-dependent features
624 may be non-portable. You should follow good programming practice and
625 isolate and clearly document any sections of your program that make use
626 of these features in a non-portable manner.
629 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
630 ``GNAT'' in the remainder of this document.
634 * What This Reference Manual Contains::
636 * Related Information::
639 @node What This Reference Manual Contains
640 @unnumberedsec What This Reference Manual Contains
643 This reference manual contains the following chapters:
647 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
648 pragmas, which can be used to extend and enhance the functionality of the
652 @ref{Implementation Defined Attributes}, lists GNAT
653 implementation-dependent attributes, which can be used to extend and
654 enhance the functionality of the compiler.
657 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
658 implementation-dependent restrictions, which can be used to extend and
659 enhance the functionality of the compiler.
662 @ref{Implementation Advice}, provides information on generally
663 desirable behavior which are not requirements that all compilers must
664 follow since it cannot be provided on all systems, or which may be
665 undesirable on some systems.
668 @ref{Implementation Defined Characteristics}, provides a guide to
669 minimizing implementation dependent features.
672 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
673 implemented by GNAT, and how they can be imported into user
674 application programs.
677 @ref{Representation Clauses and Pragmas}, describes in detail the
678 way that GNAT represents data, and in particular the exact set
679 of representation clauses and pragmas that is accepted.
682 @ref{Standard Library Routines}, provides a listing of packages and a
683 brief description of the functionality that is provided by Ada's
684 extensive set of standard library routines as implemented by GNAT@.
687 @ref{The Implementation of Standard I/O}, details how the GNAT
688 implementation of the input-output facilities.
691 @ref{The GNAT Library}, is a catalog of packages that complement
692 the Ada predefined library.
695 @ref{Interfacing to Other Languages}, describes how programs
696 written in Ada using GNAT can be interfaced to other programming
699 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
700 of the specialized needs annexes.
703 @ref{Implementation of Specific Ada Features}, discusses issues related
704 to GNAT's implementation of machine code insertions, tasking, and several
708 @ref{Implementation of Ada 2012 Features}, describes the status of the
709 GNAT implementation of the Ada 2012 language standard.
712 @ref{Obsolescent Features} documents implementation dependent features,
713 including pragmas and attributes, which are considered obsolescent, since
714 there are other preferred ways of achieving the same results. These
715 obsolescent forms are retained for backwards compatibility.
719 @cindex Ada 95 Language Reference Manual
720 @cindex Ada 2005 Language Reference Manual
722 This reference manual assumes a basic familiarity with the Ada 95 language, as
723 described in the International Standard ANSI/ISO/IEC-8652:1995,
725 It does not require knowledge of the new features introduced by Ada 2005,
726 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
728 Both reference manuals are included in the GNAT documentation
732 @unnumberedsec Conventions
733 @cindex Conventions, typographical
734 @cindex Typographical conventions
737 Following are examples of the typographical and graphic conventions used
742 @code{Functions}, @code{utility program names}, @code{standard names},
749 @file{File names}, @samp{button names}, and @samp{field names}.
752 @code{Variables}, @env{environment variables}, and @var{metasyntactic
759 [optional information or parameters]
762 Examples are described by text
764 and then shown this way.
769 Commands that are entered by the user are preceded in this manual by the
770 characters @samp{$ } (dollar sign followed by space). If your system uses this
771 sequence as a prompt, then the commands will appear exactly as you see them
772 in the manual. If your system uses some other prompt, then the command will
773 appear with the @samp{$} replaced by whatever prompt character you are using.
775 @node Related Information
776 @unnumberedsec Related Information
778 See the following documents for further information on GNAT:
782 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
783 @value{EDITION} User's Guide}, which provides information on how to use the
784 GNAT compiler system.
787 @cite{Ada 95 Reference Manual}, which contains all reference
788 material for the Ada 95 programming language.
791 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
792 of the Ada 95 standard. The annotations describe
793 detailed aspects of the design decision, and in particular contain useful
794 sections on Ada 83 compatibility.
797 @cite{Ada 2005 Reference Manual}, which contains all reference
798 material for the Ada 2005 programming language.
801 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
802 of the Ada 2005 standard. The annotations describe
803 detailed aspects of the design decision, and in particular contain useful
804 sections on Ada 83 and Ada 95 compatibility.
807 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
808 which contains specific information on compatibility between GNAT and
812 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
813 describes in detail the pragmas and attributes provided by the DEC Ada 83
818 @node Implementation Defined Pragmas
819 @chapter Implementation Defined Pragmas
822 Ada defines a set of pragmas that can be used to supply additional
823 information to the compiler. These language defined pragmas are
824 implemented in GNAT and work as described in the Ada Reference Manual.
826 In addition, Ada allows implementations to define additional pragmas
827 whose meaning is defined by the implementation. GNAT provides a number
828 of these implementation-defined pragmas, which can be used to extend
829 and enhance the functionality of the compiler. This section of the GNAT
830 Reference Manual describes these additional pragmas.
832 Note that any program using these pragmas might not be portable to other
833 compilers (although GNAT implements this set of pragmas on all
834 platforms). Therefore if portability to other compilers is an important
835 consideration, the use of these pragmas should be minimized.
838 * Pragma Abort_Defer::
847 * Pragma Assertion_Policy::
848 * Pragma Assume_No_Invalid_Values::
849 * Pragma Attribute_Definition::
851 * Pragma C_Pass_By_Copy::
853 * Pragma Check_Name::
854 * Pragma Check_Policy::
856 * Pragma Common_Object::
857 * Pragma Compile_Time_Error::
858 * Pragma Compile_Time_Warning::
859 * Pragma Compiler_Unit::
860 * Pragma Complete_Representation::
861 * Pragma Complex_Representation::
862 * Pragma Component_Alignment::
863 * Pragma Contract_Case::
864 * Pragma Convention_Identifier::
866 * Pragma CPP_Constructor::
867 * Pragma CPP_Virtual::
868 * Pragma CPP_Vtable::
870 * Pragma Debug_Policy::
871 * Pragma Detect_Blocking::
872 * Pragma Elaboration_Checks::
874 * Pragma Export_Exception::
875 * Pragma Export_Function::
876 * Pragma Export_Object::
877 * Pragma Export_Procedure::
878 * Pragma Export_Value::
879 * Pragma Export_Valued_Procedure::
880 * Pragma Extend_System::
881 * Pragma Extensions_Allowed::
883 * Pragma External_Name_Casing::
885 * Pragma Favor_Top_Level::
886 * Pragma Finalize_Storage_Only::
887 * Pragma Float_Representation::
889 * Pragma Implemented::
890 * Pragma Implicit_Packing::
891 * Pragma Import_Exception::
892 * Pragma Import_Function::
893 * Pragma Import_Object::
894 * Pragma Import_Procedure::
895 * Pragma Import_Valued_Procedure::
896 * Pragma Initialize_Scalars::
897 * Pragma Inline_Always::
898 * Pragma Inline_Generic::
900 * Pragma Interface_Name::
901 * Pragma Interrupt_Handler::
902 * Pragma Interrupt_State::
904 * Pragma Keep_Names::
907 * Pragma Linker_Alias::
908 * Pragma Linker_Constructor::
909 * Pragma Linker_Destructor::
910 * Pragma Linker_Section::
911 * Pragma Long_Float::
912 * Pragma Machine_Attribute::
914 * Pragma Main_Storage::
917 * Pragma No_Strict_Aliasing::
918 * Pragma Normalize_Scalars::
919 * Pragma Obsolescent::
920 * Pragma Optimize_Alignment::
922 * Pragma Overflow_Checks::
924 * Pragma Persistent_BSS::
926 * Pragma Postcondition::
927 * Pragma Precondition::
928 * Pragma Profile (Ravenscar)::
929 * Pragma Profile (Restricted)::
930 * Pragma Psect_Object::
931 * Pragma Pure_Function::
932 * Pragma Remote_Access_Type::
933 * Pragma Restriction_Warnings::
935 * Pragma Short_Circuit_And_Or::
936 * Pragma Short_Descriptors::
937 * Pragma Simple_Storage_Pool_Type::
938 * Pragma Source_File_Name::
939 * Pragma Source_File_Name_Project::
940 * Pragma Source_Reference::
941 * Pragma Static_Elaboration_Desired::
942 * Pragma Stream_Convert::
943 * Pragma Style_Checks::
946 * Pragma Suppress_All::
947 * Pragma Suppress_Exception_Locations::
948 * Pragma Suppress_Initialization::
951 * Pragma Task_Storage::
953 * Pragma Thread_Local_Storage::
954 * Pragma Time_Slice::
956 * Pragma Unchecked_Union::
957 * Pragma Unimplemented_Unit::
958 * Pragma Universal_Aliasing ::
959 * Pragma Universal_Data::
960 * Pragma Unmodified::
961 * Pragma Unreferenced::
962 * Pragma Unreferenced_Objects::
963 * Pragma Unreserve_All_Interrupts::
964 * Pragma Unsuppress::
965 * Pragma Use_VADS_Size::
966 * Pragma Validity_Checks::
969 * Pragma Weak_External::
970 * Pragma Wide_Character_Encoding::
973 @node Pragma Abort_Defer
974 @unnumberedsec Pragma Abort_Defer
976 @cindex Deferring aborts
984 This pragma must appear at the start of the statement sequence of a
985 handled sequence of statements (right after the @code{begin}). It has
986 the effect of deferring aborts for the sequence of statements (but not
987 for the declarations or handlers, if any, associated with this statement
991 @unnumberedsec Pragma Ada_83
1000 A configuration pragma that establishes Ada 83 mode for the unit to
1001 which it applies, regardless of the mode set by the command line
1002 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1003 the syntax and semantics of Ada 83, as defined in the original Ada
1004 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1005 and Ada 2005 are not recognized, optional package bodies are allowed,
1006 and generics may name types with unknown discriminants without using
1007 the @code{(<>)} notation. In addition, some but not all of the additional
1008 restrictions of Ada 83 are enforced.
1010 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1011 Ada 83 code to be compiled and adapted to GNAT with less effort.
1012 Secondly, it aids in keeping code backwards compatible with Ada 83.
1013 However, there is no guarantee that code that is processed correctly
1014 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1015 83 compiler, since GNAT does not enforce all the additional checks
1019 @unnumberedsec Pragma Ada_95
1023 @smallexample @c ada
1028 A configuration pragma that establishes Ada 95 mode for the unit to which
1029 it applies, regardless of the mode set by the command line switches.
1030 This mode is set automatically for the @code{Ada} and @code{System}
1031 packages and their children, so you need not specify it in these
1032 contexts. This pragma is useful when writing a reusable component that
1033 itself uses Ada 95 features, but which is intended to be usable from
1034 either Ada 83 or Ada 95 programs.
1037 @unnumberedsec Pragma Ada_05
1041 @smallexample @c ada
1046 A configuration pragma that establishes Ada 2005 mode for the unit to which
1047 it applies, regardless of the mode set by the command line switches.
1048 This pragma is useful when writing a reusable component that
1049 itself uses Ada 2005 features, but which is intended to be usable from
1050 either Ada 83 or Ada 95 programs.
1052 @node Pragma Ada_2005
1053 @unnumberedsec Pragma Ada_2005
1057 @smallexample @c ada
1062 This configuration pragma is a synonym for pragma Ada_05 and has the
1063 same syntax and effect.
1066 @unnumberedsec Pragma Ada_12
1070 @smallexample @c ada
1075 A configuration pragma that establishes Ada 2012 mode for the unit to which
1076 it applies, regardless of the mode set by the command line switches.
1077 This mode is set automatically for the @code{Ada} and @code{System}
1078 packages and their children, so you need not specify it in these
1079 contexts. This pragma is useful when writing a reusable component that
1080 itself uses Ada 2012 features, but which is intended to be usable from
1081 Ada 83, Ada 95, or Ada 2005 programs.
1083 @node Pragma Ada_2012
1084 @unnumberedsec Pragma Ada_2012
1088 @smallexample @c ada
1093 This configuration pragma is a synonym for pragma Ada_12 and has the
1094 same syntax and effect.
1096 @node Pragma Annotate
1097 @unnumberedsec Pragma Annotate
1101 @smallexample @c ada
1102 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1104 ARG ::= NAME | EXPRESSION
1108 This pragma is used to annotate programs. @var{identifier} identifies
1109 the type of annotation. GNAT verifies that it is an identifier, but does
1110 not otherwise analyze it. The second optional identifier is also left
1111 unanalyzed, and by convention is used to control the action of the tool to
1112 which the annotation is addressed. The remaining @var{arg} arguments
1113 can be either string literals or more generally expressions.
1114 String literals are assumed to be either of type
1115 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1116 depending on the character literals they contain.
1117 All other kinds of arguments are analyzed as expressions, and must be
1120 The analyzed pragma is retained in the tree, but not otherwise processed
1121 by any part of the GNAT compiler, except to generate corresponding note
1122 lines in the generated ALI file. For the format of these note lines, see
1123 the compiler source file lib-writ.ads. This pragma is intended for use by
1124 external tools, including ASIS@. The use of pragma Annotate does not
1125 affect the compilation process in any way. This pragma may be used as
1126 a configuration pragma.
1129 @unnumberedsec Pragma Assert
1133 @smallexample @c ada
1136 [, string_EXPRESSION]);
1140 The effect of this pragma depends on whether the corresponding command
1141 line switch is set to activate assertions. The pragma expands into code
1142 equivalent to the following:
1144 @smallexample @c ada
1145 if assertions-enabled then
1146 if not boolean_EXPRESSION then
1147 System.Assertions.Raise_Assert_Failure
1148 (string_EXPRESSION);
1154 The string argument, if given, is the message that will be associated
1155 with the exception occurrence if the exception is raised. If no second
1156 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1157 where @var{file} is the name of the source file containing the assert,
1158 and @var{nnn} is the line number of the assert. A pragma is not a
1159 statement, so if a statement sequence contains nothing but a pragma
1160 assert, then a null statement is required in addition, as in:
1162 @smallexample @c ada
1165 pragma Assert (K > 3, "Bad value for K");
1171 Note that, as with the @code{if} statement to which it is equivalent, the
1172 type of the expression is either @code{Standard.Boolean}, or any type derived
1173 from this standard type.
1175 If assertions are disabled (switch @option{-gnata} not used), then there
1176 is no run-time effect (and in particular, any side effects from the
1177 expression will not occur at run time). (The expression is still
1178 analyzed at compile time, and may cause types to be frozen if they are
1179 mentioned here for the first time).
1181 If assertions are enabled, then the given expression is tested, and if
1182 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1183 which results in the raising of @code{Assert_Failure} with the given message.
1185 You should generally avoid side effects in the expression arguments of
1186 this pragma, because these side effects will turn on and off with the
1187 setting of the assertions mode, resulting in assertions that have an
1188 effect on the program. However, the expressions are analyzed for
1189 semantic correctness whether or not assertions are enabled, so turning
1190 assertions on and off cannot affect the legality of a program.
1192 Note that the implementation defined policy @code{DISABLE}, given in a
1193 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1195 Note: this is a standard language-defined pragma in versions
1196 of Ada from 2005 on. In GNAT, it is implemented in all versions
1197 of Ada, and the DISABLE policy is an implementation-defined
1200 @node Pragma Assertion_Policy
1201 @unnumberedsec Pragma Assertion_Policy
1202 @findex Debug_Policy
1206 @smallexample @c ada
1207 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1211 If the argument is @code{CHECK}, then assertions are enabled.
1212 If the argument is @code{IGNORE}, then assertions are ignored.
1213 This pragma overrides the effect of the @option{-gnata} switch on the
1216 Assertions are of three kinds:
1220 Pragma @code{Assert}.
1222 In Ada 2012, all assertions defined in the RM as aspects: preconditions,
1223 postconditions, type invariants and (sub)type predicates.
1225 Corresponding pragmas for type invariants and (sub)type predicates.
1228 The implementation defined policy @code{DISABLE} is like
1229 @code{IGNORE} except that it completely disables semantic
1230 checking of the argument to @code{pragma Assert}. This may
1231 be useful when the pragma argument references subprograms
1232 in a with'ed package which is replaced by a dummy package
1233 for the final build.
1235 Note: this is a standard language-defined pragma in versions
1236 of Ada from 2005 on. In GNAT, it is implemented in all versions
1237 of Ada, and the DISABLE policy is an implementation-defined
1240 @node Pragma Assume_No_Invalid_Values
1241 @unnumberedsec Pragma Assume_No_Invalid_Values
1242 @findex Assume_No_Invalid_Values
1243 @cindex Invalid representations
1244 @cindex Invalid values
1247 @smallexample @c ada
1248 pragma Assume_No_Invalid_Values (On | Off);
1252 This is a configuration pragma that controls the assumptions made by the
1253 compiler about the occurrence of invalid representations (invalid values)
1256 The default behavior (corresponding to an Off argument for this pragma), is
1257 to assume that values may in general be invalid unless the compiler can
1258 prove they are valid. Consider the following example:
1260 @smallexample @c ada
1261 V1 : Integer range 1 .. 10;
1262 V2 : Integer range 11 .. 20;
1264 for J in V2 .. V1 loop
1270 if V1 and V2 have valid values, then the loop is known at compile
1271 time not to execute since the lower bound must be greater than the
1272 upper bound. However in default mode, no such assumption is made,
1273 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1274 is given, the compiler will assume that any occurrence of a variable
1275 other than in an explicit @code{'Valid} test always has a valid
1276 value, and the loop above will be optimized away.
1278 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1279 you know your code is free of uninitialized variables and other
1280 possible sources of invalid representations, and may result in
1281 more efficient code. A program that accesses an invalid representation
1282 with this pragma in effect is erroneous, so no guarantees can be made
1285 It is peculiar though permissible to use this pragma in conjunction
1286 with validity checking (-gnatVa). In such cases, accessing invalid
1287 values will generally give an exception, though formally the program
1288 is erroneous so there are no guarantees that this will always be the
1289 case, and it is recommended that these two options not be used together.
1291 @node Pragma Ast_Entry
1292 @unnumberedsec Pragma Ast_Entry
1297 @smallexample @c ada
1298 pragma AST_Entry (entry_IDENTIFIER);
1302 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1303 argument is the simple name of a single entry; at most one @code{AST_Entry}
1304 pragma is allowed for any given entry. This pragma must be used in
1305 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1306 the entry declaration and in the same task type specification or single task
1307 as the entry to which it applies. This pragma specifies that the given entry
1308 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1309 resulting from an OpenVMS system service call. The pragma does not affect
1310 normal use of the entry. For further details on this pragma, see the
1311 DEC Ada Language Reference Manual, section 9.12a.
1313 @node Pragma Attribute_Definition
1314 @unnumberedsec Pragma Attribute_Definition
1315 @findex Attribute_Definition
1318 @smallexample @c ada
1319 pragma Attribute_Definition
1320 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1321 [Entity =>] LOCAL_NAME,
1322 [Expression =>] EXPRESSION | NAME);
1326 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1327 the attribute definition clause:
1329 @smallexample @c ada
1330 for Entity'Attribute use Expression;
1333 If @code{Attribute} is not a recognized attribute name, the pragma is
1334 ignored, and a warning is emitted. This allows source
1335 code to be written that takes advantage of some new attribute, while remaining
1336 compilable with earlier compilers.
1338 @node Pragma C_Pass_By_Copy
1339 @unnumberedsec Pragma C_Pass_By_Copy
1340 @cindex Passing by copy
1341 @findex C_Pass_By_Copy
1344 @smallexample @c ada
1345 pragma C_Pass_By_Copy
1346 ([Max_Size =>] static_integer_EXPRESSION);
1350 Normally the default mechanism for passing C convention records to C
1351 convention subprograms is to pass them by reference, as suggested by RM
1352 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1353 this default, by requiring that record formal parameters be passed by
1354 copy if all of the following conditions are met:
1358 The size of the record type does not exceed the value specified for
1361 The record type has @code{Convention C}.
1363 The formal parameter has this record type, and the subprogram has a
1364 foreign (non-Ada) convention.
1368 If these conditions are met the argument is passed by copy, i.e.@: in a
1369 manner consistent with what C expects if the corresponding formal in the
1370 C prototype is a struct (rather than a pointer to a struct).
1372 You can also pass records by copy by specifying the convention
1373 @code{C_Pass_By_Copy} for the record type, or by using the extended
1374 @code{Import} and @code{Export} pragmas, which allow specification of
1375 passing mechanisms on a parameter by parameter basis.
1378 @unnumberedsec Pragma Check
1380 @cindex Named assertions
1384 @smallexample @c ada
1386 [Name =>] Identifier,
1387 [Check =>] Boolean_EXPRESSION
1388 [, [Message =>] string_EXPRESSION] );
1392 This pragma is similar to the predefined pragma @code{Assert} except that an
1393 extra identifier argument is present. In conjunction with pragma
1394 @code{Check_Policy}, this can be used to define groups of assertions that can
1395 be independently controlled. The identifier @code{Assertion} is special, it
1396 refers to the normal set of pragma @code{Assert} statements. The identifiers
1397 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1398 names, so these three names would normally not be used directly in a pragma
1401 Checks introduced by this pragma are normally deactivated by default. They can
1402 be activated either by the command line option @option{-gnata}, which turns on
1403 all checks, or individually controlled using pragma @code{Check_Policy}.
1405 @node Pragma Check_Name
1406 @unnumberedsec Pragma Check_Name
1407 @cindex Defining check names
1408 @cindex Check names, defining
1412 @smallexample @c ada
1413 pragma Check_Name (check_name_IDENTIFIER);
1417 This is a configuration pragma that defines a new implementation
1418 defined check name (unless IDENTIFIER matches one of the predefined
1419 check names, in which case the pragma has no effect). Check names
1420 are global to a partition, so if two or more configuration pragmas
1421 are present in a partition mentioning the same name, only one new
1422 check name is introduced.
1424 An implementation defined check name introduced with this pragma may
1425 be used in only three contexts: @code{pragma Suppress},
1426 @code{pragma Unsuppress},
1427 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1428 any of these three cases, the check name must be visible. A check
1429 name is visible if it is in the configuration pragmas applying to
1430 the current unit, or if it appears at the start of any unit that
1431 is part of the dependency set of the current unit (e.g., units that
1432 are mentioned in @code{with} clauses).
1434 @node Pragma Check_Policy
1435 @unnumberedsec Pragma Check_Policy
1436 @cindex Controlling assertions
1437 @cindex Assertions, control
1438 @cindex Check pragma control
1439 @cindex Named assertions
1443 @smallexample @c ada
1445 ([Name =>] Identifier,
1446 [Policy =>] POLICY_IDENTIFIER);
1448 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1452 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1453 except that it controls sets of named assertions introduced using the
1454 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1455 @code{Assertion_Policy}) can be used within a declarative part, in which case
1456 it controls the status to the end of the corresponding construct (in a manner
1457 identical to pragma @code{Suppress)}.
1459 The identifier given as the first argument corresponds to a name used in
1460 associated @code{Check} pragmas. For example, if the pragma:
1462 @smallexample @c ada
1463 pragma Check_Policy (Critical_Error, OFF);
1467 is given, then subsequent @code{Check} pragmas whose first argument is also
1468 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1469 controls the behavior of normal assertions (thus a pragma
1470 @code{Check_Policy} with this identifier is similar to the normal
1471 @code{Assertion_Policy} pragma except that it can appear within a
1474 The special identifiers @code{Precondition} and @code{Postcondition} control
1475 the status of preconditions and postconditions given as pragmas.
1476 If a @code{Precondition} pragma
1477 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1478 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1479 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1480 are recognized. Note that preconditions and postconditions given as aspects
1481 are controlled differently, either by the @code{Assertion_Policy} pragma or
1482 by the @code{Check_Policy} pragma with identifier @code{Assertion}.
1484 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1485 to turn on corresponding checks. The default for a set of checks for which no
1486 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1487 @option{-gnata} is given, which turns on all checks by default.
1489 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1490 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1491 compatibility with the standard @code{Assertion_Policy} pragma.
1493 The implementation defined policy @code{DISABLE} is like
1494 @code{OFF} except that it completely disables semantic
1495 checking of the argument to the corresponding class of
1496 pragmas. This may be useful when the pragma arguments reference
1497 subprograms in a with'ed package which is replaced by a dummy package
1498 for the final build.
1500 @node Pragma Comment
1501 @unnumberedsec Pragma Comment
1506 @smallexample @c ada
1507 pragma Comment (static_string_EXPRESSION);
1511 This is almost identical in effect to pragma @code{Ident}. It allows the
1512 placement of a comment into the object file and hence into the
1513 executable file if the operating system permits such usage. The
1514 difference is that @code{Comment}, unlike @code{Ident}, has
1515 no limitations on placement of the pragma (it can be placed
1516 anywhere in the main source unit), and if more than one pragma
1517 is used, all comments are retained.
1519 @node Pragma Common_Object
1520 @unnumberedsec Pragma Common_Object
1521 @findex Common_Object
1525 @smallexample @c ada
1526 pragma Common_Object (
1527 [Internal =>] LOCAL_NAME
1528 [, [External =>] EXTERNAL_SYMBOL]
1529 [, [Size =>] EXTERNAL_SYMBOL] );
1533 | static_string_EXPRESSION
1537 This pragma enables the shared use of variables stored in overlaid
1538 linker areas corresponding to the use of @code{COMMON}
1539 in Fortran. The single
1540 object @var{LOCAL_NAME} is assigned to the area designated by
1541 the @var{External} argument.
1542 You may define a record to correspond to a series
1543 of fields. The @var{Size} argument
1544 is syntax checked in GNAT, but otherwise ignored.
1546 @code{Common_Object} is not supported on all platforms. If no
1547 support is available, then the code generator will issue a message
1548 indicating that the necessary attribute for implementation of this
1549 pragma is not available.
1551 @node Pragma Compile_Time_Error
1552 @unnumberedsec Pragma Compile_Time_Error
1553 @findex Compile_Time_Error
1557 @smallexample @c ada
1558 pragma Compile_Time_Error
1559 (boolean_EXPRESSION, static_string_EXPRESSION);
1563 This pragma can be used to generate additional compile time
1565 is particularly useful in generics, where errors can be issued for
1566 specific problematic instantiations. The first parameter is a boolean
1567 expression. The pragma is effective only if the value of this expression
1568 is known at compile time, and has the value True. The set of expressions
1569 whose values are known at compile time includes all static boolean
1570 expressions, and also other values which the compiler can determine
1571 at compile time (e.g., the size of a record type set by an explicit
1572 size representation clause, or the value of a variable which was
1573 initialized to a constant and is known not to have been modified).
1574 If these conditions are met, an error message is generated using
1575 the value given as the second argument. This string value may contain
1576 embedded ASCII.LF characters to break the message into multiple lines.
1578 @node Pragma Compile_Time_Warning
1579 @unnumberedsec Pragma Compile_Time_Warning
1580 @findex Compile_Time_Warning
1584 @smallexample @c ada
1585 pragma Compile_Time_Warning
1586 (boolean_EXPRESSION, static_string_EXPRESSION);
1590 Same as pragma Compile_Time_Error, except a warning is issued instead
1591 of an error message. Note that if this pragma is used in a package that
1592 is with'ed by a client, the client will get the warning even though it
1593 is issued by a with'ed package (normally warnings in with'ed units are
1594 suppressed, but this is a special exception to that rule).
1596 One typical use is within a generic where compile time known characteristics
1597 of formal parameters are tested, and warnings given appropriately. Another use
1598 with a first parameter of True is to warn a client about use of a package,
1599 for example that it is not fully implemented.
1601 @node Pragma Compiler_Unit
1602 @unnumberedsec Pragma Compiler_Unit
1603 @findex Compiler_Unit
1607 @smallexample @c ada
1608 pragma Compiler_Unit;
1612 This pragma is intended only for internal use in the GNAT run-time library.
1613 It indicates that the unit is used as part of the compiler build. The effect
1614 is to disallow constructs (raise with message, conditional expressions etc)
1615 that would cause trouble when bootstrapping using an older version of GNAT.
1616 For the exact list of restrictions, see the compiler sources and references
1617 to Is_Compiler_Unit.
1619 @node Pragma Complete_Representation
1620 @unnumberedsec Pragma Complete_Representation
1621 @findex Complete_Representation
1625 @smallexample @c ada
1626 pragma Complete_Representation;
1630 This pragma must appear immediately within a record representation
1631 clause. Typical placements are before the first component clause
1632 or after the last component clause. The effect is to give an error
1633 message if any component is missing a component clause. This pragma
1634 may be used to ensure that a record representation clause is
1635 complete, and that this invariant is maintained if fields are
1636 added to the record in the future.
1638 @node Pragma Complex_Representation
1639 @unnumberedsec Pragma Complex_Representation
1640 @findex Complex_Representation
1644 @smallexample @c ada
1645 pragma Complex_Representation
1646 ([Entity =>] LOCAL_NAME);
1650 The @var{Entity} argument must be the name of a record type which has
1651 two fields of the same floating-point type. The effect of this pragma is
1652 to force gcc to use the special internal complex representation form for
1653 this record, which may be more efficient. Note that this may result in
1654 the code for this type not conforming to standard ABI (application
1655 binary interface) requirements for the handling of record types. For
1656 example, in some environments, there is a requirement for passing
1657 records by pointer, and the use of this pragma may result in passing
1658 this type in floating-point registers.
1660 @node Pragma Component_Alignment
1661 @unnumberedsec Pragma Component_Alignment
1662 @cindex Alignments of components
1663 @findex Component_Alignment
1667 @smallexample @c ada
1668 pragma Component_Alignment (
1669 [Form =>] ALIGNMENT_CHOICE
1670 [, [Name =>] type_LOCAL_NAME]);
1672 ALIGNMENT_CHOICE ::=
1680 Specifies the alignment of components in array or record types.
1681 The meaning of the @var{Form} argument is as follows:
1684 @findex Component_Size
1685 @item Component_Size
1686 Aligns scalar components and subcomponents of the array or record type
1687 on boundaries appropriate to their inherent size (naturally
1688 aligned). For example, 1-byte components are aligned on byte boundaries,
1689 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1690 integer components are aligned on 4-byte boundaries and so on. These
1691 alignment rules correspond to the normal rules for C compilers on all
1692 machines except the VAX@.
1694 @findex Component_Size_4
1695 @item Component_Size_4
1696 Naturally aligns components with a size of four or fewer
1697 bytes. Components that are larger than 4 bytes are placed on the next
1700 @findex Storage_Unit
1702 Specifies that array or record components are byte aligned, i.e.@:
1703 aligned on boundaries determined by the value of the constant
1704 @code{System.Storage_Unit}.
1708 Specifies that array or record components are aligned on default
1709 boundaries, appropriate to the underlying hardware or operating system or
1710 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1711 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1712 the @code{Default} choice is the same as @code{Component_Size} (natural
1717 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1718 refer to a local record or array type, and the specified alignment
1719 choice applies to the specified type. The use of
1720 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1721 @code{Component_Alignment} pragma to be ignored. The use of
1722 @code{Component_Alignment} together with a record representation clause
1723 is only effective for fields not specified by the representation clause.
1725 If the @code{Name} parameter is absent, the pragma can be used as either
1726 a configuration pragma, in which case it applies to one or more units in
1727 accordance with the normal rules for configuration pragmas, or it can be
1728 used within a declarative part, in which case it applies to types that
1729 are declared within this declarative part, or within any nested scope
1730 within this declarative part. In either case it specifies the alignment
1731 to be applied to any record or array type which has otherwise standard
1734 If the alignment for a record or array type is not specified (using
1735 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1736 clause), the GNAT uses the default alignment as described previously.
1738 @node Pragma Contract_Case
1739 @unnumberedsec Pragma Contract_Case
1740 @cindex Contract cases
1741 @findex Contract_Case
1745 @smallexample @c ada
1746 pragma Contract_Case (
1747 [Name =>] static_string_Expression
1748 ,[Mode =>] (Nominal | Robustness)
1749 [, Requires => Boolean_Expression]
1750 [, Ensures => Boolean_Expression]);
1754 The @code{Contract_Case} pragma allows defining fine-grain specifications
1755 that can complement or replace the contract given by a precondition and a
1756 postcondition. Additionally, the @code{Contract_Case} pragma can be used
1757 by testing and formal verification tools. The compiler checks its validity and,
1758 depending on the assertion policy at the point of declaration of the pragma,
1759 it may insert a check in the executable. For code generation, the contract
1762 @smallexample @c ada
1763 pragma Contract_Case (
1773 @smallexample @c ada
1774 pragma Postcondition (not R'Old or else E);
1778 which is also equivalent to (in Ada 2012)
1780 @smallexample @c ada
1781 pragma Postcondition (if R'Old then E);
1785 expressing that, whenever condition @code{R} is satisfied on entry to the
1786 subprogram, condition @code{E} should be fulfilled on exit to the subprogram.
1788 A precondition @code{P} and postcondition @code{Q} can also be
1789 expressed as contract cases:
1791 @smallexample @c ada
1792 pragma Contract_Case (
1793 Name => "Replace precondition",
1797 pragma Contract_Case (
1798 Name => "Replace postcondition",
1804 @code{Contract_Case} pragmas may only appear immediately following the
1805 (separate) declaration of a subprogram in a package declaration, inside
1806 a package spec unit. Only other pragmas may intervene (that is appear
1807 between the subprogram declaration and a contract case).
1809 The compiler checks that boolean expressions given in @code{Requires} and
1810 @code{Ensures} are valid, where the rules for @code{Requires} are the
1811 same as the rule for an expression in @code{Precondition} and the rules
1812 for @code{Ensures} are the same as the rule for an expression in
1813 @code{Postcondition}. In particular, attributes @code{'Old} and
1814 @code{'Result} can only be used within the @code{Ensures}
1815 expression. The following is an example of use within a package spec:
1817 @smallexample @c ada
1818 package Math_Functions is
1820 function Sqrt (Arg : Float) return Float;
1821 pragma Contract_Case (Name => "Small argument",
1823 Requires => Arg < 100,
1824 Ensures => Sqrt'Result < 10);
1830 The meaning of a contract case is that, whenever the associated subprogram is
1831 executed in a context where @code{Requires} holds, then @code{Ensures}
1832 should hold when the subprogram returns. Mode @code{Nominal} indicates
1833 that the input context should also satisfy the precondition of the
1834 subprogram, and the output context should also satisfy its
1835 postcondition. More @code{Robustness} indicates that the precondition and
1836 postcondition of the subprogram should be ignored for this contract case,
1837 which is mostly useful when testing such a contract using a testing tool
1838 that understands contract cases.
1840 @node Pragma Convention_Identifier
1841 @unnumberedsec Pragma Convention_Identifier
1842 @findex Convention_Identifier
1843 @cindex Conventions, synonyms
1847 @smallexample @c ada
1848 pragma Convention_Identifier (
1849 [Name =>] IDENTIFIER,
1850 [Convention =>] convention_IDENTIFIER);
1854 This pragma provides a mechanism for supplying synonyms for existing
1855 convention identifiers. The @code{Name} identifier can subsequently
1856 be used as a synonym for the given convention in other pragmas (including
1857 for example pragma @code{Import} or another @code{Convention_Identifier}
1858 pragma). As an example of the use of this, suppose you had legacy code
1859 which used Fortran77 as the identifier for Fortran. Then the pragma:
1861 @smallexample @c ada
1862 pragma Convention_Identifier (Fortran77, Fortran);
1866 would allow the use of the convention identifier @code{Fortran77} in
1867 subsequent code, avoiding the need to modify the sources. As another
1868 example, you could use this to parameterize convention requirements
1869 according to systems. Suppose you needed to use @code{Stdcall} on
1870 windows systems, and @code{C} on some other system, then you could
1871 define a convention identifier @code{Library} and use a single
1872 @code{Convention_Identifier} pragma to specify which convention
1873 would be used system-wide.
1875 @node Pragma CPP_Class
1876 @unnumberedsec Pragma CPP_Class
1878 @cindex Interfacing with C++
1882 @smallexample @c ada
1883 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1887 The argument denotes an entity in the current declarative region that is
1888 declared as a record type. It indicates that the type corresponds to an
1889 externally declared C++ class type, and is to be laid out the same way
1890 that C++ would lay out the type. If the C++ class has virtual primitives
1891 then the record must be declared as a tagged record type.
1893 Types for which @code{CPP_Class} is specified do not have assignment or
1894 equality operators defined (such operations can be imported or declared
1895 as subprograms as required). Initialization is allowed only by constructor
1896 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1897 limited if not explicitly declared as limited or derived from a limited
1898 type, and an error is issued in that case.
1900 See @ref{Interfacing to C++} for related information.
1902 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1903 for backward compatibility but its functionality is available
1904 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1906 @node Pragma CPP_Constructor
1907 @unnumberedsec Pragma CPP_Constructor
1908 @cindex Interfacing with C++
1909 @findex CPP_Constructor
1913 @smallexample @c ada
1914 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1915 [, [External_Name =>] static_string_EXPRESSION ]
1916 [, [Link_Name =>] static_string_EXPRESSION ]);
1920 This pragma identifies an imported function (imported in the usual way
1921 with pragma @code{Import}) as corresponding to a C++ constructor. If
1922 @code{External_Name} and @code{Link_Name} are not specified then the
1923 @code{Entity} argument is a name that must have been previously mentioned
1924 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1925 must be of one of the following forms:
1929 @code{function @var{Fname} return @var{T}}
1933 @code{function @var{Fname} return @var{T}'Class}
1936 @code{function @var{Fname} (@dots{}) return @var{T}}
1940 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1944 where @var{T} is a limited record type imported from C++ with pragma
1945 @code{Import} and @code{Convention} = @code{CPP}.
1947 The first two forms import the default constructor, used when an object
1948 of type @var{T} is created on the Ada side with no explicit constructor.
1949 The latter two forms cover all the non-default constructors of the type.
1950 See the @value{EDITION} User's Guide for details.
1952 If no constructors are imported, it is impossible to create any objects
1953 on the Ada side and the type is implicitly declared abstract.
1955 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1956 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
1958 See @ref{Interfacing to C++} for more related information.
1960 Note: The use of functions returning class-wide types for constructors is
1961 currently obsolete. They are supported for backward compatibility. The
1962 use of functions returning the type T leave the Ada sources more clear
1963 because the imported C++ constructors always return an object of type T;
1964 that is, they never return an object whose type is a descendant of type T.
1966 @node Pragma CPP_Virtual
1967 @unnumberedsec Pragma CPP_Virtual
1968 @cindex Interfacing to C++
1971 This pragma is now obsolete has has no effect because GNAT generates
1972 the same object layout than the G++ compiler.
1974 See @ref{Interfacing to C++} for related information.
1976 @node Pragma CPP_Vtable
1977 @unnumberedsec Pragma CPP_Vtable
1978 @cindex Interfacing with C++
1981 This pragma is now obsolete has has no effect because GNAT generates
1982 the same object layout than the G++ compiler.
1984 See @ref{Interfacing to C++} for related information.
1987 @unnumberedsec Pragma Debug
1992 @smallexample @c ada
1993 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1995 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1997 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2001 The procedure call argument has the syntactic form of an expression, meeting
2002 the syntactic requirements for pragmas.
2004 If debug pragmas are not enabled or if the condition is present and evaluates
2005 to False, this pragma has no effect. If debug pragmas are enabled, the
2006 semantics of the pragma is exactly equivalent to the procedure call statement
2007 corresponding to the argument with a terminating semicolon. Pragmas are
2008 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2009 intersperse calls to debug procedures in the middle of declarations. Debug
2010 pragmas can be enabled either by use of the command line switch @option{-gnata}
2011 or by use of the configuration pragma @code{Debug_Policy}.
2013 @node Pragma Debug_Policy
2014 @unnumberedsec Pragma Debug_Policy
2015 @findex Debug_Policy
2019 @smallexample @c ada
2020 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
2024 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
2025 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
2026 This pragma overrides the effect of the @option{-gnata} switch on the
2029 The implementation defined policy @code{DISABLE} is like
2030 @code{IGNORE} except that it completely disables semantic
2031 checking of the argument to @code{pragma Debug}. This may
2032 be useful when the pragma argument references subprograms
2033 in a with'ed package which is replaced by a dummy package
2034 for the final build.
2036 @node Pragma Detect_Blocking
2037 @unnumberedsec Pragma Detect_Blocking
2038 @findex Detect_Blocking
2042 @smallexample @c ada
2043 pragma Detect_Blocking;
2047 This is a configuration pragma that forces the detection of potentially
2048 blocking operations within a protected operation, and to raise Program_Error
2051 @node Pragma Elaboration_Checks
2052 @unnumberedsec Pragma Elaboration_Checks
2053 @cindex Elaboration control
2054 @findex Elaboration_Checks
2058 @smallexample @c ada
2059 pragma Elaboration_Checks (Dynamic | Static);
2063 This is a configuration pragma that provides control over the
2064 elaboration model used by the compilation affected by the
2065 pragma. If the parameter is @code{Dynamic},
2066 then the dynamic elaboration
2067 model described in the Ada Reference Manual is used, as though
2068 the @option{-gnatE} switch had been specified on the command
2069 line. If the parameter is @code{Static}, then the default GNAT static
2070 model is used. This configuration pragma overrides the setting
2071 of the command line. For full details on the elaboration models
2072 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2073 gnat_ugn, @value{EDITION} User's Guide}.
2075 @node Pragma Eliminate
2076 @unnumberedsec Pragma Eliminate
2077 @cindex Elimination of unused subprograms
2082 @smallexample @c ada
2083 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2084 [Source_Location =>] STRING_LITERAL);
2088 The string literal given for the source location is a string which
2089 specifies the line number of the occurrence of the entity, using
2090 the syntax for SOURCE_TRACE given below:
2092 @smallexample @c ada
2093 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2098 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2100 LINE_NUMBER ::= DIGIT @{DIGIT@}
2104 Spaces around the colon in a @code{Source_Reference} are optional.
2106 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2107 explicit subprogram declaration, where the @code{entity} name in this
2108 designator appears on the source line specified by the source location.
2110 The source trace that is given as the @code{Source_Location} shall obey the
2111 following rules. The @code{FILE_NAME} is the short name (with no directory
2112 information) of an Ada source file, given using exactly the required syntax
2113 for the underlying file system (e.g. case is important if the underlying
2114 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2115 number of the occurrence of the @code{entity}
2116 as a decimal literal without an exponent or point. If an @code{entity} is not
2117 declared in a generic instantiation (this includes generic subprogram
2118 instances), the source trace includes only one source reference. If an entity
2119 is declared inside a generic instantiation, its source trace (when parsing
2120 from left to right) starts with the source location of the declaration of the
2121 entity in the generic unit and ends with the source location of the
2122 instantiation (it is given in square brackets). This approach is recursively
2123 used in case of nested instantiations: the rightmost (nested most deeply in
2124 square brackets) element of the source trace is the location of the outermost
2125 instantiation, the next to left element is the location of the next (first
2126 nested) instantiation in the code of the corresponding generic unit, and so
2127 on, and the leftmost element (that is out of any square brackets) is the
2128 location of the declaration of the entity to eliminate in a generic unit.
2130 Note that the @code{Source_Location} argument specifies which of a set of
2131 similarly named entities is being eliminated, dealing both with overloading,
2132 and also appearence of the same entity name in different scopes.
2134 This pragma indicates that the given entity is not used in the program to be
2135 compiled and built. The effect of the pragma is to allow the compiler to
2136 eliminate the code or data associated with the named entity. Any reference to
2137 an eliminated entity causes a compile-time or link-time error.
2139 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2140 in a system-independent manner, with unused entities eliminated, without
2141 needing to modify the source text. Normally the required set of
2142 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2144 Any source file change that removes, splits, or
2145 adds lines may make the set of Eliminate pragmas invalid because their
2146 @code{Source_Location} argument values may get out of date.
2148 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2149 operation. In this case all the subprograms to which the given operation can
2150 dispatch are considered to be unused (are never called as a result of a direct
2151 or a dispatching call).
2153 @node Pragma Export_Exception
2154 @unnumberedsec Pragma Export_Exception
2156 @findex Export_Exception
2160 @smallexample @c ada
2161 pragma Export_Exception (
2162 [Internal =>] LOCAL_NAME
2163 [, [External =>] EXTERNAL_SYMBOL]
2164 [, [Form =>] Ada | VMS]
2165 [, [Code =>] static_integer_EXPRESSION]);
2169 | static_string_EXPRESSION
2173 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2174 causes the specified exception to be propagated outside of the Ada program,
2175 so that it can be handled by programs written in other OpenVMS languages.
2176 This pragma establishes an external name for an Ada exception and makes the
2177 name available to the OpenVMS Linker as a global symbol. For further details
2178 on this pragma, see the
2179 DEC Ada Language Reference Manual, section 13.9a3.2.
2181 @node Pragma Export_Function
2182 @unnumberedsec Pragma Export_Function
2183 @cindex Argument passing mechanisms
2184 @findex Export_Function
2189 @smallexample @c ada
2190 pragma Export_Function (
2191 [Internal =>] LOCAL_NAME
2192 [, [External =>] EXTERNAL_SYMBOL]
2193 [, [Parameter_Types =>] PARAMETER_TYPES]
2194 [, [Result_Type =>] result_SUBTYPE_MARK]
2195 [, [Mechanism =>] MECHANISM]
2196 [, [Result_Mechanism =>] MECHANISM_NAME]);
2200 | static_string_EXPRESSION
2205 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2209 | subtype_Name ' Access
2213 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2215 MECHANISM_ASSOCIATION ::=
2216 [formal_parameter_NAME =>] MECHANISM_NAME
2221 | Descriptor [([Class =>] CLASS_NAME)]
2222 | Short_Descriptor [([Class =>] CLASS_NAME)]
2224 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2228 Use this pragma to make a function externally callable and optionally
2229 provide information on mechanisms to be used for passing parameter and
2230 result values. We recommend, for the purposes of improving portability,
2231 this pragma always be used in conjunction with a separate pragma
2232 @code{Export}, which must precede the pragma @code{Export_Function}.
2233 GNAT does not require a separate pragma @code{Export}, but if none is
2234 present, @code{Convention Ada} is assumed, which is usually
2235 not what is wanted, so it is usually appropriate to use this
2236 pragma in conjunction with a @code{Export} or @code{Convention}
2237 pragma that specifies the desired foreign convention.
2238 Pragma @code{Export_Function}
2239 (and @code{Export}, if present) must appear in the same declarative
2240 region as the function to which they apply.
2242 @var{internal_name} must uniquely designate the function to which the
2243 pragma applies. If more than one function name exists of this name in
2244 the declarative part you must use the @code{Parameter_Types} and
2245 @code{Result_Type} parameters is mandatory to achieve the required
2246 unique designation. @var{subtype_mark}s in these parameters must
2247 exactly match the subtypes in the corresponding function specification,
2248 using positional notation to match parameters with subtype marks.
2249 The form with an @code{'Access} attribute can be used to match an
2250 anonymous access parameter.
2253 @cindex Passing by descriptor
2254 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2255 The default behavior for Export_Function is to accept either 64bit or
2256 32bit descriptors unless short_descriptor is specified, then only 32bit
2257 descriptors are accepted.
2259 @cindex Suppressing external name
2260 Special treatment is given if the EXTERNAL is an explicit null
2261 string or a static string expressions that evaluates to the null
2262 string. In this case, no external name is generated. This form
2263 still allows the specification of parameter mechanisms.
2265 @node Pragma Export_Object
2266 @unnumberedsec Pragma Export_Object
2267 @findex Export_Object
2271 @smallexample @c ada
2272 pragma Export_Object
2273 [Internal =>] LOCAL_NAME
2274 [, [External =>] EXTERNAL_SYMBOL]
2275 [, [Size =>] EXTERNAL_SYMBOL]
2279 | static_string_EXPRESSION
2283 This pragma designates an object as exported, and apart from the
2284 extended rules for external symbols, is identical in effect to the use of
2285 the normal @code{Export} pragma applied to an object. You may use a
2286 separate Export pragma (and you probably should from the point of view
2287 of portability), but it is not required. @var{Size} is syntax checked,
2288 but otherwise ignored by GNAT@.
2290 @node Pragma Export_Procedure
2291 @unnumberedsec Pragma Export_Procedure
2292 @findex Export_Procedure
2296 @smallexample @c ada
2297 pragma Export_Procedure (
2298 [Internal =>] LOCAL_NAME
2299 [, [External =>] EXTERNAL_SYMBOL]
2300 [, [Parameter_Types =>] PARAMETER_TYPES]
2301 [, [Mechanism =>] MECHANISM]);
2305 | static_string_EXPRESSION
2310 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2314 | subtype_Name ' Access
2318 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2320 MECHANISM_ASSOCIATION ::=
2321 [formal_parameter_NAME =>] MECHANISM_NAME
2326 | Descriptor [([Class =>] CLASS_NAME)]
2327 | Short_Descriptor [([Class =>] CLASS_NAME)]
2329 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2333 This pragma is identical to @code{Export_Function} except that it
2334 applies to a procedure rather than a function and the parameters
2335 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2336 GNAT does not require a separate pragma @code{Export}, but if none is
2337 present, @code{Convention Ada} is assumed, which is usually
2338 not what is wanted, so it is usually appropriate to use this
2339 pragma in conjunction with a @code{Export} or @code{Convention}
2340 pragma that specifies the desired foreign convention.
2343 @cindex Passing by descriptor
2344 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2345 The default behavior for Export_Procedure is to accept either 64bit or
2346 32bit descriptors unless short_descriptor is specified, then only 32bit
2347 descriptors are accepted.
2349 @cindex Suppressing external name
2350 Special treatment is given if the EXTERNAL is an explicit null
2351 string or a static string expressions that evaluates to the null
2352 string. In this case, no external name is generated. This form
2353 still allows the specification of parameter mechanisms.
2355 @node Pragma Export_Value
2356 @unnumberedsec Pragma Export_Value
2357 @findex Export_Value
2361 @smallexample @c ada
2362 pragma Export_Value (
2363 [Value =>] static_integer_EXPRESSION,
2364 [Link_Name =>] static_string_EXPRESSION);
2368 This pragma serves to export a static integer value for external use.
2369 The first argument specifies the value to be exported. The Link_Name
2370 argument specifies the symbolic name to be associated with the integer
2371 value. This pragma is useful for defining a named static value in Ada
2372 that can be referenced in assembly language units to be linked with
2373 the application. This pragma is currently supported only for the
2374 AAMP target and is ignored for other targets.
2376 @node Pragma Export_Valued_Procedure
2377 @unnumberedsec Pragma Export_Valued_Procedure
2378 @findex Export_Valued_Procedure
2382 @smallexample @c ada
2383 pragma Export_Valued_Procedure (
2384 [Internal =>] LOCAL_NAME
2385 [, [External =>] EXTERNAL_SYMBOL]
2386 [, [Parameter_Types =>] PARAMETER_TYPES]
2387 [, [Mechanism =>] MECHANISM]);
2391 | static_string_EXPRESSION
2396 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2400 | subtype_Name ' Access
2404 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2406 MECHANISM_ASSOCIATION ::=
2407 [formal_parameter_NAME =>] MECHANISM_NAME
2412 | Descriptor [([Class =>] CLASS_NAME)]
2413 | Short_Descriptor [([Class =>] CLASS_NAME)]
2415 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2419 This pragma is identical to @code{Export_Procedure} except that the
2420 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2421 mode @code{OUT}, and externally the subprogram is treated as a function
2422 with this parameter as the result of the function. GNAT provides for
2423 this capability to allow the use of @code{OUT} and @code{IN OUT}
2424 parameters in interfacing to external functions (which are not permitted
2426 GNAT does not require a separate pragma @code{Export}, but if none is
2427 present, @code{Convention Ada} is assumed, which is almost certainly
2428 not what is wanted since the whole point of this pragma is to interface
2429 with foreign language functions, so it is usually appropriate to use this
2430 pragma in conjunction with a @code{Export} or @code{Convention}
2431 pragma that specifies the desired foreign convention.
2434 @cindex Passing by descriptor
2435 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2436 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2437 32bit descriptors unless short_descriptor is specified, then only 32bit
2438 descriptors are accepted.
2440 @cindex Suppressing external name
2441 Special treatment is given if the EXTERNAL is an explicit null
2442 string or a static string expressions that evaluates to the null
2443 string. In this case, no external name is generated. This form
2444 still allows the specification of parameter mechanisms.
2446 @node Pragma Extend_System
2447 @unnumberedsec Pragma Extend_System
2448 @cindex @code{system}, extending
2450 @findex Extend_System
2454 @smallexample @c ada
2455 pragma Extend_System ([Name =>] IDENTIFIER);
2459 This pragma is used to provide backwards compatibility with other
2460 implementations that extend the facilities of package @code{System}. In
2461 GNAT, @code{System} contains only the definitions that are present in
2462 the Ada RM@. However, other implementations, notably the DEC Ada 83
2463 implementation, provide many extensions to package @code{System}.
2465 For each such implementation accommodated by this pragma, GNAT provides a
2466 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2467 implementation, which provides the required additional definitions. You
2468 can use this package in two ways. You can @code{with} it in the normal
2469 way and access entities either by selection or using a @code{use}
2470 clause. In this case no special processing is required.
2472 However, if existing code contains references such as
2473 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2474 definitions provided in package @code{System}, you may use this pragma
2475 to extend visibility in @code{System} in a non-standard way that
2476 provides greater compatibility with the existing code. Pragma
2477 @code{Extend_System} is a configuration pragma whose single argument is
2478 the name of the package containing the extended definition
2479 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2480 control of this pragma will be processed using special visibility
2481 processing that looks in package @code{System.Aux_@var{xxx}} where
2482 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2483 package @code{System}, but not found in package @code{System}.
2485 You can use this pragma either to access a predefined @code{System}
2486 extension supplied with the compiler, for example @code{Aux_DEC} or
2487 you can construct your own extension unit following the above
2488 definition. Note that such a package is a child of @code{System}
2489 and thus is considered part of the implementation. To compile
2490 it you will have to use the appropriate switch for compiling
2492 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2495 @node Pragma Extensions_Allowed
2496 @unnumberedsec Pragma Extensions_Allowed
2497 @cindex Ada Extensions
2498 @cindex GNAT Extensions
2499 @findex Extensions_Allowed
2503 @smallexample @c ada
2504 pragma Extensions_Allowed (On | Off);
2508 This configuration pragma enables or disables the implementation
2509 extension mode (the use of Off as a parameter cancels the effect
2510 of the @option{-gnatX} command switch).
2512 In extension mode, the latest version of the Ada language is
2513 implemented (currently Ada 2012), and in addition a small number
2514 of GNAT specific extensions are recognized as follows:
2517 @item Constrained attribute for generic objects
2518 The @code{Constrained} attribute is permitted for objects of
2519 generic types. The result indicates if the corresponding actual
2524 @node Pragma External
2525 @unnumberedsec Pragma External
2530 @smallexample @c ada
2532 [ Convention =>] convention_IDENTIFIER,
2533 [ Entity =>] LOCAL_NAME
2534 [, [External_Name =>] static_string_EXPRESSION ]
2535 [, [Link_Name =>] static_string_EXPRESSION ]);
2539 This pragma is identical in syntax and semantics to pragma
2540 @code{Export} as defined in the Ada Reference Manual. It is
2541 provided for compatibility with some Ada 83 compilers that
2542 used this pragma for exactly the same purposes as pragma
2543 @code{Export} before the latter was standardized.
2545 @node Pragma External_Name_Casing
2546 @unnumberedsec Pragma External_Name_Casing
2547 @cindex Dec Ada 83 casing compatibility
2548 @cindex External Names, casing
2549 @cindex Casing of External names
2550 @findex External_Name_Casing
2554 @smallexample @c ada
2555 pragma External_Name_Casing (
2556 Uppercase | Lowercase
2557 [, Uppercase | Lowercase | As_Is]);
2561 This pragma provides control over the casing of external names associated
2562 with Import and Export pragmas. There are two cases to consider:
2565 @item Implicit external names
2566 Implicit external names are derived from identifiers. The most common case
2567 arises when a standard Ada Import or Export pragma is used with only two
2570 @smallexample @c ada
2571 pragma Import (C, C_Routine);
2575 Since Ada is a case-insensitive language, the spelling of the identifier in
2576 the Ada source program does not provide any information on the desired
2577 casing of the external name, and so a convention is needed. In GNAT the
2578 default treatment is that such names are converted to all lower case
2579 letters. This corresponds to the normal C style in many environments.
2580 The first argument of pragma @code{External_Name_Casing} can be used to
2581 control this treatment. If @code{Uppercase} is specified, then the name
2582 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2583 then the normal default of all lower case letters will be used.
2585 This same implicit treatment is also used in the case of extended DEC Ada 83
2586 compatible Import and Export pragmas where an external name is explicitly
2587 specified using an identifier rather than a string.
2589 @item Explicit external names
2590 Explicit external names are given as string literals. The most common case
2591 arises when a standard Ada Import or Export pragma is used with three
2594 @smallexample @c ada
2595 pragma Import (C, C_Routine, "C_routine");
2599 In this case, the string literal normally provides the exact casing required
2600 for the external name. The second argument of pragma
2601 @code{External_Name_Casing} may be used to modify this behavior.
2602 If @code{Uppercase} is specified, then the name
2603 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2604 then the name will be forced to all lowercase letters. A specification of
2605 @code{As_Is} provides the normal default behavior in which the casing is
2606 taken from the string provided.
2610 This pragma may appear anywhere that a pragma is valid. In particular, it
2611 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2612 case it applies to all subsequent compilations, or it can be used as a program
2613 unit pragma, in which case it only applies to the current unit, or it can
2614 be used more locally to control individual Import/Export pragmas.
2616 It is primarily intended for use with OpenVMS systems, where many
2617 compilers convert all symbols to upper case by default. For interfacing to
2618 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2621 @smallexample @c ada
2622 pragma External_Name_Casing (Uppercase, Uppercase);
2626 to enforce the upper casing of all external symbols.
2628 @node Pragma Fast_Math
2629 @unnumberedsec Pragma Fast_Math
2634 @smallexample @c ada
2639 This is a configuration pragma which activates a mode in which speed is
2640 considered more important for floating-point operations than absolutely
2641 accurate adherence to the requirements of the standard. Currently the
2642 following operations are affected:
2645 @item Complex Multiplication
2646 The normal simple formula for complex multiplication can result in intermediate
2647 overflows for numbers near the end of the range. The Ada standard requires that
2648 this situation be detected and corrected by scaling, but in Fast_Math mode such
2649 cases will simply result in overflow. Note that to take advantage of this you
2650 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2651 under control of the pragma, rather than use the preinstantiated versions.
2654 @node Pragma Favor_Top_Level
2655 @unnumberedsec Pragma Favor_Top_Level
2656 @findex Favor_Top_Level
2660 @smallexample @c ada
2661 pragma Favor_Top_Level (type_NAME);
2665 The named type must be an access-to-subprogram type. This pragma is an
2666 efficiency hint to the compiler, regarding the use of 'Access or
2667 'Unrestricted_Access on nested (non-library-level) subprograms. The
2668 pragma means that nested subprograms are not used with this type, or
2669 are rare, so that the generated code should be efficient in the
2670 top-level case. When this pragma is used, dynamically generated
2671 trampolines may be used on some targets for nested subprograms.
2672 See also the No_Implicit_Dynamic_Code restriction.
2674 @node Pragma Finalize_Storage_Only
2675 @unnumberedsec Pragma Finalize_Storage_Only
2676 @findex Finalize_Storage_Only
2680 @smallexample @c ada
2681 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2685 This pragma allows the compiler not to emit a Finalize call for objects
2686 defined at the library level. This is mostly useful for types where
2687 finalization is only used to deal with storage reclamation since in most
2688 environments it is not necessary to reclaim memory just before terminating
2689 execution, hence the name.
2691 @node Pragma Float_Representation
2692 @unnumberedsec Pragma Float_Representation
2694 @findex Float_Representation
2698 @smallexample @c ada
2699 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2701 FLOAT_REP ::= VAX_Float | IEEE_Float
2705 In the one argument form, this pragma is a configuration pragma which
2706 allows control over the internal representation chosen for the predefined
2707 floating point types declared in the packages @code{Standard} and
2708 @code{System}. On all systems other than OpenVMS, the argument must
2709 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2710 argument may be @code{VAX_Float} to specify the use of the VAX float
2711 format for the floating-point types in Standard. This requires that
2712 the standard runtime libraries be recompiled.
2714 The two argument form specifies the representation to be used for
2715 the specified floating-point type. On all systems other than OpenVMS,
2717 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2718 argument may be @code{VAX_Float} to specify the use of the VAX float
2723 For digits values up to 6, F float format will be used.
2725 For digits values from 7 to 9, D float format will be used.
2727 For digits values from 10 to 15, G float format will be used.
2729 Digits values above 15 are not allowed.
2733 @unnumberedsec Pragma Ident
2738 @smallexample @c ada
2739 pragma Ident (static_string_EXPRESSION);
2743 This pragma provides a string identification in the generated object file,
2744 if the system supports the concept of this kind of identification string.
2745 This pragma is allowed only in the outermost declarative part or
2746 declarative items of a compilation unit. If more than one @code{Ident}
2747 pragma is given, only the last one processed is effective.
2749 On OpenVMS systems, the effect of the pragma is identical to the effect of
2750 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2751 maximum allowed length is 31 characters, so if it is important to
2752 maintain compatibility with this compiler, you should obey this length
2755 @node Pragma Implemented
2756 @unnumberedsec Pragma Implemented
2761 @smallexample @c ada
2762 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2764 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2768 This is an Ada 2012 representation pragma which applies to protected, task
2769 and synchronized interface primitives. The use of pragma Implemented provides
2770 a way to impose a static requirement on the overriding operation by adhering
2771 to one of the three implementation kids: entry, protected procedure or any of
2774 @smallexample @c ada
2775 type Synch_Iface is synchronized interface;
2776 procedure Prim_Op (Obj : in out Iface) is abstract;
2777 pragma Implemented (Prim_Op, By_Protected_Procedure);
2779 protected type Prot_1 is new Synch_Iface with
2780 procedure Prim_Op; -- Legal
2783 protected type Prot_2 is new Synch_Iface with
2784 entry Prim_Op; -- Illegal
2787 task type Task_Typ is new Synch_Iface with
2788 entry Prim_Op; -- Illegal
2793 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2794 Implemented determines the runtime behavior of the requeue. Implementation kind
2795 By_Entry guarantees that the action of requeueing will proceed from an entry to
2796 another entry. Implementation kind By_Protected_Procedure transforms the
2797 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2798 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2799 the target's overriding subprogram kind.
2801 @node Pragma Implicit_Packing
2802 @unnumberedsec Pragma Implicit_Packing
2803 @findex Implicit_Packing
2807 @smallexample @c ada
2808 pragma Implicit_Packing;
2812 This is a configuration pragma that requests implicit packing for packed
2813 arrays for which a size clause is given but no explicit pragma Pack or
2814 specification of Component_Size is present. It also applies to records
2815 where no record representation clause is present. Consider this example:
2817 @smallexample @c ada
2818 type R is array (0 .. 7) of Boolean;
2823 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2824 does not change the layout of a composite object. So the Size clause in the
2825 above example is normally rejected, since the default layout of the array uses
2826 8-bit components, and thus the array requires a minimum of 64 bits.
2828 If this declaration is compiled in a region of code covered by an occurrence
2829 of the configuration pragma Implicit_Packing, then the Size clause in this
2830 and similar examples will cause implicit packing and thus be accepted. For
2831 this implicit packing to occur, the type in question must be an array of small
2832 components whose size is known at compile time, and the Size clause must
2833 specify the exact size that corresponds to the length of the array multiplied
2834 by the size in bits of the component type.
2835 @cindex Array packing
2837 Similarly, the following example shows the use in the record case
2839 @smallexample @c ada
2841 a, b, c, d, e, f, g, h : boolean;
2848 Without a pragma Pack, each Boolean field requires 8 bits, so the
2849 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2850 sufficient. The use of pragma Implicit_Packing allows this record
2851 declaration to compile without an explicit pragma Pack.
2852 @node Pragma Import_Exception
2853 @unnumberedsec Pragma Import_Exception
2855 @findex Import_Exception
2859 @smallexample @c ada
2860 pragma Import_Exception (
2861 [Internal =>] LOCAL_NAME
2862 [, [External =>] EXTERNAL_SYMBOL]
2863 [, [Form =>] Ada | VMS]
2864 [, [Code =>] static_integer_EXPRESSION]);
2868 | static_string_EXPRESSION
2872 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2873 It allows OpenVMS conditions (for example, from OpenVMS system services or
2874 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2875 The pragma specifies that the exception associated with an exception
2876 declaration in an Ada program be defined externally (in non-Ada code).
2877 For further details on this pragma, see the
2878 DEC Ada Language Reference Manual, section 13.9a.3.1.
2880 @node Pragma Import_Function
2881 @unnumberedsec Pragma Import_Function
2882 @findex Import_Function
2886 @smallexample @c ada
2887 pragma Import_Function (
2888 [Internal =>] LOCAL_NAME,
2889 [, [External =>] EXTERNAL_SYMBOL]
2890 [, [Parameter_Types =>] PARAMETER_TYPES]
2891 [, [Result_Type =>] SUBTYPE_MARK]
2892 [, [Mechanism =>] MECHANISM]
2893 [, [Result_Mechanism =>] MECHANISM_NAME]
2894 [, [First_Optional_Parameter =>] IDENTIFIER]);
2898 | static_string_EXPRESSION
2902 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2906 | subtype_Name ' Access
2910 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2912 MECHANISM_ASSOCIATION ::=
2913 [formal_parameter_NAME =>] MECHANISM_NAME
2918 | Descriptor [([Class =>] CLASS_NAME)]
2919 | Short_Descriptor [([Class =>] CLASS_NAME)]
2921 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2925 This pragma is used in conjunction with a pragma @code{Import} to
2926 specify additional information for an imported function. The pragma
2927 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2928 @code{Import_Function} pragma and both must appear in the same
2929 declarative part as the function specification.
2931 The @var{Internal} argument must uniquely designate
2932 the function to which the
2933 pragma applies. If more than one function name exists of this name in
2934 the declarative part you must use the @code{Parameter_Types} and
2935 @var{Result_Type} parameters to achieve the required unique
2936 designation. Subtype marks in these parameters must exactly match the
2937 subtypes in the corresponding function specification, using positional
2938 notation to match parameters with subtype marks.
2939 The form with an @code{'Access} attribute can be used to match an
2940 anonymous access parameter.
2942 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2943 parameters to specify passing mechanisms for the
2944 parameters and result. If you specify a single mechanism name, it
2945 applies to all parameters. Otherwise you may specify a mechanism on a
2946 parameter by parameter basis using either positional or named
2947 notation. If the mechanism is not specified, the default mechanism
2951 @cindex Passing by descriptor
2952 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2953 The default behavior for Import_Function is to pass a 64bit descriptor
2954 unless short_descriptor is specified, then a 32bit descriptor is passed.
2956 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2957 It specifies that the designated parameter and all following parameters
2958 are optional, meaning that they are not passed at the generated code
2959 level (this is distinct from the notion of optional parameters in Ada
2960 where the parameters are passed anyway with the designated optional
2961 parameters). All optional parameters must be of mode @code{IN} and have
2962 default parameter values that are either known at compile time
2963 expressions, or uses of the @code{'Null_Parameter} attribute.
2965 @node Pragma Import_Object
2966 @unnumberedsec Pragma Import_Object
2967 @findex Import_Object
2971 @smallexample @c ada
2972 pragma Import_Object
2973 [Internal =>] LOCAL_NAME
2974 [, [External =>] EXTERNAL_SYMBOL]
2975 [, [Size =>] EXTERNAL_SYMBOL]);
2979 | static_string_EXPRESSION
2983 This pragma designates an object as imported, and apart from the
2984 extended rules for external symbols, is identical in effect to the use of
2985 the normal @code{Import} pragma applied to an object. Unlike the
2986 subprogram case, you need not use a separate @code{Import} pragma,
2987 although you may do so (and probably should do so from a portability
2988 point of view). @var{size} is syntax checked, but otherwise ignored by
2991 @node Pragma Import_Procedure
2992 @unnumberedsec Pragma Import_Procedure
2993 @findex Import_Procedure
2997 @smallexample @c ada
2998 pragma Import_Procedure (
2999 [Internal =>] LOCAL_NAME
3000 [, [External =>] EXTERNAL_SYMBOL]
3001 [, [Parameter_Types =>] PARAMETER_TYPES]
3002 [, [Mechanism =>] MECHANISM]
3003 [, [First_Optional_Parameter =>] IDENTIFIER]);
3007 | static_string_EXPRESSION
3011 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3015 | subtype_Name ' Access
3019 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3021 MECHANISM_ASSOCIATION ::=
3022 [formal_parameter_NAME =>] MECHANISM_NAME
3027 | Descriptor [([Class =>] CLASS_NAME)]
3028 | Short_Descriptor [([Class =>] CLASS_NAME)]
3030 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3034 This pragma is identical to @code{Import_Function} except that it
3035 applies to a procedure rather than a function and the parameters
3036 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3038 @node Pragma Import_Valued_Procedure
3039 @unnumberedsec Pragma Import_Valued_Procedure
3040 @findex Import_Valued_Procedure
3044 @smallexample @c ada
3045 pragma Import_Valued_Procedure (
3046 [Internal =>] LOCAL_NAME
3047 [, [External =>] EXTERNAL_SYMBOL]
3048 [, [Parameter_Types =>] PARAMETER_TYPES]
3049 [, [Mechanism =>] MECHANISM]
3050 [, [First_Optional_Parameter =>] IDENTIFIER]);
3054 | static_string_EXPRESSION
3058 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3062 | subtype_Name ' Access
3066 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3068 MECHANISM_ASSOCIATION ::=
3069 [formal_parameter_NAME =>] MECHANISM_NAME
3074 | Descriptor [([Class =>] CLASS_NAME)]
3075 | Short_Descriptor [([Class =>] CLASS_NAME)]
3077 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3081 This pragma is identical to @code{Import_Procedure} except that the
3082 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3083 mode @code{OUT}, and externally the subprogram is treated as a function
3084 with this parameter as the result of the function. The purpose of this
3085 capability is to allow the use of @code{OUT} and @code{IN OUT}
3086 parameters in interfacing to external functions (which are not permitted
3087 in Ada functions). You may optionally use the @code{Mechanism}
3088 parameters to specify passing mechanisms for the parameters.
3089 If you specify a single mechanism name, it applies to all parameters.
3090 Otherwise you may specify a mechanism on a parameter by parameter
3091 basis using either positional or named notation. If the mechanism is not
3092 specified, the default mechanism is used.
3094 Note that it is important to use this pragma in conjunction with a separate
3095 pragma Import that specifies the desired convention, since otherwise the
3096 default convention is Ada, which is almost certainly not what is required.
3098 @node Pragma Initialize_Scalars
3099 @unnumberedsec Pragma Initialize_Scalars
3100 @findex Initialize_Scalars
3101 @cindex debugging with Initialize_Scalars
3105 @smallexample @c ada
3106 pragma Initialize_Scalars;
3110 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3111 two important differences. First, there is no requirement for the pragma
3112 to be used uniformly in all units of a partition, in particular, it is fine
3113 to use this just for some or all of the application units of a partition,
3114 without needing to recompile the run-time library.
3116 In the case where some units are compiled with the pragma, and some without,
3117 then a declaration of a variable where the type is defined in package
3118 Standard or is locally declared will always be subject to initialization,
3119 as will any declaration of a scalar variable. For composite variables,
3120 whether the variable is initialized may also depend on whether the package
3121 in which the type of the variable is declared is compiled with the pragma.
3123 The other important difference is that you can control the value used
3124 for initializing scalar objects. At bind time, you can select several
3125 options for initialization. You can
3126 initialize with invalid values (similar to Normalize_Scalars, though for
3127 Initialize_Scalars it is not always possible to determine the invalid
3128 values in complex cases like signed component fields with non-standard
3129 sizes). You can also initialize with high or
3130 low values, or with a specified bit pattern. See the @value{EDITION}
3131 User's Guide for binder options for specifying these cases.
3133 This means that you can compile a program, and then without having to
3134 recompile the program, you can run it with different values being used
3135 for initializing otherwise uninitialized values, to test if your program
3136 behavior depends on the choice. Of course the behavior should not change,
3137 and if it does, then most likely you have an erroneous reference to an
3138 uninitialized value.
3140 It is even possible to change the value at execution time eliminating even
3141 the need to rebind with a different switch using an environment variable.
3142 See the @value{EDITION} User's Guide for details.
3144 Note that pragma @code{Initialize_Scalars} is particularly useful in
3145 conjunction with the enhanced validity checking that is now provided
3146 in GNAT, which checks for invalid values under more conditions.
3147 Using this feature (see description of the @option{-gnatV} flag in the
3148 @value{EDITION} User's Guide) in conjunction with
3149 pragma @code{Initialize_Scalars}
3150 provides a powerful new tool to assist in the detection of problems
3151 caused by uninitialized variables.
3153 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3154 effect on the generated code. This may cause your code to be
3155 substantially larger. It may also cause an increase in the amount
3156 of stack required, so it is probably a good idea to turn on stack
3157 checking (see description of stack checking in the @value{EDITION}
3158 User's Guide) when using this pragma.
3160 @node Pragma Inline_Always
3161 @unnumberedsec Pragma Inline_Always
3162 @findex Inline_Always
3166 @smallexample @c ada
3167 pragma Inline_Always (NAME [, NAME]);
3171 Similar to pragma @code{Inline} except that inlining is not subject to
3172 the use of option @option{-gnatn} and the inlining happens regardless of
3173 whether this option is used.
3175 @node Pragma Inline_Generic
3176 @unnumberedsec Pragma Inline_Generic
3177 @findex Inline_Generic
3181 @smallexample @c ada
3182 pragma Inline_Generic (generic_package_NAME);
3186 This is implemented for compatibility with DEC Ada 83 and is recognized,
3187 but otherwise ignored, by GNAT@. All generic instantiations are inlined
3188 by default when using GNAT@.
3190 @node Pragma Interface
3191 @unnumberedsec Pragma Interface
3196 @smallexample @c ada
3198 [Convention =>] convention_identifier,
3199 [Entity =>] local_NAME
3200 [, [External_Name =>] static_string_expression]
3201 [, [Link_Name =>] static_string_expression]);
3205 This pragma is identical in syntax and semantics to
3206 the standard Ada pragma @code{Import}. It is provided for compatibility
3207 with Ada 83. The definition is upwards compatible both with pragma
3208 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3209 with some extended implementations of this pragma in certain Ada 83
3210 implementations. The only difference between pragma @code{Interface}
3211 and pragma @code{Import} is that there is special circuitry to allow
3212 both pragmas to appear for the same subprogram entity (normally it
3213 is illegal to have multiple @code{Import} pragmas. This is useful in
3214 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3217 @node Pragma Interface_Name
3218 @unnumberedsec Pragma Interface_Name
3219 @findex Interface_Name
3223 @smallexample @c ada
3224 pragma Interface_Name (
3225 [Entity =>] LOCAL_NAME
3226 [, [External_Name =>] static_string_EXPRESSION]
3227 [, [Link_Name =>] static_string_EXPRESSION]);
3231 This pragma provides an alternative way of specifying the interface name
3232 for an interfaced subprogram, and is provided for compatibility with Ada
3233 83 compilers that use the pragma for this purpose. You must provide at
3234 least one of @var{External_Name} or @var{Link_Name}.
3236 @node Pragma Interrupt_Handler
3237 @unnumberedsec Pragma Interrupt_Handler
3238 @findex Interrupt_Handler
3242 @smallexample @c ada
3243 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3247 This program unit pragma is supported for parameterless protected procedures
3248 as described in Annex C of the Ada Reference Manual. On the AAMP target
3249 the pragma can also be specified for nonprotected parameterless procedures
3250 that are declared at the library level (which includes procedures
3251 declared at the top level of a library package). In the case of AAMP,
3252 when this pragma is applied to a nonprotected procedure, the instruction
3253 @code{IERET} is generated for returns from the procedure, enabling
3254 maskable interrupts, in place of the normal return instruction.
3256 @node Pragma Interrupt_State
3257 @unnumberedsec Pragma Interrupt_State
3258 @findex Interrupt_State
3262 @smallexample @c ada
3263 pragma Interrupt_State
3265 [State =>] SYSTEM | RUNTIME | USER);
3269 Normally certain interrupts are reserved to the implementation. Any attempt
3270 to attach an interrupt causes Program_Error to be raised, as described in
3271 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3272 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3273 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3274 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3275 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3276 Ada exceptions, or used to implement run-time functions such as the
3277 @code{abort} statement and stack overflow checking.
3279 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3280 such uses of interrupts. It subsumes the functionality of pragma
3281 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3282 available on Windows or VMS. On all other platforms than VxWorks,
3283 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3284 and may be used to mark interrupts required by the board support package
3287 Interrupts can be in one of three states:
3291 The interrupt is reserved (no Ada handler can be installed), and the
3292 Ada run-time may not install a handler. As a result you are guaranteed
3293 standard system default action if this interrupt is raised.
3297 The interrupt is reserved (no Ada handler can be installed). The run time
3298 is allowed to install a handler for internal control purposes, but is
3299 not required to do so.
3303 The interrupt is unreserved. The user may install a handler to provide
3308 These states are the allowed values of the @code{State} parameter of the
3309 pragma. The @code{Name} parameter is a value of the type
3310 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3311 @code{Ada.Interrupts.Names}.
3313 This is a configuration pragma, and the binder will check that there
3314 are no inconsistencies between different units in a partition in how a
3315 given interrupt is specified. It may appear anywhere a pragma is legal.
3317 The effect is to move the interrupt to the specified state.
3319 By declaring interrupts to be SYSTEM, you guarantee the standard system
3320 action, such as a core dump.
3322 By declaring interrupts to be USER, you guarantee that you can install
3325 Note that certain signals on many operating systems cannot be caught and
3326 handled by applications. In such cases, the pragma is ignored. See the
3327 operating system documentation, or the value of the array @code{Reserved}
3328 declared in the spec of package @code{System.OS_Interface}.
3330 Overriding the default state of signals used by the Ada runtime may interfere
3331 with an application's runtime behavior in the cases of the synchronous signals,
3332 and in the case of the signal used to implement the @code{abort} statement.
3334 @node Pragma Invariant
3335 @unnumberedsec Pragma Invariant
3340 @smallexample @c ada
3342 ([Entity =>] private_type_LOCAL_NAME,
3343 [Check =>] EXPRESSION
3344 [,[Message =>] String_Expression]);
3348 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3349 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3350 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3351 requires the use of the aspect syntax, which is not available except in 2012
3352 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3353 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3354 note that the aspect Invariant is a synonym in GNAT for the aspect
3355 Type_Invariant, but there is no pragma Type_Invariant.
3357 The pragma must appear within the visible part of the package specification,
3358 after the type to which its Entity argument appears. As with the Invariant
3359 aspect, the Check expression is not analyzed until the end of the visible
3360 part of the package, so it may contain forward references. The Message
3361 argument, if present, provides the exception message used if the invariant
3362 is violated. If no Message parameter is provided, a default message that
3363 identifies the line on which the pragma appears is used.
3365 It is permissible to have multiple Invariants for the same type entity, in
3366 which case they are and'ed together. It is permissible to use this pragma
3367 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3368 invariant pragma for the same entity.
3370 For further details on the use of this pragma, see the Ada 2012 documentation
3371 of the Type_Invariant aspect.
3373 @node Pragma Keep_Names
3374 @unnumberedsec Pragma Keep_Names
3379 @smallexample @c ada
3380 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3384 The @var{LOCAL_NAME} argument
3385 must refer to an enumeration first subtype
3386 in the current declarative part. The effect is to retain the enumeration
3387 literal names for use by @code{Image} and @code{Value} even if a global
3388 @code{Discard_Names} pragma applies. This is useful when you want to
3389 generally suppress enumeration literal names and for example you therefore
3390 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3391 want to retain the names for specific enumeration types.
3393 @node Pragma License
3394 @unnumberedsec Pragma License
3396 @cindex License checking
3400 @smallexample @c ada
3401 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3405 This pragma is provided to allow automated checking for appropriate license
3406 conditions with respect to the standard and modified GPL@. A pragma
3407 @code{License}, which is a configuration pragma that typically appears at
3408 the start of a source file or in a separate @file{gnat.adc} file, specifies
3409 the licensing conditions of a unit as follows:
3413 This is used for a unit that can be freely used with no license restrictions.
3414 Examples of such units are public domain units, and units from the Ada
3418 This is used for a unit that is licensed under the unmodified GPL, and which
3419 therefore cannot be @code{with}'ed by a restricted unit.
3422 This is used for a unit licensed under the GNAT modified GPL that includes
3423 a special exception paragraph that specifically permits the inclusion of
3424 the unit in programs without requiring the entire program to be released
3428 This is used for a unit that is restricted in that it is not permitted to
3429 depend on units that are licensed under the GPL@. Typical examples are
3430 proprietary code that is to be released under more restrictive license
3431 conditions. Note that restricted units are permitted to @code{with} units
3432 which are licensed under the modified GPL (this is the whole point of the
3438 Normally a unit with no @code{License} pragma is considered to have an
3439 unknown license, and no checking is done. However, standard GNAT headers
3440 are recognized, and license information is derived from them as follows.
3444 A GNAT license header starts with a line containing 78 hyphens. The following
3445 comment text is searched for the appearance of any of the following strings.
3447 If the string ``GNU General Public License'' is found, then the unit is assumed
3448 to have GPL license, unless the string ``As a special exception'' follows, in
3449 which case the license is assumed to be modified GPL@.
3451 If one of the strings
3452 ``This specification is adapted from the Ada Semantic Interface'' or
3453 ``This specification is derived from the Ada Reference Manual'' is found
3454 then the unit is assumed to be unrestricted.
3458 These default actions means that a program with a restricted license pragma
3459 will automatically get warnings if a GPL unit is inappropriately
3460 @code{with}'ed. For example, the program:
3462 @smallexample @c ada
3465 procedure Secret_Stuff is
3471 if compiled with pragma @code{License} (@code{Restricted}) in a
3472 @file{gnat.adc} file will generate the warning:
3477 >>> license of withed unit "Sem_Ch3" is incompatible
3479 2. with GNAT.Sockets;
3480 3. procedure Secret_Stuff is
3484 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3485 compiler and is licensed under the
3486 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3487 run time, and is therefore licensed under the modified GPL@.
3489 @node Pragma Link_With
3490 @unnumberedsec Pragma Link_With
3495 @smallexample @c ada
3496 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3500 This pragma is provided for compatibility with certain Ada 83 compilers.
3501 It has exactly the same effect as pragma @code{Linker_Options} except
3502 that spaces occurring within one of the string expressions are treated
3503 as separators. For example, in the following case:
3505 @smallexample @c ada
3506 pragma Link_With ("-labc -ldef");
3510 results in passing the strings @code{-labc} and @code{-ldef} as two
3511 separate arguments to the linker. In addition pragma Link_With allows
3512 multiple arguments, with the same effect as successive pragmas.
3514 @node Pragma Linker_Alias
3515 @unnumberedsec Pragma Linker_Alias
3516 @findex Linker_Alias
3520 @smallexample @c ada
3521 pragma Linker_Alias (
3522 [Entity =>] LOCAL_NAME,
3523 [Target =>] static_string_EXPRESSION);
3527 @var{LOCAL_NAME} must refer to an object that is declared at the library
3528 level. This pragma establishes the given entity as a linker alias for the
3529 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3530 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3531 @var{static_string_EXPRESSION} in the object file, that is to say no space
3532 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3533 to the same address as @var{static_string_EXPRESSION} by the linker.
3535 The actual linker name for the target must be used (e.g.@: the fully
3536 encoded name with qualification in Ada, or the mangled name in C++),
3537 or it must be declared using the C convention with @code{pragma Import}
3538 or @code{pragma Export}.
3540 Not all target machines support this pragma. On some of them it is accepted
3541 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3543 @smallexample @c ada
3544 -- Example of the use of pragma Linker_Alias
3548 pragma Export (C, i);
3550 new_name_for_i : Integer;
3551 pragma Linker_Alias (new_name_for_i, "i");
3555 @node Pragma Linker_Constructor
3556 @unnumberedsec Pragma Linker_Constructor
3557 @findex Linker_Constructor
3561 @smallexample @c ada
3562 pragma Linker_Constructor (procedure_LOCAL_NAME);
3566 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3567 is declared at the library level. A procedure to which this pragma is
3568 applied will be treated as an initialization routine by the linker.
3569 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3570 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3571 of the executable is called (or immediately after the shared library is
3572 loaded if the procedure is linked in a shared library), in particular
3573 before the Ada run-time environment is set up.
3575 Because of these specific contexts, the set of operations such a procedure
3576 can perform is very limited and the type of objects it can manipulate is
3577 essentially restricted to the elementary types. In particular, it must only
3578 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3580 This pragma is used by GNAT to implement auto-initialization of shared Stand
3581 Alone Libraries, which provides a related capability without the restrictions
3582 listed above. Where possible, the use of Stand Alone Libraries is preferable
3583 to the use of this pragma.
3585 @node Pragma Linker_Destructor
3586 @unnumberedsec Pragma Linker_Destructor
3587 @findex Linker_Destructor
3591 @smallexample @c ada
3592 pragma Linker_Destructor (procedure_LOCAL_NAME);
3596 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3597 is declared at the library level. A procedure to which this pragma is
3598 applied will be treated as a finalization routine by the linker.
3599 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3600 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3601 of the executable has exited (or immediately before the shared library
3602 is unloaded if the procedure is linked in a shared library), in particular
3603 after the Ada run-time environment is shut down.
3605 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3606 because of these specific contexts.
3608 @node Pragma Linker_Section
3609 @unnumberedsec Pragma Linker_Section
3610 @findex Linker_Section
3614 @smallexample @c ada
3615 pragma Linker_Section (
3616 [Entity =>] LOCAL_NAME,
3617 [Section =>] static_string_EXPRESSION);
3621 @var{LOCAL_NAME} must refer to an object that is declared at the library
3622 level. This pragma specifies the name of the linker section for the given
3623 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3624 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3625 section of the executable (assuming the linker doesn't rename the section).
3627 The compiler normally places library-level objects in standard sections
3628 depending on their type: procedures and functions generally go in the
3629 @code{.text} section, initialized variables in the @code{.data} section
3630 and uninitialized variables in the @code{.bss} section.
3632 Other, special sections may exist on given target machines to map special
3633 hardware, for example I/O ports or flash memory. This pragma is a means to
3634 defer the final layout of the executable to the linker, thus fully working
3635 at the symbolic level with the compiler.
3637 Some file formats do not support arbitrary sections so not all target
3638 machines support this pragma. The use of this pragma may cause a program
3639 execution to be erroneous if it is used to place an entity into an
3640 inappropriate section (e.g.@: a modified variable into the @code{.text}
3641 section). See also @code{pragma Persistent_BSS}.
3643 @smallexample @c ada
3644 -- Example of the use of pragma Linker_Section
3648 pragma Volatile (Port_A);
3649 pragma Linker_Section (Port_A, ".bss.port_a");
3652 pragma Volatile (Port_B);
3653 pragma Linker_Section (Port_B, ".bss.port_b");
3657 @node Pragma Long_Float
3658 @unnumberedsec Pragma Long_Float
3664 @smallexample @c ada
3665 pragma Long_Float (FLOAT_FORMAT);
3667 FLOAT_FORMAT ::= D_Float | G_Float
3671 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3672 It allows control over the internal representation chosen for the predefined
3673 type @code{Long_Float} and for floating point type representations with
3674 @code{digits} specified in the range 7 through 15.
3675 For further details on this pragma, see the
3676 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3677 this pragma, the standard runtime libraries must be recompiled.
3679 @node Pragma Machine_Attribute
3680 @unnumberedsec Pragma Machine_Attribute
3681 @findex Machine_Attribute
3685 @smallexample @c ada
3686 pragma Machine_Attribute (
3687 [Entity =>] LOCAL_NAME,
3688 [Attribute_Name =>] static_string_EXPRESSION
3689 [, [Info =>] static_EXPRESSION] );
3693 Machine-dependent attributes can be specified for types and/or
3694 declarations. This pragma is semantically equivalent to
3695 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3696 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3697 in GNU C, where @code{@var{attribute_name}} is recognized by the
3698 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3699 specific macro. A string literal for the optional parameter @var{info}
3700 is transformed into an identifier, which may make this pragma unusable
3701 for some attributes. @xref{Target Attributes,, Defining target-specific
3702 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3703 Internals}, further information.
3706 @unnumberedsec Pragma Main
3712 @smallexample @c ada
3714 (MAIN_OPTION [, MAIN_OPTION]);
3717 [Stack_Size =>] static_integer_EXPRESSION
3718 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3719 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3723 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3724 no effect in GNAT, other than being syntax checked.
3726 @node Pragma Main_Storage
3727 @unnumberedsec Pragma Main_Storage
3729 @findex Main_Storage
3733 @smallexample @c ada
3735 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3737 MAIN_STORAGE_OPTION ::=
3738 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3739 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3743 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3744 no effect in GNAT, other than being syntax checked. Note that the pragma
3745 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3747 @node Pragma No_Body
3748 @unnumberedsec Pragma No_Body
3753 @smallexample @c ada
3758 There are a number of cases in which a package spec does not require a body,
3759 and in fact a body is not permitted. GNAT will not permit the spec to be
3760 compiled if there is a body around. The pragma No_Body allows you to provide
3761 a body file, even in a case where no body is allowed. The body file must
3762 contain only comments and a single No_Body pragma. This is recognized by
3763 the compiler as indicating that no body is logically present.
3765 This is particularly useful during maintenance when a package is modified in
3766 such a way that a body needed before is no longer needed. The provision of a
3767 dummy body with a No_Body pragma ensures that there is no interference from
3768 earlier versions of the package body.
3770 @node Pragma No_Return
3771 @unnumberedsec Pragma No_Return
3776 @smallexample @c ada
3777 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3781 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3782 declarations in the current declarative part. A procedure to which this
3783 pragma is applied may not contain any explicit @code{return} statements.
3784 In addition, if the procedure contains any implicit returns from falling
3785 off the end of a statement sequence, then execution of that implicit
3786 return will cause Program_Error to be raised.
3788 One use of this pragma is to identify procedures whose only purpose is to raise
3789 an exception. Another use of this pragma is to suppress incorrect warnings
3790 about missing returns in functions, where the last statement of a function
3791 statement sequence is a call to such a procedure.
3793 Note that in Ada 2005 mode, this pragma is part of the language, and is
3794 identical in effect to the pragma as implemented in Ada 95 mode.
3796 @node Pragma No_Strict_Aliasing
3797 @unnumberedsec Pragma No_Strict_Aliasing
3798 @findex No_Strict_Aliasing
3802 @smallexample @c ada
3803 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3807 @var{type_LOCAL_NAME} must refer to an access type
3808 declaration in the current declarative part. The effect is to inhibit
3809 strict aliasing optimization for the given type. The form with no
3810 arguments is a configuration pragma which applies to all access types
3811 declared in units to which the pragma applies. For a detailed
3812 description of the strict aliasing optimization, and the situations
3813 in which it must be suppressed, see @ref{Optimization and Strict
3814 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3816 This pragma currently has no effects on access to unconstrained array types.
3818 @node Pragma Normalize_Scalars
3819 @unnumberedsec Pragma Normalize_Scalars
3820 @findex Normalize_Scalars
3824 @smallexample @c ada
3825 pragma Normalize_Scalars;
3829 This is a language defined pragma which is fully implemented in GNAT@. The
3830 effect is to cause all scalar objects that are not otherwise initialized
3831 to be initialized. The initial values are implementation dependent and
3835 @item Standard.Character
3837 Objects whose root type is Standard.Character are initialized to
3838 Character'Last unless the subtype range excludes NUL (in which case
3839 NUL is used). This choice will always generate an invalid value if
3842 @item Standard.Wide_Character
3844 Objects whose root type is Standard.Wide_Character are initialized to
3845 Wide_Character'Last unless the subtype range excludes NUL (in which case
3846 NUL is used). This choice will always generate an invalid value if
3849 @item Standard.Wide_Wide_Character
3851 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3852 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3853 which case NUL is used). This choice will always generate an invalid value if
3858 Objects of an integer type are treated differently depending on whether
3859 negative values are present in the subtype. If no negative values are
3860 present, then all one bits is used as the initial value except in the
3861 special case where zero is excluded from the subtype, in which case
3862 all zero bits are used. This choice will always generate an invalid
3863 value if one exists.
3865 For subtypes with negative values present, the largest negative number
3866 is used, except in the unusual case where this largest negative number
3867 is in the subtype, and the largest positive number is not, in which case
3868 the largest positive value is used. This choice will always generate
3869 an invalid value if one exists.
3871 @item Floating-Point Types
3872 Objects of all floating-point types are initialized to all 1-bits. For
3873 standard IEEE format, this corresponds to a NaN (not a number) which is
3874 indeed an invalid value.
3876 @item Fixed-Point Types
3877 Objects of all fixed-point types are treated as described above for integers,
3878 with the rules applying to the underlying integer value used to represent
3879 the fixed-point value.
3882 Objects of a modular type are initialized to all one bits, except in
3883 the special case where zero is excluded from the subtype, in which
3884 case all zero bits are used. This choice will always generate an
3885 invalid value if one exists.
3887 @item Enumeration types
3888 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3889 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3890 whose Pos value is zero, in which case a code of zero is used. This choice
3891 will always generate an invalid value if one exists.
3895 @node Pragma Obsolescent
3896 @unnumberedsec Pragma Obsolescent
3901 @smallexample @c ada
3904 pragma Obsolescent (
3905 [Message =>] static_string_EXPRESSION
3906 [,[Version =>] Ada_05]]);
3908 pragma Obsolescent (
3910 [,[Message =>] static_string_EXPRESSION
3911 [,[Version =>] Ada_05]] );
3915 This pragma can occur immediately following a declaration of an entity,
3916 including the case of a record component. If no Entity argument is present,
3917 then this declaration is the one to which the pragma applies. If an Entity
3918 parameter is present, it must either match the name of the entity in this
3919 declaration, or alternatively, the pragma can immediately follow an enumeration
3920 type declaration, where the Entity argument names one of the enumeration
3923 This pragma is used to indicate that the named entity
3924 is considered obsolescent and should not be used. Typically this is
3925 used when an API must be modified by eventually removing or modifying
3926 existing subprograms or other entities. The pragma can be used at an
3927 intermediate stage when the entity is still present, but will be
3930 The effect of this pragma is to output a warning message on a reference to
3931 an entity thus marked that the subprogram is obsolescent if the appropriate
3932 warning option in the compiler is activated. If the Message parameter is
3933 present, then a second warning message is given containing this text. In
3934 addition, a reference to the entity is considered to be a violation of pragma
3935 Restrictions (No_Obsolescent_Features).
3937 This pragma can also be used as a program unit pragma for a package,
3938 in which case the entity name is the name of the package, and the
3939 pragma indicates that the entire package is considered
3940 obsolescent. In this case a client @code{with}'ing such a package
3941 violates the restriction, and the @code{with} statement is
3942 flagged with warnings if the warning option is set.
3944 If the Version parameter is present (which must be exactly
3945 the identifier Ada_05, no other argument is allowed), then the
3946 indication of obsolescence applies only when compiling in Ada 2005
3947 mode. This is primarily intended for dealing with the situations
3948 in the predefined library where subprograms or packages
3949 have become defined as obsolescent in Ada 2005
3950 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3952 The following examples show typical uses of this pragma:
3954 @smallexample @c ada
3956 pragma Obsolescent (p, Message => "use pp instead of p");
3961 pragma Obsolescent ("use q2new instead");
3963 type R is new integer;
3966 Message => "use RR in Ada 2005",
3976 type E is (a, bc, 'd', quack);
3977 pragma Obsolescent (Entity => bc)
3978 pragma Obsolescent (Entity => 'd')
3981 (a, b : character) return character;
3982 pragma Obsolescent (Entity => "+");
3987 Note that, as for all pragmas, if you use a pragma argument identifier,
3988 then all subsequent parameters must also use a pragma argument identifier.
3989 So if you specify "Entity =>" for the Entity argument, and a Message
3990 argument is present, it must be preceded by "Message =>".
3992 @node Pragma Optimize_Alignment
3993 @unnumberedsec Pragma Optimize_Alignment
3994 @findex Optimize_Alignment
3995 @cindex Alignment, default settings
3999 @smallexample @c ada
4000 pragma Optimize_Alignment (TIME | SPACE | OFF);
4004 This is a configuration pragma which affects the choice of default alignments
4005 for types where no alignment is explicitly specified. There is a time/space
4006 trade-off in the selection of these values. Large alignments result in more
4007 efficient code, at the expense of larger data space, since sizes have to be
4008 increased to match these alignments. Smaller alignments save space, but the
4009 access code is slower. The normal choice of default alignments (which is what
4010 you get if you do not use this pragma, or if you use an argument of OFF),
4011 tries to balance these two requirements.
4013 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4014 First any packed record is given an alignment of 1. Second, if a size is given
4015 for the type, then the alignment is chosen to avoid increasing this size. For
4018 @smallexample @c ada
4028 In the default mode, this type gets an alignment of 4, so that access to the
4029 Integer field X are efficient. But this means that objects of the type end up
4030 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4031 allowed to be bigger than the size of the type, but it can waste space if for
4032 example fields of type R appear in an enclosing record. If the above type is
4033 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4035 However, there is one case in which SPACE is ignored. If a variable length
4036 record (that is a discriminated record with a component which is an array
4037 whose length depends on a discriminant), has a pragam pack, then it is not
4038 in general possible to set the alignment of such a record to one, so the
4039 pragma is ignored in this case (with a warning).
4041 Specifying TIME causes larger default alignments to be chosen in the case of
4042 small types with sizes that are not a power of 2. For example, consider:
4044 @smallexample @c ada
4056 The default alignment for this record is normally 1, but if this type is
4057 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4058 to 4, which wastes space for objects of the type, since they are now 4 bytes
4059 long, but results in more efficient access when the whole record is referenced.
4061 As noted above, this is a configuration pragma, and there is a requirement
4062 that all units in a partition be compiled with a consistent setting of the
4063 optimization setting. This would normally be achieved by use of a configuration
4064 pragma file containing the appropriate setting. The exception to this rule is
4065 that units with an explicit configuration pragma in the same file as the source
4066 unit are excluded from the consistency check, as are all predefined units. The
4067 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4068 pragma appears at the start of the file.
4070 @node Pragma Ordered
4071 @unnumberedsec Pragma Ordered
4073 @findex pragma @code{Ordered}
4077 @smallexample @c ada
4078 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4082 Most enumeration types are from a conceptual point of view unordered.
4083 For example, consider:
4085 @smallexample @c ada
4086 type Color is (Red, Blue, Green, Yellow);
4090 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4091 but really these relations make no sense; the enumeration type merely
4092 specifies a set of possible colors, and the order is unimportant.
4094 For unordered enumeration types, it is generally a good idea if
4095 clients avoid comparisons (other than equality or inequality) and
4096 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4097 other than the unit where the type is declared, its body, and its subunits.)
4098 For example, if code buried in some client says:
4100 @smallexample @c ada
4101 if Current_Color < Yellow then ...
4102 if Current_Color in Blue .. Green then ...
4106 then the client code is relying on the order, which is undesirable.
4107 It makes the code hard to read and creates maintenance difficulties if
4108 entries have to be added to the enumeration type. Instead,
4109 the code in the client should list the possibilities, or an
4110 appropriate subtype should be declared in the unit that declares
4111 the original enumeration type. E.g., the following subtype could
4112 be declared along with the type @code{Color}:
4114 @smallexample @c ada
4115 subtype RBG is Color range Red .. Green;
4119 and then the client could write:
4121 @smallexample @c ada
4122 if Current_Color in RBG then ...
4123 if Current_Color = Blue or Current_Color = Green then ...
4127 However, some enumeration types are legitimately ordered from a conceptual
4128 point of view. For example, if you declare:
4130 @smallexample @c ada
4131 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4135 then the ordering imposed by the language is reasonable, and
4136 clients can depend on it, writing for example:
4138 @smallexample @c ada
4139 if D in Mon .. Fri then ...
4144 The pragma @option{Ordered} is provided to mark enumeration types that
4145 are conceptually ordered, alerting the reader that clients may depend
4146 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4147 rather than one to mark them as unordered, since in our experience,
4148 the great majority of enumeration types are conceptually unordered.
4150 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4151 and @code{Wide_Wide_Character}
4152 are considered to be ordered types, so each is declared with a
4153 pragma @code{Ordered} in package @code{Standard}.
4155 Normally pragma @code{Ordered} serves only as documentation and a guide for
4156 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4157 requests warnings for inappropriate uses (comparisons and explicit
4158 subranges) for unordered types. If this switch is used, then any
4159 enumeration type not marked with pragma @code{Ordered} will be considered
4160 as unordered, and will generate warnings for inappropriate uses.
4162 For additional information please refer to the description of the
4163 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4165 @node Pragma Overflow_Checks
4166 @unnumberedsec Pragma Overflow_Checks
4167 @findex Overflow checks
4168 @findex pragma @code{Overflow_Checks}
4172 @smallexample @c ada
4173 pragma Overflow_Checks
4175 [,[Assertions =>] MODE]);
4177 MODE ::= SUPPRESSED | CHECKED | MINIMIZED | ELIMINATED
4181 This pragma sets the current overflow mode to the given mode. For details
4182 of the meaning of these modes, please refer to the
4183 ``Overflow Check Handling in GNAT'' appendix in the
4184 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4185 the given mode applies to all expressions. If both parameters are present,
4186 the @code{General} mode applies to expressions outside assertions, and
4187 the @code{Eliminated} mode applies to expressions within assertions.
4189 The case of the @code{MODE} parameter is ignored,
4190 so @code{MINIMIZED}, @code{Minimized} and
4191 @code{minimized} all have the same effect.
4193 The @code{Overflow_Checks} pragma has the same scoping and placement
4194 rules as pragma @code{Suppress}, so it can occur either as a
4195 configuration pragma, specifying a default for the whole
4196 program, or in a declarative scope, where it applies to the
4197 remaining declarations and statements in that scope.
4199 The pragma @code{Suppress (Overflow_Check)} sets mode
4201 @smallexample @c ada
4202 General => Suppressed
4206 suppressing all overflow checking within and outside
4209 The pragam @code{Unsuppress (Overflow_Check)} sets mode
4211 @smallexample @c ada
4216 which causes overflow checking of all intermediate overflows.
4217 This applies both inside and outside assertions.
4220 @node Pragma Passive
4221 @unnumberedsec Pragma Passive
4226 @smallexample @c ada
4227 pragma Passive [(Semaphore | No)];
4231 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
4232 compatibility with DEC Ada 83 implementations, where it is used within a
4233 task definition to request that a task be made passive. If the argument
4234 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4235 treats the pragma as an assertion that the containing task is passive
4236 and that optimization of context switch with this task is permitted and
4237 desired. If the argument @code{No} is present, the task must not be
4238 optimized. GNAT does not attempt to optimize any tasks in this manner
4239 (since protected objects are available in place of passive tasks).
4241 @node Pragma Persistent_BSS
4242 @unnumberedsec Pragma Persistent_BSS
4243 @findex Persistent_BSS
4247 @smallexample @c ada
4248 pragma Persistent_BSS [(LOCAL_NAME)]
4252 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4253 section. On some targets the linker and loader provide for special
4254 treatment of this section, allowing a program to be reloaded without
4255 affecting the contents of this data (hence the name persistent).
4257 There are two forms of usage. If an argument is given, it must be the
4258 local name of a library level object, with no explicit initialization
4259 and whose type is potentially persistent. If no argument is given, then
4260 the pragma is a configuration pragma, and applies to all library level
4261 objects with no explicit initialization of potentially persistent types.
4263 A potentially persistent type is a scalar type, or a non-tagged,
4264 non-discriminated record, all of whose components have no explicit
4265 initialization and are themselves of a potentially persistent type,
4266 or an array, all of whose constraints are static, and whose component
4267 type is potentially persistent.
4269 If this pragma is used on a target where this feature is not supported,
4270 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4272 @node Pragma Polling
4273 @unnumberedsec Pragma Polling
4278 @smallexample @c ada
4279 pragma Polling (ON | OFF);
4283 This pragma controls the generation of polling code. This is normally off.
4284 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4285 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
4286 runtime library, and can be found in file @file{a-excpol.adb}.
4288 Pragma @code{Polling} can appear as a configuration pragma (for example it
4289 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4290 can be used in the statement or declaration sequence to control polling
4293 A call to the polling routine is generated at the start of every loop and
4294 at the start of every subprogram call. This guarantees that the @code{Poll}
4295 routine is called frequently, and places an upper bound (determined by
4296 the complexity of the code) on the period between two @code{Poll} calls.
4298 The primary purpose of the polling interface is to enable asynchronous
4299 aborts on targets that cannot otherwise support it (for example Windows
4300 NT), but it may be used for any other purpose requiring periodic polling.
4301 The standard version is null, and can be replaced by a user program. This
4302 will require re-compilation of the @code{Ada.Exceptions} package that can
4303 be found in files @file{a-except.ads} and @file{a-except.adb}.
4305 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
4306 distribution) is used to enable the asynchronous abort capability on
4307 targets that do not normally support the capability. The version of
4308 @code{Poll} in this file makes a call to the appropriate runtime routine
4309 to test for an abort condition.
4311 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4312 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4315 @node Pragma Postcondition
4316 @unnumberedsec Pragma Postcondition
4317 @cindex Postconditions
4318 @cindex Checks, postconditions
4319 @findex Postconditions
4323 @smallexample @c ada
4324 pragma Postcondition (
4325 [Check =>] Boolean_Expression
4326 [,[Message =>] String_Expression]);
4330 The @code{Postcondition} pragma allows specification of automatic
4331 postcondition checks for subprograms. These checks are similar to
4332 assertions, but are automatically inserted just prior to the return
4333 statements of the subprogram with which they are associated (including
4334 implicit returns at the end of procedure bodies and associated
4335 exception handlers).
4337 In addition, the boolean expression which is the condition which
4338 must be true may contain references to function'Result in the case
4339 of a function to refer to the returned value.
4341 @code{Postcondition} pragmas may appear either immediately following the
4342 (separate) declaration of a subprogram, or at the start of the
4343 declarations of a subprogram body. Only other pragmas may intervene
4344 (that is appear between the subprogram declaration and its
4345 postconditions, or appear before the postcondition in the
4346 declaration sequence in a subprogram body). In the case of a
4347 postcondition appearing after a subprogram declaration, the
4348 formal arguments of the subprogram are visible, and can be
4349 referenced in the postcondition expressions.
4351 The postconditions are collected and automatically tested just
4352 before any return (implicit or explicit) in the subprogram body.
4353 A postcondition is only recognized if postconditions are active
4354 at the time the pragma is encountered. The compiler switch @option{gnata}
4355 turns on all postconditions by default, and pragma @code{Check_Policy}
4356 with an identifier of @code{Postcondition} can also be used to
4357 control whether postconditions are active.
4359 The general approach is that postconditions are placed in the spec
4360 if they represent functional aspects which make sense to the client.
4361 For example we might have:
4363 @smallexample @c ada
4364 function Direction return Integer;
4365 pragma Postcondition
4366 (Direction'Result = +1
4368 Direction'Result = -1);
4372 which serves to document that the result must be +1 or -1, and
4373 will test that this is the case at run time if postcondition
4376 Postconditions within the subprogram body can be used to
4377 check that some internal aspect of the implementation,
4378 not visible to the client, is operating as expected.
4379 For instance if a square root routine keeps an internal
4380 counter of the number of times it is called, then we
4381 might have the following postcondition:
4383 @smallexample @c ada
4384 Sqrt_Calls : Natural := 0;
4386 function Sqrt (Arg : Float) return Float is
4387 pragma Postcondition
4388 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4394 As this example, shows, the use of the @code{Old} attribute
4395 is often useful in postconditions to refer to the state on
4396 entry to the subprogram.
4398 Note that postconditions are only checked on normal returns
4399 from the subprogram. If an abnormal return results from
4400 raising an exception, then the postconditions are not checked.
4402 If a postcondition fails, then the exception
4403 @code{System.Assertions.Assert_Failure} is raised. If
4404 a message argument was supplied, then the given string
4405 will be used as the exception message. If no message
4406 argument was supplied, then the default message has
4407 the form "Postcondition failed at file:line". The
4408 exception is raised in the context of the subprogram
4409 body, so it is possible to catch postcondition failures
4410 within the subprogram body itself.
4412 Within a package spec, normal visibility rules
4413 in Ada would prevent forward references within a
4414 postcondition pragma to functions defined later in
4415 the same package. This would introduce undesirable
4416 ordering constraints. To avoid this problem, all
4417 postcondition pragmas are analyzed at the end of
4418 the package spec, allowing forward references.
4420 The following example shows that this even allows
4421 mutually recursive postconditions as in:
4423 @smallexample @c ada
4424 package Parity_Functions is
4425 function Odd (X : Natural) return Boolean;
4426 pragma Postcondition
4430 (x /= 0 and then Even (X - 1))));
4432 function Even (X : Natural) return Boolean;
4433 pragma Postcondition
4437 (x /= 1 and then Odd (X - 1))));
4439 end Parity_Functions;
4443 There are no restrictions on the complexity or form of
4444 conditions used within @code{Postcondition} pragmas.
4445 The following example shows that it is even possible
4446 to verify performance behavior.
4448 @smallexample @c ada
4451 Performance : constant Float;
4452 -- Performance constant set by implementation
4453 -- to match target architecture behavior.
4455 procedure Treesort (Arg : String);
4456 -- Sorts characters of argument using N*logN sort
4457 pragma Postcondition
4458 (Float (Clock - Clock'Old) <=
4459 Float (Arg'Length) *
4460 log (Float (Arg'Length)) *
4466 Note: postcondition pragmas associated with subprograms that are
4467 marked as Inline_Always, or those marked as Inline with front-end
4468 inlining (-gnatN option set) are accepted and legality-checked
4469 by the compiler, but are ignored at run-time even if postcondition
4470 checking is enabled.
4472 @node Pragma Precondition
4473 @unnumberedsec Pragma Precondition
4474 @cindex Preconditions
4475 @cindex Checks, preconditions
4476 @findex Preconditions
4480 @smallexample @c ada
4481 pragma Precondition (
4482 [Check =>] Boolean_Expression
4483 [,[Message =>] String_Expression]);
4487 The @code{Precondition} pragma is similar to @code{Postcondition}
4488 except that the corresponding checks take place immediately upon
4489 entry to the subprogram, and if a precondition fails, the exception
4490 is raised in the context of the caller, and the attribute 'Result
4491 cannot be used within the precondition expression.
4493 Otherwise, the placement and visibility rules are identical to those
4494 described for postconditions. The following is an example of use
4495 within a package spec:
4497 @smallexample @c ada
4498 package Math_Functions is
4500 function Sqrt (Arg : Float) return Float;
4501 pragma Precondition (Arg >= 0.0)
4507 @code{Precondition} pragmas may appear either immediately following the
4508 (separate) declaration of a subprogram, or at the start of the
4509 declarations of a subprogram body. Only other pragmas may intervene
4510 (that is appear between the subprogram declaration and its
4511 postconditions, or appear before the postcondition in the
4512 declaration sequence in a subprogram body).
4514 Note: postcondition pragmas associated with subprograms that are
4515 marked as Inline_Always, or those marked as Inline with front-end
4516 inlining (-gnatN option set) are accepted and legality-checked
4517 by the compiler, but are ignored at run-time even if postcondition
4518 checking is enabled.
4520 @node Pragma Profile (Ravenscar)
4521 @unnumberedsec Pragma Profile (Ravenscar)
4526 @smallexample @c ada
4527 pragma Profile (Ravenscar);
4531 A configuration pragma that establishes the following set of configuration
4535 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4536 [RM D.2.2] Tasks are dispatched following a preemptive
4537 priority-ordered scheduling policy.
4539 @item Locking_Policy (Ceiling_Locking)
4540 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4541 the ceiling priority of the corresponding protected object.
4543 @c @item Detect_Blocking
4544 @c This pragma forces the detection of potentially blocking operations within a
4545 @c protected operation, and to raise Program_Error if that happens.
4549 plus the following set of restrictions:
4552 @item Max_Entry_Queue_Length => 1
4553 No task can be queued on a protected entry.
4554 @item Max_Protected_Entries => 1
4555 @item Max_Task_Entries => 0
4556 No rendezvous statements are allowed.
4557 @item No_Abort_Statements
4558 @item No_Dynamic_Attachment
4559 @item No_Dynamic_Priorities
4560 @item No_Implicit_Heap_Allocations
4561 @item No_Local_Protected_Objects
4562 @item No_Local_Timing_Events
4563 @item No_Protected_Type_Allocators
4564 @item No_Relative_Delay
4565 @item No_Requeue_Statements
4566 @item No_Select_Statements
4567 @item No_Specific_Termination_Handlers
4568 @item No_Task_Allocators
4569 @item No_Task_Hierarchy
4570 @item No_Task_Termination
4571 @item Simple_Barriers
4575 The Ravenscar profile also includes the following restrictions that specify
4576 that there are no semantic dependences on the corresponding predefined
4580 @item No_Dependence => Ada.Asynchronous_Task_Control
4581 @item No_Dependence => Ada.Calendar
4582 @item No_Dependence => Ada.Execution_Time.Group_Budget
4583 @item No_Dependence => Ada.Execution_Time.Timers
4584 @item No_Dependence => Ada.Task_Attributes
4585 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4590 This set of configuration pragmas and restrictions correspond to the
4591 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4592 published by the @cite{International Real-Time Ada Workshop}, 1997,
4593 and whose most recent description is available at
4594 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4596 The original definition of the profile was revised at subsequent IRTAW
4597 meetings. It has been included in the ISO
4598 @cite{Guide for the Use of the Ada Programming Language in High
4599 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4600 the next revision of the standard. The formal definition given by
4601 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4602 AI-305) available at
4603 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4604 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4606 The above set is a superset of the restrictions provided by pragma
4607 @code{Profile (Restricted)}, it includes six additional restrictions
4608 (@code{Simple_Barriers}, @code{No_Select_Statements},
4609 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4610 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4611 that pragma @code{Profile (Ravenscar)}, like the pragma
4612 @code{Profile (Restricted)},
4613 automatically causes the use of a simplified,
4614 more efficient version of the tasking run-time system.
4616 @node Pragma Profile (Restricted)
4617 @unnumberedsec Pragma Profile (Restricted)
4618 @findex Restricted Run Time
4622 @smallexample @c ada
4623 pragma Profile (Restricted);
4627 A configuration pragma that establishes the following set of restrictions:
4630 @item No_Abort_Statements
4631 @item No_Entry_Queue
4632 @item No_Task_Hierarchy
4633 @item No_Task_Allocators
4634 @item No_Dynamic_Priorities
4635 @item No_Terminate_Alternatives
4636 @item No_Dynamic_Attachment
4637 @item No_Protected_Type_Allocators
4638 @item No_Local_Protected_Objects
4639 @item No_Requeue_Statements
4640 @item No_Task_Attributes_Package
4641 @item Max_Asynchronous_Select_Nesting = 0
4642 @item Max_Task_Entries = 0
4643 @item Max_Protected_Entries = 1
4644 @item Max_Select_Alternatives = 0
4648 This set of restrictions causes the automatic selection of a simplified
4649 version of the run time that provides improved performance for the
4650 limited set of tasking functionality permitted by this set of restrictions.
4652 @node Pragma Psect_Object
4653 @unnumberedsec Pragma Psect_Object
4654 @findex Psect_Object
4658 @smallexample @c ada
4659 pragma Psect_Object (
4660 [Internal =>] LOCAL_NAME,
4661 [, [External =>] EXTERNAL_SYMBOL]
4662 [, [Size =>] EXTERNAL_SYMBOL]);
4666 | static_string_EXPRESSION
4670 This pragma is identical in effect to pragma @code{Common_Object}.
4672 @node Pragma Pure_Function
4673 @unnumberedsec Pragma Pure_Function
4674 @findex Pure_Function
4678 @smallexample @c ada
4679 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4683 This pragma appears in the same declarative part as a function
4684 declaration (or a set of function declarations if more than one
4685 overloaded declaration exists, in which case the pragma applies
4686 to all entities). It specifies that the function @code{Entity} is
4687 to be considered pure for the purposes of code generation. This means
4688 that the compiler can assume that there are no side effects, and
4689 in particular that two calls with identical arguments produce the
4690 same result. It also means that the function can be used in an
4693 Note that, quite deliberately, there are no static checks to try
4694 to ensure that this promise is met, so @code{Pure_Function} can be used
4695 with functions that are conceptually pure, even if they do modify
4696 global variables. For example, a square root function that is
4697 instrumented to count the number of times it is called is still
4698 conceptually pure, and can still be optimized, even though it
4699 modifies a global variable (the count). Memo functions are another
4700 example (where a table of previous calls is kept and consulted to
4701 avoid re-computation).
4703 Note also that the normal rules excluding optimization of subprograms
4704 in pure units (when parameter types are descended from System.Address,
4705 or when the full view of a parameter type is limited), do not apply
4706 for the Pure_Function case. If you explicitly specify Pure_Function,
4707 the compiler may optimize away calls with identical arguments, and
4708 if that results in unexpected behavior, the proper action is not to
4709 use the pragma for subprograms that are not (conceptually) pure.
4712 Note: Most functions in a @code{Pure} package are automatically pure, and
4713 there is no need to use pragma @code{Pure_Function} for such functions. One
4714 exception is any function that has at least one formal of type
4715 @code{System.Address} or a type derived from it. Such functions are not
4716 considered pure by default, since the compiler assumes that the
4717 @code{Address} parameter may be functioning as a pointer and that the
4718 referenced data may change even if the address value does not.
4719 Similarly, imported functions are not considered to be pure by default,
4720 since there is no way of checking that they are in fact pure. The use
4721 of pragma @code{Pure_Function} for such a function will override these default
4722 assumption, and cause the compiler to treat a designated subprogram as pure
4725 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4726 applies to the underlying renamed function. This can be used to
4727 disambiguate cases of overloading where some but not all functions
4728 in a set of overloaded functions are to be designated as pure.
4730 If pragma @code{Pure_Function} is applied to a library level function, the
4731 function is also considered pure from an optimization point of view, but the
4732 unit is not a Pure unit in the categorization sense. So for example, a function
4733 thus marked is free to @code{with} non-pure units.
4735 @node Pragma Remote_Access_Type
4736 @unnumberedsec Pragma Remote_Access_Type
4737 @findex Remote_Access_Type
4741 @smallexample @c ada
4742 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
4746 This pragma appears in the formal part of a generic declaration.
4747 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
4748 the use of a remote access to class-wide type as actual for a formal
4751 When this pragma applies to a formal access type @code{Entity}, that
4752 type is treated as a remote access to class-wide type in the generic.
4753 It must be a formal general access type, and its designated type must
4754 be the class-wide type of a formal tagged limited private type from the
4755 same generic declaration.
4757 In the generic unit, the formal type is subject to all restrictions
4758 pertaining to remote access to class-wide types. At instantiation, the
4759 actual type must be a remote access to class-wide type.
4761 @node Pragma Restriction_Warnings
4762 @unnumberedsec Pragma Restriction_Warnings
4763 @findex Restriction_Warnings
4767 @smallexample @c ada
4768 pragma Restriction_Warnings
4769 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4773 This pragma allows a series of restriction identifiers to be
4774 specified (the list of allowed identifiers is the same as for
4775 pragma @code{Restrictions}). For each of these identifiers
4776 the compiler checks for violations of the restriction, but
4777 generates a warning message rather than an error message
4778 if the restriction is violated.
4781 @unnumberedsec Pragma Shared
4785 This pragma is provided for compatibility with Ada 83. The syntax and
4786 semantics are identical to pragma Atomic.
4788 @node Pragma Short_Circuit_And_Or
4789 @unnumberedsec Pragma Short_Circuit_And_Or
4790 @findex Short_Circuit_And_Or
4793 This configuration pragma causes any occurrence of the AND operator applied to
4794 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4795 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4796 may be useful in the context of certification protocols requiring the use of
4797 short-circuited logical operators. If this configuration pragma occurs locally
4798 within the file being compiled, it applies only to the file being compiled.
4799 There is no requirement that all units in a partition use this option.
4801 @node Pragma Short_Descriptors
4802 @unnumberedsec Pragma Short_Descriptors
4803 @findex Short_Descriptors
4807 @smallexample @c ada
4808 pragma Short_Descriptors
4812 In VMS versions of the compiler, this configuration pragma causes all
4813 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4814 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4815 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4818 @node Pragma Simple_Storage_Pool_Type
4819 @unnumberedsec Pragma Simple_Storage_Pool_Type
4820 @findex Simple_Storage_Pool_Type
4821 @cindex Storage pool, simple
4822 @cindex Simple storage pool
4826 @smallexample @c ada
4827 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
4831 A type can be established as a ``simple storage pool type'' by applying
4832 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
4833 A type named in the pragma must be a library-level immutably limited record
4834 type or limited tagged type declared immediately within a package declaration.
4835 The type can also be a limited private type whose full type is allowed as
4836 a simple storage pool type.
4838 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
4839 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
4840 are subtype conformant with the following subprogram declarations:
4842 @smallexample @c ada
4845 Storage_Address : out System.Address;
4846 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4847 Alignment : System.Storage_Elements.Storage_Count);
4849 procedure Deallocate
4851 Storage_Address : System.Address;
4852 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4853 Alignment : System.Storage_Elements.Storage_Count);
4855 function Storage_Size (Pool : SSP)
4856 return System.Storage_Elements.Storage_Count;
4860 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
4861 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
4862 applying an unchecked deallocation has no effect other than to set its actual
4863 parameter to null. If @code{Storage_Size} is not declared, then the
4864 @code{Storage_Size} attribute applied to an access type associated with
4865 a pool object of type SSP returns zero. Additional operations can be declared
4866 for a simple storage pool type (such as for supporting a mark/release
4867 storage-management discipline).
4869 An object of a simple storage pool type can be associated with an access
4870 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
4872 @smallexample @c ada
4874 My_Pool : My_Simple_Storage_Pool_Type;
4876 type Acc is access My_Data_Type;
4878 for Acc'Simple_Storage_Pool use My_Pool;
4883 See attribute @code{Simple_Storage_Pool} for further details.
4885 @node Pragma Source_File_Name
4886 @unnumberedsec Pragma Source_File_Name
4887 @findex Source_File_Name
4891 @smallexample @c ada
4892 pragma Source_File_Name (
4893 [Unit_Name =>] unit_NAME,
4894 Spec_File_Name => STRING_LITERAL,
4895 [Index => INTEGER_LITERAL]);
4897 pragma Source_File_Name (
4898 [Unit_Name =>] unit_NAME,
4899 Body_File_Name => STRING_LITERAL,
4900 [Index => INTEGER_LITERAL]);
4904 Use this to override the normal naming convention. It is a configuration
4905 pragma, and so has the usual applicability of configuration pragmas
4906 (i.e.@: it applies to either an entire partition, or to all units in a
4907 compilation, or to a single unit, depending on how it is used.
4908 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4909 the second argument is required, and indicates whether this is the file
4910 name for the spec or for the body.
4912 The optional Index argument should be used when a file contains multiple
4913 units, and when you do not want to use @code{gnatchop} to separate then
4914 into multiple files (which is the recommended procedure to limit the
4915 number of recompilations that are needed when some sources change).
4916 For instance, if the source file @file{source.ada} contains
4918 @smallexample @c ada
4930 you could use the following configuration pragmas:
4932 @smallexample @c ada
4933 pragma Source_File_Name
4934 (B, Spec_File_Name => "source.ada", Index => 1);
4935 pragma Source_File_Name
4936 (A, Body_File_Name => "source.ada", Index => 2);
4939 Note that the @code{gnatname} utility can also be used to generate those
4940 configuration pragmas.
4942 Another form of the @code{Source_File_Name} pragma allows
4943 the specification of patterns defining alternative file naming schemes
4944 to apply to all files.
4946 @smallexample @c ada
4947 pragma Source_File_Name
4948 ( [Spec_File_Name =>] STRING_LITERAL
4949 [,[Casing =>] CASING_SPEC]
4950 [,[Dot_Replacement =>] STRING_LITERAL]);
4952 pragma Source_File_Name
4953 ( [Body_File_Name =>] STRING_LITERAL
4954 [,[Casing =>] CASING_SPEC]
4955 [,[Dot_Replacement =>] STRING_LITERAL]);
4957 pragma Source_File_Name
4958 ( [Subunit_File_Name =>] STRING_LITERAL
4959 [,[Casing =>] CASING_SPEC]
4960 [,[Dot_Replacement =>] STRING_LITERAL]);
4962 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4966 The first argument is a pattern that contains a single asterisk indicating
4967 the point at which the unit name is to be inserted in the pattern string
4968 to form the file name. The second argument is optional. If present it
4969 specifies the casing of the unit name in the resulting file name string.
4970 The default is lower case. Finally the third argument allows for systematic
4971 replacement of any dots in the unit name by the specified string literal.
4973 Note that Source_File_Name pragmas should not be used if you are using
4974 project files. The reason for this rule is that the project manager is not
4975 aware of these pragmas, and so other tools that use the projet file would not
4976 be aware of the intended naming conventions. If you are using project files,
4977 file naming is controlled by Source_File_Name_Project pragmas, which are
4978 usually supplied automatically by the project manager. A pragma
4979 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
4981 For more details on the use of the @code{Source_File_Name} pragma,
4982 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4983 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4986 @node Pragma Source_File_Name_Project
4987 @unnumberedsec Pragma Source_File_Name_Project
4988 @findex Source_File_Name_Project
4991 This pragma has the same syntax and semantics as pragma Source_File_Name.
4992 It is only allowed as a stand alone configuration pragma.
4993 It cannot appear after a @ref{Pragma Source_File_Name}, and
4994 most importantly, once pragma Source_File_Name_Project appears,
4995 no further Source_File_Name pragmas are allowed.
4997 The intention is that Source_File_Name_Project pragmas are always
4998 generated by the Project Manager in a manner consistent with the naming
4999 specified in a project file, and when naming is controlled in this manner,
5000 it is not permissible to attempt to modify this naming scheme using
5001 Source_File_Name or Source_File_Name_Project pragmas (which would not be
5002 known to the project manager).
5004 @node Pragma Source_Reference
5005 @unnumberedsec Pragma Source_Reference
5006 @findex Source_Reference
5010 @smallexample @c ada
5011 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
5015 This pragma must appear as the first line of a source file.
5016 @var{integer_literal} is the logical line number of the line following
5017 the pragma line (for use in error messages and debugging
5018 information). @var{string_literal} is a static string constant that
5019 specifies the file name to be used in error messages and debugging
5020 information. This is most notably used for the output of @code{gnatchop}
5021 with the @option{-r} switch, to make sure that the original unchopped
5022 source file is the one referred to.
5024 The second argument must be a string literal, it cannot be a static
5025 string expression other than a string literal. This is because its value
5026 is needed for error messages issued by all phases of the compiler.
5028 @node Pragma Static_Elaboration_Desired
5029 @unnumberedsec Pragma Static_Elaboration_Desired
5030 @findex Static_Elaboration_Desired
5034 @smallexample @c ada
5035 pragma Static_Elaboration_Desired;
5039 This pragma is used to indicate that the compiler should attempt to initialize
5040 statically the objects declared in the library unit to which the pragma applies,
5041 when these objects are initialized (explicitly or implicitly) by an aggregate.
5042 In the absence of this pragma, aggregates in object declarations are expanded
5043 into assignments and loops, even when the aggregate components are static
5044 constants. When the aggregate is present the compiler builds a static expression
5045 that requires no run-time code, so that the initialized object can be placed in
5046 read-only data space. If the components are not static, or the aggregate has
5047 more that 100 components, the compiler emits a warning that the pragma cannot
5048 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
5049 construction of larger aggregates with static components that include an others
5052 @node Pragma Stream_Convert
5053 @unnumberedsec Pragma Stream_Convert
5054 @findex Stream_Convert
5058 @smallexample @c ada
5059 pragma Stream_Convert (
5060 [Entity =>] type_LOCAL_NAME,
5061 [Read =>] function_NAME,
5062 [Write =>] function_NAME);
5066 This pragma provides an efficient way of providing stream functions for
5067 types defined in packages. Not only is it simpler to use than declaring
5068 the necessary functions with attribute representation clauses, but more
5069 significantly, it allows the declaration to made in such a way that the
5070 stream packages are not loaded unless they are needed. The use of
5071 the Stream_Convert pragma adds no overhead at all, unless the stream
5072 attributes are actually used on the designated type.
5074 The first argument specifies the type for which stream functions are
5075 provided. The second parameter provides a function used to read values
5076 of this type. It must name a function whose argument type may be any
5077 subtype, and whose returned type must be the type given as the first
5078 argument to the pragma.
5080 The meaning of the @var{Read}
5081 parameter is that if a stream attribute directly
5082 or indirectly specifies reading of the type given as the first parameter,
5083 then a value of the type given as the argument to the Read function is
5084 read from the stream, and then the Read function is used to convert this
5085 to the required target type.
5087 Similarly the @var{Write} parameter specifies how to treat write attributes
5088 that directly or indirectly apply to the type given as the first parameter.
5089 It must have an input parameter of the type specified by the first parameter,
5090 and the return type must be the same as the input type of the Read function.
5091 The effect is to first call the Write function to convert to the given stream
5092 type, and then write the result type to the stream.
5094 The Read and Write functions must not be overloaded subprograms. If necessary
5095 renamings can be supplied to meet this requirement.
5096 The usage of this attribute is best illustrated by a simple example, taken
5097 from the GNAT implementation of package Ada.Strings.Unbounded:
5099 @smallexample @c ada
5100 function To_Unbounded (S : String)
5101 return Unbounded_String
5102 renames To_Unbounded_String;
5104 pragma Stream_Convert
5105 (Unbounded_String, To_Unbounded, To_String);
5109 The specifications of the referenced functions, as given in the Ada
5110 Reference Manual are:
5112 @smallexample @c ada
5113 function To_Unbounded_String (Source : String)
5114 return Unbounded_String;
5116 function To_String (Source : Unbounded_String)
5121 The effect is that if the value of an unbounded string is written to a stream,
5122 then the representation of the item in the stream is in the same format that
5123 would be used for @code{Standard.String'Output}, and this same representation
5124 is expected when a value of this type is read from the stream. Note that the
5125 value written always includes the bounds, even for Unbounded_String'Write,
5126 since Unbounded_String is not an array type.
5128 @node Pragma Style_Checks
5129 @unnumberedsec Pragma Style_Checks
5130 @findex Style_Checks
5134 @smallexample @c ada
5135 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
5136 On | Off [, LOCAL_NAME]);
5140 This pragma is used in conjunction with compiler switches to control the
5141 built in style checking provided by GNAT@. The compiler switches, if set,
5142 provide an initial setting for the switches, and this pragma may be used
5143 to modify these settings, or the settings may be provided entirely by
5144 the use of the pragma. This pragma can be used anywhere that a pragma
5145 is legal, including use as a configuration pragma (including use in
5146 the @file{gnat.adc} file).
5148 The form with a string literal specifies which style options are to be
5149 activated. These are additive, so they apply in addition to any previously
5150 set style check options. The codes for the options are the same as those
5151 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
5152 For example the following two methods can be used to enable
5157 @smallexample @c ada
5158 pragma Style_Checks ("l");
5163 gcc -c -gnatyl @dots{}
5168 The form ALL_CHECKS activates all standard checks (its use is equivalent
5169 to the use of the @code{gnaty} switch with no options. @xref{Top,
5170 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
5171 @value{EDITION} User's Guide}, for details.)
5173 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
5174 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
5175 options (i.e. equivalent to -gnatyg).
5177 The forms with @code{Off} and @code{On}
5178 can be used to temporarily disable style checks
5179 as shown in the following example:
5181 @smallexample @c ada
5185 pragma Style_Checks ("k"); -- requires keywords in lower case
5186 pragma Style_Checks (Off); -- turn off style checks
5187 NULL; -- this will not generate an error message
5188 pragma Style_Checks (On); -- turn style checks back on
5189 NULL; -- this will generate an error message
5193 Finally the two argument form is allowed only if the first argument is
5194 @code{On} or @code{Off}. The effect is to turn of semantic style checks
5195 for the specified entity, as shown in the following example:
5197 @smallexample @c ada
5201 pragma Style_Checks ("r"); -- require consistency of identifier casing
5203 Rf1 : Integer := ARG; -- incorrect, wrong case
5204 pragma Style_Checks (Off, Arg);
5205 Rf2 : Integer := ARG; -- OK, no error
5208 @node Pragma Subtitle
5209 @unnumberedsec Pragma Subtitle
5214 @smallexample @c ada
5215 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5219 This pragma is recognized for compatibility with other Ada compilers
5220 but is ignored by GNAT@.
5222 @node Pragma Suppress
5223 @unnumberedsec Pragma Suppress
5228 @smallexample @c ada
5229 pragma Suppress (Identifier [, [On =>] Name]);
5233 This is a standard pragma, and supports all the check names required in
5234 the RM. It is included here because GNAT recognizes one additional check
5235 name: @code{Alignment_Check} which can be used to suppress alignment checks
5236 on addresses used in address clauses. Such checks can also be suppressed
5237 by suppressing range checks, but the specific use of @code{Alignment_Check}
5238 allows suppression of alignment checks without suppressing other range checks.
5240 Note that pragma Suppress gives the compiler permission to omit
5241 checks, but does not require the compiler to omit checks. The compiler
5242 will generate checks if they are essentially free, even when they are
5243 suppressed. In particular, if the compiler can prove that a certain
5244 check will necessarily fail, it will generate code to do an
5245 unconditional ``raise'', even if checks are suppressed. The compiler
5248 Of course, run-time checks are omitted whenever the compiler can prove
5249 that they will not fail, whether or not checks are suppressed.
5251 @node Pragma Suppress_All
5252 @unnumberedsec Pragma Suppress_All
5253 @findex Suppress_All
5257 @smallexample @c ada
5258 pragma Suppress_All;
5262 This pragma can appear anywhere within a unit.
5263 The effect is to apply @code{Suppress (All_Checks)} to the unit
5264 in which it appears. This pragma is implemented for compatibility with DEC
5265 Ada 83 usage where it appears at the end of a unit, and for compatibility
5266 with Rational Ada, where it appears as a program unit pragma.
5267 The use of the standard Ada pragma @code{Suppress (All_Checks)}
5268 as a normal configuration pragma is the preferred usage in GNAT@.
5270 @node Pragma Suppress_Exception_Locations
5271 @unnumberedsec Pragma Suppress_Exception_Locations
5272 @findex Suppress_Exception_Locations
5276 @smallexample @c ada
5277 pragma Suppress_Exception_Locations;
5281 In normal mode, a raise statement for an exception by default generates
5282 an exception message giving the file name and line number for the location
5283 of the raise. This is useful for debugging and logging purposes, but this
5284 entails extra space for the strings for the messages. The configuration
5285 pragma @code{Suppress_Exception_Locations} can be used to suppress the
5286 generation of these strings, with the result that space is saved, but the
5287 exception message for such raises is null. This configuration pragma may
5288 appear in a global configuration pragma file, or in a specific unit as
5289 usual. It is not required that this pragma be used consistently within
5290 a partition, so it is fine to have some units within a partition compiled
5291 with this pragma and others compiled in normal mode without it.
5293 @node Pragma Suppress_Initialization
5294 @unnumberedsec Pragma Suppress_Initialization
5295 @findex Suppress_Initialization
5296 @cindex Suppressing initialization
5297 @cindex Initialization, suppression of
5301 @smallexample @c ada
5302 pragma Suppress_Initialization ([Entity =>] subtype_Name);
5306 Here subtype_Name is the name introduced by a type declaration
5307 or subtype declaration.
5308 This pragma suppresses any implicit or explicit initialization
5309 for all variables of the given type or subtype,
5310 including initialization resulting from the use of pragmas
5311 Normalize_Scalars or Initialize_Scalars.
5313 This is considered a representation item, so it cannot be given after
5314 the type is frozen. It applies to all subsequent object declarations,
5315 and also any allocator that creates objects of the type.
5317 If the pragma is given for the first subtype, then it is considered
5318 to apply to the base type and all its subtypes. If the pragma is given
5319 for other than a first subtype, then it applies only to the given subtype.
5320 The pragma may not be given after the type is frozen.
5322 @node Pragma Task_Info
5323 @unnumberedsec Pragma Task_Info
5328 @smallexample @c ada
5329 pragma Task_Info (EXPRESSION);
5333 This pragma appears within a task definition (like pragma
5334 @code{Priority}) and applies to the task in which it appears. The
5335 argument must be of type @code{System.Task_Info.Task_Info_Type}.
5336 The @code{Task_Info} pragma provides system dependent control over
5337 aspects of tasking implementation, for example, the ability to map
5338 tasks to specific processors. For details on the facilities available
5339 for the version of GNAT that you are using, see the documentation
5340 in the spec of package System.Task_Info in the runtime
5343 @node Pragma Task_Name
5344 @unnumberedsec Pragma Task_Name
5349 @smallexample @c ada
5350 pragma Task_Name (string_EXPRESSION);
5354 This pragma appears within a task definition (like pragma
5355 @code{Priority}) and applies to the task in which it appears. The
5356 argument must be of type String, and provides a name to be used for
5357 the task instance when the task is created. Note that this expression
5358 is not required to be static, and in particular, it can contain
5359 references to task discriminants. This facility can be used to
5360 provide different names for different tasks as they are created,
5361 as illustrated in the example below.
5363 The task name is recorded internally in the run-time structures
5364 and is accessible to tools like the debugger. In addition the
5365 routine @code{Ada.Task_Identification.Image} will return this
5366 string, with a unique task address appended.
5368 @smallexample @c ada
5369 -- Example of the use of pragma Task_Name
5371 with Ada.Task_Identification;
5372 use Ada.Task_Identification;
5373 with Text_IO; use Text_IO;
5376 type Astring is access String;
5378 task type Task_Typ (Name : access String) is
5379 pragma Task_Name (Name.all);
5382 task body Task_Typ is
5383 Nam : constant String := Image (Current_Task);
5385 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5388 type Ptr_Task is access Task_Typ;
5389 Task_Var : Ptr_Task;
5393 new Task_Typ (new String'("This is task 1"));
5395 new Task_Typ (new String'("This is task 2"));
5399 @node Pragma Task_Storage
5400 @unnumberedsec Pragma Task_Storage
5401 @findex Task_Storage
5404 @smallexample @c ada
5405 pragma Task_Storage (
5406 [Task_Type =>] LOCAL_NAME,
5407 [Top_Guard =>] static_integer_EXPRESSION);
5411 This pragma specifies the length of the guard area for tasks. The guard
5412 area is an additional storage area allocated to a task. A value of zero
5413 means that either no guard area is created or a minimal guard area is
5414 created, depending on the target. This pragma can appear anywhere a
5415 @code{Storage_Size} attribute definition clause is allowed for a task
5418 @node Pragma Test_Case
5419 @unnumberedsec Pragma Test_Case
5425 @smallexample @c ada
5427 [Name =>] static_string_Expression
5428 ,[Mode =>] (Nominal | Robustness)
5429 [, Requires => Boolean_Expression]
5430 [, Ensures => Boolean_Expression]);
5434 The @code{Test_Case} pragma allows defining fine-grain specifications
5435 for use by testing tools. Its syntax is similar to the syntax of the
5436 @code{Contract_Case} pragma, which is used for both testing and
5437 formal verification.
5438 The compiler checks the validity of the @code{Test_Case} pragma, but its
5439 presence does not lead to any modification of the code generated by the
5440 compiler, contrary to the treatment of the @code{Contract_Case} pragma.
5442 @code{Test_Case} pragmas may only appear immediately following the
5443 (separate) declaration of a subprogram in a package declaration, inside
5444 a package spec unit. Only other pragmas may intervene (that is appear
5445 between the subprogram declaration and a test case).
5447 The compiler checks that boolean expressions given in @code{Requires} and
5448 @code{Ensures} are valid, where the rules for @code{Requires} are the
5449 same as the rule for an expression in @code{Precondition} and the rules
5450 for @code{Ensures} are the same as the rule for an expression in
5451 @code{Postcondition}. In particular, attributes @code{'Old} and
5452 @code{'Result} can only be used within the @code{Ensures}
5453 expression. The following is an example of use within a package spec:
5455 @smallexample @c ada
5456 package Math_Functions is
5458 function Sqrt (Arg : Float) return Float;
5459 pragma Test_Case (Name => "Test 1",
5461 Requires => Arg < 10000,
5462 Ensures => Sqrt'Result < 10);
5468 The meaning of a test case is that there is at least one context where
5469 @code{Requires} holds such that, if the associated subprogram is executed in
5470 that context, then @code{Ensures} holds when the subprogram returns.
5471 Mode @code{Nominal} indicates that the input context should also satisfy the
5472 precondition of the subprogram, and the output context should also satisfy its
5473 postcondition. More @code{Robustness} indicates that the precondition and
5474 postcondition of the subprogram should be ignored for this test case.
5476 @node Pragma Thread_Local_Storage
5477 @unnumberedsec Pragma Thread_Local_Storage
5478 @findex Thread_Local_Storage
5479 @cindex Task specific storage
5480 @cindex TLS (Thread Local Storage)
5483 @smallexample @c ada
5484 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5488 This pragma specifies that the specified entity, which must be
5489 a variable declared in a library level package, is to be marked as
5490 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5491 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5492 (and hence each Ada task) to see a distinct copy of the variable.
5494 The variable may not have default initialization, and if there is
5495 an explicit initialization, it must be either @code{null} for an
5496 access variable, or a static expression for a scalar variable.
5497 This provides a low level mechanism similar to that provided by
5498 the @code{Ada.Task_Attributes} package, but much more efficient
5499 and is also useful in writing interface code that will interact
5500 with foreign threads.
5502 If this pragma is used on a system where @code{TLS} is not supported,
5503 then an error message will be generated and the program will be rejected.
5505 @node Pragma Time_Slice
5506 @unnumberedsec Pragma Time_Slice
5511 @smallexample @c ada
5512 pragma Time_Slice (static_duration_EXPRESSION);
5516 For implementations of GNAT on operating systems where it is possible
5517 to supply a time slice value, this pragma may be used for this purpose.
5518 It is ignored if it is used in a system that does not allow this control,
5519 or if it appears in other than the main program unit.
5521 Note that the effect of this pragma is identical to the effect of the
5522 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5525 @unnumberedsec Pragma Title
5530 @smallexample @c ada
5531 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5534 [Title =>] STRING_LITERAL,
5535 | [Subtitle =>] STRING_LITERAL
5539 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5540 pragma used in DEC Ada 83 implementations to provide a title and/or
5541 subtitle for the program listing. The program listing generated by GNAT
5542 does not have titles or subtitles.
5544 Unlike other pragmas, the full flexibility of named notation is allowed
5545 for this pragma, i.e.@: the parameters may be given in any order if named
5546 notation is used, and named and positional notation can be mixed
5547 following the normal rules for procedure calls in Ada.
5549 @node Pragma Unchecked_Union
5550 @unnumberedsec Pragma Unchecked_Union
5552 @findex Unchecked_Union
5556 @smallexample @c ada
5557 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5561 This pragma is used to specify a representation of a record type that is
5562 equivalent to a C union. It was introduced as a GNAT implementation defined
5563 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5564 pragma, making it language defined, and GNAT fully implements this extended
5565 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5566 details, consult the Ada 2005 Reference Manual, section B.3.3.
5568 @node Pragma Unimplemented_Unit
5569 @unnumberedsec Pragma Unimplemented_Unit
5570 @findex Unimplemented_Unit
5574 @smallexample @c ada
5575 pragma Unimplemented_Unit;
5579 If this pragma occurs in a unit that is processed by the compiler, GNAT
5580 aborts with the message @samp{@var{xxx} not implemented}, where
5581 @var{xxx} is the name of the current compilation unit. This pragma is
5582 intended to allow the compiler to handle unimplemented library units in
5585 The abort only happens if code is being generated. Thus you can use
5586 specs of unimplemented packages in syntax or semantic checking mode.
5588 @node Pragma Universal_Aliasing
5589 @unnumberedsec Pragma Universal_Aliasing
5590 @findex Universal_Aliasing
5594 @smallexample @c ada
5595 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5599 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5600 declarative part. The effect is to inhibit strict type-based aliasing
5601 optimization for the given type. In other words, the effect is as though
5602 access types designating this type were subject to pragma No_Strict_Aliasing.
5603 For a detailed description of the strict aliasing optimization, and the
5604 situations in which it must be suppressed, @xref{Optimization and Strict
5605 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5607 @node Pragma Universal_Data
5608 @unnumberedsec Pragma Universal_Data
5609 @findex Universal_Data
5613 @smallexample @c ada
5614 pragma Universal_Data [(library_unit_Name)];
5618 This pragma is supported only for the AAMP target and is ignored for
5619 other targets. The pragma specifies that all library-level objects
5620 (Counter 0 data) associated with the library unit are to be accessed
5621 and updated using universal addressing (24-bit addresses for AAMP5)
5622 rather than the default of 16-bit Data Environment (DENV) addressing.
5623 Use of this pragma will generally result in less efficient code for
5624 references to global data associated with the library unit, but
5625 allows such data to be located anywhere in memory. This pragma is
5626 a library unit pragma, but can also be used as a configuration pragma
5627 (including use in the @file{gnat.adc} file). The functionality
5628 of this pragma is also available by applying the -univ switch on the
5629 compilations of units where universal addressing of the data is desired.
5631 @node Pragma Unmodified
5632 @unnumberedsec Pragma Unmodified
5634 @cindex Warnings, unmodified
5638 @smallexample @c ada
5639 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5643 This pragma signals that the assignable entities (variables,
5644 @code{out} parameters, @code{in out} parameters) whose names are listed are
5645 deliberately not assigned in the current source unit. This
5646 suppresses warnings about the
5647 entities being referenced but not assigned, and in addition a warning will be
5648 generated if one of these entities is in fact assigned in the
5649 same unit as the pragma (or in the corresponding body, or one
5652 This is particularly useful for clearly signaling that a particular
5653 parameter is not modified, even though the spec suggests that it might
5656 @node Pragma Unreferenced
5657 @unnumberedsec Pragma Unreferenced
5658 @findex Unreferenced
5659 @cindex Warnings, unreferenced
5663 @smallexample @c ada
5664 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5665 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5669 This pragma signals that the entities whose names are listed are
5670 deliberately not referenced in the current source unit. This
5671 suppresses warnings about the
5672 entities being unreferenced, and in addition a warning will be
5673 generated if one of these entities is in fact subsequently referenced in the
5674 same unit as the pragma (or in the corresponding body, or one
5677 This is particularly useful for clearly signaling that a particular
5678 parameter is not referenced in some particular subprogram implementation
5679 and that this is deliberate. It can also be useful in the case of
5680 objects declared only for their initialization or finalization side
5683 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5684 current scope, then the entity most recently declared is the one to which
5685 the pragma applies. Note that in the case of accept formals, the pragma
5686 Unreferenced may appear immediately after the keyword @code{do} which
5687 allows the indication of whether or not accept formals are referenced
5688 or not to be given individually for each accept statement.
5690 The left hand side of an assignment does not count as a reference for the
5691 purpose of this pragma. Thus it is fine to assign to an entity for which
5692 pragma Unreferenced is given.
5694 Note that if a warning is desired for all calls to a given subprogram,
5695 regardless of whether they occur in the same unit as the subprogram
5696 declaration, then this pragma should not be used (calls from another
5697 unit would not be flagged); pragma Obsolescent can be used instead
5698 for this purpose, see @xref{Pragma Obsolescent}.
5700 The second form of pragma @code{Unreferenced} is used within a context
5701 clause. In this case the arguments must be unit names of units previously
5702 mentioned in @code{with} clauses (similar to the usage of pragma
5703 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5704 units and unreferenced entities within these units.
5706 @node Pragma Unreferenced_Objects
5707 @unnumberedsec Pragma Unreferenced_Objects
5708 @findex Unreferenced_Objects
5709 @cindex Warnings, unreferenced
5713 @smallexample @c ada
5714 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5718 This pragma signals that for the types or subtypes whose names are
5719 listed, objects which are declared with one of these types or subtypes may
5720 not be referenced, and if no references appear, no warnings are given.
5722 This is particularly useful for objects which are declared solely for their
5723 initialization and finalization effect. Such variables are sometimes referred
5724 to as RAII variables (Resource Acquisition Is Initialization). Using this
5725 pragma on the relevant type (most typically a limited controlled type), the
5726 compiler will automatically suppress unwanted warnings about these variables
5727 not being referenced.
5729 @node Pragma Unreserve_All_Interrupts
5730 @unnumberedsec Pragma Unreserve_All_Interrupts
5731 @findex Unreserve_All_Interrupts
5735 @smallexample @c ada
5736 pragma Unreserve_All_Interrupts;
5740 Normally certain interrupts are reserved to the implementation. Any attempt
5741 to attach an interrupt causes Program_Error to be raised, as described in
5742 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5743 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5744 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5745 interrupt execution.
5747 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5748 a program, then all such interrupts are unreserved. This allows the
5749 program to handle these interrupts, but disables their standard
5750 functions. For example, if this pragma is used, then pressing
5751 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5752 a program can then handle the @code{SIGINT} interrupt as it chooses.
5754 For a full list of the interrupts handled in a specific implementation,
5755 see the source code for the spec of @code{Ada.Interrupts.Names} in
5756 file @file{a-intnam.ads}. This is a target dependent file that contains the
5757 list of interrupts recognized for a given target. The documentation in
5758 this file also specifies what interrupts are affected by the use of
5759 the @code{Unreserve_All_Interrupts} pragma.
5761 For a more general facility for controlling what interrupts can be
5762 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5763 of the @code{Unreserve_All_Interrupts} pragma.
5765 @node Pragma Unsuppress
5766 @unnumberedsec Pragma Unsuppress
5771 @smallexample @c ada
5772 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5776 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5777 there is no corresponding pragma @code{Suppress} in effect, it has no
5778 effect. The range of the effect is the same as for pragma
5779 @code{Suppress}. The meaning of the arguments is identical to that used
5780 in pragma @code{Suppress}.
5782 One important application is to ensure that checks are on in cases where
5783 code depends on the checks for its correct functioning, so that the code
5784 will compile correctly even if the compiler switches are set to suppress
5787 @node Pragma Use_VADS_Size
5788 @unnumberedsec Pragma Use_VADS_Size
5789 @cindex @code{Size}, VADS compatibility
5790 @findex Use_VADS_Size
5794 @smallexample @c ada
5795 pragma Use_VADS_Size;
5799 This is a configuration pragma. In a unit to which it applies, any use
5800 of the 'Size attribute is automatically interpreted as a use of the
5801 'VADS_Size attribute. Note that this may result in incorrect semantic
5802 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5803 the handling of existing code which depends on the interpretation of Size
5804 as implemented in the VADS compiler. See description of the VADS_Size
5805 attribute for further details.
5807 @node Pragma Validity_Checks
5808 @unnumberedsec Pragma Validity_Checks
5809 @findex Validity_Checks
5813 @smallexample @c ada
5814 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5818 This pragma is used in conjunction with compiler switches to control the
5819 built-in validity checking provided by GNAT@. The compiler switches, if set
5820 provide an initial setting for the switches, and this pragma may be used
5821 to modify these settings, or the settings may be provided entirely by
5822 the use of the pragma. This pragma can be used anywhere that a pragma
5823 is legal, including use as a configuration pragma (including use in
5824 the @file{gnat.adc} file).
5826 The form with a string literal specifies which validity options are to be
5827 activated. The validity checks are first set to include only the default
5828 reference manual settings, and then a string of letters in the string
5829 specifies the exact set of options required. The form of this string
5830 is exactly as described for the @option{-gnatVx} compiler switch (see the
5831 @value{EDITION} User's Guide for details). For example the following two
5832 methods can be used to enable validity checking for mode @code{in} and
5833 @code{in out} subprogram parameters:
5837 @smallexample @c ada
5838 pragma Validity_Checks ("im");
5843 gcc -c -gnatVim @dots{}
5848 The form ALL_CHECKS activates all standard checks (its use is equivalent
5849 to the use of the @code{gnatva} switch.
5851 The forms with @code{Off} and @code{On}
5852 can be used to temporarily disable validity checks
5853 as shown in the following example:
5855 @smallexample @c ada
5859 pragma Validity_Checks ("c"); -- validity checks for copies
5860 pragma Validity_Checks (Off); -- turn off validity checks
5861 A := B; -- B will not be validity checked
5862 pragma Validity_Checks (On); -- turn validity checks back on
5863 A := C; -- C will be validity checked
5866 @node Pragma Volatile
5867 @unnumberedsec Pragma Volatile
5872 @smallexample @c ada
5873 pragma Volatile (LOCAL_NAME);
5877 This pragma is defined by the Ada Reference Manual, and the GNAT
5878 implementation is fully conformant with this definition. The reason it
5879 is mentioned in this section is that a pragma of the same name was supplied
5880 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5881 implementation of pragma Volatile is upwards compatible with the
5882 implementation in DEC Ada 83.
5884 @node Pragma Warnings
5885 @unnumberedsec Pragma Warnings
5890 @smallexample @c ada
5891 pragma Warnings (On | Off);
5892 pragma Warnings (On | Off, LOCAL_NAME);
5893 pragma Warnings (static_string_EXPRESSION);
5894 pragma Warnings (On | Off, static_string_EXPRESSION);
5898 Normally warnings are enabled, with the output being controlled by
5899 the command line switch. Warnings (@code{Off}) turns off generation of
5900 warnings until a Warnings (@code{On}) is encountered or the end of the
5901 current unit. If generation of warnings is turned off using this
5902 pragma, then no warning messages are output, regardless of the
5903 setting of the command line switches.
5905 The form with a single argument may be used as a configuration pragma.
5907 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5908 the specified entity. This suppression is effective from the point where
5909 it occurs till the end of the extended scope of the variable (similar to
5910 the scope of @code{Suppress}).
5912 The form with a single static_string_EXPRESSION argument provides more precise
5913 control over which warnings are active. The string is a list of letters
5914 specifying which warnings are to be activated and which deactivated. The
5915 code for these letters is the same as the string used in the command
5916 line switch controlling warnings. For a brief summary, use the gnatmake
5917 command with no arguments, which will generate usage information containing
5918 the list of warnings switches supported. For
5919 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5923 The specified warnings will be in effect until the end of the program
5924 or another pragma Warnings is encountered. The effect of the pragma is
5925 cumulative. Initially the set of warnings is the standard default set
5926 as possibly modified by compiler switches. Then each pragma Warning
5927 modifies this set of warnings as specified. This form of the pragma may
5928 also be used as a configuration pragma.
5930 The fourth form, with an @code{On|Off} parameter and a string, is used to
5931 control individual messages, based on their text. The string argument
5932 is a pattern that is used to match against the text of individual
5933 warning messages (not including the initial "warning: " tag).
5935 The pattern may contain asterisks, which match zero or more characters in
5936 the message. For example, you can use
5937 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5938 message @code{warning: 960 bits of "a" unused}. No other regular
5939 expression notations are permitted. All characters other than asterisk in
5940 these three specific cases are treated as literal characters in the match.
5942 There are two ways to use the pragma in this form. The OFF form can be used as a
5943 configuration pragma. The effect is to suppress all warnings (if any)
5944 that match the pattern string throughout the compilation.
5946 The second usage is to suppress a warning locally, and in this case, two
5947 pragmas must appear in sequence:
5949 @smallexample @c ada
5950 pragma Warnings (Off, Pattern);
5951 @dots{} code where given warning is to be suppressed
5952 pragma Warnings (On, Pattern);
5956 In this usage, the pattern string must match in the Off and On pragmas,
5957 and at least one matching warning must be suppressed.
5959 Note: to write a string that will match any warning, use the string
5960 @code{"***"}. It will not work to use a single asterisk or two asterisks
5961 since this looks like an operator name. This form with three asterisks
5962 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
5963 matching @code{pragma Warnings (On, "***")} will be required. This can be
5964 helpful in avoiding forgetting to turn warnings back on.
5966 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5967 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5968 be useful in checking whether obsolete pragmas in existing programs are hiding
5971 Note: pragma Warnings does not affect the processing of style messages. See
5972 separate entry for pragma Style_Checks for control of style messages.
5974 @node Pragma Weak_External
5975 @unnumberedsec Pragma Weak_External
5976 @findex Weak_External
5980 @smallexample @c ada
5981 pragma Weak_External ([Entity =>] LOCAL_NAME);
5985 @var{LOCAL_NAME} must refer to an object that is declared at the library
5986 level. This pragma specifies that the given entity should be marked as a
5987 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5988 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5989 of a regular symbol, that is to say a symbol that does not have to be
5990 resolved by the linker if used in conjunction with a pragma Import.
5992 When a weak symbol is not resolved by the linker, its address is set to
5993 zero. This is useful in writing interfaces to external modules that may
5994 or may not be linked in the final executable, for example depending on
5995 configuration settings.
5997 If a program references at run time an entity to which this pragma has been
5998 applied, and the corresponding symbol was not resolved at link time, then
5999 the execution of the program is erroneous. It is not erroneous to take the
6000 Address of such an entity, for example to guard potential references,
6001 as shown in the example below.
6003 Some file formats do not support weak symbols so not all target machines
6004 support this pragma.
6006 @smallexample @c ada
6007 -- Example of the use of pragma Weak_External
6009 package External_Module is
6011 pragma Import (C, key);
6012 pragma Weak_External (key);
6013 function Present return boolean;
6014 end External_Module;
6016 with System; use System;
6017 package body External_Module is
6018 function Present return boolean is
6020 return key'Address /= System.Null_Address;
6022 end External_Module;
6025 @node Pragma Wide_Character_Encoding
6026 @unnumberedsec Pragma Wide_Character_Encoding
6027 @findex Wide_Character_Encoding
6031 @smallexample @c ada
6032 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
6036 This pragma specifies the wide character encoding to be used in program
6037 source text appearing subsequently. It is a configuration pragma, but may
6038 also be used at any point that a pragma is allowed, and it is permissible
6039 to have more than one such pragma in a file, allowing multiple encodings
6040 to appear within the same file.
6042 The argument can be an identifier or a character literal. In the identifier
6043 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
6044 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
6045 case it is correspondingly one of the characters @samp{h}, @samp{u},
6046 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
6048 Note that when the pragma is used within a file, it affects only the
6049 encoding within that file, and does not affect withed units, specs,
6052 @node Implementation Defined Attributes
6053 @chapter Implementation Defined Attributes
6054 Ada defines (throughout the Ada reference manual,
6055 summarized in Annex K),
6056 a set of attributes that provide useful additional functionality in all
6057 areas of the language. These language defined attributes are implemented
6058 in GNAT and work as described in the Ada Reference Manual.
6060 In addition, Ada allows implementations to define additional
6061 attributes whose meaning is defined by the implementation. GNAT provides
6062 a number of these implementation-dependent attributes which can be used
6063 to extend and enhance the functionality of the compiler. This section of
6064 the GNAT reference manual describes these additional attributes.
6066 Note that any program using these attributes may not be portable to
6067 other compilers (although GNAT implements this set of attributes on all
6068 platforms). Therefore if portability to other compilers is an important
6069 consideration, you should minimize the use of these attributes.
6079 * Compiler_Version::
6081 * Default_Bit_Order::
6093 * Has_Access_Values::
6094 * Has_Discriminants::
6101 * Max_Interrupt_Priority::
6103 * Maximum_Alignment::
6107 * Passed_By_Reference::
6114 * Scalar_Storage_Order::
6115 * Simple_Storage_Pool::
6119 * System_Allocator_Alignment::
6125 * Unconstrained_Array::
6126 * Universal_Literal_String::
6127 * Unrestricted_Access::
6136 @unnumberedsec Abort_Signal
6137 @findex Abort_Signal
6139 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
6140 prefix) provides the entity for the special exception used to signal
6141 task abort or asynchronous transfer of control. Normally this attribute
6142 should only be used in the tasking runtime (it is highly peculiar, and
6143 completely outside the normal semantics of Ada, for a user program to
6144 intercept the abort exception).
6147 @unnumberedsec Address_Size
6148 @cindex Size of @code{Address}
6149 @findex Address_Size
6151 @code{Standard'Address_Size} (@code{Standard} is the only allowed
6152 prefix) is a static constant giving the number of bits in an
6153 @code{Address}. It is the same value as System.Address'Size,
6154 but has the advantage of being static, while a direct
6155 reference to System.Address'Size is non-static because Address
6159 @unnumberedsec Asm_Input
6162 The @code{Asm_Input} attribute denotes a function that takes two
6163 parameters. The first is a string, the second is an expression of the
6164 type designated by the prefix. The first (string) argument is required
6165 to be a static expression, and is the constraint for the parameter,
6166 (e.g.@: what kind of register is required). The second argument is the
6167 value to be used as the input argument. The possible values for the
6168 constant are the same as those used in the RTL, and are dependent on
6169 the configuration file used to built the GCC back end.
6170 @ref{Machine Code Insertions}
6173 @unnumberedsec Asm_Output
6176 The @code{Asm_Output} attribute denotes a function that takes two
6177 parameters. The first is a string, the second is the name of a variable
6178 of the type designated by the attribute prefix. The first (string)
6179 argument is required to be a static expression and designates the
6180 constraint for the parameter (e.g.@: what kind of register is
6181 required). The second argument is the variable to be updated with the
6182 result. The possible values for constraint are the same as those used in
6183 the RTL, and are dependent on the configuration file used to build the
6184 GCC back end. If there are no output operands, then this argument may
6185 either be omitted, or explicitly given as @code{No_Output_Operands}.
6186 @ref{Machine Code Insertions}
6189 @unnumberedsec AST_Entry
6193 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
6194 the name of an entry, it yields a value of the predefined type AST_Handler
6195 (declared in the predefined package System, as extended by the use of
6196 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
6197 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
6198 Language Reference Manual}, section 9.12a.
6203 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
6204 offset within the storage unit (byte) that contains the first bit of
6205 storage allocated for the object. The value of this attribute is of the
6206 type @code{Universal_Integer}, and is always a non-negative number not
6207 exceeding the value of @code{System.Storage_Unit}.
6209 For an object that is a variable or a constant allocated in a register,
6210 the value is zero. (The use of this attribute does not force the
6211 allocation of a variable to memory).
6213 For an object that is a formal parameter, this attribute applies
6214 to either the matching actual parameter or to a copy of the
6215 matching actual parameter.
6217 For an access object the value is zero. Note that
6218 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
6219 designated object. Similarly for a record component
6220 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
6221 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
6222 are subject to index checks.
6224 This attribute is designed to be compatible with the DEC Ada 83 definition
6225 and implementation of the @code{Bit} attribute.
6228 @unnumberedsec Bit_Position
6229 @findex Bit_Position
6231 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
6232 of the fields of the record type, yields the bit
6233 offset within the record contains the first bit of
6234 storage allocated for the object. The value of this attribute is of the
6235 type @code{Universal_Integer}. The value depends only on the field
6236 @var{C} and is independent of the alignment of
6237 the containing record @var{R}.
6239 @node Compiler_Version
6240 @unnumberedsec Compiler_Version
6241 @findex Compiler_Version
6243 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
6244 prefix) yields a static string identifying the version of the compiler
6245 being used to compile the unit containing the attribute reference. A
6246 typical result would be something like "@value{EDITION} @i{version} (20090221)".
6249 @unnumberedsec Code_Address
6250 @findex Code_Address
6251 @cindex Subprogram address
6252 @cindex Address of subprogram code
6255 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
6256 intended effect seems to be to provide
6257 an address value which can be used to call the subprogram by means of
6258 an address clause as in the following example:
6260 @smallexample @c ada
6261 procedure K is @dots{}
6264 for L'Address use K'Address;
6265 pragma Import (Ada, L);
6269 A call to @code{L} is then expected to result in a call to @code{K}@.
6270 In Ada 83, where there were no access-to-subprogram values, this was
6271 a common work-around for getting the effect of an indirect call.
6272 GNAT implements the above use of @code{Address} and the technique
6273 illustrated by the example code works correctly.
6275 However, for some purposes, it is useful to have the address of the start
6276 of the generated code for the subprogram. On some architectures, this is
6277 not necessarily the same as the @code{Address} value described above.
6278 For example, the @code{Address} value may reference a subprogram
6279 descriptor rather than the subprogram itself.
6281 The @code{'Code_Address} attribute, which can only be applied to
6282 subprogram entities, always returns the address of the start of the
6283 generated code of the specified subprogram, which may or may not be
6284 the same value as is returned by the corresponding @code{'Address}
6287 @node Default_Bit_Order
6288 @unnumberedsec Default_Bit_Order
6290 @cindex Little endian
6291 @findex Default_Bit_Order
6293 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
6294 permissible prefix), provides the value @code{System.Default_Bit_Order}
6295 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
6296 @code{Low_Order_First}). This is used to construct the definition of
6297 @code{Default_Bit_Order} in package @code{System}.
6299 @node Descriptor_Size
6300 @unnumberedsec Descriptor_Size
6303 @findex Descriptor_Size
6305 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
6306 descriptor allocated for a type. The result is non-zero only for unconstrained
6307 array types and the returned value is of type universal integer. In GNAT, an
6308 array descriptor contains bounds information and is located immediately before
6309 the first element of the array.
6311 @smallexample @c ada
6312 type Unconstr_Array is array (Positive range <>) of Boolean;
6313 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
6317 The attribute takes into account any additional padding due to type alignment.
6318 In the example above, the descriptor contains two values of type
6319 @code{Positive} representing the low and high bound. Since @code{Positive} has
6320 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
6321 Positive'Size + 2} or 64 bits.
6324 @unnumberedsec Elaborated
6327 The prefix of the @code{'Elaborated} attribute must be a unit name. The
6328 value is a Boolean which indicates whether or not the given unit has been
6329 elaborated. This attribute is primarily intended for internal use by the
6330 generated code for dynamic elaboration checking, but it can also be used
6331 in user programs. The value will always be True once elaboration of all
6332 units has been completed. An exception is for units which need no
6333 elaboration, the value is always False for such units.
6336 @unnumberedsec Elab_Body
6339 This attribute can only be applied to a program unit name. It returns
6340 the entity for the corresponding elaboration procedure for elaborating
6341 the body of the referenced unit. This is used in the main generated
6342 elaboration procedure by the binder and is not normally used in any
6343 other context. However, there may be specialized situations in which it
6344 is useful to be able to call this elaboration procedure from Ada code,
6345 e.g.@: if it is necessary to do selective re-elaboration to fix some
6349 @unnumberedsec Elab_Spec
6352 This attribute can only be applied to a program unit name. It returns
6353 the entity for the corresponding elaboration procedure for elaborating
6354 the spec of the referenced unit. This is used in the main
6355 generated elaboration procedure by the binder and is not normally used
6356 in any other context. However, there may be specialized situations in
6357 which it is useful to be able to call this elaboration procedure from
6358 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6361 @node Elab_Subp_Body
6362 @unnumberedsec Elab_Subp_Body
6363 @findex Elab_Subp_Body
6365 This attribute can only be applied to a library level subprogram
6366 name and is only allowed in CodePeer mode. It returns the entity
6367 for the corresponding elaboration procedure for elaborating the body
6368 of the referenced subprogram unit. This is used in the main generated
6369 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6374 @cindex Ada 83 attributes
6377 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6378 the Ada 83 reference manual for an exact description of the semantics of
6382 @unnumberedsec Enabled
6385 The @code{Enabled} attribute allows an application program to check at compile
6386 time to see if the designated check is currently enabled. The prefix is a
6387 simple identifier, referencing any predefined check name (other than
6388 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6389 no argument is given for the attribute, the check is for the general state
6390 of the check, if an argument is given, then it is an entity name, and the
6391 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6392 given naming the entity (if not, then the argument is ignored).
6394 Note that instantiations inherit the check status at the point of the
6395 instantiation, so a useful idiom is to have a library package that
6396 introduces a check name with @code{pragma Check_Name}, and then contains
6397 generic packages or subprograms which use the @code{Enabled} attribute
6398 to see if the check is enabled. A user of this package can then issue
6399 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6400 the package or subprogram, controlling whether the check will be present.
6403 @unnumberedsec Enum_Rep
6404 @cindex Representation of enums
6407 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6408 function with the following spec:
6410 @smallexample @c ada
6411 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6412 return @i{Universal_Integer};
6416 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6417 enumeration type or to a non-overloaded enumeration
6418 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6419 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6420 enumeration literal or object.
6422 The function returns the representation value for the given enumeration
6423 value. This will be equal to value of the @code{Pos} attribute in the
6424 absence of an enumeration representation clause. This is a static
6425 attribute (i.e.@: the result is static if the argument is static).
6427 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6428 in which case it simply returns the integer value. The reason for this
6429 is to allow it to be used for @code{(<>)} discrete formal arguments in
6430 a generic unit that can be instantiated with either enumeration types
6431 or integer types. Note that if @code{Enum_Rep} is used on a modular
6432 type whose upper bound exceeds the upper bound of the largest signed
6433 integer type, and the argument is a variable, so that the universal
6434 integer calculation is done at run time, then the call to @code{Enum_Rep}
6435 may raise @code{Constraint_Error}.
6438 @unnumberedsec Enum_Val
6439 @cindex Representation of enums
6442 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6443 function with the following spec:
6445 @smallexample @c ada
6446 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6447 return @var{S}'Base};
6451 The function returns the enumeration value whose representation matches the
6452 argument, or raises Constraint_Error if no enumeration literal of the type
6453 has the matching value.
6454 This will be equal to value of the @code{Val} attribute in the
6455 absence of an enumeration representation clause. This is a static
6456 attribute (i.e.@: the result is static if the argument is static).
6459 @unnumberedsec Epsilon
6460 @cindex Ada 83 attributes
6463 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6464 the Ada 83 reference manual for an exact description of the semantics of
6468 @unnumberedsec Fixed_Value
6471 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6472 function with the following specification:
6474 @smallexample @c ada
6475 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6480 The value returned is the fixed-point value @var{V} such that
6482 @smallexample @c ada
6483 @var{V} = Arg * @var{S}'Small
6487 The effect is thus similar to first converting the argument to the
6488 integer type used to represent @var{S}, and then doing an unchecked
6489 conversion to the fixed-point type. The difference is
6490 that there are full range checks, to ensure that the result is in range.
6491 This attribute is primarily intended for use in implementation of the
6492 input-output functions for fixed-point values.
6494 @node Has_Access_Values
6495 @unnumberedsec Has_Access_Values
6496 @cindex Access values, testing for
6497 @findex Has_Access_Values
6499 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6500 is a Boolean value which is True if the is an access type, or is a composite
6501 type with a component (at any nesting depth) that is an access type, and is
6503 The intended use of this attribute is in conjunction with generic
6504 definitions. If the attribute is applied to a generic private type, it
6505 indicates whether or not the corresponding actual type has access values.
6507 @node Has_Discriminants
6508 @unnumberedsec Has_Discriminants
6509 @cindex Discriminants, testing for
6510 @findex Has_Discriminants
6512 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6513 is a Boolean value which is True if the type has discriminants, and False
6514 otherwise. The intended use of this attribute is in conjunction with generic
6515 definitions. If the attribute is applied to a generic private type, it
6516 indicates whether or not the corresponding actual type has discriminants.
6522 The @code{Img} attribute differs from @code{Image} in that it may be
6523 applied to objects as well as types, in which case it gives the
6524 @code{Image} for the subtype of the object. This is convenient for
6527 @smallexample @c ada
6528 Put_Line ("X = " & X'Img);
6532 has the same meaning as the more verbose:
6534 @smallexample @c ada
6535 Put_Line ("X = " & @var{T}'Image (X));
6539 where @var{T} is the (sub)type of the object @code{X}.
6542 @unnumberedsec Integer_Value
6543 @findex Integer_Value
6545 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6546 function with the following spec:
6548 @smallexample @c ada
6549 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6554 The value returned is the integer value @var{V}, such that
6556 @smallexample @c ada
6557 Arg = @var{V} * @var{T}'Small
6561 where @var{T} is the type of @code{Arg}.
6562 The effect is thus similar to first doing an unchecked conversion from
6563 the fixed-point type to its corresponding implementation type, and then
6564 converting the result to the target integer type. The difference is
6565 that there are full range checks, to ensure that the result is in range.
6566 This attribute is primarily intended for use in implementation of the
6567 standard input-output functions for fixed-point values.
6570 @unnumberedsec Invalid_Value
6571 @findex Invalid_Value
6573 For every scalar type S, S'Invalid_Value returns an undefined value of the
6574 type. If possible this value is an invalid representation for the type. The
6575 value returned is identical to the value used to initialize an otherwise
6576 uninitialized value of the type if pragma Initialize_Scalars is used,
6577 including the ability to modify the value with the binder -Sxx flag and
6578 relevant environment variables at run time.
6581 @unnumberedsec Large
6582 @cindex Ada 83 attributes
6585 The @code{Large} attribute is provided for compatibility with Ada 83. See
6586 the Ada 83 reference manual for an exact description of the semantics of
6590 @unnumberedsec Machine_Size
6591 @findex Machine_Size
6593 This attribute is identical to the @code{Object_Size} attribute. It is
6594 provided for compatibility with the DEC Ada 83 attribute of this name.
6597 @unnumberedsec Mantissa
6598 @cindex Ada 83 attributes
6601 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6602 the Ada 83 reference manual for an exact description of the semantics of
6605 @node Max_Interrupt_Priority
6606 @unnumberedsec Max_Interrupt_Priority
6607 @cindex Interrupt priority, maximum
6608 @findex Max_Interrupt_Priority
6610 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6611 permissible prefix), provides the same value as
6612 @code{System.Max_Interrupt_Priority}.
6615 @unnumberedsec Max_Priority
6616 @cindex Priority, maximum
6617 @findex Max_Priority
6619 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6620 prefix) provides the same value as @code{System.Max_Priority}.
6622 @node Maximum_Alignment
6623 @unnumberedsec Maximum_Alignment
6624 @cindex Alignment, maximum
6625 @findex Maximum_Alignment
6627 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6628 permissible prefix) provides the maximum useful alignment value for the
6629 target. This is a static value that can be used to specify the alignment
6630 for an object, guaranteeing that it is properly aligned in all
6633 @node Mechanism_Code
6634 @unnumberedsec Mechanism_Code
6635 @cindex Return values, passing mechanism
6636 @cindex Parameters, passing mechanism
6637 @findex Mechanism_Code
6639 @code{@var{function}'Mechanism_Code} yields an integer code for the
6640 mechanism used for the result of function, and
6641 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6642 used for formal parameter number @var{n} (a static integer value with 1
6643 meaning the first parameter) of @var{subprogram}. The code returned is:
6651 by descriptor (default descriptor class)
6653 by descriptor (UBS: unaligned bit string)
6655 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6657 by descriptor (UBA: unaligned bit array)
6659 by descriptor (S: string, also scalar access type parameter)
6661 by descriptor (SB: string with arbitrary bounds)
6663 by descriptor (A: contiguous array)
6665 by descriptor (NCA: non-contiguous array)
6669 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6672 @node Null_Parameter
6673 @unnumberedsec Null_Parameter
6674 @cindex Zero address, passing
6675 @findex Null_Parameter
6677 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6678 type or subtype @var{T} allocated at machine address zero. The attribute
6679 is allowed only as the default expression of a formal parameter, or as
6680 an actual expression of a subprogram call. In either case, the
6681 subprogram must be imported.
6683 The identity of the object is represented by the address zero in the
6684 argument list, independent of the passing mechanism (explicit or
6687 This capability is needed to specify that a zero address should be
6688 passed for a record or other composite object passed by reference.
6689 There is no way of indicating this without the @code{Null_Parameter}
6693 @unnumberedsec Object_Size
6694 @cindex Size, used for objects
6697 The size of an object is not necessarily the same as the size of the type
6698 of an object. This is because by default object sizes are increased to be
6699 a multiple of the alignment of the object. For example,
6700 @code{Natural'Size} is
6701 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6702 Similarly, a record containing an integer and a character:
6704 @smallexample @c ada
6712 will have a size of 40 (that is @code{Rec'Size} will be 40). The
6713 alignment will be 4, because of the
6714 integer field, and so the default size of record objects for this type
6715 will be 64 (8 bytes).
6717 @node Passed_By_Reference
6718 @unnumberedsec Passed_By_Reference
6719 @cindex Parameters, when passed by reference
6720 @findex Passed_By_Reference
6722 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6723 a value of type @code{Boolean} value that is @code{True} if the type is
6724 normally passed by reference and @code{False} if the type is normally
6725 passed by copy in calls. For scalar types, the result is always @code{False}
6726 and is static. For non-scalar types, the result is non-static.
6729 @unnumberedsec Pool_Address
6730 @cindex Parameters, when passed by reference
6731 @findex Pool_Address
6733 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6734 of X within its storage pool. This is the same as
6735 @code{@var{X}'Address}, except that for an unconstrained array whose
6736 bounds are allocated just before the first component,
6737 @code{@var{X}'Pool_Address} returns the address of those bounds,
6738 whereas @code{@var{X}'Address} returns the address of the first
6741 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6742 the object is allocated'', which could be a user-defined storage pool,
6743 the global heap, on the stack, or in a static memory area. For an
6744 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6745 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6748 @unnumberedsec Range_Length
6749 @findex Range_Length
6751 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6752 the number of values represented by the subtype (zero for a null
6753 range). The result is static for static subtypes. @code{Range_Length}
6754 applied to the index subtype of a one dimensional array always gives the
6755 same result as @code{Range} applied to the array itself.
6761 The @code{System.Address'Ref}
6762 (@code{System.Address} is the only permissible prefix)
6763 denotes a function identical to
6764 @code{System.Storage_Elements.To_Address} except that
6765 it is a static attribute. See @ref{To_Address} for more details.
6768 @unnumberedsec Result
6771 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6772 for a function. The prefix must be the name of the corresponding function. This
6773 is used to refer to the result of the function in the postcondition expression.
6774 For a further discussion of the use of this attribute and examples of its use,
6775 see the description of pragma Postcondition.
6778 @unnumberedsec Safe_Emax
6779 @cindex Ada 83 attributes
6782 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6783 the Ada 83 reference manual for an exact description of the semantics of
6787 @unnumberedsec Safe_Large
6788 @cindex Ada 83 attributes
6791 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6792 the Ada 83 reference manual for an exact description of the semantics of
6795 @node Scalar_Storage_Order
6796 @unnumberedsec Scalar_Storage_Order
6798 @cindex Scalar storage order
6799 @findex Scalar_Storage_Order
6801 For every array or record type @var{S}, the representation attribute
6802 @code{Scalar_Storage_Order} denotes the order in which storage elements
6803 that make up scalar components are ordered within S. Other properties are
6804 as for standard representation attribute @code{Bit_Order}, as defined by
6805 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
6807 If @code{@var{S}'Scalar_Storage_Order} is specified explicitly, it shall be
6808 equal to @code{@var{S}'Bit_Order}. Note: This means that if a
6809 @code{Scalar_Storage_Order} attribute definition clause is not confirming,
6810 then the type's @code{Bit_Order} shall be specified explicitly and set to
6813 If a component of S has itself a record or array type, then it shall also
6814 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
6815 if the component does not start on a byte boundary, then the scalar storage
6816 order specified for S and for the nested component type shall be identical.
6818 No component of a type that has a @code{Scalar_Storage_Order} attribute
6819 definition may be aliased.
6821 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
6822 with a value equal to @code{System.Default_Bit_Order}) has no effect.
6824 If the opposite storage order is specified, then whenever the value of
6825 a scalar component of S is read, the storage elements of the enclosing
6826 machine scalar are first reversed (before retrieving the component value,
6827 possibly applying some shift and mask operatings on the enclosing machine
6828 scalar), and the opposite operation is done for writes.
6830 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
6831 are relaxed. Instead, the following rules apply:
6834 @item the underlying storage elements are those at positions
6835 @code{(position + first_bit / storage_element_size) ..
6836 (position + (last_bit + storage_element_size - 1) /
6837 storage_element_size)}
6838 @item the sequence of underlying storage elements shall have
6839 a size no greater than the largest machine scalar
6840 @item the enclosing machine scalar is defined as the smallest machine
6841 scalar starting at a position no greater than
6842 @code{position + first_bit / storage_element_size} and covering
6843 storage elements at least up to @code{position + (last_bit +
6844 storage_element_size - 1) / storage_element_size}
6845 @item the position of the component is interpreted relative to that machine
6850 @node Simple_Storage_Pool
6851 @unnumberedsec Simple_Storage_Pool
6852 @cindex Storage pool, simple
6853 @cindex Simple storage pool
6854 @findex Simple_Storage_Pool
6856 For every nonformal, nonderived access-to-object type @var{Acc}, the
6857 representation attribute @code{Simple_Storage_Pool} may be specified
6858 via an attribute_definition_clause (or by specifying the equivalent aspect):
6860 @smallexample @c ada
6862 My_Pool : My_Simple_Storage_Pool_Type;
6864 type Acc is access My_Data_Type;
6866 for Acc'Simple_Storage_Pool use My_Pool;
6871 The name given in an attribute_definition_clause for the
6872 @code{Simple_Storage_Pool} attribute shall denote a variable of
6873 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
6875 The use of this attribute is only allowed for a prefix denoting a type
6876 for which it has been specified. The type of the attribute is the type
6877 of the variable specified as the simple storage pool of the access type,
6878 and the attribute denotes that variable.
6880 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
6881 for the same access type.
6883 If the @code{Simple_Storage_Pool} attribute has been specified for an access
6884 type, then applying the @code{Storage_Pool} attribute to the type is flagged
6885 with a warning and its evaluation raises the exception @code{Program_Error}.
6887 If the Simple_Storage_Pool attribute has been specified for an access
6888 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
6889 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
6890 which is intended to indicate the number of storage elements reserved for
6891 the simple storage pool. If the Storage_Size function has not been defined
6892 for the simple storage pool type, then this attribute returns zero.
6894 If an access type @var{S} has a specified simple storage pool of type
6895 @var{SSP}, then the evaluation of an allocator for that access type calls
6896 the primitive @code{Allocate} procedure for type @var{SSP}, passing
6897 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
6898 semantics of such allocators is the same as those defined for allocators
6899 in section 13.11 of the Ada Reference Manual, with the term
6900 ``simple storage pool'' substituted for ``storage pool''.
6902 If an access type @var{S} has a specified simple storage pool of type
6903 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
6904 for that access type invokes the primitive @code{Deallocate} procedure
6905 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
6906 parameter. The detailed semantics of such unchecked deallocations is the same
6907 as defined in section 13.11.2 of the Ada Reference Manual, except that the
6908 term ``simple storage pool'' is substituted for ``storage pool''.
6911 @unnumberedsec Small
6912 @cindex Ada 83 attributes
6915 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6917 GNAT also allows this attribute to be applied to floating-point types
6918 for compatibility with Ada 83. See
6919 the Ada 83 reference manual for an exact description of the semantics of
6920 this attribute when applied to floating-point types.
6923 @unnumberedsec Storage_Unit
6924 @findex Storage_Unit
6926 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6927 prefix) provides the same value as @code{System.Storage_Unit}.
6930 @unnumberedsec Stub_Type
6933 The GNAT implementation of remote access-to-classwide types is
6934 organized as described in AARM section E.4 (20.t): a value of an RACW type
6935 (designating a remote object) is represented as a normal access
6936 value, pointing to a "stub" object which in turn contains the
6937 necessary information to contact the designated remote object. A
6938 call on any dispatching operation of such a stub object does the
6939 remote call, if necessary, using the information in the stub object
6940 to locate the target partition, etc.
6942 For a prefix @code{T} that denotes a remote access-to-classwide type,
6943 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6945 By construction, the layout of @code{T'Stub_Type} is identical to that of
6946 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6947 unit @code{System.Partition_Interface}. Use of this attribute will create
6948 an implicit dependency on this unit.
6950 @node System_Allocator_Alignment
6951 @unnumberedsec System_Allocator_Alignment
6952 @cindex Alignment, allocator
6953 @findex System_Allocator_Alignment
6955 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
6956 permissible prefix) provides the observable guaranted to be honored by
6957 the system allocator (malloc). This is a static value that can be used
6958 in user storage pools based on malloc either to reject allocation
6959 with alignment too large or to enable a realignment circuitry if the
6960 alignment request is larger than this value.
6963 @unnumberedsec Target_Name
6966 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6967 prefix) provides a static string value that identifies the target
6968 for the current compilation. For GCC implementations, this is the
6969 standard gcc target name without the terminating slash (for
6970 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6976 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6977 provides the same value as @code{System.Tick},
6980 @unnumberedsec To_Address
6983 The @code{System'To_Address}
6984 (@code{System} is the only permissible prefix)
6985 denotes a function identical to
6986 @code{System.Storage_Elements.To_Address} except that
6987 it is a static attribute. This means that if its argument is
6988 a static expression, then the result of the attribute is a
6989 static expression. The result is that such an expression can be
6990 used in contexts (e.g.@: preelaborable packages) which require a
6991 static expression and where the function call could not be used
6992 (since the function call is always non-static, even if its
6993 argument is static).
6996 @unnumberedsec Type_Class
6999 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
7000 the value of the type class for the full type of @var{type}. If
7001 @var{type} is a generic formal type, the value is the value for the
7002 corresponding actual subtype. The value of this attribute is of type
7003 @code{System.Aux_DEC.Type_Class}, which has the following definition:
7005 @smallexample @c ada
7007 (Type_Class_Enumeration,
7009 Type_Class_Fixed_Point,
7010 Type_Class_Floating_Point,
7015 Type_Class_Address);
7019 Protected types yield the value @code{Type_Class_Task}, which thus
7020 applies to all concurrent types. This attribute is designed to
7021 be compatible with the DEC Ada 83 attribute of the same name.
7024 @unnumberedsec UET_Address
7027 The @code{UET_Address} attribute can only be used for a prefix which
7028 denotes a library package. It yields the address of the unit exception
7029 table when zero cost exception handling is used. This attribute is
7030 intended only for use within the GNAT implementation. See the unit
7031 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
7032 for details on how this attribute is used in the implementation.
7034 @node Unconstrained_Array
7035 @unnumberedsec Unconstrained_Array
7036 @findex Unconstrained_Array
7038 The @code{Unconstrained_Array} attribute can be used with a prefix that
7039 denotes any type or subtype. It is a static attribute that yields
7040 @code{True} if the prefix designates an unconstrained array,
7041 and @code{False} otherwise. In a generic instance, the result is
7042 still static, and yields the result of applying this test to the
7045 @node Universal_Literal_String
7046 @unnumberedsec Universal_Literal_String
7047 @cindex Named numbers, representation of
7048 @findex Universal_Literal_String
7050 The prefix of @code{Universal_Literal_String} must be a named
7051 number. The static result is the string consisting of the characters of
7052 the number as defined in the original source. This allows the user
7053 program to access the actual text of named numbers without intermediate
7054 conversions and without the need to enclose the strings in quotes (which
7055 would preclude their use as numbers).
7057 For example, the following program prints the first 50 digits of pi:
7059 @smallexample @c ada
7060 with Text_IO; use Text_IO;
7064 Put (Ada.Numerics.Pi'Universal_Literal_String);
7068 @node Unrestricted_Access
7069 @unnumberedsec Unrestricted_Access
7070 @cindex @code{Access}, unrestricted
7071 @findex Unrestricted_Access
7073 The @code{Unrestricted_Access} attribute is similar to @code{Access}
7074 except that all accessibility and aliased view checks are omitted. This
7075 is a user-beware attribute. It is similar to
7076 @code{Address}, for which it is a desirable replacement where the value
7077 desired is an access type. In other words, its effect is identical to
7078 first applying the @code{Address} attribute and then doing an unchecked
7079 conversion to a desired access type. In GNAT, but not necessarily in
7080 other implementations, the use of static chains for inner level
7081 subprograms means that @code{Unrestricted_Access} applied to a
7082 subprogram yields a value that can be called as long as the subprogram
7083 is in scope (normal Ada accessibility rules restrict this usage).
7085 It is possible to use @code{Unrestricted_Access} for any type, but care
7086 must be exercised if it is used to create pointers to unconstrained
7087 objects. In this case, the resulting pointer has the same scope as the
7088 context of the attribute, and may not be returned to some enclosing
7089 scope. For instance, a function cannot use @code{Unrestricted_Access}
7090 to create a unconstrained pointer and then return that value to the
7094 @unnumberedsec Valid_Scalars
7095 @findex Valid_Scalars
7097 The @code{'Valid_Scalars} attribute is intended to make it easier to
7098 check the validity of scalar subcomponents of composite objects. It
7099 is defined for any prefix @code{X} that denotes an object.
7100 The value of this attribute is of the predefined type Boolean.
7101 @code{X'Valid_Scalars} yields True if and only if evaluation of
7102 @code{P'Valid} yields True for every scalar part P of X or if X has
7103 no scalar parts. It is not specified in what order the scalar parts
7104 are checked, nor whether any more are checked after any one of them
7105 is determined to be invalid. If the prefix @code{X} is of a class-wide
7106 type @code{T'Class} (where @code{T} is the associated specific type),
7107 or if the prefix @code{X} is of a specific tagged type @code{T}, then
7108 only the scalar parts of components of @code{T} are traversed; in other
7109 words, components of extensions of @code{T} are not traversed even if
7110 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
7111 be determined at compile time that the prefix of the attribute has no
7112 scalar parts (e.g., if the prefix is of an access type, an interface type,
7113 an undiscriminated task type, or an undiscriminated protected type).
7116 @unnumberedsec VADS_Size
7117 @cindex @code{Size}, VADS compatibility
7120 The @code{'VADS_Size} attribute is intended to make it easier to port
7121 legacy code which relies on the semantics of @code{'Size} as implemented
7122 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
7123 same semantic interpretation. In particular, @code{'VADS_Size} applied
7124 to a predefined or other primitive type with no Size clause yields the
7125 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
7126 typical machines). In addition @code{'VADS_Size} applied to an object
7127 gives the result that would be obtained by applying the attribute to
7128 the corresponding type.
7131 @unnumberedsec Value_Size
7132 @cindex @code{Size}, setting for not-first subtype
7134 @code{@var{type}'Value_Size} is the number of bits required to represent
7135 a value of the given subtype. It is the same as @code{@var{type}'Size},
7136 but, unlike @code{Size}, may be set for non-first subtypes.
7139 @unnumberedsec Wchar_T_Size
7140 @findex Wchar_T_Size
7141 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
7142 prefix) provides the size in bits of the C @code{wchar_t} type
7143 primarily for constructing the definition of this type in
7144 package @code{Interfaces.C}.
7147 @unnumberedsec Word_Size
7149 @code{Standard'Word_Size} (@code{Standard} is the only permissible
7150 prefix) provides the value @code{System.Word_Size}.
7152 @node Standard and Implementation Defined Restrictions
7153 @chapter Standard and Implementation Defined Restrictions
7156 All RM defined Restriction identifiers are implemented:
7159 @item language-defined restrictions (see 13.12.1)
7160 @item tasking restrictions (see D.7)
7161 @item high integrity restrictions (see H.4)
7165 GNAT implements additional restriction identifiers. All restrictions, whether
7166 language defined or GNAT-specific, are listed in the following.
7169 * Partition-Wide Restrictions::
7170 * Program Unit Level Restrictions::
7173 @node Partition-Wide Restrictions
7174 @section Partition-Wide Restrictions
7176 There are two separate lists of restriction identifiers. The first
7177 set requires consistency throughout a partition (in other words, if the
7178 restriction identifier is used for any compilation unit in the partition,
7179 then all compilation units in the partition must obey the restriction).
7182 * Immediate_Reclamation::
7183 * Max_Asynchronous_Select_Nesting::
7184 * Max_Entry_Queue_Length::
7185 * Max_Protected_Entries::
7186 * Max_Select_Alternatives::
7187 * Max_Storage_At_Blocking::
7188 * Max_Task_Entries::
7190 * No_Abort_Statements::
7191 * No_Access_Parameter_Allocators::
7192 * No_Access_Subprograms::
7194 * No_Anonymous_Allocators::
7197 * No_Default_Initialization::
7200 * No_Direct_Boolean_Operators::
7202 * No_Dispatching_Calls::
7203 * No_Dynamic_Attachment::
7204 * No_Dynamic_Priorities::
7205 * No_Entry_Calls_In_Elaboration_Code::
7206 * No_Enumeration_Maps::
7207 * No_Exception_Handlers::
7208 * No_Exception_Propagation::
7209 * No_Exception_Registration::
7213 * No_Floating_Point::
7214 * No_Implicit_Conditionals::
7215 * No_Implicit_Dynamic_Code::
7216 * No_Implicit_Heap_Allocations::
7217 * No_Implicit_Loops::
7218 * No_Initialize_Scalars::
7220 * No_Local_Allocators::
7221 * No_Local_Protected_Objects::
7222 * No_Local_Timing_Events::
7223 * No_Nested_Finalization::
7224 * No_Protected_Type_Allocators::
7225 * No_Protected_Types::
7228 * No_Relative_Delay::
7229 * No_Requeue_Statements::
7230 * No_Secondary_Stack::
7231 * No_Select_Statements::
7232 * No_Specific_Termination_Handlers::
7233 * No_Specification_of_Aspect::
7234 * No_Standard_Allocators_After_Elaboration::
7235 * No_Standard_Storage_Pools::
7236 * No_Stream_Optimizations::
7238 * No_Task_Allocators::
7239 * No_Task_Attributes_Package::
7240 * No_Task_Hierarchy::
7241 * No_Task_Termination::
7243 * No_Terminate_Alternatives::
7244 * No_Unchecked_Access::
7246 * Static_Priorities::
7247 * Static_Storage_Size::
7250 @node Immediate_Reclamation
7251 @unnumberedsubsec Immediate_Reclamation
7252 @findex Immediate_Reclamation
7253 [RM H.4] This restriction ensures that, except for storage occupied by
7254 objects created by allocators and not deallocated via unchecked
7255 deallocation, any storage reserved at run time for an object is
7256 immediately reclaimed when the object no longer exists.
7258 @node Max_Asynchronous_Select_Nesting
7259 @unnumberedsubsec Max_Asynchronous_Select_Nesting
7260 @findex Max_Asynchronous_Select_Nesting
7261 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
7262 selects. Violations of this restriction with a value of zero are
7263 detected at compile time. Violations of this restriction with values
7264 other than zero cause Storage_Error to be raised.
7266 @node Max_Entry_Queue_Length
7267 @unnumberedsubsec Max_Entry_Queue_Length
7268 @findex Max_Entry_Queue_Length
7269 [RM D.7] This restriction is a declaration that any protected entry compiled in
7270 the scope of the restriction has at most the specified number of
7271 tasks waiting on the entry at any one time, and so no queue is required.
7272 Note that this restriction is checked at run time. Violation of this
7273 restriction results in the raising of Program_Error exception at the point of
7276 @node Max_Protected_Entries
7277 @unnumberedsubsec Max_Protected_Entries
7278 @findex Max_Protected_Entries
7279 [RM D.7] Specifies the maximum number of entries per protected type. The
7280 bounds of every entry family of a protected unit shall be static, or shall be
7281 defined by a discriminant of a subtype whose corresponding bound is static.
7283 @node Max_Select_Alternatives
7284 @unnumberedsubsec Max_Select_Alternatives
7285 @findex Max_Select_Alternatives
7286 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
7288 @node Max_Storage_At_Blocking
7289 @unnumberedsubsec Max_Storage_At_Blocking
7290 @findex Max_Storage_At_Blocking
7291 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
7292 Storage_Size that can be retained by a blocked task. A violation of this
7293 restriction causes Storage_Error to be raised.
7295 @node Max_Task_Entries
7296 @unnumberedsubsec Max_Task_Entries
7297 @findex Max_Task_Entries
7298 [RM D.7] Specifies the maximum number of entries
7299 per task. The bounds of every entry family
7300 of a task unit shall be static, or shall be
7301 defined by a discriminant of a subtype whose
7302 corresponding bound is static.
7305 @unnumberedsubsec Max_Tasks
7307 [RM D.7] Specifies the maximum number of task that may be created, not
7308 counting the creation of the environment task. Violations of this
7309 restriction with a value of zero are detected at compile
7310 time. Violations of this restriction with values other than zero cause
7311 Storage_Error to be raised.
7313 @node No_Abort_Statements
7314 @unnumberedsubsec No_Abort_Statements
7315 @findex No_Abort_Statements
7316 [RM D.7] There are no abort_statements, and there are
7317 no calls to Task_Identification.Abort_Task.
7319 @node No_Access_Parameter_Allocators
7320 @unnumberedsubsec No_Access_Parameter_Allocators
7321 @findex No_Access_Parameter_Allocators
7322 [RM H.4] This restriction ensures at compile time that there are no
7323 occurrences of an allocator as the actual parameter to an access
7326 @node No_Access_Subprograms
7327 @unnumberedsubsec No_Access_Subprograms
7328 @findex No_Access_Subprograms
7329 [RM H.4] This restriction ensures at compile time that there are no
7330 declarations of access-to-subprogram types.
7333 @unnumberedsubsec No_Allocators
7334 @findex No_Allocators
7335 [RM H.4] This restriction ensures at compile time that there are no
7336 occurrences of an allocator.
7338 @node No_Anonymous_Allocators
7339 @unnumberedsubsec No_Anonymous_Allocators
7340 @findex No_Anonymous_Allocators
7341 [RM H.4] This restriction ensures at compile time that there are no
7342 occurrences of an allocator of anonymous access type.
7345 @unnumberedsubsec No_Calendar
7347 [GNAT] This restriction ensures at compile time that there is no implicit or
7348 explicit dependence on the package @code{Ada.Calendar}.
7350 @node No_Coextensions
7351 @unnumberedsubsec No_Coextensions
7352 @findex No_Coextensions
7353 [RM H.4] This restriction ensures at compile time that there are no
7354 coextensions. See 3.10.2.
7356 @node No_Default_Initialization
7357 @unnumberedsubsec No_Default_Initialization
7358 @findex No_Default_Initialization
7360 [GNAT] This restriction prohibits any instance of default initialization
7361 of variables. The binder implements a consistency rule which prevents
7362 any unit compiled without the restriction from with'ing a unit with the
7363 restriction (this allows the generation of initialization procedures to
7364 be skipped, since you can be sure that no call is ever generated to an
7365 initialization procedure in a unit with the restriction active). If used
7366 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
7367 is to prohibit all cases of variables declared without a specific
7368 initializer (including the case of OUT scalar parameters).
7371 @unnumberedsubsec No_Delay
7373 [RM H.4] This restriction ensures at compile time that there are no
7374 delay statements and no dependences on package Calendar.
7377 @unnumberedsubsec No_Dependence
7378 @findex No_Dependence
7379 [RM 13.12.1] This restriction checks at compile time that there are no
7380 dependence on a library unit.
7382 @node No_Direct_Boolean_Operators
7383 @unnumberedsubsec No_Direct_Boolean_Operators
7384 @findex No_Direct_Boolean_Operators
7385 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
7386 operands of type Boolean (or any type derived
7387 from Boolean). This is intended for use in safety critical programs
7388 where the certification protocol requires the use of short-circuit
7389 (and then, or else) forms for all composite boolean operations.
7392 @unnumberedsubsec No_Dispatch
7394 [RM H.4] This restriction ensures at compile time that there are no
7395 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
7397 @node No_Dispatching_Calls
7398 @unnumberedsubsec No_Dispatching_Calls
7399 @findex No_Dispatching_Calls
7400 [GNAT] This restriction ensures at compile time that the code generated by the
7401 compiler involves no dispatching calls. The use of this restriction allows the
7402 safe use of record extensions, classwide membership tests and other classwide
7403 features not involving implicit dispatching. This restriction ensures that
7404 the code contains no indirect calls through a dispatching mechanism. Note that
7405 this includes internally-generated calls created by the compiler, for example
7406 in the implementation of class-wide objects assignments. The
7407 membership test is allowed in the presence of this restriction, because its
7408 implementation requires no dispatching.
7409 This restriction is comparable to the official Ada restriction
7410 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7411 all classwide constructs that do not imply dispatching.
7412 The following example indicates constructs that violate this restriction.
7416 type T is tagged record
7419 procedure P (X : T);
7421 type DT is new T with record
7422 More_Data : Natural;
7424 procedure Q (X : DT);
7428 procedure Example is
7429 procedure Test (O : T'Class) is
7430 N : Natural := O'Size;-- Error: Dispatching call
7431 C : T'Class := O; -- Error: implicit Dispatching Call
7433 if O in DT'Class then -- OK : Membership test
7434 Q (DT (O)); -- OK : Type conversion plus direct call
7436 P (O); -- Error: Dispatching call
7442 P (Obj); -- OK : Direct call
7443 P (T (Obj)); -- OK : Type conversion plus direct call
7444 P (T'Class (Obj)); -- Error: Dispatching call
7446 Test (Obj); -- OK : Type conversion
7448 if Obj in T'Class then -- OK : Membership test
7454 @node No_Dynamic_Attachment
7455 @unnumberedsubsec No_Dynamic_Attachment
7456 @findex No_Dynamic_Attachment
7457 [RM D.7] This restriction ensures that there is no call to any of the
7458 operations defined in package Ada.Interrupts
7459 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
7460 Detach_Handler, and Reference).
7462 @node No_Dynamic_Priorities
7463 @unnumberedsubsec No_Dynamic_Priorities
7464 @findex No_Dynamic_Priorities
7465 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
7467 @node No_Entry_Calls_In_Elaboration_Code
7468 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
7469 @findex No_Entry_Calls_In_Elaboration_Code
7470 [GNAT] This restriction ensures at compile time that no task or protected entry
7471 calls are made during elaboration code. As a result of the use of this
7472 restriction, the compiler can assume that no code past an accept statement
7473 in a task can be executed at elaboration time.
7475 @node No_Enumeration_Maps
7476 @unnumberedsubsec No_Enumeration_Maps
7477 @findex No_Enumeration_Maps
7478 [GNAT] This restriction ensures at compile time that no operations requiring
7479 enumeration maps are used (that is Image and Value attributes applied
7480 to enumeration types).
7482 @node No_Exception_Handlers
7483 @unnumberedsubsec No_Exception_Handlers
7484 @findex No_Exception_Handlers
7485 [GNAT] This restriction ensures at compile time that there are no explicit
7486 exception handlers. It also indicates that no exception propagation will
7487 be provided. In this mode, exceptions may be raised but will result in
7488 an immediate call to the last chance handler, a routine that the user
7489 must define with the following profile:
7491 @smallexample @c ada
7492 procedure Last_Chance_Handler
7493 (Source_Location : System.Address; Line : Integer);
7494 pragma Export (C, Last_Chance_Handler,
7495 "__gnat_last_chance_handler");
7498 The parameter is a C null-terminated string representing a message to be
7499 associated with the exception (typically the source location of the raise
7500 statement generated by the compiler). The Line parameter when nonzero
7501 represents the line number in the source program where the raise occurs.
7503 @node No_Exception_Propagation
7504 @unnumberedsubsec No_Exception_Propagation
7505 @findex No_Exception_Propagation
7506 [GNAT] This restriction guarantees that exceptions are never propagated
7507 to an outer subprogram scope. The only case in which an exception may
7508 be raised is when the handler is statically in the same subprogram, so
7509 that the effect of a raise is essentially like a goto statement. Any
7510 other raise statement (implicit or explicit) will be considered
7511 unhandled. Exception handlers are allowed, but may not contain an
7512 exception occurrence identifier (exception choice). In addition, use of
7513 the package GNAT.Current_Exception is not permitted, and reraise
7514 statements (raise with no operand) are not permitted.
7516 @node No_Exception_Registration
7517 @unnumberedsubsec No_Exception_Registration
7518 @findex No_Exception_Registration
7519 [GNAT] This restriction ensures at compile time that no stream operations for
7520 types Exception_Id or Exception_Occurrence are used. This also makes it
7521 impossible to pass exceptions to or from a partition with this restriction
7522 in a distributed environment. If this exception is active, then the generated
7523 code is simplified by omitting the otherwise-required global registration
7524 of exceptions when they are declared.
7527 @unnumberedsubsec No_Exceptions
7528 @findex No_Exceptions
7529 [RM H.4] This restriction ensures at compile time that there are no
7530 raise statements and no exception handlers.
7532 @node No_Finalization
7533 @unnumberedsubsec No_Finalization
7534 @findex No_Finalization
7535 [GNAT] This restriction disables the language features described in
7536 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
7537 performed by the compiler to support these features. The following types
7538 are no longer considered controlled when this restriction is in effect:
7541 @code{Ada.Finalization.Controlled}
7543 @code{Ada.Finalization.Limited_Controlled}
7545 Derivations from @code{Controlled} or @code{Limited_Controlled}
7553 Array and record types with controlled components
7555 The compiler no longer generates code to initialize, finalize or adjust an
7556 object or a nested component, either declared on the stack or on the heap. The
7557 deallocation of a controlled object no longer finalizes its contents.
7559 @node No_Fixed_Point
7560 @unnumberedsubsec No_Fixed_Point
7561 @findex No_Fixed_Point
7562 [RM H.4] This restriction ensures at compile time that there are no
7563 occurrences of fixed point types and operations.
7565 @node No_Floating_Point
7566 @unnumberedsubsec No_Floating_Point
7567 @findex No_Floating_Point
7568 [RM H.4] This restriction ensures at compile time that there are no
7569 occurrences of floating point types and operations.
7571 @node No_Implicit_Conditionals
7572 @unnumberedsubsec No_Implicit_Conditionals
7573 @findex No_Implicit_Conditionals
7574 [GNAT] This restriction ensures that the generated code does not contain any
7575 implicit conditionals, either by modifying the generated code where possible,
7576 or by rejecting any construct that would otherwise generate an implicit
7577 conditional. Note that this check does not include run time constraint
7578 checks, which on some targets may generate implicit conditionals as
7579 well. To control the latter, constraint checks can be suppressed in the
7580 normal manner. Constructs generating implicit conditionals include comparisons
7581 of composite objects and the Max/Min attributes.
7583 @node No_Implicit_Dynamic_Code
7584 @unnumberedsubsec No_Implicit_Dynamic_Code
7585 @findex No_Implicit_Dynamic_Code
7587 [GNAT] This restriction prevents the compiler from building ``trampolines''.
7588 This is a structure that is built on the stack and contains dynamic
7589 code to be executed at run time. On some targets, a trampoline is
7590 built for the following features: @code{Access},
7591 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
7592 nested task bodies; primitive operations of nested tagged types.
7593 Trampolines do not work on machines that prevent execution of stack
7594 data. For example, on windows systems, enabling DEP (data execution
7595 protection) will cause trampolines to raise an exception.
7596 Trampolines are also quite slow at run time.
7598 On many targets, trampolines have been largely eliminated. Look at the
7599 version of system.ads for your target --- if it has
7600 Always_Compatible_Rep equal to False, then trampolines are largely
7601 eliminated. In particular, a trampoline is built for the following
7602 features: @code{Address} of a nested subprogram;
7603 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
7604 but only if pragma Favor_Top_Level applies, or the access type has a
7605 foreign-language convention; primitive operations of nested tagged
7608 @node No_Implicit_Heap_Allocations
7609 @unnumberedsubsec No_Implicit_Heap_Allocations
7610 @findex No_Implicit_Heap_Allocations
7611 [RM D.7] No constructs are allowed to cause implicit heap allocation.
7613 @node No_Implicit_Loops
7614 @unnumberedsubsec No_Implicit_Loops
7615 @findex No_Implicit_Loops
7616 [GNAT] This restriction ensures that the generated code does not contain any
7617 implicit @code{for} loops, either by modifying
7618 the generated code where possible,
7619 or by rejecting any construct that would otherwise generate an implicit
7620 @code{for} loop. If this restriction is active, it is possible to build
7621 large array aggregates with all static components without generating an
7622 intermediate temporary, and without generating a loop to initialize individual
7623 components. Otherwise, a loop is created for arrays larger than about 5000
7626 @node No_Initialize_Scalars
7627 @unnumberedsubsec No_Initialize_Scalars
7628 @findex No_Initialize_Scalars
7629 [GNAT] This restriction ensures that no unit in the partition is compiled with
7630 pragma Initialize_Scalars. This allows the generation of more efficient
7631 code, and in particular eliminates dummy null initialization routines that
7632 are otherwise generated for some record and array types.
7635 @unnumberedsubsec No_IO
7637 [RM H.4] This restriction ensures at compile time that there are no
7638 dependences on any of the library units Sequential_IO, Direct_IO,
7639 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
7641 @node No_Local_Allocators
7642 @unnumberedsubsec No_Local_Allocators
7643 @findex No_Local_Allocators
7644 [RM H.4] This restriction ensures at compile time that there are no
7645 occurrences of an allocator in subprograms, generic subprograms, tasks,
7648 @node No_Local_Protected_Objects
7649 @unnumberedsubsec No_Local_Protected_Objects
7650 @findex No_Local_Protected_Objects
7651 [RM D.7] This restriction ensures at compile time that protected objects are
7652 only declared at the library level.
7654 @node No_Local_Timing_Events
7655 @unnumberedsubsec No_Local_Timing_Events
7656 @findex No_Local_Timing_Events
7657 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
7658 declared at the library level.
7660 @node No_Nested_Finalization
7661 @unnumberedsubsec No_Nested_Finalization
7662 @findex No_Nested_Finalization
7663 [RM D.7] All objects requiring finalization are declared at the library level.
7665 @node No_Protected_Type_Allocators
7666 @unnumberedsubsec No_Protected_Type_Allocators
7667 @findex No_Protected_Type_Allocators
7668 [RM D.7] This restriction ensures at compile time that there are no allocator
7669 expressions that attempt to allocate protected objects.
7671 @node No_Protected_Types
7672 @unnumberedsubsec No_Protected_Types
7673 @findex No_Protected_Types
7674 [RM H.4] This restriction ensures at compile time that there are no
7675 declarations of protected types or protected objects.
7678 @unnumberedsubsec No_Recursion
7679 @findex No_Recursion
7680 [RM H.4] A program execution is erroneous if a subprogram is invoked as
7681 part of its execution.
7684 @unnumberedsubsec No_Reentrancy
7685 @findex No_Reentrancy
7686 [RM H.4] A program execution is erroneous if a subprogram is executed by
7687 two tasks at the same time.
7689 @node No_Relative_Delay
7690 @unnumberedsubsec No_Relative_Delay
7691 @findex No_Relative_Delay
7692 [RM D.7] This restriction ensures at compile time that there are no delay
7693 relative statements and prevents expressions such as @code{delay 1.23;} from
7694 appearing in source code.
7696 @node No_Requeue_Statements
7697 @unnumberedsubsec No_Requeue_Statements
7698 @findex No_Requeue_Statements
7699 [RM D.7] This restriction ensures at compile time that no requeue statements
7700 are permitted and prevents keyword @code{requeue} from being used in source
7703 @node No_Secondary_Stack
7704 @unnumberedsubsec No_Secondary_Stack
7705 @findex No_Secondary_Stack
7706 [GNAT] This restriction ensures at compile time that the generated code
7707 does not contain any reference to the secondary stack. The secondary
7708 stack is used to implement functions returning unconstrained objects
7709 (arrays or records) on some targets.
7711 @node No_Select_Statements
7712 @unnumberedsubsec No_Select_Statements
7713 @findex No_Select_Statements
7714 [RM D.7] This restriction ensures at compile time no select statements of any
7715 kind are permitted, that is the keyword @code{select} may not appear.
7717 @node No_Specific_Termination_Handlers
7718 @unnumberedsubsec No_Specific_Termination_Handlers
7719 @findex No_Specific_Termination_Handlers
7720 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
7721 or to Ada.Task_Termination.Specific_Handler.
7723 @node No_Specification_of_Aspect
7724 @unnumberedsubsec No_Specification_of_Aspect
7725 @findex No_Specification_of_Aspect
7726 [RM 13.12.1] This restriction checks at compile time that no aspect
7727 specification, attribute definition clause, or pragma is given for a
7730 @node No_Standard_Allocators_After_Elaboration
7731 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
7732 @findex No_Standard_Allocators_After_Elaboration
7733 [RM D.7] Specifies that an allocator using a standard storage pool
7734 should never be evaluated at run time after the elaboration of the
7735 library items of the partition has completed. Otherwise, Storage_Error
7738 @node No_Standard_Storage_Pools
7739 @unnumberedsubsec No_Standard_Storage_Pools
7740 @findex No_Standard_Storage_Pools
7741 [GNAT] This restriction ensures at compile time that no access types
7742 use the standard default storage pool. Any access type declared must
7743 have an explicit Storage_Pool attribute defined specifying a
7744 user-defined storage pool.
7746 @node No_Stream_Optimizations
7747 @unnumberedsubsec No_Stream_Optimizations
7748 @findex No_Stream_Optimizations
7749 [GNAT] This restriction affects the performance of stream operations on types
7750 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
7751 compiler uses block reads and writes when manipulating @code{String} objects
7752 due to their supperior performance. When this restriction is in effect, the
7753 compiler performs all IO operations on a per-character basis.
7756 @unnumberedsubsec No_Streams
7758 [GNAT] This restriction ensures at compile/bind time that there are no
7759 stream objects created and no use of stream attributes.
7760 This restriction does not forbid dependences on the package
7761 @code{Ada.Streams}. So it is permissible to with
7762 @code{Ada.Streams} (or another package that does so itself)
7763 as long as no actual stream objects are created and no
7764 stream attributes are used.
7766 Note that the use of restriction allows optimization of tagged types,
7767 since they do not need to worry about dispatching stream operations.
7768 To take maximum advantage of this space-saving optimization, any
7769 unit declaring a tagged type should be compiled with the restriction,
7770 though this is not required.
7772 @node No_Task_Allocators
7773 @unnumberedsubsec No_Task_Allocators
7774 @findex No_Task_Allocators
7775 [RM D.7] There are no allocators for task types
7776 or types containing task subcomponents.
7778 @node No_Task_Attributes_Package
7779 @unnumberedsubsec No_Task_Attributes_Package
7780 @findex No_Task_Attributes_Package
7781 [GNAT] This restriction ensures at compile time that there are no implicit or
7782 explicit dependencies on the package @code{Ada.Task_Attributes}.
7784 @node No_Task_Hierarchy
7785 @unnumberedsubsec No_Task_Hierarchy
7786 @findex No_Task_Hierarchy
7787 [RM D.7] All (non-environment) tasks depend
7788 directly on the environment task of the partition.
7790 @node No_Task_Termination
7791 @unnumberedsubsec No_Task_Termination
7792 @findex No_Task_Termination
7793 [RM D.7] Tasks which terminate are erroneous.
7796 @unnumberedsubsec No_Tasking
7798 [GNAT] This restriction prevents the declaration of tasks or task types
7799 throughout the partition. It is similar in effect to the use of
7800 @code{Max_Tasks => 0} except that violations are caught at compile time
7801 and cause an error message to be output either by the compiler or
7804 @node No_Terminate_Alternatives
7805 @unnumberedsubsec No_Terminate_Alternatives
7806 @findex No_Terminate_Alternatives
7807 [RM D.7] There are no selective accepts with terminate alternatives.
7809 @node No_Unchecked_Access
7810 @unnumberedsubsec No_Unchecked_Access
7811 @findex No_Unchecked_Access
7812 [RM H.4] This restriction ensures at compile time that there are no
7813 occurrences of the Unchecked_Access attribute.
7815 @node Simple_Barriers
7816 @unnumberedsubsec Simple_Barriers
7817 @findex Simple_Barriers
7818 [RM D.7] This restriction ensures at compile time that barriers in entry
7819 declarations for protected types are restricted to either static boolean
7820 expressions or references to simple boolean variables defined in the private
7821 part of the protected type. No other form of entry barriers is permitted.
7823 @node Static_Priorities
7824 @unnumberedsubsec Static_Priorities
7825 @findex Static_Priorities
7826 [GNAT] This restriction ensures at compile time that all priority expressions
7827 are static, and that there are no dependences on the package
7828 @code{Ada.Dynamic_Priorities}.
7830 @node Static_Storage_Size
7831 @unnumberedsubsec Static_Storage_Size
7832 @findex Static_Storage_Size
7833 [GNAT] This restriction ensures at compile time that any expression appearing
7834 in a Storage_Size pragma or attribute definition clause is static.
7836 @node Program Unit Level Restrictions
7837 @section Program Unit Level Restrictions
7840 The second set of restriction identifiers
7841 does not require partition-wide consistency.
7842 The restriction may be enforced for a single
7843 compilation unit without any effect on any of the
7844 other compilation units in the partition.
7847 * No_Elaboration_Code::
7849 * No_Implementation_Aspect_Specifications::
7850 * No_Implementation_Attributes::
7851 * No_Implementation_Identifiers::
7852 * No_Implementation_Pragmas::
7853 * No_Implementation_Restrictions::
7854 * No_Implementation_Units::
7855 * No_Implicit_Aliasing::
7856 * No_Obsolescent_Features::
7857 * No_Wide_Characters::
7861 @node No_Elaboration_Code
7862 @unnumberedsubsec No_Elaboration_Code
7863 @findex No_Elaboration_Code
7864 [GNAT] This restriction ensures at compile time that no elaboration code is
7865 generated. Note that this is not the same condition as is enforced
7866 by pragma @code{Preelaborate}. There are cases in which pragma
7867 @code{Preelaborate} still permits code to be generated (e.g.@: code
7868 to initialize a large array to all zeroes), and there are cases of units
7869 which do not meet the requirements for pragma @code{Preelaborate},
7870 but for which no elaboration code is generated. Generally, it is
7871 the case that preelaborable units will meet the restrictions, with
7872 the exception of large aggregates initialized with an others_clause,
7873 and exception declarations (which generate calls to a run-time
7874 registry procedure). This restriction is enforced on
7875 a unit by unit basis, it need not be obeyed consistently
7876 throughout a partition.
7878 In the case of aggregates with others, if the aggregate has a dynamic
7879 size, there is no way to eliminate the elaboration code (such dynamic
7880 bounds would be incompatible with @code{Preelaborate} in any case). If
7881 the bounds are static, then use of this restriction actually modifies
7882 the code choice of the compiler to avoid generating a loop, and instead
7883 generate the aggregate statically if possible, no matter how many times
7884 the data for the others clause must be repeatedly generated.
7886 It is not possible to precisely document
7887 the constructs which are compatible with this restriction, since,
7888 unlike most other restrictions, this is not a restriction on the
7889 source code, but a restriction on the generated object code. For
7890 example, if the source contains a declaration:
7893 Val : constant Integer := X;
7897 where X is not a static constant, it may be possible, depending
7898 on complex optimization circuitry, for the compiler to figure
7899 out the value of X at compile time, in which case this initialization
7900 can be done by the loader, and requires no initialization code. It
7901 is not possible to document the precise conditions under which the
7902 optimizer can figure this out.
7904 Note that this the implementation of this restriction requires full
7905 code generation. If it is used in conjunction with "semantics only"
7906 checking, then some cases of violations may be missed.
7908 @node No_Entry_Queue
7909 @unnumberedsubsec No_Entry_Queue
7910 @findex No_Entry_Queue
7911 [GNAT] This restriction is a declaration that any protected entry compiled in
7912 the scope of the restriction has at most one task waiting on the entry
7913 at any one time, and so no queue is required. This restriction is not
7914 checked at compile time. A program execution is erroneous if an attempt
7915 is made to queue a second task on such an entry.
7917 @node No_Implementation_Aspect_Specifications
7918 @unnumberedsubsec No_Implementation_Aspect_Specifications
7919 @findex No_Implementation_Aspect_Specifications
7920 [RM 13.12.1] This restriction checks at compile time that no
7921 GNAT-defined aspects are present. With this restriction, the only
7922 aspects that can be used are those defined in the Ada Reference Manual.
7924 @node No_Implementation_Attributes
7925 @unnumberedsubsec No_Implementation_Attributes
7926 @findex No_Implementation_Attributes
7927 [RM 13.12.1] This restriction checks at compile time that no
7928 GNAT-defined attributes are present. With this restriction, the only
7929 attributes that can be used are those defined in the Ada Reference
7932 @node No_Implementation_Identifiers
7933 @unnumberedsubsec No_Implementation_Identifiers
7934 @findex No_Implementation_Identifiers
7935 [RM 13.12.1] This restriction checks at compile time that no
7936 implementation-defined identifiers occur within language-defined
7939 @node No_Implementation_Pragmas
7940 @unnumberedsubsec No_Implementation_Pragmas
7941 @findex No_Implementation_Pragmas
7942 [RM 13.12.1] This restriction checks at compile time that no
7943 GNAT-defined pragmas are present. With this restriction, the only
7944 pragmas that can be used are those defined in the Ada Reference Manual.
7946 @node No_Implementation_Restrictions
7947 @unnumberedsubsec No_Implementation_Restrictions
7948 @findex No_Implementation_Restrictions
7949 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
7950 identifiers (other than @code{No_Implementation_Restrictions} itself)
7951 are present. With this restriction, the only other restriction identifiers
7952 that can be used are those defined in the Ada Reference Manual.
7954 @node No_Implementation_Units
7955 @unnumberedsubsec No_Implementation_Units
7956 @findex No_Implementation_Units
7957 [RM 13.12.1] This restriction checks at compile time that there is no
7958 mention in the context clause of any implementation-defined descendants
7959 of packages Ada, Interfaces, or System.
7961 @node No_Implicit_Aliasing
7962 @unnumberedsubsec No_Implicit_Aliasing
7963 @findex No_Implicit_Aliasing
7964 [GNAT] This restriction, which is not required to be partition-wide consistent,
7965 requires an explicit aliased keyword for an object to which 'Access,
7966 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
7967 the 'Unrestricted_Access attribute for objects. Note: the reason that
7968 Unrestricted_Access is forbidden is that it would require the prefix
7969 to be aliased, and in such cases, it can always be replaced by
7970 the standard attribute Unchecked_Access which is preferable.
7972 @node No_Obsolescent_Features
7973 @unnumberedsubsec No_Obsolescent_Features
7974 @findex No_Obsolescent_Features
7975 [RM 13.12.1] This restriction checks at compile time that no obsolescent
7976 features are used, as defined in Annex J of the Ada Reference Manual.
7978 @node No_Wide_Characters
7979 @unnumberedsubsec No_Wide_Characters
7980 @findex No_Wide_Characters
7981 [GNAT] This restriction ensures at compile time that no uses of the types
7982 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7984 appear, and that no wide or wide wide string or character literals
7985 appear in the program (that is literals representing characters not in
7986 type @code{Character}).
7989 @unnumberedsubsec SPARK
7991 [GNAT] This restriction checks at compile time that some constructs
7992 forbidden in SPARK are not present. The SPARK version used as a
7993 reference is the same as the Ada mode for the unit, so a unit compiled
7994 in Ada 95 mode with SPARK restrictions will be checked for constructs
7995 forbidden in SPARK 95. Error messages related to SPARK restriction have
7999 violation of restriction "SPARK" at <file>
8003 This is not a replacement for the semantic checks performed by the
8004 SPARK Examiner tool, as the compiler only deals currently with code,
8005 not at all with SPARK annotations and does not guarantee catching all
8006 cases of constructs forbidden by SPARK.
8008 Thus it may well be the case that code which
8009 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
8010 e.g. due to the different visibility rules of the Examiner based on
8011 SPARK @code{inherit} annotations.
8013 This restriction can be useful in providing an initial filter for
8014 code developed using SPARK, or in examining legacy code to see how far
8015 it is from meeting SPARK restrictions.
8017 @c ------------------------
8018 @node Implementation Advice
8019 @chapter Implementation Advice
8021 The main text of the Ada Reference Manual describes the required
8022 behavior of all Ada compilers, and the GNAT compiler conforms to
8025 In addition, there are sections throughout the Ada Reference Manual headed
8026 by the phrase ``Implementation advice''. These sections are not normative,
8027 i.e., they do not specify requirements that all compilers must
8028 follow. Rather they provide advice on generally desirable behavior. You
8029 may wonder why they are not requirements. The most typical answer is
8030 that they describe behavior that seems generally desirable, but cannot
8031 be provided on all systems, or which may be undesirable on some systems.
8033 As far as practical, GNAT follows the implementation advice sections in
8034 the Ada Reference Manual. This chapter contains a table giving the
8035 reference manual section number, paragraph number and several keywords
8036 for each advice. Each entry consists of the text of the advice followed
8037 by the GNAT interpretation of this advice. Most often, this simply says
8038 ``followed'', which means that GNAT follows the advice. However, in a
8039 number of cases, GNAT deliberately deviates from this advice, in which
8040 case the text describes what GNAT does and why.
8042 @cindex Error detection
8043 @unnumberedsec 1.1.3(20): Error Detection
8046 If an implementation detects the use of an unsupported Specialized Needs
8047 Annex feature at run time, it should raise @code{Program_Error} if
8050 Not relevant. All specialized needs annex features are either supported,
8051 or diagnosed at compile time.
8054 @unnumberedsec 1.1.3(31): Child Units
8057 If an implementation wishes to provide implementation-defined
8058 extensions to the functionality of a language-defined library unit, it
8059 should normally do so by adding children to the library unit.
8063 @cindex Bounded errors
8064 @unnumberedsec 1.1.5(12): Bounded Errors
8067 If an implementation detects a bounded error or erroneous
8068 execution, it should raise @code{Program_Error}.
8070 Followed in all cases in which the implementation detects a bounded
8071 error or erroneous execution. Not all such situations are detected at
8075 @unnumberedsec 2.8(16): Pragmas
8078 Normally, implementation-defined pragmas should have no semantic effect
8079 for error-free programs; that is, if the implementation-defined pragmas
8080 are removed from a working program, the program should still be legal,
8081 and should still have the same semantics.
8083 The following implementation defined pragmas are exceptions to this
8095 @item CPP_Constructor
8099 @item Interface_Name
8101 @item Machine_Attribute
8103 @item Unimplemented_Unit
8105 @item Unchecked_Union
8110 In each of the above cases, it is essential to the purpose of the pragma
8111 that this advice not be followed. For details see the separate section
8112 on implementation defined pragmas.
8114 @unnumberedsec 2.8(17-19): Pragmas
8117 Normally, an implementation should not define pragmas that can
8118 make an illegal program legal, except as follows:
8122 A pragma used to complete a declaration, such as a pragma @code{Import};
8126 A pragma used to configure the environment by adding, removing, or
8127 replacing @code{library_items}.
8129 See response to paragraph 16 of this same section.
8131 @cindex Character Sets
8132 @cindex Alternative Character Sets
8133 @unnumberedsec 3.5.2(5): Alternative Character Sets
8136 If an implementation supports a mode with alternative interpretations
8137 for @code{Character} and @code{Wide_Character}, the set of graphic
8138 characters of @code{Character} should nevertheless remain a proper
8139 subset of the set of graphic characters of @code{Wide_Character}. Any
8140 character set ``localizations'' should be reflected in the results of
8141 the subprograms defined in the language-defined package
8142 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
8143 an alternative interpretation of @code{Character}, the implementation should
8144 also support a corresponding change in what is a legal
8145 @code{identifier_letter}.
8147 Not all wide character modes follow this advice, in particular the JIS
8148 and IEC modes reflect standard usage in Japan, and in these encoding,
8149 the upper half of the Latin-1 set is not part of the wide-character
8150 subset, since the most significant bit is used for wide character
8151 encoding. However, this only applies to the external forms. Internally
8152 there is no such restriction.
8154 @cindex Integer types
8155 @unnumberedsec 3.5.4(28): Integer Types
8159 An implementation should support @code{Long_Integer} in addition to
8160 @code{Integer} if the target machine supports 32-bit (or longer)
8161 arithmetic. No other named integer subtypes are recommended for package
8162 @code{Standard}. Instead, appropriate named integer subtypes should be
8163 provided in the library package @code{Interfaces} (see B.2).
8165 @code{Long_Integer} is supported. Other standard integer types are supported
8166 so this advice is not fully followed. These types
8167 are supported for convenient interface to C, and so that all hardware
8168 types of the machine are easily available.
8169 @unnumberedsec 3.5.4(29): Integer Types
8173 An implementation for a two's complement machine should support
8174 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
8175 implementation should support a non-binary modules up to @code{Integer'Last}.
8179 @cindex Enumeration values
8180 @unnumberedsec 3.5.5(8): Enumeration Values
8183 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
8184 subtype, if the value of the operand does not correspond to the internal
8185 code for any enumeration literal of its type (perhaps due to an
8186 un-initialized variable), then the implementation should raise
8187 @code{Program_Error}. This is particularly important for enumeration
8188 types with noncontiguous internal codes specified by an
8189 enumeration_representation_clause.
8194 @unnumberedsec 3.5.7(17): Float Types
8197 An implementation should support @code{Long_Float} in addition to
8198 @code{Float} if the target machine supports 11 or more digits of
8199 precision. No other named floating point subtypes are recommended for
8200 package @code{Standard}. Instead, appropriate named floating point subtypes
8201 should be provided in the library package @code{Interfaces} (see B.2).
8203 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
8204 former provides improved compatibility with other implementations
8205 supporting this type. The latter corresponds to the highest precision
8206 floating-point type supported by the hardware. On most machines, this
8207 will be the same as @code{Long_Float}, but on some machines, it will
8208 correspond to the IEEE extended form. The notable case is all ia32
8209 (x86) implementations, where @code{Long_Long_Float} corresponds to
8210 the 80-bit extended precision format supported in hardware on this
8211 processor. Note that the 128-bit format on SPARC is not supported,
8212 since this is a software rather than a hardware format.
8214 @cindex Multidimensional arrays
8215 @cindex Arrays, multidimensional
8216 @unnumberedsec 3.6.2(11): Multidimensional Arrays
8219 An implementation should normally represent multidimensional arrays in
8220 row-major order, consistent with the notation used for multidimensional
8221 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
8222 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
8223 column-major order should be used instead (see B.5, ``Interfacing with
8228 @findex Duration'Small
8229 @unnumberedsec 9.6(30-31): Duration'Small
8232 Whenever possible in an implementation, the value of @code{Duration'Small}
8233 should be no greater than 100 microseconds.
8235 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
8239 The time base for @code{delay_relative_statements} should be monotonic;
8240 it need not be the same time base as used for @code{Calendar.Clock}.
8244 @unnumberedsec 10.2.1(12): Consistent Representation
8247 In an implementation, a type declared in a pre-elaborated package should
8248 have the same representation in every elaboration of a given version of
8249 the package, whether the elaborations occur in distinct executions of
8250 the same program, or in executions of distinct programs or partitions
8251 that include the given version.
8253 Followed, except in the case of tagged types. Tagged types involve
8254 implicit pointers to a local copy of a dispatch table, and these pointers
8255 have representations which thus depend on a particular elaboration of the
8256 package. It is not easy to see how it would be possible to follow this
8257 advice without severely impacting efficiency of execution.
8259 @cindex Exception information
8260 @unnumberedsec 11.4.1(19): Exception Information
8263 @code{Exception_Message} by default and @code{Exception_Information}
8264 should produce information useful for
8265 debugging. @code{Exception_Message} should be short, about one
8266 line. @code{Exception_Information} can be long. @code{Exception_Message}
8267 should not include the
8268 @code{Exception_Name}. @code{Exception_Information} should include both
8269 the @code{Exception_Name} and the @code{Exception_Message}.
8271 Followed. For each exception that doesn't have a specified
8272 @code{Exception_Message}, the compiler generates one containing the location
8273 of the raise statement. This location has the form ``file:line'', where
8274 file is the short file name (without path information) and line is the line
8275 number in the file. Note that in the case of the Zero Cost Exception
8276 mechanism, these messages become redundant with the Exception_Information that
8277 contains a full backtrace of the calling sequence, so they are disabled.
8278 To disable explicitly the generation of the source location message, use the
8279 Pragma @code{Discard_Names}.
8281 @cindex Suppression of checks
8282 @cindex Checks, suppression of
8283 @unnumberedsec 11.5(28): Suppression of Checks
8286 The implementation should minimize the code executed for checks that
8287 have been suppressed.
8291 @cindex Representation clauses
8292 @unnumberedsec 13.1 (21-24): Representation Clauses
8295 The recommended level of support for all representation items is
8296 qualified as follows:
8300 An implementation need not support representation items containing
8301 non-static expressions, except that an implementation should support a
8302 representation item for a given entity if each non-static expression in
8303 the representation item is a name that statically denotes a constant
8304 declared before the entity.
8306 Followed. In fact, GNAT goes beyond the recommended level of support
8307 by allowing nonstatic expressions in some representation clauses even
8308 without the need to declare constants initialized with the values of
8312 @smallexample @c ada
8315 for Y'Address use X'Address;>>
8320 An implementation need not support a specification for the @code{Size}
8321 for a given composite subtype, nor the size or storage place for an
8322 object (including a component) of a given composite subtype, unless the
8323 constraints on the subtype and its composite subcomponents (if any) are
8324 all static constraints.
8326 Followed. Size Clauses are not permitted on non-static components, as
8331 An aliased component, or a component whose type is by-reference, should
8332 always be allocated at an addressable location.
8336 @cindex Packed types
8337 @unnumberedsec 13.2(6-8): Packed Types
8340 If a type is packed, then the implementation should try to minimize
8341 storage allocated to objects of the type, possibly at the expense of
8342 speed of accessing components, subject to reasonable complexity in
8343 addressing calculations.
8347 The recommended level of support pragma @code{Pack} is:
8349 For a packed record type, the components should be packed as tightly as
8350 possible subject to the Sizes of the component subtypes, and subject to
8351 any @code{record_representation_clause} that applies to the type; the
8352 implementation may, but need not, reorder components or cross aligned
8353 word boundaries to improve the packing. A component whose @code{Size} is
8354 greater than the word size may be allocated an integral number of words.
8356 Followed. Tight packing of arrays is supported for all component sizes
8357 up to 64-bits. If the array component size is 1 (that is to say, if
8358 the component is a boolean type or an enumeration type with two values)
8359 then values of the type are implicitly initialized to zero. This
8360 happens both for objects of the packed type, and for objects that have a
8361 subcomponent of the packed type.
8365 An implementation should support Address clauses for imported
8369 @cindex @code{Address} clauses
8370 @unnumberedsec 13.3(14-19): Address Clauses
8374 For an array @var{X}, @code{@var{X}'Address} should point at the first
8375 component of the array, and not at the array bounds.
8381 The recommended level of support for the @code{Address} attribute is:
8383 @code{@var{X}'Address} should produce a useful result if @var{X} is an
8384 object that is aliased or of a by-reference type, or is an entity whose
8385 @code{Address} has been specified.
8387 Followed. A valid address will be produced even if none of those
8388 conditions have been met. If necessary, the object is forced into
8389 memory to ensure the address is valid.
8393 An implementation should support @code{Address} clauses for imported
8400 Objects (including subcomponents) that are aliased or of a by-reference
8401 type should be allocated on storage element boundaries.
8407 If the @code{Address} of an object is specified, or it is imported or exported,
8408 then the implementation should not perform optimizations based on
8409 assumptions of no aliases.
8413 @cindex @code{Alignment} clauses
8414 @unnumberedsec 13.3(29-35): Alignment Clauses
8417 The recommended level of support for the @code{Alignment} attribute for
8420 An implementation should support specified Alignments that are factors
8421 and multiples of the number of storage elements per word, subject to the
8428 An implementation need not support specified @code{Alignment}s for
8429 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
8430 loaded and stored by available machine instructions.
8436 An implementation need not support specified @code{Alignment}s that are
8437 greater than the maximum @code{Alignment} the implementation ever returns by
8444 The recommended level of support for the @code{Alignment} attribute for
8447 Same as above, for subtypes, but in addition:
8453 For stand-alone library-level objects of statically constrained
8454 subtypes, the implementation should support all @code{Alignment}s
8455 supported by the target linker. For example, page alignment is likely to
8456 be supported for such objects, but not for subtypes.
8460 @cindex @code{Size} clauses
8461 @unnumberedsec 13.3(42-43): Size Clauses
8464 The recommended level of support for the @code{Size} attribute of
8467 A @code{Size} clause should be supported for an object if the specified
8468 @code{Size} is at least as large as its subtype's @code{Size}, and
8469 corresponds to a size in storage elements that is a multiple of the
8470 object's @code{Alignment} (if the @code{Alignment} is nonzero).
8474 @unnumberedsec 13.3(50-56): Size Clauses
8477 If the @code{Size} of a subtype is specified, and allows for efficient
8478 independent addressability (see 9.10) on the target architecture, then
8479 the @code{Size} of the following objects of the subtype should equal the
8480 @code{Size} of the subtype:
8482 Aliased objects (including components).
8488 @code{Size} clause on a composite subtype should not affect the
8489 internal layout of components.
8491 Followed. But note that this can be overridden by use of the implementation
8492 pragma Implicit_Packing in the case of packed arrays.
8496 The recommended level of support for the @code{Size} attribute of subtypes is:
8500 The @code{Size} (if not specified) of a static discrete or fixed point
8501 subtype should be the number of bits needed to represent each value
8502 belonging to the subtype using an unbiased representation, leaving space
8503 for a sign bit only if the subtype contains negative values. If such a
8504 subtype is a first subtype, then an implementation should support a
8505 specified @code{Size} for it that reflects this representation.
8511 For a subtype implemented with levels of indirection, the @code{Size}
8512 should include the size of the pointers, but not the size of what they
8517 @cindex @code{Component_Size} clauses
8518 @unnumberedsec 13.3(71-73): Component Size Clauses
8521 The recommended level of support for the @code{Component_Size}
8526 An implementation need not support specified @code{Component_Sizes} that are
8527 less than the @code{Size} of the component subtype.
8533 An implementation should support specified @code{Component_Size}s that
8534 are factors and multiples of the word size. For such
8535 @code{Component_Size}s, the array should contain no gaps between
8536 components. For other @code{Component_Size}s (if supported), the array
8537 should contain no gaps between components when packing is also
8538 specified; the implementation should forbid this combination in cases
8539 where it cannot support a no-gaps representation.
8543 @cindex Enumeration representation clauses
8544 @cindex Representation clauses, enumeration
8545 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
8548 The recommended level of support for enumeration representation clauses
8551 An implementation need not support enumeration representation clauses
8552 for boolean types, but should at minimum support the internal codes in
8553 the range @code{System.Min_Int.System.Max_Int}.
8557 @cindex Record representation clauses
8558 @cindex Representation clauses, records
8559 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
8562 The recommended level of support for
8563 @*@code{record_representation_clauses} is:
8565 An implementation should support storage places that can be extracted
8566 with a load, mask, shift sequence of machine code, and set with a load,
8567 shift, mask, store sequence, given the available machine instructions
8574 A storage place should be supported if its size is equal to the
8575 @code{Size} of the component subtype, and it starts and ends on a
8576 boundary that obeys the @code{Alignment} of the component subtype.
8582 If the default bit ordering applies to the declaration of a given type,
8583 then for a component whose subtype's @code{Size} is less than the word
8584 size, any storage place that does not cross an aligned word boundary
8585 should be supported.
8591 An implementation may reserve a storage place for the tag field of a
8592 tagged type, and disallow other components from overlapping that place.
8594 Followed. The storage place for the tag field is the beginning of the tagged
8595 record, and its size is Address'Size. GNAT will reject an explicit component
8596 clause for the tag field.
8600 An implementation need not support a @code{component_clause} for a
8601 component of an extension part if the storage place is not after the
8602 storage places of all components of the parent type, whether or not
8603 those storage places had been specified.
8605 Followed. The above advice on record representation clauses is followed,
8606 and all mentioned features are implemented.
8608 @cindex Storage place attributes
8609 @unnumberedsec 13.5.2(5): Storage Place Attributes
8612 If a component is represented using some form of pointer (such as an
8613 offset) to the actual data of the component, and this data is contiguous
8614 with the rest of the object, then the storage place attributes should
8615 reflect the place of the actual data, not the pointer. If a component is
8616 allocated discontinuously from the rest of the object, then a warning
8617 should be generated upon reference to one of its storage place
8620 Followed. There are no such components in GNAT@.
8622 @cindex Bit ordering
8623 @unnumberedsec 13.5.3(7-8): Bit Ordering
8626 The recommended level of support for the non-default bit ordering is:
8630 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
8631 should support the non-default bit ordering in addition to the default
8634 Followed. Word size does not equal storage size in this implementation.
8635 Thus non-default bit ordering is not supported.
8637 @cindex @code{Address}, as private type
8638 @unnumberedsec 13.7(37): Address as Private
8641 @code{Address} should be of a private type.
8645 @cindex Operations, on @code{Address}
8646 @cindex @code{Address}, operations of
8647 @unnumberedsec 13.7.1(16): Address Operations
8650 Operations in @code{System} and its children should reflect the target
8651 environment semantics as closely as is reasonable. For example, on most
8652 machines, it makes sense for address arithmetic to ``wrap around''.
8653 Operations that do not make sense should raise @code{Program_Error}.
8655 Followed. Address arithmetic is modular arithmetic that wraps around. No
8656 operation raises @code{Program_Error}, since all operations make sense.
8658 @cindex Unchecked conversion
8659 @unnumberedsec 13.9(14-17): Unchecked Conversion
8662 The @code{Size} of an array object should not include its bounds; hence,
8663 the bounds should not be part of the converted data.
8669 The implementation should not generate unnecessary run-time checks to
8670 ensure that the representation of @var{S} is a representation of the
8671 target type. It should take advantage of the permission to return by
8672 reference when possible. Restrictions on unchecked conversions should be
8673 avoided unless required by the target environment.
8675 Followed. There are no restrictions on unchecked conversion. A warning is
8676 generated if the source and target types do not have the same size since
8677 the semantics in this case may be target dependent.
8681 The recommended level of support for unchecked conversions is:
8685 Unchecked conversions should be supported and should be reversible in
8686 the cases where this clause defines the result. To enable meaningful use
8687 of unchecked conversion, a contiguous representation should be used for
8688 elementary subtypes, for statically constrained array subtypes whose
8689 component subtype is one of the subtypes described in this paragraph,
8690 and for record subtypes without discriminants whose component subtypes
8691 are described in this paragraph.
8695 @cindex Heap usage, implicit
8696 @unnumberedsec 13.11(23-25): Implicit Heap Usage
8699 An implementation should document any cases in which it dynamically
8700 allocates heap storage for a purpose other than the evaluation of an
8703 Followed, the only other points at which heap storage is dynamically
8704 allocated are as follows:
8708 At initial elaboration time, to allocate dynamically sized global
8712 To allocate space for a task when a task is created.
8715 To extend the secondary stack dynamically when needed. The secondary
8716 stack is used for returning variable length results.
8721 A default (implementation-provided) storage pool for an
8722 access-to-constant type should not have overhead to support deallocation of
8729 A storage pool for an anonymous access type should be created at the
8730 point of an allocator for the type, and be reclaimed when the designated
8731 object becomes inaccessible.
8735 @cindex Unchecked deallocation
8736 @unnumberedsec 13.11.2(17): Unchecked De-allocation
8739 For a standard storage pool, @code{Free} should actually reclaim the
8744 @cindex Stream oriented attributes
8745 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
8748 If a stream element is the same size as a storage element, then the
8749 normal in-memory representation should be used by @code{Read} and
8750 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
8751 should use the smallest number of stream elements needed to represent
8752 all values in the base range of the scalar type.
8755 Followed. By default, GNAT uses the interpretation suggested by AI-195,
8756 which specifies using the size of the first subtype.
8757 However, such an implementation is based on direct binary
8758 representations and is therefore target- and endianness-dependent.
8759 To address this issue, GNAT also supplies an alternate implementation
8760 of the stream attributes @code{Read} and @code{Write},
8761 which uses the target-independent XDR standard representation
8763 @cindex XDR representation
8764 @cindex @code{Read} attribute
8765 @cindex @code{Write} attribute
8766 @cindex Stream oriented attributes
8767 The XDR implementation is provided as an alternative body of the
8768 @code{System.Stream_Attributes} package, in the file
8769 @file{s-stratt-xdr.adb} in the GNAT library.
8770 There is no @file{s-stratt-xdr.ads} file.
8771 In order to install the XDR implementation, do the following:
8773 @item Replace the default implementation of the
8774 @code{System.Stream_Attributes} package with the XDR implementation.
8775 For example on a Unix platform issue the commands:
8777 $ mv s-stratt.adb s-stratt-default.adb
8778 $ mv s-stratt-xdr.adb s-stratt.adb
8782 Rebuild the GNAT run-time library as documented in
8783 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
8786 @unnumberedsec A.1(52): Names of Predefined Numeric Types
8789 If an implementation provides additional named predefined integer types,
8790 then the names should end with @samp{Integer} as in
8791 @samp{Long_Integer}. If an implementation provides additional named
8792 predefined floating point types, then the names should end with
8793 @samp{Float} as in @samp{Long_Float}.
8797 @findex Ada.Characters.Handling
8798 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
8801 If an implementation provides a localized definition of @code{Character}
8802 or @code{Wide_Character}, then the effects of the subprograms in
8803 @code{Characters.Handling} should reflect the localizations. See also
8806 Followed. GNAT provides no such localized definitions.
8808 @cindex Bounded-length strings
8809 @unnumberedsec A.4.4(106): Bounded-Length String Handling
8812 Bounded string objects should not be implemented by implicit pointers
8813 and dynamic allocation.
8815 Followed. No implicit pointers or dynamic allocation are used.
8817 @cindex Random number generation
8818 @unnumberedsec A.5.2(46-47): Random Number Generation
8821 Any storage associated with an object of type @code{Generator} should be
8822 reclaimed on exit from the scope of the object.
8828 If the generator period is sufficiently long in relation to the number
8829 of distinct initiator values, then each possible value of
8830 @code{Initiator} passed to @code{Reset} should initiate a sequence of
8831 random numbers that does not, in a practical sense, overlap the sequence
8832 initiated by any other value. If this is not possible, then the mapping
8833 between initiator values and generator states should be a rapidly
8834 varying function of the initiator value.
8836 Followed. The generator period is sufficiently long for the first
8837 condition here to hold true.
8839 @findex Get_Immediate
8840 @unnumberedsec A.10.7(23): @code{Get_Immediate}
8843 The @code{Get_Immediate} procedures should be implemented with
8844 unbuffered input. For a device such as a keyboard, input should be
8845 @dfn{available} if a key has already been typed, whereas for a disk
8846 file, input should always be available except at end of file. For a file
8847 associated with a keyboard-like device, any line-editing features of the
8848 underlying operating system should be disabled during the execution of
8849 @code{Get_Immediate}.
8851 Followed on all targets except VxWorks. For VxWorks, there is no way to
8852 provide this functionality that does not result in the input buffer being
8853 flushed before the @code{Get_Immediate} call. A special unit
8854 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
8858 @unnumberedsec B.1(39-41): Pragma @code{Export}
8861 If an implementation supports pragma @code{Export} to a given language,
8862 then it should also allow the main subprogram to be written in that
8863 language. It should support some mechanism for invoking the elaboration
8864 of the Ada library units included in the system, and for invoking the
8865 finalization of the environment task. On typical systems, the
8866 recommended mechanism is to provide two subprograms whose link names are
8867 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
8868 elaboration code for library units. @code{adafinal} should contain the
8869 finalization code. These subprograms should have no effect the second
8870 and subsequent time they are called.
8876 Automatic elaboration of pre-elaborated packages should be
8877 provided when pragma @code{Export} is supported.
8879 Followed when the main program is in Ada. If the main program is in a
8880 foreign language, then
8881 @code{adainit} must be called to elaborate pre-elaborated
8886 For each supported convention @var{L} other than @code{Intrinsic}, an
8887 implementation should support @code{Import} and @code{Export} pragmas
8888 for objects of @var{L}-compatible types and for subprograms, and pragma
8889 @code{Convention} for @var{L}-eligible types and for subprograms,
8890 presuming the other language has corresponding features. Pragma
8891 @code{Convention} need not be supported for scalar types.
8895 @cindex Package @code{Interfaces}
8897 @unnumberedsec B.2(12-13): Package @code{Interfaces}
8900 For each implementation-defined convention identifier, there should be a
8901 child package of package Interfaces with the corresponding name. This
8902 package should contain any declarations that would be useful for
8903 interfacing to the language (implementation) represented by the
8904 convention. Any declarations useful for interfacing to any language on
8905 the given hardware architecture should be provided directly in
8908 Followed. An additional package not defined
8909 in the Ada Reference Manual is @code{Interfaces.CPP}, used
8910 for interfacing to C++.
8914 An implementation supporting an interface to C, COBOL, or Fortran should
8915 provide the corresponding package or packages described in the following
8918 Followed. GNAT provides all the packages described in this section.
8920 @cindex C, interfacing with
8921 @unnumberedsec B.3(63-71): Interfacing with C
8924 An implementation should support the following interface correspondences
8931 An Ada procedure corresponds to a void-returning C function.
8937 An Ada function corresponds to a non-void C function.
8943 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
8950 An Ada @code{in} parameter of an access-to-object type with designated
8951 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
8952 where @var{t} is the C type corresponding to the Ada type @var{T}.
8958 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
8959 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
8960 argument to a C function, where @var{t} is the C type corresponding to
8961 the Ada type @var{T}. In the case of an elementary @code{out} or
8962 @code{in out} parameter, a pointer to a temporary copy is used to
8963 preserve by-copy semantics.
8969 An Ada parameter of a record type @var{T}, of any mode, is passed as a
8970 @code{@var{t}*} argument to a C function, where @var{t} is the C
8971 structure corresponding to the Ada type @var{T}.
8973 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
8974 pragma, or Convention, or by explicitly specifying the mechanism for a given
8975 call using an extended import or export pragma.
8979 An Ada parameter of an array type with component type @var{T}, of any
8980 mode, is passed as a @code{@var{t}*} argument to a C function, where
8981 @var{t} is the C type corresponding to the Ada type @var{T}.
8987 An Ada parameter of an access-to-subprogram type is passed as a pointer
8988 to a C function whose prototype corresponds to the designated
8989 subprogram's specification.
8993 @cindex COBOL, interfacing with
8994 @unnumberedsec B.4(95-98): Interfacing with COBOL
8997 An Ada implementation should support the following interface
8998 correspondences between Ada and COBOL@.
9004 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
9005 the COBOL type corresponding to @var{T}.
9011 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
9012 the corresponding COBOL type.
9018 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
9019 COBOL type corresponding to the Ada parameter type; for scalars, a local
9020 copy is used if necessary to ensure by-copy semantics.
9024 @cindex Fortran, interfacing with
9025 @unnumberedsec B.5(22-26): Interfacing with Fortran
9028 An Ada implementation should support the following interface
9029 correspondences between Ada and Fortran:
9035 An Ada procedure corresponds to a Fortran subroutine.
9041 An Ada function corresponds to a Fortran function.
9047 An Ada parameter of an elementary, array, or record type @var{T} is
9048 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
9049 the Fortran type corresponding to the Ada type @var{T}, and where the
9050 INTENT attribute of the corresponding dummy argument matches the Ada
9051 formal parameter mode; the Fortran implementation's parameter passing
9052 conventions are used. For elementary types, a local copy is used if
9053 necessary to ensure by-copy semantics.
9059 An Ada parameter of an access-to-subprogram type is passed as a
9060 reference to a Fortran procedure whose interface corresponds to the
9061 designated subprogram's specification.
9065 @cindex Machine operations
9066 @unnumberedsec C.1(3-5): Access to Machine Operations
9069 The machine code or intrinsic support should allow access to all
9070 operations normally available to assembly language programmers for the
9071 target environment, including privileged instructions, if any.
9077 The interfacing pragmas (see Annex B) should support interface to
9078 assembler; the default assembler should be associated with the
9079 convention identifier @code{Assembler}.
9085 If an entity is exported to assembly language, then the implementation
9086 should allocate it at an addressable location, and should ensure that it
9087 is retained by the linking process, even if not otherwise referenced
9088 from the Ada code. The implementation should assume that any call to a
9089 machine code or assembler subprogram is allowed to read or update every
9090 object that is specified as exported.
9094 @unnumberedsec C.1(10-16): Access to Machine Operations
9097 The implementation should ensure that little or no overhead is
9098 associated with calling intrinsic and machine-code subprograms.
9100 Followed for both intrinsics and machine-code subprograms.
9104 It is recommended that intrinsic subprograms be provided for convenient
9105 access to any machine operations that provide special capabilities or
9106 efficiency and that are not otherwise available through the language
9109 Followed. A full set of machine operation intrinsic subprograms is provided.
9113 Atomic read-modify-write operations---e.g.@:, test and set, compare and
9114 swap, decrement and test, enqueue/dequeue.
9116 Followed on any target supporting such operations.
9120 Standard numeric functions---e.g.@:, sin, log.
9122 Followed on any target supporting such operations.
9126 String manipulation operations---e.g.@:, translate and test.
9128 Followed on any target supporting such operations.
9132 Vector operations---e.g.@:, compare vector against thresholds.
9134 Followed on any target supporting such operations.
9138 Direct operations on I/O ports.
9140 Followed on any target supporting such operations.
9142 @cindex Interrupt support
9143 @unnumberedsec C.3(28): Interrupt Support
9146 If the @code{Ceiling_Locking} policy is not in effect, the
9147 implementation should provide means for the application to specify which
9148 interrupts are to be blocked during protected actions, if the underlying
9149 system allows for a finer-grain control of interrupt blocking.
9151 Followed. The underlying system does not allow for finer-grain control
9152 of interrupt blocking.
9154 @cindex Protected procedure handlers
9155 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
9158 Whenever possible, the implementation should allow interrupt handlers to
9159 be called directly by the hardware.
9161 Followed on any target where the underlying operating system permits
9166 Whenever practical, violations of any
9167 implementation-defined restrictions should be detected before run time.
9169 Followed. Compile time warnings are given when possible.
9171 @cindex Package @code{Interrupts}
9173 @unnumberedsec C.3.2(25): Package @code{Interrupts}
9177 If implementation-defined forms of interrupt handler procedures are
9178 supported, such as protected procedures with parameters, then for each
9179 such form of a handler, a type analogous to @code{Parameterless_Handler}
9180 should be specified in a child package of @code{Interrupts}, with the
9181 same operations as in the predefined package Interrupts.
9185 @cindex Pre-elaboration requirements
9186 @unnumberedsec C.4(14): Pre-elaboration Requirements
9189 It is recommended that pre-elaborated packages be implemented in such a
9190 way that there should be little or no code executed at run time for the
9191 elaboration of entities not already covered by the Implementation
9194 Followed. Executable code is generated in some cases, e.g.@: loops
9195 to initialize large arrays.
9197 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
9200 If the pragma applies to an entity, then the implementation should
9201 reduce the amount of storage used for storing names associated with that
9206 @cindex Package @code{Task_Attributes}
9207 @findex Task_Attributes
9208 @unnumberedsec C.7.2(30): The Package Task_Attributes
9211 Some implementations are targeted to domains in which memory use at run
9212 time must be completely deterministic. For such implementations, it is
9213 recommended that the storage for task attributes will be pre-allocated
9214 statically and not from the heap. This can be accomplished by either
9215 placing restrictions on the number and the size of the task's
9216 attributes, or by using the pre-allocated storage for the first @var{N}
9217 attribute objects, and the heap for the others. In the latter case,
9218 @var{N} should be documented.
9220 Not followed. This implementation is not targeted to such a domain.
9222 @cindex Locking Policies
9223 @unnumberedsec D.3(17): Locking Policies
9227 The implementation should use names that end with @samp{_Locking} for
9228 locking policies defined by the implementation.
9230 Followed. Two implementation-defined locking policies are defined,
9231 whose names (@code{Inheritance_Locking} and
9232 @code{Concurrent_Readers_Locking}) follow this suggestion.
9234 @cindex Entry queuing policies
9235 @unnumberedsec D.4(16): Entry Queuing Policies
9238 Names that end with @samp{_Queuing} should be used
9239 for all implementation-defined queuing policies.
9241 Followed. No such implementation-defined queuing policies exist.
9243 @cindex Preemptive abort
9244 @unnumberedsec D.6(9-10): Preemptive Abort
9247 Even though the @code{abort_statement} is included in the list of
9248 potentially blocking operations (see 9.5.1), it is recommended that this
9249 statement be implemented in a way that never requires the task executing
9250 the @code{abort_statement} to block.
9256 On a multi-processor, the delay associated with aborting a task on
9257 another processor should be bounded; the implementation should use
9258 periodic polling, if necessary, to achieve this.
9262 @cindex Tasking restrictions
9263 @unnumberedsec D.7(21): Tasking Restrictions
9266 When feasible, the implementation should take advantage of the specified
9267 restrictions to produce a more efficient implementation.
9269 GNAT currently takes advantage of these restrictions by providing an optimized
9270 run time when the Ravenscar profile and the GNAT restricted run time set
9271 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
9272 pragma @code{Profile (Restricted)} for more details.
9274 @cindex Time, monotonic
9275 @unnumberedsec D.8(47-49): Monotonic Time
9278 When appropriate, implementations should provide configuration
9279 mechanisms to change the value of @code{Tick}.
9281 Such configuration mechanisms are not appropriate to this implementation
9282 and are thus not supported.
9286 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
9287 be implemented as transformations of the same time base.
9293 It is recommended that the @dfn{best} time base which exists in
9294 the underlying system be available to the application through
9295 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
9299 @cindex Partition communication subsystem
9301 @unnumberedsec E.5(28-29): Partition Communication Subsystem
9304 Whenever possible, the PCS on the called partition should allow for
9305 multiple tasks to call the RPC-receiver with different messages and
9306 should allow them to block until the corresponding subprogram body
9309 Followed by GLADE, a separately supplied PCS that can be used with
9314 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
9315 should raise @code{Storage_Error} if it runs out of space trying to
9316 write the @code{Item} into the stream.
9318 Followed by GLADE, a separately supplied PCS that can be used with
9321 @cindex COBOL support
9322 @unnumberedsec F(7): COBOL Support
9325 If COBOL (respectively, C) is widely supported in the target
9326 environment, implementations supporting the Information Systems Annex
9327 should provide the child package @code{Interfaces.COBOL} (respectively,
9328 @code{Interfaces.C}) specified in Annex B and should support a
9329 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
9330 pragmas (see Annex B), thus allowing Ada programs to interface with
9331 programs written in that language.
9335 @cindex Decimal radix support
9336 @unnumberedsec F.1(2): Decimal Radix Support
9339 Packed decimal should be used as the internal representation for objects
9340 of subtype @var{S} when @var{S}'Machine_Radix = 10.
9342 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
9346 @unnumberedsec G: Numerics
9349 If Fortran (respectively, C) is widely supported in the target
9350 environment, implementations supporting the Numerics Annex
9351 should provide the child package @code{Interfaces.Fortran} (respectively,
9352 @code{Interfaces.C}) specified in Annex B and should support a
9353 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
9354 pragmas (see Annex B), thus allowing Ada programs to interface with
9355 programs written in that language.
9359 @cindex Complex types
9360 @unnumberedsec G.1.1(56-58): Complex Types
9363 Because the usual mathematical meaning of multiplication of a complex
9364 operand and a real operand is that of the scaling of both components of
9365 the former by the latter, an implementation should not perform this
9366 operation by first promoting the real operand to complex type and then
9367 performing a full complex multiplication. In systems that, in the
9368 future, support an Ada binding to IEC 559:1989, the latter technique
9369 will not generate the required result when one of the components of the
9370 complex operand is infinite. (Explicit multiplication of the infinite
9371 component by the zero component obtained during promotion yields a NaN
9372 that propagates into the final result.) Analogous advice applies in the
9373 case of multiplication of a complex operand and a pure-imaginary
9374 operand, and in the case of division of a complex operand by a real or
9375 pure-imaginary operand.
9381 Similarly, because the usual mathematical meaning of addition of a
9382 complex operand and a real operand is that the imaginary operand remains
9383 unchanged, an implementation should not perform this operation by first
9384 promoting the real operand to complex type and then performing a full
9385 complex addition. In implementations in which the @code{Signed_Zeros}
9386 attribute of the component type is @code{True} (and which therefore
9387 conform to IEC 559:1989 in regard to the handling of the sign of zero in
9388 predefined arithmetic operations), the latter technique will not
9389 generate the required result when the imaginary component of the complex
9390 operand is a negatively signed zero. (Explicit addition of the negative
9391 zero to the zero obtained during promotion yields a positive zero.)
9392 Analogous advice applies in the case of addition of a complex operand
9393 and a pure-imaginary operand, and in the case of subtraction of a
9394 complex operand and a real or pure-imaginary operand.
9400 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
9401 attempt to provide a rational treatment of the signs of zero results and
9402 result components. As one example, the result of the @code{Argument}
9403 function should have the sign of the imaginary component of the
9404 parameter @code{X} when the point represented by that parameter lies on
9405 the positive real axis; as another, the sign of the imaginary component
9406 of the @code{Compose_From_Polar} function should be the same as
9407 (respectively, the opposite of) that of the @code{Argument} parameter when that
9408 parameter has a value of zero and the @code{Modulus} parameter has a
9409 nonnegative (respectively, negative) value.
9413 @cindex Complex elementary functions
9414 @unnumberedsec G.1.2(49): Complex Elementary Functions
9417 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
9418 @code{True} should attempt to provide a rational treatment of the signs
9419 of zero results and result components. For example, many of the complex
9420 elementary functions have components that are odd functions of one of
9421 the parameter components; in these cases, the result component should
9422 have the sign of the parameter component at the origin. Other complex
9423 elementary functions have zero components whose sign is opposite that of
9424 a parameter component at the origin, or is always positive or always
9429 @cindex Accuracy requirements
9430 @unnumberedsec G.2.4(19): Accuracy Requirements
9433 The versions of the forward trigonometric functions without a
9434 @code{Cycle} parameter should not be implemented by calling the
9435 corresponding version with a @code{Cycle} parameter of
9436 @code{2.0*Numerics.Pi}, since this will not provide the required
9437 accuracy in some portions of the domain. For the same reason, the
9438 version of @code{Log} without a @code{Base} parameter should not be
9439 implemented by calling the corresponding version with a @code{Base}
9440 parameter of @code{Numerics.e}.
9444 @cindex Complex arithmetic accuracy
9445 @cindex Accuracy, complex arithmetic
9446 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
9450 The version of the @code{Compose_From_Polar} function without a
9451 @code{Cycle} parameter should not be implemented by calling the
9452 corresponding version with a @code{Cycle} parameter of
9453 @code{2.0*Numerics.Pi}, since this will not provide the required
9454 accuracy in some portions of the domain.
9458 @cindex Sequential elaboration policy
9459 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
9463 If the partition elaboration policy is @code{Sequential} and the
9464 Environment task becomes permanently blocked during elaboration then the
9465 partition is deadlocked and it is recommended that the partition be
9466 immediately terminated.
9470 @c -----------------------------------------
9471 @node Implementation Defined Characteristics
9472 @chapter Implementation Defined Characteristics
9475 In addition to the implementation dependent pragmas and attributes, and the
9476 implementation advice, there are a number of other Ada features that are
9477 potentially implementation dependent and are designated as
9478 implementation-defined. These are mentioned throughout the Ada Reference
9479 Manual, and are summarized in Annex M@.
9481 A requirement for conforming Ada compilers is that they provide
9482 documentation describing how the implementation deals with each of these
9483 issues. In this chapter, you will find each point in Annex M listed
9484 followed by a description in italic font of how GNAT
9485 handles the implementation dependence.
9487 You can use this chapter as a guide to minimizing implementation
9488 dependent features in your programs if portability to other compilers
9489 and other operating systems is an important consideration. The numbers
9490 in each section below correspond to the paragraph number in the Ada
9496 @strong{2}. Whether or not each recommendation given in Implementation
9497 Advice is followed. See 1.1.2(37).
9500 @xref{Implementation Advice}.
9505 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
9508 The complexity of programs that can be processed is limited only by the
9509 total amount of available virtual memory, and disk space for the
9510 generated object files.
9515 @strong{4}. Variations from the standard that are impractical to avoid
9516 given the implementation's execution environment. See 1.1.3(6).
9519 There are no variations from the standard.
9524 @strong{5}. Which @code{code_statement}s cause external
9525 interactions. See 1.1.3(10).
9528 Any @code{code_statement} can potentially cause external interactions.
9533 @strong{6}. The coded representation for the text of an Ada
9534 program. See 2.1(4).
9537 See separate section on source representation.
9542 @strong{7}. The control functions allowed in comments. See 2.1(14).
9545 See separate section on source representation.
9550 @strong{8}. The representation for an end of line. See 2.2(2).
9553 See separate section on source representation.
9558 @strong{9}. Maximum supported line length and lexical element
9559 length. See 2.2(15).
9562 The maximum line length is 255 characters and the maximum length of
9563 a lexical element is also 255 characters. This is the default setting
9564 if not overridden by the use of compiler switch @option{-gnaty} (which
9565 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
9566 line length to be specified to be any value up to 32767. The maximum
9567 length of a lexical element is the same as the maximum line length.
9572 @strong{10}. Implementation defined pragmas. See 2.8(14).
9576 @xref{Implementation Defined Pragmas}.
9581 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
9584 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
9585 parameter, checks that the optimization flag is set, and aborts if it is
9591 @strong{12}. The sequence of characters of the value returned by
9592 @code{@var{S}'Image} when some of the graphic characters of
9593 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
9597 The sequence of characters is as defined by the wide character encoding
9598 method used for the source. See section on source representation for
9604 @strong{13}. The predefined integer types declared in
9605 @code{Standard}. See 3.5.4(25).
9609 @item Short_Short_Integer
9612 (Short) 16 bit signed
9616 64 bit signed (on most 64 bit targets, depending on the C definition of long).
9617 32 bit signed (all other targets)
9618 @item Long_Long_Integer
9625 @strong{14}. Any nonstandard integer types and the operators defined
9626 for them. See 3.5.4(26).
9629 There are no nonstandard integer types.
9634 @strong{15}. Any nonstandard real types and the operators defined for
9638 There are no nonstandard real types.
9643 @strong{16}. What combinations of requested decimal precision and range
9644 are supported for floating point types. See 3.5.7(7).
9647 The precision and range is as defined by the IEEE standard.
9652 @strong{17}. The predefined floating point types declared in
9653 @code{Standard}. See 3.5.7(16).
9660 (Short) 32 bit IEEE short
9663 @item Long_Long_Float
9664 64 bit IEEE long (80 bit IEEE long on x86 processors)
9670 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
9673 @code{Fine_Delta} is 2**(@minus{}63)
9678 @strong{19}. What combinations of small, range, and digits are
9679 supported for fixed point types. See 3.5.9(10).
9682 Any combinations are permitted that do not result in a small less than
9683 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
9684 If the mantissa is larger than 53 bits on machines where Long_Long_Float
9685 is 64 bits (true of all architectures except ia32), then the output from
9686 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
9687 is because floating-point conversions are used to convert fixed point.
9692 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
9693 within an unnamed @code{block_statement}. See 3.9(10).
9696 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
9697 decimal integer are allocated.
9702 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
9705 @xref{Implementation Defined Attributes}.
9710 @strong{22}. Any implementation-defined time types. See 9.6(6).
9713 There are no implementation-defined time types.
9718 @strong{23}. The time base associated with relative delays.
9721 See 9.6(20). The time base used is that provided by the C library
9722 function @code{gettimeofday}.
9727 @strong{24}. The time base of the type @code{Calendar.Time}. See
9731 The time base used is that provided by the C library function
9732 @code{gettimeofday}.
9737 @strong{25}. The time zone used for package @code{Calendar}
9738 operations. See 9.6(24).
9741 The time zone used by package @code{Calendar} is the current system time zone
9742 setting for local time, as accessed by the C library function
9748 @strong{26}. Any limit on @code{delay_until_statements} of
9749 @code{select_statements}. See 9.6(29).
9752 There are no such limits.
9757 @strong{27}. Whether or not two non-overlapping parts of a composite
9758 object are independently addressable, in the case where packing, record
9759 layout, or @code{Component_Size} is specified for the object. See
9763 Separate components are independently addressable if they do not share
9764 overlapping storage units.
9769 @strong{28}. The representation for a compilation. See 10.1(2).
9772 A compilation is represented by a sequence of files presented to the
9773 compiler in a single invocation of the @command{gcc} command.
9778 @strong{29}. Any restrictions on compilations that contain multiple
9779 compilation_units. See 10.1(4).
9782 No single file can contain more than one compilation unit, but any
9783 sequence of files can be presented to the compiler as a single
9789 @strong{30}. The mechanisms for creating an environment and for adding
9790 and replacing compilation units. See 10.1.4(3).
9793 See separate section on compilation model.
9798 @strong{31}. The manner of explicitly assigning library units to a
9799 partition. See 10.2(2).
9802 If a unit contains an Ada main program, then the Ada units for the partition
9803 are determined by recursive application of the rules in the Ada Reference
9804 Manual section 10.2(2-6). In other words, the Ada units will be those that
9805 are needed by the main program, and then this definition of need is applied
9806 recursively to those units, and the partition contains the transitive
9807 closure determined by this relationship. In short, all the necessary units
9808 are included, with no need to explicitly specify the list. If additional
9809 units are required, e.g.@: by foreign language units, then all units must be
9810 mentioned in the context clause of one of the needed Ada units.
9812 If the partition contains no main program, or if the main program is in
9813 a language other than Ada, then GNAT
9814 provides the binder options @option{-z} and @option{-n} respectively, and in
9815 this case a list of units can be explicitly supplied to the binder for
9816 inclusion in the partition (all units needed by these units will also
9817 be included automatically). For full details on the use of these
9818 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
9819 @value{EDITION} User's Guide}.
9824 @strong{32}. The implementation-defined means, if any, of specifying
9825 which compilation units are needed by a given compilation unit. See
9829 The units needed by a given compilation unit are as defined in
9830 the Ada Reference Manual section 10.2(2-6). There are no
9831 implementation-defined pragmas or other implementation-defined
9832 means for specifying needed units.
9837 @strong{33}. The manner of designating the main subprogram of a
9838 partition. See 10.2(7).
9841 The main program is designated by providing the name of the
9842 corresponding @file{ALI} file as the input parameter to the binder.
9847 @strong{34}. The order of elaboration of @code{library_items}. See
9851 The first constraint on ordering is that it meets the requirements of
9852 Chapter 10 of the Ada Reference Manual. This still leaves some
9853 implementation dependent choices, which are resolved by first
9854 elaborating bodies as early as possible (i.e., in preference to specs
9855 where there is a choice), and second by evaluating the immediate with
9856 clauses of a unit to determine the probably best choice, and
9857 third by elaborating in alphabetical order of unit names
9858 where a choice still remains.
9863 @strong{35}. Parameter passing and function return for the main
9864 subprogram. See 10.2(21).
9867 The main program has no parameters. It may be a procedure, or a function
9868 returning an integer type. In the latter case, the returned integer
9869 value is the return code of the program (overriding any value that
9870 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
9875 @strong{36}. The mechanisms for building and running partitions. See
9879 GNAT itself supports programs with only a single partition. The GNATDIST
9880 tool provided with the GLADE package (which also includes an implementation
9881 of the PCS) provides a completely flexible method for building and running
9882 programs consisting of multiple partitions. See the separate GLADE manual
9888 @strong{37}. The details of program execution, including program
9889 termination. See 10.2(25).
9892 See separate section on compilation model.
9897 @strong{38}. The semantics of any non-active partitions supported by the
9898 implementation. See 10.2(28).
9901 Passive partitions are supported on targets where shared memory is
9902 provided by the operating system. See the GLADE reference manual for
9908 @strong{39}. The information returned by @code{Exception_Message}. See
9912 Exception message returns the null string unless a specific message has
9913 been passed by the program.
9918 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
9919 declared within an unnamed @code{block_statement}. See 11.4.1(12).
9922 Blocks have implementation defined names of the form @code{B@var{nnn}}
9923 where @var{nnn} is an integer.
9928 @strong{41}. The information returned by
9929 @code{Exception_Information}. See 11.4.1(13).
9932 @code{Exception_Information} returns a string in the following format:
9935 @emph{Exception_Name:} nnnnn
9936 @emph{Message:} mmmmm
9938 @emph{Call stack traceback locations:}
9939 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
9947 @code{nnnn} is the fully qualified name of the exception in all upper
9948 case letters. This line is always present.
9951 @code{mmmm} is the message (this line present only if message is non-null)
9954 @code{ppp} is the Process Id value as a decimal integer (this line is
9955 present only if the Process Id is nonzero). Currently we are
9956 not making use of this field.
9959 The Call stack traceback locations line and the following values
9960 are present only if at least one traceback location was recorded.
9961 The values are given in C style format, with lower case letters
9962 for a-f, and only as many digits present as are necessary.
9966 The line terminator sequence at the end of each line, including
9967 the last line is a single @code{LF} character (@code{16#0A#}).
9972 @strong{42}. Implementation-defined check names. See 11.5(27).
9975 The implementation defined check name Alignment_Check controls checking of
9976 address clause values for proper alignment (that is, the address supplied
9977 must be consistent with the alignment of the type).
9979 In addition, a user program can add implementation-defined check names
9980 by means of the pragma Check_Name.
9985 @strong{43}. The interpretation of each aspect of representation. See
9989 See separate section on data representations.
9994 @strong{44}. Any restrictions placed upon representation items. See
9998 See separate section on data representations.
10003 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
10007 Size for an indefinite subtype is the maximum possible size, except that
10008 for the case of a subprogram parameter, the size of the parameter object
10009 is the actual size.
10014 @strong{46}. The default external representation for a type tag. See
10018 The default external representation for a type tag is the fully expanded
10019 name of the type in upper case letters.
10024 @strong{47}. What determines whether a compilation unit is the same in
10025 two different partitions. See 13.3(76).
10028 A compilation unit is the same in two different partitions if and only
10029 if it derives from the same source file.
10034 @strong{48}. Implementation-defined components. See 13.5.1(15).
10037 The only implementation defined component is the tag for a tagged type,
10038 which contains a pointer to the dispatching table.
10043 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
10044 ordering. See 13.5.3(5).
10047 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
10048 implementation, so no non-default bit ordering is supported. The default
10049 bit ordering corresponds to the natural endianness of the target architecture.
10054 @strong{50}. The contents of the visible part of package @code{System}
10055 and its language-defined children. See 13.7(2).
10058 See the definition of these packages in files @file{system.ads} and
10059 @file{s-stoele.ads}.
10064 @strong{51}. The contents of the visible part of package
10065 @code{System.Machine_Code}, and the meaning of
10066 @code{code_statements}. See 13.8(7).
10069 See the definition and documentation in file @file{s-maccod.ads}.
10074 @strong{52}. The effect of unchecked conversion. See 13.9(11).
10077 Unchecked conversion between types of the same size
10078 results in an uninterpreted transmission of the bits from one type
10079 to the other. If the types are of unequal sizes, then in the case of
10080 discrete types, a shorter source is first zero or sign extended as
10081 necessary, and a shorter target is simply truncated on the left.
10082 For all non-discrete types, the source is first copied if necessary
10083 to ensure that the alignment requirements of the target are met, then
10084 a pointer is constructed to the source value, and the result is obtained
10085 by dereferencing this pointer after converting it to be a pointer to the
10086 target type. Unchecked conversions where the target subtype is an
10087 unconstrained array are not permitted. If the target alignment is
10088 greater than the source alignment, then a copy of the result is
10089 made with appropriate alignment
10094 @strong{53}. The semantics of operations on invalid representations.
10098 For assignments and other operations where the use of invalid values cannot
10099 result in erroneous behavior, the compiler ignores the possibility of invalid
10100 values. An exception is raised at the point where an invalid value would
10101 result in erroneous behavior. For example executing:
10103 @smallexample @c ada
10104 procedure invalidvals is
10106 Y : Natural range 1 .. 10;
10107 for Y'Address use X'Address;
10108 Z : Natural range 1 .. 10;
10109 A : array (Natural range 1 .. 10) of Integer;
10111 Z := Y; -- no exception
10112 A (Z) := 3; -- exception raised;
10117 As indicated, an exception is raised on the array assignment, but not
10118 on the simple assignment of the invalid negative value from Y to Z.
10123 @strong{53}. The manner of choosing a storage pool for an access type
10124 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
10127 There are 3 different standard pools used by the compiler when
10128 @code{Storage_Pool} is not specified depending whether the type is local
10129 to a subprogram or defined at the library level and whether
10130 @code{Storage_Size}is specified or not. See documentation in the runtime
10131 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
10132 @code{System.Pool_Local} in files @file{s-poosiz.ads},
10133 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
10134 default pools used.
10139 @strong{54}. Whether or not the implementation provides user-accessible
10140 names for the standard pool type(s). See 13.11(17).
10144 See documentation in the sources of the run time mentioned in paragraph
10145 @strong{53} . All these pools are accessible by means of @code{with}'ing
10151 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
10154 @code{Storage_Size} is measured in storage units, and refers to the
10155 total space available for an access type collection, or to the primary
10156 stack space for a task.
10161 @strong{56}. Implementation-defined aspects of storage pools. See
10165 See documentation in the sources of the run time mentioned in paragraph
10166 @strong{53} for details on GNAT-defined aspects of storage pools.
10171 @strong{57}. The set of restrictions allowed in a pragma
10172 @code{Restrictions}. See 13.12(7).
10175 @xref{Standard and Implementation Defined Restrictions}.
10180 @strong{58}. The consequences of violating limitations on
10181 @code{Restrictions} pragmas. See 13.12(9).
10184 Restrictions that can be checked at compile time result in illegalities
10185 if violated. Currently there are no other consequences of violating
10191 @strong{59}. The representation used by the @code{Read} and
10192 @code{Write} attributes of elementary types in terms of stream
10193 elements. See 13.13.2(9).
10196 The representation is the in-memory representation of the base type of
10197 the type, using the number of bits corresponding to the
10198 @code{@var{type}'Size} value, and the natural ordering of the machine.
10203 @strong{60}. The names and characteristics of the numeric subtypes
10204 declared in the visible part of package @code{Standard}. See A.1(3).
10207 See items describing the integer and floating-point types supported.
10212 @strong{61}. The accuracy actually achieved by the elementary
10213 functions. See A.5.1(1).
10216 The elementary functions correspond to the functions available in the C
10217 library. Only fast math mode is implemented.
10222 @strong{62}. The sign of a zero result from some of the operators or
10223 functions in @code{Numerics.Generic_Elementary_Functions}, when
10224 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
10227 The sign of zeroes follows the requirements of the IEEE 754 standard on
10233 @strong{63}. The value of
10234 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
10237 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10242 @strong{64}. The value of
10243 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
10246 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10251 @strong{65}. The algorithms for random number generation. See
10255 The algorithm is the Mersenne Twister, as documented in the source file
10256 @file{s-rannum.adb}. This version of the algorithm has a period of
10262 @strong{66}. The string representation of a random number generator's
10263 state. See A.5.2(38).
10266 The value returned by the Image function is the concatenation of
10267 the fixed-width decimal representations of the 624 32-bit integers
10268 of the state vector.
10273 @strong{67}. The minimum time interval between calls to the
10274 time-dependent Reset procedure that are guaranteed to initiate different
10275 random number sequences. See A.5.2(45).
10278 The minimum period between reset calls to guarantee distinct series of
10279 random numbers is one microsecond.
10284 @strong{68}. The values of the @code{Model_Mantissa},
10285 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
10286 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
10287 Annex is not supported. See A.5.3(72).
10290 Run the compiler with @option{-gnatS} to produce a listing of package
10291 @code{Standard}, has the values of all numeric attributes.
10296 @strong{69}. Any implementation-defined characteristics of the
10297 input-output packages. See A.7(14).
10300 There are no special implementation defined characteristics for these
10306 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
10310 All type representations are contiguous, and the @code{Buffer_Size} is
10311 the value of @code{@var{type}'Size} rounded up to the next storage unit
10317 @strong{71}. External files for standard input, standard output, and
10318 standard error See A.10(5).
10321 These files are mapped onto the files provided by the C streams
10322 libraries. See source file @file{i-cstrea.ads} for further details.
10327 @strong{72}. The accuracy of the value produced by @code{Put}. See
10331 If more digits are requested in the output than are represented by the
10332 precision of the value, zeroes are output in the corresponding least
10333 significant digit positions.
10338 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
10339 @code{Command_Name}. See A.15(1).
10342 These are mapped onto the @code{argv} and @code{argc} parameters of the
10343 main program in the natural manner.
10348 @strong{74}. The interpretation of the @code{Form} parameter in procedure
10349 @code{Create_Directory}. See A.16(56).
10352 The @code{Form} parameter is not used.
10357 @strong{75}. The interpretation of the @code{Form} parameter in procedure
10358 @code{Create_Path}. See A.16(60).
10361 The @code{Form} parameter is not used.
10366 @strong{76}. The interpretation of the @code{Form} parameter in procedure
10367 @code{Copy_File}. See A.16(68).
10370 The @code{Form} parameter is case-insensitive.
10372 Two fields are recognized in the @code{Form} parameter:
10376 @item preserve=<value>
10383 <value> starts immediately after the character '=' and ends with the
10384 character immediately preceding the next comma (',') or with the last
10385 character of the parameter.
10387 The only possible values for preserve= are:
10391 @item no_attributes
10392 Do not try to preserve any file attributes. This is the default if no
10393 preserve= is found in Form.
10395 @item all_attributes
10396 Try to preserve all file attributes (timestamps, access rights).
10399 Preserve the timestamp of the copied file, but not the other file attributes.
10404 The only possible values for mode= are:
10409 Only do the copy if the destination file does not already exist. If it already
10410 exists, Copy_File fails.
10413 Copy the file in all cases. Overwrite an already existing destination file.
10416 Append the original file to the destination file. If the destination file does
10417 not exist, the destination file is a copy of the source file. When mode=append,
10418 the field preserve=, if it exists, is not taken into account.
10423 If the Form parameter includes one or both of the fields and the value or
10424 values are incorrect, Copy_file fails with Use_Error.
10426 Examples of correct Forms:
10429 Form => "preserve=no_attributes,mode=overwrite" (the default)
10430 Form => "mode=append"
10431 Form => "mode=copy, preserve=all_attributes"
10435 Examples of incorrect Forms
10438 Form => "preserve=junk"
10439 Form => "mode=internal, preserve=timestamps"
10445 @strong{77}. Implementation-defined convention names. See B.1(11).
10448 The following convention names are supported
10453 @item Ada_Pass_By_Copy
10454 Allowed for any types except by-reference types such as limited
10455 records. Compatible with convention Ada, but causes any parameters
10456 with this convention to be passed by copy.
10457 @item Ada_Pass_By_Reference
10458 Allowed for any types except by-copy types such as scalars.
10459 Compatible with convention Ada, but causes any parameters
10460 with this convention to be passed by reference.
10464 Synonym for Assembler
10466 Synonym for Assembler
10469 @item C_Pass_By_Copy
10470 Allowed only for record types, like C, but also notes that record
10471 is to be passed by copy rather than reference.
10474 @item C_Plus_Plus (or CPP)
10477 Treated the same as C
10479 Treated the same as C
10483 For support of pragma @code{Import} with convention Intrinsic, see
10484 separate section on Intrinsic Subprograms.
10486 Stdcall (used for Windows implementations only). This convention correspond
10487 to the WINAPI (previously called Pascal convention) C/C++ convention under
10488 Windows. A routine with this convention cleans the stack before
10489 exit. This pragma cannot be applied to a dispatching call.
10491 Synonym for Stdcall
10493 Synonym for Stdcall
10495 Stubbed is a special convention used to indicate that the body of the
10496 subprogram will be entirely ignored. Any call to the subprogram
10497 is converted into a raise of the @code{Program_Error} exception. If a
10498 pragma @code{Import} specifies convention @code{stubbed} then no body need
10499 be present at all. This convention is useful during development for the
10500 inclusion of subprograms whose body has not yet been written.
10504 In addition, all otherwise unrecognized convention names are also
10505 treated as being synonymous with convention C@. In all implementations
10506 except for VMS, use of such other names results in a warning. In VMS
10507 implementations, these names are accepted silently.
10512 @strong{78}. The meaning of link names. See B.1(36).
10515 Link names are the actual names used by the linker.
10520 @strong{79}. The manner of choosing link names when neither the link
10521 name nor the address of an imported or exported entity is specified. See
10525 The default linker name is that which would be assigned by the relevant
10526 external language, interpreting the Ada name as being in all lower case
10532 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
10535 The string passed to @code{Linker_Options} is presented uninterpreted as
10536 an argument to the link command, unless it contains ASCII.NUL characters.
10537 NUL characters if they appear act as argument separators, so for example
10539 @smallexample @c ada
10540 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
10544 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
10545 linker. The order of linker options is preserved for a given unit. The final
10546 list of options passed to the linker is in reverse order of the elaboration
10547 order. For example, linker options for a body always appear before the options
10548 from the corresponding package spec.
10553 @strong{81}. The contents of the visible part of package
10554 @code{Interfaces} and its language-defined descendants. See B.2(1).
10557 See files with prefix @file{i-} in the distributed library.
10562 @strong{82}. Implementation-defined children of package
10563 @code{Interfaces}. The contents of the visible part of package
10564 @code{Interfaces}. See B.2(11).
10567 See files with prefix @file{i-} in the distributed library.
10572 @strong{83}. The types @code{Floating}, @code{Long_Floating},
10573 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
10574 @code{COBOL_Character}; and the initialization of the variables
10575 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
10576 @code{Interfaces.COBOL}. See B.4(50).
10582 @item Long_Floating
10583 (Floating) Long_Float
10588 @item Decimal_Element
10590 @item COBOL_Character
10595 For initialization, see the file @file{i-cobol.ads} in the distributed library.
10600 @strong{84}. Support for access to machine instructions. See C.1(1).
10603 See documentation in file @file{s-maccod.ads} in the distributed library.
10608 @strong{85}. Implementation-defined aspects of access to machine
10609 operations. See C.1(9).
10612 See documentation in file @file{s-maccod.ads} in the distributed library.
10617 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
10620 Interrupts are mapped to signals or conditions as appropriate. See
10622 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
10623 on the interrupts supported on a particular target.
10628 @strong{87}. Implementation-defined aspects of pre-elaboration. See
10632 GNAT does not permit a partition to be restarted without reloading,
10633 except under control of the debugger.
10638 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
10641 Pragma @code{Discard_Names} causes names of enumeration literals to
10642 be suppressed. In the presence of this pragma, the Image attribute
10643 provides the image of the Pos of the literal, and Value accepts
10649 @strong{89}. The result of the @code{Task_Identification.Image}
10650 attribute. See C.7.1(7).
10653 The result of this attribute is a string that identifies
10654 the object or component that denotes a given task. If a variable @code{Var}
10655 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
10657 is the hexadecimal representation of the virtual address of the corresponding
10658 task control block. If the variable is an array of tasks, the image of each
10659 task will have the form of an indexed component indicating the position of a
10660 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
10661 component of a record, the image of the task will have the form of a selected
10662 component. These rules are fully recursive, so that the image of a task that
10663 is a subcomponent of a composite object corresponds to the expression that
10664 designates this task.
10666 If a task is created by an allocator, its image depends on the context. If the
10667 allocator is part of an object declaration, the rules described above are used
10668 to construct its image, and this image is not affected by subsequent
10669 assignments. If the allocator appears within an expression, the image
10670 includes only the name of the task type.
10672 If the configuration pragma Discard_Names is present, or if the restriction
10673 No_Implicit_Heap_Allocation is in effect, the image reduces to
10674 the numeric suffix, that is to say the hexadecimal representation of the
10675 virtual address of the control block of the task.
10679 @strong{90}. The value of @code{Current_Task} when in a protected entry
10680 or interrupt handler. See C.7.1(17).
10683 Protected entries or interrupt handlers can be executed by any
10684 convenient thread, so the value of @code{Current_Task} is undefined.
10689 @strong{91}. The effect of calling @code{Current_Task} from an entry
10690 body or interrupt handler. See C.7.1(19).
10693 The effect of calling @code{Current_Task} from an entry body or
10694 interrupt handler is to return the identification of the task currently
10695 executing the code.
10700 @strong{92}. Implementation-defined aspects of
10701 @code{Task_Attributes}. See C.7.2(19).
10704 There are no implementation-defined aspects of @code{Task_Attributes}.
10709 @strong{93}. Values of all @code{Metrics}. See D(2).
10712 The metrics information for GNAT depends on the performance of the
10713 underlying operating system. The sources of the run-time for tasking
10714 implementation, together with the output from @option{-gnatG} can be
10715 used to determine the exact sequence of operating systems calls made
10716 to implement various tasking constructs. Together with appropriate
10717 information on the performance of the underlying operating system,
10718 on the exact target in use, this information can be used to determine
10719 the required metrics.
10724 @strong{94}. The declarations of @code{Any_Priority} and
10725 @code{Priority}. See D.1(11).
10728 See declarations in file @file{system.ads}.
10733 @strong{95}. Implementation-defined execution resources. See D.1(15).
10736 There are no implementation-defined execution resources.
10741 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
10742 access to a protected object keeps its processor busy. See D.2.1(3).
10745 On a multi-processor, a task that is waiting for access to a protected
10746 object does not keep its processor busy.
10751 @strong{97}. The affect of implementation defined execution resources
10752 on task dispatching. See D.2.1(9).
10755 Tasks map to threads in the threads package used by GNAT@. Where possible
10756 and appropriate, these threads correspond to native threads of the
10757 underlying operating system.
10762 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
10763 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
10766 There are no implementation-defined policy-identifiers allowed in this
10772 @strong{99}. Implementation-defined aspects of priority inversion. See
10776 Execution of a task cannot be preempted by the implementation processing
10777 of delay expirations for lower priority tasks.
10782 @strong{100}. Implementation-defined task dispatching. See D.2.2(18).
10785 The policy is the same as that of the underlying threads implementation.
10790 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
10791 in a pragma @code{Locking_Policy}. See D.3(4).
10794 The two implementation defined policies permitted in GNAT are
10795 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
10796 targets that support the @code{Inheritance_Locking} policy, locking is
10797 implemented by inheritance, i.e.@: the task owning the lock operates
10798 at a priority equal to the highest priority of any task currently
10799 requesting the lock. On targets that support the
10800 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
10801 read/write lock allowing multiple propected object functions to enter
10807 @strong{102}. Default ceiling priorities. See D.3(10).
10810 The ceiling priority of protected objects of the type
10811 @code{System.Interrupt_Priority'Last} as described in the Ada
10812 Reference Manual D.3(10),
10817 @strong{103}. The ceiling of any protected object used internally by
10818 the implementation. See D.3(16).
10821 The ceiling priority of internal protected objects is
10822 @code{System.Priority'Last}.
10827 @strong{104}. Implementation-defined queuing policies. See D.4(1).
10830 There are no implementation-defined queuing policies.
10835 @strong{105}. On a multiprocessor, any conditions that cause the
10836 completion of an aborted construct to be delayed later than what is
10837 specified for a single processor. See D.6(3).
10840 The semantics for abort on a multi-processor is the same as on a single
10841 processor, there are no further delays.
10846 @strong{106}. Any operations that implicitly require heap storage
10847 allocation. See D.7(8).
10850 The only operation that implicitly requires heap storage allocation is
10856 @strong{107}. Implementation-defined aspects of pragma
10857 @code{Restrictions}. See D.7(20).
10860 There are no such implementation-defined aspects.
10865 @strong{108}. Implementation-defined aspects of package
10866 @code{Real_Time}. See D.8(17).
10869 There are no implementation defined aspects of package @code{Real_Time}.
10874 @strong{109}. Implementation-defined aspects of
10875 @code{delay_statements}. See D.9(8).
10878 Any difference greater than one microsecond will cause the task to be
10879 delayed (see D.9(7)).
10884 @strong{110}. The upper bound on the duration of interrupt blocking
10885 caused by the implementation. See D.12(5).
10888 The upper bound is determined by the underlying operating system. In
10889 no cases is it more than 10 milliseconds.
10894 @strong{111}. The means for creating and executing distributed
10895 programs. See E(5).
10898 The GLADE package provides a utility GNATDIST for creating and executing
10899 distributed programs. See the GLADE reference manual for further details.
10904 @strong{112}. Any events that can result in a partition becoming
10905 inaccessible. See E.1(7).
10908 See the GLADE reference manual for full details on such events.
10913 @strong{113}. The scheduling policies, treatment of priorities, and
10914 management of shared resources between partitions in certain cases. See
10918 See the GLADE reference manual for full details on these aspects of
10919 multi-partition execution.
10924 @strong{114}. Events that cause the version of a compilation unit to
10925 change. See E.3(5).
10928 Editing the source file of a compilation unit, or the source files of
10929 any units on which it is dependent in a significant way cause the version
10930 to change. No other actions cause the version number to change. All changes
10931 are significant except those which affect only layout, capitalization or
10937 @strong{115}. Whether the execution of the remote subprogram is
10938 immediately aborted as a result of cancellation. See E.4(13).
10941 See the GLADE reference manual for details on the effect of abort in
10942 a distributed application.
10947 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
10950 See the GLADE reference manual for a full description of all implementation
10951 defined aspects of the PCS@.
10956 @strong{117}. Implementation-defined interfaces in the PCS@. See
10960 See the GLADE reference manual for a full description of all
10961 implementation defined interfaces.
10966 @strong{118}. The values of named numbers in the package
10967 @code{Decimal}. See F.2(7).
10979 @item Max_Decimal_Digits
10986 @strong{119}. The value of @code{Max_Picture_Length} in the package
10987 @code{Text_IO.Editing}. See F.3.3(16).
10995 @strong{120}. The value of @code{Max_Picture_Length} in the package
10996 @code{Wide_Text_IO.Editing}. See F.3.4(5).
11004 @strong{121}. The accuracy actually achieved by the complex elementary
11005 functions and by other complex arithmetic operations. See G.1(1).
11008 Standard library functions are used for the complex arithmetic
11009 operations. Only fast math mode is currently supported.
11014 @strong{122}. The sign of a zero result (or a component thereof) from
11015 any operator or function in @code{Numerics.Generic_Complex_Types}, when
11016 @code{Real'Signed_Zeros} is True. See G.1.1(53).
11019 The signs of zero values are as recommended by the relevant
11020 implementation advice.
11025 @strong{123}. The sign of a zero result (or a component thereof) from
11026 any operator or function in
11027 @code{Numerics.Generic_Complex_Elementary_Functions}, when
11028 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
11031 The signs of zero values are as recommended by the relevant
11032 implementation advice.
11037 @strong{124}. Whether the strict mode or the relaxed mode is the
11038 default. See G.2(2).
11041 The strict mode is the default. There is no separate relaxed mode. GNAT
11042 provides a highly efficient implementation of strict mode.
11047 @strong{125}. The result interval in certain cases of fixed-to-float
11048 conversion. See G.2.1(10).
11051 For cases where the result interval is implementation dependent, the
11052 accuracy is that provided by performing all operations in 64-bit IEEE
11053 floating-point format.
11058 @strong{126}. The result of a floating point arithmetic operation in
11059 overflow situations, when the @code{Machine_Overflows} attribute of the
11060 result type is @code{False}. See G.2.1(13).
11063 Infinite and NaN values are produced as dictated by the IEEE
11064 floating-point standard.
11066 Note that on machines that are not fully compliant with the IEEE
11067 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
11068 must be used for achieving IEEE conforming behavior (although at the cost
11069 of a significant performance penalty), so infinite and NaN values are
11070 properly generated.
11075 @strong{127}. The result interval for division (or exponentiation by a
11076 negative exponent), when the floating point hardware implements division
11077 as multiplication by a reciprocal. See G.2.1(16).
11080 Not relevant, division is IEEE exact.
11085 @strong{128}. The definition of close result set, which determines the
11086 accuracy of certain fixed point multiplications and divisions. See
11090 Operations in the close result set are performed using IEEE long format
11091 floating-point arithmetic. The input operands are converted to
11092 floating-point, the operation is done in floating-point, and the result
11093 is converted to the target type.
11098 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
11099 point multiplication or division for which the result shall be in the
11100 perfect result set. See G.2.3(22).
11103 The result is only defined to be in the perfect result set if the result
11104 can be computed by a single scaling operation involving a scale factor
11105 representable in 64-bits.
11110 @strong{130}. The result of a fixed point arithmetic operation in
11111 overflow situations, when the @code{Machine_Overflows} attribute of the
11112 result type is @code{False}. See G.2.3(27).
11115 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
11121 @strong{131}. The result of an elementary function reference in
11122 overflow situations, when the @code{Machine_Overflows} attribute of the
11123 result type is @code{False}. See G.2.4(4).
11126 IEEE infinite and Nan values are produced as appropriate.
11131 @strong{132}. The value of the angle threshold, within which certain
11132 elementary functions, complex arithmetic operations, and complex
11133 elementary functions yield results conforming to a maximum relative
11134 error bound. See G.2.4(10).
11137 Information on this subject is not yet available.
11142 @strong{133}. The accuracy of certain elementary functions for
11143 parameters beyond the angle threshold. See G.2.4(10).
11146 Information on this subject is not yet available.
11151 @strong{134}. The result of a complex arithmetic operation or complex
11152 elementary function reference in overflow situations, when the
11153 @code{Machine_Overflows} attribute of the corresponding real type is
11154 @code{False}. See G.2.6(5).
11157 IEEE infinite and Nan values are produced as appropriate.
11162 @strong{135}. The accuracy of certain complex arithmetic operations and
11163 certain complex elementary functions for parameters (or components
11164 thereof) beyond the angle threshold. See G.2.6(8).
11167 Information on those subjects is not yet available.
11172 @strong{136}. Information regarding bounded errors and erroneous
11173 execution. See H.2(1).
11176 Information on this subject is not yet available.
11181 @strong{137}. Implementation-defined aspects of pragma
11182 @code{Inspection_Point}. See H.3.2(8).
11185 Pragma @code{Inspection_Point} ensures that the variable is live and can
11186 be examined by the debugger at the inspection point.
11191 @strong{138}. Implementation-defined aspects of pragma
11192 @code{Restrictions}. See H.4(25).
11195 There are no implementation-defined aspects of pragma @code{Restrictions}. The
11196 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
11197 generated code. Checks must suppressed by use of pragma @code{Suppress}.
11202 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
11206 There are no restrictions on pragma @code{Restrictions}.
11208 @node Intrinsic Subprograms
11209 @chapter Intrinsic Subprograms
11210 @cindex Intrinsic Subprograms
11213 * Intrinsic Operators::
11214 * Enclosing_Entity::
11215 * Exception_Information::
11216 * Exception_Message::
11220 * Shifts and Rotates::
11221 * Source_Location::
11225 GNAT allows a user application program to write the declaration:
11227 @smallexample @c ada
11228 pragma Import (Intrinsic, name);
11232 providing that the name corresponds to one of the implemented intrinsic
11233 subprograms in GNAT, and that the parameter profile of the referenced
11234 subprogram meets the requirements. This chapter describes the set of
11235 implemented intrinsic subprograms, and the requirements on parameter profiles.
11236 Note that no body is supplied; as with other uses of pragma Import, the
11237 body is supplied elsewhere (in this case by the compiler itself). Note
11238 that any use of this feature is potentially non-portable, since the
11239 Ada standard does not require Ada compilers to implement this feature.
11241 @node Intrinsic Operators
11242 @section Intrinsic Operators
11243 @cindex Intrinsic operator
11246 All the predefined numeric operators in package Standard
11247 in @code{pragma Import (Intrinsic,..)}
11248 declarations. In the binary operator case, the operands must have the same
11249 size. The operand or operands must also be appropriate for
11250 the operator. For example, for addition, the operands must
11251 both be floating-point or both be fixed-point, and the
11252 right operand for @code{"**"} must have a root type of
11253 @code{Standard.Integer'Base}.
11254 You can use an intrinsic operator declaration as in the following example:
11256 @smallexample @c ada
11257 type Int1 is new Integer;
11258 type Int2 is new Integer;
11260 function "+" (X1 : Int1; X2 : Int2) return Int1;
11261 function "+" (X1 : Int1; X2 : Int2) return Int2;
11262 pragma Import (Intrinsic, "+");
11266 This declaration would permit ``mixed mode'' arithmetic on items
11267 of the differing types @code{Int1} and @code{Int2}.
11268 It is also possible to specify such operators for private types, if the
11269 full views are appropriate arithmetic types.
11271 @node Enclosing_Entity
11272 @section Enclosing_Entity
11273 @cindex Enclosing_Entity
11275 This intrinsic subprogram is used in the implementation of the
11276 library routine @code{GNAT.Source_Info}. The only useful use of the
11277 intrinsic import in this case is the one in this unit, so an
11278 application program should simply call the function
11279 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
11280 the current subprogram, package, task, entry, or protected subprogram.
11282 @node Exception_Information
11283 @section Exception_Information
11284 @cindex Exception_Information'
11286 This intrinsic subprogram is used in the implementation of the
11287 library routine @code{GNAT.Current_Exception}. The only useful
11288 use of the intrinsic import in this case is the one in this unit,
11289 so an application program should simply call the function
11290 @code{GNAT.Current_Exception.Exception_Information} to obtain
11291 the exception information associated with the current exception.
11293 @node Exception_Message
11294 @section Exception_Message
11295 @cindex Exception_Message
11297 This intrinsic subprogram is used in the implementation of the
11298 library routine @code{GNAT.Current_Exception}. The only useful
11299 use of the intrinsic import in this case is the one in this unit,
11300 so an application program should simply call the function
11301 @code{GNAT.Current_Exception.Exception_Message} to obtain
11302 the message associated with the current exception.
11304 @node Exception_Name
11305 @section Exception_Name
11306 @cindex Exception_Name
11308 This intrinsic subprogram is used in the implementation of the
11309 library routine @code{GNAT.Current_Exception}. The only useful
11310 use of the intrinsic import in this case is the one in this unit,
11311 so an application program should simply call the function
11312 @code{GNAT.Current_Exception.Exception_Name} to obtain
11313 the name of the current exception.
11319 This intrinsic subprogram is used in the implementation of the
11320 library routine @code{GNAT.Source_Info}. The only useful use of the
11321 intrinsic import in this case is the one in this unit, so an
11322 application program should simply call the function
11323 @code{GNAT.Source_Info.File} to obtain the name of the current
11330 This intrinsic subprogram is used in the implementation of the
11331 library routine @code{GNAT.Source_Info}. The only useful use of the
11332 intrinsic import in this case is the one in this unit, so an
11333 application program should simply call the function
11334 @code{GNAT.Source_Info.Line} to obtain the number of the current
11337 @node Shifts and Rotates
11338 @section Shifts and Rotates
11340 @cindex Shift_Right
11341 @cindex Shift_Right_Arithmetic
11342 @cindex Rotate_Left
11343 @cindex Rotate_Right
11345 In standard Ada, the shift and rotate functions are available only
11346 for the predefined modular types in package @code{Interfaces}. However, in
11347 GNAT it is possible to define these functions for any integer
11348 type (signed or modular), as in this example:
11350 @smallexample @c ada
11351 function Shift_Left
11358 The function name must be one of
11359 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
11360 Rotate_Right. T must be an integer type. T'Size must be
11361 8, 16, 32 or 64 bits; if T is modular, the modulus
11362 must be 2**8, 2**16, 2**32 or 2**64.
11363 The result type must be the same as the type of @code{Value}.
11364 The shift amount must be Natural.
11365 The formal parameter names can be anything.
11367 @node Source_Location
11368 @section Source_Location
11369 @cindex Source_Location
11371 This intrinsic subprogram is used in the implementation of the
11372 library routine @code{GNAT.Source_Info}. The only useful use of the
11373 intrinsic import in this case is the one in this unit, so an
11374 application program should simply call the function
11375 @code{GNAT.Source_Info.Source_Location} to obtain the current
11376 source file location.
11378 @node Representation Clauses and Pragmas
11379 @chapter Representation Clauses and Pragmas
11380 @cindex Representation Clauses
11383 * Alignment Clauses::
11385 * Storage_Size Clauses::
11386 * Size of Variant Record Objects::
11387 * Biased Representation ::
11388 * Value_Size and Object_Size Clauses::
11389 * Component_Size Clauses::
11390 * Bit_Order Clauses::
11391 * Effect of Bit_Order on Byte Ordering::
11392 * Pragma Pack for Arrays::
11393 * Pragma Pack for Records::
11394 * Record Representation Clauses::
11395 * Enumeration Clauses::
11396 * Address Clauses::
11397 * Effect of Convention on Representation::
11398 * Determining the Representations chosen by GNAT::
11402 @cindex Representation Clause
11403 @cindex Representation Pragma
11404 @cindex Pragma, representation
11405 This section describes the representation clauses accepted by GNAT, and
11406 their effect on the representation of corresponding data objects.
11408 GNAT fully implements Annex C (Systems Programming). This means that all
11409 the implementation advice sections in chapter 13 are fully implemented.
11410 However, these sections only require a minimal level of support for
11411 representation clauses. GNAT provides much more extensive capabilities,
11412 and this section describes the additional capabilities provided.
11414 @node Alignment Clauses
11415 @section Alignment Clauses
11416 @cindex Alignment Clause
11419 GNAT requires that all alignment clauses specify a power of 2, and all
11420 default alignments are always a power of 2. The default alignment
11421 values are as follows:
11424 @item @emph{Primitive Types}.
11425 For primitive types, the alignment is the minimum of the actual size of
11426 objects of the type divided by @code{Storage_Unit},
11427 and the maximum alignment supported by the target.
11428 (This maximum alignment is given by the GNAT-specific attribute
11429 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
11430 @cindex @code{Maximum_Alignment} attribute
11431 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
11432 default alignment will be 8 on any target that supports alignments
11433 this large, but on some targets, the maximum alignment may be smaller
11434 than 8, in which case objects of type @code{Long_Float} will be maximally
11437 @item @emph{Arrays}.
11438 For arrays, the alignment is equal to the alignment of the component type
11439 for the normal case where no packing or component size is given. If the
11440 array is packed, and the packing is effective (see separate section on
11441 packed arrays), then the alignment will be one for long packed arrays,
11442 or arrays whose length is not known at compile time. For short packed
11443 arrays, which are handled internally as modular types, the alignment
11444 will be as described for primitive types, e.g.@: a packed array of length
11445 31 bits will have an object size of four bytes, and an alignment of 4.
11447 @item @emph{Records}.
11448 For the normal non-packed case, the alignment of a record is equal to
11449 the maximum alignment of any of its components. For tagged records, this
11450 includes the implicit access type used for the tag. If a pragma @code{Pack}
11451 is used and all components are packable (see separate section on pragma
11452 @code{Pack}), then the resulting alignment is 1, unless the layout of the
11453 record makes it profitable to increase it.
11455 A special case is when:
11458 the size of the record is given explicitly, or a
11459 full record representation clause is given, and
11461 the size of the record is 2, 4, or 8 bytes.
11464 In this case, an alignment is chosen to match the
11465 size of the record. For example, if we have:
11467 @smallexample @c ada
11468 type Small is record
11471 for Small'Size use 16;
11475 then the default alignment of the record type @code{Small} is 2, not 1. This
11476 leads to more efficient code when the record is treated as a unit, and also
11477 allows the type to specified as @code{Atomic} on architectures requiring
11483 An alignment clause may specify a larger alignment than the default value
11484 up to some maximum value dependent on the target (obtainable by using the
11485 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
11486 a smaller alignment than the default value for enumeration, integer and
11487 fixed point types, as well as for record types, for example
11489 @smallexample @c ada
11494 for V'alignment use 1;
11498 @cindex Alignment, default
11499 The default alignment for the type @code{V} is 4, as a result of the
11500 Integer field in the record, but it is permissible, as shown, to
11501 override the default alignment of the record with a smaller value.
11504 @section Size Clauses
11505 @cindex Size Clause
11508 The default size for a type @code{T} is obtainable through the
11509 language-defined attribute @code{T'Size} and also through the
11510 equivalent GNAT-defined attribute @code{T'Value_Size}.
11511 For objects of type @code{T}, GNAT will generally increase the type size
11512 so that the object size (obtainable through the GNAT-defined attribute
11513 @code{T'Object_Size})
11514 is a multiple of @code{T'Alignment * Storage_Unit}.
11517 @smallexample @c ada
11518 type Smallint is range 1 .. 6;
11527 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
11528 as specified by the RM rules,
11529 but objects of this type will have a size of 8
11530 (@code{Smallint'Object_Size} = 8),
11531 since objects by default occupy an integral number
11532 of storage units. On some targets, notably older
11533 versions of the Digital Alpha, the size of stand
11534 alone objects of this type may be 32, reflecting
11535 the inability of the hardware to do byte load/stores.
11537 Similarly, the size of type @code{Rec} is 40 bits
11538 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
11539 the alignment is 4, so objects of this type will have
11540 their size increased to 64 bits so that it is a multiple
11541 of the alignment (in bits). This decision is
11542 in accordance with the specific Implementation Advice in RM 13.3(43):
11545 A @code{Size} clause should be supported for an object if the specified
11546 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
11547 to a size in storage elements that is a multiple of the object's
11548 @code{Alignment} (if the @code{Alignment} is nonzero).
11552 An explicit size clause may be used to override the default size by
11553 increasing it. For example, if we have:
11555 @smallexample @c ada
11556 type My_Boolean is new Boolean;
11557 for My_Boolean'Size use 32;
11561 then values of this type will always be 32 bits long. In the case of
11562 discrete types, the size can be increased up to 64 bits, with the effect
11563 that the entire specified field is used to hold the value, sign- or
11564 zero-extended as appropriate. If more than 64 bits is specified, then
11565 padding space is allocated after the value, and a warning is issued that
11566 there are unused bits.
11568 Similarly the size of records and arrays may be increased, and the effect
11569 is to add padding bits after the value. This also causes a warning message
11572 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
11573 Size in bits, this corresponds to an object of size 256 megabytes (minus
11574 one). This limitation is true on all targets. The reason for this
11575 limitation is that it improves the quality of the code in many cases
11576 if it is known that a Size value can be accommodated in an object of
11579 @node Storage_Size Clauses
11580 @section Storage_Size Clauses
11581 @cindex Storage_Size Clause
11584 For tasks, the @code{Storage_Size} clause specifies the amount of space
11585 to be allocated for the task stack. This cannot be extended, and if the
11586 stack is exhausted, then @code{Storage_Error} will be raised (if stack
11587 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
11588 or a @code{Storage_Size} pragma in the task definition to set the
11589 appropriate required size. A useful technique is to include in every
11590 task definition a pragma of the form:
11592 @smallexample @c ada
11593 pragma Storage_Size (Default_Stack_Size);
11597 Then @code{Default_Stack_Size} can be defined in a global package, and
11598 modified as required. Any tasks requiring stack sizes different from the
11599 default can have an appropriate alternative reference in the pragma.
11601 You can also use the @option{-d} binder switch to modify the default stack
11604 For access types, the @code{Storage_Size} clause specifies the maximum
11605 space available for allocation of objects of the type. If this space is
11606 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
11607 In the case where the access type is declared local to a subprogram, the
11608 use of a @code{Storage_Size} clause triggers automatic use of a special
11609 predefined storage pool (@code{System.Pool_Size}) that ensures that all
11610 space for the pool is automatically reclaimed on exit from the scope in
11611 which the type is declared.
11613 A special case recognized by the compiler is the specification of a
11614 @code{Storage_Size} of zero for an access type. This means that no
11615 items can be allocated from the pool, and this is recognized at compile
11616 time, and all the overhead normally associated with maintaining a fixed
11617 size storage pool is eliminated. Consider the following example:
11619 @smallexample @c ada
11621 type R is array (Natural) of Character;
11622 type P is access all R;
11623 for P'Storage_Size use 0;
11624 -- Above access type intended only for interfacing purposes
11628 procedure g (m : P);
11629 pragma Import (C, g);
11640 As indicated in this example, these dummy storage pools are often useful in
11641 connection with interfacing where no object will ever be allocated. If you
11642 compile the above example, you get the warning:
11645 p.adb:16:09: warning: allocation from empty storage pool
11646 p.adb:16:09: warning: Storage_Error will be raised at run time
11650 Of course in practice, there will not be any explicit allocators in the
11651 case of such an access declaration.
11653 @node Size of Variant Record Objects
11654 @section Size of Variant Record Objects
11655 @cindex Size, variant record objects
11656 @cindex Variant record objects, size
11659 In the case of variant record objects, there is a question whether Size gives
11660 information about a particular variant, or the maximum size required
11661 for any variant. Consider the following program
11663 @smallexample @c ada
11664 with Text_IO; use Text_IO;
11666 type R1 (A : Boolean := False) is record
11668 when True => X : Character;
11669 when False => null;
11677 Put_Line (Integer'Image (V1'Size));
11678 Put_Line (Integer'Image (V2'Size));
11683 Here we are dealing with a variant record, where the True variant
11684 requires 16 bits, and the False variant requires 8 bits.
11685 In the above example, both V1 and V2 contain the False variant,
11686 which is only 8 bits long. However, the result of running the
11695 The reason for the difference here is that the discriminant value of
11696 V1 is fixed, and will always be False. It is not possible to assign
11697 a True variant value to V1, therefore 8 bits is sufficient. On the
11698 other hand, in the case of V2, the initial discriminant value is
11699 False (from the default), but it is possible to assign a True
11700 variant value to V2, therefore 16 bits must be allocated for V2
11701 in the general case, even fewer bits may be needed at any particular
11702 point during the program execution.
11704 As can be seen from the output of this program, the @code{'Size}
11705 attribute applied to such an object in GNAT gives the actual allocated
11706 size of the variable, which is the largest size of any of the variants.
11707 The Ada Reference Manual is not completely clear on what choice should
11708 be made here, but the GNAT behavior seems most consistent with the
11709 language in the RM@.
11711 In some cases, it may be desirable to obtain the size of the current
11712 variant, rather than the size of the largest variant. This can be
11713 achieved in GNAT by making use of the fact that in the case of a
11714 subprogram parameter, GNAT does indeed return the size of the current
11715 variant (because a subprogram has no way of knowing how much space
11716 is actually allocated for the actual).
11718 Consider the following modified version of the above program:
11720 @smallexample @c ada
11721 with Text_IO; use Text_IO;
11723 type R1 (A : Boolean := False) is record
11725 when True => X : Character;
11726 when False => null;
11732 function Size (V : R1) return Integer is
11738 Put_Line (Integer'Image (V2'Size));
11739 Put_Line (Integer'IMage (Size (V2)));
11741 Put_Line (Integer'Image (V2'Size));
11742 Put_Line (Integer'IMage (Size (V2)));
11747 The output from this program is
11757 Here we see that while the @code{'Size} attribute always returns
11758 the maximum size, regardless of the current variant value, the
11759 @code{Size} function does indeed return the size of the current
11762 @node Biased Representation
11763 @section Biased Representation
11764 @cindex Size for biased representation
11765 @cindex Biased representation
11768 In the case of scalars with a range starting at other than zero, it is
11769 possible in some cases to specify a size smaller than the default minimum
11770 value, and in such cases, GNAT uses an unsigned biased representation,
11771 in which zero is used to represent the lower bound, and successive values
11772 represent successive values of the type.
11774 For example, suppose we have the declaration:
11776 @smallexample @c ada
11777 type Small is range -7 .. -4;
11778 for Small'Size use 2;
11782 Although the default size of type @code{Small} is 4, the @code{Size}
11783 clause is accepted by GNAT and results in the following representation
11787 -7 is represented as 2#00#
11788 -6 is represented as 2#01#
11789 -5 is represented as 2#10#
11790 -4 is represented as 2#11#
11794 Biased representation is only used if the specified @code{Size} clause
11795 cannot be accepted in any other manner. These reduced sizes that force
11796 biased representation can be used for all discrete types except for
11797 enumeration types for which a representation clause is given.
11799 @node Value_Size and Object_Size Clauses
11800 @section Value_Size and Object_Size Clauses
11802 @findex Object_Size
11803 @cindex Size, of objects
11806 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
11807 number of bits required to hold values of type @code{T}.
11808 Although this interpretation was allowed in Ada 83, it was not required,
11809 and this requirement in practice can cause some significant difficulties.
11810 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
11811 However, in Ada 95 and Ada 2005,
11812 @code{Natural'Size} is
11813 typically 31. This means that code may change in behavior when moving
11814 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
11816 @smallexample @c ada
11817 type Rec is record;
11823 at 0 range 0 .. Natural'Size - 1;
11824 at 0 range Natural'Size .. 2 * Natural'Size - 1;
11829 In the above code, since the typical size of @code{Natural} objects
11830 is 32 bits and @code{Natural'Size} is 31, the above code can cause
11831 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
11832 there are cases where the fact that the object size can exceed the
11833 size of the type causes surprises.
11835 To help get around this problem GNAT provides two implementation
11836 defined attributes, @code{Value_Size} and @code{Object_Size}. When
11837 applied to a type, these attributes yield the size of the type
11838 (corresponding to the RM defined size attribute), and the size of
11839 objects of the type respectively.
11841 The @code{Object_Size} is used for determining the default size of
11842 objects and components. This size value can be referred to using the
11843 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
11844 the basis of the determination of the size. The backend is free to
11845 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
11846 character might be stored in 32 bits on a machine with no efficient
11847 byte access instructions such as the Alpha.
11849 The default rules for the value of @code{Object_Size} for
11850 discrete types are as follows:
11854 The @code{Object_Size} for base subtypes reflect the natural hardware
11855 size in bits (run the compiler with @option{-gnatS} to find those values
11856 for numeric types). Enumeration types and fixed-point base subtypes have
11857 8, 16, 32 or 64 bits for this size, depending on the range of values
11861 The @code{Object_Size} of a subtype is the same as the
11862 @code{Object_Size} of
11863 the type from which it is obtained.
11866 The @code{Object_Size} of a derived base type is copied from the parent
11867 base type, and the @code{Object_Size} of a derived first subtype is copied
11868 from the parent first subtype.
11872 The @code{Value_Size} attribute
11873 is the (minimum) number of bits required to store a value
11875 This value is used to determine how tightly to pack
11876 records or arrays with components of this type, and also affects
11877 the semantics of unchecked conversion (unchecked conversions where
11878 the @code{Value_Size} values differ generate a warning, and are potentially
11881 The default rules for the value of @code{Value_Size} are as follows:
11885 The @code{Value_Size} for a base subtype is the minimum number of bits
11886 required to store all values of the type (including the sign bit
11887 only if negative values are possible).
11890 If a subtype statically matches the first subtype of a given type, then it has
11891 by default the same @code{Value_Size} as the first subtype. This is a
11892 consequence of RM 13.1(14) (``if two subtypes statically match,
11893 then their subtype-specific aspects are the same''.)
11896 All other subtypes have a @code{Value_Size} corresponding to the minimum
11897 number of bits required to store all values of the subtype. For
11898 dynamic bounds, it is assumed that the value can range down or up
11899 to the corresponding bound of the ancestor
11903 The RM defined attribute @code{Size} corresponds to the
11904 @code{Value_Size} attribute.
11906 The @code{Size} attribute may be defined for a first-named subtype. This sets
11907 the @code{Value_Size} of
11908 the first-named subtype to the given value, and the
11909 @code{Object_Size} of this first-named subtype to the given value padded up
11910 to an appropriate boundary. It is a consequence of the default rules
11911 above that this @code{Object_Size} will apply to all further subtypes. On the
11912 other hand, @code{Value_Size} is affected only for the first subtype, any
11913 dynamic subtypes obtained from it directly, and any statically matching
11914 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
11916 @code{Value_Size} and
11917 @code{Object_Size} may be explicitly set for any subtype using
11918 an attribute definition clause. Note that the use of these attributes
11919 can cause the RM 13.1(14) rule to be violated. If two access types
11920 reference aliased objects whose subtypes have differing @code{Object_Size}
11921 values as a result of explicit attribute definition clauses, then it
11922 is erroneous to convert from one access subtype to the other.
11924 At the implementation level, Esize stores the Object_Size and the
11925 RM_Size field stores the @code{Value_Size} (and hence the value of the
11926 @code{Size} attribute,
11927 which, as noted above, is equivalent to @code{Value_Size}).
11929 To get a feel for the difference, consider the following examples (note
11930 that in each case the base is @code{Short_Short_Integer} with a size of 8):
11933 Object_Size Value_Size
11935 type x1 is range 0 .. 5; 8 3
11937 type x2 is range 0 .. 5;
11938 for x2'size use 12; 16 12
11940 subtype x3 is x2 range 0 .. 3; 16 2
11942 subtype x4 is x2'base range 0 .. 10; 8 4
11944 subtype x5 is x2 range 0 .. dynamic; 16 3*
11946 subtype x6 is x2'base range 0 .. dynamic; 8 3*
11951 Note: the entries marked ``3*'' are not actually specified by the Ada
11952 Reference Manual, but it seems in the spirit of the RM rules to allocate
11953 the minimum number of bits (here 3, given the range for @code{x2})
11954 known to be large enough to hold the given range of values.
11956 So far, so good, but GNAT has to obey the RM rules, so the question is
11957 under what conditions must the RM @code{Size} be used.
11958 The following is a list
11959 of the occasions on which the RM @code{Size} must be used:
11963 Component size for packed arrays or records
11966 Value of the attribute @code{Size} for a type
11969 Warning about sizes not matching for unchecked conversion
11973 For record types, the @code{Object_Size} is always a multiple of the
11974 alignment of the type (this is true for all types). In some cases the
11975 @code{Value_Size} can be smaller. Consider:
11985 On a typical 32-bit architecture, the X component will be four bytes, and
11986 require four-byte alignment, and the Y component will be one byte. In this
11987 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
11988 required to store a value of this type, and for example, it is permissible
11989 to have a component of type R in an outer array whose component size is
11990 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
11991 since it must be rounded up so that this value is a multiple of the
11992 alignment (4 bytes = 32 bits).
11995 For all other types, the @code{Object_Size}
11996 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
11997 Only @code{Size} may be specified for such types.
11999 @node Component_Size Clauses
12000 @section Component_Size Clauses
12001 @cindex Component_Size Clause
12004 Normally, the value specified in a component size clause must be consistent
12005 with the subtype of the array component with regard to size and alignment.
12006 In other words, the value specified must be at least equal to the size
12007 of this subtype, and must be a multiple of the alignment value.
12009 In addition, component size clauses are allowed which cause the array
12010 to be packed, by specifying a smaller value. A first case is for
12011 component size values in the range 1 through 63. The value specified
12012 must not be smaller than the Size of the subtype. GNAT will accurately
12013 honor all packing requests in this range. For example, if we have:
12015 @smallexample @c ada
12016 type r is array (1 .. 8) of Natural;
12017 for r'Component_Size use 31;
12021 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
12022 Of course access to the components of such an array is considerably
12023 less efficient than if the natural component size of 32 is used.
12024 A second case is when the subtype of the component is a record type
12025 padded because of its default alignment. For example, if we have:
12027 @smallexample @c ada
12034 type a is array (1 .. 8) of r;
12035 for a'Component_Size use 72;
12039 then the resulting array has a length of 72 bytes, instead of 96 bytes
12040 if the alignment of the record (4) was obeyed.
12042 Note that there is no point in giving both a component size clause
12043 and a pragma Pack for the same array type. if such duplicate
12044 clauses are given, the pragma Pack will be ignored.
12046 @node Bit_Order Clauses
12047 @section Bit_Order Clauses
12048 @cindex Bit_Order Clause
12049 @cindex bit ordering
12050 @cindex ordering, of bits
12053 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
12054 attribute. The specification may either correspond to the default bit
12055 order for the target, in which case the specification has no effect and
12056 places no additional restrictions, or it may be for the non-standard
12057 setting (that is the opposite of the default).
12059 In the case where the non-standard value is specified, the effect is
12060 to renumber bits within each byte, but the ordering of bytes is not
12061 affected. There are certain
12062 restrictions placed on component clauses as follows:
12066 @item Components fitting within a single storage unit.
12068 These are unrestricted, and the effect is merely to renumber bits. For
12069 example if we are on a little-endian machine with @code{Low_Order_First}
12070 being the default, then the following two declarations have exactly
12073 @smallexample @c ada
12076 B : Integer range 1 .. 120;
12080 A at 0 range 0 .. 0;
12081 B at 0 range 1 .. 7;
12086 B : Integer range 1 .. 120;
12089 for R2'Bit_Order use High_Order_First;
12092 A at 0 range 7 .. 7;
12093 B at 0 range 0 .. 6;
12098 The useful application here is to write the second declaration with the
12099 @code{Bit_Order} attribute definition clause, and know that it will be treated
12100 the same, regardless of whether the target is little-endian or big-endian.
12102 @item Components occupying an integral number of bytes.
12104 These are components that exactly fit in two or more bytes. Such component
12105 declarations are allowed, but have no effect, since it is important to realize
12106 that the @code{Bit_Order} specification does not affect the ordering of bytes.
12107 In particular, the following attempt at getting an endian-independent integer
12110 @smallexample @c ada
12115 for R2'Bit_Order use High_Order_First;
12118 A at 0 range 0 .. 31;
12123 This declaration will result in a little-endian integer on a
12124 little-endian machine, and a big-endian integer on a big-endian machine.
12125 If byte flipping is required for interoperability between big- and
12126 little-endian machines, this must be explicitly programmed. This capability
12127 is not provided by @code{Bit_Order}.
12129 @item Components that are positioned across byte boundaries
12131 but do not occupy an integral number of bytes. Given that bytes are not
12132 reordered, such fields would occupy a non-contiguous sequence of bits
12133 in memory, requiring non-trivial code to reassemble. They are for this
12134 reason not permitted, and any component clause specifying such a layout
12135 will be flagged as illegal by GNAT@.
12140 Since the misconception that Bit_Order automatically deals with all
12141 endian-related incompatibilities is a common one, the specification of
12142 a component field that is an integral number of bytes will always
12143 generate a warning. This warning may be suppressed using @code{pragma
12144 Warnings (Off)} if desired. The following section contains additional
12145 details regarding the issue of byte ordering.
12147 @node Effect of Bit_Order on Byte Ordering
12148 @section Effect of Bit_Order on Byte Ordering
12149 @cindex byte ordering
12150 @cindex ordering, of bytes
12153 In this section we will review the effect of the @code{Bit_Order} attribute
12154 definition clause on byte ordering. Briefly, it has no effect at all, but
12155 a detailed example will be helpful. Before giving this
12156 example, let us review the precise
12157 definition of the effect of defining @code{Bit_Order}. The effect of a
12158 non-standard bit order is described in section 15.5.3 of the Ada
12162 2 A bit ordering is a method of interpreting the meaning of
12163 the storage place attributes.
12167 To understand the precise definition of storage place attributes in
12168 this context, we visit section 13.5.1 of the manual:
12171 13 A record_representation_clause (without the mod_clause)
12172 specifies the layout. The storage place attributes (see 13.5.2)
12173 are taken from the values of the position, first_bit, and last_bit
12174 expressions after normalizing those values so that first_bit is
12175 less than Storage_Unit.
12179 The critical point here is that storage places are taken from
12180 the values after normalization, not before. So the @code{Bit_Order}
12181 interpretation applies to normalized values. The interpretation
12182 is described in the later part of the 15.5.3 paragraph:
12185 2 A bit ordering is a method of interpreting the meaning of
12186 the storage place attributes. High_Order_First (known in the
12187 vernacular as ``big endian'') means that the first bit of a
12188 storage element (bit 0) is the most significant bit (interpreting
12189 the sequence of bits that represent a component as an unsigned
12190 integer value). Low_Order_First (known in the vernacular as
12191 ``little endian'') means the opposite: the first bit is the
12196 Note that the numbering is with respect to the bits of a storage
12197 unit. In other words, the specification affects only the numbering
12198 of bits within a single storage unit.
12200 We can make the effect clearer by giving an example.
12202 Suppose that we have an external device which presents two bytes, the first
12203 byte presented, which is the first (low addressed byte) of the two byte
12204 record is called Master, and the second byte is called Slave.
12206 The left most (most significant bit is called Control for each byte, and
12207 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
12208 (least significant) bit.
12210 On a big-endian machine, we can write the following representation clause
12212 @smallexample @c ada
12213 type Data is record
12214 Master_Control : Bit;
12222 Slave_Control : Bit;
12232 for Data use record
12233 Master_Control at 0 range 0 .. 0;
12234 Master_V1 at 0 range 1 .. 1;
12235 Master_V2 at 0 range 2 .. 2;
12236 Master_V3 at 0 range 3 .. 3;
12237 Master_V4 at 0 range 4 .. 4;
12238 Master_V5 at 0 range 5 .. 5;
12239 Master_V6 at 0 range 6 .. 6;
12240 Master_V7 at 0 range 7 .. 7;
12241 Slave_Control at 1 range 0 .. 0;
12242 Slave_V1 at 1 range 1 .. 1;
12243 Slave_V2 at 1 range 2 .. 2;
12244 Slave_V3 at 1 range 3 .. 3;
12245 Slave_V4 at 1 range 4 .. 4;
12246 Slave_V5 at 1 range 5 .. 5;
12247 Slave_V6 at 1 range 6 .. 6;
12248 Slave_V7 at 1 range 7 .. 7;
12253 Now if we move this to a little endian machine, then the bit ordering within
12254 the byte is backwards, so we have to rewrite the record rep clause as:
12256 @smallexample @c ada
12257 for Data use record
12258 Master_Control at 0 range 7 .. 7;
12259 Master_V1 at 0 range 6 .. 6;
12260 Master_V2 at 0 range 5 .. 5;
12261 Master_V3 at 0 range 4 .. 4;
12262 Master_V4 at 0 range 3 .. 3;
12263 Master_V5 at 0 range 2 .. 2;
12264 Master_V6 at 0 range 1 .. 1;
12265 Master_V7 at 0 range 0 .. 0;
12266 Slave_Control at 1 range 7 .. 7;
12267 Slave_V1 at 1 range 6 .. 6;
12268 Slave_V2 at 1 range 5 .. 5;
12269 Slave_V3 at 1 range 4 .. 4;
12270 Slave_V4 at 1 range 3 .. 3;
12271 Slave_V5 at 1 range 2 .. 2;
12272 Slave_V6 at 1 range 1 .. 1;
12273 Slave_V7 at 1 range 0 .. 0;
12278 It is a nuisance to have to rewrite the clause, especially if
12279 the code has to be maintained on both machines. However,
12280 this is a case that we can handle with the
12281 @code{Bit_Order} attribute if it is implemented.
12282 Note that the implementation is not required on byte addressed
12283 machines, but it is indeed implemented in GNAT.
12284 This means that we can simply use the
12285 first record clause, together with the declaration
12287 @smallexample @c ada
12288 for Data'Bit_Order use High_Order_First;
12292 and the effect is what is desired, namely the layout is exactly the same,
12293 independent of whether the code is compiled on a big-endian or little-endian
12296 The important point to understand is that byte ordering is not affected.
12297 A @code{Bit_Order} attribute definition never affects which byte a field
12298 ends up in, only where it ends up in that byte.
12299 To make this clear, let us rewrite the record rep clause of the previous
12302 @smallexample @c ada
12303 for Data'Bit_Order use High_Order_First;
12304 for Data use record
12305 Master_Control at 0 range 0 .. 0;
12306 Master_V1 at 0 range 1 .. 1;
12307 Master_V2 at 0 range 2 .. 2;
12308 Master_V3 at 0 range 3 .. 3;
12309 Master_V4 at 0 range 4 .. 4;
12310 Master_V5 at 0 range 5 .. 5;
12311 Master_V6 at 0 range 6 .. 6;
12312 Master_V7 at 0 range 7 .. 7;
12313 Slave_Control at 0 range 8 .. 8;
12314 Slave_V1 at 0 range 9 .. 9;
12315 Slave_V2 at 0 range 10 .. 10;
12316 Slave_V3 at 0 range 11 .. 11;
12317 Slave_V4 at 0 range 12 .. 12;
12318 Slave_V5 at 0 range 13 .. 13;
12319 Slave_V6 at 0 range 14 .. 14;
12320 Slave_V7 at 0 range 15 .. 15;
12325 This is exactly equivalent to saying (a repeat of the first example):
12327 @smallexample @c ada
12328 for Data'Bit_Order use High_Order_First;
12329 for Data use record
12330 Master_Control at 0 range 0 .. 0;
12331 Master_V1 at 0 range 1 .. 1;
12332 Master_V2 at 0 range 2 .. 2;
12333 Master_V3 at 0 range 3 .. 3;
12334 Master_V4 at 0 range 4 .. 4;
12335 Master_V5 at 0 range 5 .. 5;
12336 Master_V6 at 0 range 6 .. 6;
12337 Master_V7 at 0 range 7 .. 7;
12338 Slave_Control at 1 range 0 .. 0;
12339 Slave_V1 at 1 range 1 .. 1;
12340 Slave_V2 at 1 range 2 .. 2;
12341 Slave_V3 at 1 range 3 .. 3;
12342 Slave_V4 at 1 range 4 .. 4;
12343 Slave_V5 at 1 range 5 .. 5;
12344 Slave_V6 at 1 range 6 .. 6;
12345 Slave_V7 at 1 range 7 .. 7;
12350 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
12351 field. The storage place attributes are obtained by normalizing the
12352 values given so that the @code{First_Bit} value is less than 8. After
12353 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
12354 we specified in the other case.
12356 Now one might expect that the @code{Bit_Order} attribute might affect
12357 bit numbering within the entire record component (two bytes in this
12358 case, thus affecting which byte fields end up in), but that is not
12359 the way this feature is defined, it only affects numbering of bits,
12360 not which byte they end up in.
12362 Consequently it never makes sense to specify a starting bit number
12363 greater than 7 (for a byte addressable field) if an attribute
12364 definition for @code{Bit_Order} has been given, and indeed it
12365 may be actively confusing to specify such a value, so the compiler
12366 generates a warning for such usage.
12368 If you do need to control byte ordering then appropriate conditional
12369 values must be used. If in our example, the slave byte came first on
12370 some machines we might write:
12372 @smallexample @c ada
12373 Master_Byte_First constant Boolean := @dots{};
12375 Master_Byte : constant Natural :=
12376 1 - Boolean'Pos (Master_Byte_First);
12377 Slave_Byte : constant Natural :=
12378 Boolean'Pos (Master_Byte_First);
12380 for Data'Bit_Order use High_Order_First;
12381 for Data use record
12382 Master_Control at Master_Byte range 0 .. 0;
12383 Master_V1 at Master_Byte range 1 .. 1;
12384 Master_V2 at Master_Byte range 2 .. 2;
12385 Master_V3 at Master_Byte range 3 .. 3;
12386 Master_V4 at Master_Byte range 4 .. 4;
12387 Master_V5 at Master_Byte range 5 .. 5;
12388 Master_V6 at Master_Byte range 6 .. 6;
12389 Master_V7 at Master_Byte range 7 .. 7;
12390 Slave_Control at Slave_Byte range 0 .. 0;
12391 Slave_V1 at Slave_Byte range 1 .. 1;
12392 Slave_V2 at Slave_Byte range 2 .. 2;
12393 Slave_V3 at Slave_Byte range 3 .. 3;
12394 Slave_V4 at Slave_Byte range 4 .. 4;
12395 Slave_V5 at Slave_Byte range 5 .. 5;
12396 Slave_V6 at Slave_Byte range 6 .. 6;
12397 Slave_V7 at Slave_Byte range 7 .. 7;
12402 Now to switch between machines, all that is necessary is
12403 to set the boolean constant @code{Master_Byte_First} in
12404 an appropriate manner.
12406 @node Pragma Pack for Arrays
12407 @section Pragma Pack for Arrays
12408 @cindex Pragma Pack (for arrays)
12411 Pragma @code{Pack} applied to an array has no effect unless the component type
12412 is packable. For a component type to be packable, it must be one of the
12419 Any type whose size is specified with a size clause
12421 Any packed array type with a static size
12423 Any record type padded because of its default alignment
12427 For all these cases, if the component subtype size is in the range
12428 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
12429 component size were specified giving the component subtype size.
12430 For example if we have:
12432 @smallexample @c ada
12433 type r is range 0 .. 17;
12435 type ar is array (1 .. 8) of r;
12440 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
12441 and the size of the array @code{ar} will be exactly 40 bits.
12443 Note that in some cases this rather fierce approach to packing can produce
12444 unexpected effects. For example, in Ada 95 and Ada 2005,
12445 subtype @code{Natural} typically has a size of 31, meaning that if you
12446 pack an array of @code{Natural}, you get 31-bit
12447 close packing, which saves a few bits, but results in far less efficient
12448 access. Since many other Ada compilers will ignore such a packing request,
12449 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
12450 might not be what is intended. You can easily remove this warning by
12451 using an explicit @code{Component_Size} setting instead, which never generates
12452 a warning, since the intention of the programmer is clear in this case.
12454 GNAT treats packed arrays in one of two ways. If the size of the array is
12455 known at compile time and is less than 64 bits, then internally the array
12456 is represented as a single modular type, of exactly the appropriate number
12457 of bits. If the length is greater than 63 bits, or is not known at compile
12458 time, then the packed array is represented as an array of bytes, and the
12459 length is always a multiple of 8 bits.
12461 Note that to represent a packed array as a modular type, the alignment must
12462 be suitable for the modular type involved. For example, on typical machines
12463 a 32-bit packed array will be represented by a 32-bit modular integer with
12464 an alignment of four bytes. If you explicitly override the default alignment
12465 with an alignment clause that is too small, the modular representation
12466 cannot be used. For example, consider the following set of declarations:
12468 @smallexample @c ada
12469 type R is range 1 .. 3;
12470 type S is array (1 .. 31) of R;
12471 for S'Component_Size use 2;
12473 for S'Alignment use 1;
12477 If the alignment clause were not present, then a 62-bit modular
12478 representation would be chosen (typically with an alignment of 4 or 8
12479 bytes depending on the target). But the default alignment is overridden
12480 with the explicit alignment clause. This means that the modular
12481 representation cannot be used, and instead the array of bytes
12482 representation must be used, meaning that the length must be a multiple
12483 of 8. Thus the above set of declarations will result in a diagnostic
12484 rejecting the size clause and noting that the minimum size allowed is 64.
12486 @cindex Pragma Pack (for type Natural)
12487 @cindex Pragma Pack warning
12489 One special case that is worth noting occurs when the base type of the
12490 component size is 8/16/32 and the subtype is one bit less. Notably this
12491 occurs with subtype @code{Natural}. Consider:
12493 @smallexample @c ada
12494 type Arr is array (1 .. 32) of Natural;
12499 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
12500 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
12501 Ada 83 compilers did not attempt 31 bit packing.
12503 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
12504 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
12505 substantial unintended performance penalty when porting legacy Ada 83 code.
12506 To help prevent this, GNAT generates a warning in such cases. If you really
12507 want 31 bit packing in a case like this, you can set the component size
12510 @smallexample @c ada
12511 type Arr is array (1 .. 32) of Natural;
12512 for Arr'Component_Size use 31;
12516 Here 31-bit packing is achieved as required, and no warning is generated,
12517 since in this case the programmer intention is clear.
12519 @node Pragma Pack for Records
12520 @section Pragma Pack for Records
12521 @cindex Pragma Pack (for records)
12524 Pragma @code{Pack} applied to a record will pack the components to reduce
12525 wasted space from alignment gaps and by reducing the amount of space
12526 taken by components. We distinguish between @emph{packable} components and
12527 @emph{non-packable} components.
12528 Components of the following types are considered packable:
12531 All primitive types are packable.
12534 Small packed arrays, whose size does not exceed 64 bits, and where the
12535 size is statically known at compile time, are represented internally
12536 as modular integers, and so they are also packable.
12541 All packable components occupy the exact number of bits corresponding to
12542 their @code{Size} value, and are packed with no padding bits, i.e.@: they
12543 can start on an arbitrary bit boundary.
12545 All other types are non-packable, they occupy an integral number of
12547 are placed at a boundary corresponding to their alignment requirements.
12549 For example, consider the record
12551 @smallexample @c ada
12552 type Rb1 is array (1 .. 13) of Boolean;
12555 type Rb2 is array (1 .. 65) of Boolean;
12570 The representation for the record x2 is as follows:
12572 @smallexample @c ada
12573 for x2'Size use 224;
12575 l1 at 0 range 0 .. 0;
12576 l2 at 0 range 1 .. 64;
12577 l3 at 12 range 0 .. 31;
12578 l4 at 16 range 0 .. 0;
12579 l5 at 16 range 1 .. 13;
12580 l6 at 18 range 0 .. 71;
12585 Studying this example, we see that the packable fields @code{l1}
12587 of length equal to their sizes, and placed at specific bit boundaries (and
12588 not byte boundaries) to
12589 eliminate padding. But @code{l3} is of a non-packable float type, so
12590 it is on the next appropriate alignment boundary.
12592 The next two fields are fully packable, so @code{l4} and @code{l5} are
12593 minimally packed with no gaps. However, type @code{Rb2} is a packed
12594 array that is longer than 64 bits, so it is itself non-packable. Thus
12595 the @code{l6} field is aligned to the next byte boundary, and takes an
12596 integral number of bytes, i.e.@: 72 bits.
12598 @node Record Representation Clauses
12599 @section Record Representation Clauses
12600 @cindex Record Representation Clause
12603 Record representation clauses may be given for all record types, including
12604 types obtained by record extension. Component clauses are allowed for any
12605 static component. The restrictions on component clauses depend on the type
12608 @cindex Component Clause
12609 For all components of an elementary type, the only restriction on component
12610 clauses is that the size must be at least the 'Size value of the type
12611 (actually the Value_Size). There are no restrictions due to alignment,
12612 and such components may freely cross storage boundaries.
12614 Packed arrays with a size up to and including 64 bits are represented
12615 internally using a modular type with the appropriate number of bits, and
12616 thus the same lack of restriction applies. For example, if you declare:
12618 @smallexample @c ada
12619 type R is array (1 .. 49) of Boolean;
12625 then a component clause for a component of type R may start on any
12626 specified bit boundary, and may specify a value of 49 bits or greater.
12628 For packed bit arrays that are longer than 64 bits, there are two
12629 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
12630 including the important case of single bits or boolean values, then
12631 there are no limitations on placement of such components, and they
12632 may start and end at arbitrary bit boundaries.
12634 If the component size is not a power of 2 (e.g.@: 3 or 5), then
12635 an array of this type longer than 64 bits must always be placed on
12636 on a storage unit (byte) boundary and occupy an integral number
12637 of storage units (bytes). Any component clause that does not
12638 meet this requirement will be rejected.
12640 Any aliased component, or component of an aliased type, must
12641 have its normal alignment and size. A component clause that
12642 does not meet this requirement will be rejected.
12644 The tag field of a tagged type always occupies an address sized field at
12645 the start of the record. No component clause may attempt to overlay this
12646 tag. When a tagged type appears as a component, the tag field must have
12649 In the case of a record extension T1, of a type T, no component clause applied
12650 to the type T1 can specify a storage location that would overlap the first
12651 T'Size bytes of the record.
12653 For all other component types, including non-bit-packed arrays,
12654 the component can be placed at an arbitrary bit boundary,
12655 so for example, the following is permitted:
12657 @smallexample @c ada
12658 type R is array (1 .. 10) of Boolean;
12667 G at 0 range 0 .. 0;
12668 H at 0 range 1 .. 1;
12669 L at 0 range 2 .. 81;
12670 R at 0 range 82 .. 161;
12675 Note: the above rules apply to recent releases of GNAT 5.
12676 In GNAT 3, there are more severe restrictions on larger components.
12677 For non-primitive types, including packed arrays with a size greater than
12678 64 bits, component clauses must respect the alignment requirement of the
12679 type, in particular, always starting on a byte boundary, and the length
12680 must be a multiple of the storage unit.
12682 @node Enumeration Clauses
12683 @section Enumeration Clauses
12685 The only restriction on enumeration clauses is that the range of values
12686 must be representable. For the signed case, if one or more of the
12687 representation values are negative, all values must be in the range:
12689 @smallexample @c ada
12690 System.Min_Int .. System.Max_Int
12694 For the unsigned case, where all values are nonnegative, the values must
12697 @smallexample @c ada
12698 0 .. System.Max_Binary_Modulus;
12702 A @emph{confirming} representation clause is one in which the values range
12703 from 0 in sequence, i.e.@: a clause that confirms the default representation
12704 for an enumeration type.
12705 Such a confirming representation
12706 is permitted by these rules, and is specially recognized by the compiler so
12707 that no extra overhead results from the use of such a clause.
12709 If an array has an index type which is an enumeration type to which an
12710 enumeration clause has been applied, then the array is stored in a compact
12711 manner. Consider the declarations:
12713 @smallexample @c ada
12714 type r is (A, B, C);
12715 for r use (A => 1, B => 5, C => 10);
12716 type t is array (r) of Character;
12720 The array type t corresponds to a vector with exactly three elements and
12721 has a default size equal to @code{3*Character'Size}. This ensures efficient
12722 use of space, but means that accesses to elements of the array will incur
12723 the overhead of converting representation values to the corresponding
12724 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
12726 @node Address Clauses
12727 @section Address Clauses
12728 @cindex Address Clause
12730 The reference manual allows a general restriction on representation clauses,
12731 as found in RM 13.1(22):
12734 An implementation need not support representation
12735 items containing nonstatic expressions, except that
12736 an implementation should support a representation item
12737 for a given entity if each nonstatic expression in the
12738 representation item is a name that statically denotes
12739 a constant declared before the entity.
12743 In practice this is applicable only to address clauses, since this is the
12744 only case in which a non-static expression is permitted by the syntax. As
12745 the AARM notes in sections 13.1 (22.a-22.h):
12748 22.a Reason: This is to avoid the following sort of thing:
12750 22.b X : Integer := F(@dots{});
12751 Y : Address := G(@dots{});
12752 for X'Address use Y;
12754 22.c In the above, we have to evaluate the
12755 initialization expression for X before we
12756 know where to put the result. This seems
12757 like an unreasonable implementation burden.
12759 22.d The above code should instead be written
12762 22.e Y : constant Address := G(@dots{});
12763 X : Integer := F(@dots{});
12764 for X'Address use Y;
12766 22.f This allows the expression ``Y'' to be safely
12767 evaluated before X is created.
12769 22.g The constant could be a formal parameter of mode in.
12771 22.h An implementation can support other nonstatic
12772 expressions if it wants to. Expressions of type
12773 Address are hardly ever static, but their value
12774 might be known at compile time anyway in many
12779 GNAT does indeed permit many additional cases of non-static expressions. In
12780 particular, if the type involved is elementary there are no restrictions
12781 (since in this case, holding a temporary copy of the initialization value,
12782 if one is present, is inexpensive). In addition, if there is no implicit or
12783 explicit initialization, then there are no restrictions. GNAT will reject
12784 only the case where all three of these conditions hold:
12789 The type of the item is non-elementary (e.g.@: a record or array).
12792 There is explicit or implicit initialization required for the object.
12793 Note that access values are always implicitly initialized.
12796 The address value is non-static. Here GNAT is more permissive than the
12797 RM, and allows the address value to be the address of a previously declared
12798 stand-alone variable, as long as it does not itself have an address clause.
12800 @smallexample @c ada
12801 Anchor : Some_Initialized_Type;
12802 Overlay : Some_Initialized_Type;
12803 for Overlay'Address use Anchor'Address;
12807 However, the prefix of the address clause cannot be an array component, or
12808 a component of a discriminated record.
12813 As noted above in section 22.h, address values are typically non-static. In
12814 particular the To_Address function, even if applied to a literal value, is
12815 a non-static function call. To avoid this minor annoyance, GNAT provides
12816 the implementation defined attribute 'To_Address. The following two
12817 expressions have identical values:
12821 @smallexample @c ada
12822 To_Address (16#1234_0000#)
12823 System'To_Address (16#1234_0000#);
12827 except that the second form is considered to be a static expression, and
12828 thus when used as an address clause value is always permitted.
12831 Additionally, GNAT treats as static an address clause that is an
12832 unchecked_conversion of a static integer value. This simplifies the porting
12833 of legacy code, and provides a portable equivalent to the GNAT attribute
12836 Another issue with address clauses is the interaction with alignment
12837 requirements. When an address clause is given for an object, the address
12838 value must be consistent with the alignment of the object (which is usually
12839 the same as the alignment of the type of the object). If an address clause
12840 is given that specifies an inappropriately aligned address value, then the
12841 program execution is erroneous.
12843 Since this source of erroneous behavior can have unfortunate effects, GNAT
12844 checks (at compile time if possible, generating a warning, or at execution
12845 time with a run-time check) that the alignment is appropriate. If the
12846 run-time check fails, then @code{Program_Error} is raised. This run-time
12847 check is suppressed if range checks are suppressed, or if the special GNAT
12848 check Alignment_Check is suppressed, or if
12849 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
12851 Finally, GNAT does not permit overlaying of objects of controlled types or
12852 composite types containing a controlled component. In most cases, the compiler
12853 can detect an attempt at such overlays and will generate a warning at compile
12854 time and a Program_Error exception at run time.
12857 An address clause cannot be given for an exported object. More
12858 understandably the real restriction is that objects with an address
12859 clause cannot be exported. This is because such variables are not
12860 defined by the Ada program, so there is no external object to export.
12863 It is permissible to give an address clause and a pragma Import for the
12864 same object. In this case, the variable is not really defined by the
12865 Ada program, so there is no external symbol to be linked. The link name
12866 and the external name are ignored in this case. The reason that we allow this
12867 combination is that it provides a useful idiom to avoid unwanted
12868 initializations on objects with address clauses.
12870 When an address clause is given for an object that has implicit or
12871 explicit initialization, then by default initialization takes place. This
12872 means that the effect of the object declaration is to overwrite the
12873 memory at the specified address. This is almost always not what the
12874 programmer wants, so GNAT will output a warning:
12884 for Ext'Address use System'To_Address (16#1234_1234#);
12886 >>> warning: implicit initialization of "Ext" may
12887 modify overlaid storage
12888 >>> warning: use pragma Import for "Ext" to suppress
12889 initialization (RM B(24))
12895 As indicated by the warning message, the solution is to use a (dummy) pragma
12896 Import to suppress this initialization. The pragma tell the compiler that the
12897 object is declared and initialized elsewhere. The following package compiles
12898 without warnings (and the initialization is suppressed):
12900 @smallexample @c ada
12908 for Ext'Address use System'To_Address (16#1234_1234#);
12909 pragma Import (Ada, Ext);
12914 A final issue with address clauses involves their use for overlaying
12915 variables, as in the following example:
12916 @cindex Overlaying of objects
12918 @smallexample @c ada
12921 for B'Address use A'Address;
12925 or alternatively, using the form recommended by the RM:
12927 @smallexample @c ada
12929 Addr : constant Address := A'Address;
12931 for B'Address use Addr;
12935 In both of these cases, @code{A}
12936 and @code{B} become aliased to one another via the
12937 address clause. This use of address clauses to overlay
12938 variables, achieving an effect similar to unchecked
12939 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
12940 the effect is implementation defined. Furthermore, the
12941 Ada RM specifically recommends that in a situation
12942 like this, @code{B} should be subject to the following
12943 implementation advice (RM 13.3(19)):
12946 19 If the Address of an object is specified, or it is imported
12947 or exported, then the implementation should not perform
12948 optimizations based on assumptions of no aliases.
12952 GNAT follows this recommendation, and goes further by also applying
12953 this recommendation to the overlaid variable (@code{A}
12954 in the above example) in this case. This means that the overlay
12955 works "as expected", in that a modification to one of the variables
12956 will affect the value of the other.
12958 @node Effect of Convention on Representation
12959 @section Effect of Convention on Representation
12960 @cindex Convention, effect on representation
12963 Normally the specification of a foreign language convention for a type or
12964 an object has no effect on the chosen representation. In particular, the
12965 representation chosen for data in GNAT generally meets the standard system
12966 conventions, and for example records are laid out in a manner that is
12967 consistent with C@. This means that specifying convention C (for example)
12970 There are four exceptions to this general rule:
12974 @item Convention Fortran and array subtypes
12975 If pragma Convention Fortran is specified for an array subtype, then in
12976 accordance with the implementation advice in section 3.6.2(11) of the
12977 Ada Reference Manual, the array will be stored in a Fortran-compatible
12978 column-major manner, instead of the normal default row-major order.
12980 @item Convention C and enumeration types
12981 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
12982 to accommodate all values of the type. For example, for the enumeration
12985 @smallexample @c ada
12986 type Color is (Red, Green, Blue);
12990 8 bits is sufficient to store all values of the type, so by default, objects
12991 of type @code{Color} will be represented using 8 bits. However, normal C
12992 convention is to use 32 bits for all enum values in C, since enum values
12993 are essentially of type int. If pragma @code{Convention C} is specified for an
12994 Ada enumeration type, then the size is modified as necessary (usually to
12995 32 bits) to be consistent with the C convention for enum values.
12997 Note that this treatment applies only to types. If Convention C is given for
12998 an enumeration object, where the enumeration type is not Convention C, then
12999 Object_Size bits are allocated. For example, for a normal enumeration type,
13000 with less than 256 elements, only 8 bits will be allocated for the object.
13001 Since this may be a surprise in terms of what C expects, GNAT will issue a
13002 warning in this situation. The warning can be suppressed by giving an explicit
13003 size clause specifying the desired size.
13005 @item Convention C/Fortran and Boolean types
13006 In C, the usual convention for boolean values, that is values used for
13007 conditions, is that zero represents false, and nonzero values represent
13008 true. In Ada, the normal convention is that two specific values, typically
13009 0/1, are used to represent false/true respectively.
13011 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
13012 value represents true).
13014 To accommodate the Fortran and C conventions, if a pragma Convention specifies
13015 C or Fortran convention for a derived Boolean, as in the following example:
13017 @smallexample @c ada
13018 type C_Switch is new Boolean;
13019 pragma Convention (C, C_Switch);
13023 then the GNAT generated code will treat any nonzero value as true. For truth
13024 values generated by GNAT, the conventional value 1 will be used for True, but
13025 when one of these values is read, any nonzero value is treated as True.
13027 @item Access types on OpenVMS
13028 For 64-bit OpenVMS systems, access types (other than those for unconstrained
13029 arrays) are 64-bits long. An exception to this rule is for the case of
13030 C-convention access types where there is no explicit size clause present (or
13031 inherited for derived types). In this case, GNAT chooses to make these
13032 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
13033 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
13037 @node Determining the Representations chosen by GNAT
13038 @section Determining the Representations chosen by GNAT
13039 @cindex Representation, determination of
13040 @cindex @option{-gnatR} switch
13043 Although the descriptions in this section are intended to be complete, it is
13044 often easier to simply experiment to see what GNAT accepts and what the
13045 effect is on the layout of types and objects.
13047 As required by the Ada RM, if a representation clause is not accepted, then
13048 it must be rejected as illegal by the compiler. However, when a
13049 representation clause or pragma is accepted, there can still be questions
13050 of what the compiler actually does. For example, if a partial record
13051 representation clause specifies the location of some components and not
13052 others, then where are the non-specified components placed? Or if pragma
13053 @code{Pack} is used on a record, then exactly where are the resulting
13054 fields placed? The section on pragma @code{Pack} in this chapter can be
13055 used to answer the second question, but it is often easier to just see
13056 what the compiler does.
13058 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
13059 with this option, then the compiler will output information on the actual
13060 representations chosen, in a format similar to source representation
13061 clauses. For example, if we compile the package:
13063 @smallexample @c ada
13065 type r (x : boolean) is tagged record
13067 when True => S : String (1 .. 100);
13068 when False => null;
13072 type r2 is new r (false) with record
13077 y2 at 16 range 0 .. 31;
13084 type x1 is array (1 .. 10) of x;
13085 for x1'component_size use 11;
13087 type ia is access integer;
13089 type Rb1 is array (1 .. 13) of Boolean;
13092 type Rb2 is array (1 .. 65) of Boolean;
13108 using the switch @option{-gnatR} we obtain the following output:
13111 Representation information for unit q
13112 -------------------------------------
13115 for r'Alignment use 4;
13117 x at 4 range 0 .. 7;
13118 _tag at 0 range 0 .. 31;
13119 s at 5 range 0 .. 799;
13122 for r2'Size use 160;
13123 for r2'Alignment use 4;
13125 x at 4 range 0 .. 7;
13126 _tag at 0 range 0 .. 31;
13127 _parent at 0 range 0 .. 63;
13128 y2 at 16 range 0 .. 31;
13132 for x'Alignment use 1;
13134 y at 0 range 0 .. 7;
13137 for x1'Size use 112;
13138 for x1'Alignment use 1;
13139 for x1'Component_Size use 11;
13141 for rb1'Size use 13;
13142 for rb1'Alignment use 2;
13143 for rb1'Component_Size use 1;
13145 for rb2'Size use 72;
13146 for rb2'Alignment use 1;
13147 for rb2'Component_Size use 1;
13149 for x2'Size use 224;
13150 for x2'Alignment use 4;
13152 l1 at 0 range 0 .. 0;
13153 l2 at 0 range 1 .. 64;
13154 l3 at 12 range 0 .. 31;
13155 l4 at 16 range 0 .. 0;
13156 l5 at 16 range 1 .. 13;
13157 l6 at 18 range 0 .. 71;
13162 The Size values are actually the Object_Size, i.e.@: the default size that
13163 will be allocated for objects of the type.
13164 The ?? size for type r indicates that we have a variant record, and the
13165 actual size of objects will depend on the discriminant value.
13167 The Alignment values show the actual alignment chosen by the compiler
13168 for each record or array type.
13170 The record representation clause for type r shows where all fields
13171 are placed, including the compiler generated tag field (whose location
13172 cannot be controlled by the programmer).
13174 The record representation clause for the type extension r2 shows all the
13175 fields present, including the parent field, which is a copy of the fields
13176 of the parent type of r2, i.e.@: r1.
13178 The component size and size clauses for types rb1 and rb2 show
13179 the exact effect of pragma @code{Pack} on these arrays, and the record
13180 representation clause for type x2 shows how pragma @code{Pack} affects
13183 In some cases, it may be useful to cut and paste the representation clauses
13184 generated by the compiler into the original source to fix and guarantee
13185 the actual representation to be used.
13187 @node Standard Library Routines
13188 @chapter Standard Library Routines
13191 The Ada Reference Manual contains in Annex A a full description of an
13192 extensive set of standard library routines that can be used in any Ada
13193 program, and which must be provided by all Ada compilers. They are
13194 analogous to the standard C library used by C programs.
13196 GNAT implements all of the facilities described in annex A, and for most
13197 purposes the description in the Ada Reference Manual, or appropriate Ada
13198 text book, will be sufficient for making use of these facilities.
13200 In the case of the input-output facilities,
13201 @xref{The Implementation of Standard I/O},
13202 gives details on exactly how GNAT interfaces to the
13203 file system. For the remaining packages, the Ada Reference Manual
13204 should be sufficient. The following is a list of the packages included,
13205 together with a brief description of the functionality that is provided.
13207 For completeness, references are included to other predefined library
13208 routines defined in other sections of the Ada Reference Manual (these are
13209 cross-indexed from Annex A).
13213 This is a parent package for all the standard library packages. It is
13214 usually included implicitly in your program, and itself contains no
13215 useful data or routines.
13217 @item Ada.Calendar (9.6)
13218 @code{Calendar} provides time of day access, and routines for
13219 manipulating times and durations.
13221 @item Ada.Characters (A.3.1)
13222 This is a dummy parent package that contains no useful entities
13224 @item Ada.Characters.Handling (A.3.2)
13225 This package provides some basic character handling capabilities,
13226 including classification functions for classes of characters (e.g.@: test
13227 for letters, or digits).
13229 @item Ada.Characters.Latin_1 (A.3.3)
13230 This package includes a complete set of definitions of the characters
13231 that appear in type CHARACTER@. It is useful for writing programs that
13232 will run in international environments. For example, if you want an
13233 upper case E with an acute accent in a string, it is often better to use
13234 the definition of @code{UC_E_Acute} in this package. Then your program
13235 will print in an understandable manner even if your environment does not
13236 support these extended characters.
13238 @item Ada.Command_Line (A.15)
13239 This package provides access to the command line parameters and the name
13240 of the current program (analogous to the use of @code{argc} and @code{argv}
13241 in C), and also allows the exit status for the program to be set in a
13242 system-independent manner.
13244 @item Ada.Decimal (F.2)
13245 This package provides constants describing the range of decimal numbers
13246 implemented, and also a decimal divide routine (analogous to the COBOL
13247 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
13249 @item Ada.Direct_IO (A.8.4)
13250 This package provides input-output using a model of a set of records of
13251 fixed-length, containing an arbitrary definite Ada type, indexed by an
13252 integer record number.
13254 @item Ada.Dynamic_Priorities (D.5)
13255 This package allows the priorities of a task to be adjusted dynamically
13256 as the task is running.
13258 @item Ada.Exceptions (11.4.1)
13259 This package provides additional information on exceptions, and also
13260 contains facilities for treating exceptions as data objects, and raising
13261 exceptions with associated messages.
13263 @item Ada.Finalization (7.6)
13264 This package contains the declarations and subprograms to support the
13265 use of controlled types, providing for automatic initialization and
13266 finalization (analogous to the constructors and destructors of C++)
13268 @item Ada.Interrupts (C.3.2)
13269 This package provides facilities for interfacing to interrupts, which
13270 includes the set of signals or conditions that can be raised and
13271 recognized as interrupts.
13273 @item Ada.Interrupts.Names (C.3.2)
13274 This package provides the set of interrupt names (actually signal
13275 or condition names) that can be handled by GNAT@.
13277 @item Ada.IO_Exceptions (A.13)
13278 This package defines the set of exceptions that can be raised by use of
13279 the standard IO packages.
13282 This package contains some standard constants and exceptions used
13283 throughout the numerics packages. Note that the constants pi and e are
13284 defined here, and it is better to use these definitions than rolling
13287 @item Ada.Numerics.Complex_Elementary_Functions
13288 Provides the implementation of standard elementary functions (such as
13289 log and trigonometric functions) operating on complex numbers using the
13290 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
13291 created by the package @code{Numerics.Complex_Types}.
13293 @item Ada.Numerics.Complex_Types
13294 This is a predefined instantiation of
13295 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
13296 build the type @code{Complex} and @code{Imaginary}.
13298 @item Ada.Numerics.Discrete_Random
13299 This generic package provides a random number generator suitable for generating
13300 uniformly distributed values of a specified discrete subtype.
13302 @item Ada.Numerics.Float_Random
13303 This package provides a random number generator suitable for generating
13304 uniformly distributed floating point values in the unit interval.
13306 @item Ada.Numerics.Generic_Complex_Elementary_Functions
13307 This is a generic version of the package that provides the
13308 implementation of standard elementary functions (such as log and
13309 trigonometric functions) for an arbitrary complex type.
13311 The following predefined instantiations of this package are provided:
13315 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
13317 @code{Ada.Numerics.Complex_Elementary_Functions}
13319 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
13322 @item Ada.Numerics.Generic_Complex_Types
13323 This is a generic package that allows the creation of complex types,
13324 with associated complex arithmetic operations.
13326 The following predefined instantiations of this package exist
13329 @code{Ada.Numerics.Short_Complex_Complex_Types}
13331 @code{Ada.Numerics.Complex_Complex_Types}
13333 @code{Ada.Numerics.Long_Complex_Complex_Types}
13336 @item Ada.Numerics.Generic_Elementary_Functions
13337 This is a generic package that provides the implementation of standard
13338 elementary functions (such as log an trigonometric functions) for an
13339 arbitrary float type.
13341 The following predefined instantiations of this package exist
13345 @code{Ada.Numerics.Short_Elementary_Functions}
13347 @code{Ada.Numerics.Elementary_Functions}
13349 @code{Ada.Numerics.Long_Elementary_Functions}
13352 @item Ada.Real_Time (D.8)
13353 This package provides facilities similar to those of @code{Calendar}, but
13354 operating with a finer clock suitable for real time control. Note that
13355 annex D requires that there be no backward clock jumps, and GNAT generally
13356 guarantees this behavior, but of course if the external clock on which
13357 the GNAT runtime depends is deliberately reset by some external event,
13358 then such a backward jump may occur.
13360 @item Ada.Sequential_IO (A.8.1)
13361 This package provides input-output facilities for sequential files,
13362 which can contain a sequence of values of a single type, which can be
13363 any Ada type, including indefinite (unconstrained) types.
13365 @item Ada.Storage_IO (A.9)
13366 This package provides a facility for mapping arbitrary Ada types to and
13367 from a storage buffer. It is primarily intended for the creation of new
13370 @item Ada.Streams (13.13.1)
13371 This is a generic package that provides the basic support for the
13372 concept of streams as used by the stream attributes (@code{Input},
13373 @code{Output}, @code{Read} and @code{Write}).
13375 @item Ada.Streams.Stream_IO (A.12.1)
13376 This package is a specialization of the type @code{Streams} defined in
13377 package @code{Streams} together with a set of operations providing
13378 Stream_IO capability. The Stream_IO model permits both random and
13379 sequential access to a file which can contain an arbitrary set of values
13380 of one or more Ada types.
13382 @item Ada.Strings (A.4.1)
13383 This package provides some basic constants used by the string handling
13386 @item Ada.Strings.Bounded (A.4.4)
13387 This package provides facilities for handling variable length
13388 strings. The bounded model requires a maximum length. It is thus
13389 somewhat more limited than the unbounded model, but avoids the use of
13390 dynamic allocation or finalization.
13392 @item Ada.Strings.Fixed (A.4.3)
13393 This package provides facilities for handling fixed length strings.
13395 @item Ada.Strings.Maps (A.4.2)
13396 This package provides facilities for handling character mappings and
13397 arbitrarily defined subsets of characters. For instance it is useful in
13398 defining specialized translation tables.
13400 @item Ada.Strings.Maps.Constants (A.4.6)
13401 This package provides a standard set of predefined mappings and
13402 predefined character sets. For example, the standard upper to lower case
13403 conversion table is found in this package. Note that upper to lower case
13404 conversion is non-trivial if you want to take the entire set of
13405 characters, including extended characters like E with an acute accent,
13406 into account. You should use the mappings in this package (rather than
13407 adding 32 yourself) to do case mappings.
13409 @item Ada.Strings.Unbounded (A.4.5)
13410 This package provides facilities for handling variable length
13411 strings. The unbounded model allows arbitrary length strings, but
13412 requires the use of dynamic allocation and finalization.
13414 @item Ada.Strings.Wide_Bounded (A.4.7)
13415 @itemx Ada.Strings.Wide_Fixed (A.4.7)
13416 @itemx Ada.Strings.Wide_Maps (A.4.7)
13417 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
13418 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
13419 These packages provide analogous capabilities to the corresponding
13420 packages without @samp{Wide_} in the name, but operate with the types
13421 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
13422 and @code{Character}.
13424 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
13425 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
13426 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
13427 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
13428 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
13429 These packages provide analogous capabilities to the corresponding
13430 packages without @samp{Wide_} in the name, but operate with the types
13431 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
13432 of @code{String} and @code{Character}.
13434 @item Ada.Synchronous_Task_Control (D.10)
13435 This package provides some standard facilities for controlling task
13436 communication in a synchronous manner.
13439 This package contains definitions for manipulation of the tags of tagged
13442 @item Ada.Task_Attributes
13443 This package provides the capability of associating arbitrary
13444 task-specific data with separate tasks.
13447 This package provides basic text input-output capabilities for
13448 character, string and numeric data. The subpackages of this
13449 package are listed next.
13451 @item Ada.Text_IO.Decimal_IO
13452 Provides input-output facilities for decimal fixed-point types
13454 @item Ada.Text_IO.Enumeration_IO
13455 Provides input-output facilities for enumeration types.
13457 @item Ada.Text_IO.Fixed_IO
13458 Provides input-output facilities for ordinary fixed-point types.
13460 @item Ada.Text_IO.Float_IO
13461 Provides input-output facilities for float types. The following
13462 predefined instantiations of this generic package are available:
13466 @code{Short_Float_Text_IO}
13468 @code{Float_Text_IO}
13470 @code{Long_Float_Text_IO}
13473 @item Ada.Text_IO.Integer_IO
13474 Provides input-output facilities for integer types. The following
13475 predefined instantiations of this generic package are available:
13478 @item Short_Short_Integer
13479 @code{Ada.Short_Short_Integer_Text_IO}
13480 @item Short_Integer
13481 @code{Ada.Short_Integer_Text_IO}
13483 @code{Ada.Integer_Text_IO}
13485 @code{Ada.Long_Integer_Text_IO}
13486 @item Long_Long_Integer
13487 @code{Ada.Long_Long_Integer_Text_IO}
13490 @item Ada.Text_IO.Modular_IO
13491 Provides input-output facilities for modular (unsigned) types
13493 @item Ada.Text_IO.Complex_IO (G.1.3)
13494 This package provides basic text input-output capabilities for complex
13497 @item Ada.Text_IO.Editing (F.3.3)
13498 This package contains routines for edited output, analogous to the use
13499 of pictures in COBOL@. The picture formats used by this package are a
13500 close copy of the facility in COBOL@.
13502 @item Ada.Text_IO.Text_Streams (A.12.2)
13503 This package provides a facility that allows Text_IO files to be treated
13504 as streams, so that the stream attributes can be used for writing
13505 arbitrary data, including binary data, to Text_IO files.
13507 @item Ada.Unchecked_Conversion (13.9)
13508 This generic package allows arbitrary conversion from one type to
13509 another of the same size, providing for breaking the type safety in
13510 special circumstances.
13512 If the types have the same Size (more accurately the same Value_Size),
13513 then the effect is simply to transfer the bits from the source to the
13514 target type without any modification. This usage is well defined, and
13515 for simple types whose representation is typically the same across
13516 all implementations, gives a portable method of performing such
13519 If the types do not have the same size, then the result is implementation
13520 defined, and thus may be non-portable. The following describes how GNAT
13521 handles such unchecked conversion cases.
13523 If the types are of different sizes, and are both discrete types, then
13524 the effect is of a normal type conversion without any constraint checking.
13525 In particular if the result type has a larger size, the result will be
13526 zero or sign extended. If the result type has a smaller size, the result
13527 will be truncated by ignoring high order bits.
13529 If the types are of different sizes, and are not both discrete types,
13530 then the conversion works as though pointers were created to the source
13531 and target, and the pointer value is converted. The effect is that bits
13532 are copied from successive low order storage units and bits of the source
13533 up to the length of the target type.
13535 A warning is issued if the lengths differ, since the effect in this
13536 case is implementation dependent, and the above behavior may not match
13537 that of some other compiler.
13539 A pointer to one type may be converted to a pointer to another type using
13540 unchecked conversion. The only case in which the effect is undefined is
13541 when one or both pointers are pointers to unconstrained array types. In
13542 this case, the bounds information may get incorrectly transferred, and in
13543 particular, GNAT uses double size pointers for such types, and it is
13544 meaningless to convert between such pointer types. GNAT will issue a
13545 warning if the alignment of the target designated type is more strict
13546 than the alignment of the source designated type (since the result may
13547 be unaligned in this case).
13549 A pointer other than a pointer to an unconstrained array type may be
13550 converted to and from System.Address. Such usage is common in Ada 83
13551 programs, but note that Ada.Address_To_Access_Conversions is the
13552 preferred method of performing such conversions in Ada 95 and Ada 2005.
13554 unchecked conversion nor Ada.Address_To_Access_Conversions should be
13555 used in conjunction with pointers to unconstrained objects, since
13556 the bounds information cannot be handled correctly in this case.
13558 @item Ada.Unchecked_Deallocation (13.11.2)
13559 This generic package allows explicit freeing of storage previously
13560 allocated by use of an allocator.
13562 @item Ada.Wide_Text_IO (A.11)
13563 This package is similar to @code{Ada.Text_IO}, except that the external
13564 file supports wide character representations, and the internal types are
13565 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13566 and @code{String}. It contains generic subpackages listed next.
13568 @item Ada.Wide_Text_IO.Decimal_IO
13569 Provides input-output facilities for decimal fixed-point types
13571 @item Ada.Wide_Text_IO.Enumeration_IO
13572 Provides input-output facilities for enumeration types.
13574 @item Ada.Wide_Text_IO.Fixed_IO
13575 Provides input-output facilities for ordinary fixed-point types.
13577 @item Ada.Wide_Text_IO.Float_IO
13578 Provides input-output facilities for float types. The following
13579 predefined instantiations of this generic package are available:
13583 @code{Short_Float_Wide_Text_IO}
13585 @code{Float_Wide_Text_IO}
13587 @code{Long_Float_Wide_Text_IO}
13590 @item Ada.Wide_Text_IO.Integer_IO
13591 Provides input-output facilities for integer types. The following
13592 predefined instantiations of this generic package are available:
13595 @item Short_Short_Integer
13596 @code{Ada.Short_Short_Integer_Wide_Text_IO}
13597 @item Short_Integer
13598 @code{Ada.Short_Integer_Wide_Text_IO}
13600 @code{Ada.Integer_Wide_Text_IO}
13602 @code{Ada.Long_Integer_Wide_Text_IO}
13603 @item Long_Long_Integer
13604 @code{Ada.Long_Long_Integer_Wide_Text_IO}
13607 @item Ada.Wide_Text_IO.Modular_IO
13608 Provides input-output facilities for modular (unsigned) types
13610 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
13611 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13612 external file supports wide character representations.
13614 @item Ada.Wide_Text_IO.Editing (F.3.4)
13615 This package is similar to @code{Ada.Text_IO.Editing}, except that the
13616 types are @code{Wide_Character} and @code{Wide_String} instead of
13617 @code{Character} and @code{String}.
13619 @item Ada.Wide_Text_IO.Streams (A.12.3)
13620 This package is similar to @code{Ada.Text_IO.Streams}, except that the
13621 types are @code{Wide_Character} and @code{Wide_String} instead of
13622 @code{Character} and @code{String}.
13624 @item Ada.Wide_Wide_Text_IO (A.11)
13625 This package is similar to @code{Ada.Text_IO}, except that the external
13626 file supports wide character representations, and the internal types are
13627 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13628 and @code{String}. It contains generic subpackages listed next.
13630 @item Ada.Wide_Wide_Text_IO.Decimal_IO
13631 Provides input-output facilities for decimal fixed-point types
13633 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
13634 Provides input-output facilities for enumeration types.
13636 @item Ada.Wide_Wide_Text_IO.Fixed_IO
13637 Provides input-output facilities for ordinary fixed-point types.
13639 @item Ada.Wide_Wide_Text_IO.Float_IO
13640 Provides input-output facilities for float types. The following
13641 predefined instantiations of this generic package are available:
13645 @code{Short_Float_Wide_Wide_Text_IO}
13647 @code{Float_Wide_Wide_Text_IO}
13649 @code{Long_Float_Wide_Wide_Text_IO}
13652 @item Ada.Wide_Wide_Text_IO.Integer_IO
13653 Provides input-output facilities for integer types. The following
13654 predefined instantiations of this generic package are available:
13657 @item Short_Short_Integer
13658 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
13659 @item Short_Integer
13660 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
13662 @code{Ada.Integer_Wide_Wide_Text_IO}
13664 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
13665 @item Long_Long_Integer
13666 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
13669 @item Ada.Wide_Wide_Text_IO.Modular_IO
13670 Provides input-output facilities for modular (unsigned) types
13672 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
13673 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13674 external file supports wide character representations.
13676 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
13677 This package is similar to @code{Ada.Text_IO.Editing}, except that the
13678 types are @code{Wide_Character} and @code{Wide_String} instead of
13679 @code{Character} and @code{String}.
13681 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
13682 This package is similar to @code{Ada.Text_IO.Streams}, except that the
13683 types are @code{Wide_Character} and @code{Wide_String} instead of
13684 @code{Character} and @code{String}.
13687 @node The Implementation of Standard I/O
13688 @chapter The Implementation of Standard I/O
13691 GNAT implements all the required input-output facilities described in
13692 A.6 through A.14. These sections of the Ada Reference Manual describe the
13693 required behavior of these packages from the Ada point of view, and if
13694 you are writing a portable Ada program that does not need to know the
13695 exact manner in which Ada maps to the outside world when it comes to
13696 reading or writing external files, then you do not need to read this
13697 chapter. As long as your files are all regular files (not pipes or
13698 devices), and as long as you write and read the files only from Ada, the
13699 description in the Ada Reference Manual is sufficient.
13701 However, if you want to do input-output to pipes or other devices, such
13702 as the keyboard or screen, or if the files you are dealing with are
13703 either generated by some other language, or to be read by some other
13704 language, then you need to know more about the details of how the GNAT
13705 implementation of these input-output facilities behaves.
13707 In this chapter we give a detailed description of exactly how GNAT
13708 interfaces to the file system. As always, the sources of the system are
13709 available to you for answering questions at an even more detailed level,
13710 but for most purposes the information in this chapter will suffice.
13712 Another reason that you may need to know more about how input-output is
13713 implemented arises when you have a program written in mixed languages
13714 where, for example, files are shared between the C and Ada sections of
13715 the same program. GNAT provides some additional facilities, in the form
13716 of additional child library packages, that facilitate this sharing, and
13717 these additional facilities are also described in this chapter.
13720 * Standard I/O Packages::
13726 * Wide_Wide_Text_IO::
13728 * Text Translation::
13730 * Filenames encoding::
13732 * Operations on C Streams::
13733 * Interfacing to C Streams::
13736 @node Standard I/O Packages
13737 @section Standard I/O Packages
13740 The Standard I/O packages described in Annex A for
13746 Ada.Text_IO.Complex_IO
13748 Ada.Text_IO.Text_Streams
13752 Ada.Wide_Text_IO.Complex_IO
13754 Ada.Wide_Text_IO.Text_Streams
13756 Ada.Wide_Wide_Text_IO
13758 Ada.Wide_Wide_Text_IO.Complex_IO
13760 Ada.Wide_Wide_Text_IO.Text_Streams
13770 are implemented using the C
13771 library streams facility; where
13775 All files are opened using @code{fopen}.
13777 All input/output operations use @code{fread}/@code{fwrite}.
13781 There is no internal buffering of any kind at the Ada library level. The only
13782 buffering is that provided at the system level in the implementation of the
13783 library routines that support streams. This facilitates shared use of these
13784 streams by mixed language programs. Note though that system level buffering is
13785 explicitly enabled at elaboration of the standard I/O packages and that can
13786 have an impact on mixed language programs, in particular those using I/O before
13787 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
13788 the Ada elaboration routine before performing any I/O or when impractical,
13789 flush the common I/O streams and in particular Standard_Output before
13790 elaborating the Ada code.
13793 @section FORM Strings
13796 The format of a FORM string in GNAT is:
13799 "keyword=value,keyword=value,@dots{},keyword=value"
13803 where letters may be in upper or lower case, and there are no spaces
13804 between values. The order of the entries is not important. Currently
13805 the following keywords defined.
13808 TEXT_TRANSLATION=[YES|NO]
13810 WCEM=[n|h|u|s|e|8|b]
13811 ENCODING=[UTF8|8BITS]
13815 The use of these parameters is described later in this section. If an
13816 unrecognized keyword appears in a form string, it is silently ignored
13817 and not considered invalid.
13823 Direct_IO can only be instantiated for definite types. This is a
13824 restriction of the Ada language, which means that the records are fixed
13825 length (the length being determined by @code{@var{type}'Size}, rounded
13826 up to the next storage unit boundary if necessary).
13828 The records of a Direct_IO file are simply written to the file in index
13829 sequence, with the first record starting at offset zero, and subsequent
13830 records following. There is no control information of any kind. For
13831 example, if 32-bit integers are being written, each record takes
13832 4-bytes, so the record at index @var{K} starts at offset
13833 (@var{K}@minus{}1)*4.
13835 There is no limit on the size of Direct_IO files, they are expanded as
13836 necessary to accommodate whatever records are written to the file.
13838 @node Sequential_IO
13839 @section Sequential_IO
13842 Sequential_IO may be instantiated with either a definite (constrained)
13843 or indefinite (unconstrained) type.
13845 For the definite type case, the elements written to the file are simply
13846 the memory images of the data values with no control information of any
13847 kind. The resulting file should be read using the same type, no validity
13848 checking is performed on input.
13850 For the indefinite type case, the elements written consist of two
13851 parts. First is the size of the data item, written as the memory image
13852 of a @code{Interfaces.C.size_t} value, followed by the memory image of
13853 the data value. The resulting file can only be read using the same
13854 (unconstrained) type. Normal assignment checks are performed on these
13855 read operations, and if these checks fail, @code{Data_Error} is
13856 raised. In particular, in the array case, the lengths must match, and in
13857 the variant record case, if the variable for a particular read operation
13858 is constrained, the discriminants must match.
13860 Note that it is not possible to use Sequential_IO to write variable
13861 length array items, and then read the data back into different length
13862 arrays. For example, the following will raise @code{Data_Error}:
13864 @smallexample @c ada
13865 package IO is new Sequential_IO (String);
13870 IO.Write (F, "hello!")
13871 IO.Reset (F, Mode=>In_File);
13878 On some Ada implementations, this will print @code{hell}, but the program is
13879 clearly incorrect, since there is only one element in the file, and that
13880 element is the string @code{hello!}.
13882 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
13883 using Stream_IO, and this is the preferred mechanism. In particular, the
13884 above program fragment rewritten to use Stream_IO will work correctly.
13890 Text_IO files consist of a stream of characters containing the following
13891 special control characters:
13894 LF (line feed, 16#0A#) Line Mark
13895 FF (form feed, 16#0C#) Page Mark
13899 A canonical Text_IO file is defined as one in which the following
13900 conditions are met:
13904 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
13908 The character @code{FF} is used only as a page mark, i.e.@: to mark the
13909 end of a page and consequently can appear only immediately following a
13910 @code{LF} (line mark) character.
13913 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
13914 (line mark, page mark). In the former case, the page mark is implicitly
13915 assumed to be present.
13919 A file written using Text_IO will be in canonical form provided that no
13920 explicit @code{LF} or @code{FF} characters are written using @code{Put}
13921 or @code{Put_Line}. There will be no @code{FF} character at the end of
13922 the file unless an explicit @code{New_Page} operation was performed
13923 before closing the file.
13925 A canonical Text_IO file that is a regular file (i.e., not a device or a
13926 pipe) can be read using any of the routines in Text_IO@. The
13927 semantics in this case will be exactly as defined in the Ada Reference
13928 Manual, and all the routines in Text_IO are fully implemented.
13930 A text file that does not meet the requirements for a canonical Text_IO
13931 file has one of the following:
13935 The file contains @code{FF} characters not immediately following a
13936 @code{LF} character.
13939 The file contains @code{LF} or @code{FF} characters written by
13940 @code{Put} or @code{Put_Line}, which are not logically considered to be
13941 line marks or page marks.
13944 The file ends in a character other than @code{LF} or @code{FF},
13945 i.e.@: there is no explicit line mark or page mark at the end of the file.
13949 Text_IO can be used to read such non-standard text files but subprograms
13950 to do with line or page numbers do not have defined meanings. In
13951 particular, a @code{FF} character that does not follow a @code{LF}
13952 character may or may not be treated as a page mark from the point of
13953 view of page and line numbering. Every @code{LF} character is considered
13954 to end a line, and there is an implied @code{LF} character at the end of
13958 * Text_IO Stream Pointer Positioning::
13959 * Text_IO Reading and Writing Non-Regular Files::
13961 * Treating Text_IO Files as Streams::
13962 * Text_IO Extensions::
13963 * Text_IO Facilities for Unbounded Strings::
13966 @node Text_IO Stream Pointer Positioning
13967 @subsection Stream Pointer Positioning
13970 @code{Ada.Text_IO} has a definition of current position for a file that
13971 is being read. No internal buffering occurs in Text_IO, and usually the
13972 physical position in the stream used to implement the file corresponds
13973 to this logical position defined by Text_IO@. There are two exceptions:
13977 After a call to @code{End_Of_Page} that returns @code{True}, the stream
13978 is positioned past the @code{LF} (line mark) that precedes the page
13979 mark. Text_IO maintains an internal flag so that subsequent read
13980 operations properly handle the logical position which is unchanged by
13981 the @code{End_Of_Page} call.
13984 After a call to @code{End_Of_File} that returns @code{True}, if the
13985 Text_IO file was positioned before the line mark at the end of file
13986 before the call, then the logical position is unchanged, but the stream
13987 is physically positioned right at the end of file (past the line mark,
13988 and past a possible page mark following the line mark. Again Text_IO
13989 maintains internal flags so that subsequent read operations properly
13990 handle the logical position.
13994 These discrepancies have no effect on the observable behavior of
13995 Text_IO, but if a single Ada stream is shared between a C program and
13996 Ada program, or shared (using @samp{shared=yes} in the form string)
13997 between two Ada files, then the difference may be observable in some
14000 @node Text_IO Reading and Writing Non-Regular Files
14001 @subsection Reading and Writing Non-Regular Files
14004 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
14005 can be used for reading and writing. Writing is not affected and the
14006 sequence of characters output is identical to the normal file case, but
14007 for reading, the behavior of Text_IO is modified to avoid undesirable
14008 look-ahead as follows:
14010 An input file that is not a regular file is considered to have no page
14011 marks. Any @code{Ascii.FF} characters (the character normally used for a
14012 page mark) appearing in the file are considered to be data
14013 characters. In particular:
14017 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
14018 following a line mark. If a page mark appears, it will be treated as a
14022 This avoids the need to wait for an extra character to be typed or
14023 entered from the pipe to complete one of these operations.
14026 @code{End_Of_Page} always returns @code{False}
14029 @code{End_Of_File} will return @code{False} if there is a page mark at
14030 the end of the file.
14034 Output to non-regular files is the same as for regular files. Page marks
14035 may be written to non-regular files using @code{New_Page}, but as noted
14036 above they will not be treated as page marks on input if the output is
14037 piped to another Ada program.
14039 Another important discrepancy when reading non-regular files is that the end
14040 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
14041 pressing the @key{EOT} key,
14043 is signaled once (i.e.@: the test @code{End_Of_File}
14044 will yield @code{True}, or a read will
14045 raise @code{End_Error}), but then reading can resume
14046 to read data past that end of
14047 file indication, until another end of file indication is entered.
14049 @node Get_Immediate
14050 @subsection Get_Immediate
14051 @cindex Get_Immediate
14054 Get_Immediate returns the next character (including control characters)
14055 from the input file. In particular, Get_Immediate will return LF or FF
14056 characters used as line marks or page marks. Such operations leave the
14057 file positioned past the control character, and it is thus not treated
14058 as having its normal function. This means that page, line and column
14059 counts after this kind of Get_Immediate call are set as though the mark
14060 did not occur. In the case where a Get_Immediate leaves the file
14061 positioned between the line mark and page mark (which is not normally
14062 possible), it is undefined whether the FF character will be treated as a
14065 @node Treating Text_IO Files as Streams
14066 @subsection Treating Text_IO Files as Streams
14067 @cindex Stream files
14070 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
14071 as a stream. Data written to a Text_IO file in this stream mode is
14072 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
14073 16#0C# (@code{FF}), the resulting file may have non-standard
14074 format. Similarly if read operations are used to read from a Text_IO
14075 file treated as a stream, then @code{LF} and @code{FF} characters may be
14076 skipped and the effect is similar to that described above for
14077 @code{Get_Immediate}.
14079 @node Text_IO Extensions
14080 @subsection Text_IO Extensions
14081 @cindex Text_IO extensions
14084 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
14085 to the standard @code{Text_IO} package:
14088 @item function File_Exists (Name : String) return Boolean;
14089 Determines if a file of the given name exists.
14091 @item function Get_Line return String;
14092 Reads a string from the standard input file. The value returned is exactly
14093 the length of the line that was read.
14095 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
14096 Similar, except that the parameter File specifies the file from which
14097 the string is to be read.
14101 @node Text_IO Facilities for Unbounded Strings
14102 @subsection Text_IO Facilities for Unbounded Strings
14103 @cindex Text_IO for unbounded strings
14104 @cindex Unbounded_String, Text_IO operations
14107 The package @code{Ada.Strings.Unbounded.Text_IO}
14108 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
14109 subprograms useful for Text_IO operations on unbounded strings:
14113 @item function Get_Line (File : File_Type) return Unbounded_String;
14114 Reads a line from the specified file
14115 and returns the result as an unbounded string.
14117 @item procedure Put (File : File_Type; U : Unbounded_String);
14118 Writes the value of the given unbounded string to the specified file
14119 Similar to the effect of
14120 @code{Put (To_String (U))} except that an extra copy is avoided.
14122 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
14123 Writes the value of the given unbounded string to the specified file,
14124 followed by a @code{New_Line}.
14125 Similar to the effect of @code{Put_Line (To_String (U))} except
14126 that an extra copy is avoided.
14130 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
14131 and is optional. If the parameter is omitted, then the standard input or
14132 output file is referenced as appropriate.
14134 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
14135 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
14136 @code{Wide_Text_IO} functionality for unbounded wide strings.
14138 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
14139 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
14140 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
14143 @section Wide_Text_IO
14146 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
14147 both input and output files may contain special sequences that represent
14148 wide character values. The encoding scheme for a given file may be
14149 specified using a FORM parameter:
14156 as part of the FORM string (WCEM = wide character encoding method),
14157 where @var{x} is one of the following characters
14163 Upper half encoding
14175 The encoding methods match those that
14176 can be used in a source
14177 program, but there is no requirement that the encoding method used for
14178 the source program be the same as the encoding method used for files,
14179 and different files may use different encoding methods.
14181 The default encoding method for the standard files, and for opened files
14182 for which no WCEM parameter is given in the FORM string matches the
14183 wide character encoding specified for the main program (the default
14184 being brackets encoding if no coding method was specified with -gnatW).
14188 In this encoding, a wide character is represented by a five character
14196 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
14197 characters (using upper case letters) of the wide character code. For
14198 example, ESC A345 is used to represent the wide character with code
14199 16#A345#. This scheme is compatible with use of the full
14200 @code{Wide_Character} set.
14202 @item Upper Half Coding
14203 The wide character with encoding 16#abcd#, where the upper bit is on
14204 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
14205 16#cd#. The second byte may never be a format control character, but is
14206 not required to be in the upper half. This method can be also used for
14207 shift-JIS or EUC where the internal coding matches the external coding.
14209 @item Shift JIS Coding
14210 A wide character is represented by a two character sequence 16#ab# and
14211 16#cd#, with the restrictions described for upper half encoding as
14212 described above. The internal character code is the corresponding JIS
14213 character according to the standard algorithm for Shift-JIS
14214 conversion. Only characters defined in the JIS code set table can be
14215 used with this encoding method.
14218 A wide character is represented by a two character sequence 16#ab# and
14219 16#cd#, with both characters being in the upper half. The internal
14220 character code is the corresponding JIS character according to the EUC
14221 encoding algorithm. Only characters defined in the JIS code set table
14222 can be used with this encoding method.
14225 A wide character is represented using
14226 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14227 10646-1/Am.2. Depending on the character value, the representation
14228 is a one, two, or three byte sequence:
14231 16#0000#-16#007f#: 2#0xxxxxxx#
14232 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
14233 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14237 where the @var{xxx} bits correspond to the left-padded bits of the
14238 16-bit character value. Note that all lower half ASCII characters
14239 are represented as ASCII bytes and all upper half characters and
14240 other wide characters are represented as sequences of upper-half
14241 (The full UTF-8 scheme allows for encoding 31-bit characters as
14242 6-byte sequences, but in this implementation, all UTF-8 sequences
14243 of four or more bytes length will raise a Constraint_Error, as
14244 will all invalid UTF-8 sequences.)
14246 @item Brackets Coding
14247 In this encoding, a wide character is represented by the following eight
14248 character sequence:
14255 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
14256 characters (using uppercase letters) of the wide character code. For
14257 example, @code{["A345"]} is used to represent the wide character with code
14259 This scheme is compatible with use of the full Wide_Character set.
14260 On input, brackets coding can also be used for upper half characters,
14261 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14262 is only used for wide characters with a code greater than @code{16#FF#}.
14264 Note that brackets coding is not normally used in the context of
14265 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
14266 a portable way of encoding source files. In the context of Wide_Text_IO
14267 or Wide_Wide_Text_IO, it can only be used if the file does not contain
14268 any instance of the left bracket character other than to encode wide
14269 character values using the brackets encoding method. In practice it is
14270 expected that some standard wide character encoding method such
14271 as UTF-8 will be used for text input output.
14273 If brackets notation is used, then any occurrence of a left bracket
14274 in the input file which is not the start of a valid wide character
14275 sequence will cause Constraint_Error to be raised. It is possible to
14276 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
14277 input will interpret this as a left bracket.
14279 However, when a left bracket is output, it will be output as a left bracket
14280 and not as ["5B"]. We make this decision because for normal use of
14281 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
14282 brackets. For example, if we write:
14285 Put_Line ("Start of output [first run]");
14289 we really do not want to have the left bracket in this message clobbered so
14290 that the output reads:
14293 Start of output ["5B"]first run]
14297 In practice brackets encoding is reasonably useful for normal Put_Line use
14298 since we won't get confused between left brackets and wide character
14299 sequences in the output. But for input, or when files are written out
14300 and read back in, it really makes better sense to use one of the standard
14301 encoding methods such as UTF-8.
14306 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
14307 not all wide character
14308 values can be represented. An attempt to output a character that cannot
14309 be represented using the encoding scheme for the file causes
14310 Constraint_Error to be raised. An invalid wide character sequence on
14311 input also causes Constraint_Error to be raised.
14314 * Wide_Text_IO Stream Pointer Positioning::
14315 * Wide_Text_IO Reading and Writing Non-Regular Files::
14318 @node Wide_Text_IO Stream Pointer Positioning
14319 @subsection Stream Pointer Positioning
14322 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14323 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14326 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
14327 normal lower ASCII set (i.e.@: a character in the range:
14329 @smallexample @c ada
14330 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
14334 then although the logical position of the file pointer is unchanged by
14335 the @code{Look_Ahead} call, the stream is physically positioned past the
14336 wide character sequence. Again this is to avoid the need for buffering
14337 or backup, and all @code{Wide_Text_IO} routines check the internal
14338 indication that this situation has occurred so that this is not visible
14339 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
14340 can be observed if the wide text file shares a stream with another file.
14342 @node Wide_Text_IO Reading and Writing Non-Regular Files
14343 @subsection Reading and Writing Non-Regular Files
14346 As in the case of Text_IO, when a non-regular file is read, it is
14347 assumed that the file contains no page marks (any form characters are
14348 treated as data characters), and @code{End_Of_Page} always returns
14349 @code{False}. Similarly, the end of file indication is not sticky, so
14350 it is possible to read beyond an end of file.
14352 @node Wide_Wide_Text_IO
14353 @section Wide_Wide_Text_IO
14356 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
14357 both input and output files may contain special sequences that represent
14358 wide wide character values. The encoding scheme for a given file may be
14359 specified using a FORM parameter:
14366 as part of the FORM string (WCEM = wide character encoding method),
14367 where @var{x} is one of the following characters
14373 Upper half encoding
14385 The encoding methods match those that
14386 can be used in a source
14387 program, but there is no requirement that the encoding method used for
14388 the source program be the same as the encoding method used for files,
14389 and different files may use different encoding methods.
14391 The default encoding method for the standard files, and for opened files
14392 for which no WCEM parameter is given in the FORM string matches the
14393 wide character encoding specified for the main program (the default
14394 being brackets encoding if no coding method was specified with -gnatW).
14399 A wide character is represented using
14400 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14401 10646-1/Am.2. Depending on the character value, the representation
14402 is a one, two, three, or four byte sequence:
14405 16#000000#-16#00007f#: 2#0xxxxxxx#
14406 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
14407 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14408 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
14412 where the @var{xxx} bits correspond to the left-padded bits of the
14413 21-bit character value. Note that all lower half ASCII characters
14414 are represented as ASCII bytes and all upper half characters and
14415 other wide characters are represented as sequences of upper-half
14418 @item Brackets Coding
14419 In this encoding, a wide wide character is represented by the following eight
14420 character sequence if is in wide character range
14426 and by the following ten character sequence if not
14429 [ " a b c d e f " ]
14433 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
14434 are the four or six hexadecimal
14435 characters (using uppercase letters) of the wide wide character code. For
14436 example, @code{["01A345"]} is used to represent the wide wide character
14437 with code @code{16#01A345#}.
14439 This scheme is compatible with use of the full Wide_Wide_Character set.
14440 On input, brackets coding can also be used for upper half characters,
14441 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14442 is only used for wide characters with a code greater than @code{16#FF#}.
14447 If is also possible to use the other Wide_Character encoding methods,
14448 such as Shift-JIS, but the other schemes cannot support the full range
14449 of wide wide characters.
14450 An attempt to output a character that cannot
14451 be represented using the encoding scheme for the file causes
14452 Constraint_Error to be raised. An invalid wide character sequence on
14453 input also causes Constraint_Error to be raised.
14456 * Wide_Wide_Text_IO Stream Pointer Positioning::
14457 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
14460 @node Wide_Wide_Text_IO Stream Pointer Positioning
14461 @subsection Stream Pointer Positioning
14464 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14465 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14468 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
14469 normal lower ASCII set (i.e.@: a character in the range:
14471 @smallexample @c ada
14472 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
14476 then although the logical position of the file pointer is unchanged by
14477 the @code{Look_Ahead} call, the stream is physically positioned past the
14478 wide character sequence. Again this is to avoid the need for buffering
14479 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
14480 indication that this situation has occurred so that this is not visible
14481 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
14482 can be observed if the wide text file shares a stream with another file.
14484 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
14485 @subsection Reading and Writing Non-Regular Files
14488 As in the case of Text_IO, when a non-regular file is read, it is
14489 assumed that the file contains no page marks (any form characters are
14490 treated as data characters), and @code{End_Of_Page} always returns
14491 @code{False}. Similarly, the end of file indication is not sticky, so
14492 it is possible to read beyond an end of file.
14498 A stream file is a sequence of bytes, where individual elements are
14499 written to the file as described in the Ada Reference Manual. The type
14500 @code{Stream_Element} is simply a byte. There are two ways to read or
14501 write a stream file.
14505 The operations @code{Read} and @code{Write} directly read or write a
14506 sequence of stream elements with no control information.
14509 The stream attributes applied to a stream file transfer data in the
14510 manner described for stream attributes.
14513 @node Text Translation
14514 @section Text Translation
14517 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
14518 passed to Text_IO.Create and Text_IO.Open:
14519 @samp{Text_Translation=@var{Yes}} is the default, which means to
14520 translate LF to/from CR/LF on Windows systems.
14521 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
14522 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
14523 may be used to create Unix-style files on
14524 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
14528 @section Shared Files
14531 Section A.14 of the Ada Reference Manual allows implementations to
14532 provide a wide variety of behavior if an attempt is made to access the
14533 same external file with two or more internal files.
14535 To provide a full range of functionality, while at the same time
14536 minimizing the problems of portability caused by this implementation
14537 dependence, GNAT handles file sharing as follows:
14541 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
14542 to open two or more files with the same full name is considered an error
14543 and is not supported. The exception @code{Use_Error} will be
14544 raised. Note that a file that is not explicitly closed by the program
14545 remains open until the program terminates.
14548 If the form parameter @samp{shared=no} appears in the form string, the
14549 file can be opened or created with its own separate stream identifier,
14550 regardless of whether other files sharing the same external file are
14551 opened. The exact effect depends on how the C stream routines handle
14552 multiple accesses to the same external files using separate streams.
14555 If the form parameter @samp{shared=yes} appears in the form string for
14556 each of two or more files opened using the same full name, the same
14557 stream is shared between these files, and the semantics are as described
14558 in Ada Reference Manual, Section A.14.
14562 When a program that opens multiple files with the same name is ported
14563 from another Ada compiler to GNAT, the effect will be that
14564 @code{Use_Error} is raised.
14566 The documentation of the original compiler and the documentation of the
14567 program should then be examined to determine if file sharing was
14568 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
14569 and @code{Create} calls as required.
14571 When a program is ported from GNAT to some other Ada compiler, no
14572 special attention is required unless the @samp{shared=@var{xxx}} form
14573 parameter is used in the program. In this case, you must examine the
14574 documentation of the new compiler to see if it supports the required
14575 file sharing semantics, and form strings modified appropriately. Of
14576 course it may be the case that the program cannot be ported if the
14577 target compiler does not support the required functionality. The best
14578 approach in writing portable code is to avoid file sharing (and hence
14579 the use of the @samp{shared=@var{xxx}} parameter in the form string)
14582 One common use of file sharing in Ada 83 is the use of instantiations of
14583 Sequential_IO on the same file with different types, to achieve
14584 heterogeneous input-output. Although this approach will work in GNAT if
14585 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
14586 for this purpose (using the stream attributes)
14588 @node Filenames encoding
14589 @section Filenames encoding
14592 An encoding form parameter can be used to specify the filename
14593 encoding @samp{encoding=@var{xxx}}.
14597 If the form parameter @samp{encoding=utf8} appears in the form string, the
14598 filename must be encoded in UTF-8.
14601 If the form parameter @samp{encoding=8bits} appears in the form
14602 string, the filename must be a standard 8bits string.
14605 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
14606 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
14607 variable. And if not set @samp{utf8} is assumed.
14611 The current system Windows ANSI code page.
14616 This encoding form parameter is only supported on the Windows
14617 platform. On the other Operating Systems the run-time is supporting
14621 @section Open Modes
14624 @code{Open} and @code{Create} calls result in a call to @code{fopen}
14625 using the mode shown in the following table:
14628 @center @code{Open} and @code{Create} Call Modes
14630 @b{OPEN } @b{CREATE}
14631 Append_File "r+" "w+"
14633 Out_File (Direct_IO) "r+" "w"
14634 Out_File (all other cases) "w" "w"
14635 Inout_File "r+" "w+"
14639 If text file translation is required, then either @samp{b} or @samp{t}
14640 is added to the mode, depending on the setting of Text. Text file
14641 translation refers to the mapping of CR/LF sequences in an external file
14642 to LF characters internally. This mapping only occurs in DOS and
14643 DOS-like systems, and is not relevant to other systems.
14645 A special case occurs with Stream_IO@. As shown in the above table, the
14646 file is initially opened in @samp{r} or @samp{w} mode for the
14647 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
14648 subsequently requires switching from reading to writing or vice-versa,
14649 then the file is reopened in @samp{r+} mode to permit the required operation.
14651 @node Operations on C Streams
14652 @section Operations on C Streams
14653 The package @code{Interfaces.C_Streams} provides an Ada program with direct
14654 access to the C library functions for operations on C streams:
14656 @smallexample @c adanocomment
14657 package Interfaces.C_Streams is
14658 -- Note: the reason we do not use the types that are in
14659 -- Interfaces.C is that we want to avoid dragging in the
14660 -- code in this unit if possible.
14661 subtype chars is System.Address;
14662 -- Pointer to null-terminated array of characters
14663 subtype FILEs is System.Address;
14664 -- Corresponds to the C type FILE*
14665 subtype voids is System.Address;
14666 -- Corresponds to the C type void*
14667 subtype int is Integer;
14668 subtype long is Long_Integer;
14669 -- Note: the above types are subtypes deliberately, and it
14670 -- is part of this spec that the above correspondences are
14671 -- guaranteed. This means that it is legitimate to, for
14672 -- example, use Integer instead of int. We provide these
14673 -- synonyms for clarity, but in some cases it may be
14674 -- convenient to use the underlying types (for example to
14675 -- avoid an unnecessary dependency of a spec on the spec
14677 type size_t is mod 2 ** Standard'Address_Size;
14678 NULL_Stream : constant FILEs;
14679 -- Value returned (NULL in C) to indicate an
14680 -- fdopen/fopen/tmpfile error
14681 ----------------------------------
14682 -- Constants Defined in stdio.h --
14683 ----------------------------------
14684 EOF : constant int;
14685 -- Used by a number of routines to indicate error or
14687 IOFBF : constant int;
14688 IOLBF : constant int;
14689 IONBF : constant int;
14690 -- Used to indicate buffering mode for setvbuf call
14691 SEEK_CUR : constant int;
14692 SEEK_END : constant int;
14693 SEEK_SET : constant int;
14694 -- Used to indicate origin for fseek call
14695 function stdin return FILEs;
14696 function stdout return FILEs;
14697 function stderr return FILEs;
14698 -- Streams associated with standard files
14699 --------------------------
14700 -- Standard C functions --
14701 --------------------------
14702 -- The functions selected below are ones that are
14703 -- available in UNIX (but not necessarily in ANSI C).
14704 -- These are very thin interfaces
14705 -- which copy exactly the C headers. For more
14706 -- documentation on these functions, see the Microsoft C
14707 -- "Run-Time Library Reference" (Microsoft Press, 1990,
14708 -- ISBN 1-55615-225-6), which includes useful information
14709 -- on system compatibility.
14710 procedure clearerr (stream : FILEs);
14711 function fclose (stream : FILEs) return int;
14712 function fdopen (handle : int; mode : chars) return FILEs;
14713 function feof (stream : FILEs) return int;
14714 function ferror (stream : FILEs) return int;
14715 function fflush (stream : FILEs) return int;
14716 function fgetc (stream : FILEs) return int;
14717 function fgets (strng : chars; n : int; stream : FILEs)
14719 function fileno (stream : FILEs) return int;
14720 function fopen (filename : chars; Mode : chars)
14722 -- Note: to maintain target independence, use
14723 -- text_translation_required, a boolean variable defined in
14724 -- a-sysdep.c to deal with the target dependent text
14725 -- translation requirement. If this variable is set,
14726 -- then b/t should be appended to the standard mode
14727 -- argument to set the text translation mode off or on
14729 function fputc (C : int; stream : FILEs) return int;
14730 function fputs (Strng : chars; Stream : FILEs) return int;
14747 function ftell (stream : FILEs) return long;
14754 function isatty (handle : int) return int;
14755 procedure mktemp (template : chars);
14756 -- The return value (which is just a pointer to template)
14758 procedure rewind (stream : FILEs);
14759 function rmtmp return int;
14767 function tmpfile return FILEs;
14768 function ungetc (c : int; stream : FILEs) return int;
14769 function unlink (filename : chars) return int;
14770 ---------------------
14771 -- Extra functions --
14772 ---------------------
14773 -- These functions supply slightly thicker bindings than
14774 -- those above. They are derived from functions in the
14775 -- C Run-Time Library, but may do a bit more work than
14776 -- just directly calling one of the Library functions.
14777 function is_regular_file (handle : int) return int;
14778 -- Tests if given handle is for a regular file (result 1)
14779 -- or for a non-regular file (pipe or device, result 0).
14780 ---------------------------------
14781 -- Control of Text/Binary Mode --
14782 ---------------------------------
14783 -- If text_translation_required is true, then the following
14784 -- functions may be used to dynamically switch a file from
14785 -- binary to text mode or vice versa. These functions have
14786 -- no effect if text_translation_required is false (i.e.@: in
14787 -- normal UNIX mode). Use fileno to get a stream handle.
14788 procedure set_binary_mode (handle : int);
14789 procedure set_text_mode (handle : int);
14790 ----------------------------
14791 -- Full Path Name support --
14792 ----------------------------
14793 procedure full_name (nam : chars; buffer : chars);
14794 -- Given a NUL terminated string representing a file
14795 -- name, returns in buffer a NUL terminated string
14796 -- representing the full path name for the file name.
14797 -- On systems where it is relevant the drive is also
14798 -- part of the full path name. It is the responsibility
14799 -- of the caller to pass an actual parameter for buffer
14800 -- that is big enough for any full path name. Use
14801 -- max_path_len given below as the size of buffer.
14802 max_path_len : integer;
14803 -- Maximum length of an allowable full path name on the
14804 -- system, including a terminating NUL character.
14805 end Interfaces.C_Streams;
14808 @node Interfacing to C Streams
14809 @section Interfacing to C Streams
14812 The packages in this section permit interfacing Ada files to C Stream
14815 @smallexample @c ada
14816 with Interfaces.C_Streams;
14817 package Ada.Sequential_IO.C_Streams is
14818 function C_Stream (F : File_Type)
14819 return Interfaces.C_Streams.FILEs;
14821 (File : in out File_Type;
14822 Mode : in File_Mode;
14823 C_Stream : in Interfaces.C_Streams.FILEs;
14824 Form : in String := "");
14825 end Ada.Sequential_IO.C_Streams;
14827 with Interfaces.C_Streams;
14828 package Ada.Direct_IO.C_Streams is
14829 function C_Stream (F : File_Type)
14830 return Interfaces.C_Streams.FILEs;
14832 (File : in out File_Type;
14833 Mode : in File_Mode;
14834 C_Stream : in Interfaces.C_Streams.FILEs;
14835 Form : in String := "");
14836 end Ada.Direct_IO.C_Streams;
14838 with Interfaces.C_Streams;
14839 package Ada.Text_IO.C_Streams is
14840 function C_Stream (F : File_Type)
14841 return Interfaces.C_Streams.FILEs;
14843 (File : in out File_Type;
14844 Mode : in File_Mode;
14845 C_Stream : in Interfaces.C_Streams.FILEs;
14846 Form : in String := "");
14847 end Ada.Text_IO.C_Streams;
14849 with Interfaces.C_Streams;
14850 package Ada.Wide_Text_IO.C_Streams is
14851 function C_Stream (F : File_Type)
14852 return Interfaces.C_Streams.FILEs;
14854 (File : in out File_Type;
14855 Mode : in File_Mode;
14856 C_Stream : in Interfaces.C_Streams.FILEs;
14857 Form : in String := "");
14858 end Ada.Wide_Text_IO.C_Streams;
14860 with Interfaces.C_Streams;
14861 package Ada.Wide_Wide_Text_IO.C_Streams is
14862 function C_Stream (F : File_Type)
14863 return Interfaces.C_Streams.FILEs;
14865 (File : in out File_Type;
14866 Mode : in File_Mode;
14867 C_Stream : in Interfaces.C_Streams.FILEs;
14868 Form : in String := "");
14869 end Ada.Wide_Wide_Text_IO.C_Streams;
14871 with Interfaces.C_Streams;
14872 package Ada.Stream_IO.C_Streams is
14873 function C_Stream (F : File_Type)
14874 return Interfaces.C_Streams.FILEs;
14876 (File : in out File_Type;
14877 Mode : in File_Mode;
14878 C_Stream : in Interfaces.C_Streams.FILEs;
14879 Form : in String := "");
14880 end Ada.Stream_IO.C_Streams;
14884 In each of these six packages, the @code{C_Stream} function obtains the
14885 @code{FILE} pointer from a currently opened Ada file. It is then
14886 possible to use the @code{Interfaces.C_Streams} package to operate on
14887 this stream, or the stream can be passed to a C program which can
14888 operate on it directly. Of course the program is responsible for
14889 ensuring that only appropriate sequences of operations are executed.
14891 One particular use of relevance to an Ada program is that the
14892 @code{setvbuf} function can be used to control the buffering of the
14893 stream used by an Ada file. In the absence of such a call the standard
14894 default buffering is used.
14896 The @code{Open} procedures in these packages open a file giving an
14897 existing C Stream instead of a file name. Typically this stream is
14898 imported from a C program, allowing an Ada file to operate on an
14901 @node The GNAT Library
14902 @chapter The GNAT Library
14905 The GNAT library contains a number of general and special purpose packages.
14906 It represents functionality that the GNAT developers have found useful, and
14907 which is made available to GNAT users. The packages described here are fully
14908 supported, and upwards compatibility will be maintained in future releases,
14909 so you can use these facilities with the confidence that the same functionality
14910 will be available in future releases.
14912 The chapter here simply gives a brief summary of the facilities available.
14913 The full documentation is found in the spec file for the package. The full
14914 sources of these library packages, including both spec and body, are provided
14915 with all GNAT releases. For example, to find out the full specifications of
14916 the SPITBOL pattern matching capability, including a full tutorial and
14917 extensive examples, look in the @file{g-spipat.ads} file in the library.
14919 For each entry here, the package name (as it would appear in a @code{with}
14920 clause) is given, followed by the name of the corresponding spec file in
14921 parentheses. The packages are children in four hierarchies, @code{Ada},
14922 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
14923 GNAT-specific hierarchy.
14925 Note that an application program should only use packages in one of these
14926 four hierarchies if the package is defined in the Ada Reference Manual,
14927 or is listed in this section of the GNAT Programmers Reference Manual.
14928 All other units should be considered internal implementation units and
14929 should not be directly @code{with}'ed by application code. The use of
14930 a @code{with} statement that references one of these internal implementation
14931 units makes an application potentially dependent on changes in versions
14932 of GNAT, and will generate a warning message.
14935 * Ada.Characters.Latin_9 (a-chlat9.ads)::
14936 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
14937 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
14938 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
14939 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
14940 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
14941 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
14942 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
14943 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
14944 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
14945 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
14946 * Ada.Command_Line.Environment (a-colien.ads)::
14947 * Ada.Command_Line.Remove (a-colire.ads)::
14948 * Ada.Command_Line.Response_File (a-clrefi.ads)::
14949 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
14950 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
14951 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
14952 * Ada.Exceptions.Traceback (a-exctra.ads)::
14953 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
14954 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
14955 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
14956 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
14957 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
14958 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
14959 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
14960 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
14961 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
14962 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
14963 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
14964 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
14965 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
14966 * GNAT.Altivec (g-altive.ads)::
14967 * GNAT.Altivec.Conversions (g-altcon.ads)::
14968 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
14969 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
14970 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
14971 * GNAT.Array_Split (g-arrspl.ads)::
14972 * GNAT.AWK (g-awk.ads)::
14973 * GNAT.Bounded_Buffers (g-boubuf.ads)::
14974 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
14975 * GNAT.Bubble_Sort (g-bubsor.ads)::
14976 * GNAT.Bubble_Sort_A (g-busora.ads)::
14977 * GNAT.Bubble_Sort_G (g-busorg.ads)::
14978 * GNAT.Byte_Order_Mark (g-byorma.ads)::
14979 * GNAT.Byte_Swapping (g-bytswa.ads)::
14980 * GNAT.Calendar (g-calend.ads)::
14981 * GNAT.Calendar.Time_IO (g-catiio.ads)::
14982 * GNAT.Case_Util (g-casuti.ads)::
14983 * GNAT.CGI (g-cgi.ads)::
14984 * GNAT.CGI.Cookie (g-cgicoo.ads)::
14985 * GNAT.CGI.Debug (g-cgideb.ads)::
14986 * GNAT.Command_Line (g-comlin.ads)::
14987 * GNAT.Compiler_Version (g-comver.ads)::
14988 * GNAT.Ctrl_C (g-ctrl_c.ads)::
14989 * GNAT.CRC32 (g-crc32.ads)::
14990 * GNAT.Current_Exception (g-curexc.ads)::
14991 * GNAT.Debug_Pools (g-debpoo.ads)::
14992 * GNAT.Debug_Utilities (g-debuti.ads)::
14993 * GNAT.Decode_String (g-decstr.ads)::
14994 * GNAT.Decode_UTF8_String (g-deutst.ads)::
14995 * GNAT.Directory_Operations (g-dirope.ads)::
14996 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
14997 * GNAT.Dynamic_HTables (g-dynhta.ads)::
14998 * GNAT.Dynamic_Tables (g-dyntab.ads)::
14999 * GNAT.Encode_String (g-encstr.ads)::
15000 * GNAT.Encode_UTF8_String (g-enutst.ads)::
15001 * GNAT.Exception_Actions (g-excact.ads)::
15002 * GNAT.Exception_Traces (g-exctra.ads)::
15003 * GNAT.Exceptions (g-except.ads)::
15004 * GNAT.Expect (g-expect.ads)::
15005 * GNAT.Expect.TTY (g-exptty.ads)::
15006 * GNAT.Float_Control (g-flocon.ads)::
15007 * GNAT.Heap_Sort (g-heasor.ads)::
15008 * GNAT.Heap_Sort_A (g-hesora.ads)::
15009 * GNAT.Heap_Sort_G (g-hesorg.ads)::
15010 * GNAT.HTable (g-htable.ads)::
15011 * GNAT.IO (g-io.ads)::
15012 * GNAT.IO_Aux (g-io_aux.ads)::
15013 * GNAT.Lock_Files (g-locfil.ads)::
15014 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
15015 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
15016 * GNAT.MD5 (g-md5.ads)::
15017 * GNAT.Memory_Dump (g-memdum.ads)::
15018 * GNAT.Most_Recent_Exception (g-moreex.ads)::
15019 * GNAT.OS_Lib (g-os_lib.ads)::
15020 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
15021 * GNAT.Random_Numbers (g-rannum.ads)::
15022 * GNAT.Regexp (g-regexp.ads)::
15023 * GNAT.Registry (g-regist.ads)::
15024 * GNAT.Regpat (g-regpat.ads)::
15025 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
15026 * GNAT.Semaphores (g-semaph.ads)::
15027 * GNAT.Serial_Communications (g-sercom.ads)::
15028 * GNAT.SHA1 (g-sha1.ads)::
15029 * GNAT.SHA224 (g-sha224.ads)::
15030 * GNAT.SHA256 (g-sha256.ads)::
15031 * GNAT.SHA384 (g-sha384.ads)::
15032 * GNAT.SHA512 (g-sha512.ads)::
15033 * GNAT.Signals (g-signal.ads)::
15034 * GNAT.Sockets (g-socket.ads)::
15035 * GNAT.Source_Info (g-souinf.ads)::
15036 * GNAT.Spelling_Checker (g-speche.ads)::
15037 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
15038 * GNAT.Spitbol.Patterns (g-spipat.ads)::
15039 * GNAT.Spitbol (g-spitbo.ads)::
15040 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
15041 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
15042 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
15043 * GNAT.SSE (g-sse.ads)::
15044 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
15045 * GNAT.Strings (g-string.ads)::
15046 * GNAT.String_Split (g-strspl.ads)::
15047 * GNAT.Table (g-table.ads)::
15048 * GNAT.Task_Lock (g-tasloc.ads)::
15049 * GNAT.Threads (g-thread.ads)::
15050 * GNAT.Time_Stamp (g-timsta.ads)::
15051 * GNAT.Traceback (g-traceb.ads)::
15052 * GNAT.Traceback.Symbolic (g-trasym.ads)::
15053 * GNAT.UTF_32 (g-utf_32.ads)::
15054 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
15055 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
15056 * GNAT.Wide_String_Split (g-wistsp.ads)::
15057 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
15058 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
15059 * Interfaces.C.Extensions (i-cexten.ads)::
15060 * Interfaces.C.Streams (i-cstrea.ads)::
15061 * Interfaces.CPP (i-cpp.ads)::
15062 * Interfaces.Packed_Decimal (i-pacdec.ads)::
15063 * Interfaces.VxWorks (i-vxwork.ads)::
15064 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
15065 * System.Address_Image (s-addima.ads)::
15066 * System.Assertions (s-assert.ads)::
15067 * System.Memory (s-memory.ads)::
15068 * System.Partition_Interface (s-parint.ads)::
15069 * System.Pool_Global (s-pooglo.ads)::
15070 * System.Pool_Local (s-pooloc.ads)::
15071 * System.Restrictions (s-restri.ads)::
15072 * System.Rident (s-rident.ads)::
15073 * System.Strings.Stream_Ops (s-ststop.ads)::
15074 * System.Task_Info (s-tasinf.ads)::
15075 * System.Wch_Cnv (s-wchcnv.ads)::
15076 * System.Wch_Con (s-wchcon.ads)::
15079 @node Ada.Characters.Latin_9 (a-chlat9.ads)
15080 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15081 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15082 @cindex Latin_9 constants for Character
15085 This child of @code{Ada.Characters}
15086 provides a set of definitions corresponding to those in the
15087 RM-defined package @code{Ada.Characters.Latin_1} but with the
15088 few modifications required for @code{Latin-9}
15089 The provision of such a package
15090 is specifically authorized by the Ada Reference Manual
15093 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
15094 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15095 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15096 @cindex Latin_1 constants for Wide_Character
15099 This child of @code{Ada.Characters}
15100 provides a set of definitions corresponding to those in the
15101 RM-defined package @code{Ada.Characters.Latin_1} but with the
15102 types of the constants being @code{Wide_Character}
15103 instead of @code{Character}. The provision of such a package
15104 is specifically authorized by the Ada Reference Manual
15107 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
15108 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15109 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15110 @cindex Latin_9 constants for Wide_Character
15113 This child of @code{Ada.Characters}
15114 provides a set of definitions corresponding to those in the
15115 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15116 types of the constants being @code{Wide_Character}
15117 instead of @code{Character}. The provision of such a package
15118 is specifically authorized by the Ada Reference Manual
15121 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
15122 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15123 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15124 @cindex Latin_1 constants for Wide_Wide_Character
15127 This child of @code{Ada.Characters}
15128 provides a set of definitions corresponding to those in the
15129 RM-defined package @code{Ada.Characters.Latin_1} but with the
15130 types of the constants being @code{Wide_Wide_Character}
15131 instead of @code{Character}. The provision of such a package
15132 is specifically authorized by the Ada Reference Manual
15135 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
15136 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15137 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15138 @cindex Latin_9 constants for Wide_Wide_Character
15141 This child of @code{Ada.Characters}
15142 provides a set of definitions corresponding to those in the
15143 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15144 types of the constants being @code{Wide_Wide_Character}
15145 instead of @code{Character}. The provision of such a package
15146 is specifically authorized by the Ada Reference Manual
15149 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
15150 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15151 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15152 @cindex Formal container for doubly linked lists
15155 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15156 container for doubly linked lists, meant to facilitate formal verification of
15157 code using such containers.
15159 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
15160 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15161 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15162 @cindex Formal container for hashed maps
15165 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15166 container for hashed maps, meant to facilitate formal verification of
15167 code using such containers.
15169 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
15170 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15171 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15172 @cindex Formal container for hashed sets
15175 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15176 container for hashed sets, meant to facilitate formal verification of
15177 code using such containers.
15179 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
15180 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15181 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15182 @cindex Formal container for ordered maps
15185 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15186 container for ordered maps, meant to facilitate formal verification of
15187 code using such containers.
15189 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
15190 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15191 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15192 @cindex Formal container for ordered sets
15195 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15196 container for ordered sets, meant to facilitate formal verification of
15197 code using such containers.
15199 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
15200 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15201 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15202 @cindex Formal container for vectors
15205 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15206 container for vectors, meant to facilitate formal verification of
15207 code using such containers.
15209 @node Ada.Command_Line.Environment (a-colien.ads)
15210 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15211 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15212 @cindex Environment entries
15215 This child of @code{Ada.Command_Line}
15216 provides a mechanism for obtaining environment values on systems
15217 where this concept makes sense.
15219 @node Ada.Command_Line.Remove (a-colire.ads)
15220 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15221 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15222 @cindex Removing command line arguments
15223 @cindex Command line, argument removal
15226 This child of @code{Ada.Command_Line}
15227 provides a mechanism for logically removing
15228 arguments from the argument list. Once removed, an argument is not visible
15229 to further calls on the subprograms in @code{Ada.Command_Line} will not
15230 see the removed argument.
15232 @node Ada.Command_Line.Response_File (a-clrefi.ads)
15233 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15234 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15235 @cindex Response file for command line
15236 @cindex Command line, response file
15237 @cindex Command line, handling long command lines
15240 This child of @code{Ada.Command_Line} provides a mechanism facilities for
15241 getting command line arguments from a text file, called a "response file".
15242 Using a response file allow passing a set of arguments to an executable longer
15243 than the maximum allowed by the system on the command line.
15245 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
15246 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15247 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15248 @cindex C Streams, Interfacing with Direct_IO
15251 This package provides subprograms that allow interfacing between
15252 C streams and @code{Direct_IO}. The stream identifier can be
15253 extracted from a file opened on the Ada side, and an Ada file
15254 can be constructed from a stream opened on the C side.
15256 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
15257 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15258 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15259 @cindex Null_Occurrence, testing for
15262 This child subprogram provides a way of testing for the null
15263 exception occurrence (@code{Null_Occurrence}) without raising
15266 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
15267 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15268 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15269 @cindex Null_Occurrence, testing for
15272 This child subprogram is used for handling otherwise unhandled
15273 exceptions (hence the name last chance), and perform clean ups before
15274 terminating the program. Note that this subprogram never returns.
15276 @node Ada.Exceptions.Traceback (a-exctra.ads)
15277 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15278 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15279 @cindex Traceback for Exception Occurrence
15282 This child package provides the subprogram (@code{Tracebacks}) to
15283 give a traceback array of addresses based on an exception
15286 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
15287 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15288 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15289 @cindex C Streams, Interfacing with Sequential_IO
15292 This package provides subprograms that allow interfacing between
15293 C streams and @code{Sequential_IO}. The stream identifier can be
15294 extracted from a file opened on the Ada side, and an Ada file
15295 can be constructed from a stream opened on the C side.
15297 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
15298 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15299 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15300 @cindex C Streams, Interfacing with Stream_IO
15303 This package provides subprograms that allow interfacing between
15304 C streams and @code{Stream_IO}. The stream identifier can be
15305 extracted from a file opened on the Ada side, and an Ada file
15306 can be constructed from a stream opened on the C side.
15308 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
15309 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15310 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15311 @cindex @code{Unbounded_String}, IO support
15312 @cindex @code{Text_IO}, extensions for unbounded strings
15315 This package provides subprograms for Text_IO for unbounded
15316 strings, avoiding the necessity for an intermediate operation
15317 with ordinary strings.
15319 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
15320 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15321 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15322 @cindex @code{Unbounded_Wide_String}, IO support
15323 @cindex @code{Text_IO}, extensions for unbounded wide strings
15326 This package provides subprograms for Text_IO for unbounded
15327 wide strings, avoiding the necessity for an intermediate operation
15328 with ordinary wide strings.
15330 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
15331 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15332 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15333 @cindex @code{Unbounded_Wide_Wide_String}, IO support
15334 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
15337 This package provides subprograms for Text_IO for unbounded
15338 wide wide strings, avoiding the necessity for an intermediate operation
15339 with ordinary wide wide strings.
15341 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
15342 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15343 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15344 @cindex C Streams, Interfacing with @code{Text_IO}
15347 This package provides subprograms that allow interfacing between
15348 C streams and @code{Text_IO}. The stream identifier can be
15349 extracted from a file opened on the Ada side, and an Ada file
15350 can be constructed from a stream opened on the C side.
15352 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
15353 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15354 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15355 @cindex @code{Text_IO} resetting standard files
15358 This procedure is used to reset the status of the standard files used
15359 by Ada.Text_IO. This is useful in a situation (such as a restart in an
15360 embedded application) where the status of the files may change during
15361 execution (for example a standard input file may be redefined to be
15364 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
15365 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15366 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15367 @cindex Unicode categorization, Wide_Character
15370 This package provides subprograms that allow categorization of
15371 Wide_Character values according to Unicode categories.
15373 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
15374 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15375 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15376 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
15379 This package provides subprograms that allow interfacing between
15380 C streams and @code{Wide_Text_IO}. The stream identifier can be
15381 extracted from a file opened on the Ada side, and an Ada file
15382 can be constructed from a stream opened on the C side.
15384 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
15385 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15386 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15387 @cindex @code{Wide_Text_IO} resetting standard files
15390 This procedure is used to reset the status of the standard files used
15391 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
15392 embedded application) where the status of the files may change during
15393 execution (for example a standard input file may be redefined to be
15396 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
15397 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15398 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15399 @cindex Unicode categorization, Wide_Wide_Character
15402 This package provides subprograms that allow categorization of
15403 Wide_Wide_Character values according to Unicode categories.
15405 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
15406 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15407 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15408 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
15411 This package provides subprograms that allow interfacing between
15412 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
15413 extracted from a file opened on the Ada side, and an Ada file
15414 can be constructed from a stream opened on the C side.
15416 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
15417 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15418 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15419 @cindex @code{Wide_Wide_Text_IO} resetting standard files
15422 This procedure is used to reset the status of the standard files used
15423 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
15424 restart in an embedded application) where the status of the files may
15425 change during execution (for example a standard input file may be
15426 redefined to be interactive).
15428 @node GNAT.Altivec (g-altive.ads)
15429 @section @code{GNAT.Altivec} (@file{g-altive.ads})
15430 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
15434 This is the root package of the GNAT AltiVec binding. It provides
15435 definitions of constants and types common to all the versions of the
15438 @node GNAT.Altivec.Conversions (g-altcon.ads)
15439 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15440 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15444 This package provides the Vector/View conversion routines.
15446 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
15447 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15448 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15452 This package exposes the Ada interface to the AltiVec operations on
15453 vector objects. A soft emulation is included by default in the GNAT
15454 library. The hard binding is provided as a separate package. This unit
15455 is common to both bindings.
15457 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
15458 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15459 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15463 This package exposes the various vector types part of the Ada binding
15464 to AltiVec facilities.
15466 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
15467 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15468 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15472 This package provides public 'View' data types from/to which private
15473 vector representations can be converted via
15474 GNAT.Altivec.Conversions. This allows convenient access to individual
15475 vector elements and provides a simple way to initialize vector
15478 @node GNAT.Array_Split (g-arrspl.ads)
15479 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15480 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15481 @cindex Array splitter
15484 Useful array-manipulation routines: given a set of separators, split
15485 an array wherever the separators appear, and provide direct access
15486 to the resulting slices.
15488 @node GNAT.AWK (g-awk.ads)
15489 @section @code{GNAT.AWK} (@file{g-awk.ads})
15490 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
15495 Provides AWK-like parsing functions, with an easy interface for parsing one
15496 or more files containing formatted data. The file is viewed as a database
15497 where each record is a line and a field is a data element in this line.
15499 @node GNAT.Bounded_Buffers (g-boubuf.ads)
15500 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15501 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15503 @cindex Bounded Buffers
15506 Provides a concurrent generic bounded buffer abstraction. Instances are
15507 useful directly or as parts of the implementations of other abstractions,
15510 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
15511 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15512 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15517 Provides a thread-safe asynchronous intertask mailbox communication facility.
15519 @node GNAT.Bubble_Sort (g-bubsor.ads)
15520 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15521 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15523 @cindex Bubble sort
15526 Provides a general implementation of bubble sort usable for sorting arbitrary
15527 data items. Exchange and comparison procedures are provided by passing
15528 access-to-procedure values.
15530 @node GNAT.Bubble_Sort_A (g-busora.ads)
15531 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15532 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15534 @cindex Bubble sort
15537 Provides a general implementation of bubble sort usable for sorting arbitrary
15538 data items. Move and comparison procedures are provided by passing
15539 access-to-procedure values. This is an older version, retained for
15540 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
15542 @node GNAT.Bubble_Sort_G (g-busorg.ads)
15543 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15544 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15546 @cindex Bubble sort
15549 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
15550 are provided as generic parameters, this improves efficiency, especially
15551 if the procedures can be inlined, at the expense of duplicating code for
15552 multiple instantiations.
15554 @node GNAT.Byte_Order_Mark (g-byorma.ads)
15555 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15556 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15557 @cindex UTF-8 representation
15558 @cindex Wide characte representations
15561 Provides a routine which given a string, reads the start of the string to
15562 see whether it is one of the standard byte order marks (BOM's) which signal
15563 the encoding of the string. The routine includes detection of special XML
15564 sequences for various UCS input formats.
15566 @node GNAT.Byte_Swapping (g-bytswa.ads)
15567 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15568 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15569 @cindex Byte swapping
15573 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
15574 Machine-specific implementations are available in some cases.
15576 @node GNAT.Calendar (g-calend.ads)
15577 @section @code{GNAT.Calendar} (@file{g-calend.ads})
15578 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
15579 @cindex @code{Calendar}
15582 Extends the facilities provided by @code{Ada.Calendar} to include handling
15583 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
15584 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
15585 C @code{timeval} format.
15587 @node GNAT.Calendar.Time_IO (g-catiio.ads)
15588 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15589 @cindex @code{Calendar}
15591 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15593 @node GNAT.CRC32 (g-crc32.ads)
15594 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
15595 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
15597 @cindex Cyclic Redundancy Check
15600 This package implements the CRC-32 algorithm. For a full description
15601 of this algorithm see
15602 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
15603 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
15604 Aug.@: 1988. Sarwate, D.V@.
15606 @node GNAT.Case_Util (g-casuti.ads)
15607 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
15608 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
15609 @cindex Casing utilities
15610 @cindex Character handling (@code{GNAT.Case_Util})
15613 A set of simple routines for handling upper and lower casing of strings
15614 without the overhead of the full casing tables
15615 in @code{Ada.Characters.Handling}.
15617 @node GNAT.CGI (g-cgi.ads)
15618 @section @code{GNAT.CGI} (@file{g-cgi.ads})
15619 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
15620 @cindex CGI (Common Gateway Interface)
15623 This is a package for interfacing a GNAT program with a Web server via the
15624 Common Gateway Interface (CGI)@. Basically this package parses the CGI
15625 parameters, which are a set of key/value pairs sent by the Web server. It
15626 builds a table whose index is the key and provides some services to deal
15629 @node GNAT.CGI.Cookie (g-cgicoo.ads)
15630 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15631 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15632 @cindex CGI (Common Gateway Interface) cookie support
15633 @cindex Cookie support in CGI
15636 This is a package to interface a GNAT program with a Web server via the
15637 Common Gateway Interface (CGI). It exports services to deal with Web
15638 cookies (piece of information kept in the Web client software).
15640 @node GNAT.CGI.Debug (g-cgideb.ads)
15641 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15642 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15643 @cindex CGI (Common Gateway Interface) debugging
15646 This is a package to help debugging CGI (Common Gateway Interface)
15647 programs written in Ada.
15649 @node GNAT.Command_Line (g-comlin.ads)
15650 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
15651 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
15652 @cindex Command line
15655 Provides a high level interface to @code{Ada.Command_Line} facilities,
15656 including the ability to scan for named switches with optional parameters
15657 and expand file names using wild card notations.
15659 @node GNAT.Compiler_Version (g-comver.ads)
15660 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15661 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15662 @cindex Compiler Version
15663 @cindex Version, of compiler
15666 Provides a routine for obtaining the version of the compiler used to
15667 compile the program. More accurately this is the version of the binder
15668 used to bind the program (this will normally be the same as the version
15669 of the compiler if a consistent tool set is used to compile all units
15672 @node GNAT.Ctrl_C (g-ctrl_c.ads)
15673 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15674 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15678 Provides a simple interface to handle Ctrl-C keyboard events.
15680 @node GNAT.Current_Exception (g-curexc.ads)
15681 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15682 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15683 @cindex Current exception
15684 @cindex Exception retrieval
15687 Provides access to information on the current exception that has been raised
15688 without the need for using the Ada 95 / Ada 2005 exception choice parameter
15689 specification syntax.
15690 This is particularly useful in simulating typical facilities for
15691 obtaining information about exceptions provided by Ada 83 compilers.
15693 @node GNAT.Debug_Pools (g-debpoo.ads)
15694 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15695 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15697 @cindex Debug pools
15698 @cindex Memory corruption debugging
15701 Provide a debugging storage pools that helps tracking memory corruption
15702 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
15703 @value{EDITION} User's Guide}.
15705 @node GNAT.Debug_Utilities (g-debuti.ads)
15706 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15707 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15711 Provides a few useful utilities for debugging purposes, including conversion
15712 to and from string images of address values. Supports both C and Ada formats
15713 for hexadecimal literals.
15715 @node GNAT.Decode_String (g-decstr.ads)
15716 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
15717 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
15718 @cindex Decoding strings
15719 @cindex String decoding
15720 @cindex Wide character encoding
15725 A generic package providing routines for decoding wide character and wide wide
15726 character strings encoded as sequences of 8-bit characters using a specified
15727 encoding method. Includes validation routines, and also routines for stepping
15728 to next or previous encoded character in an encoded string.
15729 Useful in conjunction with Unicode character coding. Note there is a
15730 preinstantiation for UTF-8. See next entry.
15732 @node GNAT.Decode_UTF8_String (g-deutst.ads)
15733 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15734 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15735 @cindex Decoding strings
15736 @cindex Decoding UTF-8 strings
15737 @cindex UTF-8 string decoding
15738 @cindex Wide character decoding
15743 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
15745 @node GNAT.Directory_Operations (g-dirope.ads)
15746 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15747 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15748 @cindex Directory operations
15751 Provides a set of routines for manipulating directories, including changing
15752 the current directory, making new directories, and scanning the files in a
15755 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
15756 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15757 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15758 @cindex Directory operations iteration
15761 A child unit of GNAT.Directory_Operations providing additional operations
15762 for iterating through directories.
15764 @node GNAT.Dynamic_HTables (g-dynhta.ads)
15765 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15766 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15767 @cindex Hash tables
15770 A generic implementation of hash tables that can be used to hash arbitrary
15771 data. Provided in two forms, a simple form with built in hash functions,
15772 and a more complex form in which the hash function is supplied.
15775 This package provides a facility similar to that of @code{GNAT.HTable},
15776 except that this package declares a type that can be used to define
15777 dynamic instances of the hash table, while an instantiation of
15778 @code{GNAT.HTable} creates a single instance of the hash table.
15780 @node GNAT.Dynamic_Tables (g-dyntab.ads)
15781 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15782 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15783 @cindex Table implementation
15784 @cindex Arrays, extendable
15787 A generic package providing a single dimension array abstraction where the
15788 length of the array can be dynamically modified.
15791 This package provides a facility similar to that of @code{GNAT.Table},
15792 except that this package declares a type that can be used to define
15793 dynamic instances of the table, while an instantiation of
15794 @code{GNAT.Table} creates a single instance of the table type.
15796 @node GNAT.Encode_String (g-encstr.ads)
15797 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
15798 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
15799 @cindex Encoding strings
15800 @cindex String encoding
15801 @cindex Wide character encoding
15806 A generic package providing routines for encoding wide character and wide
15807 wide character strings as sequences of 8-bit characters using a specified
15808 encoding method. Useful in conjunction with Unicode character coding.
15809 Note there is a preinstantiation for UTF-8. See next entry.
15811 @node GNAT.Encode_UTF8_String (g-enutst.ads)
15812 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15813 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15814 @cindex Encoding strings
15815 @cindex Encoding UTF-8 strings
15816 @cindex UTF-8 string encoding
15817 @cindex Wide character encoding
15822 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
15824 @node GNAT.Exception_Actions (g-excact.ads)
15825 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15826 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15827 @cindex Exception actions
15830 Provides callbacks when an exception is raised. Callbacks can be registered
15831 for specific exceptions, or when any exception is raised. This
15832 can be used for instance to force a core dump to ease debugging.
15834 @node GNAT.Exception_Traces (g-exctra.ads)
15835 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15836 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15837 @cindex Exception traces
15841 Provides an interface allowing to control automatic output upon exception
15844 @node GNAT.Exceptions (g-except.ads)
15845 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
15846 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
15847 @cindex Exceptions, Pure
15848 @cindex Pure packages, exceptions
15851 Normally it is not possible to raise an exception with
15852 a message from a subprogram in a pure package, since the
15853 necessary types and subprograms are in @code{Ada.Exceptions}
15854 which is not a pure unit. @code{GNAT.Exceptions} provides a
15855 facility for getting around this limitation for a few
15856 predefined exceptions, and for example allow raising
15857 @code{Constraint_Error} with a message from a pure subprogram.
15859 @node GNAT.Expect (g-expect.ads)
15860 @section @code{GNAT.Expect} (@file{g-expect.ads})
15861 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
15864 Provides a set of subprograms similar to what is available
15865 with the standard Tcl Expect tool.
15866 It allows you to easily spawn and communicate with an external process.
15867 You can send commands or inputs to the process, and compare the output
15868 with some expected regular expression. Currently @code{GNAT.Expect}
15869 is implemented on all native GNAT ports except for OpenVMS@.
15870 It is not implemented for cross ports, and in particular is not
15871 implemented for VxWorks or LynxOS@.
15873 @node GNAT.Expect.TTY (g-exptty.ads)
15874 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15875 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15878 As GNAT.Expect but using pseudo-terminal.
15879 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
15880 ports except for OpenVMS@. It is not implemented for cross ports, and
15881 in particular is not implemented for VxWorks or LynxOS@.
15883 @node GNAT.Float_Control (g-flocon.ads)
15884 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
15885 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
15886 @cindex Floating-Point Processor
15889 Provides an interface for resetting the floating-point processor into the
15890 mode required for correct semantic operation in Ada. Some third party
15891 library calls may cause this mode to be modified, and the Reset procedure
15892 in this package can be used to reestablish the required mode.
15894 @node GNAT.Heap_Sort (g-heasor.ads)
15895 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15896 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15900 Provides a general implementation of heap sort usable for sorting arbitrary
15901 data items. Exchange and comparison procedures are provided by passing
15902 access-to-procedure values. The algorithm used is a modified heap sort
15903 that performs approximately N*log(N) comparisons in the worst case.
15905 @node GNAT.Heap_Sort_A (g-hesora.ads)
15906 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15907 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15911 Provides a general implementation of heap sort usable for sorting arbitrary
15912 data items. Move and comparison procedures are provided by passing
15913 access-to-procedure values. The algorithm used is a modified heap sort
15914 that performs approximately N*log(N) comparisons in the worst case.
15915 This differs from @code{GNAT.Heap_Sort} in having a less convenient
15916 interface, but may be slightly more efficient.
15918 @node GNAT.Heap_Sort_G (g-hesorg.ads)
15919 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15920 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15924 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
15925 are provided as generic parameters, this improves efficiency, especially
15926 if the procedures can be inlined, at the expense of duplicating code for
15927 multiple instantiations.
15929 @node GNAT.HTable (g-htable.ads)
15930 @section @code{GNAT.HTable} (@file{g-htable.ads})
15931 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
15932 @cindex Hash tables
15935 A generic implementation of hash tables that can be used to hash arbitrary
15936 data. Provides two approaches, one a simple static approach, and the other
15937 allowing arbitrary dynamic hash tables.
15939 @node GNAT.IO (g-io.ads)
15940 @section @code{GNAT.IO} (@file{g-io.ads})
15941 @cindex @code{GNAT.IO} (@file{g-io.ads})
15943 @cindex Input/Output facilities
15946 A simple preelaborable input-output package that provides a subset of
15947 simple Text_IO functions for reading characters and strings from
15948 Standard_Input, and writing characters, strings and integers to either
15949 Standard_Output or Standard_Error.
15951 @node GNAT.IO_Aux (g-io_aux.ads)
15952 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15953 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15955 @cindex Input/Output facilities
15957 Provides some auxiliary functions for use with Text_IO, including a test
15958 for whether a file exists, and functions for reading a line of text.
15960 @node GNAT.Lock_Files (g-locfil.ads)
15961 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15962 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15963 @cindex File locking
15964 @cindex Locking using files
15967 Provides a general interface for using files as locks. Can be used for
15968 providing program level synchronization.
15970 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
15971 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15972 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15973 @cindex Random number generation
15976 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
15977 a modified version of the Blum-Blum-Shub generator.
15979 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
15980 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15981 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15982 @cindex Random number generation
15985 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
15986 a modified version of the Blum-Blum-Shub generator.
15988 @node GNAT.MD5 (g-md5.ads)
15989 @section @code{GNAT.MD5} (@file{g-md5.ads})
15990 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
15991 @cindex Message Digest MD5
15994 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
15996 @node GNAT.Memory_Dump (g-memdum.ads)
15997 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15998 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15999 @cindex Dump Memory
16002 Provides a convenient routine for dumping raw memory to either the
16003 standard output or standard error files. Uses GNAT.IO for actual
16006 @node GNAT.Most_Recent_Exception (g-moreex.ads)
16007 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
16008 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
16009 @cindex Exception, obtaining most recent
16012 Provides access to the most recently raised exception. Can be used for
16013 various logging purposes, including duplicating functionality of some
16014 Ada 83 implementation dependent extensions.
16016 @node GNAT.OS_Lib (g-os_lib.ads)
16017 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
16018 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
16019 @cindex Operating System interface
16020 @cindex Spawn capability
16023 Provides a range of target independent operating system interface functions,
16024 including time/date management, file operations, subprocess management,
16025 including a portable spawn procedure, and access to environment variables
16026 and error return codes.
16028 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
16029 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
16030 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
16031 @cindex Hash functions
16034 Provides a generator of static minimal perfect hash functions. No
16035 collisions occur and each item can be retrieved from the table in one
16036 probe (perfect property). The hash table size corresponds to the exact
16037 size of the key set and no larger (minimal property). The key set has to
16038 be know in advance (static property). The hash functions are also order
16039 preserving. If w2 is inserted after w1 in the generator, their
16040 hashcode are in the same order. These hashing functions are very
16041 convenient for use with realtime applications.
16043 @node GNAT.Random_Numbers (g-rannum.ads)
16044 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
16045 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
16046 @cindex Random number generation
16049 Provides random number capabilities which extend those available in the
16050 standard Ada library and are more convenient to use.
16052 @node GNAT.Regexp (g-regexp.ads)
16053 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
16054 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
16055 @cindex Regular expressions
16056 @cindex Pattern matching
16059 A simple implementation of regular expressions, using a subset of regular
16060 expression syntax copied from familiar Unix style utilities. This is the
16061 simples of the three pattern matching packages provided, and is particularly
16062 suitable for ``file globbing'' applications.
16064 @node GNAT.Registry (g-regist.ads)
16065 @section @code{GNAT.Registry} (@file{g-regist.ads})
16066 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
16067 @cindex Windows Registry
16070 This is a high level binding to the Windows registry. It is possible to
16071 do simple things like reading a key value, creating a new key. For full
16072 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
16073 package provided with the Win32Ada binding
16075 @node GNAT.Regpat (g-regpat.ads)
16076 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
16077 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
16078 @cindex Regular expressions
16079 @cindex Pattern matching
16082 A complete implementation of Unix-style regular expression matching, copied
16083 from the original V7 style regular expression library written in C by
16084 Henry Spencer (and binary compatible with this C library).
16086 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
16087 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16088 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16089 @cindex Secondary Stack Info
16092 Provide the capability to query the high water mark of the current task's
16095 @node GNAT.Semaphores (g-semaph.ads)
16096 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
16097 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
16101 Provides classic counting and binary semaphores using protected types.
16103 @node GNAT.Serial_Communications (g-sercom.ads)
16104 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16105 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16106 @cindex Serial_Communications
16109 Provides a simple interface to send and receive data over a serial
16110 port. This is only supported on GNU/Linux and Windows.
16112 @node GNAT.SHA1 (g-sha1.ads)
16113 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
16114 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
16115 @cindex Secure Hash Algorithm SHA-1
16118 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
16121 @node GNAT.SHA224 (g-sha224.ads)
16122 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
16123 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
16124 @cindex Secure Hash Algorithm SHA-224
16127 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
16129 @node GNAT.SHA256 (g-sha256.ads)
16130 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
16131 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
16132 @cindex Secure Hash Algorithm SHA-256
16135 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
16137 @node GNAT.SHA384 (g-sha384.ads)
16138 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
16139 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
16140 @cindex Secure Hash Algorithm SHA-384
16143 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
16145 @node GNAT.SHA512 (g-sha512.ads)
16146 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
16147 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
16148 @cindex Secure Hash Algorithm SHA-512
16151 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
16153 @node GNAT.Signals (g-signal.ads)
16154 @section @code{GNAT.Signals} (@file{g-signal.ads})
16155 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
16159 Provides the ability to manipulate the blocked status of signals on supported
16162 @node GNAT.Sockets (g-socket.ads)
16163 @section @code{GNAT.Sockets} (@file{g-socket.ads})
16164 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
16168 A high level and portable interface to develop sockets based applications.
16169 This package is based on the sockets thin binding found in
16170 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
16171 on all native GNAT ports except for OpenVMS@. It is not implemented
16172 for the LynxOS@ cross port.
16174 @node GNAT.Source_Info (g-souinf.ads)
16175 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
16176 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
16177 @cindex Source Information
16180 Provides subprograms that give access to source code information known at
16181 compile time, such as the current file name and line number.
16183 @node GNAT.Spelling_Checker (g-speche.ads)
16184 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16185 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16186 @cindex Spell checking
16189 Provides a function for determining whether one string is a plausible
16190 near misspelling of another string.
16192 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
16193 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16194 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16195 @cindex Spell checking
16198 Provides a generic function that can be instantiated with a string type for
16199 determining whether one string is a plausible near misspelling of another
16202 @node GNAT.Spitbol.Patterns (g-spipat.ads)
16203 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16204 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16205 @cindex SPITBOL pattern matching
16206 @cindex Pattern matching
16209 A complete implementation of SNOBOL4 style pattern matching. This is the
16210 most elaborate of the pattern matching packages provided. It fully duplicates
16211 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
16212 efficient algorithm developed by Robert Dewar for the SPITBOL system.
16214 @node GNAT.Spitbol (g-spitbo.ads)
16215 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16216 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16217 @cindex SPITBOL interface
16220 The top level package of the collection of SPITBOL-style functionality, this
16221 package provides basic SNOBOL4 string manipulation functions, such as
16222 Pad, Reverse, Trim, Substr capability, as well as a generic table function
16223 useful for constructing arbitrary mappings from strings in the style of
16224 the SNOBOL4 TABLE function.
16226 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
16227 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16228 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16229 @cindex Sets of strings
16230 @cindex SPITBOL Tables
16233 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16234 for type @code{Standard.Boolean}, giving an implementation of sets of
16237 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
16238 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16239 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16240 @cindex Integer maps
16242 @cindex SPITBOL Tables
16245 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16246 for type @code{Standard.Integer}, giving an implementation of maps
16247 from string to integer values.
16249 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
16250 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16251 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16252 @cindex String maps
16254 @cindex SPITBOL Tables
16257 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
16258 a variable length string type, giving an implementation of general
16259 maps from strings to strings.
16261 @node GNAT.SSE (g-sse.ads)
16262 @section @code{GNAT.SSE} (@file{g-sse.ads})
16263 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
16266 Root of a set of units aimed at offering Ada bindings to a subset of
16267 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
16268 targets. It exposes vector component types together with a general
16269 introduction to the binding contents and use.
16271 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
16272 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16273 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16276 SSE vector types for use with SSE related intrinsics.
16278 @node GNAT.Strings (g-string.ads)
16279 @section @code{GNAT.Strings} (@file{g-string.ads})
16280 @cindex @code{GNAT.Strings} (@file{g-string.ads})
16283 Common String access types and related subprograms. Basically it
16284 defines a string access and an array of string access types.
16286 @node GNAT.String_Split (g-strspl.ads)
16287 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
16288 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
16289 @cindex String splitter
16292 Useful string manipulation routines: given a set of separators, split
16293 a string wherever the separators appear, and provide direct access
16294 to the resulting slices. This package is instantiated from
16295 @code{GNAT.Array_Split}.
16297 @node GNAT.Table (g-table.ads)
16298 @section @code{GNAT.Table} (@file{g-table.ads})
16299 @cindex @code{GNAT.Table} (@file{g-table.ads})
16300 @cindex Table implementation
16301 @cindex Arrays, extendable
16304 A generic package providing a single dimension array abstraction where the
16305 length of the array can be dynamically modified.
16308 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
16309 except that this package declares a single instance of the table type,
16310 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
16311 used to define dynamic instances of the table.
16313 @node GNAT.Task_Lock (g-tasloc.ads)
16314 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16315 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16316 @cindex Task synchronization
16317 @cindex Task locking
16321 A very simple facility for locking and unlocking sections of code using a
16322 single global task lock. Appropriate for use in situations where contention
16323 between tasks is very rarely expected.
16325 @node GNAT.Time_Stamp (g-timsta.ads)
16326 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16327 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16329 @cindex Current time
16332 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
16333 represents the current date and time in ISO 8601 format. This is a very simple
16334 routine with minimal code and there are no dependencies on any other unit.
16336 @node GNAT.Threads (g-thread.ads)
16337 @section @code{GNAT.Threads} (@file{g-thread.ads})
16338 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
16339 @cindex Foreign threads
16340 @cindex Threads, foreign
16343 Provides facilities for dealing with foreign threads which need to be known
16344 by the GNAT run-time system. Consult the documentation of this package for
16345 further details if your program has threads that are created by a non-Ada
16346 environment which then accesses Ada code.
16348 @node GNAT.Traceback (g-traceb.ads)
16349 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
16350 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
16351 @cindex Trace back facilities
16354 Provides a facility for obtaining non-symbolic traceback information, useful
16355 in various debugging situations.
16357 @node GNAT.Traceback.Symbolic (g-trasym.ads)
16358 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16359 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16360 @cindex Trace back facilities
16362 @node GNAT.UTF_32 (g-utf_32.ads)
16363 @section @code{GNAT.UTF_32} (@file{g-table.ads})
16364 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
16365 @cindex Wide character codes
16368 This is a package intended to be used in conjunction with the
16369 @code{Wide_Character} type in Ada 95 and the
16370 @code{Wide_Wide_Character} type in Ada 2005 (available
16371 in @code{GNAT} in Ada 2005 mode). This package contains
16372 Unicode categorization routines, as well as lexical
16373 categorization routines corresponding to the Ada 2005
16374 lexical rules for identifiers and strings, and also a
16375 lower case to upper case fold routine corresponding to
16376 the Ada 2005 rules for identifier equivalence.
16378 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
16379 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16380 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16381 @cindex Spell checking
16384 Provides a function for determining whether one wide wide string is a plausible
16385 near misspelling of another wide wide string, where the strings are represented
16386 using the UTF_32_String type defined in System.Wch_Cnv.
16388 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
16389 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16390 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16391 @cindex Spell checking
16394 Provides a function for determining whether one wide string is a plausible
16395 near misspelling of another wide string.
16397 @node GNAT.Wide_String_Split (g-wistsp.ads)
16398 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16399 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16400 @cindex Wide_String splitter
16403 Useful wide string manipulation routines: given a set of separators, split
16404 a wide string wherever the separators appear, and provide direct access
16405 to the resulting slices. This package is instantiated from
16406 @code{GNAT.Array_Split}.
16408 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
16409 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16410 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16411 @cindex Spell checking
16414 Provides a function for determining whether one wide wide string is a plausible
16415 near misspelling of another wide wide string.
16417 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
16418 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16419 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16420 @cindex Wide_Wide_String splitter
16423 Useful wide wide string manipulation routines: given a set of separators, split
16424 a wide wide string wherever the separators appear, and provide direct access
16425 to the resulting slices. This package is instantiated from
16426 @code{GNAT.Array_Split}.
16428 @node Interfaces.C.Extensions (i-cexten.ads)
16429 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16430 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16433 This package contains additional C-related definitions, intended
16434 for use with either manually or automatically generated bindings
16437 @node Interfaces.C.Streams (i-cstrea.ads)
16438 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16439 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16440 @cindex C streams, interfacing
16443 This package is a binding for the most commonly used operations
16446 @node Interfaces.CPP (i-cpp.ads)
16447 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
16448 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
16449 @cindex C++ interfacing
16450 @cindex Interfacing, to C++
16453 This package provides facilities for use in interfacing to C++. It
16454 is primarily intended to be used in connection with automated tools
16455 for the generation of C++ interfaces.
16457 @node Interfaces.Packed_Decimal (i-pacdec.ads)
16458 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16459 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16460 @cindex IBM Packed Format
16461 @cindex Packed Decimal
16464 This package provides a set of routines for conversions to and
16465 from a packed decimal format compatible with that used on IBM
16468 @node Interfaces.VxWorks (i-vxwork.ads)
16469 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16470 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16471 @cindex Interfacing to VxWorks
16472 @cindex VxWorks, interfacing
16475 This package provides a limited binding to the VxWorks API.
16476 In particular, it interfaces with the
16477 VxWorks hardware interrupt facilities.
16479 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
16480 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16481 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16482 @cindex Interfacing to VxWorks' I/O
16483 @cindex VxWorks, I/O interfacing
16484 @cindex VxWorks, Get_Immediate
16485 @cindex Get_Immediate, VxWorks
16488 This package provides a binding to the ioctl (IO/Control)
16489 function of VxWorks, defining a set of option values and
16490 function codes. A particular use of this package is
16491 to enable the use of Get_Immediate under VxWorks.
16493 @node System.Address_Image (s-addima.ads)
16494 @section @code{System.Address_Image} (@file{s-addima.ads})
16495 @cindex @code{System.Address_Image} (@file{s-addima.ads})
16496 @cindex Address image
16497 @cindex Image, of an address
16500 This function provides a useful debugging
16501 function that gives an (implementation dependent)
16502 string which identifies an address.
16504 @node System.Assertions (s-assert.ads)
16505 @section @code{System.Assertions} (@file{s-assert.ads})
16506 @cindex @code{System.Assertions} (@file{s-assert.ads})
16508 @cindex Assert_Failure, exception
16511 This package provides the declaration of the exception raised
16512 by an run-time assertion failure, as well as the routine that
16513 is used internally to raise this assertion.
16515 @node System.Memory (s-memory.ads)
16516 @section @code{System.Memory} (@file{s-memory.ads})
16517 @cindex @code{System.Memory} (@file{s-memory.ads})
16518 @cindex Memory allocation
16521 This package provides the interface to the low level routines used
16522 by the generated code for allocation and freeing storage for the
16523 default storage pool (analogous to the C routines malloc and free.
16524 It also provides a reallocation interface analogous to the C routine
16525 realloc. The body of this unit may be modified to provide alternative
16526 allocation mechanisms for the default pool, and in addition, direct
16527 calls to this unit may be made for low level allocation uses (for
16528 example see the body of @code{GNAT.Tables}).
16530 @node System.Partition_Interface (s-parint.ads)
16531 @section @code{System.Partition_Interface} (@file{s-parint.ads})
16532 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
16533 @cindex Partition interfacing functions
16536 This package provides facilities for partition interfacing. It
16537 is used primarily in a distribution context when using Annex E
16540 @node System.Pool_Global (s-pooglo.ads)
16541 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
16542 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
16543 @cindex Storage pool, global
16544 @cindex Global storage pool
16547 This package provides a storage pool that is equivalent to the default
16548 storage pool used for access types for which no pool is specifically
16549 declared. It uses malloc/free to allocate/free and does not attempt to
16550 do any automatic reclamation.
16552 @node System.Pool_Local (s-pooloc.ads)
16553 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
16554 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
16555 @cindex Storage pool, local
16556 @cindex Local storage pool
16559 This package provides a storage pool that is intended for use with locally
16560 defined access types. It uses malloc/free for allocate/free, and maintains
16561 a list of allocated blocks, so that all storage allocated for the pool can
16562 be freed automatically when the pool is finalized.
16564 @node System.Restrictions (s-restri.ads)
16565 @section @code{System.Restrictions} (@file{s-restri.ads})
16566 @cindex @code{System.Restrictions} (@file{s-restri.ads})
16567 @cindex Run-time restrictions access
16570 This package provides facilities for accessing at run time
16571 the status of restrictions specified at compile time for
16572 the partition. Information is available both with regard
16573 to actual restrictions specified, and with regard to
16574 compiler determined information on which restrictions
16575 are violated by one or more packages in the partition.
16577 @node System.Rident (s-rident.ads)
16578 @section @code{System.Rident} (@file{s-rident.ads})
16579 @cindex @code{System.Rident} (@file{s-rident.ads})
16580 @cindex Restrictions definitions
16583 This package provides definitions of the restrictions
16584 identifiers supported by GNAT, and also the format of
16585 the restrictions provided in package System.Restrictions.
16586 It is not normally necessary to @code{with} this generic package
16587 since the necessary instantiation is included in
16588 package System.Restrictions.
16590 @node System.Strings.Stream_Ops (s-ststop.ads)
16591 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16592 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16593 @cindex Stream operations
16594 @cindex String stream operations
16597 This package provides a set of stream subprograms for standard string types.
16598 It is intended primarily to support implicit use of such subprograms when
16599 stream attributes are applied to string types, but the subprograms in this
16600 package can be used directly by application programs.
16602 @node System.Task_Info (s-tasinf.ads)
16603 @section @code{System.Task_Info} (@file{s-tasinf.ads})
16604 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
16605 @cindex Task_Info pragma
16608 This package provides target dependent functionality that is used
16609 to support the @code{Task_Info} pragma
16611 @node System.Wch_Cnv (s-wchcnv.ads)
16612 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16613 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16614 @cindex Wide Character, Representation
16615 @cindex Wide String, Conversion
16616 @cindex Representation of wide characters
16619 This package provides routines for converting between
16620 wide and wide wide characters and a representation as a value of type
16621 @code{Standard.String}, using a specified wide character
16622 encoding method. It uses definitions in
16623 package @code{System.Wch_Con}.
16625 @node System.Wch_Con (s-wchcon.ads)
16626 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
16627 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
16630 This package provides definitions and descriptions of
16631 the various methods used for encoding wide characters
16632 in ordinary strings. These definitions are used by
16633 the package @code{System.Wch_Cnv}.
16635 @node Interfacing to Other Languages
16636 @chapter Interfacing to Other Languages
16638 The facilities in annex B of the Ada Reference Manual are fully
16639 implemented in GNAT, and in addition, a full interface to C++ is
16643 * Interfacing to C::
16644 * Interfacing to C++::
16645 * Interfacing to COBOL::
16646 * Interfacing to Fortran::
16647 * Interfacing to non-GNAT Ada code::
16650 @node Interfacing to C
16651 @section Interfacing to C
16654 Interfacing to C with GNAT can use one of two approaches:
16658 The types in the package @code{Interfaces.C} may be used.
16660 Standard Ada types may be used directly. This may be less portable to
16661 other compilers, but will work on all GNAT compilers, which guarantee
16662 correspondence between the C and Ada types.
16666 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
16667 effect, since this is the default. The following table shows the
16668 correspondence between Ada scalar types and the corresponding C types.
16673 @item Short_Integer
16675 @item Short_Short_Integer
16679 @item Long_Long_Integer
16687 @item Long_Long_Float
16688 This is the longest floating-point type supported by the hardware.
16692 Additionally, there are the following general correspondences between Ada
16696 Ada enumeration types map to C enumeration types directly if pragma
16697 @code{Convention C} is specified, which causes them to have int
16698 length. Without pragma @code{Convention C}, Ada enumeration types map to
16699 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
16700 @code{int}, respectively) depending on the number of values passed.
16701 This is the only case in which pragma @code{Convention C} affects the
16702 representation of an Ada type.
16705 Ada access types map to C pointers, except for the case of pointers to
16706 unconstrained types in Ada, which have no direct C equivalent.
16709 Ada arrays map directly to C arrays.
16712 Ada records map directly to C structures.
16715 Packed Ada records map to C structures where all members are bit fields
16716 of the length corresponding to the @code{@var{type}'Size} value in Ada.
16719 @node Interfacing to C++
16720 @section Interfacing to C++
16723 The interface to C++ makes use of the following pragmas, which are
16724 primarily intended to be constructed automatically using a binding generator
16725 tool, although it is possible to construct them by hand.
16727 Using these pragmas it is possible to achieve complete
16728 inter-operability between Ada tagged types and C++ class definitions.
16729 See @ref{Implementation Defined Pragmas}, for more details.
16732 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
16733 The argument denotes an entity in the current declarative region that is
16734 declared as a tagged or untagged record type. It indicates that the type
16735 corresponds to an externally declared C++ class type, and is to be laid
16736 out the same way that C++ would lay out the type.
16738 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
16739 for backward compatibility but its functionality is available
16740 using pragma @code{Import} with @code{Convention} = @code{CPP}.
16742 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
16743 This pragma identifies an imported function (imported in the usual way
16744 with pragma @code{Import}) as corresponding to a C++ constructor.
16747 In addition, C++ exceptions are propagated and can be handled in an
16748 @code{others} choice of an exception handler. The corresponding Ada
16749 occurrence has no message, and the simple name of the exception identity
16750 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
16751 tasks works properly when such foreign exceptions are propagated.
16753 @node Interfacing to COBOL
16754 @section Interfacing to COBOL
16757 Interfacing to COBOL is achieved as described in section B.4 of
16758 the Ada Reference Manual.
16760 @node Interfacing to Fortran
16761 @section Interfacing to Fortran
16764 Interfacing to Fortran is achieved as described in section B.5 of the
16765 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
16766 multi-dimensional array causes the array to be stored in column-major
16767 order as required for convenient interface to Fortran.
16769 @node Interfacing to non-GNAT Ada code
16770 @section Interfacing to non-GNAT Ada code
16772 It is possible to specify the convention @code{Ada} in a pragma
16773 @code{Import} or pragma @code{Export}. However this refers to
16774 the calling conventions used by GNAT, which may or may not be
16775 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
16776 compiler to allow interoperation.
16778 If arguments types are kept simple, and if the foreign compiler generally
16779 follows system calling conventions, then it may be possible to integrate
16780 files compiled by other Ada compilers, provided that the elaboration
16781 issues are adequately addressed (for example by eliminating the
16782 need for any load time elaboration).
16784 In particular, GNAT running on VMS is designed to
16785 be highly compatible with the DEC Ada 83 compiler, so this is one
16786 case in which it is possible to import foreign units of this type,
16787 provided that the data items passed are restricted to simple scalar
16788 values or simple record types without variants, or simple array
16789 types with fixed bounds.
16791 @node Specialized Needs Annexes
16792 @chapter Specialized Needs Annexes
16795 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
16796 required in all implementations. However, as described in this chapter,
16797 GNAT implements all of these annexes:
16800 @item Systems Programming (Annex C)
16801 The Systems Programming Annex is fully implemented.
16803 @item Real-Time Systems (Annex D)
16804 The Real-Time Systems Annex is fully implemented.
16806 @item Distributed Systems (Annex E)
16807 Stub generation is fully implemented in the GNAT compiler. In addition,
16808 a complete compatible PCS is available as part of the GLADE system,
16809 a separate product. When the two
16810 products are used in conjunction, this annex is fully implemented.
16812 @item Information Systems (Annex F)
16813 The Information Systems annex is fully implemented.
16815 @item Numerics (Annex G)
16816 The Numerics Annex is fully implemented.
16818 @item Safety and Security / High-Integrity Systems (Annex H)
16819 The Safety and Security Annex (termed the High-Integrity Systems Annex
16820 in Ada 2005) is fully implemented.
16823 @node Implementation of Specific Ada Features
16824 @chapter Implementation of Specific Ada Features
16827 This chapter describes the GNAT implementation of several Ada language
16831 * Machine Code Insertions::
16832 * GNAT Implementation of Tasking::
16833 * GNAT Implementation of Shared Passive Packages::
16834 * Code Generation for Array Aggregates::
16835 * The Size of Discriminated Records with Default Discriminants::
16836 * Strict Conformance to the Ada Reference Manual::
16839 @node Machine Code Insertions
16840 @section Machine Code Insertions
16841 @cindex Machine Code insertions
16844 Package @code{Machine_Code} provides machine code support as described
16845 in the Ada Reference Manual in two separate forms:
16848 Machine code statements, consisting of qualified expressions that
16849 fit the requirements of RM section 13.8.
16851 An intrinsic callable procedure, providing an alternative mechanism of
16852 including machine instructions in a subprogram.
16856 The two features are similar, and both are closely related to the mechanism
16857 provided by the asm instruction in the GNU C compiler. Full understanding
16858 and use of the facilities in this package requires understanding the asm
16859 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
16860 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
16862 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
16863 semantic restrictions and effects as described below. Both are provided so
16864 that the procedure call can be used as a statement, and the function call
16865 can be used to form a code_statement.
16867 The first example given in the GCC documentation is the C @code{asm}
16870 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
16874 The equivalent can be written for GNAT as:
16876 @smallexample @c ada
16877 Asm ("fsinx %1 %0",
16878 My_Float'Asm_Output ("=f", result),
16879 My_Float'Asm_Input ("f", angle));
16883 The first argument to @code{Asm} is the assembler template, and is
16884 identical to what is used in GNU C@. This string must be a static
16885 expression. The second argument is the output operand list. It is
16886 either a single @code{Asm_Output} attribute reference, or a list of such
16887 references enclosed in parentheses (technically an array aggregate of
16890 The @code{Asm_Output} attribute denotes a function that takes two
16891 parameters. The first is a string, the second is the name of a variable
16892 of the type designated by the attribute prefix. The first (string)
16893 argument is required to be a static expression and designates the
16894 constraint for the parameter (e.g.@: what kind of register is
16895 required). The second argument is the variable to be updated with the
16896 result. The possible values for constraint are the same as those used in
16897 the RTL, and are dependent on the configuration file used to build the
16898 GCC back end. If there are no output operands, then this argument may
16899 either be omitted, or explicitly given as @code{No_Output_Operands}.
16901 The second argument of @code{@var{my_float}'Asm_Output} functions as
16902 though it were an @code{out} parameter, which is a little curious, but
16903 all names have the form of expressions, so there is no syntactic
16904 irregularity, even though normally functions would not be permitted
16905 @code{out} parameters. The third argument is the list of input
16906 operands. It is either a single @code{Asm_Input} attribute reference, or
16907 a list of such references enclosed in parentheses (technically an array
16908 aggregate of such references).
16910 The @code{Asm_Input} attribute denotes a function that takes two
16911 parameters. The first is a string, the second is an expression of the
16912 type designated by the prefix. The first (string) argument is required
16913 to be a static expression, and is the constraint for the parameter,
16914 (e.g.@: what kind of register is required). The second argument is the
16915 value to be used as the input argument. The possible values for the
16916 constant are the same as those used in the RTL, and are dependent on
16917 the configuration file used to built the GCC back end.
16919 If there are no input operands, this argument may either be omitted, or
16920 explicitly given as @code{No_Input_Operands}. The fourth argument, not
16921 present in the above example, is a list of register names, called the
16922 @dfn{clobber} argument. This argument, if given, must be a static string
16923 expression, and is a space or comma separated list of names of registers
16924 that must be considered destroyed as a result of the @code{Asm} call. If
16925 this argument is the null string (the default value), then the code
16926 generator assumes that no additional registers are destroyed.
16928 The fifth argument, not present in the above example, called the
16929 @dfn{volatile} argument, is by default @code{False}. It can be set to
16930 the literal value @code{True} to indicate to the code generator that all
16931 optimizations with respect to the instruction specified should be
16932 suppressed, and that in particular, for an instruction that has outputs,
16933 the instruction will still be generated, even if none of the outputs are
16934 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
16935 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
16936 Generally it is strongly advisable to use Volatile for any ASM statement
16937 that is missing either input or output operands, or when two or more ASM
16938 statements appear in sequence, to avoid unwanted optimizations. A warning
16939 is generated if this advice is not followed.
16941 The @code{Asm} subprograms may be used in two ways. First the procedure
16942 forms can be used anywhere a procedure call would be valid, and
16943 correspond to what the RM calls ``intrinsic'' routines. Such calls can
16944 be used to intersperse machine instructions with other Ada statements.
16945 Second, the function forms, which return a dummy value of the limited
16946 private type @code{Asm_Insn}, can be used in code statements, and indeed
16947 this is the only context where such calls are allowed. Code statements
16948 appear as aggregates of the form:
16950 @smallexample @c ada
16951 Asm_Insn'(Asm (@dots{}));
16952 Asm_Insn'(Asm_Volatile (@dots{}));
16956 In accordance with RM rules, such code statements are allowed only
16957 within subprograms whose entire body consists of such statements. It is
16958 not permissible to intermix such statements with other Ada statements.
16960 Typically the form using intrinsic procedure calls is more convenient
16961 and more flexible. The code statement form is provided to meet the RM
16962 suggestion that such a facility should be made available. The following
16963 is the exact syntax of the call to @code{Asm}. As usual, if named notation
16964 is used, the arguments may be given in arbitrary order, following the
16965 normal rules for use of positional and named arguments)
16969 [Template =>] static_string_EXPRESSION
16970 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
16971 [,[Inputs =>] INPUT_OPERAND_LIST ]
16972 [,[Clobber =>] static_string_EXPRESSION ]
16973 [,[Volatile =>] static_boolean_EXPRESSION] )
16975 OUTPUT_OPERAND_LIST ::=
16976 [PREFIX.]No_Output_Operands
16977 | OUTPUT_OPERAND_ATTRIBUTE
16978 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
16980 OUTPUT_OPERAND_ATTRIBUTE ::=
16981 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
16983 INPUT_OPERAND_LIST ::=
16984 [PREFIX.]No_Input_Operands
16985 | INPUT_OPERAND_ATTRIBUTE
16986 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
16988 INPUT_OPERAND_ATTRIBUTE ::=
16989 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
16993 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
16994 are declared in the package @code{Machine_Code} and must be referenced
16995 according to normal visibility rules. In particular if there is no
16996 @code{use} clause for this package, then appropriate package name
16997 qualification is required.
16999 @node GNAT Implementation of Tasking
17000 @section GNAT Implementation of Tasking
17003 This chapter outlines the basic GNAT approach to tasking (in particular,
17004 a multi-layered library for portability) and discusses issues related
17005 to compliance with the Real-Time Systems Annex.
17008 * Mapping Ada Tasks onto the Underlying Kernel Threads::
17009 * Ensuring Compliance with the Real-Time Annex::
17012 @node Mapping Ada Tasks onto the Underlying Kernel Threads
17013 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
17016 GNAT's run-time support comprises two layers:
17019 @item GNARL (GNAT Run-time Layer)
17020 @item GNULL (GNAT Low-level Library)
17024 In GNAT, Ada's tasking services rely on a platform and OS independent
17025 layer known as GNARL@. This code is responsible for implementing the
17026 correct semantics of Ada's task creation, rendezvous, protected
17029 GNARL decomposes Ada's tasking semantics into simpler lower level
17030 operations such as create a thread, set the priority of a thread,
17031 yield, create a lock, lock/unlock, etc. The spec for these low-level
17032 operations constitutes GNULLI, the GNULL Interface. This interface is
17033 directly inspired from the POSIX real-time API@.
17035 If the underlying executive or OS implements the POSIX standard
17036 faithfully, the GNULL Interface maps as is to the services offered by
17037 the underlying kernel. Otherwise, some target dependent glue code maps
17038 the services offered by the underlying kernel to the semantics expected
17041 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
17042 key point is that each Ada task is mapped on a thread in the underlying
17043 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
17045 In addition Ada task priorities map onto the underlying thread priorities.
17046 Mapping Ada tasks onto the underlying kernel threads has several advantages:
17050 The underlying scheduler is used to schedule the Ada tasks. This
17051 makes Ada tasks as efficient as kernel threads from a scheduling
17055 Interaction with code written in C containing threads is eased
17056 since at the lowest level Ada tasks and C threads map onto the same
17057 underlying kernel concept.
17060 When an Ada task is blocked during I/O the remaining Ada tasks are
17064 On multiprocessor systems Ada tasks can execute in parallel.
17068 Some threads libraries offer a mechanism to fork a new process, with the
17069 child process duplicating the threads from the parent.
17071 support this functionality when the parent contains more than one task.
17072 @cindex Forking a new process
17074 @node Ensuring Compliance with the Real-Time Annex
17075 @subsection Ensuring Compliance with the Real-Time Annex
17076 @cindex Real-Time Systems Annex compliance
17079 Although mapping Ada tasks onto
17080 the underlying threads has significant advantages, it does create some
17081 complications when it comes to respecting the scheduling semantics
17082 specified in the real-time annex (Annex D).
17084 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
17085 scheduling policy states:
17088 @emph{When the active priority of a ready task that is not running
17089 changes, or the setting of its base priority takes effect, the
17090 task is removed from the ready queue for its old active priority
17091 and is added at the tail of the ready queue for its new active
17092 priority, except in the case where the active priority is lowered
17093 due to the loss of inherited priority, in which case the task is
17094 added at the head of the ready queue for its new active priority.}
17098 While most kernels do put tasks at the end of the priority queue when
17099 a task changes its priority, (which respects the main
17100 FIFO_Within_Priorities requirement), almost none keep a thread at the
17101 beginning of its priority queue when its priority drops from the loss
17102 of inherited priority.
17104 As a result most vendors have provided incomplete Annex D implementations.
17106 The GNAT run-time, has a nice cooperative solution to this problem
17107 which ensures that accurate FIFO_Within_Priorities semantics are
17110 The principle is as follows. When an Ada task T is about to start
17111 running, it checks whether some other Ada task R with the same
17112 priority as T has been suspended due to the loss of priority
17113 inheritance. If this is the case, T yields and is placed at the end of
17114 its priority queue. When R arrives at the front of the queue it
17117 Note that this simple scheme preserves the relative order of the tasks
17118 that were ready to execute in the priority queue where R has been
17121 @node GNAT Implementation of Shared Passive Packages
17122 @section GNAT Implementation of Shared Passive Packages
17123 @cindex Shared passive packages
17126 GNAT fully implements the pragma @code{Shared_Passive} for
17127 @cindex pragma @code{Shared_Passive}
17128 the purpose of designating shared passive packages.
17129 This allows the use of passive partitions in the
17130 context described in the Ada Reference Manual; i.e., for communication
17131 between separate partitions of a distributed application using the
17132 features in Annex E.
17134 @cindex Distribution Systems Annex
17136 However, the implementation approach used by GNAT provides for more
17137 extensive usage as follows:
17140 @item Communication between separate programs
17142 This allows separate programs to access the data in passive
17143 partitions, using protected objects for synchronization where
17144 needed. The only requirement is that the two programs have a
17145 common shared file system. It is even possible for programs
17146 running on different machines with different architectures
17147 (e.g.@: different endianness) to communicate via the data in
17148 a passive partition.
17150 @item Persistence between program runs
17152 The data in a passive package can persist from one run of a
17153 program to another, so that a later program sees the final
17154 values stored by a previous run of the same program.
17159 The implementation approach used is to store the data in files. A
17160 separate stream file is created for each object in the package, and
17161 an access to an object causes the corresponding file to be read or
17164 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
17165 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
17166 set to the directory to be used for these files.
17167 The files in this directory
17168 have names that correspond to their fully qualified names. For
17169 example, if we have the package
17171 @smallexample @c ada
17173 pragma Shared_Passive (X);
17180 and the environment variable is set to @code{/stemp/}, then the files created
17181 will have the names:
17189 These files are created when a value is initially written to the object, and
17190 the files are retained until manually deleted. This provides the persistence
17191 semantics. If no file exists, it means that no partition has assigned a value
17192 to the variable; in this case the initial value declared in the package
17193 will be used. This model ensures that there are no issues in synchronizing
17194 the elaboration process, since elaboration of passive packages elaborates the
17195 initial values, but does not create the files.
17197 The files are written using normal @code{Stream_IO} access.
17198 If you want to be able
17199 to communicate between programs or partitions running on different
17200 architectures, then you should use the XDR versions of the stream attribute
17201 routines, since these are architecture independent.
17203 If active synchronization is required for access to the variables in the
17204 shared passive package, then as described in the Ada Reference Manual, the
17205 package may contain protected objects used for this purpose. In this case
17206 a lock file (whose name is @file{___lock} (three underscores)
17207 is created in the shared memory directory.
17208 @cindex @file{___lock} file (for shared passive packages)
17209 This is used to provide the required locking
17210 semantics for proper protected object synchronization.
17212 As of January 2003, GNAT supports shared passive packages on all platforms
17213 except for OpenVMS.
17215 @node Code Generation for Array Aggregates
17216 @section Code Generation for Array Aggregates
17219 * Static constant aggregates with static bounds::
17220 * Constant aggregates with unconstrained nominal types::
17221 * Aggregates with static bounds::
17222 * Aggregates with non-static bounds::
17223 * Aggregates in assignment statements::
17227 Aggregates have a rich syntax and allow the user to specify the values of
17228 complex data structures by means of a single construct. As a result, the
17229 code generated for aggregates can be quite complex and involve loops, case
17230 statements and multiple assignments. In the simplest cases, however, the
17231 compiler will recognize aggregates whose components and constraints are
17232 fully static, and in those cases the compiler will generate little or no
17233 executable code. The following is an outline of the code that GNAT generates
17234 for various aggregate constructs. For further details, you will find it
17235 useful to examine the output produced by the -gnatG flag to see the expanded
17236 source that is input to the code generator. You may also want to examine
17237 the assembly code generated at various levels of optimization.
17239 The code generated for aggregates depends on the context, the component values,
17240 and the type. In the context of an object declaration the code generated is
17241 generally simpler than in the case of an assignment. As a general rule, static
17242 component values and static subtypes also lead to simpler code.
17244 @node Static constant aggregates with static bounds
17245 @subsection Static constant aggregates with static bounds
17248 For the declarations:
17249 @smallexample @c ada
17250 type One_Dim is array (1..10) of integer;
17251 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
17255 GNAT generates no executable code: the constant ar0 is placed in static memory.
17256 The same is true for constant aggregates with named associations:
17258 @smallexample @c ada
17259 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
17260 Cr3 : constant One_Dim := (others => 7777);
17264 The same is true for multidimensional constant arrays such as:
17266 @smallexample @c ada
17267 type two_dim is array (1..3, 1..3) of integer;
17268 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
17272 The same is true for arrays of one-dimensional arrays: the following are
17275 @smallexample @c ada
17276 type ar1b is array (1..3) of boolean;
17277 type ar_ar is array (1..3) of ar1b;
17278 None : constant ar1b := (others => false); -- fully static
17279 None2 : constant ar_ar := (1..3 => None); -- fully static
17283 However, for multidimensional aggregates with named associations, GNAT will
17284 generate assignments and loops, even if all associations are static. The
17285 following two declarations generate a loop for the first dimension, and
17286 individual component assignments for the second dimension:
17288 @smallexample @c ada
17289 Zero1: constant two_dim := (1..3 => (1..3 => 0));
17290 Zero2: constant two_dim := (others => (others => 0));
17293 @node Constant aggregates with unconstrained nominal types
17294 @subsection Constant aggregates with unconstrained nominal types
17297 In such cases the aggregate itself establishes the subtype, so that
17298 associations with @code{others} cannot be used. GNAT determines the
17299 bounds for the actual subtype of the aggregate, and allocates the
17300 aggregate statically as well. No code is generated for the following:
17302 @smallexample @c ada
17303 type One_Unc is array (natural range <>) of integer;
17304 Cr_Unc : constant One_Unc := (12,24,36);
17307 @node Aggregates with static bounds
17308 @subsection Aggregates with static bounds
17311 In all previous examples the aggregate was the initial (and immutable) value
17312 of a constant. If the aggregate initializes a variable, then code is generated
17313 for it as a combination of individual assignments and loops over the target
17314 object. The declarations
17316 @smallexample @c ada
17317 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
17318 Cr_Var2 : One_Dim := (others > -1);
17322 generate the equivalent of
17324 @smallexample @c ada
17330 for I in Cr_Var2'range loop
17335 @node Aggregates with non-static bounds
17336 @subsection Aggregates with non-static bounds
17339 If the bounds of the aggregate are not statically compatible with the bounds
17340 of the nominal subtype of the target, then constraint checks have to be
17341 generated on the bounds. For a multidimensional array, constraint checks may
17342 have to be applied to sub-arrays individually, if they do not have statically
17343 compatible subtypes.
17345 @node Aggregates in assignment statements
17346 @subsection Aggregates in assignment statements
17349 In general, aggregate assignment requires the construction of a temporary,
17350 and a copy from the temporary to the target of the assignment. This is because
17351 it is not always possible to convert the assignment into a series of individual
17352 component assignments. For example, consider the simple case:
17354 @smallexample @c ada
17359 This cannot be converted into:
17361 @smallexample @c ada
17367 So the aggregate has to be built first in a separate location, and then
17368 copied into the target. GNAT recognizes simple cases where this intermediate
17369 step is not required, and the assignments can be performed in place, directly
17370 into the target. The following sufficient criteria are applied:
17374 The bounds of the aggregate are static, and the associations are static.
17376 The components of the aggregate are static constants, names of
17377 simple variables that are not renamings, or expressions not involving
17378 indexed components whose operands obey these rules.
17382 If any of these conditions are violated, the aggregate will be built in
17383 a temporary (created either by the front-end or the code generator) and then
17384 that temporary will be copied onto the target.
17386 @node The Size of Discriminated Records with Default Discriminants
17387 @section The Size of Discriminated Records with Default Discriminants
17390 If a discriminated type @code{T} has discriminants with default values, it is
17391 possible to declare an object of this type without providing an explicit
17394 @smallexample @c ada
17396 type Size is range 1..100;
17398 type Rec (D : Size := 15) is record
17399 Name : String (1..D);
17407 Such an object is said to be @emph{unconstrained}.
17408 The discriminant of the object
17409 can be modified by a full assignment to the object, as long as it preserves the
17410 relation between the value of the discriminant, and the value of the components
17413 @smallexample @c ada
17415 Word := (3, "yes");
17417 Word := (5, "maybe");
17419 Word := (5, "no"); -- raises Constraint_Error
17424 In order to support this behavior efficiently, an unconstrained object is
17425 given the maximum size that any value of the type requires. In the case
17426 above, @code{Word} has storage for the discriminant and for
17427 a @code{String} of length 100.
17428 It is important to note that unconstrained objects do not require dynamic
17429 allocation. It would be an improper implementation to place on the heap those
17430 components whose size depends on discriminants. (This improper implementation
17431 was used by some Ada83 compilers, where the @code{Name} component above
17433 been stored as a pointer to a dynamic string). Following the principle that
17434 dynamic storage management should never be introduced implicitly,
17435 an Ada compiler should reserve the full size for an unconstrained declared
17436 object, and place it on the stack.
17438 This maximum size approach
17439 has been a source of surprise to some users, who expect the default
17440 values of the discriminants to determine the size reserved for an
17441 unconstrained object: ``If the default is 15, why should the object occupy
17443 The answer, of course, is that the discriminant may be later modified,
17444 and its full range of values must be taken into account. This is why the
17449 type Rec (D : Positive := 15) is record
17450 Name : String (1..D);
17458 is flagged by the compiler with a warning:
17459 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
17460 because the required size includes @code{Positive'Last}
17461 bytes. As the first example indicates, the proper approach is to declare an
17462 index type of ``reasonable'' range so that unconstrained objects are not too
17465 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
17466 created in the heap by means of an allocator, then it is @emph{not}
17468 it is constrained by the default values of the discriminants, and those values
17469 cannot be modified by full assignment. This is because in the presence of
17470 aliasing all views of the object (which may be manipulated by different tasks,
17471 say) must be consistent, so it is imperative that the object, once created,
17474 @node Strict Conformance to the Ada Reference Manual
17475 @section Strict Conformance to the Ada Reference Manual
17478 The dynamic semantics defined by the Ada Reference Manual impose a set of
17479 run-time checks to be generated. By default, the GNAT compiler will insert many
17480 run-time checks into the compiled code, including most of those required by the
17481 Ada Reference Manual. However, there are three checks that are not enabled
17482 in the default mode for efficiency reasons: arithmetic overflow checking for
17483 integer operations (including division by zero), checks for access before
17484 elaboration on subprogram calls, and stack overflow checking (most operating
17485 systems do not perform this check by default).
17487 Strict conformance to the Ada Reference Manual can be achieved by adding
17488 three compiler options for overflow checking for integer operations
17489 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
17490 calls and generic instantiations (@option{-gnatE}), and stack overflow
17491 checking (@option{-fstack-check}).
17493 Note that the result of a floating point arithmetic operation in overflow and
17494 invalid situations, when the @code{Machine_Overflows} attribute of the result
17495 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
17496 case for machines compliant with the IEEE floating-point standard, but on
17497 machines that are not fully compliant with this standard, such as Alpha, the
17498 @option{-mieee} compiler flag must be used for achieving IEEE confirming
17499 behavior (although at the cost of a significant performance penalty), so
17500 infinite and NaN values are properly generated.
17503 @node Implementation of Ada 2012 Features
17504 @chapter Implementation of Ada 2012 Features
17505 @cindex Ada 2012 implementation status
17507 This chapter contains a complete list of Ada 2012 features that have been
17508 implemented as of GNAT version 6.4. Generally, these features are only
17509 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
17510 @cindex @option{-gnat12} option
17511 or if the configuration pragma @code{Ada_2012} is used.
17512 @cindex pragma @code{Ada_2012}
17513 @cindex configuration pragma @code{Ada_2012}
17514 @cindex @code{Ada_2012} configuration pragma
17515 However, new pragmas, attributes, and restrictions are
17516 unconditionally available, since the Ada 95 standard allows the addition of
17517 new pragmas, attributes, and restrictions (there are exceptions, which are
17518 documented in the individual descriptions), and also certain packages
17519 were made available in earlier versions of Ada.
17521 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
17522 This date shows the implementation date of the feature. Any wavefront
17523 subsequent to this date will contain the indicated feature, as will any
17524 subsequent releases. A date of 0000-00-00 means that GNAT has always
17525 implemented the feature, or implemented it as soon as it appeared as a
17526 binding interpretation.
17528 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
17529 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
17530 The features are ordered based on the relevant sections of the Ada
17531 Reference Manual (``RM''). When a given AI relates to multiple points
17532 in the RM, the earliest is used.
17534 A complete description of the AIs may be found in
17535 @url{www.ada-auth.org/ai05-summary.html}.
17540 @emph{AI-0176 Quantified expressions (2010-09-29)}
17541 @cindex AI-0176 (Ada 2012 feature)
17544 Both universally and existentially quantified expressions are implemented.
17545 They use the new syntax for iterators proposed in AI05-139-2, as well as
17546 the standard Ada loop syntax.
17549 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
17552 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
17553 @cindex AI-0079 (Ada 2012 feature)
17556 Wide characters in the unicode category @i{other_format} are now allowed in
17557 source programs between tokens, but not within a token such as an identifier.
17560 RM References: 2.01 (4/2) 2.02 (7)
17563 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
17564 @cindex AI-0091 (Ada 2012 feature)
17567 Wide characters in the unicode category @i{other_format} are not permitted
17568 within an identifier, since this can be a security problem. The error
17569 message for this case has been improved to be more specific, but GNAT has
17570 never allowed such characters to appear in identifiers.
17573 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)
17576 @emph{AI-0100 Placement of pragmas (2010-07-01)}
17577 @cindex AI-0100 (Ada 2012 feature)
17580 This AI is an earlier version of AI-163. It simplifies the rules
17581 for legal placement of pragmas. In the case of lists that allow pragmas, if
17582 the list may have no elements, then the list may consist solely of pragmas.
17585 RM References: 2.08 (7)
17588 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
17589 @cindex AI-0163 (Ada 2012 feature)
17592 A statement sequence may be composed entirely of pragmas. It is no longer
17593 necessary to add a dummy @code{null} statement to make the sequence legal.
17596 RM References: 2.08 (7) 2.08 (16)
17600 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
17601 @cindex AI-0080 (Ada 2012 feature)
17604 This is an editorial change only, described as non-testable in the AI.
17607 RM References: 3.01 (7)
17611 @emph{AI-0183 Aspect specifications (2010-08-16)}
17612 @cindex AI-0183 (Ada 2012 feature)
17615 Aspect specifications have been fully implemented except for pre and post-
17616 conditions, and type invariants, which have their own separate AI's. All
17617 forms of declarations listed in the AI are supported. The following is a
17618 list of the aspects supported (with GNAT implementation aspects marked)
17620 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
17621 @item @code{Ada_2005} @tab -- GNAT
17622 @item @code{Ada_2012} @tab -- GNAT
17623 @item @code{Address} @tab
17624 @item @code{Alignment} @tab
17625 @item @code{Atomic} @tab
17626 @item @code{Atomic_Components} @tab
17627 @item @code{Bit_Order} @tab
17628 @item @code{Component_Size} @tab
17629 @item @code{Contract_Case} @tab -- GNAT
17630 @item @code{Discard_Names} @tab
17631 @item @code{External_Tag} @tab
17632 @item @code{Favor_Top_Level} @tab -- GNAT
17633 @item @code{Inline} @tab
17634 @item @code{Inline_Always} @tab -- GNAT
17635 @item @code{Invariant} @tab -- GNAT
17636 @item @code{Machine_Radix} @tab
17637 @item @code{No_Return} @tab
17638 @item @code{Object_Size} @tab -- GNAT
17639 @item @code{Pack} @tab
17640 @item @code{Persistent_BSS} @tab -- GNAT
17641 @item @code{Post} @tab
17642 @item @code{Pre} @tab
17643 @item @code{Predicate} @tab
17644 @item @code{Preelaborable_Initialization} @tab
17645 @item @code{Pure_Function} @tab -- GNAT
17646 @item @code{Remote_Access_Type} @tab -- GNAT
17647 @item @code{Shared} @tab -- GNAT
17648 @item @code{Size} @tab
17649 @item @code{Storage_Pool} @tab
17650 @item @code{Storage_Size} @tab
17651 @item @code{Stream_Size} @tab
17652 @item @code{Suppress} @tab
17653 @item @code{Suppress_Debug_Info} @tab -- GNAT
17654 @item @code{Test_Case} @tab -- GNAT
17655 @item @code{Type_Invariant} @tab
17656 @item @code{Unchecked_Union} @tab
17657 @item @code{Universal_Aliasing} @tab -- GNAT
17658 @item @code{Unmodified} @tab -- GNAT
17659 @item @code{Unreferenced} @tab -- GNAT
17660 @item @code{Unreferenced_Objects} @tab -- GNAT
17661 @item @code{Unsuppress} @tab
17662 @item @code{Value_Size} @tab -- GNAT
17663 @item @code{Volatile} @tab
17664 @item @code{Volatile_Components}
17665 @item @code{Warnings} @tab -- GNAT
17669 Note that for aspects with an expression, e.g. @code{Size}, the expression is
17670 treated like a default expression (visibility is analyzed at the point of
17671 occurrence of the aspect, but evaluation of the expression occurs at the
17672 freeze point of the entity involved.
17675 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
17676 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
17677 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
17678 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
17679 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
17684 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
17685 @cindex AI-0128 (Ada 2012 feature)
17688 If an equality operator ("=") is declared for a type, then the implicitly
17689 declared inequality operator ("/=") is a primitive operation of the type.
17690 This is the only reasonable interpretation, and is the one always implemented
17691 by GNAT, but the RM was not entirely clear in making this point.
17694 RM References: 3.02.03 (6) 6.06 (6)
17697 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
17698 @cindex AI-0003 (Ada 2012 feature)
17701 In Ada 2012, a qualified expression is considered to be syntactically a name,
17702 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
17703 useful in disambiguating some cases of overloading.
17706 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
17710 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
17711 @cindex AI-0120 (Ada 2012 feature)
17714 This is an RM editorial change only. The section that lists objects that are
17715 constant failed to include the current instance of a protected object
17716 within a protected function. This has always been treated as a constant
17720 RM References: 3.03 (21)
17723 @emph{AI-0008 General access to constrained objects (0000-00-00)}
17724 @cindex AI-0008 (Ada 2012 feature)
17727 The wording in the RM implied that if you have a general access to a
17728 constrained object, it could be used to modify the discriminants. This was
17729 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
17730 has always done so in this situation.
17733 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
17737 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
17738 @cindex AI-0093 (Ada 2012 feature)
17741 This is an editorial change only, to make more widespread use of the Ada 2012
17742 ``immutably limited''.
17745 RM References: 3.03 (23.4/3)
17750 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
17751 @cindex AI-0096 (Ada 2012 feature)
17754 In general it is illegal for a type derived from a formal limited type to be
17755 nonlimited. This AI makes an exception to this rule: derivation is legal
17756 if it appears in the private part of the generic, and the formal type is not
17757 tagged. If the type is tagged, the legality check must be applied to the
17758 private part of the package.
17761 RM References: 3.04 (5.1/2) 6.02 (7)
17765 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
17766 @cindex AI-0181 (Ada 2012 feature)
17769 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
17770 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
17771 @code{Image} and @code{Value} attributes for the character types. Strictly
17772 speaking this is an inconsistency with Ada 95, but in practice the use of
17773 these attributes is so obscure that it will not cause problems.
17776 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
17780 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
17781 @cindex AI-0182 (Ada 2012 feature)
17784 This AI allows @code{Character'Value} to accept the string @code{'?'} where
17785 @code{?} is any character including non-graphic control characters. GNAT has
17786 always accepted such strings. It also allows strings such as
17787 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
17788 permission and raises @code{Constraint_Error}, as is certainly still
17792 RM References: 3.05 (56/2)
17796 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
17797 @cindex AI-0214 (Ada 2012 feature)
17800 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
17801 to have default expressions by allowing them when the type is limited. It
17802 is often useful to define a default value for a discriminant even though
17803 it can't be changed by assignment.
17806 RM References: 3.07 (9.1/2) 3.07.02 (3)
17810 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
17811 @cindex AI-0102 (Ada 2012 feature)
17814 It is illegal to assign an anonymous access constant to an anonymous access
17815 variable. The RM did not have a clear rule to prevent this, but GNAT has
17816 always generated an error for this usage.
17819 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
17823 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
17824 @cindex AI-0158 (Ada 2012 feature)
17827 This AI extends the syntax of membership tests to simplify complex conditions
17828 that can be expressed as membership in a subset of values of any type. It
17829 introduces syntax for a list of expressions that may be used in loop contexts
17833 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
17837 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
17838 @cindex AI-0173 (Ada 2012 feature)
17841 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
17842 with the tag of an abstract type, and @code{False} otherwise.
17845 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
17850 @emph{AI-0076 function with controlling result (0000-00-00)}
17851 @cindex AI-0076 (Ada 2012 feature)
17854 This is an editorial change only. The RM defines calls with controlling
17855 results, but uses the term ``function with controlling result'' without an
17856 explicit definition.
17859 RM References: 3.09.02 (2/2)
17863 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
17864 @cindex AI-0126 (Ada 2012 feature)
17867 This AI clarifies dispatching rules, and simply confirms that dispatching
17868 executes the operation of the parent type when there is no explicitly or
17869 implicitly declared operation for the descendant type. This has always been
17870 the case in all versions of GNAT.
17873 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
17877 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
17878 @cindex AI-0097 (Ada 2012 feature)
17881 The RM as written implied that in some cases it was possible to create an
17882 object of an abstract type, by having an abstract extension inherit a non-
17883 abstract constructor from its parent type. This mistake has been corrected
17884 in GNAT and in the RM, and this construct is now illegal.
17887 RM References: 3.09.03 (4/2)
17891 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
17892 @cindex AI-0203 (Ada 2012 feature)
17895 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
17896 permitted such usage.
17899 RM References: 3.09.03 (8/3)
17903 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
17904 @cindex AI-0198 (Ada 2012 feature)
17907 This AI resolves a conflict between two rules involving inherited abstract
17908 operations and predefined operators. If a derived numeric type inherits
17909 an abstract operator, it overrides the predefined one. This interpretation
17910 was always the one implemented in GNAT.
17913 RM References: 3.09.03 (4/3)
17916 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
17917 @cindex AI-0073 (Ada 2012 feature)
17920 This AI covers a number of issues regarding returning abstract types. In
17921 particular generic functions cannot have abstract result types or access
17922 result types designated an abstract type. There are some other cases which
17923 are detailed in the AI. Note that this binding interpretation has not been
17924 retrofitted to operate before Ada 2012 mode, since it caused a significant
17925 number of regressions.
17928 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
17932 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
17933 @cindex AI-0070 (Ada 2012 feature)
17936 This is an editorial change only, there are no testable consequences short of
17937 checking for the absence of generated code for an interface declaration.
17940 RM References: 3.09.04 (18/2)
17944 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
17945 @cindex AI-0208 (Ada 2012 feature)
17948 The wording in the Ada 2005 RM concerning characteristics of incomplete views
17949 was incorrect and implied that some programs intended to be legal were now
17950 illegal. GNAT had never considered such programs illegal, so it has always
17951 implemented the intent of this AI.
17954 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
17958 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
17959 @cindex AI-0162 (Ada 2012 feature)
17962 Incomplete types are made more useful by allowing them to be completed by
17963 private types and private extensions.
17966 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
17971 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
17972 @cindex AI-0098 (Ada 2012 feature)
17975 An unintentional omission in the RM implied some inconsistent restrictions on
17976 the use of anonymous access to subprogram values. These restrictions were not
17977 intentional, and have never been enforced by GNAT.
17980 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
17984 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
17985 @cindex AI-0199 (Ada 2012 feature)
17988 A choice list in a record aggregate can include several components of
17989 (distinct) anonymous access types as long as they have matching designated
17993 RM References: 4.03.01 (16)
17997 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
17998 @cindex AI-0220 (Ada 2012 feature)
18001 This AI addresses a wording problem in the RM that appears to permit some
18002 complex cases of aggregates with non-static discriminants. GNAT has always
18003 implemented the intended semantics.
18006 RM References: 4.03.01 (17)
18009 @emph{AI-0147 Conditional expressions (2009-03-29)}
18010 @cindex AI-0147 (Ada 2012 feature)
18013 Conditional expressions are permitted. The form of such an expression is:
18016 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
18019 The parentheses can be omitted in contexts where parentheses are present
18020 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
18021 clause is omitted, @b{else True} is assumed;
18022 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
18023 @emph{(A implies B)} in standard logic.
18026 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
18027 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
18031 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
18032 @cindex AI-0037 (Ada 2012 feature)
18035 This AI confirms that an association of the form @code{Indx => <>} in an
18036 array aggregate must raise @code{Constraint_Error} if @code{Indx}
18037 is out of range. The RM specified a range check on other associations, but
18038 not when the value of the association was defaulted. GNAT has always inserted
18039 a constraint check on the index value.
18042 RM References: 4.03.03 (29)
18046 @emph{AI-0123 Composability of equality (2010-04-13)}
18047 @cindex AI-0123 (Ada 2012 feature)
18050 Equality of untagged record composes, so that the predefined equality for a
18051 composite type that includes a component of some untagged record type
18052 @code{R} uses the equality operation of @code{R} (which may be user-defined
18053 or predefined). This makes the behavior of untagged records identical to that
18054 of tagged types in this respect.
18056 This change is an incompatibility with previous versions of Ada, but it
18057 corrects a non-uniformity that was often a source of confusion. Analysis of
18058 a large number of industrial programs indicates that in those rare cases
18059 where a composite type had an untagged record component with a user-defined
18060 equality, either there was no use of the composite equality, or else the code
18061 expected the same composability as for tagged types, and thus had a bug that
18062 would be fixed by this change.
18065 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
18070 @emph{AI-0088 The value of exponentiation (0000-00-00)}
18071 @cindex AI-0088 (Ada 2012 feature)
18074 This AI clarifies the equivalence rule given for the dynamic semantics of
18075 exponentiation: the value of the operation can be obtained by repeated
18076 multiplication, but the operation can be implemented otherwise (for example
18077 using the familiar divide-by-two-and-square algorithm, even if this is less
18078 accurate), and does not imply repeated reads of a volatile base.
18081 RM References: 4.05.06 (11)
18084 @emph{AI-0188 Case expressions (2010-01-09)}
18085 @cindex AI-0188 (Ada 2012 feature)
18088 Case expressions are permitted. This allows use of constructs such as:
18090 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
18094 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
18097 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
18098 @cindex AI-0104 (Ada 2012 feature)
18101 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
18102 @code{Constraint_Error} because the default value of the allocated object is
18103 @b{null}. This useless construct is illegal in Ada 2012.
18106 RM References: 4.08 (2)
18109 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
18110 @cindex AI-0157 (Ada 2012 feature)
18113 Allocation and Deallocation from an empty storage pool (i.e. allocation or
18114 deallocation of a pointer for which a static storage size clause of zero
18115 has been given) is now illegal and is detected as such. GNAT
18116 previously gave a warning but not an error.
18119 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
18122 @emph{AI-0179 Statement not required after label (2010-04-10)}
18123 @cindex AI-0179 (Ada 2012 feature)
18126 It is not necessary to have a statement following a label, so a label
18127 can appear at the end of a statement sequence without the need for putting a
18128 null statement afterwards, but it is not allowable to have only labels and
18129 no real statements in a statement sequence.
18132 RM References: 5.01 (2)
18136 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
18137 @cindex AI-139-2 (Ada 2012 feature)
18140 The new syntax for iterating over arrays and containers is now implemented.
18141 Iteration over containers is for now limited to read-only iterators. Only
18142 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
18145 RM References: 5.05
18148 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
18149 @cindex AI-0134 (Ada 2012 feature)
18152 For full conformance, the profiles of anonymous-access-to-subprogram
18153 parameters must match. GNAT has always enforced this rule.
18156 RM References: 6.03.01 (18)
18159 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
18160 @cindex AI-0207 (Ada 2012 feature)
18163 This AI confirms that access_to_constant indication must match for mode
18164 conformance. This was implemented in GNAT when the qualifier was originally
18165 introduced in Ada 2005.
18168 RM References: 6.03.01 (16/2)
18172 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
18173 @cindex AI-0046 (Ada 2012 feature)
18176 For full conformance, in the case of access parameters, the null exclusion
18177 must match (either both or neither must have @code{@b{not null}}).
18180 RM References: 6.03.02 (18)
18184 @emph{AI-0118 The association of parameter associations (0000-00-00)}
18185 @cindex AI-0118 (Ada 2012 feature)
18188 This AI clarifies the rules for named associations in subprogram calls and
18189 generic instantiations. The rules have been in place since Ada 83.
18192 RM References: 6.04.01 (2) 12.03 (9)
18196 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
18197 @cindex AI-0196 (Ada 2012 feature)
18200 Null exclusion checks are not made for @code{@b{out}} parameters when
18201 evaluating the actual parameters. GNAT has never generated these checks.
18204 RM References: 6.04.01 (13)
18207 @emph{AI-0015 Constant return objects (0000-00-00)}
18208 @cindex AI-0015 (Ada 2012 feature)
18211 The return object declared in an @i{extended_return_statement} may be
18212 declared constant. This was always intended, and GNAT has always allowed it.
18215 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
18220 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
18221 @cindex AI-0032 (Ada 2012 feature)
18224 If a function returns a class-wide type, the object of an extended return
18225 statement can be declared with a specific type that is covered by the class-
18226 wide type. This has been implemented in GNAT since the introduction of
18227 extended returns. Note AI-0103 complements this AI by imposing matching
18228 rules for constrained return types.
18231 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
18235 @emph{AI-0103 Static matching for extended return (2010-07-23)}
18236 @cindex AI-0103 (Ada 2012 feature)
18239 If the return subtype of a function is an elementary type or a constrained
18240 type, the subtype indication in an extended return statement must match
18241 statically this return subtype.
18244 RM References: 6.05 (5.2/2)
18248 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
18249 @cindex AI-0058 (Ada 2012 feature)
18252 The RM had some incorrect wording implying wrong treatment of abnormal
18253 completion in an extended return. GNAT has always implemented the intended
18254 correct semantics as described by this AI.
18257 RM References: 6.05 (22/2)
18261 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
18262 @cindex AI-0050 (Ada 2012 feature)
18265 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
18266 not take advantage of these incorrect permissions in any case.
18269 RM References: 6.05 (24/2)
18273 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
18274 @cindex AI-0125 (Ada 2012 feature)
18277 In Ada 2012, the declaration of a primitive operation of a type extension
18278 or private extension can also override an inherited primitive that is not
18279 visible at the point of this declaration.
18282 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
18285 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
18286 @cindex AI-0062 (Ada 2012 feature)
18289 A full constant may have a null exclusion even if its associated deferred
18290 constant does not. GNAT has always allowed this.
18293 RM References: 7.04 (6/2) 7.04 (7.1/2)
18297 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
18298 @cindex AI-0178 (Ada 2012 feature)
18301 This AI clarifies the role of incomplete views and plugs an omission in the
18302 RM. GNAT always correctly restricted the use of incomplete views and types.
18305 RM References: 7.05 (3/2) 7.05 (6/2)
18308 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
18309 @cindex AI-0087 (Ada 2012 feature)
18312 The actual for a formal nonlimited derived type cannot be limited. In
18313 particular, a formal derived type that extends a limited interface but which
18314 is not explicitly limited cannot be instantiated with a limited type.
18317 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
18320 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
18321 @cindex AI-0099 (Ada 2012 feature)
18324 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
18325 and therefore depends on the run-time characteristics of an object (i.e. its
18326 tag) and not on its nominal type. As the AI indicates: ``we do not expect
18327 this to affect any implementation''.
18330 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
18335 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
18336 @cindex AI-0064 (Ada 2012 feature)
18339 This is an editorial change only. The intended behavior is already checked
18340 by an existing ACATS test, which GNAT has always executed correctly.
18343 RM References: 7.06.01 (17.1/1)
18346 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
18347 @cindex AI-0026 (Ada 2012 feature)
18350 Record representation clauses concerning Unchecked_Union types cannot mention
18351 the discriminant of the type. The type of a component declared in the variant
18352 part of an Unchecked_Union cannot be controlled, have controlled components,
18353 nor have protected or task parts. If an Unchecked_Union type is declared
18354 within the body of a generic unit or its descendants, then the type of a
18355 component declared in the variant part cannot be a formal private type or a
18356 formal private extension declared within the same generic unit.
18359 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
18363 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
18364 @cindex AI-0205 (Ada 2012 feature)
18367 This AI corrects a simple omission in the RM. Return objects have always
18368 been visible within an extended return statement.
18371 RM References: 8.03 (17)
18375 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
18376 @cindex AI-0042 (Ada 2012 feature)
18379 This AI fixes a wording gap in the RM. An operation of a synchronized
18380 interface can be implemented by a protected or task entry, but the abstract
18381 operation is not being overridden in the usual sense, and it must be stated
18382 separately that this implementation is legal. This has always been the case
18386 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
18389 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
18390 @cindex AI-0030 (Ada 2012 feature)
18393 Requeue is permitted to a protected, synchronized or task interface primitive
18394 providing it is known that the overriding operation is an entry. Otherwise
18395 the requeue statement has the same effect as a procedure call. Use of pragma
18396 @code{Implemented} provides a way to impose a static requirement on the
18397 overriding operation by adhering to one of the implementation kinds: entry,
18398 protected procedure or any of the above.
18401 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
18402 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
18406 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
18407 @cindex AI-0201 (Ada 2012 feature)
18410 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
18411 attribute, then individual components may not be addressable by independent
18412 tasks. However, if the representation clause has no effect (is confirming),
18413 then independence is not compromised. Furthermore, in GNAT, specification of
18414 other appropriately addressable component sizes (e.g. 16 for 8-bit
18415 characters) also preserves independence. GNAT now gives very clear warnings
18416 both for the declaration of such a type, and for any assignment to its components.
18419 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
18422 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
18423 @cindex AI-0009 (Ada 2012 feature)
18426 This AI introduces the new pragmas @code{Independent} and
18427 @code{Independent_Components},
18428 which control guaranteeing independence of access to objects and components.
18429 The AI also requires independence not unaffected by confirming rep clauses.
18432 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
18433 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
18437 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
18438 @cindex AI-0072 (Ada 2012 feature)
18441 This AI clarifies that task signalling for reading @code{'Terminated} only
18442 occurs if the result is True. GNAT semantics has always been consistent with
18443 this notion of task signalling.
18446 RM References: 9.10 (6.1/1)
18449 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
18450 @cindex AI-0108 (Ada 2012 feature)
18453 This AI confirms that an incomplete type from a limited view does not have
18454 discriminants. This has always been the case in GNAT.
18457 RM References: 10.01.01 (12.3/2)
18460 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
18461 @cindex AI-0129 (Ada 2012 feature)
18464 This AI clarifies the description of limited views: a limited view of a
18465 package includes only one view of a type that has an incomplete declaration
18466 and a full declaration (there is no possible ambiguity in a client package).
18467 This AI also fixes an omission: a nested package in the private part has no
18468 limited view. GNAT always implemented this correctly.
18471 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
18476 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
18477 @cindex AI-0077 (Ada 2012 feature)
18480 This AI clarifies that a declaration does not include a context clause,
18481 and confirms that it is illegal to have a context in which both a limited
18482 and a nonlimited view of a package are accessible. Such double visibility
18483 was always rejected by GNAT.
18486 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
18489 @emph{AI-0122 Private with and children of generics (0000-00-00)}
18490 @cindex AI-0122 (Ada 2012 feature)
18493 This AI clarifies the visibility of private children of generic units within
18494 instantiations of a parent. GNAT has always handled this correctly.
18497 RM References: 10.01.02 (12/2)
18502 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
18503 @cindex AI-0040 (Ada 2012 feature)
18506 This AI confirms that a limited with clause in a child unit cannot name
18507 an ancestor of the unit. This has always been checked in GNAT.
18510 RM References: 10.01.02 (20/2)
18513 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
18514 @cindex AI-0132 (Ada 2012 feature)
18517 This AI fills a gap in the description of library unit pragmas. The pragma
18518 clearly must apply to a library unit, even if it does not carry the name
18519 of the enclosing unit. GNAT has always enforced the required check.
18522 RM References: 10.01.05 (7)
18526 @emph{AI-0034 Categorization of limited views (0000-00-00)}
18527 @cindex AI-0034 (Ada 2012 feature)
18530 The RM makes certain limited with clauses illegal because of categorization
18531 considerations, when the corresponding normal with would be legal. This is
18532 not intended, and GNAT has always implemented the recommended behavior.
18535 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
18539 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
18540 @cindex AI-0035 (Ada 2012 feature)
18543 This AI remedies some inconsistencies in the legality rules for Pure units.
18544 Derived access types are legal in a pure unit (on the assumption that the
18545 rule for a zero storage pool size has been enforced on the ancestor type).
18546 The rules are enforced in generic instances and in subunits. GNAT has always
18547 implemented the recommended behavior.
18550 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)
18554 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
18555 @cindex AI-0219 (Ada 2012 feature)
18558 This AI refines the rules for the cases with limited parameters which do not
18559 allow the implementations to omit ``redundant''. GNAT now properly conforms
18560 to the requirements of this binding interpretation.
18563 RM References: 10.02.01 (18/2)
18566 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
18567 @cindex AI-0043 (Ada 2012 feature)
18570 This AI covers various omissions in the RM regarding the raising of
18571 exceptions. GNAT has always implemented the intended semantics.
18574 RM References: 11.04.01 (10.1/2) 11 (2)
18578 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
18579 @cindex AI-0200 (Ada 2012 feature)
18582 This AI plugs a gap in the RM which appeared to allow some obviously intended
18583 illegal instantiations. GNAT has never allowed these instantiations.
18586 RM References: 12.07 (16)
18590 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
18591 @cindex AI-0112 (Ada 2012 feature)
18594 This AI concerns giving names to various representation aspects, but the
18595 practical effect is simply to make the use of duplicate
18596 @code{Atomic}[@code{_Components}],
18597 @code{Volatile}[@code{_Components}] and
18598 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
18599 now performs this required check.
18602 RM References: 13.01 (8)
18605 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
18606 @cindex AI-0106 (Ada 2012 feature)
18609 The RM appeared to allow representation pragmas on generic formal parameters,
18610 but this was not intended, and GNAT has never permitted this usage.
18613 RM References: 13.01 (9.1/1)
18617 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
18618 @cindex AI-0012 (Ada 2012 feature)
18621 It is now illegal to give an inappropriate component size or a pragma
18622 @code{Pack} that attempts to change the component size in the case of atomic
18623 or aliased components. Previously GNAT ignored such an attempt with a
18627 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
18631 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
18632 @cindex AI-0039 (Ada 2012 feature)
18635 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
18636 for stream attributes, but these were never useful and are now illegal. GNAT
18637 has always regarded such expressions as illegal.
18640 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
18644 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
18645 @cindex AI-0095 (Ada 2012 feature)
18648 The prefix of @code{'Address} cannot statically denote a subprogram with
18649 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
18650 @code{Program_Error} if the prefix denotes a subprogram with convention
18654 RM References: 13.03 (11/1)
18658 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
18659 @cindex AI-0116 (Ada 2012 feature)
18662 This AI requires that the alignment of a class-wide object be no greater
18663 than the alignment of any type in the class. GNAT has always followed this
18667 RM References: 13.03 (29) 13.11 (16)
18671 @emph{AI-0146 Type invariants (2009-09-21)}
18672 @cindex AI-0146 (Ada 2012 feature)
18675 Type invariants may be specified for private types using the aspect notation.
18676 Aspect @code{Type_Invariant} may be specified for any private type,
18677 @code{Type_Invariant'Class} can
18678 only be specified for tagged types, and is inherited by any descendent of the
18679 tagged types. The invariant is a boolean expression that is tested for being
18680 true in the following situations: conversions to the private type, object
18681 declarations for the private type that are default initialized, and
18683 parameters and returned result on return from any primitive operation for
18684 the type that is visible to a client.
18685 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
18686 @code{Invariant'Class} for @code{Type_Invariant'Class}.
18689 RM References: 13.03.03 (00)
18692 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
18693 @cindex AI-0078 (Ada 2012 feature)
18696 In Ada 2012, compilers are required to support unchecked conversion where the
18697 target alignment is a multiple of the source alignment. GNAT always supported
18698 this case (and indeed all cases of differing alignments, doing copies where
18699 required if the alignment was reduced).
18702 RM References: 13.09 (7)
18706 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
18707 @cindex AI-0195 (Ada 2012 feature)
18710 The handling of invalid values is now designated to be implementation
18711 defined. This is a documentation change only, requiring Annex M in the GNAT
18712 Reference Manual to document this handling.
18713 In GNAT, checks for invalid values are made
18714 only when necessary to avoid erroneous behavior. Operations like assignments
18715 which cannot cause erroneous behavior ignore the possibility of invalid
18716 values and do not do a check. The date given above applies only to the
18717 documentation change, this behavior has always been implemented by GNAT.
18720 RM References: 13.09.01 (10)
18723 @emph{AI-0193 Alignment of allocators (2010-09-16)}
18724 @cindex AI-0193 (Ada 2012 feature)
18727 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
18728 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
18732 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
18733 13.11.01 (2) 13.11.01 (3)
18737 @emph{AI-0177 Parameterized expressions (2010-07-10)}
18738 @cindex AI-0177 (Ada 2012 feature)
18741 The new Ada 2012 notion of parameterized expressions is implemented. The form
18744 @i{function specification} @b{is} (@i{expression})
18748 This is exactly equivalent to the
18749 corresponding function body that returns the expression, but it can appear
18750 in a package spec. Note that the expression must be parenthesized.
18753 RM References: 13.11.01 (3/2)
18756 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
18757 @cindex AI-0033 (Ada 2012 feature)
18760 Neither of these two pragmas may appear within a generic template, because
18761 the generic might be instantiated at other than the library level.
18764 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
18768 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
18769 @cindex AI-0161 (Ada 2012 feature)
18772 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
18773 of the default stream attributes for elementary types. If this restriction is
18774 in force, then it is necessary to provide explicit subprograms for any
18775 stream attributes used.
18778 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
18781 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
18782 @cindex AI-0194 (Ada 2012 feature)
18785 The @code{Stream_Size} attribute returns the default number of bits in the
18786 stream representation of the given type.
18787 This value is not affected by the presence
18788 of stream subprogram attributes for the type. GNAT has always implemented
18789 this interpretation.
18792 RM References: 13.13.02 (1.2/2)
18795 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
18796 @cindex AI-0109 (Ada 2012 feature)
18799 This AI is an editorial change only. It removes the need for a tag check
18800 that can never fail.
18803 RM References: 13.13.02 (34/2)
18806 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
18807 @cindex AI-0007 (Ada 2012 feature)
18810 The RM as written appeared to limit the possibilities of declaring read
18811 attribute procedures for private scalar types. This limitation was not
18812 intended, and has never been enforced by GNAT.
18815 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
18819 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
18820 @cindex AI-0065 (Ada 2012 feature)
18823 This AI clarifies the fact that all remote access types support external
18824 streaming. This fixes an obvious oversight in the definition of the
18825 language, and GNAT always implemented the intended correct rules.
18828 RM References: 13.13.02 (52/2)
18831 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
18832 @cindex AI-0019 (Ada 2012 feature)
18835 The RM suggests that primitive subprograms of a specific tagged type are
18836 frozen when the tagged type is frozen. This would be an incompatible change
18837 and is not intended. GNAT has never attempted this kind of freezing and its
18838 behavior is consistent with the recommendation of this AI.
18841 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)
18844 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
18845 @cindex AI-0017 (Ada 2012 feature)
18848 So-called ``Taft-amendment types'' (i.e., types that are completed in package
18849 bodies) are not frozen by the occurrence of bodies in the
18850 enclosing declarative part. GNAT always implemented this properly.
18853 RM References: 13.14 (3/1)
18857 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
18858 @cindex AI-0060 (Ada 2012 feature)
18861 This AI extends the definition of remote access types to include access
18862 to limited, synchronized, protected or task class-wide interface types.
18863 GNAT already implemented this extension.
18866 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
18869 @emph{AI-0114 Classification of letters (0000-00-00)}
18870 @cindex AI-0114 (Ada 2012 feature)
18873 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
18874 181 (@code{MICRO SIGN}), and
18875 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
18876 lower case letters by Unicode.
18877 However, they are not allowed in identifiers, and they
18878 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
18879 This behavior is consistent with that defined in Ada 95.
18882 RM References: A.03.02 (59) A.04.06 (7)
18886 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
18887 @cindex AI-0185 (Ada 2012 feature)
18890 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
18891 classification functions for @code{Wide_Character} and
18892 @code{Wide_Wide_Character}, as well as providing
18893 case folding routines for @code{Wide_[Wide_]Character} and
18894 @code{Wide_[Wide_]String}.
18897 RM References: A.03.05 (0) A.03.06 (0)
18901 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
18902 @cindex AI-0031 (Ada 2012 feature)
18905 A new version of @code{Find_Token} is added to all relevant string packages,
18906 with an extra parameter @code{From}. Instead of starting at the first
18907 character of the string, the search for a matching Token starts at the
18908 character indexed by the value of @code{From}.
18909 These procedures are available in all versions of Ada
18910 but if used in versions earlier than Ada 2012 they will generate a warning
18911 that an Ada 2012 subprogram is being used.
18914 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
18919 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
18920 @cindex AI-0056 (Ada 2012 feature)
18923 The wording in the Ada 2005 RM implied an incompatible handling of the
18924 @code{Index} functions, resulting in raising an exception instead of
18925 returning zero in some situations.
18926 This was not intended and has been corrected.
18927 GNAT always returned zero, and is thus consistent with this AI.
18930 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
18934 @emph{AI-0137 String encoding package (2010-03-25)}
18935 @cindex AI-0137 (Ada 2012 feature)
18938 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
18939 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
18940 and @code{Wide_Wide_Strings} have been
18941 implemented. These packages (whose documentation can be found in the spec
18942 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
18943 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
18944 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
18945 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
18946 UTF-16), as well as conversions between the different UTF encodings. With
18947 the exception of @code{Wide_Wide_Strings}, these packages are available in
18948 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
18949 The @code{Wide_Wide_Strings package}
18950 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
18951 mode since it uses @code{Wide_Wide_Character}).
18954 RM References: A.04.11
18957 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
18958 @cindex AI-0038 (Ada 2012 feature)
18961 These are minor errors in the description on three points. The intent on
18962 all these points has always been clear, and GNAT has always implemented the
18963 correct intended semantics.
18966 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)
18969 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
18970 @cindex AI-0044 (Ada 2012 feature)
18973 This AI places restrictions on allowed instantiations of generic containers.
18974 These restrictions are not checked by the compiler, so there is nothing to
18975 change in the implementation. This affects only the RM documentation.
18978 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)
18981 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
18982 @cindex AI-0127 (Ada 2012 feature)
18985 This package provides an interface for identifying the current locale.
18988 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
18989 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
18994 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
18995 @cindex AI-0002 (Ada 2012 feature)
18998 The compiler is not required to support exporting an Ada subprogram with
18999 convention C if there are parameters or a return type of an unconstrained
19000 array type (such as @code{String}). GNAT allows such declarations but
19001 generates warnings. It is possible, but complicated, to write the
19002 corresponding C code and certainly such code would be specific to GNAT and
19006 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
19010 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
19011 @cindex AI05-0216 (Ada 2012 feature)
19014 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
19015 forbid tasks declared locally within subprograms, or functions returning task
19016 objects, and that is the implementation that GNAT has always provided.
19017 However the language in the RM was not sufficiently clear on this point.
19018 Thus this is a documentation change in the RM only.
19021 RM References: D.07 (3/3)
19024 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
19025 @cindex AI-0211 (Ada 2012 feature)
19028 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
19029 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
19032 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
19035 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
19036 @cindex AI-0190 (Ada 2012 feature)
19039 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
19040 used to control storage pools globally.
19041 In particular, you can force every access
19042 type that is used for allocation (@b{new}) to have an explicit storage pool,
19043 or you can declare a pool globally to be used for all access types that lack
19047 RM References: D.07 (8)
19050 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
19051 @cindex AI-0189 (Ada 2012 feature)
19054 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
19055 which says that no dynamic allocation will occur once elaboration is
19057 In general this requires a run-time check, which is not required, and which
19058 GNAT does not attempt. But the static cases of allocators in a task body or
19059 in the body of the main program are detected and flagged at compile or bind
19063 RM References: D.07 (19.1/2) H.04 (23.3/2)
19066 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
19067 @cindex AI-0171 (Ada 2012 feature)
19070 A new package @code{System.Multiprocessors} is added, together with the
19071 definition of pragma @code{CPU} for controlling task affinity. A new no
19072 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
19073 is added to the Ravenscar profile.
19076 RM References: D.13.01 (4/2) D.16
19080 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
19081 @cindex AI-0210 (Ada 2012 feature)
19084 This is a documentation only issue regarding wording of metric requirements,
19085 that does not affect the implementation of the compiler.
19088 RM References: D.15 (24/2)
19092 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
19093 @cindex AI-0206 (Ada 2012 feature)
19096 Remote types packages are now allowed to depend on preelaborated packages.
19097 This was formerly considered illegal.
19100 RM References: E.02.02 (6)
19105 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
19106 @cindex AI-0152 (Ada 2012 feature)
19109 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
19110 where the type of the returned value is an anonymous access type.
19113 RM References: H.04 (8/1)
19117 @node Obsolescent Features
19118 @chapter Obsolescent Features
19121 This chapter describes features that are provided by GNAT, but are
19122 considered obsolescent since there are preferred ways of achieving
19123 the same effect. These features are provided solely for historical
19124 compatibility purposes.
19127 * pragma No_Run_Time::
19128 * pragma Ravenscar::
19129 * pragma Restricted_Run_Time::
19132 @node pragma No_Run_Time
19133 @section pragma No_Run_Time
19135 The pragma @code{No_Run_Time} is used to achieve an affect similar
19136 to the use of the "Zero Foot Print" configurable run time, but without
19137 requiring a specially configured run time. The result of using this
19138 pragma, which must be used for all units in a partition, is to restrict
19139 the use of any language features requiring run-time support code. The
19140 preferred usage is to use an appropriately configured run-time that
19141 includes just those features that are to be made accessible.
19143 @node pragma Ravenscar
19144 @section pragma Ravenscar
19146 The pragma @code{Ravenscar} has exactly the same effect as pragma
19147 @code{Profile (Ravenscar)}. The latter usage is preferred since it
19148 is part of the new Ada 2005 standard.
19150 @node pragma Restricted_Run_Time
19151 @section pragma Restricted_Run_Time
19153 The pragma @code{Restricted_Run_Time} has exactly the same effect as
19154 pragma @code{Profile (Restricted)}. The latter usage is
19155 preferred since the Ada 2005 pragma @code{Profile} is intended for
19156 this kind of implementation dependent addition.
19159 @c GNU Free Documentation License
19161 @node Index,,GNU Free Documentation License, Top