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_Float_Overflow::
115 * Pragma Check_Name::
116 * Pragma Check_Policy::
118 * Pragma Common_Object::
119 * Pragma Compile_Time_Error::
120 * Pragma Compile_Time_Warning::
121 * Pragma Compiler_Unit::
122 * Pragma Complete_Representation::
123 * Pragma Complex_Representation::
124 * Pragma Component_Alignment::
125 * Pragma Contract_Case::
126 * Pragma Convention_Identifier::
128 * Pragma CPP_Constructor::
129 * Pragma CPP_Virtual::
130 * Pragma CPP_Vtable::
133 * Pragma Debug_Policy::
134 * Pragma Default_Storage_Pool::
135 * Pragma Detect_Blocking::
136 * Pragma Dispatching_Domain::
137 * Pragma Elaboration_Checks::
139 * Pragma Export_Exception::
140 * Pragma Export_Function::
141 * Pragma Export_Object::
142 * Pragma Export_Procedure::
143 * Pragma Export_Value::
144 * Pragma Export_Valued_Procedure::
145 * Pragma Extend_System::
146 * Pragma Extensions_Allowed::
148 * Pragma External_Name_Casing::
150 * Pragma Favor_Top_Level::
151 * Pragma Finalize_Storage_Only::
152 * Pragma Float_Representation::
154 * Pragma Implementation_Defined::
155 * Pragma Implemented::
156 * Pragma Implicit_Packing::
157 * Pragma Import_Exception::
158 * Pragma Import_Function::
159 * Pragma Import_Object::
160 * Pragma Import_Procedure::
161 * Pragma Import_Valued_Procedure::
162 * Pragma Independent::
163 * Pragma Independent_Components::
164 * Pragma Initialize_Scalars::
165 * Pragma Inline_Always::
166 * Pragma Inline_Generic::
168 * Pragma Interface_Name::
169 * Pragma Interrupt_Handler::
170 * Pragma Interrupt_State::
172 * Pragma Keep_Names::
175 * Pragma Linker_Alias::
176 * Pragma Linker_Constructor::
177 * Pragma Linker_Destructor::
178 * Pragma Linker_Section::
179 * Pragma Long_Float::
180 * Pragma Loop_Optimize::
181 * Pragma Machine_Attribute::
183 * Pragma Main_Storage::
187 * Pragma No_Strict_Aliasing ::
188 * Pragma Normalize_Scalars::
189 * Pragma Obsolescent::
190 * Pragma Optimize_Alignment::
192 * Pragma Overflow_Mode::
193 * Pragma Partition_Elaboration_Policy::
195 * Pragma Persistent_BSS::
197 * Pragma Postcondition::
198 * Pragma Precondition::
199 * Pragma Preelaborable_Initialization::
200 * Pragma Priority_Specific_Dispatching::
201 * Pragma Profile (Ravenscar)::
202 * Pragma Profile (Restricted)::
203 * Pragma Profile (Rational)::
204 * Pragma Psect_Object::
205 * Pragma Pure_Function::
206 * Pragma Relative_Deadline::
207 * Pragma Remote_Access_Type::
208 * Pragma Restriction_Warnings::
210 * Pragma Short_Circuit_And_Or::
211 * Pragma Short_Descriptors::
212 * Pragma Simple_Storage_Pool_Type::
213 * Pragma Source_File_Name::
214 * Pragma Source_File_Name_Project::
215 * Pragma Source_Reference::
216 * Pragma Static_Elaboration_Desired::
217 * Pragma Stream_Convert::
218 * Pragma Style_Checks::
221 * Pragma Suppress_All::
222 * Pragma Suppress_Exception_Locations::
223 * Pragma Suppress_Initialization::
226 * Pragma Task_Storage::
228 * Pragma Thread_Local_Storage::
229 * Pragma Time_Slice::
231 * Pragma Unchecked_Union::
232 * Pragma Unimplemented_Unit::
233 * Pragma Universal_Aliasing ::
234 * Pragma Universal_Data::
235 * Pragma Unmodified::
236 * Pragma Unreferenced::
237 * Pragma Unreferenced_Objects::
238 * Pragma Unreserve_All_Interrupts::
239 * Pragma Unsuppress::
240 * Pragma Use_VADS_Size::
241 * Pragma Validity_Checks::
244 * Pragma Weak_External::
245 * Pragma Wide_Character_Encoding::
247 Implementation Defined Attributes
258 * Default_Bit_Order::
270 * Has_Access_Values::
271 * Has_Discriminants::
278 * Max_Interrupt_Priority::
280 * Maximum_Alignment::
284 * Passed_By_Reference::
290 * Scalar_Storage_Order::
291 * Simple_Storage_Pool::
295 * System_Allocator_Alignment::
301 * Unconstrained_Array::
302 * Universal_Literal_String::
303 * Unrestricted_Access::
310 Standard and Implementation Defined Restrictions
312 * Partition-Wide Restrictions::
313 * Program Unit Level Restrictions::
315 Partition-Wide Restrictions
317 * Immediate_Reclamation::
318 * Max_Asynchronous_Select_Nesting::
319 * Max_Entry_Queue_Length::
320 * Max_Protected_Entries::
321 * Max_Select_Alternatives::
322 * Max_Storage_At_Blocking::
325 * No_Abort_Statements::
326 * No_Access_Parameter_Allocators::
327 * No_Access_Subprograms::
329 * No_Anonymous_Allocators::
332 * No_Default_Initialization::
335 * No_Direct_Boolean_Operators::
337 * No_Dispatching_Calls::
338 * No_Dynamic_Attachment::
339 * No_Dynamic_Priorities::
340 * No_Entry_Calls_In_Elaboration_Code::
341 * No_Enumeration_Maps::
342 * No_Exception_Handlers::
343 * No_Exception_Propagation::
344 * No_Exception_Registration::
348 * No_Floating_Point::
349 * No_Implicit_Conditionals::
350 * No_Implicit_Dynamic_Code::
351 * No_Implicit_Heap_Allocations::
352 * No_Implicit_Loops::
353 * No_Initialize_Scalars::
355 * No_Local_Allocators::
356 * No_Local_Protected_Objects::
357 * No_Local_Timing_Events::
358 * No_Nested_Finalization::
359 * No_Protected_Type_Allocators::
360 * No_Protected_Types::
363 * No_Relative_Delay::
364 * No_Requeue_Statements::
365 * No_Secondary_Stack::
366 * No_Select_Statements::
367 * No_Specific_Termination_Handlers::
368 * No_Specification_of_Aspect::
369 * No_Standard_Allocators_After_Elaboration::
370 * No_Standard_Storage_Pools::
371 * No_Stream_Optimizations::
373 * No_Task_Allocators::
374 * No_Task_Attributes_Package::
375 * No_Task_Hierarchy::
376 * No_Task_Termination::
378 * No_Terminate_Alternatives::
379 * No_Unchecked_Access::
381 * Static_Priorities::
382 * Static_Storage_Size::
384 Program Unit Level Restrictions
386 * No_Elaboration_Code::
388 * No_Implementation_Aspect_Specifications::
389 * No_Implementation_Attributes::
390 * No_Implementation_Identifiers::
391 * No_Implementation_Pragmas::
392 * No_Implementation_Restrictions::
393 * No_Implementation_Units::
394 * No_Implicit_Aliasing::
395 * No_Obsolescent_Features::
396 * No_Wide_Characters::
399 The Implementation of Standard I/O
401 * Standard I/O Packages::
407 * Wide_Wide_Text_IO::
411 * Filenames encoding::
413 * Operations on C Streams::
414 * Interfacing to C Streams::
418 * Ada.Characters.Latin_9 (a-chlat9.ads)::
419 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
420 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
421 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
422 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
423 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
424 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
425 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
426 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
427 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
428 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
429 * Ada.Command_Line.Environment (a-colien.ads)::
430 * Ada.Command_Line.Remove (a-colire.ads)::
431 * Ada.Command_Line.Response_File (a-clrefi.ads)::
432 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
433 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
434 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
435 * Ada.Exceptions.Traceback (a-exctra.ads)::
436 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
437 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
438 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
439 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
440 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
441 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
442 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
443 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
444 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
445 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
446 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
447 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
448 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
449 * GNAT.Altivec (g-altive.ads)::
450 * GNAT.Altivec.Conversions (g-altcon.ads)::
451 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
452 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
453 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
454 * GNAT.Array_Split (g-arrspl.ads)::
455 * GNAT.AWK (g-awk.ads)::
456 * GNAT.Bounded_Buffers (g-boubuf.ads)::
457 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
458 * GNAT.Bubble_Sort (g-bubsor.ads)::
459 * GNAT.Bubble_Sort_A (g-busora.ads)::
460 * GNAT.Bubble_Sort_G (g-busorg.ads)::
461 * GNAT.Byte_Order_Mark (g-byorma.ads)::
462 * GNAT.Byte_Swapping (g-bytswa.ads)::
463 * GNAT.Calendar (g-calend.ads)::
464 * GNAT.Calendar.Time_IO (g-catiio.ads)::
465 * GNAT.Case_Util (g-casuti.ads)::
466 * GNAT.CGI (g-cgi.ads)::
467 * GNAT.CGI.Cookie (g-cgicoo.ads)::
468 * GNAT.CGI.Debug (g-cgideb.ads)::
469 * GNAT.Command_Line (g-comlin.ads)::
470 * GNAT.Compiler_Version (g-comver.ads)::
471 * GNAT.Ctrl_C (g-ctrl_c.ads)::
472 * GNAT.CRC32 (g-crc32.ads)::
473 * GNAT.Current_Exception (g-curexc.ads)::
474 * GNAT.Debug_Pools (g-debpoo.ads)::
475 * GNAT.Debug_Utilities (g-debuti.ads)::
476 * GNAT.Decode_String (g-decstr.ads)::
477 * GNAT.Decode_UTF8_String (g-deutst.ads)::
478 * GNAT.Directory_Operations (g-dirope.ads)::
479 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
480 * GNAT.Dynamic_HTables (g-dynhta.ads)::
481 * GNAT.Dynamic_Tables (g-dyntab.ads)::
482 * GNAT.Encode_String (g-encstr.ads)::
483 * GNAT.Encode_UTF8_String (g-enutst.ads)::
484 * GNAT.Exception_Actions (g-excact.ads)::
485 * GNAT.Exception_Traces (g-exctra.ads)::
486 * GNAT.Exceptions (g-except.ads)::
487 * GNAT.Expect (g-expect.ads)::
488 * GNAT.Expect.TTY (g-exptty.ads)::
489 * GNAT.Float_Control (g-flocon.ads)::
490 * GNAT.Heap_Sort (g-heasor.ads)::
491 * GNAT.Heap_Sort_A (g-hesora.ads)::
492 * GNAT.Heap_Sort_G (g-hesorg.ads)::
493 * GNAT.HTable (g-htable.ads)::
494 * GNAT.IO (g-io.ads)::
495 * GNAT.IO_Aux (g-io_aux.ads)::
496 * GNAT.Lock_Files (g-locfil.ads)::
497 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
498 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
499 * GNAT.MD5 (g-md5.ads)::
500 * GNAT.Memory_Dump (g-memdum.ads)::
501 * GNAT.Most_Recent_Exception (g-moreex.ads)::
502 * GNAT.OS_Lib (g-os_lib.ads)::
503 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
504 * GNAT.Random_Numbers (g-rannum.ads)::
505 * GNAT.Regexp (g-regexp.ads)::
506 * GNAT.Registry (g-regist.ads)::
507 * GNAT.Regpat (g-regpat.ads)::
508 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
509 * GNAT.Semaphores (g-semaph.ads)::
510 * GNAT.Serial_Communications (g-sercom.ads)::
511 * GNAT.SHA1 (g-sha1.ads)::
512 * GNAT.SHA224 (g-sha224.ads)::
513 * GNAT.SHA256 (g-sha256.ads)::
514 * GNAT.SHA384 (g-sha384.ads)::
515 * GNAT.SHA512 (g-sha512.ads)::
516 * GNAT.Signals (g-signal.ads)::
517 * GNAT.Sockets (g-socket.ads)::
518 * GNAT.Source_Info (g-souinf.ads)::
519 * GNAT.Spelling_Checker (g-speche.ads)::
520 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
521 * GNAT.Spitbol.Patterns (g-spipat.ads)::
522 * GNAT.Spitbol (g-spitbo.ads)::
523 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
524 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
525 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
526 * GNAT.SSE (g-sse.ads)::
527 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
528 * GNAT.Strings (g-string.ads)::
529 * GNAT.String_Split (g-strspl.ads)::
530 * GNAT.Table (g-table.ads)::
531 * GNAT.Task_Lock (g-tasloc.ads)::
532 * GNAT.Threads (g-thread.ads)::
533 * GNAT.Time_Stamp (g-timsta.ads)::
534 * GNAT.Traceback (g-traceb.ads)::
535 * GNAT.Traceback.Symbolic (g-trasym.ads)::
536 * GNAT.UTF_32 (g-utf_32.ads)::
537 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
538 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
539 * GNAT.Wide_String_Split (g-wistsp.ads)::
540 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
541 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
542 * Interfaces.C.Extensions (i-cexten.ads)::
543 * Interfaces.C.Streams (i-cstrea.ads)::
544 * Interfaces.CPP (i-cpp.ads)::
545 * Interfaces.Packed_Decimal (i-pacdec.ads)::
546 * Interfaces.VxWorks (i-vxwork.ads)::
547 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
548 * System.Address_Image (s-addima.ads)::
549 * System.Assertions (s-assert.ads)::
550 * System.Memory (s-memory.ads)::
551 * System.Partition_Interface (s-parint.ads)::
552 * System.Pool_Global (s-pooglo.ads)::
553 * System.Pool_Local (s-pooloc.ads)::
554 * System.Restrictions (s-restri.ads)::
555 * System.Rident (s-rident.ads)::
556 * System.Strings.Stream_Ops (s-ststop.ads)::
557 * System.Task_Info (s-tasinf.ads)::
558 * System.Wch_Cnv (s-wchcnv.ads)::
559 * System.Wch_Con (s-wchcon.ads)::
563 * Text_IO Stream Pointer Positioning::
564 * Text_IO Reading and Writing Non-Regular Files::
566 * Treating Text_IO Files as Streams::
567 * Text_IO Extensions::
568 * Text_IO Facilities for Unbounded Strings::
572 * Wide_Text_IO Stream Pointer Positioning::
573 * Wide_Text_IO Reading and Writing Non-Regular Files::
577 * Wide_Wide_Text_IO Stream Pointer Positioning::
578 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
580 Interfacing to Other Languages
583 * Interfacing to C++::
584 * Interfacing to COBOL::
585 * Interfacing to Fortran::
586 * Interfacing to non-GNAT Ada code::
588 Specialized Needs Annexes
590 Implementation of Specific Ada Features
591 * Machine Code Insertions::
592 * GNAT Implementation of Tasking::
593 * GNAT Implementation of Shared Passive Packages::
594 * Code Generation for Array Aggregates::
595 * The Size of Discriminated Records with Default Discriminants::
596 * Strict Conformance to the Ada Reference Manual::
598 Implementation of Ada 2012 Features
602 GNU Free Documentation License
609 @node About This Guide
610 @unnumbered About This Guide
613 This manual contains useful information in writing programs using the
614 @value{EDITION} compiler. It includes information on implementation dependent
615 characteristics of @value{EDITION}, including all the information required by
616 Annex M of the Ada language standard.
618 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
619 Ada 83 compatibility mode.
620 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
621 but you can override with a compiler switch
622 to explicitly specify the language version.
623 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
624 @value{EDITION} User's Guide}, for details on these switches.)
625 Throughout this manual, references to ``Ada'' without a year suffix
626 apply to both the Ada 95 and Ada 2005 versions of the language.
628 Ada is designed to be highly portable.
629 In general, a program will have the same effect even when compiled by
630 different compilers on different platforms.
631 However, since Ada is designed to be used in a
632 wide variety of applications, it also contains a number of system
633 dependent features to be used in interfacing to the external world.
634 @cindex Implementation-dependent features
637 Note: Any program that makes use of implementation-dependent features
638 may be non-portable. You should follow good programming practice and
639 isolate and clearly document any sections of your program that make use
640 of these features in a non-portable manner.
643 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
644 ``GNAT'' in the remainder of this document.
648 * What This Reference Manual Contains::
650 * Related Information::
653 @node What This Reference Manual Contains
654 @unnumberedsec What This Reference Manual Contains
657 This reference manual contains the following chapters:
661 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
662 pragmas, which can be used to extend and enhance the functionality of the
666 @ref{Implementation Defined Attributes}, lists GNAT
667 implementation-dependent attributes, which can be used to extend and
668 enhance the functionality of the compiler.
671 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
672 implementation-dependent restrictions, which can be used to extend and
673 enhance the functionality of the compiler.
676 @ref{Implementation Advice}, provides information on generally
677 desirable behavior which are not requirements that all compilers must
678 follow since it cannot be provided on all systems, or which may be
679 undesirable on some systems.
682 @ref{Implementation Defined Characteristics}, provides a guide to
683 minimizing implementation dependent features.
686 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
687 implemented by GNAT, and how they can be imported into user
688 application programs.
691 @ref{Representation Clauses and Pragmas}, describes in detail the
692 way that GNAT represents data, and in particular the exact set
693 of representation clauses and pragmas that is accepted.
696 @ref{Standard Library Routines}, provides a listing of packages and a
697 brief description of the functionality that is provided by Ada's
698 extensive set of standard library routines as implemented by GNAT@.
701 @ref{The Implementation of Standard I/O}, details how the GNAT
702 implementation of the input-output facilities.
705 @ref{The GNAT Library}, is a catalog of packages that complement
706 the Ada predefined library.
709 @ref{Interfacing to Other Languages}, describes how programs
710 written in Ada using GNAT can be interfaced to other programming
713 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
714 of the specialized needs annexes.
717 @ref{Implementation of Specific Ada Features}, discusses issues related
718 to GNAT's implementation of machine code insertions, tasking, and several
722 @ref{Implementation of Ada 2012 Features}, describes the status of the
723 GNAT implementation of the Ada 2012 language standard.
726 @ref{Obsolescent Features} documents implementation dependent features,
727 including pragmas and attributes, which are considered obsolescent, since
728 there are other preferred ways of achieving the same results. These
729 obsolescent forms are retained for backwards compatibility.
733 @cindex Ada 95 Language Reference Manual
734 @cindex Ada 2005 Language Reference Manual
736 This reference manual assumes a basic familiarity with the Ada 95 language, as
737 described in the International Standard ANSI/ISO/IEC-8652:1995,
739 It does not require knowledge of the new features introduced by Ada 2005,
740 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
742 Both reference manuals are included in the GNAT documentation
746 @unnumberedsec Conventions
747 @cindex Conventions, typographical
748 @cindex Typographical conventions
751 Following are examples of the typographical and graphic conventions used
756 @code{Functions}, @code{utility program names}, @code{standard names},
763 @file{File names}, @samp{button names}, and @samp{field names}.
766 @code{Variables}, @env{environment variables}, and @var{metasyntactic
773 [optional information or parameters]
776 Examples are described by text
778 and then shown this way.
783 Commands that are entered by the user are preceded in this manual by the
784 characters @samp{$ } (dollar sign followed by space). If your system uses this
785 sequence as a prompt, then the commands will appear exactly as you see them
786 in the manual. If your system uses some other prompt, then the command will
787 appear with the @samp{$} replaced by whatever prompt character you are using.
789 @node Related Information
790 @unnumberedsec Related Information
792 See the following documents for further information on GNAT:
796 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
797 @value{EDITION} User's Guide}, which provides information on how to use the
798 GNAT compiler system.
801 @cite{Ada 95 Reference Manual}, which contains all reference
802 material for the Ada 95 programming language.
805 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
806 of the Ada 95 standard. The annotations describe
807 detailed aspects of the design decision, and in particular contain useful
808 sections on Ada 83 compatibility.
811 @cite{Ada 2005 Reference Manual}, which contains all reference
812 material for the Ada 2005 programming language.
815 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
816 of the Ada 2005 standard. The annotations describe
817 detailed aspects of the design decision, and in particular contain useful
818 sections on Ada 83 and Ada 95 compatibility.
821 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
822 which contains specific information on compatibility between GNAT and
826 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
827 describes in detail the pragmas and attributes provided by the DEC Ada 83
832 @node Implementation Defined Pragmas
833 @chapter Implementation Defined Pragmas
836 Ada defines a set of pragmas that can be used to supply additional
837 information to the compiler. These language defined pragmas are
838 implemented in GNAT and work as described in the Ada Reference Manual.
840 In addition, Ada allows implementations to define additional pragmas
841 whose meaning is defined by the implementation. GNAT provides a number
842 of these implementation-defined pragmas, which can be used to extend
843 and enhance the functionality of the compiler. This section of the GNAT
844 Reference Manual describes these additional pragmas.
846 Note that any program using these pragmas might not be portable to other
847 compilers (although GNAT implements this set of pragmas on all
848 platforms). Therefore if portability to other compilers is an important
849 consideration, the use of these pragmas should be minimized.
852 * Pragma Abort_Defer::
861 * Pragma Assertion_Policy::
862 * Pragma Assume_No_Invalid_Values::
863 * Pragma Attribute_Definition::
865 * Pragma C_Pass_By_Copy::
867 * Pragma Check_Float_Overflow::
868 * Pragma Check_Name::
869 * Pragma Check_Policy::
871 * Pragma Common_Object::
872 * Pragma Compile_Time_Error::
873 * Pragma Compile_Time_Warning::
874 * Pragma Compiler_Unit::
875 * Pragma Complete_Representation::
876 * Pragma Complex_Representation::
877 * Pragma Component_Alignment::
878 * Pragma Contract_Case::
879 * Pragma Convention_Identifier::
881 * Pragma CPP_Constructor::
882 * Pragma CPP_Virtual::
883 * Pragma CPP_Vtable::
886 * Pragma Debug_Policy::
887 * Pragma Default_Storage_Pool::
888 * Pragma Detect_Blocking::
889 * Pragma Dispatching_Domain::
890 * Pragma Elaboration_Checks::
892 * Pragma Export_Exception::
893 * Pragma Export_Function::
894 * Pragma Export_Object::
895 * Pragma Export_Procedure::
896 * Pragma Export_Value::
897 * Pragma Export_Valued_Procedure::
898 * Pragma Extend_System::
899 * Pragma Extensions_Allowed::
901 * Pragma External_Name_Casing::
903 * Pragma Favor_Top_Level::
904 * Pragma Finalize_Storage_Only::
905 * Pragma Float_Representation::
907 * Pragma Implementation_Defined::
908 * Pragma Implemented::
909 * Pragma Implicit_Packing::
910 * Pragma Import_Exception::
911 * Pragma Import_Function::
912 * Pragma Import_Object::
913 * Pragma Import_Procedure::
914 * Pragma Import_Valued_Procedure::
915 * Pragma Independent::
916 * Pragma Independent_Components::
917 * Pragma Initialize_Scalars::
918 * Pragma Inline_Always::
919 * Pragma Inline_Generic::
921 * Pragma Interface_Name::
922 * Pragma Interrupt_Handler::
923 * Pragma Interrupt_State::
925 * Pragma Keep_Names::
928 * Pragma Linker_Alias::
929 * Pragma Linker_Constructor::
930 * Pragma Linker_Destructor::
931 * Pragma Linker_Section::
932 * Pragma Long_Float::
933 * Pragma Loop_Optimize::
934 * Pragma Machine_Attribute::
936 * Pragma Main_Storage::
940 * Pragma No_Strict_Aliasing::
941 * Pragma Normalize_Scalars::
942 * Pragma Obsolescent::
943 * Pragma Optimize_Alignment::
945 * Pragma Overflow_Mode::
946 * Pragma Partition_Elaboration_Policy::
948 * Pragma Persistent_BSS::
950 * Pragma Postcondition::
951 * Pragma Precondition::
952 * Pragma Preelaborable_Initialization::
953 * Pragma Priority_Specific_Dispatching::
954 * Pragma Profile (Ravenscar)::
955 * Pragma Profile (Restricted)::
956 * Pragma Profile (Rational)::
957 * Pragma Psect_Object::
958 * Pragma Pure_Function::
959 * Pragma Relative_Deadline::
960 * Pragma Remote_Access_Type::
961 * Pragma Restriction_Warnings::
963 * Pragma Short_Circuit_And_Or::
964 * Pragma Short_Descriptors::
965 * Pragma Simple_Storage_Pool_Type::
966 * Pragma Source_File_Name::
967 * Pragma Source_File_Name_Project::
968 * Pragma Source_Reference::
969 * Pragma Static_Elaboration_Desired::
970 * Pragma Stream_Convert::
971 * Pragma Style_Checks::
974 * Pragma Suppress_All::
975 * Pragma Suppress_Exception_Locations::
976 * Pragma Suppress_Initialization::
979 * Pragma Task_Storage::
981 * Pragma Thread_Local_Storage::
982 * Pragma Time_Slice::
984 * Pragma Unchecked_Union::
985 * Pragma Unimplemented_Unit::
986 * Pragma Universal_Aliasing ::
987 * Pragma Universal_Data::
988 * Pragma Unmodified::
989 * Pragma Unreferenced::
990 * Pragma Unreferenced_Objects::
991 * Pragma Unreserve_All_Interrupts::
992 * Pragma Unsuppress::
993 * Pragma Use_VADS_Size::
994 * Pragma Validity_Checks::
997 * Pragma Weak_External::
998 * Pragma Wide_Character_Encoding::
1001 @node Pragma Abort_Defer
1002 @unnumberedsec Pragma Abort_Defer
1004 @cindex Deferring aborts
1012 This pragma must appear at the start of the statement sequence of a
1013 handled sequence of statements (right after the @code{begin}). It has
1014 the effect of deferring aborts for the sequence of statements (but not
1015 for the declarations or handlers, if any, associated with this statement
1019 @unnumberedsec Pragma Ada_83
1023 @smallexample @c ada
1028 A configuration pragma that establishes Ada 83 mode for the unit to
1029 which it applies, regardless of the mode set by the command line
1030 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1031 the syntax and semantics of Ada 83, as defined in the original Ada
1032 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1033 and Ada 2005 are not recognized, optional package bodies are allowed,
1034 and generics may name types with unknown discriminants without using
1035 the @code{(<>)} notation. In addition, some but not all of the additional
1036 restrictions of Ada 83 are enforced.
1038 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1039 Ada 83 code to be compiled and adapted to GNAT with less effort.
1040 Secondly, it aids in keeping code backwards compatible with Ada 83.
1041 However, there is no guarantee that code that is processed correctly
1042 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1043 83 compiler, since GNAT does not enforce all the additional checks
1047 @unnumberedsec Pragma Ada_95
1051 @smallexample @c ada
1056 A configuration pragma that establishes Ada 95 mode for the unit to which
1057 it applies, regardless of the mode set by the command line switches.
1058 This mode is set automatically for the @code{Ada} and @code{System}
1059 packages and their children, so you need not specify it in these
1060 contexts. This pragma is useful when writing a reusable component that
1061 itself uses Ada 95 features, but which is intended to be usable from
1062 either Ada 83 or Ada 95 programs.
1065 @unnumberedsec Pragma Ada_05
1069 @smallexample @c ada
1074 A configuration pragma that establishes Ada 2005 mode for the unit to which
1075 it applies, regardless of the mode set by the command line switches.
1076 This pragma is useful when writing a reusable component that
1077 itself uses Ada 2005 features, but which is intended to be usable from
1078 either Ada 83 or Ada 95 programs.
1080 @node Pragma Ada_2005
1081 @unnumberedsec Pragma Ada_2005
1085 @smallexample @c ada
1090 This configuration pragma is a synonym for pragma Ada_05 and has the
1091 same syntax and effect.
1094 @unnumberedsec Pragma Ada_12
1098 @smallexample @c ada
1103 A configuration pragma that establishes Ada 2012 mode for the unit to which
1104 it applies, regardless of the mode set by the command line switches.
1105 This mode is set automatically for the @code{Ada} and @code{System}
1106 packages and their children, so you need not specify it in these
1107 contexts. This pragma is useful when writing a reusable component that
1108 itself uses Ada 2012 features, but which is intended to be usable from
1109 Ada 83, Ada 95, or Ada 2005 programs.
1111 @node Pragma Ada_2012
1112 @unnumberedsec Pragma Ada_2012
1116 @smallexample @c ada
1121 This configuration pragma is a synonym for pragma Ada_12 and has the
1122 same syntax and effect.
1124 @node Pragma Annotate
1125 @unnumberedsec Pragma Annotate
1129 @smallexample @c ada
1130 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1132 ARG ::= NAME | EXPRESSION
1136 This pragma is used to annotate programs. @var{identifier} identifies
1137 the type of annotation. GNAT verifies that it is an identifier, but does
1138 not otherwise analyze it. The second optional identifier is also left
1139 unanalyzed, and by convention is used to control the action of the tool to
1140 which the annotation is addressed. The remaining @var{arg} arguments
1141 can be either string literals or more generally expressions.
1142 String literals are assumed to be either of type
1143 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1144 depending on the character literals they contain.
1145 All other kinds of arguments are analyzed as expressions, and must be
1148 The analyzed pragma is retained in the tree, but not otherwise processed
1149 by any part of the GNAT compiler, except to generate corresponding note
1150 lines in the generated ALI file. For the format of these note lines, see
1151 the compiler source file lib-writ.ads. This pragma is intended for use by
1152 external tools, including ASIS@. The use of pragma Annotate does not
1153 affect the compilation process in any way. This pragma may be used as
1154 a configuration pragma.
1157 @unnumberedsec Pragma Assert
1161 @smallexample @c ada
1164 [, string_EXPRESSION]);
1168 The effect of this pragma depends on whether the corresponding command
1169 line switch is set to activate assertions. The pragma expands into code
1170 equivalent to the following:
1172 @smallexample @c ada
1173 if assertions-enabled then
1174 if not boolean_EXPRESSION then
1175 System.Assertions.Raise_Assert_Failure
1176 (string_EXPRESSION);
1182 The string argument, if given, is the message that will be associated
1183 with the exception occurrence if the exception is raised. If no second
1184 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1185 where @var{file} is the name of the source file containing the assert,
1186 and @var{nnn} is the line number of the assert. A pragma is not a
1187 statement, so if a statement sequence contains nothing but a pragma
1188 assert, then a null statement is required in addition, as in:
1190 @smallexample @c ada
1193 pragma Assert (K > 3, "Bad value for K");
1199 Note that, as with the @code{if} statement to which it is equivalent, the
1200 type of the expression is either @code{Standard.Boolean}, or any type derived
1201 from this standard type.
1203 If assertions are disabled (switch @option{-gnata} not used), then there
1204 is no run-time effect (and in particular, any side effects from the
1205 expression will not occur at run time). (The expression is still
1206 analyzed at compile time, and may cause types to be frozen if they are
1207 mentioned here for the first time).
1209 If assertions are enabled, then the given expression is tested, and if
1210 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1211 which results in the raising of @code{Assert_Failure} with the given message.
1213 You should generally avoid side effects in the expression arguments of
1214 this pragma, because these side effects will turn on and off with the
1215 setting of the assertions mode, resulting in assertions that have an
1216 effect on the program. However, the expressions are analyzed for
1217 semantic correctness whether or not assertions are enabled, so turning
1218 assertions on and off cannot affect the legality of a program.
1220 Note that the implementation defined policy @code{DISABLE}, given in a
1221 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1223 Note: this is a standard language-defined pragma in versions
1224 of Ada from 2005 on. In GNAT, it is implemented in all versions
1225 of Ada, and the DISABLE policy is an implementation-defined
1228 @node Pragma Assertion_Policy
1229 @unnumberedsec Pragma Assertion_Policy
1230 @findex Debug_Policy
1234 @smallexample @c ada
1235 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1239 This is a standard Ada 2005 pragma that is available as an
1240 implementation-defined pragma in earlier versions of Ada.
1242 If the argument is @code{CHECK}, then assertions are enabled.
1243 If the argument is @code{IGNORE}, then assertions are ignored.
1244 This pragma overrides the effect of the @option{-gnata} switch on the
1247 Assertions are of three kinds:
1251 Pragma @code{Assert}.
1253 In Ada 2012, all assertions defined in the RM as aspects: preconditions,
1254 postconditions, type invariants and (sub)type predicates.
1256 Corresponding pragmas for type invariants and (sub)type predicates.
1259 The implementation defined policy @code{DISABLE} is like
1260 @code{IGNORE} except that it completely disables semantic
1261 checking of the argument to @code{pragma Assert}. This may
1262 be useful when the pragma argument references subprograms
1263 in a with'ed package which is replaced by a dummy package
1264 for the final build.
1266 Note: this is a standard language-defined pragma in versions
1267 of Ada from 2005 on. In GNAT, it is implemented in all versions
1268 of Ada, and the DISABLE policy is an implementation-defined
1271 @node Pragma Assume_No_Invalid_Values
1272 @unnumberedsec Pragma Assume_No_Invalid_Values
1273 @findex Assume_No_Invalid_Values
1274 @cindex Invalid representations
1275 @cindex Invalid values
1278 @smallexample @c ada
1279 pragma Assume_No_Invalid_Values (On | Off);
1283 This is a configuration pragma that controls the assumptions made by the
1284 compiler about the occurrence of invalid representations (invalid values)
1287 The default behavior (corresponding to an Off argument for this pragma), is
1288 to assume that values may in general be invalid unless the compiler can
1289 prove they are valid. Consider the following example:
1291 @smallexample @c ada
1292 V1 : Integer range 1 .. 10;
1293 V2 : Integer range 11 .. 20;
1295 for J in V2 .. V1 loop
1301 if V1 and V2 have valid values, then the loop is known at compile
1302 time not to execute since the lower bound must be greater than the
1303 upper bound. However in default mode, no such assumption is made,
1304 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1305 is given, the compiler will assume that any occurrence of a variable
1306 other than in an explicit @code{'Valid} test always has a valid
1307 value, and the loop above will be optimized away.
1309 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1310 you know your code is free of uninitialized variables and other
1311 possible sources of invalid representations, and may result in
1312 more efficient code. A program that accesses an invalid representation
1313 with this pragma in effect is erroneous, so no guarantees can be made
1316 It is peculiar though permissible to use this pragma in conjunction
1317 with validity checking (-gnatVa). In such cases, accessing invalid
1318 values will generally give an exception, though formally the program
1319 is erroneous so there are no guarantees that this will always be the
1320 case, and it is recommended that these two options not be used together.
1322 @node Pragma Ast_Entry
1323 @unnumberedsec Pragma Ast_Entry
1328 @smallexample @c ada
1329 pragma AST_Entry (entry_IDENTIFIER);
1333 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1334 argument is the simple name of a single entry; at most one @code{AST_Entry}
1335 pragma is allowed for any given entry. This pragma must be used in
1336 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1337 the entry declaration and in the same task type specification or single task
1338 as the entry to which it applies. This pragma specifies that the given entry
1339 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1340 resulting from an OpenVMS system service call. The pragma does not affect
1341 normal use of the entry. For further details on this pragma, see the
1342 DEC Ada Language Reference Manual, section 9.12a.
1344 @node Pragma Attribute_Definition
1345 @unnumberedsec Pragma Attribute_Definition
1346 @findex Attribute_Definition
1349 @smallexample @c ada
1350 pragma Attribute_Definition
1351 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1352 [Entity =>] LOCAL_NAME,
1353 [Expression =>] EXPRESSION | NAME);
1357 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1358 the attribute definition clause:
1360 @smallexample @c ada
1361 for Entity'Attribute use Expression;
1364 If @code{Attribute} is not a recognized attribute name, the pragma is
1365 ignored, and a warning is emitted. This allows source
1366 code to be written that takes advantage of some new attribute, while remaining
1367 compilable with earlier compilers.
1369 @node Pragma C_Pass_By_Copy
1370 @unnumberedsec Pragma C_Pass_By_Copy
1371 @cindex Passing by copy
1372 @findex C_Pass_By_Copy
1375 @smallexample @c ada
1376 pragma C_Pass_By_Copy
1377 ([Max_Size =>] static_integer_EXPRESSION);
1381 Normally the default mechanism for passing C convention records to C
1382 convention subprograms is to pass them by reference, as suggested by RM
1383 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1384 this default, by requiring that record formal parameters be passed by
1385 copy if all of the following conditions are met:
1389 The size of the record type does not exceed the value specified for
1392 The record type has @code{Convention C}.
1394 The formal parameter has this record type, and the subprogram has a
1395 foreign (non-Ada) convention.
1399 If these conditions are met the argument is passed by copy, i.e.@: in a
1400 manner consistent with what C expects if the corresponding formal in the
1401 C prototype is a struct (rather than a pointer to a struct).
1403 You can also pass records by copy by specifying the convention
1404 @code{C_Pass_By_Copy} for the record type, or by using the extended
1405 @code{Import} and @code{Export} pragmas, which allow specification of
1406 passing mechanisms on a parameter by parameter basis.
1409 @unnumberedsec Pragma Check
1411 @cindex Named assertions
1415 @smallexample @c ada
1417 [Name =>] Identifier,
1418 [Check =>] Boolean_EXPRESSION
1419 [, [Message =>] string_EXPRESSION] );
1423 This pragma is similar to the predefined pragma @code{Assert} except that an
1424 extra identifier argument is present. In conjunction with pragma
1425 @code{Check_Policy}, this can be used to define groups of assertions that can
1426 be independently controlled. The identifier @code{Assertion} is special, it
1427 refers to the normal set of pragma @code{Assert} statements. The identifiers
1428 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1429 names, so these three names would normally not be used directly in a pragma
1432 Checks introduced by this pragma are normally deactivated by default. They can
1433 be activated either by the command line option @option{-gnata}, which turns on
1434 all checks, or individually controlled using pragma @code{Check_Policy}.
1436 @node Pragma Check_Float_Overflow
1437 @unnumberedsec Pragma Check_Float_Overflow
1438 @cindex Floating-point overflow
1439 @findex Check_Float_Overflow
1442 @smallexample @c ada
1443 pragma Check_Float_Overflow;
1447 In Ada, the predefined floating-point types (@code{Short_Float},
1448 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1449 defined to be @emph{unconstrained}. This means that even though each
1450 has a well-defined base range, an operation that delivers a result
1451 outside this base range is not required to raise an exception.
1452 This implementation permission accommodates the notion
1453 of infinities in IEEE floating-point, and corresponds to the
1454 efficient execution mode on most machines. GNAT will not raise
1455 overflow exceptions on these machines; instead it will generate
1456 infinities and NaN's as defined in the IEEE standard.
1458 Generating infinities, although efficient, is not always desirable.
1459 Often the preferable approach is to check for overflow, even at the
1460 (perhaps considerable) expense of run-time performance.
1461 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1462 range constraints -- and indeed such a subtype
1463 can have the same base range as its base type. For example:
1465 @smallexample @c ada
1466 subtype My_Float is Float range Float'Range;
1470 Here @code{My_Float} has the same range as
1471 @code{Float} but is constrained, so operations on
1472 @code{My_Float} values will be checked for overflow
1475 This style will achieve the desired goal, but
1476 it is often more convenient to be able to simply use
1477 the standard predefined floating-point types as long
1478 as overflow checking could be guaranteed.
1479 The @code{Check_Float_Overflow}
1480 configuration pragma achieves this effect. If a unit is compiled
1481 subject to this configuration pragma, then all operations
1482 on predefined floating-point types will be treated as
1483 though those types were constrained, and overflow checks
1484 will be generated. The @code{Constraint_Error}
1485 exception is raised if the result is out of range.
1487 This mode can also be set by use of the compiler
1488 switch @option{-gnateF}.
1490 @node Pragma Check_Name
1491 @unnumberedsec Pragma Check_Name
1492 @cindex Defining check names
1493 @cindex Check names, defining
1497 @smallexample @c ada
1498 pragma Check_Name (check_name_IDENTIFIER);
1502 This is a configuration pragma that defines a new implementation
1503 defined check name (unless IDENTIFIER matches one of the predefined
1504 check names, in which case the pragma has no effect). Check names
1505 are global to a partition, so if two or more configuration pragmas
1506 are present in a partition mentioning the same name, only one new
1507 check name is introduced.
1509 An implementation defined check name introduced with this pragma may
1510 be used in only three contexts: @code{pragma Suppress},
1511 @code{pragma Unsuppress},
1512 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1513 any of these three cases, the check name must be visible. A check
1514 name is visible if it is in the configuration pragmas applying to
1515 the current unit, or if it appears at the start of any unit that
1516 is part of the dependency set of the current unit (e.g., units that
1517 are mentioned in @code{with} clauses).
1519 Check names introduced by this pragma are subject to control by compiler
1520 switches (in particular -gnatp) in the usual manner.
1522 @node Pragma Check_Policy
1523 @unnumberedsec Pragma Check_Policy
1524 @cindex Controlling assertions
1525 @cindex Assertions, control
1526 @cindex Check pragma control
1527 @cindex Named assertions
1531 @smallexample @c ada
1533 ([Name =>] Identifier,
1534 [Policy =>] POLICY_IDENTIFIER);
1536 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1540 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1541 except that it controls sets of named assertions introduced using the
1542 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1543 @code{Assertion_Policy}) can be used within a declarative part, in which case
1544 it controls the status to the end of the corresponding construct (in a manner
1545 identical to pragma @code{Suppress)}.
1547 The identifier given as the first argument corresponds to a name used in
1548 associated @code{Check} pragmas. For example, if the pragma:
1550 @smallexample @c ada
1551 pragma Check_Policy (Critical_Error, OFF);
1555 is given, then subsequent @code{Check} pragmas whose first argument is also
1556 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1557 controls the behavior of normal assertions (thus a pragma
1558 @code{Check_Policy} with this identifier is similar to the normal
1559 @code{Assertion_Policy} pragma except that it can appear within a
1562 The special identifiers @code{Precondition} and @code{Postcondition} control
1563 the status of preconditions and postconditions given as pragmas.
1564 If a @code{Precondition} pragma
1565 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1566 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1567 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1568 are recognized. Note that preconditions and postconditions given as aspects
1569 are controlled differently, either by the @code{Assertion_Policy} pragma or
1570 by the @code{Check_Policy} pragma with identifier @code{Assertion}.
1572 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1573 to turn on corresponding checks. The default for a set of checks for which no
1574 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1575 @option{-gnata} is given, which turns on all checks by default.
1577 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1578 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1579 compatibility with the standard @code{Assertion_Policy} pragma.
1581 The implementation defined policy @code{DISABLE} is like
1582 @code{OFF} except that it completely disables semantic
1583 checking of the argument to the corresponding class of
1584 pragmas. This may be useful when the pragma arguments reference
1585 subprograms in a with'ed package which is replaced by a dummy package
1586 for the final build.
1588 @node Pragma Comment
1589 @unnumberedsec Pragma Comment
1594 @smallexample @c ada
1595 pragma Comment (static_string_EXPRESSION);
1599 This is almost identical in effect to pragma @code{Ident}. It allows the
1600 placement of a comment into the object file and hence into the
1601 executable file if the operating system permits such usage. The
1602 difference is that @code{Comment}, unlike @code{Ident}, has
1603 no limitations on placement of the pragma (it can be placed
1604 anywhere in the main source unit), and if more than one pragma
1605 is used, all comments are retained.
1607 @node Pragma Common_Object
1608 @unnumberedsec Pragma Common_Object
1609 @findex Common_Object
1613 @smallexample @c ada
1614 pragma Common_Object (
1615 [Internal =>] LOCAL_NAME
1616 [, [External =>] EXTERNAL_SYMBOL]
1617 [, [Size =>] EXTERNAL_SYMBOL] );
1621 | static_string_EXPRESSION
1625 This pragma enables the shared use of variables stored in overlaid
1626 linker areas corresponding to the use of @code{COMMON}
1627 in Fortran. The single
1628 object @var{LOCAL_NAME} is assigned to the area designated by
1629 the @var{External} argument.
1630 You may define a record to correspond to a series
1631 of fields. The @var{Size} argument
1632 is syntax checked in GNAT, but otherwise ignored.
1634 @code{Common_Object} is not supported on all platforms. If no
1635 support is available, then the code generator will issue a message
1636 indicating that the necessary attribute for implementation of this
1637 pragma is not available.
1639 @node Pragma Compile_Time_Error
1640 @unnumberedsec Pragma Compile_Time_Error
1641 @findex Compile_Time_Error
1645 @smallexample @c ada
1646 pragma Compile_Time_Error
1647 (boolean_EXPRESSION, static_string_EXPRESSION);
1651 This pragma can be used to generate additional compile time
1653 is particularly useful in generics, where errors can be issued for
1654 specific problematic instantiations. The first parameter is a boolean
1655 expression. The pragma is effective only if the value of this expression
1656 is known at compile time, and has the value True. The set of expressions
1657 whose values are known at compile time includes all static boolean
1658 expressions, and also other values which the compiler can determine
1659 at compile time (e.g., the size of a record type set by an explicit
1660 size representation clause, or the value of a variable which was
1661 initialized to a constant and is known not to have been modified).
1662 If these conditions are met, an error message is generated using
1663 the value given as the second argument. This string value may contain
1664 embedded ASCII.LF characters to break the message into multiple lines.
1666 @node Pragma Compile_Time_Warning
1667 @unnumberedsec Pragma Compile_Time_Warning
1668 @findex Compile_Time_Warning
1672 @smallexample @c ada
1673 pragma Compile_Time_Warning
1674 (boolean_EXPRESSION, static_string_EXPRESSION);
1678 Same as pragma Compile_Time_Error, except a warning is issued instead
1679 of an error message. Note that if this pragma is used in a package that
1680 is with'ed by a client, the client will get the warning even though it
1681 is issued by a with'ed package (normally warnings in with'ed units are
1682 suppressed, but this is a special exception to that rule).
1684 One typical use is within a generic where compile time known characteristics
1685 of formal parameters are tested, and warnings given appropriately. Another use
1686 with a first parameter of True is to warn a client about use of a package,
1687 for example that it is not fully implemented.
1689 @node Pragma Compiler_Unit
1690 @unnumberedsec Pragma Compiler_Unit
1691 @findex Compiler_Unit
1695 @smallexample @c ada
1696 pragma Compiler_Unit;
1700 This pragma is intended only for internal use in the GNAT run-time library.
1701 It indicates that the unit is used as part of the compiler build. The effect
1702 is to disallow constructs (raise with message, conditional expressions etc)
1703 that would cause trouble when bootstrapping using an older version of GNAT.
1704 For the exact list of restrictions, see the compiler sources and references
1705 to Is_Compiler_Unit.
1707 @node Pragma Complete_Representation
1708 @unnumberedsec Pragma Complete_Representation
1709 @findex Complete_Representation
1713 @smallexample @c ada
1714 pragma Complete_Representation;
1718 This pragma must appear immediately within a record representation
1719 clause. Typical placements are before the first component clause
1720 or after the last component clause. The effect is to give an error
1721 message if any component is missing a component clause. This pragma
1722 may be used to ensure that a record representation clause is
1723 complete, and that this invariant is maintained if fields are
1724 added to the record in the future.
1726 @node Pragma Complex_Representation
1727 @unnumberedsec Pragma Complex_Representation
1728 @findex Complex_Representation
1732 @smallexample @c ada
1733 pragma Complex_Representation
1734 ([Entity =>] LOCAL_NAME);
1738 The @var{Entity} argument must be the name of a record type which has
1739 two fields of the same floating-point type. The effect of this pragma is
1740 to force gcc to use the special internal complex representation form for
1741 this record, which may be more efficient. Note that this may result in
1742 the code for this type not conforming to standard ABI (application
1743 binary interface) requirements for the handling of record types. For
1744 example, in some environments, there is a requirement for passing
1745 records by pointer, and the use of this pragma may result in passing
1746 this type in floating-point registers.
1748 @node Pragma Component_Alignment
1749 @unnumberedsec Pragma Component_Alignment
1750 @cindex Alignments of components
1751 @findex Component_Alignment
1755 @smallexample @c ada
1756 pragma Component_Alignment (
1757 [Form =>] ALIGNMENT_CHOICE
1758 [, [Name =>] type_LOCAL_NAME]);
1760 ALIGNMENT_CHOICE ::=
1768 Specifies the alignment of components in array or record types.
1769 The meaning of the @var{Form} argument is as follows:
1772 @findex Component_Size
1773 @item Component_Size
1774 Aligns scalar components and subcomponents of the array or record type
1775 on boundaries appropriate to their inherent size (naturally
1776 aligned). For example, 1-byte components are aligned on byte boundaries,
1777 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1778 integer components are aligned on 4-byte boundaries and so on. These
1779 alignment rules correspond to the normal rules for C compilers on all
1780 machines except the VAX@.
1782 @findex Component_Size_4
1783 @item Component_Size_4
1784 Naturally aligns components with a size of four or fewer
1785 bytes. Components that are larger than 4 bytes are placed on the next
1788 @findex Storage_Unit
1790 Specifies that array or record components are byte aligned, i.e.@:
1791 aligned on boundaries determined by the value of the constant
1792 @code{System.Storage_Unit}.
1796 Specifies that array or record components are aligned on default
1797 boundaries, appropriate to the underlying hardware or operating system or
1798 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1799 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1800 the @code{Default} choice is the same as @code{Component_Size} (natural
1805 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1806 refer to a local record or array type, and the specified alignment
1807 choice applies to the specified type. The use of
1808 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1809 @code{Component_Alignment} pragma to be ignored. The use of
1810 @code{Component_Alignment} together with a record representation clause
1811 is only effective for fields not specified by the representation clause.
1813 If the @code{Name} parameter is absent, the pragma can be used as either
1814 a configuration pragma, in which case it applies to one or more units in
1815 accordance with the normal rules for configuration pragmas, or it can be
1816 used within a declarative part, in which case it applies to types that
1817 are declared within this declarative part, or within any nested scope
1818 within this declarative part. In either case it specifies the alignment
1819 to be applied to any record or array type which has otherwise standard
1822 If the alignment for a record or array type is not specified (using
1823 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1824 clause), the GNAT uses the default alignment as described previously.
1826 @node Pragma Contract_Case
1827 @unnumberedsec Pragma Contract_Case
1828 @cindex Contract cases
1829 @findex Contract_Case
1833 @smallexample @c ada
1834 pragma Contract_Case (
1835 [Name =>] static_string_Expression
1836 ,[Mode =>] (Nominal | Robustness)
1837 [, Requires => Boolean_Expression]
1838 [, Ensures => Boolean_Expression]);
1842 The @code{Contract_Case} pragma allows defining fine-grain specifications
1843 that can complement or replace the contract given by a precondition and a
1844 postcondition. Additionally, the @code{Contract_Case} pragma can be used
1845 by testing and formal verification tools. The compiler checks its validity and,
1846 depending on the assertion policy at the point of declaration of the pragma,
1847 it may insert a check in the executable. For code generation, the contract
1850 @smallexample @c ada
1851 pragma Contract_Case (
1861 @smallexample @c ada
1862 pragma Postcondition (not R'Old or else E);
1866 which is also equivalent to (in Ada 2012)
1868 @smallexample @c ada
1869 pragma Postcondition (if R'Old then E);
1873 expressing that, whenever condition @code{R} is satisfied on entry to the
1874 subprogram, condition @code{E} should be fulfilled on exit to the subprogram.
1876 A precondition @code{P} and postcondition @code{Q} can also be
1877 expressed as contract cases:
1879 @smallexample @c ada
1880 pragma Contract_Case (
1881 Name => "Replace precondition",
1885 pragma Contract_Case (
1886 Name => "Replace postcondition",
1892 @code{Contract_Case} pragmas may only appear immediately following the
1893 (separate) declaration of a subprogram in a package declaration, inside
1894 a package spec unit. Only other pragmas may intervene (that is appear
1895 between the subprogram declaration and a contract case).
1897 The compiler checks that boolean expressions given in @code{Requires} and
1898 @code{Ensures} are valid, where the rules for @code{Requires} are the
1899 same as the rule for an expression in @code{Precondition} and the rules
1900 for @code{Ensures} are the same as the rule for an expression in
1901 @code{Postcondition}. In particular, attributes @code{'Old} and
1902 @code{'Result} can only be used within the @code{Ensures}
1903 expression. The following is an example of use within a package spec:
1905 @smallexample @c ada
1906 package Math_Functions is
1908 function Sqrt (Arg : Float) return Float;
1909 pragma Contract_Case (Name => "Small argument",
1911 Requires => Arg < 100,
1912 Ensures => Sqrt'Result < 10);
1918 The meaning of a contract case is that, whenever the associated subprogram is
1919 executed in a context where @code{Requires} holds, then @code{Ensures}
1920 should hold when the subprogram returns. Mode @code{Nominal} indicates
1921 that the input context should also satisfy the precondition of the
1922 subprogram, and the output context should also satisfy its
1923 postcondition. More @code{Robustness} indicates that the precondition and
1924 postcondition of the subprogram should be ignored for this contract case,
1925 which is mostly useful when testing such a contract using a testing tool
1926 that understands contract cases.
1928 @node Pragma Convention_Identifier
1929 @unnumberedsec Pragma Convention_Identifier
1930 @findex Convention_Identifier
1931 @cindex Conventions, synonyms
1935 @smallexample @c ada
1936 pragma Convention_Identifier (
1937 [Name =>] IDENTIFIER,
1938 [Convention =>] convention_IDENTIFIER);
1942 This pragma provides a mechanism for supplying synonyms for existing
1943 convention identifiers. The @code{Name} identifier can subsequently
1944 be used as a synonym for the given convention in other pragmas (including
1945 for example pragma @code{Import} or another @code{Convention_Identifier}
1946 pragma). As an example of the use of this, suppose you had legacy code
1947 which used Fortran77 as the identifier for Fortran. Then the pragma:
1949 @smallexample @c ada
1950 pragma Convention_Identifier (Fortran77, Fortran);
1954 would allow the use of the convention identifier @code{Fortran77} in
1955 subsequent code, avoiding the need to modify the sources. As another
1956 example, you could use this to parameterize convention requirements
1957 according to systems. Suppose you needed to use @code{Stdcall} on
1958 windows systems, and @code{C} on some other system, then you could
1959 define a convention identifier @code{Library} and use a single
1960 @code{Convention_Identifier} pragma to specify which convention
1961 would be used system-wide.
1963 @node Pragma CPP_Class
1964 @unnumberedsec Pragma CPP_Class
1966 @cindex Interfacing with C++
1970 @smallexample @c ada
1971 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1975 The argument denotes an entity in the current declarative region that is
1976 declared as a record type. It indicates that the type corresponds to an
1977 externally declared C++ class type, and is to be laid out the same way
1978 that C++ would lay out the type. If the C++ class has virtual primitives
1979 then the record must be declared as a tagged record type.
1981 Types for which @code{CPP_Class} is specified do not have assignment or
1982 equality operators defined (such operations can be imported or declared
1983 as subprograms as required). Initialization is allowed only by constructor
1984 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1985 limited if not explicitly declared as limited or derived from a limited
1986 type, and an error is issued in that case.
1988 See @ref{Interfacing to C++} for related information.
1990 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1991 for backward compatibility but its functionality is available
1992 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1994 @node Pragma CPP_Constructor
1995 @unnumberedsec Pragma CPP_Constructor
1996 @cindex Interfacing with C++
1997 @findex CPP_Constructor
2001 @smallexample @c ada
2002 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2003 [, [External_Name =>] static_string_EXPRESSION ]
2004 [, [Link_Name =>] static_string_EXPRESSION ]);
2008 This pragma identifies an imported function (imported in the usual way
2009 with pragma @code{Import}) as corresponding to a C++ constructor. If
2010 @code{External_Name} and @code{Link_Name} are not specified then the
2011 @code{Entity} argument is a name that must have been previously mentioned
2012 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2013 must be of one of the following forms:
2017 @code{function @var{Fname} return @var{T}}
2021 @code{function @var{Fname} return @var{T}'Class}
2024 @code{function @var{Fname} (@dots{}) return @var{T}}
2028 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2032 where @var{T} is a limited record type imported from C++ with pragma
2033 @code{Import} and @code{Convention} = @code{CPP}.
2035 The first two forms import the default constructor, used when an object
2036 of type @var{T} is created on the Ada side with no explicit constructor.
2037 The latter two forms cover all the non-default constructors of the type.
2038 See the @value{EDITION} User's Guide for details.
2040 If no constructors are imported, it is impossible to create any objects
2041 on the Ada side and the type is implicitly declared abstract.
2043 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2044 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2046 See @ref{Interfacing to C++} for more related information.
2048 Note: The use of functions returning class-wide types for constructors is
2049 currently obsolete. They are supported for backward compatibility. The
2050 use of functions returning the type T leave the Ada sources more clear
2051 because the imported C++ constructors always return an object of type T;
2052 that is, they never return an object whose type is a descendant of type T.
2054 @node Pragma CPP_Virtual
2055 @unnumberedsec Pragma CPP_Virtual
2056 @cindex Interfacing to C++
2059 This pragma is now obsolete has has no effect because GNAT generates
2060 the same object layout than the G++ compiler.
2062 See @ref{Interfacing to C++} for related information.
2064 @node Pragma CPP_Vtable
2065 @unnumberedsec Pragma CPP_Vtable
2066 @cindex Interfacing with C++
2069 This pragma is now obsolete has has no effect because GNAT generates
2070 the same object layout than the G++ compiler.
2072 See @ref{Interfacing to C++} for related information.
2075 @unnumberedsec Pragma CPU
2080 @smallexample @c ada
2081 pragma CPU (EXPRESSSION);
2085 This pragma is standard in Ada 2012, but is available in all earlier
2086 versions of Ada as an implementation-defined pragma.
2087 See Ada 2012 Reference Manual for details.
2090 @unnumberedsec Pragma Debug
2095 @smallexample @c ada
2096 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2098 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2100 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2104 The procedure call argument has the syntactic form of an expression, meeting
2105 the syntactic requirements for pragmas.
2107 If debug pragmas are not enabled or if the condition is present and evaluates
2108 to False, this pragma has no effect. If debug pragmas are enabled, the
2109 semantics of the pragma is exactly equivalent to the procedure call statement
2110 corresponding to the argument with a terminating semicolon. Pragmas are
2111 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2112 intersperse calls to debug procedures in the middle of declarations. Debug
2113 pragmas can be enabled either by use of the command line switch @option{-gnata}
2114 or by use of the configuration pragma @code{Debug_Policy}.
2116 @node Pragma Debug_Policy
2117 @unnumberedsec Pragma Debug_Policy
2118 @findex Debug_Policy
2122 @smallexample @c ada
2123 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
2127 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
2128 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
2129 This pragma overrides the effect of the @option{-gnata} switch on the
2132 The implementation defined policy @code{DISABLE} is like
2133 @code{IGNORE} except that it completely disables semantic
2134 checking of the argument to @code{pragma Debug}. This may
2135 be useful when the pragma argument references subprograms
2136 in a with'ed package which is replaced by a dummy package
2137 for the final build.
2139 @node Pragma Default_Storage_Pool
2140 @unnumberedsec Pragma Default_Storage_Pool
2141 @findex Default_Storage_Pool
2145 @smallexample @c ada
2146 pragma Default_Storage_Pool (storage_pool_NAME | null);
2150 This pragma is standard in Ada 2012, but is available in all earlier
2151 versions of Ada as an implementation-defined pragma.
2152 See Ada 2012 Reference Manual for details.
2154 @node Pragma Detect_Blocking
2155 @unnumberedsec Pragma Detect_Blocking
2156 @findex Detect_Blocking
2160 @smallexample @c ada
2161 pragma Detect_Blocking;
2165 This is a standard pragma in Ada 2005, that is available in all earlier
2166 versions of Ada as an implementation-defined pragma.
2168 This is a configuration pragma that forces the detection of potentially
2169 blocking operations within a protected operation, and to raise Program_Error
2172 @node Pragma Dispatching_Domain
2173 @unnumberedsec Pragma Dispatching_Domain
2174 @findex Dispatching_Domain
2178 @smallexample @c ada
2179 pragma Dispatching_Domain (EXPRESSION);
2183 This pragma is standard in Ada 2012, but is available in all earlier
2184 versions of Ada as an implementation-defined pragma.
2185 See Ada 2012 Reference Manual for details.
2187 @node Pragma Elaboration_Checks
2188 @unnumberedsec Pragma Elaboration_Checks
2189 @cindex Elaboration control
2190 @findex Elaboration_Checks
2194 @smallexample @c ada
2195 pragma Elaboration_Checks (Dynamic | Static);
2199 This is a configuration pragma that provides control over the
2200 elaboration model used by the compilation affected by the
2201 pragma. If the parameter is @code{Dynamic},
2202 then the dynamic elaboration
2203 model described in the Ada Reference Manual is used, as though
2204 the @option{-gnatE} switch had been specified on the command
2205 line. If the parameter is @code{Static}, then the default GNAT static
2206 model is used. This configuration pragma overrides the setting
2207 of the command line. For full details on the elaboration models
2208 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2209 gnat_ugn, @value{EDITION} User's Guide}.
2211 @node Pragma Eliminate
2212 @unnumberedsec Pragma Eliminate
2213 @cindex Elimination of unused subprograms
2218 @smallexample @c ada
2219 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2220 [Source_Location =>] STRING_LITERAL);
2224 The string literal given for the source location is a string which
2225 specifies the line number of the occurrence of the entity, using
2226 the syntax for SOURCE_TRACE given below:
2228 @smallexample @c ada
2229 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2234 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2236 LINE_NUMBER ::= DIGIT @{DIGIT@}
2240 Spaces around the colon in a @code{Source_Reference} are optional.
2242 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2243 explicit subprogram declaration, where the @code{entity} name in this
2244 designator appears on the source line specified by the source location.
2246 The source trace that is given as the @code{Source_Location} shall obey the
2247 following rules. The @code{FILE_NAME} is the short name (with no directory
2248 information) of an Ada source file, given using exactly the required syntax
2249 for the underlying file system (e.g. case is important if the underlying
2250 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2251 number of the occurrence of the @code{entity}
2252 as a decimal literal without an exponent or point. If an @code{entity} is not
2253 declared in a generic instantiation (this includes generic subprogram
2254 instances), the source trace includes only one source reference. If an entity
2255 is declared inside a generic instantiation, its source trace (when parsing
2256 from left to right) starts with the source location of the declaration of the
2257 entity in the generic unit and ends with the source location of the
2258 instantiation (it is given in square brackets). This approach is recursively
2259 used in case of nested instantiations: the rightmost (nested most deeply in
2260 square brackets) element of the source trace is the location of the outermost
2261 instantiation, the next to left element is the location of the next (first
2262 nested) instantiation in the code of the corresponding generic unit, and so
2263 on, and the leftmost element (that is out of any square brackets) is the
2264 location of the declaration of the entity to eliminate in a generic unit.
2266 Note that the @code{Source_Location} argument specifies which of a set of
2267 similarly named entities is being eliminated, dealing both with overloading,
2268 and also appearence of the same entity name in different scopes.
2270 This pragma indicates that the given entity is not used in the program to be
2271 compiled and built. The effect of the pragma is to allow the compiler to
2272 eliminate the code or data associated with the named entity. Any reference to
2273 an eliminated entity causes a compile-time or link-time error.
2275 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2276 in a system-independent manner, with unused entities eliminated, without
2277 needing to modify the source text. Normally the required set of
2278 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2280 Any source file change that removes, splits, or
2281 adds lines may make the set of Eliminate pragmas invalid because their
2282 @code{Source_Location} argument values may get out of date.
2284 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2285 operation. In this case all the subprograms to which the given operation can
2286 dispatch are considered to be unused (are never called as a result of a direct
2287 or a dispatching call).
2289 @node Pragma Export_Exception
2290 @unnumberedsec Pragma Export_Exception
2292 @findex Export_Exception
2296 @smallexample @c ada
2297 pragma Export_Exception (
2298 [Internal =>] LOCAL_NAME
2299 [, [External =>] EXTERNAL_SYMBOL]
2300 [, [Form =>] Ada | VMS]
2301 [, [Code =>] static_integer_EXPRESSION]);
2305 | static_string_EXPRESSION
2309 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2310 causes the specified exception to be propagated outside of the Ada program,
2311 so that it can be handled by programs written in other OpenVMS languages.
2312 This pragma establishes an external name for an Ada exception and makes the
2313 name available to the OpenVMS Linker as a global symbol. For further details
2314 on this pragma, see the
2315 DEC Ada Language Reference Manual, section 13.9a3.2.
2317 @node Pragma Export_Function
2318 @unnumberedsec Pragma Export_Function
2319 @cindex Argument passing mechanisms
2320 @findex Export_Function
2325 @smallexample @c ada
2326 pragma Export_Function (
2327 [Internal =>] LOCAL_NAME
2328 [, [External =>] EXTERNAL_SYMBOL]
2329 [, [Parameter_Types =>] PARAMETER_TYPES]
2330 [, [Result_Type =>] result_SUBTYPE_MARK]
2331 [, [Mechanism =>] MECHANISM]
2332 [, [Result_Mechanism =>] MECHANISM_NAME]);
2336 | static_string_EXPRESSION
2341 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2345 | subtype_Name ' Access
2349 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2351 MECHANISM_ASSOCIATION ::=
2352 [formal_parameter_NAME =>] MECHANISM_NAME
2357 | Descriptor [([Class =>] CLASS_NAME)]
2358 | Short_Descriptor [([Class =>] CLASS_NAME)]
2360 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2364 Use this pragma to make a function externally callable and optionally
2365 provide information on mechanisms to be used for passing parameter and
2366 result values. We recommend, for the purposes of improving portability,
2367 this pragma always be used in conjunction with a separate pragma
2368 @code{Export}, which must precede the pragma @code{Export_Function}.
2369 GNAT does not require a separate pragma @code{Export}, but if none is
2370 present, @code{Convention Ada} is assumed, which is usually
2371 not what is wanted, so it is usually appropriate to use this
2372 pragma in conjunction with a @code{Export} or @code{Convention}
2373 pragma that specifies the desired foreign convention.
2374 Pragma @code{Export_Function}
2375 (and @code{Export}, if present) must appear in the same declarative
2376 region as the function to which they apply.
2378 @var{internal_name} must uniquely designate the function to which the
2379 pragma applies. If more than one function name exists of this name in
2380 the declarative part you must use the @code{Parameter_Types} and
2381 @code{Result_Type} parameters is mandatory to achieve the required
2382 unique designation. @var{subtype_mark}s in these parameters must
2383 exactly match the subtypes in the corresponding function specification,
2384 using positional notation to match parameters with subtype marks.
2385 The form with an @code{'Access} attribute can be used to match an
2386 anonymous access parameter.
2389 @cindex Passing by descriptor
2390 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2391 The default behavior for Export_Function is to accept either 64bit or
2392 32bit descriptors unless short_descriptor is specified, then only 32bit
2393 descriptors are accepted.
2395 @cindex Suppressing external name
2396 Special treatment is given if the EXTERNAL is an explicit null
2397 string or a static string expressions that evaluates to the null
2398 string. In this case, no external name is generated. This form
2399 still allows the specification of parameter mechanisms.
2401 @node Pragma Export_Object
2402 @unnumberedsec Pragma Export_Object
2403 @findex Export_Object
2407 @smallexample @c ada
2408 pragma Export_Object
2409 [Internal =>] LOCAL_NAME
2410 [, [External =>] EXTERNAL_SYMBOL]
2411 [, [Size =>] EXTERNAL_SYMBOL]
2415 | static_string_EXPRESSION
2419 This pragma designates an object as exported, and apart from the
2420 extended rules for external symbols, is identical in effect to the use of
2421 the normal @code{Export} pragma applied to an object. You may use a
2422 separate Export pragma (and you probably should from the point of view
2423 of portability), but it is not required. @var{Size} is syntax checked,
2424 but otherwise ignored by GNAT@.
2426 @node Pragma Export_Procedure
2427 @unnumberedsec Pragma Export_Procedure
2428 @findex Export_Procedure
2432 @smallexample @c ada
2433 pragma Export_Procedure (
2434 [Internal =>] LOCAL_NAME
2435 [, [External =>] EXTERNAL_SYMBOL]
2436 [, [Parameter_Types =>] PARAMETER_TYPES]
2437 [, [Mechanism =>] MECHANISM]);
2441 | static_string_EXPRESSION
2446 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2450 | subtype_Name ' Access
2454 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2456 MECHANISM_ASSOCIATION ::=
2457 [formal_parameter_NAME =>] MECHANISM_NAME
2462 | Descriptor [([Class =>] CLASS_NAME)]
2463 | Short_Descriptor [([Class =>] CLASS_NAME)]
2465 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2469 This pragma is identical to @code{Export_Function} except that it
2470 applies to a procedure rather than a function and the parameters
2471 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2472 GNAT does not require a separate pragma @code{Export}, but if none is
2473 present, @code{Convention Ada} is assumed, which is usually
2474 not what is wanted, so it is usually appropriate to use this
2475 pragma in conjunction with a @code{Export} or @code{Convention}
2476 pragma that specifies the desired foreign convention.
2479 @cindex Passing by descriptor
2480 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2481 The default behavior for Export_Procedure is to accept either 64bit or
2482 32bit descriptors unless short_descriptor is specified, then only 32bit
2483 descriptors are accepted.
2485 @cindex Suppressing external name
2486 Special treatment is given if the EXTERNAL is an explicit null
2487 string or a static string expressions that evaluates to the null
2488 string. In this case, no external name is generated. This form
2489 still allows the specification of parameter mechanisms.
2491 @node Pragma Export_Value
2492 @unnumberedsec Pragma Export_Value
2493 @findex Export_Value
2497 @smallexample @c ada
2498 pragma Export_Value (
2499 [Value =>] static_integer_EXPRESSION,
2500 [Link_Name =>] static_string_EXPRESSION);
2504 This pragma serves to export a static integer value for external use.
2505 The first argument specifies the value to be exported. The Link_Name
2506 argument specifies the symbolic name to be associated with the integer
2507 value. This pragma is useful for defining a named static value in Ada
2508 that can be referenced in assembly language units to be linked with
2509 the application. This pragma is currently supported only for the
2510 AAMP target and is ignored for other targets.
2512 @node Pragma Export_Valued_Procedure
2513 @unnumberedsec Pragma Export_Valued_Procedure
2514 @findex Export_Valued_Procedure
2518 @smallexample @c ada
2519 pragma Export_Valued_Procedure (
2520 [Internal =>] LOCAL_NAME
2521 [, [External =>] EXTERNAL_SYMBOL]
2522 [, [Parameter_Types =>] PARAMETER_TYPES]
2523 [, [Mechanism =>] MECHANISM]);
2527 | static_string_EXPRESSION
2532 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2536 | subtype_Name ' Access
2540 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2542 MECHANISM_ASSOCIATION ::=
2543 [formal_parameter_NAME =>] MECHANISM_NAME
2548 | Descriptor [([Class =>] CLASS_NAME)]
2549 | Short_Descriptor [([Class =>] CLASS_NAME)]
2551 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2555 This pragma is identical to @code{Export_Procedure} except that the
2556 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2557 mode @code{OUT}, and externally the subprogram is treated as a function
2558 with this parameter as the result of the function. GNAT provides for
2559 this capability to allow the use of @code{OUT} and @code{IN OUT}
2560 parameters in interfacing to external functions (which are not permitted
2562 GNAT does not require a separate pragma @code{Export}, but if none is
2563 present, @code{Convention Ada} is assumed, which is almost certainly
2564 not what is wanted since the whole point of this pragma is to interface
2565 with foreign language functions, so it is usually appropriate to use this
2566 pragma in conjunction with a @code{Export} or @code{Convention}
2567 pragma that specifies the desired foreign convention.
2570 @cindex Passing by descriptor
2571 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2572 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2573 32bit descriptors unless short_descriptor is specified, then only 32bit
2574 descriptors are accepted.
2576 @cindex Suppressing external name
2577 Special treatment is given if the EXTERNAL is an explicit null
2578 string or a static string expressions that evaluates to the null
2579 string. In this case, no external name is generated. This form
2580 still allows the specification of parameter mechanisms.
2582 @node Pragma Extend_System
2583 @unnumberedsec Pragma Extend_System
2584 @cindex @code{system}, extending
2586 @findex Extend_System
2590 @smallexample @c ada
2591 pragma Extend_System ([Name =>] IDENTIFIER);
2595 This pragma is used to provide backwards compatibility with other
2596 implementations that extend the facilities of package @code{System}. In
2597 GNAT, @code{System} contains only the definitions that are present in
2598 the Ada RM@. However, other implementations, notably the DEC Ada 83
2599 implementation, provide many extensions to package @code{System}.
2601 For each such implementation accommodated by this pragma, GNAT provides a
2602 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2603 implementation, which provides the required additional definitions. You
2604 can use this package in two ways. You can @code{with} it in the normal
2605 way and access entities either by selection or using a @code{use}
2606 clause. In this case no special processing is required.
2608 However, if existing code contains references such as
2609 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2610 definitions provided in package @code{System}, you may use this pragma
2611 to extend visibility in @code{System} in a non-standard way that
2612 provides greater compatibility with the existing code. Pragma
2613 @code{Extend_System} is a configuration pragma whose single argument is
2614 the name of the package containing the extended definition
2615 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2616 control of this pragma will be processed using special visibility
2617 processing that looks in package @code{System.Aux_@var{xxx}} where
2618 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2619 package @code{System}, but not found in package @code{System}.
2621 You can use this pragma either to access a predefined @code{System}
2622 extension supplied with the compiler, for example @code{Aux_DEC} or
2623 you can construct your own extension unit following the above
2624 definition. Note that such a package is a child of @code{System}
2625 and thus is considered part of the implementation. To compile
2626 it you will have to use the appropriate switch for compiling
2628 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2631 @node Pragma Extensions_Allowed
2632 @unnumberedsec Pragma Extensions_Allowed
2633 @cindex Ada Extensions
2634 @cindex GNAT Extensions
2635 @findex Extensions_Allowed
2639 @smallexample @c ada
2640 pragma Extensions_Allowed (On | Off);
2644 This configuration pragma enables or disables the implementation
2645 extension mode (the use of Off as a parameter cancels the effect
2646 of the @option{-gnatX} command switch).
2648 In extension mode, the latest version of the Ada language is
2649 implemented (currently Ada 2012), and in addition a small number
2650 of GNAT specific extensions are recognized as follows:
2653 @item Constrained attribute for generic objects
2654 The @code{Constrained} attribute is permitted for objects of
2655 generic types. The result indicates if the corresponding actual
2660 @node Pragma External
2661 @unnumberedsec Pragma External
2666 @smallexample @c ada
2668 [ Convention =>] convention_IDENTIFIER,
2669 [ Entity =>] LOCAL_NAME
2670 [, [External_Name =>] static_string_EXPRESSION ]
2671 [, [Link_Name =>] static_string_EXPRESSION ]);
2675 This pragma is identical in syntax and semantics to pragma
2676 @code{Export} as defined in the Ada Reference Manual. It is
2677 provided for compatibility with some Ada 83 compilers that
2678 used this pragma for exactly the same purposes as pragma
2679 @code{Export} before the latter was standardized.
2681 @node Pragma External_Name_Casing
2682 @unnumberedsec Pragma External_Name_Casing
2683 @cindex Dec Ada 83 casing compatibility
2684 @cindex External Names, casing
2685 @cindex Casing of External names
2686 @findex External_Name_Casing
2690 @smallexample @c ada
2691 pragma External_Name_Casing (
2692 Uppercase | Lowercase
2693 [, Uppercase | Lowercase | As_Is]);
2697 This pragma provides control over the casing of external names associated
2698 with Import and Export pragmas. There are two cases to consider:
2701 @item Implicit external names
2702 Implicit external names are derived from identifiers. The most common case
2703 arises when a standard Ada Import or Export pragma is used with only two
2706 @smallexample @c ada
2707 pragma Import (C, C_Routine);
2711 Since Ada is a case-insensitive language, the spelling of the identifier in
2712 the Ada source program does not provide any information on the desired
2713 casing of the external name, and so a convention is needed. In GNAT the
2714 default treatment is that such names are converted to all lower case
2715 letters. This corresponds to the normal C style in many environments.
2716 The first argument of pragma @code{External_Name_Casing} can be used to
2717 control this treatment. If @code{Uppercase} is specified, then the name
2718 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2719 then the normal default of all lower case letters will be used.
2721 This same implicit treatment is also used in the case of extended DEC Ada 83
2722 compatible Import and Export pragmas where an external name is explicitly
2723 specified using an identifier rather than a string.
2725 @item Explicit external names
2726 Explicit external names are given as string literals. The most common case
2727 arises when a standard Ada Import or Export pragma is used with three
2730 @smallexample @c ada
2731 pragma Import (C, C_Routine, "C_routine");
2735 In this case, the string literal normally provides the exact casing required
2736 for the external name. The second argument of pragma
2737 @code{External_Name_Casing} may be used to modify this behavior.
2738 If @code{Uppercase} is specified, then the name
2739 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2740 then the name will be forced to all lowercase letters. A specification of
2741 @code{As_Is} provides the normal default behavior in which the casing is
2742 taken from the string provided.
2746 This pragma may appear anywhere that a pragma is valid. In particular, it
2747 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2748 case it applies to all subsequent compilations, or it can be used as a program
2749 unit pragma, in which case it only applies to the current unit, or it can
2750 be used more locally to control individual Import/Export pragmas.
2752 It is primarily intended for use with OpenVMS systems, where many
2753 compilers convert all symbols to upper case by default. For interfacing to
2754 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2757 @smallexample @c ada
2758 pragma External_Name_Casing (Uppercase, Uppercase);
2762 to enforce the upper casing of all external symbols.
2764 @node Pragma Fast_Math
2765 @unnumberedsec Pragma Fast_Math
2770 @smallexample @c ada
2775 This is a configuration pragma which activates a mode in which speed is
2776 considered more important for floating-point operations than absolutely
2777 accurate adherence to the requirements of the standard. Currently the
2778 following operations are affected:
2781 @item Complex Multiplication
2782 The normal simple formula for complex multiplication can result in intermediate
2783 overflows for numbers near the end of the range. The Ada standard requires that
2784 this situation be detected and corrected by scaling, but in Fast_Math mode such
2785 cases will simply result in overflow. Note that to take advantage of this you
2786 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2787 under control of the pragma, rather than use the preinstantiated versions.
2790 @node Pragma Favor_Top_Level
2791 @unnumberedsec Pragma Favor_Top_Level
2792 @findex Favor_Top_Level
2796 @smallexample @c ada
2797 pragma Favor_Top_Level (type_NAME);
2801 The named type must be an access-to-subprogram type. This pragma is an
2802 efficiency hint to the compiler, regarding the use of 'Access or
2803 'Unrestricted_Access on nested (non-library-level) subprograms. The
2804 pragma means that nested subprograms are not used with this type, or
2805 are rare, so that the generated code should be efficient in the
2806 top-level case. When this pragma is used, dynamically generated
2807 trampolines may be used on some targets for nested subprograms.
2808 See also the No_Implicit_Dynamic_Code restriction.
2810 @node Pragma Finalize_Storage_Only
2811 @unnumberedsec Pragma Finalize_Storage_Only
2812 @findex Finalize_Storage_Only
2816 @smallexample @c ada
2817 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2821 This pragma allows the compiler not to emit a Finalize call for objects
2822 defined at the library level. This is mostly useful for types where
2823 finalization is only used to deal with storage reclamation since in most
2824 environments it is not necessary to reclaim memory just before terminating
2825 execution, hence the name.
2827 @node Pragma Float_Representation
2828 @unnumberedsec Pragma Float_Representation
2830 @findex Float_Representation
2834 @smallexample @c ada
2835 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2837 FLOAT_REP ::= VAX_Float | IEEE_Float
2841 In the one argument form, this pragma is a configuration pragma which
2842 allows control over the internal representation chosen for the predefined
2843 floating point types declared in the packages @code{Standard} and
2844 @code{System}. On all systems other than OpenVMS, the argument must
2845 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2846 argument may be @code{VAX_Float} to specify the use of the VAX float
2847 format for the floating-point types in Standard. This requires that
2848 the standard runtime libraries be recompiled.
2850 The two argument form specifies the representation to be used for
2851 the specified floating-point type. On all systems other than OpenVMS,
2853 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2854 argument may be @code{VAX_Float} to specify the use of the VAX float
2859 For digits values up to 6, F float format will be used.
2861 For digits values from 7 to 9, D float format will be used.
2863 For digits values from 10 to 15, G float format will be used.
2865 Digits values above 15 are not allowed.
2869 @unnumberedsec Pragma Ident
2874 @smallexample @c ada
2875 pragma Ident (static_string_EXPRESSION);
2879 This pragma provides a string identification in the generated object file,
2880 if the system supports the concept of this kind of identification string.
2881 This pragma is allowed only in the outermost declarative part or
2882 declarative items of a compilation unit. If more than one @code{Ident}
2883 pragma is given, only the last one processed is effective.
2885 On OpenVMS systems, the effect of the pragma is identical to the effect of
2886 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2887 maximum allowed length is 31 characters, so if it is important to
2888 maintain compatibility with this compiler, you should obey this length
2891 @node Pragma Implementation_Defined
2892 @unnumberedsec Pragma Implementation_Defined
2893 @findex Implementation_Defined
2897 @smallexample @c ada
2898 pragma Implementation_Defined (local_NAME);
2902 This pragma marks a previously declared entioty as implementation-defined.
2903 For an overloaded entity, applies to the most recent homonym.
2905 @smallexample @c ada
2906 pragma Implementation_Defined;
2910 The form with no arguments appears anywhere within a scope, most
2911 typically a package spec, and indicates that all entities that are
2912 defined within the package spec are Implementation_Defined.
2914 This pragma is used within the GNAT runtime library to identify
2915 implementation-defined entities introduced in language-defined units,
2916 for the purpose of implementing the No_Implementation_Identifiers
2919 @node Pragma Implemented
2920 @unnumberedsec Pragma Implemented
2925 @smallexample @c ada
2926 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2928 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2932 This is an Ada 2012 representation pragma which applies to protected, task
2933 and synchronized interface primitives. The use of pragma Implemented provides
2934 a way to impose a static requirement on the overriding operation by adhering
2935 to one of the three implementation kinds: entry, protected procedure or any of
2936 the above. This pragma is available in all earlier versions of Ada as an
2937 implementation-defined pragma.
2939 @smallexample @c ada
2940 type Synch_Iface is synchronized interface;
2941 procedure Prim_Op (Obj : in out Iface) is abstract;
2942 pragma Implemented (Prim_Op, By_Protected_Procedure);
2944 protected type Prot_1 is new Synch_Iface with
2945 procedure Prim_Op; -- Legal
2948 protected type Prot_2 is new Synch_Iface with
2949 entry Prim_Op; -- Illegal
2952 task type Task_Typ is new Synch_Iface with
2953 entry Prim_Op; -- Illegal
2958 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2959 Implemented determines the runtime behavior of the requeue. Implementation kind
2960 By_Entry guarantees that the action of requeueing will proceed from an entry to
2961 another entry. Implementation kind By_Protected_Procedure transforms the
2962 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2963 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2964 the target's overriding subprogram kind.
2966 @node Pragma Implicit_Packing
2967 @unnumberedsec Pragma Implicit_Packing
2968 @findex Implicit_Packing
2969 @cindex Rational Profile
2973 @smallexample @c ada
2974 pragma Implicit_Packing;
2978 This is a configuration pragma that requests implicit packing for packed
2979 arrays for which a size clause is given but no explicit pragma Pack or
2980 specification of Component_Size is present. It also applies to records
2981 where no record representation clause is present. Consider this example:
2983 @smallexample @c ada
2984 type R is array (0 .. 7) of Boolean;
2989 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2990 does not change the layout of a composite object. So the Size clause in the
2991 above example is normally rejected, since the default layout of the array uses
2992 8-bit components, and thus the array requires a minimum of 64 bits.
2994 If this declaration is compiled in a region of code covered by an occurrence
2995 of the configuration pragma Implicit_Packing, then the Size clause in this
2996 and similar examples will cause implicit packing and thus be accepted. For
2997 this implicit packing to occur, the type in question must be an array of small
2998 components whose size is known at compile time, and the Size clause must
2999 specify the exact size that corresponds to the length of the array multiplied
3000 by the size in bits of the component type.
3001 @cindex Array packing
3003 Similarly, the following example shows the use in the record case
3005 @smallexample @c ada
3007 a, b, c, d, e, f, g, h : boolean;
3014 Without a pragma Pack, each Boolean field requires 8 bits, so the
3015 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3016 sufficient. The use of pragma Implicit_Packing allows this record
3017 declaration to compile without an explicit pragma Pack.
3018 @node Pragma Import_Exception
3019 @unnumberedsec Pragma Import_Exception
3021 @findex Import_Exception
3025 @smallexample @c ada
3026 pragma Import_Exception (
3027 [Internal =>] LOCAL_NAME
3028 [, [External =>] EXTERNAL_SYMBOL]
3029 [, [Form =>] Ada | VMS]
3030 [, [Code =>] static_integer_EXPRESSION]);
3034 | static_string_EXPRESSION
3038 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3039 It allows OpenVMS conditions (for example, from OpenVMS system services or
3040 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3041 The pragma specifies that the exception associated with an exception
3042 declaration in an Ada program be defined externally (in non-Ada code).
3043 For further details on this pragma, see the
3044 DEC Ada Language Reference Manual, section 13.9a.3.1.
3046 @node Pragma Import_Function
3047 @unnumberedsec Pragma Import_Function
3048 @findex Import_Function
3052 @smallexample @c ada
3053 pragma Import_Function (
3054 [Internal =>] LOCAL_NAME,
3055 [, [External =>] EXTERNAL_SYMBOL]
3056 [, [Parameter_Types =>] PARAMETER_TYPES]
3057 [, [Result_Type =>] SUBTYPE_MARK]
3058 [, [Mechanism =>] MECHANISM]
3059 [, [Result_Mechanism =>] MECHANISM_NAME]
3060 [, [First_Optional_Parameter =>] IDENTIFIER]);
3064 | static_string_EXPRESSION
3068 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3072 | subtype_Name ' Access
3076 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3078 MECHANISM_ASSOCIATION ::=
3079 [formal_parameter_NAME =>] MECHANISM_NAME
3084 | Descriptor [([Class =>] CLASS_NAME)]
3085 | Short_Descriptor [([Class =>] CLASS_NAME)]
3087 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3091 This pragma is used in conjunction with a pragma @code{Import} to
3092 specify additional information for an imported function. The pragma
3093 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3094 @code{Import_Function} pragma and both must appear in the same
3095 declarative part as the function specification.
3097 The @var{Internal} argument must uniquely designate
3098 the function to which the
3099 pragma applies. If more than one function name exists of this name in
3100 the declarative part you must use the @code{Parameter_Types} and
3101 @var{Result_Type} parameters to achieve the required unique
3102 designation. Subtype marks in these parameters must exactly match the
3103 subtypes in the corresponding function specification, using positional
3104 notation to match parameters with subtype marks.
3105 The form with an @code{'Access} attribute can be used to match an
3106 anonymous access parameter.
3108 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3109 parameters to specify passing mechanisms for the
3110 parameters and result. If you specify a single mechanism name, it
3111 applies to all parameters. Otherwise you may specify a mechanism on a
3112 parameter by parameter basis using either positional or named
3113 notation. If the mechanism is not specified, the default mechanism
3117 @cindex Passing by descriptor
3118 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3119 The default behavior for Import_Function is to pass a 64bit descriptor
3120 unless short_descriptor is specified, then a 32bit descriptor is passed.
3122 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3123 It specifies that the designated parameter and all following parameters
3124 are optional, meaning that they are not passed at the generated code
3125 level (this is distinct from the notion of optional parameters in Ada
3126 where the parameters are passed anyway with the designated optional
3127 parameters). All optional parameters must be of mode @code{IN} and have
3128 default parameter values that are either known at compile time
3129 expressions, or uses of the @code{'Null_Parameter} attribute.
3131 @node Pragma Import_Object
3132 @unnumberedsec Pragma Import_Object
3133 @findex Import_Object
3137 @smallexample @c ada
3138 pragma Import_Object
3139 [Internal =>] LOCAL_NAME
3140 [, [External =>] EXTERNAL_SYMBOL]
3141 [, [Size =>] EXTERNAL_SYMBOL]);
3145 | static_string_EXPRESSION
3149 This pragma designates an object as imported, and apart from the
3150 extended rules for external symbols, is identical in effect to the use of
3151 the normal @code{Import} pragma applied to an object. Unlike the
3152 subprogram case, you need not use a separate @code{Import} pragma,
3153 although you may do so (and probably should do so from a portability
3154 point of view). @var{size} is syntax checked, but otherwise ignored by
3157 @node Pragma Import_Procedure
3158 @unnumberedsec Pragma Import_Procedure
3159 @findex Import_Procedure
3163 @smallexample @c ada
3164 pragma Import_Procedure (
3165 [Internal =>] LOCAL_NAME
3166 [, [External =>] EXTERNAL_SYMBOL]
3167 [, [Parameter_Types =>] PARAMETER_TYPES]
3168 [, [Mechanism =>] MECHANISM]
3169 [, [First_Optional_Parameter =>] IDENTIFIER]);
3173 | static_string_EXPRESSION
3177 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3181 | subtype_Name ' Access
3185 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3187 MECHANISM_ASSOCIATION ::=
3188 [formal_parameter_NAME =>] MECHANISM_NAME
3193 | Descriptor [([Class =>] CLASS_NAME)]
3194 | Short_Descriptor [([Class =>] CLASS_NAME)]
3196 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3200 This pragma is identical to @code{Import_Function} except that it
3201 applies to a procedure rather than a function and the parameters
3202 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3204 @node Pragma Import_Valued_Procedure
3205 @unnumberedsec Pragma Import_Valued_Procedure
3206 @findex Import_Valued_Procedure
3210 @smallexample @c ada
3211 pragma Import_Valued_Procedure (
3212 [Internal =>] LOCAL_NAME
3213 [, [External =>] EXTERNAL_SYMBOL]
3214 [, [Parameter_Types =>] PARAMETER_TYPES]
3215 [, [Mechanism =>] MECHANISM]
3216 [, [First_Optional_Parameter =>] IDENTIFIER]);
3220 | static_string_EXPRESSION
3224 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3228 | subtype_Name ' Access
3232 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3234 MECHANISM_ASSOCIATION ::=
3235 [formal_parameter_NAME =>] MECHANISM_NAME
3240 | Descriptor [([Class =>] CLASS_NAME)]
3241 | Short_Descriptor [([Class =>] CLASS_NAME)]
3243 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3247 This pragma is identical to @code{Import_Procedure} except that the
3248 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3249 mode @code{OUT}, and externally the subprogram is treated as a function
3250 with this parameter as the result of the function. The purpose of this
3251 capability is to allow the use of @code{OUT} and @code{IN OUT}
3252 parameters in interfacing to external functions (which are not permitted
3253 in Ada functions). You may optionally use the @code{Mechanism}
3254 parameters to specify passing mechanisms for the parameters.
3255 If you specify a single mechanism name, it applies to all parameters.
3256 Otherwise you may specify a mechanism on a parameter by parameter
3257 basis using either positional or named notation. If the mechanism is not
3258 specified, the default mechanism is used.
3260 Note that it is important to use this pragma in conjunction with a separate
3261 pragma Import that specifies the desired convention, since otherwise the
3262 default convention is Ada, which is almost certainly not what is required.
3264 @node Pragma Independent
3265 @unnumberedsec Pragma Independent
3270 @smallexample @c ada
3271 pragma Independent (Local_NAME);
3275 This pragma is standard in Ada 2012 mode (which also provides an aspect
3276 of the same name). It is also available as an implementation-defined
3277 pragma in all earlier versions. It specifies that the
3278 designated object or all objects of the designated type must be
3279 independently addressable. This means that separate tasks can safely
3280 manipulate such objects. For example, if two components of a record are
3281 independent, then two separate tasks may access these two components.
3283 constraints on the representation of the object (for instance prohibiting
3286 @node Pragma Independent_Components
3287 @unnumberedsec Pragma Independent_Components
3288 @findex Independent_Components
3292 @smallexample @c ada
3293 pragma Independent_Components (Local_NAME);
3297 This pragma is standard in Ada 2012 mode (which also provides an aspect
3298 of the same name). It is also available as an implementation-defined
3299 pragma in all earlier versions. It specifies that the components of the
3300 designated object, or the components of each object of the designated
3302 independently addressable. This means that separate tasks can safely
3303 manipulate separate components in the composite object. This may place
3304 constraints on the representation of the object (for instance prohibiting
3307 @node Pragma Initialize_Scalars
3308 @unnumberedsec Pragma Initialize_Scalars
3309 @findex Initialize_Scalars
3310 @cindex debugging with Initialize_Scalars
3314 @smallexample @c ada
3315 pragma Initialize_Scalars;
3319 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3320 two important differences. First, there is no requirement for the pragma
3321 to be used uniformly in all units of a partition, in particular, it is fine
3322 to use this just for some or all of the application units of a partition,
3323 without needing to recompile the run-time library.
3325 In the case where some units are compiled with the pragma, and some without,
3326 then a declaration of a variable where the type is defined in package
3327 Standard or is locally declared will always be subject to initialization,
3328 as will any declaration of a scalar variable. For composite variables,
3329 whether the variable is initialized may also depend on whether the package
3330 in which the type of the variable is declared is compiled with the pragma.
3332 The other important difference is that you can control the value used
3333 for initializing scalar objects. At bind time, you can select several
3334 options for initialization. You can
3335 initialize with invalid values (similar to Normalize_Scalars, though for
3336 Initialize_Scalars it is not always possible to determine the invalid
3337 values in complex cases like signed component fields with non-standard
3338 sizes). You can also initialize with high or
3339 low values, or with a specified bit pattern. See the @value{EDITION}
3340 User's Guide for binder options for specifying these cases.
3342 This means that you can compile a program, and then without having to
3343 recompile the program, you can run it with different values being used
3344 for initializing otherwise uninitialized values, to test if your program
3345 behavior depends on the choice. Of course the behavior should not change,
3346 and if it does, then most likely you have an erroneous reference to an
3347 uninitialized value.
3349 It is even possible to change the value at execution time eliminating even
3350 the need to rebind with a different switch using an environment variable.
3351 See the @value{EDITION} User's Guide for details.
3353 Note that pragma @code{Initialize_Scalars} is particularly useful in
3354 conjunction with the enhanced validity checking that is now provided
3355 in GNAT, which checks for invalid values under more conditions.
3356 Using this feature (see description of the @option{-gnatV} flag in the
3357 @value{EDITION} User's Guide) in conjunction with
3358 pragma @code{Initialize_Scalars}
3359 provides a powerful new tool to assist in the detection of problems
3360 caused by uninitialized variables.
3362 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3363 effect on the generated code. This may cause your code to be
3364 substantially larger. It may also cause an increase in the amount
3365 of stack required, so it is probably a good idea to turn on stack
3366 checking (see description of stack checking in the @value{EDITION}
3367 User's Guide) when using this pragma.
3369 @node Pragma Inline_Always
3370 @unnumberedsec Pragma Inline_Always
3371 @findex Inline_Always
3375 @smallexample @c ada
3376 pragma Inline_Always (NAME [, NAME]);
3380 Similar to pragma @code{Inline} except that inlining is not subject to
3381 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3382 happens regardless of whether these options are used.
3384 @node Pragma Inline_Generic
3385 @unnumberedsec Pragma Inline_Generic
3386 @findex Inline_Generic
3390 @smallexample @c ada
3391 pragma Inline_Generic (generic_package_NAME);
3395 This is implemented for compatibility with DEC Ada 83 and is recognized,
3396 but otherwise ignored, by GNAT@. All generic instantiations are inlined
3397 by default when using GNAT@.
3399 @node Pragma Interface
3400 @unnumberedsec Pragma Interface
3405 @smallexample @c ada
3407 [Convention =>] convention_identifier,
3408 [Entity =>] local_NAME
3409 [, [External_Name =>] static_string_expression]
3410 [, [Link_Name =>] static_string_expression]);
3414 This pragma is identical in syntax and semantics to
3415 the standard Ada pragma @code{Import}. It is provided for compatibility
3416 with Ada 83. The definition is upwards compatible both with pragma
3417 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3418 with some extended implementations of this pragma in certain Ada 83
3419 implementations. The only difference between pragma @code{Interface}
3420 and pragma @code{Import} is that there is special circuitry to allow
3421 both pragmas to appear for the same subprogram entity (normally it
3422 is illegal to have multiple @code{Import} pragmas. This is useful in
3423 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3426 @node Pragma Interface_Name
3427 @unnumberedsec Pragma Interface_Name
3428 @findex Interface_Name
3432 @smallexample @c ada
3433 pragma Interface_Name (
3434 [Entity =>] LOCAL_NAME
3435 [, [External_Name =>] static_string_EXPRESSION]
3436 [, [Link_Name =>] static_string_EXPRESSION]);
3440 This pragma provides an alternative way of specifying the interface name
3441 for an interfaced subprogram, and is provided for compatibility with Ada
3442 83 compilers that use the pragma for this purpose. You must provide at
3443 least one of @var{External_Name} or @var{Link_Name}.
3445 @node Pragma Interrupt_Handler
3446 @unnumberedsec Pragma Interrupt_Handler
3447 @findex Interrupt_Handler
3451 @smallexample @c ada
3452 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3456 This program unit pragma is supported for parameterless protected procedures
3457 as described in Annex C of the Ada Reference Manual. On the AAMP target
3458 the pragma can also be specified for nonprotected parameterless procedures
3459 that are declared at the library level (which includes procedures
3460 declared at the top level of a library package). In the case of AAMP,
3461 when this pragma is applied to a nonprotected procedure, the instruction
3462 @code{IERET} is generated for returns from the procedure, enabling
3463 maskable interrupts, in place of the normal return instruction.
3465 @node Pragma Interrupt_State
3466 @unnumberedsec Pragma Interrupt_State
3467 @findex Interrupt_State
3471 @smallexample @c ada
3472 pragma Interrupt_State
3474 [State =>] SYSTEM | RUNTIME | USER);
3478 Normally certain interrupts are reserved to the implementation. Any attempt
3479 to attach an interrupt causes Program_Error to be raised, as described in
3480 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3481 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3482 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3483 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3484 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3485 Ada exceptions, or used to implement run-time functions such as the
3486 @code{abort} statement and stack overflow checking.
3488 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3489 such uses of interrupts. It subsumes the functionality of pragma
3490 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3491 available on Windows or VMS. On all other platforms than VxWorks,
3492 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3493 and may be used to mark interrupts required by the board support package
3496 Interrupts can be in one of three states:
3500 The interrupt is reserved (no Ada handler can be installed), and the
3501 Ada run-time may not install a handler. As a result you are guaranteed
3502 standard system default action if this interrupt is raised.
3506 The interrupt is reserved (no Ada handler can be installed). The run time
3507 is allowed to install a handler for internal control purposes, but is
3508 not required to do so.
3512 The interrupt is unreserved. The user may install a handler to provide
3517 These states are the allowed values of the @code{State} parameter of the
3518 pragma. The @code{Name} parameter is a value of the type
3519 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3520 @code{Ada.Interrupts.Names}.
3522 This is a configuration pragma, and the binder will check that there
3523 are no inconsistencies between different units in a partition in how a
3524 given interrupt is specified. It may appear anywhere a pragma is legal.
3526 The effect is to move the interrupt to the specified state.
3528 By declaring interrupts to be SYSTEM, you guarantee the standard system
3529 action, such as a core dump.
3531 By declaring interrupts to be USER, you guarantee that you can install
3534 Note that certain signals on many operating systems cannot be caught and
3535 handled by applications. In such cases, the pragma is ignored. See the
3536 operating system documentation, or the value of the array @code{Reserved}
3537 declared in the spec of package @code{System.OS_Interface}.
3539 Overriding the default state of signals used by the Ada runtime may interfere
3540 with an application's runtime behavior in the cases of the synchronous signals,
3541 and in the case of the signal used to implement the @code{abort} statement.
3543 @node Pragma Invariant
3544 @unnumberedsec Pragma Invariant
3549 @smallexample @c ada
3551 ([Entity =>] private_type_LOCAL_NAME,
3552 [Check =>] EXPRESSION
3553 [,[Message =>] String_Expression]);
3557 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3558 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3559 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3560 requires the use of the aspect syntax, which is not available except in 2012
3561 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3562 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3563 note that the aspect Invariant is a synonym in GNAT for the aspect
3564 Type_Invariant, but there is no pragma Type_Invariant.
3566 The pragma must appear within the visible part of the package specification,
3567 after the type to which its Entity argument appears. As with the Invariant
3568 aspect, the Check expression is not analyzed until the end of the visible
3569 part of the package, so it may contain forward references. The Message
3570 argument, if present, provides the exception message used if the invariant
3571 is violated. If no Message parameter is provided, a default message that
3572 identifies the line on which the pragma appears is used.
3574 It is permissible to have multiple Invariants for the same type entity, in
3575 which case they are and'ed together. It is permissible to use this pragma
3576 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3577 invariant pragma for the same entity.
3579 For further details on the use of this pragma, see the Ada 2012 documentation
3580 of the Type_Invariant aspect.
3582 @node Pragma Keep_Names
3583 @unnumberedsec Pragma Keep_Names
3588 @smallexample @c ada
3589 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3593 The @var{LOCAL_NAME} argument
3594 must refer to an enumeration first subtype
3595 in the current declarative part. The effect is to retain the enumeration
3596 literal names for use by @code{Image} and @code{Value} even if a global
3597 @code{Discard_Names} pragma applies. This is useful when you want to
3598 generally suppress enumeration literal names and for example you therefore
3599 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3600 want to retain the names for specific enumeration types.
3602 @node Pragma License
3603 @unnumberedsec Pragma License
3605 @cindex License checking
3609 @smallexample @c ada
3610 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3614 This pragma is provided to allow automated checking for appropriate license
3615 conditions with respect to the standard and modified GPL@. A pragma
3616 @code{License}, which is a configuration pragma that typically appears at
3617 the start of a source file or in a separate @file{gnat.adc} file, specifies
3618 the licensing conditions of a unit as follows:
3622 This is used for a unit that can be freely used with no license restrictions.
3623 Examples of such units are public domain units, and units from the Ada
3627 This is used for a unit that is licensed under the unmodified GPL, and which
3628 therefore cannot be @code{with}'ed by a restricted unit.
3631 This is used for a unit licensed under the GNAT modified GPL that includes
3632 a special exception paragraph that specifically permits the inclusion of
3633 the unit in programs without requiring the entire program to be released
3637 This is used for a unit that is restricted in that it is not permitted to
3638 depend on units that are licensed under the GPL@. Typical examples are
3639 proprietary code that is to be released under more restrictive license
3640 conditions. Note that restricted units are permitted to @code{with} units
3641 which are licensed under the modified GPL (this is the whole point of the
3647 Normally a unit with no @code{License} pragma is considered to have an
3648 unknown license, and no checking is done. However, standard GNAT headers
3649 are recognized, and license information is derived from them as follows.
3653 A GNAT license header starts with a line containing 78 hyphens. The following
3654 comment text is searched for the appearance of any of the following strings.
3656 If the string ``GNU General Public License'' is found, then the unit is assumed
3657 to have GPL license, unless the string ``As a special exception'' follows, in
3658 which case the license is assumed to be modified GPL@.
3660 If one of the strings
3661 ``This specification is adapted from the Ada Semantic Interface'' or
3662 ``This specification is derived from the Ada Reference Manual'' is found
3663 then the unit is assumed to be unrestricted.
3667 These default actions means that a program with a restricted license pragma
3668 will automatically get warnings if a GPL unit is inappropriately
3669 @code{with}'ed. For example, the program:
3671 @smallexample @c ada
3674 procedure Secret_Stuff is
3680 if compiled with pragma @code{License} (@code{Restricted}) in a
3681 @file{gnat.adc} file will generate the warning:
3686 >>> license of withed unit "Sem_Ch3" is incompatible
3688 2. with GNAT.Sockets;
3689 3. procedure Secret_Stuff is
3693 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3694 compiler and is licensed under the
3695 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3696 run time, and is therefore licensed under the modified GPL@.
3698 @node Pragma Link_With
3699 @unnumberedsec Pragma Link_With
3704 @smallexample @c ada
3705 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3709 This pragma is provided for compatibility with certain Ada 83 compilers.
3710 It has exactly the same effect as pragma @code{Linker_Options} except
3711 that spaces occurring within one of the string expressions are treated
3712 as separators. For example, in the following case:
3714 @smallexample @c ada
3715 pragma Link_With ("-labc -ldef");
3719 results in passing the strings @code{-labc} and @code{-ldef} as two
3720 separate arguments to the linker. In addition pragma Link_With allows
3721 multiple arguments, with the same effect as successive pragmas.
3723 @node Pragma Linker_Alias
3724 @unnumberedsec Pragma Linker_Alias
3725 @findex Linker_Alias
3729 @smallexample @c ada
3730 pragma Linker_Alias (
3731 [Entity =>] LOCAL_NAME,
3732 [Target =>] static_string_EXPRESSION);
3736 @var{LOCAL_NAME} must refer to an object that is declared at the library
3737 level. This pragma establishes the given entity as a linker alias for the
3738 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3739 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3740 @var{static_string_EXPRESSION} in the object file, that is to say no space
3741 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3742 to the same address as @var{static_string_EXPRESSION} by the linker.
3744 The actual linker name for the target must be used (e.g.@: the fully
3745 encoded name with qualification in Ada, or the mangled name in C++),
3746 or it must be declared using the C convention with @code{pragma Import}
3747 or @code{pragma Export}.
3749 Not all target machines support this pragma. On some of them it is accepted
3750 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3752 @smallexample @c ada
3753 -- Example of the use of pragma Linker_Alias
3757 pragma Export (C, i);
3759 new_name_for_i : Integer;
3760 pragma Linker_Alias (new_name_for_i, "i");
3764 @node Pragma Linker_Constructor
3765 @unnumberedsec Pragma Linker_Constructor
3766 @findex Linker_Constructor
3770 @smallexample @c ada
3771 pragma Linker_Constructor (procedure_LOCAL_NAME);
3775 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3776 is declared at the library level. A procedure to which this pragma is
3777 applied will be treated as an initialization routine by the linker.
3778 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3779 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3780 of the executable is called (or immediately after the shared library is
3781 loaded if the procedure is linked in a shared library), in particular
3782 before the Ada run-time environment is set up.
3784 Because of these specific contexts, the set of operations such a procedure
3785 can perform is very limited and the type of objects it can manipulate is
3786 essentially restricted to the elementary types. In particular, it must only
3787 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3789 This pragma is used by GNAT to implement auto-initialization of shared Stand
3790 Alone Libraries, which provides a related capability without the restrictions
3791 listed above. Where possible, the use of Stand Alone Libraries is preferable
3792 to the use of this pragma.
3794 @node Pragma Linker_Destructor
3795 @unnumberedsec Pragma Linker_Destructor
3796 @findex Linker_Destructor
3800 @smallexample @c ada
3801 pragma Linker_Destructor (procedure_LOCAL_NAME);
3805 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3806 is declared at the library level. A procedure to which this pragma is
3807 applied will be treated as a finalization routine by the linker.
3808 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3809 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3810 of the executable has exited (or immediately before the shared library
3811 is unloaded if the procedure is linked in a shared library), in particular
3812 after the Ada run-time environment is shut down.
3814 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3815 because of these specific contexts.
3817 @node Pragma Linker_Section
3818 @unnumberedsec Pragma Linker_Section
3819 @findex Linker_Section
3823 @smallexample @c ada
3824 pragma Linker_Section (
3825 [Entity =>] LOCAL_NAME,
3826 [Section =>] static_string_EXPRESSION);
3830 @var{LOCAL_NAME} must refer to an object that is declared at the library
3831 level. This pragma specifies the name of the linker section for the given
3832 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3833 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3834 section of the executable (assuming the linker doesn't rename the section).
3836 The compiler normally places library-level objects in standard sections
3837 depending on their type: procedures and functions generally go in the
3838 @code{.text} section, initialized variables in the @code{.data} section
3839 and uninitialized variables in the @code{.bss} section.
3841 Other, special sections may exist on given target machines to map special
3842 hardware, for example I/O ports or flash memory. This pragma is a means to
3843 defer the final layout of the executable to the linker, thus fully working
3844 at the symbolic level with the compiler.
3846 Some file formats do not support arbitrary sections so not all target
3847 machines support this pragma. The use of this pragma may cause a program
3848 execution to be erroneous if it is used to place an entity into an
3849 inappropriate section (e.g.@: a modified variable into the @code{.text}
3850 section). See also @code{pragma Persistent_BSS}.
3852 @smallexample @c ada
3853 -- Example of the use of pragma Linker_Section
3857 pragma Volatile (Port_A);
3858 pragma Linker_Section (Port_A, ".bss.port_a");
3861 pragma Volatile (Port_B);
3862 pragma Linker_Section (Port_B, ".bss.port_b");
3866 @node Pragma Long_Float
3867 @unnumberedsec Pragma Long_Float
3873 @smallexample @c ada
3874 pragma Long_Float (FLOAT_FORMAT);
3876 FLOAT_FORMAT ::= D_Float | G_Float
3880 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3881 It allows control over the internal representation chosen for the predefined
3882 type @code{Long_Float} and for floating point type representations with
3883 @code{digits} specified in the range 7 through 15.
3884 For further details on this pragma, see the
3885 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3886 this pragma, the standard runtime libraries must be recompiled.
3888 @node Pragma Loop_Optimize
3889 @unnumberedsec Pragma Loop_Optimize
3890 @findex Loop_Optimize
3894 @smallexample @c ada
3895 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
3897 OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
3901 This pragma must appear immediately within a loop statement. It allows the
3902 programmer to specify optimization hints for the enclosing loop. The hints
3903 are not mutually exclusive and can be freely mixed, but not all combinations
3904 will yield a sensible outcome.
3906 There are four supported optimization hints for a loop:
3910 The loop must not be unrolled. This is a strong hint: the compiler will not
3911 unroll a loop marked with this hint.
3915 The loop should be unrolled. This is a weak hint: the compiler will try to
3916 apply unrolling to this loop preferably to other optimizations, notably
3917 vectorization, but there is no guarantee that the loop will be unrolled.
3921 The loop must not be vectorized. This is a strong hint: the compiler will not
3922 vectorize a loop marked with this hint.
3926 The loop should be vectorized. This is a weak hint: the compiler will try to
3927 apply vectorization to this loop preferably to other optimizations, notably
3928 unrolling, but there is no guarantee that the loop will be vectorized.
3932 These hints do not void the need to pass the appropriate switches to the
3933 compiler in order to enable the relevant optimizations, that is to say
3934 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
3937 @node Pragma Machine_Attribute
3938 @unnumberedsec Pragma Machine_Attribute
3939 @findex Machine_Attribute
3943 @smallexample @c ada
3944 pragma Machine_Attribute (
3945 [Entity =>] LOCAL_NAME,
3946 [Attribute_Name =>] static_string_EXPRESSION
3947 [, [Info =>] static_EXPRESSION] );
3951 Machine-dependent attributes can be specified for types and/or
3952 declarations. This pragma is semantically equivalent to
3953 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3954 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3955 in GNU C, where @code{@var{attribute_name}} is recognized by the
3956 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3957 specific macro. A string literal for the optional parameter @var{info}
3958 is transformed into an identifier, which may make this pragma unusable
3959 for some attributes. @xref{Target Attributes,, Defining target-specific
3960 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3961 Internals}, further information.
3964 @unnumberedsec Pragma Main
3970 @smallexample @c ada
3972 (MAIN_OPTION [, MAIN_OPTION]);
3975 [Stack_Size =>] static_integer_EXPRESSION
3976 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3977 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3981 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3982 no effect in GNAT, other than being syntax checked.
3984 @node Pragma Main_Storage
3985 @unnumberedsec Pragma Main_Storage
3987 @findex Main_Storage
3991 @smallexample @c ada
3993 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3995 MAIN_STORAGE_OPTION ::=
3996 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3997 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
4001 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4002 no effect in GNAT, other than being syntax checked. Note that the pragma
4003 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4005 @node Pragma No_Body
4006 @unnumberedsec Pragma No_Body
4011 @smallexample @c ada
4016 There are a number of cases in which a package spec does not require a body,
4017 and in fact a body is not permitted. GNAT will not permit the spec to be
4018 compiled if there is a body around. The pragma No_Body allows you to provide
4019 a body file, even in a case where no body is allowed. The body file must
4020 contain only comments and a single No_Body pragma. This is recognized by
4021 the compiler as indicating that no body is logically present.
4023 This is particularly useful during maintenance when a package is modified in
4024 such a way that a body needed before is no longer needed. The provision of a
4025 dummy body with a No_Body pragma ensures that there is no interference from
4026 earlier versions of the package body.
4028 @node Pragma No_Inline
4029 @unnumberedsec Pragma No_Inline
4034 @smallexample @c ada
4035 pragma No_Inline (NAME @{, NAME@});
4039 This pragma suppresses inlining for the callable entity or the instances of
4040 the generic subprogram designated by @var{NAME}, including inlining that
4041 results from the use of pragma @code{Inline}. This pragma is always active,
4042 in particular it is not subject to the use of option @option{-gnatn} or
4043 @option{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
4044 pragma @code{Inline_Always} for the same @var{NAME}.
4046 @node Pragma No_Return
4047 @unnumberedsec Pragma No_Return
4052 @smallexample @c ada
4053 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4057 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4058 declarations in the current declarative part. A procedure to which this
4059 pragma is applied may not contain any explicit @code{return} statements.
4060 In addition, if the procedure contains any implicit returns from falling
4061 off the end of a statement sequence, then execution of that implicit
4062 return will cause Program_Error to be raised.
4064 One use of this pragma is to identify procedures whose only purpose is to raise
4065 an exception. Another use of this pragma is to suppress incorrect warnings
4066 about missing returns in functions, where the last statement of a function
4067 statement sequence is a call to such a procedure.
4069 Note that in Ada 2005 mode, this pragma is part of the language. It is
4070 available in all earlier versions of Ada as an implementation-defined
4073 @node Pragma No_Strict_Aliasing
4074 @unnumberedsec Pragma No_Strict_Aliasing
4075 @findex No_Strict_Aliasing
4079 @smallexample @c ada
4080 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4084 @var{type_LOCAL_NAME} must refer to an access type
4085 declaration in the current declarative part. The effect is to inhibit
4086 strict aliasing optimization for the given type. The form with no
4087 arguments is a configuration pragma which applies to all access types
4088 declared in units to which the pragma applies. For a detailed
4089 description of the strict aliasing optimization, and the situations
4090 in which it must be suppressed, see @ref{Optimization and Strict
4091 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4093 This pragma currently has no effects on access to unconstrained array types.
4095 @node Pragma Normalize_Scalars
4096 @unnumberedsec Pragma Normalize_Scalars
4097 @findex Normalize_Scalars
4101 @smallexample @c ada
4102 pragma Normalize_Scalars;
4106 This is a language defined pragma which is fully implemented in GNAT@. The
4107 effect is to cause all scalar objects that are not otherwise initialized
4108 to be initialized. The initial values are implementation dependent and
4112 @item Standard.Character
4114 Objects whose root type is Standard.Character are initialized to
4115 Character'Last unless the subtype range excludes NUL (in which case
4116 NUL is used). This choice will always generate an invalid value if
4119 @item Standard.Wide_Character
4121 Objects whose root type is Standard.Wide_Character are initialized to
4122 Wide_Character'Last unless the subtype range excludes NUL (in which case
4123 NUL is used). This choice will always generate an invalid value if
4126 @item Standard.Wide_Wide_Character
4128 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4129 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4130 which case NUL is used). This choice will always generate an invalid value if
4135 Objects of an integer type are treated differently depending on whether
4136 negative values are present in the subtype. If no negative values are
4137 present, then all one bits is used as the initial value except in the
4138 special case where zero is excluded from the subtype, in which case
4139 all zero bits are used. This choice will always generate an invalid
4140 value if one exists.
4142 For subtypes with negative values present, the largest negative number
4143 is used, except in the unusual case where this largest negative number
4144 is in the subtype, and the largest positive number is not, in which case
4145 the largest positive value is used. This choice will always generate
4146 an invalid value if one exists.
4148 @item Floating-Point Types
4149 Objects of all floating-point types are initialized to all 1-bits. For
4150 standard IEEE format, this corresponds to a NaN (not a number) which is
4151 indeed an invalid value.
4153 @item Fixed-Point Types
4154 Objects of all fixed-point types are treated as described above for integers,
4155 with the rules applying to the underlying integer value used to represent
4156 the fixed-point value.
4159 Objects of a modular type are initialized to all one bits, except in
4160 the special case where zero is excluded from the subtype, in which
4161 case all zero bits are used. This choice will always generate an
4162 invalid value if one exists.
4164 @item Enumeration types
4165 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4166 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4167 whose Pos value is zero, in which case a code of zero is used. This choice
4168 will always generate an invalid value if one exists.
4172 @node Pragma Obsolescent
4173 @unnumberedsec Pragma Obsolescent
4178 @smallexample @c ada
4181 pragma Obsolescent (
4182 [Message =>] static_string_EXPRESSION
4183 [,[Version =>] Ada_05]]);
4185 pragma Obsolescent (
4187 [,[Message =>] static_string_EXPRESSION
4188 [,[Version =>] Ada_05]] );
4192 This pragma can occur immediately following a declaration of an entity,
4193 including the case of a record component. If no Entity argument is present,
4194 then this declaration is the one to which the pragma applies. If an Entity
4195 parameter is present, it must either match the name of the entity in this
4196 declaration, or alternatively, the pragma can immediately follow an enumeration
4197 type declaration, where the Entity argument names one of the enumeration
4200 This pragma is used to indicate that the named entity
4201 is considered obsolescent and should not be used. Typically this is
4202 used when an API must be modified by eventually removing or modifying
4203 existing subprograms or other entities. The pragma can be used at an
4204 intermediate stage when the entity is still present, but will be
4207 The effect of this pragma is to output a warning message on a reference to
4208 an entity thus marked that the subprogram is obsolescent if the appropriate
4209 warning option in the compiler is activated. If the Message parameter is
4210 present, then a second warning message is given containing this text. In
4211 addition, a reference to the entity is considered to be a violation of pragma
4212 Restrictions (No_Obsolescent_Features).
4214 This pragma can also be used as a program unit pragma for a package,
4215 in which case the entity name is the name of the package, and the
4216 pragma indicates that the entire package is considered
4217 obsolescent. In this case a client @code{with}'ing such a package
4218 violates the restriction, and the @code{with} statement is
4219 flagged with warnings if the warning option is set.
4221 If the Version parameter is present (which must be exactly
4222 the identifier Ada_05, no other argument is allowed), then the
4223 indication of obsolescence applies only when compiling in Ada 2005
4224 mode. This is primarily intended for dealing with the situations
4225 in the predefined library where subprograms or packages
4226 have become defined as obsolescent in Ada 2005
4227 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4229 The following examples show typical uses of this pragma:
4231 @smallexample @c ada
4233 pragma Obsolescent (p, Message => "use pp instead of p");
4238 pragma Obsolescent ("use q2new instead");
4240 type R is new integer;
4243 Message => "use RR in Ada 2005",
4253 type E is (a, bc, 'd', quack);
4254 pragma Obsolescent (Entity => bc)
4255 pragma Obsolescent (Entity => 'd')
4258 (a, b : character) return character;
4259 pragma Obsolescent (Entity => "+");
4264 Note that, as for all pragmas, if you use a pragma argument identifier,
4265 then all subsequent parameters must also use a pragma argument identifier.
4266 So if you specify "Entity =>" for the Entity argument, and a Message
4267 argument is present, it must be preceded by "Message =>".
4269 @node Pragma Optimize_Alignment
4270 @unnumberedsec Pragma Optimize_Alignment
4271 @findex Optimize_Alignment
4272 @cindex Alignment, default settings
4276 @smallexample @c ada
4277 pragma Optimize_Alignment (TIME | SPACE | OFF);
4281 This is a configuration pragma which affects the choice of default alignments
4282 for types where no alignment is explicitly specified. There is a time/space
4283 trade-off in the selection of these values. Large alignments result in more
4284 efficient code, at the expense of larger data space, since sizes have to be
4285 increased to match these alignments. Smaller alignments save space, but the
4286 access code is slower. The normal choice of default alignments (which is what
4287 you get if you do not use this pragma, or if you use an argument of OFF),
4288 tries to balance these two requirements.
4290 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4291 First any packed record is given an alignment of 1. Second, if a size is given
4292 for the type, then the alignment is chosen to avoid increasing this size. For
4295 @smallexample @c ada
4305 In the default mode, this type gets an alignment of 4, so that access to the
4306 Integer field X are efficient. But this means that objects of the type end up
4307 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4308 allowed to be bigger than the size of the type, but it can waste space if for
4309 example fields of type R appear in an enclosing record. If the above type is
4310 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4312 However, there is one case in which SPACE is ignored. If a variable length
4313 record (that is a discriminated record with a component which is an array
4314 whose length depends on a discriminant), has a pragma Pack, then it is not
4315 in general possible to set the alignment of such a record to one, so the
4316 pragma is ignored in this case (with a warning).
4318 Specifying TIME causes larger default alignments to be chosen in the case of
4319 small types with sizes that are not a power of 2. For example, consider:
4321 @smallexample @c ada
4333 The default alignment for this record is normally 1, but if this type is
4334 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4335 to 4, which wastes space for objects of the type, since they are now 4 bytes
4336 long, but results in more efficient access when the whole record is referenced.
4338 As noted above, this is a configuration pragma, and there is a requirement
4339 that all units in a partition be compiled with a consistent setting of the
4340 optimization setting. This would normally be achieved by use of a configuration
4341 pragma file containing the appropriate setting. The exception to this rule is
4342 that units with an explicit configuration pragma in the same file as the source
4343 unit are excluded from the consistency check, as are all predefined units. The
4344 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4345 pragma appears at the start of the file.
4347 @node Pragma Ordered
4348 @unnumberedsec Pragma Ordered
4350 @findex pragma @code{Ordered}
4354 @smallexample @c ada
4355 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4359 Most enumeration types are from a conceptual point of view unordered.
4360 For example, consider:
4362 @smallexample @c ada
4363 type Color is (Red, Blue, Green, Yellow);
4367 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4368 but really these relations make no sense; the enumeration type merely
4369 specifies a set of possible colors, and the order is unimportant.
4371 For unordered enumeration types, it is generally a good idea if
4372 clients avoid comparisons (other than equality or inequality) and
4373 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4374 other than the unit where the type is declared, its body, and its subunits.)
4375 For example, if code buried in some client says:
4377 @smallexample @c ada
4378 if Current_Color < Yellow then ...
4379 if Current_Color in Blue .. Green then ...
4383 then the client code is relying on the order, which is undesirable.
4384 It makes the code hard to read and creates maintenance difficulties if
4385 entries have to be added to the enumeration type. Instead,
4386 the code in the client should list the possibilities, or an
4387 appropriate subtype should be declared in the unit that declares
4388 the original enumeration type. E.g., the following subtype could
4389 be declared along with the type @code{Color}:
4391 @smallexample @c ada
4392 subtype RBG is Color range Red .. Green;
4396 and then the client could write:
4398 @smallexample @c ada
4399 if Current_Color in RBG then ...
4400 if Current_Color = Blue or Current_Color = Green then ...
4404 However, some enumeration types are legitimately ordered from a conceptual
4405 point of view. For example, if you declare:
4407 @smallexample @c ada
4408 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4412 then the ordering imposed by the language is reasonable, and
4413 clients can depend on it, writing for example:
4415 @smallexample @c ada
4416 if D in Mon .. Fri then ...
4421 The pragma @option{Ordered} is provided to mark enumeration types that
4422 are conceptually ordered, alerting the reader that clients may depend
4423 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4424 rather than one to mark them as unordered, since in our experience,
4425 the great majority of enumeration types are conceptually unordered.
4427 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4428 and @code{Wide_Wide_Character}
4429 are considered to be ordered types, so each is declared with a
4430 pragma @code{Ordered} in package @code{Standard}.
4432 Normally pragma @code{Ordered} serves only as documentation and a guide for
4433 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4434 requests warnings for inappropriate uses (comparisons and explicit
4435 subranges) for unordered types. If this switch is used, then any
4436 enumeration type not marked with pragma @code{Ordered} will be considered
4437 as unordered, and will generate warnings for inappropriate uses.
4439 For additional information please refer to the description of the
4440 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4442 @node Pragma Overflow_Mode
4443 @unnumberedsec Pragma Overflow_Mode
4444 @findex Overflow checks
4445 @findex Overflow mode
4446 @findex pragma @code{Overflow_Mode}
4450 @smallexample @c ada
4451 pragma Overflow_Mode
4453 [,[Assertions =>] MODE]);
4455 MODE ::= STRICT | MINIMIZED | ELIMINATED
4459 This pragma sets the current overflow mode to the given setting. For details
4460 of the meaning of these modes, please refer to the
4461 ``Overflow Check Handling in GNAT'' appendix in the
4462 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4463 the given mode applies to all expressions. If both parameters are present,
4464 the @code{General} mode applies to expressions outside assertions, and
4465 the @code{Eliminated} mode applies to expressions within assertions.
4467 The case of the @code{MODE} parameter is ignored,
4468 so @code{MINIMIZED}, @code{Minimized} and
4469 @code{minimized} all have the same effect.
4471 The @code{Overflow_Mode} pragma has the same scoping and placement
4472 rules as pragma @code{Suppress}, so it can occur either as a
4473 configuration pragma, specifying a default for the whole
4474 program, or in a declarative scope, where it applies to the
4475 remaining declarations and statements in that scope.
4477 The pragma @code{Suppress (Overflow_Check)} suppresses
4478 overflow checking, but does not affect the overflow mode.
4480 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
4481 overflow checking, but does not affect the overflow mode.
4483 @node Pragma Partition_Elaboration_Policy
4484 @unnumberedsec Pragma Partition_Elaboration_Policy
4485 @findex Partition_Elaboration_Policy
4489 @smallexample @c ada
4490 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
4492 POLICY_IDENTIFIER ::= Concurrent | Sequential
4496 This pragma is standard in Ada 2005, but is available in all earlier
4497 versions of Ada as an implementation-defined pragma.
4498 See Ada 2012 Reference Manual for details.
4500 @node Pragma Passive
4501 @unnumberedsec Pragma Passive
4506 @smallexample @c ada
4507 pragma Passive [(Semaphore | No)];
4511 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
4512 compatibility with DEC Ada 83 implementations, where it is used within a
4513 task definition to request that a task be made passive. If the argument
4514 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4515 treats the pragma as an assertion that the containing task is passive
4516 and that optimization of context switch with this task is permitted and
4517 desired. If the argument @code{No} is present, the task must not be
4518 optimized. GNAT does not attempt to optimize any tasks in this manner
4519 (since protected objects are available in place of passive tasks).
4521 @node Pragma Persistent_BSS
4522 @unnumberedsec Pragma Persistent_BSS
4523 @findex Persistent_BSS
4527 @smallexample @c ada
4528 pragma Persistent_BSS [(LOCAL_NAME)]
4532 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4533 section. On some targets the linker and loader provide for special
4534 treatment of this section, allowing a program to be reloaded without
4535 affecting the contents of this data (hence the name persistent).
4537 There are two forms of usage. If an argument is given, it must be the
4538 local name of a library level object, with no explicit initialization
4539 and whose type is potentially persistent. If no argument is given, then
4540 the pragma is a configuration pragma, and applies to all library level
4541 objects with no explicit initialization of potentially persistent types.
4543 A potentially persistent type is a scalar type, or a non-tagged,
4544 non-discriminated record, all of whose components have no explicit
4545 initialization and are themselves of a potentially persistent type,
4546 or an array, all of whose constraints are static, and whose component
4547 type is potentially persistent.
4549 If this pragma is used on a target where this feature is not supported,
4550 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4552 @node Pragma Polling
4553 @unnumberedsec Pragma Polling
4558 @smallexample @c ada
4559 pragma Polling (ON | OFF);
4563 This pragma controls the generation of polling code. This is normally off.
4564 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4565 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
4566 runtime library, and can be found in file @file{a-excpol.adb}.
4568 Pragma @code{Polling} can appear as a configuration pragma (for example it
4569 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4570 can be used in the statement or declaration sequence to control polling
4573 A call to the polling routine is generated at the start of every loop and
4574 at the start of every subprogram call. This guarantees that the @code{Poll}
4575 routine is called frequently, and places an upper bound (determined by
4576 the complexity of the code) on the period between two @code{Poll} calls.
4578 The primary purpose of the polling interface is to enable asynchronous
4579 aborts on targets that cannot otherwise support it (for example Windows
4580 NT), but it may be used for any other purpose requiring periodic polling.
4581 The standard version is null, and can be replaced by a user program. This
4582 will require re-compilation of the @code{Ada.Exceptions} package that can
4583 be found in files @file{a-except.ads} and @file{a-except.adb}.
4585 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
4586 distribution) is used to enable the asynchronous abort capability on
4587 targets that do not normally support the capability. The version of
4588 @code{Poll} in this file makes a call to the appropriate runtime routine
4589 to test for an abort condition.
4591 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4592 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4595 @node Pragma Postcondition
4596 @unnumberedsec Pragma Postcondition
4597 @cindex Postconditions
4598 @cindex Checks, postconditions
4599 @findex Postconditions
4603 @smallexample @c ada
4604 pragma Postcondition (
4605 [Check =>] Boolean_Expression
4606 [,[Message =>] String_Expression]);
4610 The @code{Postcondition} pragma allows specification of automatic
4611 postcondition checks for subprograms. These checks are similar to
4612 assertions, but are automatically inserted just prior to the return
4613 statements of the subprogram with which they are associated (including
4614 implicit returns at the end of procedure bodies and associated
4615 exception handlers).
4617 In addition, the boolean expression which is the condition which
4618 must be true may contain references to function'Result in the case
4619 of a function to refer to the returned value.
4621 @code{Postcondition} pragmas may appear either immediately following the
4622 (separate) declaration of a subprogram, or at the start of the
4623 declarations of a subprogram body. Only other pragmas may intervene
4624 (that is appear between the subprogram declaration and its
4625 postconditions, or appear before the postcondition in the
4626 declaration sequence in a subprogram body). In the case of a
4627 postcondition appearing after a subprogram declaration, the
4628 formal arguments of the subprogram are visible, and can be
4629 referenced in the postcondition expressions.
4631 The postconditions are collected and automatically tested just
4632 before any return (implicit or explicit) in the subprogram body.
4633 A postcondition is only recognized if postconditions are active
4634 at the time the pragma is encountered. The compiler switch @option{gnata}
4635 turns on all postconditions by default, and pragma @code{Check_Policy}
4636 with an identifier of @code{Postcondition} can also be used to
4637 control whether postconditions are active.
4639 The general approach is that postconditions are placed in the spec
4640 if they represent functional aspects which make sense to the client.
4641 For example we might have:
4643 @smallexample @c ada
4644 function Direction return Integer;
4645 pragma Postcondition
4646 (Direction'Result = +1
4648 Direction'Result = -1);
4652 which serves to document that the result must be +1 or -1, and
4653 will test that this is the case at run time if postcondition
4656 Postconditions within the subprogram body can be used to
4657 check that some internal aspect of the implementation,
4658 not visible to the client, is operating as expected.
4659 For instance if a square root routine keeps an internal
4660 counter of the number of times it is called, then we
4661 might have the following postcondition:
4663 @smallexample @c ada
4664 Sqrt_Calls : Natural := 0;
4666 function Sqrt (Arg : Float) return Float is
4667 pragma Postcondition
4668 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4674 As this example, shows, the use of the @code{Old} attribute
4675 is often useful in postconditions to refer to the state on
4676 entry to the subprogram.
4678 Note that postconditions are only checked on normal returns
4679 from the subprogram. If an abnormal return results from
4680 raising an exception, then the postconditions are not checked.
4682 If a postcondition fails, then the exception
4683 @code{System.Assertions.Assert_Failure} is raised. If
4684 a message argument was supplied, then the given string
4685 will be used as the exception message. If no message
4686 argument was supplied, then the default message has
4687 the form "Postcondition failed at file:line". The
4688 exception is raised in the context of the subprogram
4689 body, so it is possible to catch postcondition failures
4690 within the subprogram body itself.
4692 Within a package spec, normal visibility rules
4693 in Ada would prevent forward references within a
4694 postcondition pragma to functions defined later in
4695 the same package. This would introduce undesirable
4696 ordering constraints. To avoid this problem, all
4697 postcondition pragmas are analyzed at the end of
4698 the package spec, allowing forward references.
4700 The following example shows that this even allows
4701 mutually recursive postconditions as in:
4703 @smallexample @c ada
4704 package Parity_Functions is
4705 function Odd (X : Natural) return Boolean;
4706 pragma Postcondition
4710 (x /= 0 and then Even (X - 1))));
4712 function Even (X : Natural) return Boolean;
4713 pragma Postcondition
4717 (x /= 1 and then Odd (X - 1))));
4719 end Parity_Functions;
4723 There are no restrictions on the complexity or form of
4724 conditions used within @code{Postcondition} pragmas.
4725 The following example shows that it is even possible
4726 to verify performance behavior.
4728 @smallexample @c ada
4731 Performance : constant Float;
4732 -- Performance constant set by implementation
4733 -- to match target architecture behavior.
4735 procedure Treesort (Arg : String);
4736 -- Sorts characters of argument using N*logN sort
4737 pragma Postcondition
4738 (Float (Clock - Clock'Old) <=
4739 Float (Arg'Length) *
4740 log (Float (Arg'Length)) *
4746 Note: postcondition pragmas associated with subprograms that are
4747 marked as Inline_Always, or those marked as Inline with front-end
4748 inlining (-gnatN option set) are accepted and legality-checked
4749 by the compiler, but are ignored at run-time even if postcondition
4750 checking is enabled.
4752 @node Pragma Preelaborable_Initialization
4753 @unnumberedsec Pragma Preelaborable_Initialization
4754 @findex Preelaborable_Initialization
4758 @smallexample @c ada
4759 pragma Preelaborable_Initialization (DIRECT_NAME);
4763 This pragma is standard in Ada 2005, but is available in all earlier
4764 versions of Ada as an implementation-defined pragma.
4765 See Ada 2012 Reference Manual for details.
4767 @node Pragma Priority_Specific_Dispatching
4768 @unnumberedsec Pragma Priority_Specific_Dispatching
4769 @findex Priority_Specific_Dispatching
4773 @smallexample @c ada
4774 pragma Priority_Specific_Dispatching (
4776 first_priority_EXPRESSION,
4777 last_priority_EXPRESSION)
4779 POLICY_IDENTIFIER ::=
4780 EDF_Across_Priorities |
4781 FIFO_Within_Priorities |
4782 Non_Preemptive_Within_Priorities |
4783 Round_Robin_Within_Priorities
4787 This pragma is standard in Ada 2005, but is available in all earlier
4788 versions of Ada as an implementation-defined pragma.
4789 See Ada 2012 Reference Manual for details.
4791 @node Pragma Precondition
4792 @unnumberedsec Pragma Precondition
4793 @cindex Preconditions
4794 @cindex Checks, preconditions
4795 @findex Preconditions
4799 @smallexample @c ada
4800 pragma Precondition (
4801 [Check =>] Boolean_Expression
4802 [,[Message =>] String_Expression]);
4806 The @code{Precondition} pragma is similar to @code{Postcondition}
4807 except that the corresponding checks take place immediately upon
4808 entry to the subprogram, and if a precondition fails, the exception
4809 is raised in the context of the caller, and the attribute 'Result
4810 cannot be used within the precondition expression.
4812 Otherwise, the placement and visibility rules are identical to those
4813 described for postconditions. The following is an example of use
4814 within a package spec:
4816 @smallexample @c ada
4817 package Math_Functions is
4819 function Sqrt (Arg : Float) return Float;
4820 pragma Precondition (Arg >= 0.0)
4826 @code{Precondition} pragmas may appear either immediately following the
4827 (separate) declaration of a subprogram, or at the start of the
4828 declarations of a subprogram body. Only other pragmas may intervene
4829 (that is appear between the subprogram declaration and its
4830 postconditions, or appear before the postcondition in the
4831 declaration sequence in a subprogram body).
4833 Note: postcondition pragmas associated with subprograms that are
4834 marked as Inline_Always, or those marked as Inline with front-end
4835 inlining (-gnatN option set) are accepted and legality-checked
4836 by the compiler, but are ignored at run-time even if postcondition
4837 checking is enabled.
4839 @node Pragma Profile (Ravenscar)
4840 @unnumberedsec Pragma Profile (Ravenscar)
4845 @smallexample @c ada
4846 pragma Profile (Ravenscar | Restricted);
4850 This pragma is standard in Ada 2005, but is available in all earlier
4851 versions of Ada as an implementation-defined pragma. This is a
4852 configuration pragma that establishes the following set of configuration
4856 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4857 [RM D.2.2] Tasks are dispatched following a preemptive
4858 priority-ordered scheduling policy.
4860 @item Locking_Policy (Ceiling_Locking)
4861 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4862 the ceiling priority of the corresponding protected object.
4864 @item Detect_Blocking
4865 This pragma forces the detection of potentially blocking operations within a
4866 protected operation, and to raise Program_Error if that happens.
4870 plus the following set of restrictions:
4873 @item Max_Entry_Queue_Length => 1
4874 No task can be queued on a protected entry.
4875 @item Max_Protected_Entries => 1
4876 @item Max_Task_Entries => 0
4877 No rendezvous statements are allowed.
4878 @item No_Abort_Statements
4879 @item No_Dynamic_Attachment
4880 @item No_Dynamic_Priorities
4881 @item No_Implicit_Heap_Allocations
4882 @item No_Local_Protected_Objects
4883 @item No_Local_Timing_Events
4884 @item No_Protected_Type_Allocators
4885 @item No_Relative_Delay
4886 @item No_Requeue_Statements
4887 @item No_Select_Statements
4888 @item No_Specific_Termination_Handlers
4889 @item No_Task_Allocators
4890 @item No_Task_Hierarchy
4891 @item No_Task_Termination
4892 @item Simple_Barriers
4896 The Ravenscar profile also includes the following restrictions that specify
4897 that there are no semantic dependences on the corresponding predefined
4901 @item No_Dependence => Ada.Asynchronous_Task_Control
4902 @item No_Dependence => Ada.Calendar
4903 @item No_Dependence => Ada.Execution_Time.Group_Budget
4904 @item No_Dependence => Ada.Execution_Time.Timers
4905 @item No_Dependence => Ada.Task_Attributes
4906 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4911 This set of configuration pragmas and restrictions correspond to the
4912 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4913 published by the @cite{International Real-Time Ada Workshop}, 1997,
4914 and whose most recent description is available at
4915 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4917 The original definition of the profile was revised at subsequent IRTAW
4918 meetings. It has been included in the ISO
4919 @cite{Guide for the Use of the Ada Programming Language in High
4920 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4921 the next revision of the standard. The formal definition given by
4922 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4923 AI-305) available at
4924 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4925 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4927 The above set is a superset of the restrictions provided by pragma
4928 @code{Profile (Restricted)}, it includes six additional restrictions
4929 (@code{Simple_Barriers}, @code{No_Select_Statements},
4930 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4931 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4932 that pragma @code{Profile (Ravenscar)}, like the pragma
4933 @code{Profile (Restricted)},
4934 automatically causes the use of a simplified,
4935 more efficient version of the tasking run-time system.
4937 @node Pragma Profile (Restricted)
4938 @unnumberedsec Pragma Profile (Restricted)
4939 @findex Restricted Run Time
4943 @smallexample @c ada
4944 pragma Profile (Restricted);
4948 This is an implementation-defined version of the standard pragma defined
4949 in Ada 2005. It is available in all versions of Ada. It is a
4950 configuration pragma that establishes the following set of restrictions:
4953 @item No_Abort_Statements
4954 @item No_Entry_Queue
4955 @item No_Task_Hierarchy
4956 @item No_Task_Allocators
4957 @item No_Dynamic_Priorities
4958 @item No_Terminate_Alternatives
4959 @item No_Dynamic_Attachment
4960 @item No_Protected_Type_Allocators
4961 @item No_Local_Protected_Objects
4962 @item No_Requeue_Statements
4963 @item No_Task_Attributes_Package
4964 @item Max_Asynchronous_Select_Nesting = 0
4965 @item Max_Task_Entries = 0
4966 @item Max_Protected_Entries = 1
4967 @item Max_Select_Alternatives = 0
4971 This set of restrictions causes the automatic selection of a simplified
4972 version of the run time that provides improved performance for the
4973 limited set of tasking functionality permitted by this set of restrictions.
4975 @node Pragma Profile (Rational)
4976 @unnumberedsec Pragma Profile (Rational)
4977 @findex Rational compatibility mode
4981 @smallexample @c ada
4982 pragma Profile (Rational);
4986 The Rational profile is intended to facilitate porting legacy code that
4987 compiles with the Rational APEX compiler, even when the code includes non-
4988 conforming Ada constructs. The profile enables the following three pragmas:
4991 pragma Implicit_Packing;
4992 pragma Overriding_Renamings;
4993 pragma Use_VADS_Size;
4997 @node Pragma Psect_Object
4998 @unnumberedsec Pragma Psect_Object
4999 @findex Psect_Object
5003 @smallexample @c ada
5004 pragma Psect_Object (
5005 [Internal =>] LOCAL_NAME,
5006 [, [External =>] EXTERNAL_SYMBOL]
5007 [, [Size =>] EXTERNAL_SYMBOL]);
5011 | static_string_EXPRESSION
5015 This pragma is identical in effect to pragma @code{Common_Object}.
5017 @node Pragma Pure_Function
5018 @unnumberedsec Pragma Pure_Function
5019 @findex Pure_Function
5023 @smallexample @c ada
5024 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5028 This pragma appears in the same declarative part as a function
5029 declaration (or a set of function declarations if more than one
5030 overloaded declaration exists, in which case the pragma applies
5031 to all entities). It specifies that the function @code{Entity} is
5032 to be considered pure for the purposes of code generation. This means
5033 that the compiler can assume that there are no side effects, and
5034 in particular that two calls with identical arguments produce the
5035 same result. It also means that the function can be used in an
5038 Note that, quite deliberately, there are no static checks to try
5039 to ensure that this promise is met, so @code{Pure_Function} can be used
5040 with functions that are conceptually pure, even if they do modify
5041 global variables. For example, a square root function that is
5042 instrumented to count the number of times it is called is still
5043 conceptually pure, and can still be optimized, even though it
5044 modifies a global variable (the count). Memo functions are another
5045 example (where a table of previous calls is kept and consulted to
5046 avoid re-computation).
5048 Note also that the normal rules excluding optimization of subprograms
5049 in pure units (when parameter types are descended from System.Address,
5050 or when the full view of a parameter type is limited), do not apply
5051 for the Pure_Function case. If you explicitly specify Pure_Function,
5052 the compiler may optimize away calls with identical arguments, and
5053 if that results in unexpected behavior, the proper action is not to
5054 use the pragma for subprograms that are not (conceptually) pure.
5057 Note: Most functions in a @code{Pure} package are automatically pure, and
5058 there is no need to use pragma @code{Pure_Function} for such functions. One
5059 exception is any function that has at least one formal of type
5060 @code{System.Address} or a type derived from it. Such functions are not
5061 considered pure by default, since the compiler assumes that the
5062 @code{Address} parameter may be functioning as a pointer and that the
5063 referenced data may change even if the address value does not.
5064 Similarly, imported functions are not considered to be pure by default,
5065 since there is no way of checking that they are in fact pure. The use
5066 of pragma @code{Pure_Function} for such a function will override these default
5067 assumption, and cause the compiler to treat a designated subprogram as pure
5070 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5071 applies to the underlying renamed function. This can be used to
5072 disambiguate cases of overloading where some but not all functions
5073 in a set of overloaded functions are to be designated as pure.
5075 If pragma @code{Pure_Function} is applied to a library level function, the
5076 function is also considered pure from an optimization point of view, but the
5077 unit is not a Pure unit in the categorization sense. So for example, a function
5078 thus marked is free to @code{with} non-pure units.
5080 @node Pragma Relative_Deadline
5081 @unnumberedsec Pragma Relative_Deadline
5082 @findex Relative_Deadline
5086 @smallexample @c ada
5087 pragma Relative_Deadline (time_span_EXPRESSSION);
5091 This pragma is standard in Ada 2005, but is available in all earlier
5092 versions of Ada as an implementation-defined pragma.
5093 See Ada 2012 Reference Manual for details.
5095 @node Pragma Remote_Access_Type
5096 @unnumberedsec Pragma Remote_Access_Type
5097 @findex Remote_Access_Type
5101 @smallexample @c ada
5102 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5106 This pragma appears in the formal part of a generic declaration.
5107 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5108 the use of a remote access to class-wide type as actual for a formal
5111 When this pragma applies to a formal access type @code{Entity}, that
5112 type is treated as a remote access to class-wide type in the generic.
5113 It must be a formal general access type, and its designated type must
5114 be the class-wide type of a formal tagged limited private type from the
5115 same generic declaration.
5117 In the generic unit, the formal type is subject to all restrictions
5118 pertaining to remote access to class-wide types. At instantiation, the
5119 actual type must be a remote access to class-wide type.
5121 @node Pragma Restriction_Warnings
5122 @unnumberedsec Pragma Restriction_Warnings
5123 @findex Restriction_Warnings
5127 @smallexample @c ada
5128 pragma Restriction_Warnings
5129 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
5133 This pragma allows a series of restriction identifiers to be
5134 specified (the list of allowed identifiers is the same as for
5135 pragma @code{Restrictions}). For each of these identifiers
5136 the compiler checks for violations of the restriction, but
5137 generates a warning message rather than an error message
5138 if the restriction is violated.
5141 @unnumberedsec Pragma Shared
5145 This pragma is provided for compatibility with Ada 83. The syntax and
5146 semantics are identical to pragma Atomic.
5148 @node Pragma Short_Circuit_And_Or
5149 @unnumberedsec Pragma Short_Circuit_And_Or
5150 @findex Short_Circuit_And_Or
5153 This configuration pragma causes any occurrence of the AND operator applied to
5154 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
5155 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
5156 may be useful in the context of certification protocols requiring the use of
5157 short-circuited logical operators. If this configuration pragma occurs locally
5158 within the file being compiled, it applies only to the file being compiled.
5159 There is no requirement that all units in a partition use this option.
5161 @node Pragma Short_Descriptors
5162 @unnumberedsec Pragma Short_Descriptors
5163 @findex Short_Descriptors
5167 @smallexample @c ada
5168 pragma Short_Descriptors
5172 In VMS versions of the compiler, this configuration pragma causes all
5173 occurrences of the mechanism types Descriptor[_xxx] to be treated as
5174 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
5175 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
5178 @node Pragma Simple_Storage_Pool_Type
5179 @unnumberedsec Pragma Simple_Storage_Pool_Type
5180 @findex Simple_Storage_Pool_Type
5181 @cindex Storage pool, simple
5182 @cindex Simple storage pool
5186 @smallexample @c ada
5187 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
5191 A type can be established as a ``simple storage pool type'' by applying
5192 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
5193 A type named in the pragma must be a library-level immutably limited record
5194 type or limited tagged type declared immediately within a package declaration.
5195 The type can also be a limited private type whose full type is allowed as
5196 a simple storage pool type.
5198 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
5199 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
5200 are subtype conformant with the following subprogram declarations:
5202 @smallexample @c ada
5205 Storage_Address : out System.Address;
5206 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5207 Alignment : System.Storage_Elements.Storage_Count);
5209 procedure Deallocate
5211 Storage_Address : System.Address;
5212 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5213 Alignment : System.Storage_Elements.Storage_Count);
5215 function Storage_Size (Pool : SSP)
5216 return System.Storage_Elements.Storage_Count;
5220 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
5221 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
5222 applying an unchecked deallocation has no effect other than to set its actual
5223 parameter to null. If @code{Storage_Size} is not declared, then the
5224 @code{Storage_Size} attribute applied to an access type associated with
5225 a pool object of type SSP returns zero. Additional operations can be declared
5226 for a simple storage pool type (such as for supporting a mark/release
5227 storage-management discipline).
5229 An object of a simple storage pool type can be associated with an access
5230 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
5232 @smallexample @c ada
5234 My_Pool : My_Simple_Storage_Pool_Type;
5236 type Acc is access My_Data_Type;
5238 for Acc'Simple_Storage_Pool use My_Pool;
5243 See attribute @code{Simple_Storage_Pool} for further details.
5245 @node Pragma Source_File_Name
5246 @unnumberedsec Pragma Source_File_Name
5247 @findex Source_File_Name
5251 @smallexample @c ada
5252 pragma Source_File_Name (
5253 [Unit_Name =>] unit_NAME,
5254 Spec_File_Name => STRING_LITERAL,
5255 [Index => INTEGER_LITERAL]);
5257 pragma Source_File_Name (
5258 [Unit_Name =>] unit_NAME,
5259 Body_File_Name => STRING_LITERAL,
5260 [Index => INTEGER_LITERAL]);
5264 Use this to override the normal naming convention. It is a configuration
5265 pragma, and so has the usual applicability of configuration pragmas
5266 (i.e.@: it applies to either an entire partition, or to all units in a
5267 compilation, or to a single unit, depending on how it is used.
5268 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
5269 the second argument is required, and indicates whether this is the file
5270 name for the spec or for the body.
5272 The optional Index argument should be used when a file contains multiple
5273 units, and when you do not want to use @code{gnatchop} to separate then
5274 into multiple files (which is the recommended procedure to limit the
5275 number of recompilations that are needed when some sources change).
5276 For instance, if the source file @file{source.ada} contains
5278 @smallexample @c ada
5290 you could use the following configuration pragmas:
5292 @smallexample @c ada
5293 pragma Source_File_Name
5294 (B, Spec_File_Name => "source.ada", Index => 1);
5295 pragma Source_File_Name
5296 (A, Body_File_Name => "source.ada", Index => 2);
5299 Note that the @code{gnatname} utility can also be used to generate those
5300 configuration pragmas.
5302 Another form of the @code{Source_File_Name} pragma allows
5303 the specification of patterns defining alternative file naming schemes
5304 to apply to all files.
5306 @smallexample @c ada
5307 pragma Source_File_Name
5308 ( [Spec_File_Name =>] STRING_LITERAL
5309 [,[Casing =>] CASING_SPEC]
5310 [,[Dot_Replacement =>] STRING_LITERAL]);
5312 pragma Source_File_Name
5313 ( [Body_File_Name =>] STRING_LITERAL
5314 [,[Casing =>] CASING_SPEC]
5315 [,[Dot_Replacement =>] STRING_LITERAL]);
5317 pragma Source_File_Name
5318 ( [Subunit_File_Name =>] STRING_LITERAL
5319 [,[Casing =>] CASING_SPEC]
5320 [,[Dot_Replacement =>] STRING_LITERAL]);
5322 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
5326 The first argument is a pattern that contains a single asterisk indicating
5327 the point at which the unit name is to be inserted in the pattern string
5328 to form the file name. The second argument is optional. If present it
5329 specifies the casing of the unit name in the resulting file name string.
5330 The default is lower case. Finally the third argument allows for systematic
5331 replacement of any dots in the unit name by the specified string literal.
5333 Note that Source_File_Name pragmas should not be used if you are using
5334 project files. The reason for this rule is that the project manager is not
5335 aware of these pragmas, and so other tools that use the projet file would not
5336 be aware of the intended naming conventions. If you are using project files,
5337 file naming is controlled by Source_File_Name_Project pragmas, which are
5338 usually supplied automatically by the project manager. A pragma
5339 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
5341 For more details on the use of the @code{Source_File_Name} pragma,
5342 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
5343 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
5346 @node Pragma Source_File_Name_Project
5347 @unnumberedsec Pragma Source_File_Name_Project
5348 @findex Source_File_Name_Project
5351 This pragma has the same syntax and semantics as pragma Source_File_Name.
5352 It is only allowed as a stand alone configuration pragma.
5353 It cannot appear after a @ref{Pragma Source_File_Name}, and
5354 most importantly, once pragma Source_File_Name_Project appears,
5355 no further Source_File_Name pragmas are allowed.
5357 The intention is that Source_File_Name_Project pragmas are always
5358 generated by the Project Manager in a manner consistent with the naming
5359 specified in a project file, and when naming is controlled in this manner,
5360 it is not permissible to attempt to modify this naming scheme using
5361 Source_File_Name or Source_File_Name_Project pragmas (which would not be
5362 known to the project manager).
5364 @node Pragma Source_Reference
5365 @unnumberedsec Pragma Source_Reference
5366 @findex Source_Reference
5370 @smallexample @c ada
5371 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
5375 This pragma must appear as the first line of a source file.
5376 @var{integer_literal} is the logical line number of the line following
5377 the pragma line (for use in error messages and debugging
5378 information). @var{string_literal} is a static string constant that
5379 specifies the file name to be used in error messages and debugging
5380 information. This is most notably used for the output of @code{gnatchop}
5381 with the @option{-r} switch, to make sure that the original unchopped
5382 source file is the one referred to.
5384 The second argument must be a string literal, it cannot be a static
5385 string expression other than a string literal. This is because its value
5386 is needed for error messages issued by all phases of the compiler.
5388 @node Pragma Static_Elaboration_Desired
5389 @unnumberedsec Pragma Static_Elaboration_Desired
5390 @findex Static_Elaboration_Desired
5394 @smallexample @c ada
5395 pragma Static_Elaboration_Desired;
5399 This pragma is used to indicate that the compiler should attempt to initialize
5400 statically the objects declared in the library unit to which the pragma applies,
5401 when these objects are initialized (explicitly or implicitly) by an aggregate.
5402 In the absence of this pragma, aggregates in object declarations are expanded
5403 into assignments and loops, even when the aggregate components are static
5404 constants. When the aggregate is present the compiler builds a static expression
5405 that requires no run-time code, so that the initialized object can be placed in
5406 read-only data space. If the components are not static, or the aggregate has
5407 more that 100 components, the compiler emits a warning that the pragma cannot
5408 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
5409 construction of larger aggregates with static components that include an others
5412 @node Pragma Stream_Convert
5413 @unnumberedsec Pragma Stream_Convert
5414 @findex Stream_Convert
5418 @smallexample @c ada
5419 pragma Stream_Convert (
5420 [Entity =>] type_LOCAL_NAME,
5421 [Read =>] function_NAME,
5422 [Write =>] function_NAME);
5426 This pragma provides an efficient way of providing stream functions for
5427 types defined in packages. Not only is it simpler to use than declaring
5428 the necessary functions with attribute representation clauses, but more
5429 significantly, it allows the declaration to made in such a way that the
5430 stream packages are not loaded unless they are needed. The use of
5431 the Stream_Convert pragma adds no overhead at all, unless the stream
5432 attributes are actually used on the designated type.
5434 The first argument specifies the type for which stream functions are
5435 provided. The second parameter provides a function used to read values
5436 of this type. It must name a function whose argument type may be any
5437 subtype, and whose returned type must be the type given as the first
5438 argument to the pragma.
5440 The meaning of the @var{Read}
5441 parameter is that if a stream attribute directly
5442 or indirectly specifies reading of the type given as the first parameter,
5443 then a value of the type given as the argument to the Read function is
5444 read from the stream, and then the Read function is used to convert this
5445 to the required target type.
5447 Similarly the @var{Write} parameter specifies how to treat write attributes
5448 that directly or indirectly apply to the type given as the first parameter.
5449 It must have an input parameter of the type specified by the first parameter,
5450 and the return type must be the same as the input type of the Read function.
5451 The effect is to first call the Write function to convert to the given stream
5452 type, and then write the result type to the stream.
5454 The Read and Write functions must not be overloaded subprograms. If necessary
5455 renamings can be supplied to meet this requirement.
5456 The usage of this attribute is best illustrated by a simple example, taken
5457 from the GNAT implementation of package Ada.Strings.Unbounded:
5459 @smallexample @c ada
5460 function To_Unbounded (S : String)
5461 return Unbounded_String
5462 renames To_Unbounded_String;
5464 pragma Stream_Convert
5465 (Unbounded_String, To_Unbounded, To_String);
5469 The specifications of the referenced functions, as given in the Ada
5470 Reference Manual are:
5472 @smallexample @c ada
5473 function To_Unbounded_String (Source : String)
5474 return Unbounded_String;
5476 function To_String (Source : Unbounded_String)
5481 The effect is that if the value of an unbounded string is written to a stream,
5482 then the representation of the item in the stream is in the same format that
5483 would be used for @code{Standard.String'Output}, and this same representation
5484 is expected when a value of this type is read from the stream. Note that the
5485 value written always includes the bounds, even for Unbounded_String'Write,
5486 since Unbounded_String is not an array type.
5488 @node Pragma Style_Checks
5489 @unnumberedsec Pragma Style_Checks
5490 @findex Style_Checks
5494 @smallexample @c ada
5495 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
5496 On | Off [, LOCAL_NAME]);
5500 This pragma is used in conjunction with compiler switches to control the
5501 built in style checking provided by GNAT@. The compiler switches, if set,
5502 provide an initial setting for the switches, and this pragma may be used
5503 to modify these settings, or the settings may be provided entirely by
5504 the use of the pragma. This pragma can be used anywhere that a pragma
5505 is legal, including use as a configuration pragma (including use in
5506 the @file{gnat.adc} file).
5508 The form with a string literal specifies which style options are to be
5509 activated. These are additive, so they apply in addition to any previously
5510 set style check options. The codes for the options are the same as those
5511 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
5512 For example the following two methods can be used to enable
5517 @smallexample @c ada
5518 pragma Style_Checks ("l");
5523 gcc -c -gnatyl @dots{}
5528 The form ALL_CHECKS activates all standard checks (its use is equivalent
5529 to the use of the @code{gnaty} switch with no options. @xref{Top,
5530 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
5531 @value{EDITION} User's Guide}, for details.)
5533 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
5534 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
5535 options (i.e. equivalent to -gnatyg).
5537 The forms with @code{Off} and @code{On}
5538 can be used to temporarily disable style checks
5539 as shown in the following example:
5541 @smallexample @c ada
5545 pragma Style_Checks ("k"); -- requires keywords in lower case
5546 pragma Style_Checks (Off); -- turn off style checks
5547 NULL; -- this will not generate an error message
5548 pragma Style_Checks (On); -- turn style checks back on
5549 NULL; -- this will generate an error message
5553 Finally the two argument form is allowed only if the first argument is
5554 @code{On} or @code{Off}. The effect is to turn of semantic style checks
5555 for the specified entity, as shown in the following example:
5557 @smallexample @c ada
5561 pragma Style_Checks ("r"); -- require consistency of identifier casing
5563 Rf1 : Integer := ARG; -- incorrect, wrong case
5564 pragma Style_Checks (Off, Arg);
5565 Rf2 : Integer := ARG; -- OK, no error
5568 @node Pragma Subtitle
5569 @unnumberedsec Pragma Subtitle
5574 @smallexample @c ada
5575 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5579 This pragma is recognized for compatibility with other Ada compilers
5580 but is ignored by GNAT@.
5582 @node Pragma Suppress
5583 @unnumberedsec Pragma Suppress
5588 @smallexample @c ada
5589 pragma Suppress (Identifier [, [On =>] Name]);
5593 This is a standard pragma, and supports all the check names required in
5594 the RM. It is included here because GNAT recognizes one additional check
5595 name: @code{Alignment_Check} which can be used to suppress alignment checks
5596 on addresses used in address clauses. Such checks can also be suppressed
5597 by suppressing range checks, but the specific use of @code{Alignment_Check}
5598 allows suppression of alignment checks without suppressing other range checks.
5600 Note that pragma Suppress gives the compiler permission to omit
5601 checks, but does not require the compiler to omit checks. The compiler
5602 will generate checks if they are essentially free, even when they are
5603 suppressed. In particular, if the compiler can prove that a certain
5604 check will necessarily fail, it will generate code to do an
5605 unconditional ``raise'', even if checks are suppressed. The compiler
5608 Of course, run-time checks are omitted whenever the compiler can prove
5609 that they will not fail, whether or not checks are suppressed.
5611 @node Pragma Suppress_All
5612 @unnumberedsec Pragma Suppress_All
5613 @findex Suppress_All
5617 @smallexample @c ada
5618 pragma Suppress_All;
5622 This pragma can appear anywhere within a unit.
5623 The effect is to apply @code{Suppress (All_Checks)} to the unit
5624 in which it appears. This pragma is implemented for compatibility with DEC
5625 Ada 83 usage where it appears at the end of a unit, and for compatibility
5626 with Rational Ada, where it appears as a program unit pragma.
5627 The use of the standard Ada pragma @code{Suppress (All_Checks)}
5628 as a normal configuration pragma is the preferred usage in GNAT@.
5630 @node Pragma Suppress_Exception_Locations
5631 @unnumberedsec Pragma Suppress_Exception_Locations
5632 @findex Suppress_Exception_Locations
5636 @smallexample @c ada
5637 pragma Suppress_Exception_Locations;
5641 In normal mode, a raise statement for an exception by default generates
5642 an exception message giving the file name and line number for the location
5643 of the raise. This is useful for debugging and logging purposes, but this
5644 entails extra space for the strings for the messages. The configuration
5645 pragma @code{Suppress_Exception_Locations} can be used to suppress the
5646 generation of these strings, with the result that space is saved, but the
5647 exception message for such raises is null. This configuration pragma may
5648 appear in a global configuration pragma file, or in a specific unit as
5649 usual. It is not required that this pragma be used consistently within
5650 a partition, so it is fine to have some units within a partition compiled
5651 with this pragma and others compiled in normal mode without it.
5653 @node Pragma Suppress_Initialization
5654 @unnumberedsec Pragma Suppress_Initialization
5655 @findex Suppress_Initialization
5656 @cindex Suppressing initialization
5657 @cindex Initialization, suppression of
5661 @smallexample @c ada
5662 pragma Suppress_Initialization ([Entity =>] subtype_Name);
5666 Here subtype_Name is the name introduced by a type declaration
5667 or subtype declaration.
5668 This pragma suppresses any implicit or explicit initialization
5669 for all variables of the given type or subtype,
5670 including initialization resulting from the use of pragmas
5671 Normalize_Scalars or Initialize_Scalars.
5673 This is considered a representation item, so it cannot be given after
5674 the type is frozen. It applies to all subsequent object declarations,
5675 and also any allocator that creates objects of the type.
5677 If the pragma is given for the first subtype, then it is considered
5678 to apply to the base type and all its subtypes. If the pragma is given
5679 for other than a first subtype, then it applies only to the given subtype.
5680 The pragma may not be given after the type is frozen.
5682 @node Pragma Task_Info
5683 @unnumberedsec Pragma Task_Info
5688 @smallexample @c ada
5689 pragma Task_Info (EXPRESSION);
5693 This pragma appears within a task definition (like pragma
5694 @code{Priority}) and applies to the task in which it appears. The
5695 argument must be of type @code{System.Task_Info.Task_Info_Type}.
5696 The @code{Task_Info} pragma provides system dependent control over
5697 aspects of tasking implementation, for example, the ability to map
5698 tasks to specific processors. For details on the facilities available
5699 for the version of GNAT that you are using, see the documentation
5700 in the spec of package System.Task_Info in the runtime
5703 @node Pragma Task_Name
5704 @unnumberedsec Pragma Task_Name
5709 @smallexample @c ada
5710 pragma Task_Name (string_EXPRESSION);
5714 This pragma appears within a task definition (like pragma
5715 @code{Priority}) and applies to the task in which it appears. The
5716 argument must be of type String, and provides a name to be used for
5717 the task instance when the task is created. Note that this expression
5718 is not required to be static, and in particular, it can contain
5719 references to task discriminants. This facility can be used to
5720 provide different names for different tasks as they are created,
5721 as illustrated in the example below.
5723 The task name is recorded internally in the run-time structures
5724 and is accessible to tools like the debugger. In addition the
5725 routine @code{Ada.Task_Identification.Image} will return this
5726 string, with a unique task address appended.
5728 @smallexample @c ada
5729 -- Example of the use of pragma Task_Name
5731 with Ada.Task_Identification;
5732 use Ada.Task_Identification;
5733 with Text_IO; use Text_IO;
5736 type Astring is access String;
5738 task type Task_Typ (Name : access String) is
5739 pragma Task_Name (Name.all);
5742 task body Task_Typ is
5743 Nam : constant String := Image (Current_Task);
5745 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5748 type Ptr_Task is access Task_Typ;
5749 Task_Var : Ptr_Task;
5753 new Task_Typ (new String'("This is task 1"));
5755 new Task_Typ (new String'("This is task 2"));
5759 @node Pragma Task_Storage
5760 @unnumberedsec Pragma Task_Storage
5761 @findex Task_Storage
5764 @smallexample @c ada
5765 pragma Task_Storage (
5766 [Task_Type =>] LOCAL_NAME,
5767 [Top_Guard =>] static_integer_EXPRESSION);
5771 This pragma specifies the length of the guard area for tasks. The guard
5772 area is an additional storage area allocated to a task. A value of zero
5773 means that either no guard area is created or a minimal guard area is
5774 created, depending on the target. This pragma can appear anywhere a
5775 @code{Storage_Size} attribute definition clause is allowed for a task
5778 @node Pragma Test_Case
5779 @unnumberedsec Pragma Test_Case
5785 @smallexample @c ada
5787 [Name =>] static_string_Expression
5788 ,[Mode =>] (Nominal | Robustness)
5789 [, Requires => Boolean_Expression]
5790 [, Ensures => Boolean_Expression]);
5794 The @code{Test_Case} pragma allows defining fine-grain specifications
5795 for use by testing tools. Its syntax is similar to the syntax of the
5796 @code{Contract_Case} pragma, which is used for both testing and
5797 formal verification.
5798 The compiler checks the validity of the @code{Test_Case} pragma, but its
5799 presence does not lead to any modification of the code generated by the
5800 compiler, contrary to the treatment of the @code{Contract_Case} pragma.
5802 @code{Test_Case} pragmas may only appear immediately following the
5803 (separate) declaration of a subprogram in a package declaration, inside
5804 a package spec unit. Only other pragmas may intervene (that is appear
5805 between the subprogram declaration and a test case).
5807 The compiler checks that boolean expressions given in @code{Requires} and
5808 @code{Ensures} are valid, where the rules for @code{Requires} are the
5809 same as the rule for an expression in @code{Precondition} and the rules
5810 for @code{Ensures} are the same as the rule for an expression in
5811 @code{Postcondition}. In particular, attributes @code{'Old} and
5812 @code{'Result} can only be used within the @code{Ensures}
5813 expression. The following is an example of use within a package spec:
5815 @smallexample @c ada
5816 package Math_Functions is
5818 function Sqrt (Arg : Float) return Float;
5819 pragma Test_Case (Name => "Test 1",
5821 Requires => Arg < 10000,
5822 Ensures => Sqrt'Result < 10);
5828 The meaning of a test case is that there is at least one context where
5829 @code{Requires} holds such that, if the associated subprogram is executed in
5830 that context, then @code{Ensures} holds when the subprogram returns.
5831 Mode @code{Nominal} indicates that the input context should also satisfy the
5832 precondition of the subprogram, and the output context should also satisfy its
5833 postcondition. More @code{Robustness} indicates that the precondition and
5834 postcondition of the subprogram should be ignored for this test case.
5836 @node Pragma Thread_Local_Storage
5837 @unnumberedsec Pragma Thread_Local_Storage
5838 @findex Thread_Local_Storage
5839 @cindex Task specific storage
5840 @cindex TLS (Thread Local Storage)
5843 @smallexample @c ada
5844 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5848 This pragma specifies that the specified entity, which must be
5849 a variable declared in a library level package, is to be marked as
5850 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5851 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5852 (and hence each Ada task) to see a distinct copy of the variable.
5854 The variable may not have default initialization, and if there is
5855 an explicit initialization, it must be either @code{null} for an
5856 access variable, or a static expression for a scalar variable.
5857 This provides a low level mechanism similar to that provided by
5858 the @code{Ada.Task_Attributes} package, but much more efficient
5859 and is also useful in writing interface code that will interact
5860 with foreign threads.
5862 If this pragma is used on a system where @code{TLS} is not supported,
5863 then an error message will be generated and the program will be rejected.
5865 @node Pragma Time_Slice
5866 @unnumberedsec Pragma Time_Slice
5871 @smallexample @c ada
5872 pragma Time_Slice (static_duration_EXPRESSION);
5876 For implementations of GNAT on operating systems where it is possible
5877 to supply a time slice value, this pragma may be used for this purpose.
5878 It is ignored if it is used in a system that does not allow this control,
5879 or if it appears in other than the main program unit.
5881 Note that the effect of this pragma is identical to the effect of the
5882 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5885 @unnumberedsec Pragma Title
5890 @smallexample @c ada
5891 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5894 [Title =>] STRING_LITERAL,
5895 | [Subtitle =>] STRING_LITERAL
5899 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5900 pragma used in DEC Ada 83 implementations to provide a title and/or
5901 subtitle for the program listing. The program listing generated by GNAT
5902 does not have titles or subtitles.
5904 Unlike other pragmas, the full flexibility of named notation is allowed
5905 for this pragma, i.e.@: the parameters may be given in any order if named
5906 notation is used, and named and positional notation can be mixed
5907 following the normal rules for procedure calls in Ada.
5909 @node Pragma Unchecked_Union
5910 @unnumberedsec Pragma Unchecked_Union
5912 @findex Unchecked_Union
5916 @smallexample @c ada
5917 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5921 This pragma is used to specify a representation of a record type that is
5922 equivalent to a C union. It was introduced as a GNAT implementation defined
5923 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5924 pragma, making it language defined, and GNAT fully implements this extended
5925 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5926 details, consult the Ada 2012 Reference Manual, section B.3.3.
5928 @node Pragma Unimplemented_Unit
5929 @unnumberedsec Pragma Unimplemented_Unit
5930 @findex Unimplemented_Unit
5934 @smallexample @c ada
5935 pragma Unimplemented_Unit;
5939 If this pragma occurs in a unit that is processed by the compiler, GNAT
5940 aborts with the message @samp{@var{xxx} not implemented}, where
5941 @var{xxx} is the name of the current compilation unit. This pragma is
5942 intended to allow the compiler to handle unimplemented library units in
5945 The abort only happens if code is being generated. Thus you can use
5946 specs of unimplemented packages in syntax or semantic checking mode.
5948 @node Pragma Universal_Aliasing
5949 @unnumberedsec Pragma Universal_Aliasing
5950 @findex Universal_Aliasing
5954 @smallexample @c ada
5955 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5959 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5960 declarative part. The effect is to inhibit strict type-based aliasing
5961 optimization for the given type. In other words, the effect is as though
5962 access types designating this type were subject to pragma No_Strict_Aliasing.
5963 For a detailed description of the strict aliasing optimization, and the
5964 situations in which it must be suppressed, @xref{Optimization and Strict
5965 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5967 @node Pragma Universal_Data
5968 @unnumberedsec Pragma Universal_Data
5969 @findex Universal_Data
5973 @smallexample @c ada
5974 pragma Universal_Data [(library_unit_Name)];
5978 This pragma is supported only for the AAMP target and is ignored for
5979 other targets. The pragma specifies that all library-level objects
5980 (Counter 0 data) associated with the library unit are to be accessed
5981 and updated using universal addressing (24-bit addresses for AAMP5)
5982 rather than the default of 16-bit Data Environment (DENV) addressing.
5983 Use of this pragma will generally result in less efficient code for
5984 references to global data associated with the library unit, but
5985 allows such data to be located anywhere in memory. This pragma is
5986 a library unit pragma, but can also be used as a configuration pragma
5987 (including use in the @file{gnat.adc} file). The functionality
5988 of this pragma is also available by applying the -univ switch on the
5989 compilations of units where universal addressing of the data is desired.
5991 @node Pragma Unmodified
5992 @unnumberedsec Pragma Unmodified
5994 @cindex Warnings, unmodified
5998 @smallexample @c ada
5999 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
6003 This pragma signals that the assignable entities (variables,
6004 @code{out} parameters, @code{in out} parameters) whose names are listed are
6005 deliberately not assigned in the current source unit. This
6006 suppresses warnings about the
6007 entities being referenced but not assigned, and in addition a warning will be
6008 generated if one of these entities is in fact assigned in the
6009 same unit as the pragma (or in the corresponding body, or one
6012 This is particularly useful for clearly signaling that a particular
6013 parameter is not modified, even though the spec suggests that it might
6016 @node Pragma Unreferenced
6017 @unnumberedsec Pragma Unreferenced
6018 @findex Unreferenced
6019 @cindex Warnings, unreferenced
6023 @smallexample @c ada
6024 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
6025 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
6029 This pragma signals that the entities whose names are listed are
6030 deliberately not referenced in the current source unit. This
6031 suppresses warnings about the
6032 entities being unreferenced, and in addition a warning will be
6033 generated if one of these entities is in fact subsequently referenced in the
6034 same unit as the pragma (or in the corresponding body, or one
6037 This is particularly useful for clearly signaling that a particular
6038 parameter is not referenced in some particular subprogram implementation
6039 and that this is deliberate. It can also be useful in the case of
6040 objects declared only for their initialization or finalization side
6043 If @code{LOCAL_NAME} identifies more than one matching homonym in the
6044 current scope, then the entity most recently declared is the one to which
6045 the pragma applies. Note that in the case of accept formals, the pragma
6046 Unreferenced may appear immediately after the keyword @code{do} which
6047 allows the indication of whether or not accept formals are referenced
6048 or not to be given individually for each accept statement.
6050 The left hand side of an assignment does not count as a reference for the
6051 purpose of this pragma. Thus it is fine to assign to an entity for which
6052 pragma Unreferenced is given.
6054 Note that if a warning is desired for all calls to a given subprogram,
6055 regardless of whether they occur in the same unit as the subprogram
6056 declaration, then this pragma should not be used (calls from another
6057 unit would not be flagged); pragma Obsolescent can be used instead
6058 for this purpose, see @xref{Pragma Obsolescent}.
6060 The second form of pragma @code{Unreferenced} is used within a context
6061 clause. In this case the arguments must be unit names of units previously
6062 mentioned in @code{with} clauses (similar to the usage of pragma
6063 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
6064 units and unreferenced entities within these units.
6066 @node Pragma Unreferenced_Objects
6067 @unnumberedsec Pragma Unreferenced_Objects
6068 @findex Unreferenced_Objects
6069 @cindex Warnings, unreferenced
6073 @smallexample @c ada
6074 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
6078 This pragma signals that for the types or subtypes whose names are
6079 listed, objects which are declared with one of these types or subtypes may
6080 not be referenced, and if no references appear, no warnings are given.
6082 This is particularly useful for objects which are declared solely for their
6083 initialization and finalization effect. Such variables are sometimes referred
6084 to as RAII variables (Resource Acquisition Is Initialization). Using this
6085 pragma on the relevant type (most typically a limited controlled type), the
6086 compiler will automatically suppress unwanted warnings about these variables
6087 not being referenced.
6089 @node Pragma Unreserve_All_Interrupts
6090 @unnumberedsec Pragma Unreserve_All_Interrupts
6091 @findex Unreserve_All_Interrupts
6095 @smallexample @c ada
6096 pragma Unreserve_All_Interrupts;
6100 Normally certain interrupts are reserved to the implementation. Any attempt
6101 to attach an interrupt causes Program_Error to be raised, as described in
6102 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
6103 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
6104 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
6105 interrupt execution.
6107 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
6108 a program, then all such interrupts are unreserved. This allows the
6109 program to handle these interrupts, but disables their standard
6110 functions. For example, if this pragma is used, then pressing
6111 @kbd{Ctrl-C} will not automatically interrupt execution. However,
6112 a program can then handle the @code{SIGINT} interrupt as it chooses.
6114 For a full list of the interrupts handled in a specific implementation,
6115 see the source code for the spec of @code{Ada.Interrupts.Names} in
6116 file @file{a-intnam.ads}. This is a target dependent file that contains the
6117 list of interrupts recognized for a given target. The documentation in
6118 this file also specifies what interrupts are affected by the use of
6119 the @code{Unreserve_All_Interrupts} pragma.
6121 For a more general facility for controlling what interrupts can be
6122 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
6123 of the @code{Unreserve_All_Interrupts} pragma.
6125 @node Pragma Unsuppress
6126 @unnumberedsec Pragma Unsuppress
6131 @smallexample @c ada
6132 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
6136 This pragma undoes the effect of a previous pragma @code{Suppress}. If
6137 there is no corresponding pragma @code{Suppress} in effect, it has no
6138 effect. The range of the effect is the same as for pragma
6139 @code{Suppress}. The meaning of the arguments is identical to that used
6140 in pragma @code{Suppress}.
6142 One important application is to ensure that checks are on in cases where
6143 code depends on the checks for its correct functioning, so that the code
6144 will compile correctly even if the compiler switches are set to suppress
6147 This pragma is standard in Ada 2005. It is available in all earlier versions
6148 of Ada as an implementation-defined pragma.
6150 @node Pragma Use_VADS_Size
6151 @unnumberedsec Pragma Use_VADS_Size
6152 @cindex @code{Size}, VADS compatibility
6153 @cindex Rational profile
6154 @findex Use_VADS_Size
6158 @smallexample @c ada
6159 pragma Use_VADS_Size;
6163 This is a configuration pragma. In a unit to which it applies, any use
6164 of the 'Size attribute is automatically interpreted as a use of the
6165 'VADS_Size attribute. Note that this may result in incorrect semantic
6166 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
6167 the handling of existing code which depends on the interpretation of Size
6168 as implemented in the VADS compiler. See description of the VADS_Size
6169 attribute for further details.
6171 @node Pragma Validity_Checks
6172 @unnumberedsec Pragma Validity_Checks
6173 @findex Validity_Checks
6177 @smallexample @c ada
6178 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
6182 This pragma is used in conjunction with compiler switches to control the
6183 built-in validity checking provided by GNAT@. The compiler switches, if set
6184 provide an initial setting for the switches, and this pragma may be used
6185 to modify these settings, or the settings may be provided entirely by
6186 the use of the pragma. This pragma can be used anywhere that a pragma
6187 is legal, including use as a configuration pragma (including use in
6188 the @file{gnat.adc} file).
6190 The form with a string literal specifies which validity options are to be
6191 activated. The validity checks are first set to include only the default
6192 reference manual settings, and then a string of letters in the string
6193 specifies the exact set of options required. The form of this string
6194 is exactly as described for the @option{-gnatVx} compiler switch (see the
6195 @value{EDITION} User's Guide for details). For example the following two
6196 methods can be used to enable validity checking for mode @code{in} and
6197 @code{in out} subprogram parameters:
6201 @smallexample @c ada
6202 pragma Validity_Checks ("im");
6207 gcc -c -gnatVim @dots{}
6212 The form ALL_CHECKS activates all standard checks (its use is equivalent
6213 to the use of the @code{gnatva} switch.
6215 The forms with @code{Off} and @code{On}
6216 can be used to temporarily disable validity checks
6217 as shown in the following example:
6219 @smallexample @c ada
6223 pragma Validity_Checks ("c"); -- validity checks for copies
6224 pragma Validity_Checks (Off); -- turn off validity checks
6225 A := B; -- B will not be validity checked
6226 pragma Validity_Checks (On); -- turn validity checks back on
6227 A := C; -- C will be validity checked
6230 @node Pragma Volatile
6231 @unnumberedsec Pragma Volatile
6236 @smallexample @c ada
6237 pragma Volatile (LOCAL_NAME);
6241 This pragma is defined by the Ada Reference Manual, and the GNAT
6242 implementation is fully conformant with this definition. The reason it
6243 is mentioned in this section is that a pragma of the same name was supplied
6244 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
6245 implementation of pragma Volatile is upwards compatible with the
6246 implementation in DEC Ada 83.
6248 @node Pragma Warnings
6249 @unnumberedsec Pragma Warnings
6254 @smallexample @c ada
6255 pragma Warnings (On | Off);
6256 pragma Warnings (On | Off, LOCAL_NAME);
6257 pragma Warnings (static_string_EXPRESSION);
6258 pragma Warnings (On | Off, static_string_EXPRESSION);
6262 Normally warnings are enabled, with the output being controlled by
6263 the command line switch. Warnings (@code{Off}) turns off generation of
6264 warnings until a Warnings (@code{On}) is encountered or the end of the
6265 current unit. If generation of warnings is turned off using this
6266 pragma, then no warning messages are output, regardless of the
6267 setting of the command line switches.
6269 The form with a single argument may be used as a configuration pragma.
6271 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
6272 the specified entity. This suppression is effective from the point where
6273 it occurs till the end of the extended scope of the variable (similar to
6274 the scope of @code{Suppress}).
6276 The form with a single static_string_EXPRESSION argument provides more precise
6277 control over which warnings are active. The string is a list of letters
6278 specifying which warnings are to be activated and which deactivated. The
6279 code for these letters is the same as the string used in the command
6280 line switch controlling warnings. For a brief summary, use the gnatmake
6281 command with no arguments, which will generate usage information containing
6282 the list of warnings switches supported. For
6283 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
6287 The warnings controlled by the `-gnatw' switch are generated by the front end
6288 of the compiler. The `GCC' back end can provide additional warnings and they
6289 are controlled by the `-W' switch.
6290 The form with a single static_string_EXPRESSION argument also works for the
6291 latters, but the string must be a single full `-W' switch in this case.
6292 The above reference lists a few examples of these additional warnings.
6295 The specified warnings will be in effect until the end of the program
6296 or another pragma Warnings is encountered. The effect of the pragma is
6297 cumulative. Initially the set of warnings is the standard default set
6298 as possibly modified by compiler switches. Then each pragma Warning
6299 modifies this set of warnings as specified. This form of the pragma may
6300 also be used as a configuration pragma.
6302 The fourth form, with an @code{On|Off} parameter and a string, is used to
6303 control individual messages, based on their text. The string argument
6304 is a pattern that is used to match against the text of individual
6305 warning messages (not including the initial "warning: " tag).
6307 The pattern may contain asterisks, which match zero or more characters in
6308 the message. For example, you can use
6309 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
6310 message @code{warning: 960 bits of "a" unused}. No other regular
6311 expression notations are permitted. All characters other than asterisk in
6312 these three specific cases are treated as literal characters in the match.
6314 The above use of patterns to match the message applies only to warning
6315 messages generated by the front end. This form of the pragma with a
6316 string argument can also be used to control back end warnings controlled
6317 by a "-Wxxx" switch. Such warnings can be identified by the appearence
6318 of a string of the form "[-Wxxx]" in the message which identifies the
6319 "-W" switch that controls the message. By using the text of the
6320 "-W" switch in the pragma, such back end warnings can be turned on and off.
6322 There are two ways to use the pragma in this form. The OFF form can be used as a
6323 configuration pragma. The effect is to suppress all warnings (if any)
6324 that match the pattern string throughout the compilation (or match the
6325 -W switch in the back end case).
6327 The second usage is to suppress a warning locally, and in this case, two
6328 pragmas must appear in sequence:
6330 @smallexample @c ada
6331 pragma Warnings (Off, Pattern);
6332 @dots{} code where given warning is to be suppressed
6333 pragma Warnings (On, Pattern);
6337 In this usage, the pattern string must match in the Off and On pragmas,
6338 and at least one matching warning must be suppressed.
6340 Note: to write a string that will match any warning, use the string
6341 @code{"***"}. It will not work to use a single asterisk or two asterisks
6342 since this looks like an operator name. This form with three asterisks
6343 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
6344 matching @code{pragma Warnings (On, "***")} will be required. This can be
6345 helpful in avoiding forgetting to turn warnings back on.
6347 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
6348 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
6349 be useful in checking whether obsolete pragmas in existing programs are hiding
6352 Note: pragma Warnings does not affect the processing of style messages. See
6353 separate entry for pragma Style_Checks for control of style messages.
6355 @node Pragma Weak_External
6356 @unnumberedsec Pragma Weak_External
6357 @findex Weak_External
6361 @smallexample @c ada
6362 pragma Weak_External ([Entity =>] LOCAL_NAME);
6366 @var{LOCAL_NAME} must refer to an object that is declared at the library
6367 level. This pragma specifies that the given entity should be marked as a
6368 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
6369 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
6370 of a regular symbol, that is to say a symbol that does not have to be
6371 resolved by the linker if used in conjunction with a pragma Import.
6373 When a weak symbol is not resolved by the linker, its address is set to
6374 zero. This is useful in writing interfaces to external modules that may
6375 or may not be linked in the final executable, for example depending on
6376 configuration settings.
6378 If a program references at run time an entity to which this pragma has been
6379 applied, and the corresponding symbol was not resolved at link time, then
6380 the execution of the program is erroneous. It is not erroneous to take the
6381 Address of such an entity, for example to guard potential references,
6382 as shown in the example below.
6384 Some file formats do not support weak symbols so not all target machines
6385 support this pragma.
6387 @smallexample @c ada
6388 -- Example of the use of pragma Weak_External
6390 package External_Module is
6392 pragma Import (C, key);
6393 pragma Weak_External (key);
6394 function Present return boolean;
6395 end External_Module;
6397 with System; use System;
6398 package body External_Module is
6399 function Present return boolean is
6401 return key'Address /= System.Null_Address;
6403 end External_Module;
6406 @node Pragma Wide_Character_Encoding
6407 @unnumberedsec Pragma Wide_Character_Encoding
6408 @findex Wide_Character_Encoding
6412 @smallexample @c ada
6413 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
6417 This pragma specifies the wide character encoding to be used in program
6418 source text appearing subsequently. It is a configuration pragma, but may
6419 also be used at any point that a pragma is allowed, and it is permissible
6420 to have more than one such pragma in a file, allowing multiple encodings
6421 to appear within the same file.
6423 The argument can be an identifier or a character literal. In the identifier
6424 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
6425 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
6426 case it is correspondingly one of the characters @samp{h}, @samp{u},
6427 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
6429 Note that when the pragma is used within a file, it affects only the
6430 encoding within that file, and does not affect withed units, specs,
6433 @node Implementation Defined Attributes
6434 @chapter Implementation Defined Attributes
6435 Ada defines (throughout the Ada reference manual,
6436 summarized in Annex K),
6437 a set of attributes that provide useful additional functionality in all
6438 areas of the language. These language defined attributes are implemented
6439 in GNAT and work as described in the Ada Reference Manual.
6441 In addition, Ada allows implementations to define additional
6442 attributes whose meaning is defined by the implementation. GNAT provides
6443 a number of these implementation-dependent attributes which can be used
6444 to extend and enhance the functionality of the compiler. This section of
6445 the GNAT reference manual describes these additional attributes.
6447 Note that any program using these attributes may not be portable to
6448 other compilers (although GNAT implements this set of attributes on all
6449 platforms). Therefore if portability to other compilers is an important
6450 consideration, you should minimize the use of these attributes.
6460 * Compiler_Version::
6462 * Default_Bit_Order::
6474 * Has_Access_Values::
6475 * Has_Discriminants::
6482 * Max_Interrupt_Priority::
6484 * Maximum_Alignment::
6488 * Passed_By_Reference::
6495 * Scalar_Storage_Order::
6496 * Simple_Storage_Pool::
6500 * System_Allocator_Alignment::
6506 * Unconstrained_Array::
6507 * Universal_Literal_String::
6508 * Unrestricted_Access::
6517 @unnumberedsec Abort_Signal
6518 @findex Abort_Signal
6520 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
6521 prefix) provides the entity for the special exception used to signal
6522 task abort or asynchronous transfer of control. Normally this attribute
6523 should only be used in the tasking runtime (it is highly peculiar, and
6524 completely outside the normal semantics of Ada, for a user program to
6525 intercept the abort exception).
6528 @unnumberedsec Address_Size
6529 @cindex Size of @code{Address}
6530 @findex Address_Size
6532 @code{Standard'Address_Size} (@code{Standard} is the only allowed
6533 prefix) is a static constant giving the number of bits in an
6534 @code{Address}. It is the same value as System.Address'Size,
6535 but has the advantage of being static, while a direct
6536 reference to System.Address'Size is non-static because Address
6540 @unnumberedsec Asm_Input
6543 The @code{Asm_Input} attribute denotes a function that takes two
6544 parameters. The first is a string, the second is an expression of the
6545 type designated by the prefix. The first (string) argument is required
6546 to be a static expression, and is the constraint for the parameter,
6547 (e.g.@: what kind of register is required). The second argument is the
6548 value to be used as the input argument. The possible values for the
6549 constant are the same as those used in the RTL, and are dependent on
6550 the configuration file used to built the GCC back end.
6551 @ref{Machine Code Insertions}
6554 @unnumberedsec Asm_Output
6557 The @code{Asm_Output} attribute denotes a function that takes two
6558 parameters. The first is a string, the second is the name of a variable
6559 of the type designated by the attribute prefix. The first (string)
6560 argument is required to be a static expression and designates the
6561 constraint for the parameter (e.g.@: what kind of register is
6562 required). The second argument is the variable to be updated with the
6563 result. The possible values for constraint are the same as those used in
6564 the RTL, and are dependent on the configuration file used to build the
6565 GCC back end. If there are no output operands, then this argument may
6566 either be omitted, or explicitly given as @code{No_Output_Operands}.
6567 @ref{Machine Code Insertions}
6570 @unnumberedsec AST_Entry
6574 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
6575 the name of an entry, it yields a value of the predefined type AST_Handler
6576 (declared in the predefined package System, as extended by the use of
6577 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
6578 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
6579 Language Reference Manual}, section 9.12a.
6584 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
6585 offset within the storage unit (byte) that contains the first bit of
6586 storage allocated for the object. The value of this attribute is of the
6587 type @code{Universal_Integer}, and is always a non-negative number not
6588 exceeding the value of @code{System.Storage_Unit}.
6590 For an object that is a variable or a constant allocated in a register,
6591 the value is zero. (The use of this attribute does not force the
6592 allocation of a variable to memory).
6594 For an object that is a formal parameter, this attribute applies
6595 to either the matching actual parameter or to a copy of the
6596 matching actual parameter.
6598 For an access object the value is zero. Note that
6599 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
6600 designated object. Similarly for a record component
6601 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
6602 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
6603 are subject to index checks.
6605 This attribute is designed to be compatible with the DEC Ada 83 definition
6606 and implementation of the @code{Bit} attribute.
6609 @unnumberedsec Bit_Position
6610 @findex Bit_Position
6612 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
6613 of the fields of the record type, yields the bit
6614 offset within the record contains the first bit of
6615 storage allocated for the object. The value of this attribute is of the
6616 type @code{Universal_Integer}. The value depends only on the field
6617 @var{C} and is independent of the alignment of
6618 the containing record @var{R}.
6620 @node Compiler_Version
6621 @unnumberedsec Compiler_Version
6622 @findex Compiler_Version
6624 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
6625 prefix) yields a static string identifying the version of the compiler
6626 being used to compile the unit containing the attribute reference. A
6627 typical result would be something like "@value{EDITION} @i{version} (20090221)".
6630 @unnumberedsec Code_Address
6631 @findex Code_Address
6632 @cindex Subprogram address
6633 @cindex Address of subprogram code
6636 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
6637 intended effect seems to be to provide
6638 an address value which can be used to call the subprogram by means of
6639 an address clause as in the following example:
6641 @smallexample @c ada
6642 procedure K is @dots{}
6645 for L'Address use K'Address;
6646 pragma Import (Ada, L);
6650 A call to @code{L} is then expected to result in a call to @code{K}@.
6651 In Ada 83, where there were no access-to-subprogram values, this was
6652 a common work-around for getting the effect of an indirect call.
6653 GNAT implements the above use of @code{Address} and the technique
6654 illustrated by the example code works correctly.
6656 However, for some purposes, it is useful to have the address of the start
6657 of the generated code for the subprogram. On some architectures, this is
6658 not necessarily the same as the @code{Address} value described above.
6659 For example, the @code{Address} value may reference a subprogram
6660 descriptor rather than the subprogram itself.
6662 The @code{'Code_Address} attribute, which can only be applied to
6663 subprogram entities, always returns the address of the start of the
6664 generated code of the specified subprogram, which may or may not be
6665 the same value as is returned by the corresponding @code{'Address}
6668 @node Default_Bit_Order
6669 @unnumberedsec Default_Bit_Order
6671 @cindex Little endian
6672 @findex Default_Bit_Order
6674 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
6675 permissible prefix), provides the value @code{System.Default_Bit_Order}
6676 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
6677 @code{Low_Order_First}). This is used to construct the definition of
6678 @code{Default_Bit_Order} in package @code{System}.
6680 @node Descriptor_Size
6681 @unnumberedsec Descriptor_Size
6684 @findex Descriptor_Size
6686 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
6687 descriptor allocated for a type. The result is non-zero only for unconstrained
6688 array types and the returned value is of type universal integer. In GNAT, an
6689 array descriptor contains bounds information and is located immediately before
6690 the first element of the array.
6692 @smallexample @c ada
6693 type Unconstr_Array is array (Positive range <>) of Boolean;
6694 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
6698 The attribute takes into account any additional padding due to type alignment.
6699 In the example above, the descriptor contains two values of type
6700 @code{Positive} representing the low and high bound. Since @code{Positive} has
6701 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
6702 Positive'Size + 2} or 64 bits.
6705 @unnumberedsec Elaborated
6708 The prefix of the @code{'Elaborated} attribute must be a unit name. The
6709 value is a Boolean which indicates whether or not the given unit has been
6710 elaborated. This attribute is primarily intended for internal use by the
6711 generated code for dynamic elaboration checking, but it can also be used
6712 in user programs. The value will always be True once elaboration of all
6713 units has been completed. An exception is for units which need no
6714 elaboration, the value is always False for such units.
6717 @unnumberedsec Elab_Body
6720 This attribute can only be applied to a program unit name. It returns
6721 the entity for the corresponding elaboration procedure for elaborating
6722 the body of the referenced unit. This is used in the main generated
6723 elaboration procedure by the binder and is not normally used in any
6724 other context. However, there may be specialized situations in which it
6725 is useful to be able to call this elaboration procedure from Ada code,
6726 e.g.@: if it is necessary to do selective re-elaboration to fix some
6730 @unnumberedsec Elab_Spec
6733 This attribute can only be applied to a program unit name. It returns
6734 the entity for the corresponding elaboration procedure for elaborating
6735 the spec of the referenced unit. This is used in the main
6736 generated elaboration procedure by the binder and is not normally used
6737 in any other context. However, there may be specialized situations in
6738 which it is useful to be able to call this elaboration procedure from
6739 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6742 @node Elab_Subp_Body
6743 @unnumberedsec Elab_Subp_Body
6744 @findex Elab_Subp_Body
6746 This attribute can only be applied to a library level subprogram
6747 name and is only allowed in CodePeer mode. It returns the entity
6748 for the corresponding elaboration procedure for elaborating the body
6749 of the referenced subprogram unit. This is used in the main generated
6750 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6755 @cindex Ada 83 attributes
6758 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6759 the Ada 83 reference manual for an exact description of the semantics of
6763 @unnumberedsec Enabled
6766 The @code{Enabled} attribute allows an application program to check at compile
6767 time to see if the designated check is currently enabled. The prefix is a
6768 simple identifier, referencing any predefined check name (other than
6769 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6770 no argument is given for the attribute, the check is for the general state
6771 of the check, if an argument is given, then it is an entity name, and the
6772 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6773 given naming the entity (if not, then the argument is ignored).
6775 Note that instantiations inherit the check status at the point of the
6776 instantiation, so a useful idiom is to have a library package that
6777 introduces a check name with @code{pragma Check_Name}, and then contains
6778 generic packages or subprograms which use the @code{Enabled} attribute
6779 to see if the check is enabled. A user of this package can then issue
6780 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6781 the package or subprogram, controlling whether the check will be present.
6784 @unnumberedsec Enum_Rep
6785 @cindex Representation of enums
6788 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6789 function with the following spec:
6791 @smallexample @c ada
6792 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6793 return @i{Universal_Integer};
6797 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6798 enumeration type or to a non-overloaded enumeration
6799 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6800 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6801 enumeration literal or object.
6803 The function returns the representation value for the given enumeration
6804 value. This will be equal to value of the @code{Pos} attribute in the
6805 absence of an enumeration representation clause. This is a static
6806 attribute (i.e.@: the result is static if the argument is static).
6808 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6809 in which case it simply returns the integer value. The reason for this
6810 is to allow it to be used for @code{(<>)} discrete formal arguments in
6811 a generic unit that can be instantiated with either enumeration types
6812 or integer types. Note that if @code{Enum_Rep} is used on a modular
6813 type whose upper bound exceeds the upper bound of the largest signed
6814 integer type, and the argument is a variable, so that the universal
6815 integer calculation is done at run time, then the call to @code{Enum_Rep}
6816 may raise @code{Constraint_Error}.
6819 @unnumberedsec Enum_Val
6820 @cindex Representation of enums
6823 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6824 function with the following spec:
6826 @smallexample @c ada
6827 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6828 return @var{S}'Base};
6832 The function returns the enumeration value whose representation matches the
6833 argument, or raises Constraint_Error if no enumeration literal of the type
6834 has the matching value.
6835 This will be equal to value of the @code{Val} attribute in the
6836 absence of an enumeration representation clause. This is a static
6837 attribute (i.e.@: the result is static if the argument is static).
6840 @unnumberedsec Epsilon
6841 @cindex Ada 83 attributes
6844 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6845 the Ada 83 reference manual for an exact description of the semantics of
6849 @unnumberedsec Fixed_Value
6852 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6853 function with the following specification:
6855 @smallexample @c ada
6856 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6861 The value returned is the fixed-point value @var{V} such that
6863 @smallexample @c ada
6864 @var{V} = Arg * @var{S}'Small
6868 The effect is thus similar to first converting the argument to the
6869 integer type used to represent @var{S}, and then doing an unchecked
6870 conversion to the fixed-point type. The difference is
6871 that there are full range checks, to ensure that the result is in range.
6872 This attribute is primarily intended for use in implementation of the
6873 input-output functions for fixed-point values.
6875 @node Has_Access_Values
6876 @unnumberedsec Has_Access_Values
6877 @cindex Access values, testing for
6878 @findex Has_Access_Values
6880 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6881 is a Boolean value which is True if the is an access type, or is a composite
6882 type with a component (at any nesting depth) that is an access type, and is
6884 The intended use of this attribute is in conjunction with generic
6885 definitions. If the attribute is applied to a generic private type, it
6886 indicates whether or not the corresponding actual type has access values.
6888 @node Has_Discriminants
6889 @unnumberedsec Has_Discriminants
6890 @cindex Discriminants, testing for
6891 @findex Has_Discriminants
6893 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6894 is a Boolean value which is True if the type has discriminants, and False
6895 otherwise. The intended use of this attribute is in conjunction with generic
6896 definitions. If the attribute is applied to a generic private type, it
6897 indicates whether or not the corresponding actual type has discriminants.
6903 The @code{Img} attribute differs from @code{Image} in that it may be
6904 applied to objects as well as types, in which case it gives the
6905 @code{Image} for the subtype of the object. This is convenient for
6908 @smallexample @c ada
6909 Put_Line ("X = " & X'Img);
6913 has the same meaning as the more verbose:
6915 @smallexample @c ada
6916 Put_Line ("X = " & @var{T}'Image (X));
6920 where @var{T} is the (sub)type of the object @code{X}.
6923 @unnumberedsec Integer_Value
6924 @findex Integer_Value
6926 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6927 function with the following spec:
6929 @smallexample @c ada
6930 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6935 The value returned is the integer value @var{V}, such that
6937 @smallexample @c ada
6938 Arg = @var{V} * @var{T}'Small
6942 where @var{T} is the type of @code{Arg}.
6943 The effect is thus similar to first doing an unchecked conversion from
6944 the fixed-point type to its corresponding implementation type, and then
6945 converting the result to the target integer type. The difference is
6946 that there are full range checks, to ensure that the result is in range.
6947 This attribute is primarily intended for use in implementation of the
6948 standard input-output functions for fixed-point values.
6951 @unnumberedsec Invalid_Value
6952 @findex Invalid_Value
6954 For every scalar type S, S'Invalid_Value returns an undefined value of the
6955 type. If possible this value is an invalid representation for the type. The
6956 value returned is identical to the value used to initialize an otherwise
6957 uninitialized value of the type if pragma Initialize_Scalars is used,
6958 including the ability to modify the value with the binder -Sxx flag and
6959 relevant environment variables at run time.
6962 @unnumberedsec Large
6963 @cindex Ada 83 attributes
6966 The @code{Large} attribute is provided for compatibility with Ada 83. See
6967 the Ada 83 reference manual for an exact description of the semantics of
6971 @unnumberedsec Machine_Size
6972 @findex Machine_Size
6974 This attribute is identical to the @code{Object_Size} attribute. It is
6975 provided for compatibility with the DEC Ada 83 attribute of this name.
6978 @unnumberedsec Mantissa
6979 @cindex Ada 83 attributes
6982 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6983 the Ada 83 reference manual for an exact description of the semantics of
6986 @node Max_Interrupt_Priority
6987 @unnumberedsec Max_Interrupt_Priority
6988 @cindex Interrupt priority, maximum
6989 @findex Max_Interrupt_Priority
6991 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6992 permissible prefix), provides the same value as
6993 @code{System.Max_Interrupt_Priority}.
6996 @unnumberedsec Max_Priority
6997 @cindex Priority, maximum
6998 @findex Max_Priority
7000 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
7001 prefix) provides the same value as @code{System.Max_Priority}.
7003 @node Maximum_Alignment
7004 @unnumberedsec Maximum_Alignment
7005 @cindex Alignment, maximum
7006 @findex Maximum_Alignment
7008 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
7009 permissible prefix) provides the maximum useful alignment value for the
7010 target. This is a static value that can be used to specify the alignment
7011 for an object, guaranteeing that it is properly aligned in all
7014 @node Mechanism_Code
7015 @unnumberedsec Mechanism_Code
7016 @cindex Return values, passing mechanism
7017 @cindex Parameters, passing mechanism
7018 @findex Mechanism_Code
7020 @code{@var{function}'Mechanism_Code} yields an integer code for the
7021 mechanism used for the result of function, and
7022 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
7023 used for formal parameter number @var{n} (a static integer value with 1
7024 meaning the first parameter) of @var{subprogram}. The code returned is:
7032 by descriptor (default descriptor class)
7034 by descriptor (UBS: unaligned bit string)
7036 by descriptor (UBSB: aligned bit string with arbitrary bounds)
7038 by descriptor (UBA: unaligned bit array)
7040 by descriptor (S: string, also scalar access type parameter)
7042 by descriptor (SB: string with arbitrary bounds)
7044 by descriptor (A: contiguous array)
7046 by descriptor (NCA: non-contiguous array)
7050 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
7053 @node Null_Parameter
7054 @unnumberedsec Null_Parameter
7055 @cindex Zero address, passing
7056 @findex Null_Parameter
7058 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
7059 type or subtype @var{T} allocated at machine address zero. The attribute
7060 is allowed only as the default expression of a formal parameter, or as
7061 an actual expression of a subprogram call. In either case, the
7062 subprogram must be imported.
7064 The identity of the object is represented by the address zero in the
7065 argument list, independent of the passing mechanism (explicit or
7068 This capability is needed to specify that a zero address should be
7069 passed for a record or other composite object passed by reference.
7070 There is no way of indicating this without the @code{Null_Parameter}
7074 @unnumberedsec Object_Size
7075 @cindex Size, used for objects
7078 The size of an object is not necessarily the same as the size of the type
7079 of an object. This is because by default object sizes are increased to be
7080 a multiple of the alignment of the object. For example,
7081 @code{Natural'Size} is
7082 31, but by default objects of type @code{Natural} will have a size of 32 bits.
7083 Similarly, a record containing an integer and a character:
7085 @smallexample @c ada
7093 will have a size of 40 (that is @code{Rec'Size} will be 40). The
7094 alignment will be 4, because of the
7095 integer field, and so the default size of record objects for this type
7096 will be 64 (8 bytes).
7098 @node Passed_By_Reference
7099 @unnumberedsec Passed_By_Reference
7100 @cindex Parameters, when passed by reference
7101 @findex Passed_By_Reference
7103 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
7104 a value of type @code{Boolean} value that is @code{True} if the type is
7105 normally passed by reference and @code{False} if the type is normally
7106 passed by copy in calls. For scalar types, the result is always @code{False}
7107 and is static. For non-scalar types, the result is non-static.
7110 @unnumberedsec Pool_Address
7111 @cindex Parameters, when passed by reference
7112 @findex Pool_Address
7114 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
7115 of X within its storage pool. This is the same as
7116 @code{@var{X}'Address}, except that for an unconstrained array whose
7117 bounds are allocated just before the first component,
7118 @code{@var{X}'Pool_Address} returns the address of those bounds,
7119 whereas @code{@var{X}'Address} returns the address of the first
7122 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
7123 the object is allocated'', which could be a user-defined storage pool,
7124 the global heap, on the stack, or in a static memory area. For an
7125 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
7126 what is passed to @code{Allocate} and returned from @code{Deallocate}.
7129 @unnumberedsec Range_Length
7130 @findex Range_Length
7132 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
7133 the number of values represented by the subtype (zero for a null
7134 range). The result is static for static subtypes. @code{Range_Length}
7135 applied to the index subtype of a one dimensional array always gives the
7136 same result as @code{Range} applied to the array itself.
7142 The @code{System.Address'Ref}
7143 (@code{System.Address} is the only permissible prefix)
7144 denotes a function identical to
7145 @code{System.Storage_Elements.To_Address} except that
7146 it is a static attribute. See @ref{To_Address} for more details.
7149 @unnumberedsec Result
7152 @code{@var{function}'Result} can only be used with in a Postcondition pragma
7153 for a function. The prefix must be the name of the corresponding function. This
7154 is used to refer to the result of the function in the postcondition expression.
7155 For a further discussion of the use of this attribute and examples of its use,
7156 see the description of pragma Postcondition.
7159 @unnumberedsec Safe_Emax
7160 @cindex Ada 83 attributes
7163 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
7164 the Ada 83 reference manual for an exact description of the semantics of
7168 @unnumberedsec Safe_Large
7169 @cindex Ada 83 attributes
7172 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
7173 the Ada 83 reference manual for an exact description of the semantics of
7176 @node Scalar_Storage_Order
7177 @unnumberedsec Scalar_Storage_Order
7179 @cindex Scalar storage order
7180 @findex Scalar_Storage_Order
7182 For every array or record type @var{S}, the representation attribute
7183 @code{Scalar_Storage_Order} denotes the order in which storage elements
7184 that make up scalar components are ordered within S:
7186 @smallexample @c ada
7187 -- Component type definitions
7189 subtype Yr_Type is Natural range 0 .. 127;
7190 subtype Mo_Type is Natural range 1 .. 12;
7191 subtype Da_Type is Natural range 1 .. 31;
7193 -- Record declaration
7196 Years_Since_1980 : Yr_Type;
7198 Day_Of_Month : Da_Type;
7201 -- Record representation clause
7204 Years_Since_1980 at 0 range 0 .. 6;
7205 Month at 0 range 7 .. 10;
7206 Day_Of_Month at 0 range 11 .. 15;
7209 -- Attribute definition clauses
7211 for Date'Bit_Order use System.High_Order_First;
7212 for Date'Scalar_Storage_Order use System.High_Order_First;
7213 -- If Scalar_Storage_Order is specified, it must be consistent with
7214 -- Bit_Order, so it's best to always define the latter explicitly if
7215 -- the former is used.
7218 Other properties are
7219 as for standard representation attribute @code{Bit_Order}, as defined by
7220 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
7222 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
7223 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
7224 this means that if a @code{Scalar_Storage_Order} attribute definition
7225 clause is not confirming, then the type's @code{Bit_Order} shall be
7226 specified explicitly and set to the same value.
7228 For a record extension, the derived type shall have the same scalar storage
7229 order as the parent type.
7231 If a component of @var{S} has itself a record or array type, then it shall also
7232 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
7233 if the component does not start on a byte boundary, then the scalar storage
7234 order specified for S and for the nested component type shall be identical.
7236 No component of a type that has a @code{Scalar_Storage_Order} attribute
7237 definition may be aliased.
7239 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
7240 with a value equal to @code{System.Default_Bit_Order}) has no effect.
7242 If the opposite storage order is specified, then whenever the value of
7243 a scalar component of an object of type @var{S} is read, the storage
7244 elements of the enclosing machine scalar are first reversed (before
7245 retrieving the component value, possibly applying some shift and mask
7246 operatings on the enclosing machine scalar), and the opposite operation
7249 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
7250 are relaxed. Instead, the following rules apply:
7253 @item the underlying storage elements are those at positions
7254 @code{(position + first_bit / storage_element_size) ..
7255 (position + (last_bit + storage_element_size - 1) /
7256 storage_element_size)}
7257 @item the sequence of underlying storage elements shall have
7258 a size no greater than the largest machine scalar
7259 @item the enclosing machine scalar is defined as the smallest machine
7260 scalar starting at a position no greater than
7261 @code{position + first_bit / storage_element_size} and covering
7262 storage elements at least up to @code{position + (last_bit +
7263 storage_element_size - 1) / storage_element_size}
7264 @item the position of the component is interpreted relative to that machine
7269 @node Simple_Storage_Pool
7270 @unnumberedsec Simple_Storage_Pool
7271 @cindex Storage pool, simple
7272 @cindex Simple storage pool
7273 @findex Simple_Storage_Pool
7275 For every nonformal, nonderived access-to-object type @var{Acc}, the
7276 representation attribute @code{Simple_Storage_Pool} may be specified
7277 via an attribute_definition_clause (or by specifying the equivalent aspect):
7279 @smallexample @c ada
7281 My_Pool : My_Simple_Storage_Pool_Type;
7283 type Acc is access My_Data_Type;
7285 for Acc'Simple_Storage_Pool use My_Pool;
7290 The name given in an attribute_definition_clause for the
7291 @code{Simple_Storage_Pool} attribute shall denote a variable of
7292 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
7294 The use of this attribute is only allowed for a prefix denoting a type
7295 for which it has been specified. The type of the attribute is the type
7296 of the variable specified as the simple storage pool of the access type,
7297 and the attribute denotes that variable.
7299 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
7300 for the same access type.
7302 If the @code{Simple_Storage_Pool} attribute has been specified for an access
7303 type, then applying the @code{Storage_Pool} attribute to the type is flagged
7304 with a warning and its evaluation raises the exception @code{Program_Error}.
7306 If the Simple_Storage_Pool attribute has been specified for an access
7307 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
7308 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
7309 which is intended to indicate the number of storage elements reserved for
7310 the simple storage pool. If the Storage_Size function has not been defined
7311 for the simple storage pool type, then this attribute returns zero.
7313 If an access type @var{S} has a specified simple storage pool of type
7314 @var{SSP}, then the evaluation of an allocator for that access type calls
7315 the primitive @code{Allocate} procedure for type @var{SSP}, passing
7316 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
7317 semantics of such allocators is the same as those defined for allocators
7318 in section 13.11 of the Ada Reference Manual, with the term
7319 ``simple storage pool'' substituted for ``storage pool''.
7321 If an access type @var{S} has a specified simple storage pool of type
7322 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
7323 for that access type invokes the primitive @code{Deallocate} procedure
7324 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
7325 parameter. The detailed semantics of such unchecked deallocations is the same
7326 as defined in section 13.11.2 of the Ada Reference Manual, except that the
7327 term ``simple storage pool'' is substituted for ``storage pool''.
7330 @unnumberedsec Small
7331 @cindex Ada 83 attributes
7334 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
7336 GNAT also allows this attribute to be applied to floating-point types
7337 for compatibility with Ada 83. See
7338 the Ada 83 reference manual for an exact description of the semantics of
7339 this attribute when applied to floating-point types.
7342 @unnumberedsec Storage_Unit
7343 @findex Storage_Unit
7345 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
7346 prefix) provides the same value as @code{System.Storage_Unit}.
7349 @unnumberedsec Stub_Type
7352 The GNAT implementation of remote access-to-classwide types is
7353 organized as described in AARM section E.4 (20.t): a value of an RACW type
7354 (designating a remote object) is represented as a normal access
7355 value, pointing to a "stub" object which in turn contains the
7356 necessary information to contact the designated remote object. A
7357 call on any dispatching operation of such a stub object does the
7358 remote call, if necessary, using the information in the stub object
7359 to locate the target partition, etc.
7361 For a prefix @code{T} that denotes a remote access-to-classwide type,
7362 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
7364 By construction, the layout of @code{T'Stub_Type} is identical to that of
7365 type @code{RACW_Stub_Type} declared in the internal implementation-defined
7366 unit @code{System.Partition_Interface}. Use of this attribute will create
7367 an implicit dependency on this unit.
7369 @node System_Allocator_Alignment
7370 @unnumberedsec System_Allocator_Alignment
7371 @cindex Alignment, allocator
7372 @findex System_Allocator_Alignment
7374 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
7375 permissible prefix) provides the observable guaranted to be honored by
7376 the system allocator (malloc). This is a static value that can be used
7377 in user storage pools based on malloc either to reject allocation
7378 with alignment too large or to enable a realignment circuitry if the
7379 alignment request is larger than this value.
7382 @unnumberedsec Target_Name
7385 @code{Standard'Target_Name} (@code{Standard} is the only permissible
7386 prefix) provides a static string value that identifies the target
7387 for the current compilation. For GCC implementations, this is the
7388 standard gcc target name without the terminating slash (for
7389 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
7395 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
7396 provides the same value as @code{System.Tick},
7399 @unnumberedsec To_Address
7402 The @code{System'To_Address}
7403 (@code{System} is the only permissible prefix)
7404 denotes a function identical to
7405 @code{System.Storage_Elements.To_Address} except that
7406 it is a static attribute. This means that if its argument is
7407 a static expression, then the result of the attribute is a
7408 static expression. The result is that such an expression can be
7409 used in contexts (e.g.@: preelaborable packages) which require a
7410 static expression and where the function call could not be used
7411 (since the function call is always non-static, even if its
7412 argument is static).
7415 @unnumberedsec Type_Class
7418 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
7419 the value of the type class for the full type of @var{type}. If
7420 @var{type} is a generic formal type, the value is the value for the
7421 corresponding actual subtype. The value of this attribute is of type
7422 @code{System.Aux_DEC.Type_Class}, which has the following definition:
7424 @smallexample @c ada
7426 (Type_Class_Enumeration,
7428 Type_Class_Fixed_Point,
7429 Type_Class_Floating_Point,
7434 Type_Class_Address);
7438 Protected types yield the value @code{Type_Class_Task}, which thus
7439 applies to all concurrent types. This attribute is designed to
7440 be compatible with the DEC Ada 83 attribute of the same name.
7443 @unnumberedsec UET_Address
7446 The @code{UET_Address} attribute can only be used for a prefix which
7447 denotes a library package. It yields the address of the unit exception
7448 table when zero cost exception handling is used. This attribute is
7449 intended only for use within the GNAT implementation. See the unit
7450 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
7451 for details on how this attribute is used in the implementation.
7453 @node Unconstrained_Array
7454 @unnumberedsec Unconstrained_Array
7455 @findex Unconstrained_Array
7457 The @code{Unconstrained_Array} attribute can be used with a prefix that
7458 denotes any type or subtype. It is a static attribute that yields
7459 @code{True} if the prefix designates an unconstrained array,
7460 and @code{False} otherwise. In a generic instance, the result is
7461 still static, and yields the result of applying this test to the
7464 @node Universal_Literal_String
7465 @unnumberedsec Universal_Literal_String
7466 @cindex Named numbers, representation of
7467 @findex Universal_Literal_String
7469 The prefix of @code{Universal_Literal_String} must be a named
7470 number. The static result is the string consisting of the characters of
7471 the number as defined in the original source. This allows the user
7472 program to access the actual text of named numbers without intermediate
7473 conversions and without the need to enclose the strings in quotes (which
7474 would preclude their use as numbers).
7476 For example, the following program prints the first 50 digits of pi:
7478 @smallexample @c ada
7479 with Text_IO; use Text_IO;
7483 Put (Ada.Numerics.Pi'Universal_Literal_String);
7487 @node Unrestricted_Access
7488 @unnumberedsec Unrestricted_Access
7489 @cindex @code{Access}, unrestricted
7490 @findex Unrestricted_Access
7492 The @code{Unrestricted_Access} attribute is similar to @code{Access}
7493 except that all accessibility and aliased view checks are omitted. This
7494 is a user-beware attribute. It is similar to
7495 @code{Address}, for which it is a desirable replacement where the value
7496 desired is an access type. In other words, its effect is identical to
7497 first applying the @code{Address} attribute and then doing an unchecked
7498 conversion to a desired access type. In GNAT, but not necessarily in
7499 other implementations, the use of static chains for inner level
7500 subprograms means that @code{Unrestricted_Access} applied to a
7501 subprogram yields a value that can be called as long as the subprogram
7502 is in scope (normal Ada accessibility rules restrict this usage).
7504 It is possible to use @code{Unrestricted_Access} for any type, but care
7505 must be exercised if it is used to create pointers to unconstrained
7506 objects. In this case, the resulting pointer has the same scope as the
7507 context of the attribute, and may not be returned to some enclosing
7508 scope. For instance, a function cannot use @code{Unrestricted_Access}
7509 to create a unconstrained pointer and then return that value to the
7513 @unnumberedsec Valid_Scalars
7514 @findex Valid_Scalars
7516 The @code{'Valid_Scalars} attribute is intended to make it easier to
7517 check the validity of scalar subcomponents of composite objects. It
7518 is defined for any prefix @code{X} that denotes an object.
7519 The value of this attribute is of the predefined type Boolean.
7520 @code{X'Valid_Scalars} yields True if and only if evaluation of
7521 @code{P'Valid} yields True for every scalar part P of X or if X has
7522 no scalar parts. It is not specified in what order the scalar parts
7523 are checked, nor whether any more are checked after any one of them
7524 is determined to be invalid. If the prefix @code{X} is of a class-wide
7525 type @code{T'Class} (where @code{T} is the associated specific type),
7526 or if the prefix @code{X} is of a specific tagged type @code{T}, then
7527 only the scalar parts of components of @code{T} are traversed; in other
7528 words, components of extensions of @code{T} are not traversed even if
7529 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
7530 be determined at compile time that the prefix of the attribute has no
7531 scalar parts (e.g., if the prefix is of an access type, an interface type,
7532 an undiscriminated task type, or an undiscriminated protected type).
7535 @unnumberedsec VADS_Size
7536 @cindex @code{Size}, VADS compatibility
7539 The @code{'VADS_Size} attribute is intended to make it easier to port
7540 legacy code which relies on the semantics of @code{'Size} as implemented
7541 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
7542 same semantic interpretation. In particular, @code{'VADS_Size} applied
7543 to a predefined or other primitive type with no Size clause yields the
7544 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
7545 typical machines). In addition @code{'VADS_Size} applied to an object
7546 gives the result that would be obtained by applying the attribute to
7547 the corresponding type.
7550 @unnumberedsec Value_Size
7551 @cindex @code{Size}, setting for not-first subtype
7553 @code{@var{type}'Value_Size} is the number of bits required to represent
7554 a value of the given subtype. It is the same as @code{@var{type}'Size},
7555 but, unlike @code{Size}, may be set for non-first subtypes.
7558 @unnumberedsec Wchar_T_Size
7559 @findex Wchar_T_Size
7560 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
7561 prefix) provides the size in bits of the C @code{wchar_t} type
7562 primarily for constructing the definition of this type in
7563 package @code{Interfaces.C}.
7566 @unnumberedsec Word_Size
7568 @code{Standard'Word_Size} (@code{Standard} is the only permissible
7569 prefix) provides the value @code{System.Word_Size}.
7571 @node Standard and Implementation Defined Restrictions
7572 @chapter Standard and Implementation Defined Restrictions
7575 All RM defined Restriction identifiers are implemented:
7578 @item language-defined restrictions (see 13.12.1)
7579 @item tasking restrictions (see D.7)
7580 @item high integrity restrictions (see H.4)
7584 GNAT implements additional restriction identifiers. All restrictions, whether
7585 language defined or GNAT-specific, are listed in the following.
7588 * Partition-Wide Restrictions::
7589 * Program Unit Level Restrictions::
7592 @node Partition-Wide Restrictions
7593 @section Partition-Wide Restrictions
7595 There are two separate lists of restriction identifiers. The first
7596 set requires consistency throughout a partition (in other words, if the
7597 restriction identifier is used for any compilation unit in the partition,
7598 then all compilation units in the partition must obey the restriction).
7601 * Immediate_Reclamation::
7602 * Max_Asynchronous_Select_Nesting::
7603 * Max_Entry_Queue_Length::
7604 * Max_Protected_Entries::
7605 * Max_Select_Alternatives::
7606 * Max_Storage_At_Blocking::
7607 * Max_Task_Entries::
7609 * No_Abort_Statements::
7610 * No_Access_Parameter_Allocators::
7611 * No_Access_Subprograms::
7613 * No_Anonymous_Allocators::
7616 * No_Default_Initialization::
7619 * No_Direct_Boolean_Operators::
7621 * No_Dispatching_Calls::
7622 * No_Dynamic_Attachment::
7623 * No_Dynamic_Priorities::
7624 * No_Entry_Calls_In_Elaboration_Code::
7625 * No_Enumeration_Maps::
7626 * No_Exception_Handlers::
7627 * No_Exception_Propagation::
7628 * No_Exception_Registration::
7632 * No_Floating_Point::
7633 * No_Implicit_Conditionals::
7634 * No_Implicit_Dynamic_Code::
7635 * No_Implicit_Heap_Allocations::
7636 * No_Implicit_Loops::
7637 * No_Initialize_Scalars::
7639 * No_Local_Allocators::
7640 * No_Local_Protected_Objects::
7641 * No_Local_Timing_Events::
7642 * No_Nested_Finalization::
7643 * No_Protected_Type_Allocators::
7644 * No_Protected_Types::
7647 * No_Relative_Delay::
7648 * No_Requeue_Statements::
7649 * No_Secondary_Stack::
7650 * No_Select_Statements::
7651 * No_Specific_Termination_Handlers::
7652 * No_Specification_of_Aspect::
7653 * No_Standard_Allocators_After_Elaboration::
7654 * No_Standard_Storage_Pools::
7655 * No_Stream_Optimizations::
7657 * No_Task_Allocators::
7658 * No_Task_Attributes_Package::
7659 * No_Task_Hierarchy::
7660 * No_Task_Termination::
7662 * No_Terminate_Alternatives::
7663 * No_Unchecked_Access::
7665 * Static_Priorities::
7666 * Static_Storage_Size::
7669 @node Immediate_Reclamation
7670 @unnumberedsubsec Immediate_Reclamation
7671 @findex Immediate_Reclamation
7672 [RM H.4] This restriction ensures that, except for storage occupied by
7673 objects created by allocators and not deallocated via unchecked
7674 deallocation, any storage reserved at run time for an object is
7675 immediately reclaimed when the object no longer exists.
7677 @node Max_Asynchronous_Select_Nesting
7678 @unnumberedsubsec Max_Asynchronous_Select_Nesting
7679 @findex Max_Asynchronous_Select_Nesting
7680 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
7681 selects. Violations of this restriction with a value of zero are
7682 detected at compile time. Violations of this restriction with values
7683 other than zero cause Storage_Error to be raised.
7685 @node Max_Entry_Queue_Length
7686 @unnumberedsubsec Max_Entry_Queue_Length
7687 @findex Max_Entry_Queue_Length
7688 [RM D.7] This restriction is a declaration that any protected entry compiled in
7689 the scope of the restriction has at most the specified number of
7690 tasks waiting on the entry at any one time, and so no queue is required.
7691 Note that this restriction is checked at run time. Violation of this
7692 restriction results in the raising of Program_Error exception at the point of
7695 @node Max_Protected_Entries
7696 @unnumberedsubsec Max_Protected_Entries
7697 @findex Max_Protected_Entries
7698 [RM D.7] Specifies the maximum number of entries per protected type. The
7699 bounds of every entry family of a protected unit shall be static, or shall be
7700 defined by a discriminant of a subtype whose corresponding bound is static.
7702 @node Max_Select_Alternatives
7703 @unnumberedsubsec Max_Select_Alternatives
7704 @findex Max_Select_Alternatives
7705 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
7707 @node Max_Storage_At_Blocking
7708 @unnumberedsubsec Max_Storage_At_Blocking
7709 @findex Max_Storage_At_Blocking
7710 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
7711 Storage_Size that can be retained by a blocked task. A violation of this
7712 restriction causes Storage_Error to be raised.
7714 @node Max_Task_Entries
7715 @unnumberedsubsec Max_Task_Entries
7716 @findex Max_Task_Entries
7717 [RM D.7] Specifies the maximum number of entries
7718 per task. The bounds of every entry family
7719 of a task unit shall be static, or shall be
7720 defined by a discriminant of a subtype whose
7721 corresponding bound is static.
7724 @unnumberedsubsec Max_Tasks
7726 [RM D.7] Specifies the maximum number of task that may be created, not
7727 counting the creation of the environment task. Violations of this
7728 restriction with a value of zero are detected at compile
7729 time. Violations of this restriction with values other than zero cause
7730 Storage_Error to be raised.
7732 @node No_Abort_Statements
7733 @unnumberedsubsec No_Abort_Statements
7734 @findex No_Abort_Statements
7735 [RM D.7] There are no abort_statements, and there are
7736 no calls to Task_Identification.Abort_Task.
7738 @node No_Access_Parameter_Allocators
7739 @unnumberedsubsec No_Access_Parameter_Allocators
7740 @findex No_Access_Parameter_Allocators
7741 [RM H.4] This restriction ensures at compile time that there are no
7742 occurrences of an allocator as the actual parameter to an access
7745 @node No_Access_Subprograms
7746 @unnumberedsubsec No_Access_Subprograms
7747 @findex No_Access_Subprograms
7748 [RM H.4] This restriction ensures at compile time that there are no
7749 declarations of access-to-subprogram types.
7752 @unnumberedsubsec No_Allocators
7753 @findex No_Allocators
7754 [RM H.4] This restriction ensures at compile time that there are no
7755 occurrences of an allocator.
7757 @node No_Anonymous_Allocators
7758 @unnumberedsubsec No_Anonymous_Allocators
7759 @findex No_Anonymous_Allocators
7760 [RM H.4] This restriction ensures at compile time that there are no
7761 occurrences of an allocator of anonymous access type.
7764 @unnumberedsubsec No_Calendar
7766 [GNAT] This restriction ensures at compile time that there is no implicit or
7767 explicit dependence on the package @code{Ada.Calendar}.
7769 @node No_Coextensions
7770 @unnumberedsubsec No_Coextensions
7771 @findex No_Coextensions
7772 [RM H.4] This restriction ensures at compile time that there are no
7773 coextensions. See 3.10.2.
7775 @node No_Default_Initialization
7776 @unnumberedsubsec No_Default_Initialization
7777 @findex No_Default_Initialization
7779 [GNAT] This restriction prohibits any instance of default initialization
7780 of variables. The binder implements a consistency rule which prevents
7781 any unit compiled without the restriction from with'ing a unit with the
7782 restriction (this allows the generation of initialization procedures to
7783 be skipped, since you can be sure that no call is ever generated to an
7784 initialization procedure in a unit with the restriction active). If used
7785 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
7786 is to prohibit all cases of variables declared without a specific
7787 initializer (including the case of OUT scalar parameters).
7790 @unnumberedsubsec No_Delay
7792 [RM H.4] This restriction ensures at compile time that there are no
7793 delay statements and no dependences on package Calendar.
7796 @unnumberedsubsec No_Dependence
7797 @findex No_Dependence
7798 [RM 13.12.1] This restriction checks at compile time that there are no
7799 dependence on a library unit.
7801 @node No_Direct_Boolean_Operators
7802 @unnumberedsubsec No_Direct_Boolean_Operators
7803 @findex No_Direct_Boolean_Operators
7804 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
7805 operands of type Boolean (or any type derived
7806 from Boolean). This is intended for use in safety critical programs
7807 where the certification protocol requires the use of short-circuit
7808 (and then, or else) forms for all composite boolean operations.
7811 @unnumberedsubsec No_Dispatch
7813 [RM H.4] This restriction ensures at compile time that there are no
7814 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
7816 @node No_Dispatching_Calls
7817 @unnumberedsubsec No_Dispatching_Calls
7818 @findex No_Dispatching_Calls
7819 [GNAT] This restriction ensures at compile time that the code generated by the
7820 compiler involves no dispatching calls. The use of this restriction allows the
7821 safe use of record extensions, classwide membership tests and other classwide
7822 features not involving implicit dispatching. This restriction ensures that
7823 the code contains no indirect calls through a dispatching mechanism. Note that
7824 this includes internally-generated calls created by the compiler, for example
7825 in the implementation of class-wide objects assignments. The
7826 membership test is allowed in the presence of this restriction, because its
7827 implementation requires no dispatching.
7828 This restriction is comparable to the official Ada restriction
7829 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7830 all classwide constructs that do not imply dispatching.
7831 The following example indicates constructs that violate this restriction.
7835 type T is tagged record
7838 procedure P (X : T);
7840 type DT is new T with record
7841 More_Data : Natural;
7843 procedure Q (X : DT);
7847 procedure Example is
7848 procedure Test (O : T'Class) is
7849 N : Natural := O'Size;-- Error: Dispatching call
7850 C : T'Class := O; -- Error: implicit Dispatching Call
7852 if O in DT'Class then -- OK : Membership test
7853 Q (DT (O)); -- OK : Type conversion plus direct call
7855 P (O); -- Error: Dispatching call
7861 P (Obj); -- OK : Direct call
7862 P (T (Obj)); -- OK : Type conversion plus direct call
7863 P (T'Class (Obj)); -- Error: Dispatching call
7865 Test (Obj); -- OK : Type conversion
7867 if Obj in T'Class then -- OK : Membership test
7873 @node No_Dynamic_Attachment
7874 @unnumberedsubsec No_Dynamic_Attachment
7875 @findex No_Dynamic_Attachment
7876 [RM D.7] This restriction ensures that there is no call to any of the
7877 operations defined in package Ada.Interrupts
7878 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
7879 Detach_Handler, and Reference).
7881 @node No_Dynamic_Priorities
7882 @unnumberedsubsec No_Dynamic_Priorities
7883 @findex No_Dynamic_Priorities
7884 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
7886 @node No_Entry_Calls_In_Elaboration_Code
7887 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
7888 @findex No_Entry_Calls_In_Elaboration_Code
7889 [GNAT] This restriction ensures at compile time that no task or protected entry
7890 calls are made during elaboration code. As a result of the use of this
7891 restriction, the compiler can assume that no code past an accept statement
7892 in a task can be executed at elaboration time.
7894 @node No_Enumeration_Maps
7895 @unnumberedsubsec No_Enumeration_Maps
7896 @findex No_Enumeration_Maps
7897 [GNAT] This restriction ensures at compile time that no operations requiring
7898 enumeration maps are used (that is Image and Value attributes applied
7899 to enumeration types).
7901 @node No_Exception_Handlers
7902 @unnumberedsubsec No_Exception_Handlers
7903 @findex No_Exception_Handlers
7904 [GNAT] This restriction ensures at compile time that there are no explicit
7905 exception handlers. It also indicates that no exception propagation will
7906 be provided. In this mode, exceptions may be raised but will result in
7907 an immediate call to the last chance handler, a routine that the user
7908 must define with the following profile:
7910 @smallexample @c ada
7911 procedure Last_Chance_Handler
7912 (Source_Location : System.Address; Line : Integer);
7913 pragma Export (C, Last_Chance_Handler,
7914 "__gnat_last_chance_handler");
7917 The parameter is a C null-terminated string representing a message to be
7918 associated with the exception (typically the source location of the raise
7919 statement generated by the compiler). The Line parameter when nonzero
7920 represents the line number in the source program where the raise occurs.
7922 @node No_Exception_Propagation
7923 @unnumberedsubsec No_Exception_Propagation
7924 @findex No_Exception_Propagation
7925 [GNAT] This restriction guarantees that exceptions are never propagated
7926 to an outer subprogram scope. The only case in which an exception may
7927 be raised is when the handler is statically in the same subprogram, so
7928 that the effect of a raise is essentially like a goto statement. Any
7929 other raise statement (implicit or explicit) will be considered
7930 unhandled. Exception handlers are allowed, but may not contain an
7931 exception occurrence identifier (exception choice). In addition, use of
7932 the package GNAT.Current_Exception is not permitted, and reraise
7933 statements (raise with no operand) are not permitted.
7935 @node No_Exception_Registration
7936 @unnumberedsubsec No_Exception_Registration
7937 @findex No_Exception_Registration
7938 [GNAT] This restriction ensures at compile time that no stream operations for
7939 types Exception_Id or Exception_Occurrence are used. This also makes it
7940 impossible to pass exceptions to or from a partition with this restriction
7941 in a distributed environment. If this exception is active, then the generated
7942 code is simplified by omitting the otherwise-required global registration
7943 of exceptions when they are declared.
7946 @unnumberedsubsec No_Exceptions
7947 @findex No_Exceptions
7948 [RM H.4] This restriction ensures at compile time that there are no
7949 raise statements and no exception handlers.
7951 @node No_Finalization
7952 @unnumberedsubsec No_Finalization
7953 @findex No_Finalization
7954 [GNAT] This restriction disables the language features described in
7955 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
7956 performed by the compiler to support these features. The following types
7957 are no longer considered controlled when this restriction is in effect:
7960 @code{Ada.Finalization.Controlled}
7962 @code{Ada.Finalization.Limited_Controlled}
7964 Derivations from @code{Controlled} or @code{Limited_Controlled}
7972 Array and record types with controlled components
7974 The compiler no longer generates code to initialize, finalize or adjust an
7975 object or a nested component, either declared on the stack or on the heap. The
7976 deallocation of a controlled object no longer finalizes its contents.
7978 @node No_Fixed_Point
7979 @unnumberedsubsec No_Fixed_Point
7980 @findex No_Fixed_Point
7981 [RM H.4] This restriction ensures at compile time that there are no
7982 occurrences of fixed point types and operations.
7984 @node No_Floating_Point
7985 @unnumberedsubsec No_Floating_Point
7986 @findex No_Floating_Point
7987 [RM H.4] This restriction ensures at compile time that there are no
7988 occurrences of floating point types and operations.
7990 @node No_Implicit_Conditionals
7991 @unnumberedsubsec No_Implicit_Conditionals
7992 @findex No_Implicit_Conditionals
7993 [GNAT] This restriction ensures that the generated code does not contain any
7994 implicit conditionals, either by modifying the generated code where possible,
7995 or by rejecting any construct that would otherwise generate an implicit
7996 conditional. Note that this check does not include run time constraint
7997 checks, which on some targets may generate implicit conditionals as
7998 well. To control the latter, constraint checks can be suppressed in the
7999 normal manner. Constructs generating implicit conditionals include comparisons
8000 of composite objects and the Max/Min attributes.
8002 @node No_Implicit_Dynamic_Code
8003 @unnumberedsubsec No_Implicit_Dynamic_Code
8004 @findex No_Implicit_Dynamic_Code
8006 [GNAT] This restriction prevents the compiler from building ``trampolines''.
8007 This is a structure that is built on the stack and contains dynamic
8008 code to be executed at run time. On some targets, a trampoline is
8009 built for the following features: @code{Access},
8010 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8011 nested task bodies; primitive operations of nested tagged types.
8012 Trampolines do not work on machines that prevent execution of stack
8013 data. For example, on windows systems, enabling DEP (data execution
8014 protection) will cause trampolines to raise an exception.
8015 Trampolines are also quite slow at run time.
8017 On many targets, trampolines have been largely eliminated. Look at the
8018 version of system.ads for your target --- if it has
8019 Always_Compatible_Rep equal to False, then trampolines are largely
8020 eliminated. In particular, a trampoline is built for the following
8021 features: @code{Address} of a nested subprogram;
8022 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8023 but only if pragma Favor_Top_Level applies, or the access type has a
8024 foreign-language convention; primitive operations of nested tagged
8027 @node No_Implicit_Heap_Allocations
8028 @unnumberedsubsec No_Implicit_Heap_Allocations
8029 @findex No_Implicit_Heap_Allocations
8030 [RM D.7] No constructs are allowed to cause implicit heap allocation.
8032 @node No_Implicit_Loops
8033 @unnumberedsubsec No_Implicit_Loops
8034 @findex No_Implicit_Loops
8035 [GNAT] This restriction ensures that the generated code does not contain any
8036 implicit @code{for} loops, either by modifying
8037 the generated code where possible,
8038 or by rejecting any construct that would otherwise generate an implicit
8039 @code{for} loop. If this restriction is active, it is possible to build
8040 large array aggregates with all static components without generating an
8041 intermediate temporary, and without generating a loop to initialize individual
8042 components. Otherwise, a loop is created for arrays larger than about 5000
8045 @node No_Initialize_Scalars
8046 @unnumberedsubsec No_Initialize_Scalars
8047 @findex No_Initialize_Scalars
8048 [GNAT] This restriction ensures that no unit in the partition is compiled with
8049 pragma Initialize_Scalars. This allows the generation of more efficient
8050 code, and in particular eliminates dummy null initialization routines that
8051 are otherwise generated for some record and array types.
8054 @unnumberedsubsec No_IO
8056 [RM H.4] This restriction ensures at compile time that there are no
8057 dependences on any of the library units Sequential_IO, Direct_IO,
8058 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
8060 @node No_Local_Allocators
8061 @unnumberedsubsec No_Local_Allocators
8062 @findex No_Local_Allocators
8063 [RM H.4] This restriction ensures at compile time that there are no
8064 occurrences of an allocator in subprograms, generic subprograms, tasks,
8067 @node No_Local_Protected_Objects
8068 @unnumberedsubsec No_Local_Protected_Objects
8069 @findex No_Local_Protected_Objects
8070 [RM D.7] This restriction ensures at compile time that protected objects are
8071 only declared at the library level.
8073 @node No_Local_Timing_Events
8074 @unnumberedsubsec No_Local_Timing_Events
8075 @findex No_Local_Timing_Events
8076 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
8077 declared at the library level.
8079 @node No_Nested_Finalization
8080 @unnumberedsubsec No_Nested_Finalization
8081 @findex No_Nested_Finalization
8082 [RM D.7] All objects requiring finalization are declared at the library level.
8084 @node No_Protected_Type_Allocators
8085 @unnumberedsubsec No_Protected_Type_Allocators
8086 @findex No_Protected_Type_Allocators
8087 [RM D.7] This restriction ensures at compile time that there are no allocator
8088 expressions that attempt to allocate protected objects.
8090 @node No_Protected_Types
8091 @unnumberedsubsec No_Protected_Types
8092 @findex No_Protected_Types
8093 [RM H.4] This restriction ensures at compile time that there are no
8094 declarations of protected types or protected objects.
8097 @unnumberedsubsec No_Recursion
8098 @findex No_Recursion
8099 [RM H.4] A program execution is erroneous if a subprogram is invoked as
8100 part of its execution.
8103 @unnumberedsubsec No_Reentrancy
8104 @findex No_Reentrancy
8105 [RM H.4] A program execution is erroneous if a subprogram is executed by
8106 two tasks at the same time.
8108 @node No_Relative_Delay
8109 @unnumberedsubsec No_Relative_Delay
8110 @findex No_Relative_Delay
8111 [RM D.7] This restriction ensures at compile time that there are no delay
8112 relative statements and prevents expressions such as @code{delay 1.23;} from
8113 appearing in source code.
8115 @node No_Requeue_Statements
8116 @unnumberedsubsec No_Requeue_Statements
8117 @findex No_Requeue_Statements
8118 [RM D.7] This restriction ensures at compile time that no requeue statements
8119 are permitted and prevents keyword @code{requeue} from being used in source
8122 @node No_Secondary_Stack
8123 @unnumberedsubsec No_Secondary_Stack
8124 @findex No_Secondary_Stack
8125 [GNAT] This restriction ensures at compile time that the generated code
8126 does not contain any reference to the secondary stack. The secondary
8127 stack is used to implement functions returning unconstrained objects
8128 (arrays or records) on some targets.
8130 @node No_Select_Statements
8131 @unnumberedsubsec No_Select_Statements
8132 @findex No_Select_Statements
8133 [RM D.7] This restriction ensures at compile time no select statements of any
8134 kind are permitted, that is the keyword @code{select} may not appear.
8136 @node No_Specific_Termination_Handlers
8137 @unnumberedsubsec No_Specific_Termination_Handlers
8138 @findex No_Specific_Termination_Handlers
8139 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
8140 or to Ada.Task_Termination.Specific_Handler.
8142 @node No_Specification_of_Aspect
8143 @unnumberedsubsec No_Specification_of_Aspect
8144 @findex No_Specification_of_Aspect
8145 [RM 13.12.1] This restriction checks at compile time that no aspect
8146 specification, attribute definition clause, or pragma is given for a
8149 @node No_Standard_Allocators_After_Elaboration
8150 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
8151 @findex No_Standard_Allocators_After_Elaboration
8152 [RM D.7] Specifies that an allocator using a standard storage pool
8153 should never be evaluated at run time after the elaboration of the
8154 library items of the partition has completed. Otherwise, Storage_Error
8157 @node No_Standard_Storage_Pools
8158 @unnumberedsubsec No_Standard_Storage_Pools
8159 @findex No_Standard_Storage_Pools
8160 [GNAT] This restriction ensures at compile time that no access types
8161 use the standard default storage pool. Any access type declared must
8162 have an explicit Storage_Pool attribute defined specifying a
8163 user-defined storage pool.
8165 @node No_Stream_Optimizations
8166 @unnumberedsubsec No_Stream_Optimizations
8167 @findex No_Stream_Optimizations
8168 [GNAT] This restriction affects the performance of stream operations on types
8169 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
8170 compiler uses block reads and writes when manipulating @code{String} objects
8171 due to their supperior performance. When this restriction is in effect, the
8172 compiler performs all IO operations on a per-character basis.
8175 @unnumberedsubsec No_Streams
8177 [GNAT] This restriction ensures at compile/bind time that there are no
8178 stream objects created and no use of stream attributes.
8179 This restriction does not forbid dependences on the package
8180 @code{Ada.Streams}. So it is permissible to with
8181 @code{Ada.Streams} (or another package that does so itself)
8182 as long as no actual stream objects are created and no
8183 stream attributes are used.
8185 Note that the use of restriction allows optimization of tagged types,
8186 since they do not need to worry about dispatching stream operations.
8187 To take maximum advantage of this space-saving optimization, any
8188 unit declaring a tagged type should be compiled with the restriction,
8189 though this is not required.
8191 @node No_Task_Allocators
8192 @unnumberedsubsec No_Task_Allocators
8193 @findex No_Task_Allocators
8194 [RM D.7] There are no allocators for task types
8195 or types containing task subcomponents.
8197 @node No_Task_Attributes_Package
8198 @unnumberedsubsec No_Task_Attributes_Package
8199 @findex No_Task_Attributes_Package
8200 [GNAT] This restriction ensures at compile time that there are no implicit or
8201 explicit dependencies on the package @code{Ada.Task_Attributes}.
8203 @node No_Task_Hierarchy
8204 @unnumberedsubsec No_Task_Hierarchy
8205 @findex No_Task_Hierarchy
8206 [RM D.7] All (non-environment) tasks depend
8207 directly on the environment task of the partition.
8209 @node No_Task_Termination
8210 @unnumberedsubsec No_Task_Termination
8211 @findex No_Task_Termination
8212 [RM D.7] Tasks which terminate are erroneous.
8215 @unnumberedsubsec No_Tasking
8217 [GNAT] This restriction prevents the declaration of tasks or task types
8218 throughout the partition. It is similar in effect to the use of
8219 @code{Max_Tasks => 0} except that violations are caught at compile time
8220 and cause an error message to be output either by the compiler or
8223 @node No_Terminate_Alternatives
8224 @unnumberedsubsec No_Terminate_Alternatives
8225 @findex No_Terminate_Alternatives
8226 [RM D.7] There are no selective accepts with terminate alternatives.
8228 @node No_Unchecked_Access
8229 @unnumberedsubsec No_Unchecked_Access
8230 @findex No_Unchecked_Access
8231 [RM H.4] This restriction ensures at compile time that there are no
8232 occurrences of the Unchecked_Access attribute.
8234 @node Simple_Barriers
8235 @unnumberedsubsec Simple_Barriers
8236 @findex Simple_Barriers
8237 [RM D.7] This restriction ensures at compile time that barriers in entry
8238 declarations for protected types are restricted to either static boolean
8239 expressions or references to simple boolean variables defined in the private
8240 part of the protected type. No other form of entry barriers is permitted.
8242 @node Static_Priorities
8243 @unnumberedsubsec Static_Priorities
8244 @findex Static_Priorities
8245 [GNAT] This restriction ensures at compile time that all priority expressions
8246 are static, and that there are no dependences on the package
8247 @code{Ada.Dynamic_Priorities}.
8249 @node Static_Storage_Size
8250 @unnumberedsubsec Static_Storage_Size
8251 @findex Static_Storage_Size
8252 [GNAT] This restriction ensures at compile time that any expression appearing
8253 in a Storage_Size pragma or attribute definition clause is static.
8255 @node Program Unit Level Restrictions
8256 @section Program Unit Level Restrictions
8259 The second set of restriction identifiers
8260 does not require partition-wide consistency.
8261 The restriction may be enforced for a single
8262 compilation unit without any effect on any of the
8263 other compilation units in the partition.
8266 * No_Elaboration_Code::
8268 * No_Implementation_Aspect_Specifications::
8269 * No_Implementation_Attributes::
8270 * No_Implementation_Identifiers::
8271 * No_Implementation_Pragmas::
8272 * No_Implementation_Restrictions::
8273 * No_Implementation_Units::
8274 * No_Implicit_Aliasing::
8275 * No_Obsolescent_Features::
8276 * No_Wide_Characters::
8280 @node No_Elaboration_Code
8281 @unnumberedsubsec No_Elaboration_Code
8282 @findex No_Elaboration_Code
8283 [GNAT] This restriction ensures at compile time that no elaboration code is
8284 generated. Note that this is not the same condition as is enforced
8285 by pragma @code{Preelaborate}. There are cases in which pragma
8286 @code{Preelaborate} still permits code to be generated (e.g.@: code
8287 to initialize a large array to all zeroes), and there are cases of units
8288 which do not meet the requirements for pragma @code{Preelaborate},
8289 but for which no elaboration code is generated. Generally, it is
8290 the case that preelaborable units will meet the restrictions, with
8291 the exception of large aggregates initialized with an others_clause,
8292 and exception declarations (which generate calls to a run-time
8293 registry procedure). This restriction is enforced on
8294 a unit by unit basis, it need not be obeyed consistently
8295 throughout a partition.
8297 In the case of aggregates with others, if the aggregate has a dynamic
8298 size, there is no way to eliminate the elaboration code (such dynamic
8299 bounds would be incompatible with @code{Preelaborate} in any case). If
8300 the bounds are static, then use of this restriction actually modifies
8301 the code choice of the compiler to avoid generating a loop, and instead
8302 generate the aggregate statically if possible, no matter how many times
8303 the data for the others clause must be repeatedly generated.
8305 It is not possible to precisely document
8306 the constructs which are compatible with this restriction, since,
8307 unlike most other restrictions, this is not a restriction on the
8308 source code, but a restriction on the generated object code. For
8309 example, if the source contains a declaration:
8312 Val : constant Integer := X;
8316 where X is not a static constant, it may be possible, depending
8317 on complex optimization circuitry, for the compiler to figure
8318 out the value of X at compile time, in which case this initialization
8319 can be done by the loader, and requires no initialization code. It
8320 is not possible to document the precise conditions under which the
8321 optimizer can figure this out.
8323 Note that this the implementation of this restriction requires full
8324 code generation. If it is used in conjunction with "semantics only"
8325 checking, then some cases of violations may be missed.
8327 @node No_Entry_Queue
8328 @unnumberedsubsec No_Entry_Queue
8329 @findex No_Entry_Queue
8330 [GNAT] This restriction is a declaration that any protected entry compiled in
8331 the scope of the restriction has at most one task waiting on the entry
8332 at any one time, and so no queue is required. This restriction is not
8333 checked at compile time. A program execution is erroneous if an attempt
8334 is made to queue a second task on such an entry.
8336 @node No_Implementation_Aspect_Specifications
8337 @unnumberedsubsec No_Implementation_Aspect_Specifications
8338 @findex No_Implementation_Aspect_Specifications
8339 [RM 13.12.1] This restriction checks at compile time that no
8340 GNAT-defined aspects are present. With this restriction, the only
8341 aspects that can be used are those defined in the Ada Reference Manual.
8343 @node No_Implementation_Attributes
8344 @unnumberedsubsec No_Implementation_Attributes
8345 @findex No_Implementation_Attributes
8346 [RM 13.12.1] This restriction checks at compile time that no
8347 GNAT-defined attributes are present. With this restriction, the only
8348 attributes that can be used are those defined in the Ada Reference
8351 @node No_Implementation_Identifiers
8352 @unnumberedsubsec No_Implementation_Identifiers
8353 @findex No_Implementation_Identifiers
8354 [RM 13.12.1] This restriction checks at compile time that no
8355 implementation-defined identifiers (marked with pragma Implementation_Defined)
8356 occur within language-defined packages.
8358 @node No_Implementation_Pragmas
8359 @unnumberedsubsec No_Implementation_Pragmas
8360 @findex No_Implementation_Pragmas
8361 [RM 13.12.1] This restriction checks at compile time that no
8362 GNAT-defined pragmas are present. With this restriction, the only
8363 pragmas that can be used are those defined in the Ada Reference Manual.
8365 @node No_Implementation_Restrictions
8366 @unnumberedsubsec No_Implementation_Restrictions
8367 @findex No_Implementation_Restrictions
8368 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
8369 identifiers (other than @code{No_Implementation_Restrictions} itself)
8370 are present. With this restriction, the only other restriction identifiers
8371 that can be used are those defined in the Ada Reference Manual.
8373 @node No_Implementation_Units
8374 @unnumberedsubsec No_Implementation_Units
8375 @findex No_Implementation_Units
8376 [RM 13.12.1] This restriction checks at compile time that there is no
8377 mention in the context clause of any implementation-defined descendants
8378 of packages Ada, Interfaces, or System.
8380 @node No_Implicit_Aliasing
8381 @unnumberedsubsec No_Implicit_Aliasing
8382 @findex No_Implicit_Aliasing
8383 [GNAT] This restriction, which is not required to be partition-wide consistent,
8384 requires an explicit aliased keyword for an object to which 'Access,
8385 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
8386 the 'Unrestricted_Access attribute for objects. Note: the reason that
8387 Unrestricted_Access is forbidden is that it would require the prefix
8388 to be aliased, and in such cases, it can always be replaced by
8389 the standard attribute Unchecked_Access which is preferable.
8391 @node No_Obsolescent_Features
8392 @unnumberedsubsec No_Obsolescent_Features
8393 @findex No_Obsolescent_Features
8394 [RM 13.12.1] This restriction checks at compile time that no obsolescent
8395 features are used, as defined in Annex J of the Ada Reference Manual.
8397 @node No_Wide_Characters
8398 @unnumberedsubsec No_Wide_Characters
8399 @findex No_Wide_Characters
8400 [GNAT] This restriction ensures at compile time that no uses of the types
8401 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8403 appear, and that no wide or wide wide string or character literals
8404 appear in the program (that is literals representing characters not in
8405 type @code{Character}).
8408 @unnumberedsubsec SPARK
8410 [GNAT] This restriction checks at compile time that some constructs
8411 forbidden in SPARK are not present. The SPARK version used as a
8412 reference is the same as the Ada mode for the unit, so a unit compiled
8413 in Ada 95 mode with SPARK restrictions will be checked for constructs
8414 forbidden in SPARK 95. Error messages related to SPARK restriction have
8418 violation of restriction "SPARK" at <file>
8422 This is not a replacement for the semantic checks performed by the
8423 SPARK Examiner tool, as the compiler only deals currently with code,
8424 not at all with SPARK annotations and does not guarantee catching all
8425 cases of constructs forbidden by SPARK.
8427 Thus it may well be the case that code which
8428 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
8429 e.g. due to the different visibility rules of the Examiner based on
8430 SPARK @code{inherit} annotations.
8432 This restriction can be useful in providing an initial filter for
8433 code developed using SPARK, or in examining legacy code to see how far
8434 it is from meeting SPARK restrictions.
8436 @c ------------------------
8437 @node Implementation Advice
8438 @chapter Implementation Advice
8440 The main text of the Ada Reference Manual describes the required
8441 behavior of all Ada compilers, and the GNAT compiler conforms to
8444 In addition, there are sections throughout the Ada Reference Manual headed
8445 by the phrase ``Implementation advice''. These sections are not normative,
8446 i.e., they do not specify requirements that all compilers must
8447 follow. Rather they provide advice on generally desirable behavior. You
8448 may wonder why they are not requirements. The most typical answer is
8449 that they describe behavior that seems generally desirable, but cannot
8450 be provided on all systems, or which may be undesirable on some systems.
8452 As far as practical, GNAT follows the implementation advice sections in
8453 the Ada Reference Manual. This chapter contains a table giving the
8454 reference manual section number, paragraph number and several keywords
8455 for each advice. Each entry consists of the text of the advice followed
8456 by the GNAT interpretation of this advice. Most often, this simply says
8457 ``followed'', which means that GNAT follows the advice. However, in a
8458 number of cases, GNAT deliberately deviates from this advice, in which
8459 case the text describes what GNAT does and why.
8461 @cindex Error detection
8462 @unnumberedsec 1.1.3(20): Error Detection
8465 If an implementation detects the use of an unsupported Specialized Needs
8466 Annex feature at run time, it should raise @code{Program_Error} if
8469 Not relevant. All specialized needs annex features are either supported,
8470 or diagnosed at compile time.
8473 @unnumberedsec 1.1.3(31): Child Units
8476 If an implementation wishes to provide implementation-defined
8477 extensions to the functionality of a language-defined library unit, it
8478 should normally do so by adding children to the library unit.
8482 @cindex Bounded errors
8483 @unnumberedsec 1.1.5(12): Bounded Errors
8486 If an implementation detects a bounded error or erroneous
8487 execution, it should raise @code{Program_Error}.
8489 Followed in all cases in which the implementation detects a bounded
8490 error or erroneous execution. Not all such situations are detected at
8494 @unnumberedsec 2.8(16): Pragmas
8497 Normally, implementation-defined pragmas should have no semantic effect
8498 for error-free programs; that is, if the implementation-defined pragmas
8499 are removed from a working program, the program should still be legal,
8500 and should still have the same semantics.
8502 The following implementation defined pragmas are exceptions to this
8514 @item CPP_Constructor
8518 @item Interface_Name
8520 @item Machine_Attribute
8522 @item Unimplemented_Unit
8524 @item Unchecked_Union
8529 In each of the above cases, it is essential to the purpose of the pragma
8530 that this advice not be followed. For details see the separate section
8531 on implementation defined pragmas.
8533 @unnumberedsec 2.8(17-19): Pragmas
8536 Normally, an implementation should not define pragmas that can
8537 make an illegal program legal, except as follows:
8541 A pragma used to complete a declaration, such as a pragma @code{Import};
8545 A pragma used to configure the environment by adding, removing, or
8546 replacing @code{library_items}.
8548 See response to paragraph 16 of this same section.
8550 @cindex Character Sets
8551 @cindex Alternative Character Sets
8552 @unnumberedsec 3.5.2(5): Alternative Character Sets
8555 If an implementation supports a mode with alternative interpretations
8556 for @code{Character} and @code{Wide_Character}, the set of graphic
8557 characters of @code{Character} should nevertheless remain a proper
8558 subset of the set of graphic characters of @code{Wide_Character}. Any
8559 character set ``localizations'' should be reflected in the results of
8560 the subprograms defined in the language-defined package
8561 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
8562 an alternative interpretation of @code{Character}, the implementation should
8563 also support a corresponding change in what is a legal
8564 @code{identifier_letter}.
8566 Not all wide character modes follow this advice, in particular the JIS
8567 and IEC modes reflect standard usage in Japan, and in these encoding,
8568 the upper half of the Latin-1 set is not part of the wide-character
8569 subset, since the most significant bit is used for wide character
8570 encoding. However, this only applies to the external forms. Internally
8571 there is no such restriction.
8573 @cindex Integer types
8574 @unnumberedsec 3.5.4(28): Integer Types
8578 An implementation should support @code{Long_Integer} in addition to
8579 @code{Integer} if the target machine supports 32-bit (or longer)
8580 arithmetic. No other named integer subtypes are recommended for package
8581 @code{Standard}. Instead, appropriate named integer subtypes should be
8582 provided in the library package @code{Interfaces} (see B.2).
8584 @code{Long_Integer} is supported. Other standard integer types are supported
8585 so this advice is not fully followed. These types
8586 are supported for convenient interface to C, and so that all hardware
8587 types of the machine are easily available.
8588 @unnumberedsec 3.5.4(29): Integer Types
8592 An implementation for a two's complement machine should support
8593 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
8594 implementation should support a non-binary modules up to @code{Integer'Last}.
8598 @cindex Enumeration values
8599 @unnumberedsec 3.5.5(8): Enumeration Values
8602 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
8603 subtype, if the value of the operand does not correspond to the internal
8604 code for any enumeration literal of its type (perhaps due to an
8605 un-initialized variable), then the implementation should raise
8606 @code{Program_Error}. This is particularly important for enumeration
8607 types with noncontiguous internal codes specified by an
8608 enumeration_representation_clause.
8613 @unnumberedsec 3.5.7(17): Float Types
8616 An implementation should support @code{Long_Float} in addition to
8617 @code{Float} if the target machine supports 11 or more digits of
8618 precision. No other named floating point subtypes are recommended for
8619 package @code{Standard}. Instead, appropriate named floating point subtypes
8620 should be provided in the library package @code{Interfaces} (see B.2).
8622 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
8623 former provides improved compatibility with other implementations
8624 supporting this type. The latter corresponds to the highest precision
8625 floating-point type supported by the hardware. On most machines, this
8626 will be the same as @code{Long_Float}, but on some machines, it will
8627 correspond to the IEEE extended form. The notable case is all ia32
8628 (x86) implementations, where @code{Long_Long_Float} corresponds to
8629 the 80-bit extended precision format supported in hardware on this
8630 processor. Note that the 128-bit format on SPARC is not supported,
8631 since this is a software rather than a hardware format.
8633 @cindex Multidimensional arrays
8634 @cindex Arrays, multidimensional
8635 @unnumberedsec 3.6.2(11): Multidimensional Arrays
8638 An implementation should normally represent multidimensional arrays in
8639 row-major order, consistent with the notation used for multidimensional
8640 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
8641 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
8642 column-major order should be used instead (see B.5, ``Interfacing with
8647 @findex Duration'Small
8648 @unnumberedsec 9.6(30-31): Duration'Small
8651 Whenever possible in an implementation, the value of @code{Duration'Small}
8652 should be no greater than 100 microseconds.
8654 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
8658 The time base for @code{delay_relative_statements} should be monotonic;
8659 it need not be the same time base as used for @code{Calendar.Clock}.
8663 @unnumberedsec 10.2.1(12): Consistent Representation
8666 In an implementation, a type declared in a pre-elaborated package should
8667 have the same representation in every elaboration of a given version of
8668 the package, whether the elaborations occur in distinct executions of
8669 the same program, or in executions of distinct programs or partitions
8670 that include the given version.
8672 Followed, except in the case of tagged types. Tagged types involve
8673 implicit pointers to a local copy of a dispatch table, and these pointers
8674 have representations which thus depend on a particular elaboration of the
8675 package. It is not easy to see how it would be possible to follow this
8676 advice without severely impacting efficiency of execution.
8678 @cindex Exception information
8679 @unnumberedsec 11.4.1(19): Exception Information
8682 @code{Exception_Message} by default and @code{Exception_Information}
8683 should produce information useful for
8684 debugging. @code{Exception_Message} should be short, about one
8685 line. @code{Exception_Information} can be long. @code{Exception_Message}
8686 should not include the
8687 @code{Exception_Name}. @code{Exception_Information} should include both
8688 the @code{Exception_Name} and the @code{Exception_Message}.
8690 Followed. For each exception that doesn't have a specified
8691 @code{Exception_Message}, the compiler generates one containing the location
8692 of the raise statement. This location has the form ``file:line'', where
8693 file is the short file name (without path information) and line is the line
8694 number in the file. Note that in the case of the Zero Cost Exception
8695 mechanism, these messages become redundant with the Exception_Information that
8696 contains a full backtrace of the calling sequence, so they are disabled.
8697 To disable explicitly the generation of the source location message, use the
8698 Pragma @code{Discard_Names}.
8700 @cindex Suppression of checks
8701 @cindex Checks, suppression of
8702 @unnumberedsec 11.5(28): Suppression of Checks
8705 The implementation should minimize the code executed for checks that
8706 have been suppressed.
8710 @cindex Representation clauses
8711 @unnumberedsec 13.1 (21-24): Representation Clauses
8714 The recommended level of support for all representation items is
8715 qualified as follows:
8719 An implementation need not support representation items containing
8720 non-static expressions, except that an implementation should support a
8721 representation item for a given entity if each non-static expression in
8722 the representation item is a name that statically denotes a constant
8723 declared before the entity.
8725 Followed. In fact, GNAT goes beyond the recommended level of support
8726 by allowing nonstatic expressions in some representation clauses even
8727 without the need to declare constants initialized with the values of
8731 @smallexample @c ada
8734 for Y'Address use X'Address;>>
8739 An implementation need not support a specification for the @code{Size}
8740 for a given composite subtype, nor the size or storage place for an
8741 object (including a component) of a given composite subtype, unless the
8742 constraints on the subtype and its composite subcomponents (if any) are
8743 all static constraints.
8745 Followed. Size Clauses are not permitted on non-static components, as
8750 An aliased component, or a component whose type is by-reference, should
8751 always be allocated at an addressable location.
8755 @cindex Packed types
8756 @unnumberedsec 13.2(6-8): Packed Types
8759 If a type is packed, then the implementation should try to minimize
8760 storage allocated to objects of the type, possibly at the expense of
8761 speed of accessing components, subject to reasonable complexity in
8762 addressing calculations.
8766 The recommended level of support pragma @code{Pack} is:
8768 For a packed record type, the components should be packed as tightly as
8769 possible subject to the Sizes of the component subtypes, and subject to
8770 any @code{record_representation_clause} that applies to the type; the
8771 implementation may, but need not, reorder components or cross aligned
8772 word boundaries to improve the packing. A component whose @code{Size} is
8773 greater than the word size may be allocated an integral number of words.
8775 Followed. Tight packing of arrays is supported for all component sizes
8776 up to 64-bits. If the array component size is 1 (that is to say, if
8777 the component is a boolean type or an enumeration type with two values)
8778 then values of the type are implicitly initialized to zero. This
8779 happens both for objects of the packed type, and for objects that have a
8780 subcomponent of the packed type.
8784 An implementation should support Address clauses for imported
8788 @cindex @code{Address} clauses
8789 @unnumberedsec 13.3(14-19): Address Clauses
8793 For an array @var{X}, @code{@var{X}'Address} should point at the first
8794 component of the array, and not at the array bounds.
8800 The recommended level of support for the @code{Address} attribute is:
8802 @code{@var{X}'Address} should produce a useful result if @var{X} is an
8803 object that is aliased or of a by-reference type, or is an entity whose
8804 @code{Address} has been specified.
8806 Followed. A valid address will be produced even if none of those
8807 conditions have been met. If necessary, the object is forced into
8808 memory to ensure the address is valid.
8812 An implementation should support @code{Address} clauses for imported
8819 Objects (including subcomponents) that are aliased or of a by-reference
8820 type should be allocated on storage element boundaries.
8826 If the @code{Address} of an object is specified, or it is imported or exported,
8827 then the implementation should not perform optimizations based on
8828 assumptions of no aliases.
8832 @cindex @code{Alignment} clauses
8833 @unnumberedsec 13.3(29-35): Alignment Clauses
8836 The recommended level of support for the @code{Alignment} attribute for
8839 An implementation should support specified Alignments that are factors
8840 and multiples of the number of storage elements per word, subject to the
8847 An implementation need not support specified @code{Alignment}s for
8848 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
8849 loaded and stored by available machine instructions.
8855 An implementation need not support specified @code{Alignment}s that are
8856 greater than the maximum @code{Alignment} the implementation ever returns by
8863 The recommended level of support for the @code{Alignment} attribute for
8866 Same as above, for subtypes, but in addition:
8872 For stand-alone library-level objects of statically constrained
8873 subtypes, the implementation should support all @code{Alignment}s
8874 supported by the target linker. For example, page alignment is likely to
8875 be supported for such objects, but not for subtypes.
8879 @cindex @code{Size} clauses
8880 @unnumberedsec 13.3(42-43): Size Clauses
8883 The recommended level of support for the @code{Size} attribute of
8886 A @code{Size} clause should be supported for an object if the specified
8887 @code{Size} is at least as large as its subtype's @code{Size}, and
8888 corresponds to a size in storage elements that is a multiple of the
8889 object's @code{Alignment} (if the @code{Alignment} is nonzero).
8893 @unnumberedsec 13.3(50-56): Size Clauses
8896 If the @code{Size} of a subtype is specified, and allows for efficient
8897 independent addressability (see 9.10) on the target architecture, then
8898 the @code{Size} of the following objects of the subtype should equal the
8899 @code{Size} of the subtype:
8901 Aliased objects (including components).
8907 @code{Size} clause on a composite subtype should not affect the
8908 internal layout of components.
8910 Followed. But note that this can be overridden by use of the implementation
8911 pragma Implicit_Packing in the case of packed arrays.
8915 The recommended level of support for the @code{Size} attribute of subtypes is:
8919 The @code{Size} (if not specified) of a static discrete or fixed point
8920 subtype should be the number of bits needed to represent each value
8921 belonging to the subtype using an unbiased representation, leaving space
8922 for a sign bit only if the subtype contains negative values. If such a
8923 subtype is a first subtype, then an implementation should support a
8924 specified @code{Size} for it that reflects this representation.
8930 For a subtype implemented with levels of indirection, the @code{Size}
8931 should include the size of the pointers, but not the size of what they
8936 @cindex @code{Component_Size} clauses
8937 @unnumberedsec 13.3(71-73): Component Size Clauses
8940 The recommended level of support for the @code{Component_Size}
8945 An implementation need not support specified @code{Component_Sizes} that are
8946 less than the @code{Size} of the component subtype.
8952 An implementation should support specified @code{Component_Size}s that
8953 are factors and multiples of the word size. For such
8954 @code{Component_Size}s, the array should contain no gaps between
8955 components. For other @code{Component_Size}s (if supported), the array
8956 should contain no gaps between components when packing is also
8957 specified; the implementation should forbid this combination in cases
8958 where it cannot support a no-gaps representation.
8962 @cindex Enumeration representation clauses
8963 @cindex Representation clauses, enumeration
8964 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
8967 The recommended level of support for enumeration representation clauses
8970 An implementation need not support enumeration representation clauses
8971 for boolean types, but should at minimum support the internal codes in
8972 the range @code{System.Min_Int.System.Max_Int}.
8976 @cindex Record representation clauses
8977 @cindex Representation clauses, records
8978 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
8981 The recommended level of support for
8982 @*@code{record_representation_clauses} is:
8984 An implementation should support storage places that can be extracted
8985 with a load, mask, shift sequence of machine code, and set with a load,
8986 shift, mask, store sequence, given the available machine instructions
8993 A storage place should be supported if its size is equal to the
8994 @code{Size} of the component subtype, and it starts and ends on a
8995 boundary that obeys the @code{Alignment} of the component subtype.
9001 If the default bit ordering applies to the declaration of a given type,
9002 then for a component whose subtype's @code{Size} is less than the word
9003 size, any storage place that does not cross an aligned word boundary
9004 should be supported.
9010 An implementation may reserve a storage place for the tag field of a
9011 tagged type, and disallow other components from overlapping that place.
9013 Followed. The storage place for the tag field is the beginning of the tagged
9014 record, and its size is Address'Size. GNAT will reject an explicit component
9015 clause for the tag field.
9019 An implementation need not support a @code{component_clause} for a
9020 component of an extension part if the storage place is not after the
9021 storage places of all components of the parent type, whether or not
9022 those storage places had been specified.
9024 Followed. The above advice on record representation clauses is followed,
9025 and all mentioned features are implemented.
9027 @cindex Storage place attributes
9028 @unnumberedsec 13.5.2(5): Storage Place Attributes
9031 If a component is represented using some form of pointer (such as an
9032 offset) to the actual data of the component, and this data is contiguous
9033 with the rest of the object, then the storage place attributes should
9034 reflect the place of the actual data, not the pointer. If a component is
9035 allocated discontinuously from the rest of the object, then a warning
9036 should be generated upon reference to one of its storage place
9039 Followed. There are no such components in GNAT@.
9041 @cindex Bit ordering
9042 @unnumberedsec 13.5.3(7-8): Bit Ordering
9045 The recommended level of support for the non-default bit ordering is:
9049 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
9050 should support the non-default bit ordering in addition to the default
9053 Followed. Word size does not equal storage size in this implementation.
9054 Thus non-default bit ordering is not supported.
9056 @cindex @code{Address}, as private type
9057 @unnumberedsec 13.7(37): Address as Private
9060 @code{Address} should be of a private type.
9064 @cindex Operations, on @code{Address}
9065 @cindex @code{Address}, operations of
9066 @unnumberedsec 13.7.1(16): Address Operations
9069 Operations in @code{System} and its children should reflect the target
9070 environment semantics as closely as is reasonable. For example, on most
9071 machines, it makes sense for address arithmetic to ``wrap around''.
9072 Operations that do not make sense should raise @code{Program_Error}.
9074 Followed. Address arithmetic is modular arithmetic that wraps around. No
9075 operation raises @code{Program_Error}, since all operations make sense.
9077 @cindex Unchecked conversion
9078 @unnumberedsec 13.9(14-17): Unchecked Conversion
9081 The @code{Size} of an array object should not include its bounds; hence,
9082 the bounds should not be part of the converted data.
9088 The implementation should not generate unnecessary run-time checks to
9089 ensure that the representation of @var{S} is a representation of the
9090 target type. It should take advantage of the permission to return by
9091 reference when possible. Restrictions on unchecked conversions should be
9092 avoided unless required by the target environment.
9094 Followed. There are no restrictions on unchecked conversion. A warning is
9095 generated if the source and target types do not have the same size since
9096 the semantics in this case may be target dependent.
9100 The recommended level of support for unchecked conversions is:
9104 Unchecked conversions should be supported and should be reversible in
9105 the cases where this clause defines the result. To enable meaningful use
9106 of unchecked conversion, a contiguous representation should be used for
9107 elementary subtypes, for statically constrained array subtypes whose
9108 component subtype is one of the subtypes described in this paragraph,
9109 and for record subtypes without discriminants whose component subtypes
9110 are described in this paragraph.
9114 @cindex Heap usage, implicit
9115 @unnumberedsec 13.11(23-25): Implicit Heap Usage
9118 An implementation should document any cases in which it dynamically
9119 allocates heap storage for a purpose other than the evaluation of an
9122 Followed, the only other points at which heap storage is dynamically
9123 allocated are as follows:
9127 At initial elaboration time, to allocate dynamically sized global
9131 To allocate space for a task when a task is created.
9134 To extend the secondary stack dynamically when needed. The secondary
9135 stack is used for returning variable length results.
9140 A default (implementation-provided) storage pool for an
9141 access-to-constant type should not have overhead to support deallocation of
9148 A storage pool for an anonymous access type should be created at the
9149 point of an allocator for the type, and be reclaimed when the designated
9150 object becomes inaccessible.
9154 @cindex Unchecked deallocation
9155 @unnumberedsec 13.11.2(17): Unchecked De-allocation
9158 For a standard storage pool, @code{Free} should actually reclaim the
9163 @cindex Stream oriented attributes
9164 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
9167 If a stream element is the same size as a storage element, then the
9168 normal in-memory representation should be used by @code{Read} and
9169 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
9170 should use the smallest number of stream elements needed to represent
9171 all values in the base range of the scalar type.
9174 Followed. By default, GNAT uses the interpretation suggested by AI-195,
9175 which specifies using the size of the first subtype.
9176 However, such an implementation is based on direct binary
9177 representations and is therefore target- and endianness-dependent.
9178 To address this issue, GNAT also supplies an alternate implementation
9179 of the stream attributes @code{Read} and @code{Write},
9180 which uses the target-independent XDR standard representation
9182 @cindex XDR representation
9183 @cindex @code{Read} attribute
9184 @cindex @code{Write} attribute
9185 @cindex Stream oriented attributes
9186 The XDR implementation is provided as an alternative body of the
9187 @code{System.Stream_Attributes} package, in the file
9188 @file{s-stratt-xdr.adb} in the GNAT library.
9189 There is no @file{s-stratt-xdr.ads} file.
9190 In order to install the XDR implementation, do the following:
9192 @item Replace the default implementation of the
9193 @code{System.Stream_Attributes} package with the XDR implementation.
9194 For example on a Unix platform issue the commands:
9196 $ mv s-stratt.adb s-stratt-default.adb
9197 $ mv s-stratt-xdr.adb s-stratt.adb
9201 Rebuild the GNAT run-time library as documented in
9202 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
9205 @unnumberedsec A.1(52): Names of Predefined Numeric Types
9208 If an implementation provides additional named predefined integer types,
9209 then the names should end with @samp{Integer} as in
9210 @samp{Long_Integer}. If an implementation provides additional named
9211 predefined floating point types, then the names should end with
9212 @samp{Float} as in @samp{Long_Float}.
9216 @findex Ada.Characters.Handling
9217 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
9220 If an implementation provides a localized definition of @code{Character}
9221 or @code{Wide_Character}, then the effects of the subprograms in
9222 @code{Characters.Handling} should reflect the localizations. See also
9225 Followed. GNAT provides no such localized definitions.
9227 @cindex Bounded-length strings
9228 @unnumberedsec A.4.4(106): Bounded-Length String Handling
9231 Bounded string objects should not be implemented by implicit pointers
9232 and dynamic allocation.
9234 Followed. No implicit pointers or dynamic allocation are used.
9236 @cindex Random number generation
9237 @unnumberedsec A.5.2(46-47): Random Number Generation
9240 Any storage associated with an object of type @code{Generator} should be
9241 reclaimed on exit from the scope of the object.
9247 If the generator period is sufficiently long in relation to the number
9248 of distinct initiator values, then each possible value of
9249 @code{Initiator} passed to @code{Reset} should initiate a sequence of
9250 random numbers that does not, in a practical sense, overlap the sequence
9251 initiated by any other value. If this is not possible, then the mapping
9252 between initiator values and generator states should be a rapidly
9253 varying function of the initiator value.
9255 Followed. The generator period is sufficiently long for the first
9256 condition here to hold true.
9258 @findex Get_Immediate
9259 @unnumberedsec A.10.7(23): @code{Get_Immediate}
9262 The @code{Get_Immediate} procedures should be implemented with
9263 unbuffered input. For a device such as a keyboard, input should be
9264 @dfn{available} if a key has already been typed, whereas for a disk
9265 file, input should always be available except at end of file. For a file
9266 associated with a keyboard-like device, any line-editing features of the
9267 underlying operating system should be disabled during the execution of
9268 @code{Get_Immediate}.
9270 Followed on all targets except VxWorks. For VxWorks, there is no way to
9271 provide this functionality that does not result in the input buffer being
9272 flushed before the @code{Get_Immediate} call. A special unit
9273 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
9277 @unnumberedsec B.1(39-41): Pragma @code{Export}
9280 If an implementation supports pragma @code{Export} to a given language,
9281 then it should also allow the main subprogram to be written in that
9282 language. It should support some mechanism for invoking the elaboration
9283 of the Ada library units included in the system, and for invoking the
9284 finalization of the environment task. On typical systems, the
9285 recommended mechanism is to provide two subprograms whose link names are
9286 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
9287 elaboration code for library units. @code{adafinal} should contain the
9288 finalization code. These subprograms should have no effect the second
9289 and subsequent time they are called.
9295 Automatic elaboration of pre-elaborated packages should be
9296 provided when pragma @code{Export} is supported.
9298 Followed when the main program is in Ada. If the main program is in a
9299 foreign language, then
9300 @code{adainit} must be called to elaborate pre-elaborated
9305 For each supported convention @var{L} other than @code{Intrinsic}, an
9306 implementation should support @code{Import} and @code{Export} pragmas
9307 for objects of @var{L}-compatible types and for subprograms, and pragma
9308 @code{Convention} for @var{L}-eligible types and for subprograms,
9309 presuming the other language has corresponding features. Pragma
9310 @code{Convention} need not be supported for scalar types.
9314 @cindex Package @code{Interfaces}
9316 @unnumberedsec B.2(12-13): Package @code{Interfaces}
9319 For each implementation-defined convention identifier, there should be a
9320 child package of package Interfaces with the corresponding name. This
9321 package should contain any declarations that would be useful for
9322 interfacing to the language (implementation) represented by the
9323 convention. Any declarations useful for interfacing to any language on
9324 the given hardware architecture should be provided directly in
9327 Followed. An additional package not defined
9328 in the Ada Reference Manual is @code{Interfaces.CPP}, used
9329 for interfacing to C++.
9333 An implementation supporting an interface to C, COBOL, or Fortran should
9334 provide the corresponding package or packages described in the following
9337 Followed. GNAT provides all the packages described in this section.
9339 @cindex C, interfacing with
9340 @unnumberedsec B.3(63-71): Interfacing with C
9343 An implementation should support the following interface correspondences
9350 An Ada procedure corresponds to a void-returning C function.
9356 An Ada function corresponds to a non-void C function.
9362 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
9369 An Ada @code{in} parameter of an access-to-object type with designated
9370 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
9371 where @var{t} is the C type corresponding to the Ada type @var{T}.
9377 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
9378 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
9379 argument to a C function, where @var{t} is the C type corresponding to
9380 the Ada type @var{T}. In the case of an elementary @code{out} or
9381 @code{in out} parameter, a pointer to a temporary copy is used to
9382 preserve by-copy semantics.
9388 An Ada parameter of a record type @var{T}, of any mode, is passed as a
9389 @code{@var{t}*} argument to a C function, where @var{t} is the C
9390 structure corresponding to the Ada type @var{T}.
9392 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
9393 pragma, or Convention, or by explicitly specifying the mechanism for a given
9394 call using an extended import or export pragma.
9398 An Ada parameter of an array type with component type @var{T}, of any
9399 mode, is passed as a @code{@var{t}*} argument to a C function, where
9400 @var{t} is the C type corresponding to the Ada type @var{T}.
9406 An Ada parameter of an access-to-subprogram type is passed as a pointer
9407 to a C function whose prototype corresponds to the designated
9408 subprogram's specification.
9412 @cindex COBOL, interfacing with
9413 @unnumberedsec B.4(95-98): Interfacing with COBOL
9416 An Ada implementation should support the following interface
9417 correspondences between Ada and COBOL@.
9423 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
9424 the COBOL type corresponding to @var{T}.
9430 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
9431 the corresponding COBOL type.
9437 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
9438 COBOL type corresponding to the Ada parameter type; for scalars, a local
9439 copy is used if necessary to ensure by-copy semantics.
9443 @cindex Fortran, interfacing with
9444 @unnumberedsec B.5(22-26): Interfacing with Fortran
9447 An Ada implementation should support the following interface
9448 correspondences between Ada and Fortran:
9454 An Ada procedure corresponds to a Fortran subroutine.
9460 An Ada function corresponds to a Fortran function.
9466 An Ada parameter of an elementary, array, or record type @var{T} is
9467 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
9468 the Fortran type corresponding to the Ada type @var{T}, and where the
9469 INTENT attribute of the corresponding dummy argument matches the Ada
9470 formal parameter mode; the Fortran implementation's parameter passing
9471 conventions are used. For elementary types, a local copy is used if
9472 necessary to ensure by-copy semantics.
9478 An Ada parameter of an access-to-subprogram type is passed as a
9479 reference to a Fortran procedure whose interface corresponds to the
9480 designated subprogram's specification.
9484 @cindex Machine operations
9485 @unnumberedsec C.1(3-5): Access to Machine Operations
9488 The machine code or intrinsic support should allow access to all
9489 operations normally available to assembly language programmers for the
9490 target environment, including privileged instructions, if any.
9496 The interfacing pragmas (see Annex B) should support interface to
9497 assembler; the default assembler should be associated with the
9498 convention identifier @code{Assembler}.
9504 If an entity is exported to assembly language, then the implementation
9505 should allocate it at an addressable location, and should ensure that it
9506 is retained by the linking process, even if not otherwise referenced
9507 from the Ada code. The implementation should assume that any call to a
9508 machine code or assembler subprogram is allowed to read or update every
9509 object that is specified as exported.
9513 @unnumberedsec C.1(10-16): Access to Machine Operations
9516 The implementation should ensure that little or no overhead is
9517 associated with calling intrinsic and machine-code subprograms.
9519 Followed for both intrinsics and machine-code subprograms.
9523 It is recommended that intrinsic subprograms be provided for convenient
9524 access to any machine operations that provide special capabilities or
9525 efficiency and that are not otherwise available through the language
9528 Followed. A full set of machine operation intrinsic subprograms is provided.
9532 Atomic read-modify-write operations---e.g.@:, test and set, compare and
9533 swap, decrement and test, enqueue/dequeue.
9535 Followed on any target supporting such operations.
9539 Standard numeric functions---e.g.@:, sin, log.
9541 Followed on any target supporting such operations.
9545 String manipulation operations---e.g.@:, translate and test.
9547 Followed on any target supporting such operations.
9551 Vector operations---e.g.@:, compare vector against thresholds.
9553 Followed on any target supporting such operations.
9557 Direct operations on I/O ports.
9559 Followed on any target supporting such operations.
9561 @cindex Interrupt support
9562 @unnumberedsec C.3(28): Interrupt Support
9565 If the @code{Ceiling_Locking} policy is not in effect, the
9566 implementation should provide means for the application to specify which
9567 interrupts are to be blocked during protected actions, if the underlying
9568 system allows for a finer-grain control of interrupt blocking.
9570 Followed. The underlying system does not allow for finer-grain control
9571 of interrupt blocking.
9573 @cindex Protected procedure handlers
9574 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
9577 Whenever possible, the implementation should allow interrupt handlers to
9578 be called directly by the hardware.
9580 Followed on any target where the underlying operating system permits
9585 Whenever practical, violations of any
9586 implementation-defined restrictions should be detected before run time.
9588 Followed. Compile time warnings are given when possible.
9590 @cindex Package @code{Interrupts}
9592 @unnumberedsec C.3.2(25): Package @code{Interrupts}
9596 If implementation-defined forms of interrupt handler procedures are
9597 supported, such as protected procedures with parameters, then for each
9598 such form of a handler, a type analogous to @code{Parameterless_Handler}
9599 should be specified in a child package of @code{Interrupts}, with the
9600 same operations as in the predefined package Interrupts.
9604 @cindex Pre-elaboration requirements
9605 @unnumberedsec C.4(14): Pre-elaboration Requirements
9608 It is recommended that pre-elaborated packages be implemented in such a
9609 way that there should be little or no code executed at run time for the
9610 elaboration of entities not already covered by the Implementation
9613 Followed. Executable code is generated in some cases, e.g.@: loops
9614 to initialize large arrays.
9616 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
9619 If the pragma applies to an entity, then the implementation should
9620 reduce the amount of storage used for storing names associated with that
9625 @cindex Package @code{Task_Attributes}
9626 @findex Task_Attributes
9627 @unnumberedsec C.7.2(30): The Package Task_Attributes
9630 Some implementations are targeted to domains in which memory use at run
9631 time must be completely deterministic. For such implementations, it is
9632 recommended that the storage for task attributes will be pre-allocated
9633 statically and not from the heap. This can be accomplished by either
9634 placing restrictions on the number and the size of the task's
9635 attributes, or by using the pre-allocated storage for the first @var{N}
9636 attribute objects, and the heap for the others. In the latter case,
9637 @var{N} should be documented.
9639 Not followed. This implementation is not targeted to such a domain.
9641 @cindex Locking Policies
9642 @unnumberedsec D.3(17): Locking Policies
9646 The implementation should use names that end with @samp{_Locking} for
9647 locking policies defined by the implementation.
9649 Followed. Two implementation-defined locking policies are defined,
9650 whose names (@code{Inheritance_Locking} and
9651 @code{Concurrent_Readers_Locking}) follow this suggestion.
9653 @cindex Entry queuing policies
9654 @unnumberedsec D.4(16): Entry Queuing Policies
9657 Names that end with @samp{_Queuing} should be used
9658 for all implementation-defined queuing policies.
9660 Followed. No such implementation-defined queuing policies exist.
9662 @cindex Preemptive abort
9663 @unnumberedsec D.6(9-10): Preemptive Abort
9666 Even though the @code{abort_statement} is included in the list of
9667 potentially blocking operations (see 9.5.1), it is recommended that this
9668 statement be implemented in a way that never requires the task executing
9669 the @code{abort_statement} to block.
9675 On a multi-processor, the delay associated with aborting a task on
9676 another processor should be bounded; the implementation should use
9677 periodic polling, if necessary, to achieve this.
9681 @cindex Tasking restrictions
9682 @unnumberedsec D.7(21): Tasking Restrictions
9685 When feasible, the implementation should take advantage of the specified
9686 restrictions to produce a more efficient implementation.
9688 GNAT currently takes advantage of these restrictions by providing an optimized
9689 run time when the Ravenscar profile and the GNAT restricted run time set
9690 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
9691 pragma @code{Profile (Restricted)} for more details.
9693 @cindex Time, monotonic
9694 @unnumberedsec D.8(47-49): Monotonic Time
9697 When appropriate, implementations should provide configuration
9698 mechanisms to change the value of @code{Tick}.
9700 Such configuration mechanisms are not appropriate to this implementation
9701 and are thus not supported.
9705 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
9706 be implemented as transformations of the same time base.
9712 It is recommended that the @dfn{best} time base which exists in
9713 the underlying system be available to the application through
9714 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
9718 @cindex Partition communication subsystem
9720 @unnumberedsec E.5(28-29): Partition Communication Subsystem
9723 Whenever possible, the PCS on the called partition should allow for
9724 multiple tasks to call the RPC-receiver with different messages and
9725 should allow them to block until the corresponding subprogram body
9728 Followed by GLADE, a separately supplied PCS that can be used with
9733 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
9734 should raise @code{Storage_Error} if it runs out of space trying to
9735 write the @code{Item} into the stream.
9737 Followed by GLADE, a separately supplied PCS that can be used with
9740 @cindex COBOL support
9741 @unnumberedsec F(7): COBOL Support
9744 If COBOL (respectively, C) is widely supported in the target
9745 environment, implementations supporting the Information Systems Annex
9746 should provide the child package @code{Interfaces.COBOL} (respectively,
9747 @code{Interfaces.C}) specified in Annex B and should support a
9748 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
9749 pragmas (see Annex B), thus allowing Ada programs to interface with
9750 programs written in that language.
9754 @cindex Decimal radix support
9755 @unnumberedsec F.1(2): Decimal Radix Support
9758 Packed decimal should be used as the internal representation for objects
9759 of subtype @var{S} when @var{S}'Machine_Radix = 10.
9761 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
9765 @unnumberedsec G: Numerics
9768 If Fortran (respectively, C) is widely supported in the target
9769 environment, implementations supporting the Numerics Annex
9770 should provide the child package @code{Interfaces.Fortran} (respectively,
9771 @code{Interfaces.C}) specified in Annex B and should support a
9772 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
9773 pragmas (see Annex B), thus allowing Ada programs to interface with
9774 programs written in that language.
9778 @cindex Complex types
9779 @unnumberedsec G.1.1(56-58): Complex Types
9782 Because the usual mathematical meaning of multiplication of a complex
9783 operand and a real operand is that of the scaling of both components of
9784 the former by the latter, an implementation should not perform this
9785 operation by first promoting the real operand to complex type and then
9786 performing a full complex multiplication. In systems that, in the
9787 future, support an Ada binding to IEC 559:1989, the latter technique
9788 will not generate the required result when one of the components of the
9789 complex operand is infinite. (Explicit multiplication of the infinite
9790 component by the zero component obtained during promotion yields a NaN
9791 that propagates into the final result.) Analogous advice applies in the
9792 case of multiplication of a complex operand and a pure-imaginary
9793 operand, and in the case of division of a complex operand by a real or
9794 pure-imaginary operand.
9800 Similarly, because the usual mathematical meaning of addition of a
9801 complex operand and a real operand is that the imaginary operand remains
9802 unchanged, an implementation should not perform this operation by first
9803 promoting the real operand to complex type and then performing a full
9804 complex addition. In implementations in which the @code{Signed_Zeros}
9805 attribute of the component type is @code{True} (and which therefore
9806 conform to IEC 559:1989 in regard to the handling of the sign of zero in
9807 predefined arithmetic operations), the latter technique will not
9808 generate the required result when the imaginary component of the complex
9809 operand is a negatively signed zero. (Explicit addition of the negative
9810 zero to the zero obtained during promotion yields a positive zero.)
9811 Analogous advice applies in the case of addition of a complex operand
9812 and a pure-imaginary operand, and in the case of subtraction of a
9813 complex operand and a real or pure-imaginary operand.
9819 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
9820 attempt to provide a rational treatment of the signs of zero results and
9821 result components. As one example, the result of the @code{Argument}
9822 function should have the sign of the imaginary component of the
9823 parameter @code{X} when the point represented by that parameter lies on
9824 the positive real axis; as another, the sign of the imaginary component
9825 of the @code{Compose_From_Polar} function should be the same as
9826 (respectively, the opposite of) that of the @code{Argument} parameter when that
9827 parameter has a value of zero and the @code{Modulus} parameter has a
9828 nonnegative (respectively, negative) value.
9832 @cindex Complex elementary functions
9833 @unnumberedsec G.1.2(49): Complex Elementary Functions
9836 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
9837 @code{True} should attempt to provide a rational treatment of the signs
9838 of zero results and result components. For example, many of the complex
9839 elementary functions have components that are odd functions of one of
9840 the parameter components; in these cases, the result component should
9841 have the sign of the parameter component at the origin. Other complex
9842 elementary functions have zero components whose sign is opposite that of
9843 a parameter component at the origin, or is always positive or always
9848 @cindex Accuracy requirements
9849 @unnumberedsec G.2.4(19): Accuracy Requirements
9852 The versions of the forward trigonometric functions without a
9853 @code{Cycle} parameter should not be implemented by calling the
9854 corresponding version with a @code{Cycle} parameter of
9855 @code{2.0*Numerics.Pi}, since this will not provide the required
9856 accuracy in some portions of the domain. For the same reason, the
9857 version of @code{Log} without a @code{Base} parameter should not be
9858 implemented by calling the corresponding version with a @code{Base}
9859 parameter of @code{Numerics.e}.
9863 @cindex Complex arithmetic accuracy
9864 @cindex Accuracy, complex arithmetic
9865 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
9869 The version of the @code{Compose_From_Polar} function without a
9870 @code{Cycle} parameter should not be implemented by calling the
9871 corresponding version with a @code{Cycle} parameter of
9872 @code{2.0*Numerics.Pi}, since this will not provide the required
9873 accuracy in some portions of the domain.
9877 @cindex Sequential elaboration policy
9878 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
9882 If the partition elaboration policy is @code{Sequential} and the
9883 Environment task becomes permanently blocked during elaboration then the
9884 partition is deadlocked and it is recommended that the partition be
9885 immediately terminated.
9889 @c -----------------------------------------
9890 @node Implementation Defined Characteristics
9891 @chapter Implementation Defined Characteristics
9894 In addition to the implementation dependent pragmas and attributes, and the
9895 implementation advice, there are a number of other Ada features that are
9896 potentially implementation dependent and are designated as
9897 implementation-defined. These are mentioned throughout the Ada Reference
9898 Manual, and are summarized in Annex M@.
9900 A requirement for conforming Ada compilers is that they provide
9901 documentation describing how the implementation deals with each of these
9902 issues. In this chapter, you will find each point in Annex M listed
9903 followed by a description in italic font of how GNAT
9904 handles the implementation dependence.
9906 You can use this chapter as a guide to minimizing implementation
9907 dependent features in your programs if portability to other compilers
9908 and other operating systems is an important consideration. The numbers
9909 in each section below correspond to the paragraph number in the Ada
9915 @strong{2}. Whether or not each recommendation given in Implementation
9916 Advice is followed. See 1.1.2(37).
9919 @xref{Implementation Advice}.
9924 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
9927 The complexity of programs that can be processed is limited only by the
9928 total amount of available virtual memory, and disk space for the
9929 generated object files.
9934 @strong{4}. Variations from the standard that are impractical to avoid
9935 given the implementation's execution environment. See 1.1.3(6).
9938 There are no variations from the standard.
9943 @strong{5}. Which @code{code_statement}s cause external
9944 interactions. See 1.1.3(10).
9947 Any @code{code_statement} can potentially cause external interactions.
9952 @strong{6}. The coded representation for the text of an Ada
9953 program. See 2.1(4).
9956 See separate section on source representation.
9961 @strong{7}. The control functions allowed in comments. See 2.1(14).
9964 See separate section on source representation.
9969 @strong{8}. The representation for an end of line. See 2.2(2).
9972 See separate section on source representation.
9977 @strong{9}. Maximum supported line length and lexical element
9978 length. See 2.2(15).
9981 The maximum line length is 255 characters and the maximum length of
9982 a lexical element is also 255 characters. This is the default setting
9983 if not overridden by the use of compiler switch @option{-gnaty} (which
9984 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
9985 line length to be specified to be any value up to 32767. The maximum
9986 length of a lexical element is the same as the maximum line length.
9991 @strong{10}. Implementation defined pragmas. See 2.8(14).
9995 @xref{Implementation Defined Pragmas}.
10000 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
10003 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
10004 parameter, checks that the optimization flag is set, and aborts if it is
10010 @strong{12}. The sequence of characters of the value returned by
10011 @code{@var{S}'Image} when some of the graphic characters of
10012 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
10016 The sequence of characters is as defined by the wide character encoding
10017 method used for the source. See section on source representation for
10023 @strong{13}. The predefined integer types declared in
10024 @code{Standard}. See 3.5.4(25).
10028 @item Short_Short_Integer
10030 @item Short_Integer
10031 (Short) 16 bit signed
10035 64 bit signed (on most 64 bit targets, depending on the C definition of long).
10036 32 bit signed (all other targets)
10037 @item Long_Long_Integer
10044 @strong{14}. Any nonstandard integer types and the operators defined
10045 for them. See 3.5.4(26).
10048 There are no nonstandard integer types.
10053 @strong{15}. Any nonstandard real types and the operators defined for
10054 them. See 3.5.6(8).
10057 There are no nonstandard real types.
10062 @strong{16}. What combinations of requested decimal precision and range
10063 are supported for floating point types. See 3.5.7(7).
10066 The precision and range is as defined by the IEEE standard.
10071 @strong{17}. The predefined floating point types declared in
10072 @code{Standard}. See 3.5.7(16).
10079 (Short) 32 bit IEEE short
10082 @item Long_Long_Float
10083 64 bit IEEE long (80 bit IEEE long on x86 processors)
10089 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
10092 @code{Fine_Delta} is 2**(@minus{}63)
10097 @strong{19}. What combinations of small, range, and digits are
10098 supported for fixed point types. See 3.5.9(10).
10101 Any combinations are permitted that do not result in a small less than
10102 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
10103 If the mantissa is larger than 53 bits on machines where Long_Long_Float
10104 is 64 bits (true of all architectures except ia32), then the output from
10105 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
10106 is because floating-point conversions are used to convert fixed point.
10111 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
10112 within an unnamed @code{block_statement}. See 3.9(10).
10115 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
10116 decimal integer are allocated.
10121 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
10124 @xref{Implementation Defined Attributes}.
10129 @strong{22}. Any implementation-defined time types. See 9.6(6).
10132 There are no implementation-defined time types.
10137 @strong{23}. The time base associated with relative delays.
10140 See 9.6(20). The time base used is that provided by the C library
10141 function @code{gettimeofday}.
10146 @strong{24}. The time base of the type @code{Calendar.Time}. See
10150 The time base used is that provided by the C library function
10151 @code{gettimeofday}.
10156 @strong{25}. The time zone used for package @code{Calendar}
10157 operations. See 9.6(24).
10160 The time zone used by package @code{Calendar} is the current system time zone
10161 setting for local time, as accessed by the C library function
10167 @strong{26}. Any limit on @code{delay_until_statements} of
10168 @code{select_statements}. See 9.6(29).
10171 There are no such limits.
10176 @strong{27}. Whether or not two non-overlapping parts of a composite
10177 object are independently addressable, in the case where packing, record
10178 layout, or @code{Component_Size} is specified for the object. See
10182 Separate components are independently addressable if they do not share
10183 overlapping storage units.
10188 @strong{28}. The representation for a compilation. See 10.1(2).
10191 A compilation is represented by a sequence of files presented to the
10192 compiler in a single invocation of the @command{gcc} command.
10197 @strong{29}. Any restrictions on compilations that contain multiple
10198 compilation_units. See 10.1(4).
10201 No single file can contain more than one compilation unit, but any
10202 sequence of files can be presented to the compiler as a single
10208 @strong{30}. The mechanisms for creating an environment and for adding
10209 and replacing compilation units. See 10.1.4(3).
10212 See separate section on compilation model.
10217 @strong{31}. The manner of explicitly assigning library units to a
10218 partition. See 10.2(2).
10221 If a unit contains an Ada main program, then the Ada units for the partition
10222 are determined by recursive application of the rules in the Ada Reference
10223 Manual section 10.2(2-6). In other words, the Ada units will be those that
10224 are needed by the main program, and then this definition of need is applied
10225 recursively to those units, and the partition contains the transitive
10226 closure determined by this relationship. In short, all the necessary units
10227 are included, with no need to explicitly specify the list. If additional
10228 units are required, e.g.@: by foreign language units, then all units must be
10229 mentioned in the context clause of one of the needed Ada units.
10231 If the partition contains no main program, or if the main program is in
10232 a language other than Ada, then GNAT
10233 provides the binder options @option{-z} and @option{-n} respectively, and in
10234 this case a list of units can be explicitly supplied to the binder for
10235 inclusion in the partition (all units needed by these units will also
10236 be included automatically). For full details on the use of these
10237 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
10238 @value{EDITION} User's Guide}.
10243 @strong{32}. The implementation-defined means, if any, of specifying
10244 which compilation units are needed by a given compilation unit. See
10248 The units needed by a given compilation unit are as defined in
10249 the Ada Reference Manual section 10.2(2-6). There are no
10250 implementation-defined pragmas or other implementation-defined
10251 means for specifying needed units.
10256 @strong{33}. The manner of designating the main subprogram of a
10257 partition. See 10.2(7).
10260 The main program is designated by providing the name of the
10261 corresponding @file{ALI} file as the input parameter to the binder.
10266 @strong{34}. The order of elaboration of @code{library_items}. See
10270 The first constraint on ordering is that it meets the requirements of
10271 Chapter 10 of the Ada Reference Manual. This still leaves some
10272 implementation dependent choices, which are resolved by first
10273 elaborating bodies as early as possible (i.e., in preference to specs
10274 where there is a choice), and second by evaluating the immediate with
10275 clauses of a unit to determine the probably best choice, and
10276 third by elaborating in alphabetical order of unit names
10277 where a choice still remains.
10282 @strong{35}. Parameter passing and function return for the main
10283 subprogram. See 10.2(21).
10286 The main program has no parameters. It may be a procedure, or a function
10287 returning an integer type. In the latter case, the returned integer
10288 value is the return code of the program (overriding any value that
10289 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
10294 @strong{36}. The mechanisms for building and running partitions. See
10298 GNAT itself supports programs with only a single partition. The GNATDIST
10299 tool provided with the GLADE package (which also includes an implementation
10300 of the PCS) provides a completely flexible method for building and running
10301 programs consisting of multiple partitions. See the separate GLADE manual
10307 @strong{37}. The details of program execution, including program
10308 termination. See 10.2(25).
10311 See separate section on compilation model.
10316 @strong{38}. The semantics of any non-active partitions supported by the
10317 implementation. See 10.2(28).
10320 Passive partitions are supported on targets where shared memory is
10321 provided by the operating system. See the GLADE reference manual for
10327 @strong{39}. The information returned by @code{Exception_Message}. See
10331 Exception message returns the null string unless a specific message has
10332 been passed by the program.
10337 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
10338 declared within an unnamed @code{block_statement}. See 11.4.1(12).
10341 Blocks have implementation defined names of the form @code{B@var{nnn}}
10342 where @var{nnn} is an integer.
10347 @strong{41}. The information returned by
10348 @code{Exception_Information}. See 11.4.1(13).
10351 @code{Exception_Information} returns a string in the following format:
10354 @emph{Exception_Name:} nnnnn
10355 @emph{Message:} mmmmm
10357 @emph{Call stack traceback locations:}
10358 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
10366 @code{nnnn} is the fully qualified name of the exception in all upper
10367 case letters. This line is always present.
10370 @code{mmmm} is the message (this line present only if message is non-null)
10373 @code{ppp} is the Process Id value as a decimal integer (this line is
10374 present only if the Process Id is nonzero). Currently we are
10375 not making use of this field.
10378 The Call stack traceback locations line and the following values
10379 are present only if at least one traceback location was recorded.
10380 The values are given in C style format, with lower case letters
10381 for a-f, and only as many digits present as are necessary.
10385 The line terminator sequence at the end of each line, including
10386 the last line is a single @code{LF} character (@code{16#0A#}).
10391 @strong{42}. Implementation-defined check names. See 11.5(27).
10394 The implementation defined check name Alignment_Check controls checking of
10395 address clause values for proper alignment (that is, the address supplied
10396 must be consistent with the alignment of the type).
10398 In addition, a user program can add implementation-defined check names
10399 by means of the pragma Check_Name.
10404 @strong{43}. The interpretation of each aspect of representation. See
10408 See separate section on data representations.
10413 @strong{44}. Any restrictions placed upon representation items. See
10417 See separate section on data representations.
10422 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
10426 Size for an indefinite subtype is the maximum possible size, except that
10427 for the case of a subprogram parameter, the size of the parameter object
10428 is the actual size.
10433 @strong{46}. The default external representation for a type tag. See
10437 The default external representation for a type tag is the fully expanded
10438 name of the type in upper case letters.
10443 @strong{47}. What determines whether a compilation unit is the same in
10444 two different partitions. See 13.3(76).
10447 A compilation unit is the same in two different partitions if and only
10448 if it derives from the same source file.
10453 @strong{48}. Implementation-defined components. See 13.5.1(15).
10456 The only implementation defined component is the tag for a tagged type,
10457 which contains a pointer to the dispatching table.
10462 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
10463 ordering. See 13.5.3(5).
10466 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
10467 implementation, so no non-default bit ordering is supported. The default
10468 bit ordering corresponds to the natural endianness of the target architecture.
10473 @strong{50}. The contents of the visible part of package @code{System}
10474 and its language-defined children. See 13.7(2).
10477 See the definition of these packages in files @file{system.ads} and
10478 @file{s-stoele.ads}.
10483 @strong{51}. The contents of the visible part of package
10484 @code{System.Machine_Code}, and the meaning of
10485 @code{code_statements}. See 13.8(7).
10488 See the definition and documentation in file @file{s-maccod.ads}.
10493 @strong{52}. The effect of unchecked conversion. See 13.9(11).
10496 Unchecked conversion between types of the same size
10497 results in an uninterpreted transmission of the bits from one type
10498 to the other. If the types are of unequal sizes, then in the case of
10499 discrete types, a shorter source is first zero or sign extended as
10500 necessary, and a shorter target is simply truncated on the left.
10501 For all non-discrete types, the source is first copied if necessary
10502 to ensure that the alignment requirements of the target are met, then
10503 a pointer is constructed to the source value, and the result is obtained
10504 by dereferencing this pointer after converting it to be a pointer to the
10505 target type. Unchecked conversions where the target subtype is an
10506 unconstrained array are not permitted. If the target alignment is
10507 greater than the source alignment, then a copy of the result is
10508 made with appropriate alignment
10513 @strong{53}. The semantics of operations on invalid representations.
10517 For assignments and other operations where the use of invalid values cannot
10518 result in erroneous behavior, the compiler ignores the possibility of invalid
10519 values. An exception is raised at the point where an invalid value would
10520 result in erroneous behavior. For example executing:
10522 @smallexample @c ada
10523 procedure invalidvals is
10525 Y : Natural range 1 .. 10;
10526 for Y'Address use X'Address;
10527 Z : Natural range 1 .. 10;
10528 A : array (Natural range 1 .. 10) of Integer;
10530 Z := Y; -- no exception
10531 A (Z) := 3; -- exception raised;
10536 As indicated, an exception is raised on the array assignment, but not
10537 on the simple assignment of the invalid negative value from Y to Z.
10542 @strong{53}. The manner of choosing a storage pool for an access type
10543 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
10546 There are 3 different standard pools used by the compiler when
10547 @code{Storage_Pool} is not specified depending whether the type is local
10548 to a subprogram or defined at the library level and whether
10549 @code{Storage_Size}is specified or not. See documentation in the runtime
10550 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
10551 @code{System.Pool_Local} in files @file{s-poosiz.ads},
10552 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
10553 default pools used.
10558 @strong{54}. Whether or not the implementation provides user-accessible
10559 names for the standard pool type(s). See 13.11(17).
10563 See documentation in the sources of the run time mentioned in paragraph
10564 @strong{53} . All these pools are accessible by means of @code{with}'ing
10570 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
10573 @code{Storage_Size} is measured in storage units, and refers to the
10574 total space available for an access type collection, or to the primary
10575 stack space for a task.
10580 @strong{56}. Implementation-defined aspects of storage pools. See
10584 See documentation in the sources of the run time mentioned in paragraph
10585 @strong{53} for details on GNAT-defined aspects of storage pools.
10590 @strong{57}. The set of restrictions allowed in a pragma
10591 @code{Restrictions}. See 13.12(7).
10594 @xref{Standard and Implementation Defined Restrictions}.
10599 @strong{58}. The consequences of violating limitations on
10600 @code{Restrictions} pragmas. See 13.12(9).
10603 Restrictions that can be checked at compile time result in illegalities
10604 if violated. Currently there are no other consequences of violating
10610 @strong{59}. The representation used by the @code{Read} and
10611 @code{Write} attributes of elementary types in terms of stream
10612 elements. See 13.13.2(9).
10615 The representation is the in-memory representation of the base type of
10616 the type, using the number of bits corresponding to the
10617 @code{@var{type}'Size} value, and the natural ordering of the machine.
10622 @strong{60}. The names and characteristics of the numeric subtypes
10623 declared in the visible part of package @code{Standard}. See A.1(3).
10626 See items describing the integer and floating-point types supported.
10631 @strong{61}. The accuracy actually achieved by the elementary
10632 functions. See A.5.1(1).
10635 The elementary functions correspond to the functions available in the C
10636 library. Only fast math mode is implemented.
10641 @strong{62}. The sign of a zero result from some of the operators or
10642 functions in @code{Numerics.Generic_Elementary_Functions}, when
10643 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
10646 The sign of zeroes follows the requirements of the IEEE 754 standard on
10652 @strong{63}. The value of
10653 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
10656 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10661 @strong{64}. The value of
10662 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
10665 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10670 @strong{65}. The algorithms for random number generation. See
10674 The algorithm is the Mersenne Twister, as documented in the source file
10675 @file{s-rannum.adb}. This version of the algorithm has a period of
10681 @strong{66}. The string representation of a random number generator's
10682 state. See A.5.2(38).
10685 The value returned by the Image function is the concatenation of
10686 the fixed-width decimal representations of the 624 32-bit integers
10687 of the state vector.
10692 @strong{67}. The minimum time interval between calls to the
10693 time-dependent Reset procedure that are guaranteed to initiate different
10694 random number sequences. See A.5.2(45).
10697 The minimum period between reset calls to guarantee distinct series of
10698 random numbers is one microsecond.
10703 @strong{68}. The values of the @code{Model_Mantissa},
10704 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
10705 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
10706 Annex is not supported. See A.5.3(72).
10709 Run the compiler with @option{-gnatS} to produce a listing of package
10710 @code{Standard}, has the values of all numeric attributes.
10715 @strong{69}. Any implementation-defined characteristics of the
10716 input-output packages. See A.7(14).
10719 There are no special implementation defined characteristics for these
10725 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
10729 All type representations are contiguous, and the @code{Buffer_Size} is
10730 the value of @code{@var{type}'Size} rounded up to the next storage unit
10736 @strong{71}. External files for standard input, standard output, and
10737 standard error See A.10(5).
10740 These files are mapped onto the files provided by the C streams
10741 libraries. See source file @file{i-cstrea.ads} for further details.
10746 @strong{72}. The accuracy of the value produced by @code{Put}. See
10750 If more digits are requested in the output than are represented by the
10751 precision of the value, zeroes are output in the corresponding least
10752 significant digit positions.
10757 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
10758 @code{Command_Name}. See A.15(1).
10761 These are mapped onto the @code{argv} and @code{argc} parameters of the
10762 main program in the natural manner.
10767 @strong{74}. The interpretation of the @code{Form} parameter in procedure
10768 @code{Create_Directory}. See A.16(56).
10771 The @code{Form} parameter is not used.
10776 @strong{75}. The interpretation of the @code{Form} parameter in procedure
10777 @code{Create_Path}. See A.16(60).
10780 The @code{Form} parameter is not used.
10785 @strong{76}. The interpretation of the @code{Form} parameter in procedure
10786 @code{Copy_File}. See A.16(68).
10789 The @code{Form} parameter is case-insensitive.
10791 Two fields are recognized in the @code{Form} parameter:
10795 @item preserve=<value>
10802 <value> starts immediately after the character '=' and ends with the
10803 character immediately preceding the next comma (',') or with the last
10804 character of the parameter.
10806 The only possible values for preserve= are:
10810 @item no_attributes
10811 Do not try to preserve any file attributes. This is the default if no
10812 preserve= is found in Form.
10814 @item all_attributes
10815 Try to preserve all file attributes (timestamps, access rights).
10818 Preserve the timestamp of the copied file, but not the other file attributes.
10823 The only possible values for mode= are:
10828 Only do the copy if the destination file does not already exist. If it already
10829 exists, Copy_File fails.
10832 Copy the file in all cases. Overwrite an already existing destination file.
10835 Append the original file to the destination file. If the destination file does
10836 not exist, the destination file is a copy of the source file. When mode=append,
10837 the field preserve=, if it exists, is not taken into account.
10842 If the Form parameter includes one or both of the fields and the value or
10843 values are incorrect, Copy_file fails with Use_Error.
10845 Examples of correct Forms:
10848 Form => "preserve=no_attributes,mode=overwrite" (the default)
10849 Form => "mode=append"
10850 Form => "mode=copy, preserve=all_attributes"
10854 Examples of incorrect Forms
10857 Form => "preserve=junk"
10858 Form => "mode=internal, preserve=timestamps"
10864 @strong{77}. Implementation-defined convention names. See B.1(11).
10867 The following convention names are supported
10872 @item Ada_Pass_By_Copy
10873 Allowed for any types except by-reference types such as limited
10874 records. Compatible with convention Ada, but causes any parameters
10875 with this convention to be passed by copy.
10876 @item Ada_Pass_By_Reference
10877 Allowed for any types except by-copy types such as scalars.
10878 Compatible with convention Ada, but causes any parameters
10879 with this convention to be passed by reference.
10883 Synonym for Assembler
10885 Synonym for Assembler
10888 @item C_Pass_By_Copy
10889 Allowed only for record types, like C, but also notes that record
10890 is to be passed by copy rather than reference.
10893 @item C_Plus_Plus (or CPP)
10896 Treated the same as C
10898 Treated the same as C
10902 For support of pragma @code{Import} with convention Intrinsic, see
10903 separate section on Intrinsic Subprograms.
10905 Stdcall (used for Windows implementations only). This convention correspond
10906 to the WINAPI (previously called Pascal convention) C/C++ convention under
10907 Windows. A routine with this convention cleans the stack before
10908 exit. This pragma cannot be applied to a dispatching call.
10910 Synonym for Stdcall
10912 Synonym for Stdcall
10914 Stubbed is a special convention used to indicate that the body of the
10915 subprogram will be entirely ignored. Any call to the subprogram
10916 is converted into a raise of the @code{Program_Error} exception. If a
10917 pragma @code{Import} specifies convention @code{stubbed} then no body need
10918 be present at all. This convention is useful during development for the
10919 inclusion of subprograms whose body has not yet been written.
10923 In addition, all otherwise unrecognized convention names are also
10924 treated as being synonymous with convention C@. In all implementations
10925 except for VMS, use of such other names results in a warning. In VMS
10926 implementations, these names are accepted silently.
10931 @strong{78}. The meaning of link names. See B.1(36).
10934 Link names are the actual names used by the linker.
10939 @strong{79}. The manner of choosing link names when neither the link
10940 name nor the address of an imported or exported entity is specified. See
10944 The default linker name is that which would be assigned by the relevant
10945 external language, interpreting the Ada name as being in all lower case
10951 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
10954 The string passed to @code{Linker_Options} is presented uninterpreted as
10955 an argument to the link command, unless it contains ASCII.NUL characters.
10956 NUL characters if they appear act as argument separators, so for example
10958 @smallexample @c ada
10959 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
10963 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
10964 linker. The order of linker options is preserved for a given unit. The final
10965 list of options passed to the linker is in reverse order of the elaboration
10966 order. For example, linker options for a body always appear before the options
10967 from the corresponding package spec.
10972 @strong{81}. The contents of the visible part of package
10973 @code{Interfaces} and its language-defined descendants. See B.2(1).
10976 See files with prefix @file{i-} in the distributed library.
10981 @strong{82}. Implementation-defined children of package
10982 @code{Interfaces}. The contents of the visible part of package
10983 @code{Interfaces}. See B.2(11).
10986 See files with prefix @file{i-} in the distributed library.
10991 @strong{83}. The types @code{Floating}, @code{Long_Floating},
10992 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
10993 @code{COBOL_Character}; and the initialization of the variables
10994 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
10995 @code{Interfaces.COBOL}. See B.4(50).
11001 @item Long_Floating
11002 (Floating) Long_Float
11007 @item Decimal_Element
11009 @item COBOL_Character
11014 For initialization, see the file @file{i-cobol.ads} in the distributed library.
11019 @strong{84}. Support for access to machine instructions. See C.1(1).
11022 See documentation in file @file{s-maccod.ads} in the distributed library.
11027 @strong{85}. Implementation-defined aspects of access to machine
11028 operations. See C.1(9).
11031 See documentation in file @file{s-maccod.ads} in the distributed library.
11036 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
11039 Interrupts are mapped to signals or conditions as appropriate. See
11041 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
11042 on the interrupts supported on a particular target.
11047 @strong{87}. Implementation-defined aspects of pre-elaboration. See
11051 GNAT does not permit a partition to be restarted without reloading,
11052 except under control of the debugger.
11057 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
11060 Pragma @code{Discard_Names} causes names of enumeration literals to
11061 be suppressed. In the presence of this pragma, the Image attribute
11062 provides the image of the Pos of the literal, and Value accepts
11068 @strong{89}. The result of the @code{Task_Identification.Image}
11069 attribute. See C.7.1(7).
11072 The result of this attribute is a string that identifies
11073 the object or component that denotes a given task. If a variable @code{Var}
11074 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
11076 is the hexadecimal representation of the virtual address of the corresponding
11077 task control block. If the variable is an array of tasks, the image of each
11078 task will have the form of an indexed component indicating the position of a
11079 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
11080 component of a record, the image of the task will have the form of a selected
11081 component. These rules are fully recursive, so that the image of a task that
11082 is a subcomponent of a composite object corresponds to the expression that
11083 designates this task.
11085 If a task is created by an allocator, its image depends on the context. If the
11086 allocator is part of an object declaration, the rules described above are used
11087 to construct its image, and this image is not affected by subsequent
11088 assignments. If the allocator appears within an expression, the image
11089 includes only the name of the task type.
11091 If the configuration pragma Discard_Names is present, or if the restriction
11092 No_Implicit_Heap_Allocation is in effect, the image reduces to
11093 the numeric suffix, that is to say the hexadecimal representation of the
11094 virtual address of the control block of the task.
11098 @strong{90}. The value of @code{Current_Task} when in a protected entry
11099 or interrupt handler. See C.7.1(17).
11102 Protected entries or interrupt handlers can be executed by any
11103 convenient thread, so the value of @code{Current_Task} is undefined.
11108 @strong{91}. The effect of calling @code{Current_Task} from an entry
11109 body or interrupt handler. See C.7.1(19).
11112 The effect of calling @code{Current_Task} from an entry body or
11113 interrupt handler is to return the identification of the task currently
11114 executing the code.
11119 @strong{92}. Implementation-defined aspects of
11120 @code{Task_Attributes}. See C.7.2(19).
11123 There are no implementation-defined aspects of @code{Task_Attributes}.
11128 @strong{93}. Values of all @code{Metrics}. See D(2).
11131 The metrics information for GNAT depends on the performance of the
11132 underlying operating system. The sources of the run-time for tasking
11133 implementation, together with the output from @option{-gnatG} can be
11134 used to determine the exact sequence of operating systems calls made
11135 to implement various tasking constructs. Together with appropriate
11136 information on the performance of the underlying operating system,
11137 on the exact target in use, this information can be used to determine
11138 the required metrics.
11143 @strong{94}. The declarations of @code{Any_Priority} and
11144 @code{Priority}. See D.1(11).
11147 See declarations in file @file{system.ads}.
11152 @strong{95}. Implementation-defined execution resources. See D.1(15).
11155 There are no implementation-defined execution resources.
11160 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
11161 access to a protected object keeps its processor busy. See D.2.1(3).
11164 On a multi-processor, a task that is waiting for access to a protected
11165 object does not keep its processor busy.
11170 @strong{97}. The affect of implementation defined execution resources
11171 on task dispatching. See D.2.1(9).
11174 Tasks map to threads in the threads package used by GNAT@. Where possible
11175 and appropriate, these threads correspond to native threads of the
11176 underlying operating system.
11181 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
11182 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
11185 There are no implementation-defined policy-identifiers allowed in this
11191 @strong{99}. Implementation-defined aspects of priority inversion. See
11195 Execution of a task cannot be preempted by the implementation processing
11196 of delay expirations for lower priority tasks.
11201 @strong{100}. Implementation-defined task dispatching. See D.2.2(18).
11204 The policy is the same as that of the underlying threads implementation.
11209 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
11210 in a pragma @code{Locking_Policy}. See D.3(4).
11213 The two implementation defined policies permitted in GNAT are
11214 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
11215 targets that support the @code{Inheritance_Locking} policy, locking is
11216 implemented by inheritance, i.e.@: the task owning the lock operates
11217 at a priority equal to the highest priority of any task currently
11218 requesting the lock. On targets that support the
11219 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
11220 read/write lock allowing multiple propected object functions to enter
11226 @strong{102}. Default ceiling priorities. See D.3(10).
11229 The ceiling priority of protected objects of the type
11230 @code{System.Interrupt_Priority'Last} as described in the Ada
11231 Reference Manual D.3(10),
11236 @strong{103}. The ceiling of any protected object used internally by
11237 the implementation. See D.3(16).
11240 The ceiling priority of internal protected objects is
11241 @code{System.Priority'Last}.
11246 @strong{104}. Implementation-defined queuing policies. See D.4(1).
11249 There are no implementation-defined queuing policies.
11254 @strong{105}. On a multiprocessor, any conditions that cause the
11255 completion of an aborted construct to be delayed later than what is
11256 specified for a single processor. See D.6(3).
11259 The semantics for abort on a multi-processor is the same as on a single
11260 processor, there are no further delays.
11265 @strong{106}. Any operations that implicitly require heap storage
11266 allocation. See D.7(8).
11269 The only operation that implicitly requires heap storage allocation is
11275 @strong{107}. Implementation-defined aspects of pragma
11276 @code{Restrictions}. See D.7(20).
11279 There are no such implementation-defined aspects.
11284 @strong{108}. Implementation-defined aspects of package
11285 @code{Real_Time}. See D.8(17).
11288 There are no implementation defined aspects of package @code{Real_Time}.
11293 @strong{109}. Implementation-defined aspects of
11294 @code{delay_statements}. See D.9(8).
11297 Any difference greater than one microsecond will cause the task to be
11298 delayed (see D.9(7)).
11303 @strong{110}. The upper bound on the duration of interrupt blocking
11304 caused by the implementation. See D.12(5).
11307 The upper bound is determined by the underlying operating system. In
11308 no cases is it more than 10 milliseconds.
11313 @strong{111}. The means for creating and executing distributed
11314 programs. See E(5).
11317 The GLADE package provides a utility GNATDIST for creating and executing
11318 distributed programs. See the GLADE reference manual for further details.
11323 @strong{112}. Any events that can result in a partition becoming
11324 inaccessible. See E.1(7).
11327 See the GLADE reference manual for full details on such events.
11332 @strong{113}. The scheduling policies, treatment of priorities, and
11333 management of shared resources between partitions in certain cases. See
11337 See the GLADE reference manual for full details on these aspects of
11338 multi-partition execution.
11343 @strong{114}. Events that cause the version of a compilation unit to
11344 change. See E.3(5).
11347 Editing the source file of a compilation unit, or the source files of
11348 any units on which it is dependent in a significant way cause the version
11349 to change. No other actions cause the version number to change. All changes
11350 are significant except those which affect only layout, capitalization or
11356 @strong{115}. Whether the execution of the remote subprogram is
11357 immediately aborted as a result of cancellation. See E.4(13).
11360 See the GLADE reference manual for details on the effect of abort in
11361 a distributed application.
11366 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
11369 See the GLADE reference manual for a full description of all implementation
11370 defined aspects of the PCS@.
11375 @strong{117}. Implementation-defined interfaces in the PCS@. See
11379 See the GLADE reference manual for a full description of all
11380 implementation defined interfaces.
11385 @strong{118}. The values of named numbers in the package
11386 @code{Decimal}. See F.2(7).
11398 @item Max_Decimal_Digits
11405 @strong{119}. The value of @code{Max_Picture_Length} in the package
11406 @code{Text_IO.Editing}. See F.3.3(16).
11414 @strong{120}. The value of @code{Max_Picture_Length} in the package
11415 @code{Wide_Text_IO.Editing}. See F.3.4(5).
11423 @strong{121}. The accuracy actually achieved by the complex elementary
11424 functions and by other complex arithmetic operations. See G.1(1).
11427 Standard library functions are used for the complex arithmetic
11428 operations. Only fast math mode is currently supported.
11433 @strong{122}. The sign of a zero result (or a component thereof) from
11434 any operator or function in @code{Numerics.Generic_Complex_Types}, when
11435 @code{Real'Signed_Zeros} is True. See G.1.1(53).
11438 The signs of zero values are as recommended by the relevant
11439 implementation advice.
11444 @strong{123}. The sign of a zero result (or a component thereof) from
11445 any operator or function in
11446 @code{Numerics.Generic_Complex_Elementary_Functions}, when
11447 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
11450 The signs of zero values are as recommended by the relevant
11451 implementation advice.
11456 @strong{124}. Whether the strict mode or the relaxed mode is the
11457 default. See G.2(2).
11460 The strict mode is the default. There is no separate relaxed mode. GNAT
11461 provides a highly efficient implementation of strict mode.
11466 @strong{125}. The result interval in certain cases of fixed-to-float
11467 conversion. See G.2.1(10).
11470 For cases where the result interval is implementation dependent, the
11471 accuracy is that provided by performing all operations in 64-bit IEEE
11472 floating-point format.
11477 @strong{126}. The result of a floating point arithmetic operation in
11478 overflow situations, when the @code{Machine_Overflows} attribute of the
11479 result type is @code{False}. See G.2.1(13).
11482 Infinite and NaN values are produced as dictated by the IEEE
11483 floating-point standard.
11485 Note that on machines that are not fully compliant with the IEEE
11486 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
11487 must be used for achieving IEEE conforming behavior (although at the cost
11488 of a significant performance penalty), so infinite and NaN values are
11489 properly generated.
11494 @strong{127}. The result interval for division (or exponentiation by a
11495 negative exponent), when the floating point hardware implements division
11496 as multiplication by a reciprocal. See G.2.1(16).
11499 Not relevant, division is IEEE exact.
11504 @strong{128}. The definition of close result set, which determines the
11505 accuracy of certain fixed point multiplications and divisions. See
11509 Operations in the close result set are performed using IEEE long format
11510 floating-point arithmetic. The input operands are converted to
11511 floating-point, the operation is done in floating-point, and the result
11512 is converted to the target type.
11517 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
11518 point multiplication or division for which the result shall be in the
11519 perfect result set. See G.2.3(22).
11522 The result is only defined to be in the perfect result set if the result
11523 can be computed by a single scaling operation involving a scale factor
11524 representable in 64-bits.
11529 @strong{130}. The result of a fixed point arithmetic operation in
11530 overflow situations, when the @code{Machine_Overflows} attribute of the
11531 result type is @code{False}. See G.2.3(27).
11534 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
11540 @strong{131}. The result of an elementary function reference in
11541 overflow situations, when the @code{Machine_Overflows} attribute of the
11542 result type is @code{False}. See G.2.4(4).
11545 IEEE infinite and Nan values are produced as appropriate.
11550 @strong{132}. The value of the angle threshold, within which certain
11551 elementary functions, complex arithmetic operations, and complex
11552 elementary functions yield results conforming to a maximum relative
11553 error bound. See G.2.4(10).
11556 Information on this subject is not yet available.
11561 @strong{133}. The accuracy of certain elementary functions for
11562 parameters beyond the angle threshold. See G.2.4(10).
11565 Information on this subject is not yet available.
11570 @strong{134}. The result of a complex arithmetic operation or complex
11571 elementary function reference in overflow situations, when the
11572 @code{Machine_Overflows} attribute of the corresponding real type is
11573 @code{False}. See G.2.6(5).
11576 IEEE infinite and Nan values are produced as appropriate.
11581 @strong{135}. The accuracy of certain complex arithmetic operations and
11582 certain complex elementary functions for parameters (or components
11583 thereof) beyond the angle threshold. See G.2.6(8).
11586 Information on those subjects is not yet available.
11591 @strong{136}. Information regarding bounded errors and erroneous
11592 execution. See H.2(1).
11595 Information on this subject is not yet available.
11600 @strong{137}. Implementation-defined aspects of pragma
11601 @code{Inspection_Point}. See H.3.2(8).
11604 Pragma @code{Inspection_Point} ensures that the variable is live and can
11605 be examined by the debugger at the inspection point.
11610 @strong{138}. Implementation-defined aspects of pragma
11611 @code{Restrictions}. See H.4(25).
11614 There are no implementation-defined aspects of pragma @code{Restrictions}. The
11615 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
11616 generated code. Checks must suppressed by use of pragma @code{Suppress}.
11621 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
11625 There are no restrictions on pragma @code{Restrictions}.
11627 @node Intrinsic Subprograms
11628 @chapter Intrinsic Subprograms
11629 @cindex Intrinsic Subprograms
11632 * Intrinsic Operators::
11633 * Enclosing_Entity::
11634 * Exception_Information::
11635 * Exception_Message::
11639 * Shifts and Rotates::
11640 * Source_Location::
11644 GNAT allows a user application program to write the declaration:
11646 @smallexample @c ada
11647 pragma Import (Intrinsic, name);
11651 providing that the name corresponds to one of the implemented intrinsic
11652 subprograms in GNAT, and that the parameter profile of the referenced
11653 subprogram meets the requirements. This chapter describes the set of
11654 implemented intrinsic subprograms, and the requirements on parameter profiles.
11655 Note that no body is supplied; as with other uses of pragma Import, the
11656 body is supplied elsewhere (in this case by the compiler itself). Note
11657 that any use of this feature is potentially non-portable, since the
11658 Ada standard does not require Ada compilers to implement this feature.
11660 @node Intrinsic Operators
11661 @section Intrinsic Operators
11662 @cindex Intrinsic operator
11665 All the predefined numeric operators in package Standard
11666 in @code{pragma Import (Intrinsic,..)}
11667 declarations. In the binary operator case, the operands must have the same
11668 size. The operand or operands must also be appropriate for
11669 the operator. For example, for addition, the operands must
11670 both be floating-point or both be fixed-point, and the
11671 right operand for @code{"**"} must have a root type of
11672 @code{Standard.Integer'Base}.
11673 You can use an intrinsic operator declaration as in the following example:
11675 @smallexample @c ada
11676 type Int1 is new Integer;
11677 type Int2 is new Integer;
11679 function "+" (X1 : Int1; X2 : Int2) return Int1;
11680 function "+" (X1 : Int1; X2 : Int2) return Int2;
11681 pragma Import (Intrinsic, "+");
11685 This declaration would permit ``mixed mode'' arithmetic on items
11686 of the differing types @code{Int1} and @code{Int2}.
11687 It is also possible to specify such operators for private types, if the
11688 full views are appropriate arithmetic types.
11690 @node Enclosing_Entity
11691 @section Enclosing_Entity
11692 @cindex Enclosing_Entity
11694 This intrinsic subprogram is used in the implementation of the
11695 library routine @code{GNAT.Source_Info}. The only useful use of the
11696 intrinsic import in this case is the one in this unit, so an
11697 application program should simply call the function
11698 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
11699 the current subprogram, package, task, entry, or protected subprogram.
11701 @node Exception_Information
11702 @section Exception_Information
11703 @cindex Exception_Information'
11705 This intrinsic subprogram is used in the implementation of the
11706 library routine @code{GNAT.Current_Exception}. The only useful
11707 use of the intrinsic import in this case is the one in this unit,
11708 so an application program should simply call the function
11709 @code{GNAT.Current_Exception.Exception_Information} to obtain
11710 the exception information associated with the current exception.
11712 @node Exception_Message
11713 @section Exception_Message
11714 @cindex Exception_Message
11716 This intrinsic subprogram is used in the implementation of the
11717 library routine @code{GNAT.Current_Exception}. The only useful
11718 use of the intrinsic import in this case is the one in this unit,
11719 so an application program should simply call the function
11720 @code{GNAT.Current_Exception.Exception_Message} to obtain
11721 the message associated with the current exception.
11723 @node Exception_Name
11724 @section Exception_Name
11725 @cindex Exception_Name
11727 This intrinsic subprogram is used in the implementation of the
11728 library routine @code{GNAT.Current_Exception}. The only useful
11729 use of the intrinsic import in this case is the one in this unit,
11730 so an application program should simply call the function
11731 @code{GNAT.Current_Exception.Exception_Name} to obtain
11732 the name of the current exception.
11738 This intrinsic subprogram is used in the implementation of the
11739 library routine @code{GNAT.Source_Info}. The only useful use of the
11740 intrinsic import in this case is the one in this unit, so an
11741 application program should simply call the function
11742 @code{GNAT.Source_Info.File} to obtain the name of the current
11749 This intrinsic subprogram is used in the implementation of the
11750 library routine @code{GNAT.Source_Info}. The only useful use of the
11751 intrinsic import in this case is the one in this unit, so an
11752 application program should simply call the function
11753 @code{GNAT.Source_Info.Line} to obtain the number of the current
11756 @node Shifts and Rotates
11757 @section Shifts and Rotates
11759 @cindex Shift_Right
11760 @cindex Shift_Right_Arithmetic
11761 @cindex Rotate_Left
11762 @cindex Rotate_Right
11764 In standard Ada, the shift and rotate functions are available only
11765 for the predefined modular types in package @code{Interfaces}. However, in
11766 GNAT it is possible to define these functions for any integer
11767 type (signed or modular), as in this example:
11769 @smallexample @c ada
11770 function Shift_Left
11777 The function name must be one of
11778 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
11779 Rotate_Right. T must be an integer type. T'Size must be
11780 8, 16, 32 or 64 bits; if T is modular, the modulus
11781 must be 2**8, 2**16, 2**32 or 2**64.
11782 The result type must be the same as the type of @code{Value}.
11783 The shift amount must be Natural.
11784 The formal parameter names can be anything.
11786 @node Source_Location
11787 @section Source_Location
11788 @cindex Source_Location
11790 This intrinsic subprogram is used in the implementation of the
11791 library routine @code{GNAT.Source_Info}. The only useful use of the
11792 intrinsic import in this case is the one in this unit, so an
11793 application program should simply call the function
11794 @code{GNAT.Source_Info.Source_Location} to obtain the current
11795 source file location.
11797 @node Representation Clauses and Pragmas
11798 @chapter Representation Clauses and Pragmas
11799 @cindex Representation Clauses
11802 * Alignment Clauses::
11804 * Storage_Size Clauses::
11805 * Size of Variant Record Objects::
11806 * Biased Representation ::
11807 * Value_Size and Object_Size Clauses::
11808 * Component_Size Clauses::
11809 * Bit_Order Clauses::
11810 * Effect of Bit_Order on Byte Ordering::
11811 * Pragma Pack for Arrays::
11812 * Pragma Pack for Records::
11813 * Record Representation Clauses::
11814 * Enumeration Clauses::
11815 * Address Clauses::
11816 * Effect of Convention on Representation::
11817 * Determining the Representations chosen by GNAT::
11821 @cindex Representation Clause
11822 @cindex Representation Pragma
11823 @cindex Pragma, representation
11824 This section describes the representation clauses accepted by GNAT, and
11825 their effect on the representation of corresponding data objects.
11827 GNAT fully implements Annex C (Systems Programming). This means that all
11828 the implementation advice sections in chapter 13 are fully implemented.
11829 However, these sections only require a minimal level of support for
11830 representation clauses. GNAT provides much more extensive capabilities,
11831 and this section describes the additional capabilities provided.
11833 @node Alignment Clauses
11834 @section Alignment Clauses
11835 @cindex Alignment Clause
11838 GNAT requires that all alignment clauses specify a power of 2, and all
11839 default alignments are always a power of 2. The default alignment
11840 values are as follows:
11843 @item @emph{Primitive Types}.
11844 For primitive types, the alignment is the minimum of the actual size of
11845 objects of the type divided by @code{Storage_Unit},
11846 and the maximum alignment supported by the target.
11847 (This maximum alignment is given by the GNAT-specific attribute
11848 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
11849 @cindex @code{Maximum_Alignment} attribute
11850 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
11851 default alignment will be 8 on any target that supports alignments
11852 this large, but on some targets, the maximum alignment may be smaller
11853 than 8, in which case objects of type @code{Long_Float} will be maximally
11856 @item @emph{Arrays}.
11857 For arrays, the alignment is equal to the alignment of the component type
11858 for the normal case where no packing or component size is given. If the
11859 array is packed, and the packing is effective (see separate section on
11860 packed arrays), then the alignment will be one for long packed arrays,
11861 or arrays whose length is not known at compile time. For short packed
11862 arrays, which are handled internally as modular types, the alignment
11863 will be as described for primitive types, e.g.@: a packed array of length
11864 31 bits will have an object size of four bytes, and an alignment of 4.
11866 @item @emph{Records}.
11867 For the normal non-packed case, the alignment of a record is equal to
11868 the maximum alignment of any of its components. For tagged records, this
11869 includes the implicit access type used for the tag. If a pragma @code{Pack}
11870 is used and all components are packable (see separate section on pragma
11871 @code{Pack}), then the resulting alignment is 1, unless the layout of the
11872 record makes it profitable to increase it.
11874 A special case is when:
11877 the size of the record is given explicitly, or a
11878 full record representation clause is given, and
11880 the size of the record is 2, 4, or 8 bytes.
11883 In this case, an alignment is chosen to match the
11884 size of the record. For example, if we have:
11886 @smallexample @c ada
11887 type Small is record
11890 for Small'Size use 16;
11894 then the default alignment of the record type @code{Small} is 2, not 1. This
11895 leads to more efficient code when the record is treated as a unit, and also
11896 allows the type to specified as @code{Atomic} on architectures requiring
11902 An alignment clause may specify a larger alignment than the default value
11903 up to some maximum value dependent on the target (obtainable by using the
11904 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
11905 a smaller alignment than the default value for enumeration, integer and
11906 fixed point types, as well as for record types, for example
11908 @smallexample @c ada
11913 for V'alignment use 1;
11917 @cindex Alignment, default
11918 The default alignment for the type @code{V} is 4, as a result of the
11919 Integer field in the record, but it is permissible, as shown, to
11920 override the default alignment of the record with a smaller value.
11922 @cindex Alignment, subtypes
11923 Note that according to the Ada standard, an alignment clause applies only
11924 to the first named subtype. If additional subtypes are declared, then the
11925 compiler is allowed to choose any alignment it likes, and there is no way
11926 to control this choice. Consider:
11928 @smallexample @c ada
11929 type R is range 1 .. 10_000;
11930 for R'Alignment use 1;
11931 subtype RS is R range 1 .. 1000;
11935 The alignment clause specifies an alignment of 1 for the first named subtype
11936 @code{R} but this does not necessarily apply to @code{RS}. When writing
11937 portable Ada code, you should avoid writing code that explicitly or
11938 implicitly relies on the alignment of such subtypes.
11940 For the GNAT compiler, if an explicit alignment clause is given, this
11941 value is also used for any subsequent subtypes. So for GNAT, in the
11942 above example, you can count on the alignment of @code{RS} being 1. But this
11943 assumption is non-portable, and other compilers may choose different
11944 alignments for the subtype @code{RS}.
11947 @section Size Clauses
11948 @cindex Size Clause
11951 The default size for a type @code{T} is obtainable through the
11952 language-defined attribute @code{T'Size} and also through the
11953 equivalent GNAT-defined attribute @code{T'Value_Size}.
11954 For objects of type @code{T}, GNAT will generally increase the type size
11955 so that the object size (obtainable through the GNAT-defined attribute
11956 @code{T'Object_Size})
11957 is a multiple of @code{T'Alignment * Storage_Unit}.
11960 @smallexample @c ada
11961 type Smallint is range 1 .. 6;
11970 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
11971 as specified by the RM rules,
11972 but objects of this type will have a size of 8
11973 (@code{Smallint'Object_Size} = 8),
11974 since objects by default occupy an integral number
11975 of storage units. On some targets, notably older
11976 versions of the Digital Alpha, the size of stand
11977 alone objects of this type may be 32, reflecting
11978 the inability of the hardware to do byte load/stores.
11980 Similarly, the size of type @code{Rec} is 40 bits
11981 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
11982 the alignment is 4, so objects of this type will have
11983 their size increased to 64 bits so that it is a multiple
11984 of the alignment (in bits). This decision is
11985 in accordance with the specific Implementation Advice in RM 13.3(43):
11988 A @code{Size} clause should be supported for an object if the specified
11989 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
11990 to a size in storage elements that is a multiple of the object's
11991 @code{Alignment} (if the @code{Alignment} is nonzero).
11995 An explicit size clause may be used to override the default size by
11996 increasing it. For example, if we have:
11998 @smallexample @c ada
11999 type My_Boolean is new Boolean;
12000 for My_Boolean'Size use 32;
12004 then values of this type will always be 32 bits long. In the case of
12005 discrete types, the size can be increased up to 64 bits, with the effect
12006 that the entire specified field is used to hold the value, sign- or
12007 zero-extended as appropriate. If more than 64 bits is specified, then
12008 padding space is allocated after the value, and a warning is issued that
12009 there are unused bits.
12011 Similarly the size of records and arrays may be increased, and the effect
12012 is to add padding bits after the value. This also causes a warning message
12015 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
12016 Size in bits, this corresponds to an object of size 256 megabytes (minus
12017 one). This limitation is true on all targets. The reason for this
12018 limitation is that it improves the quality of the code in many cases
12019 if it is known that a Size value can be accommodated in an object of
12022 @node Storage_Size Clauses
12023 @section Storage_Size Clauses
12024 @cindex Storage_Size Clause
12027 For tasks, the @code{Storage_Size} clause specifies the amount of space
12028 to be allocated for the task stack. This cannot be extended, and if the
12029 stack is exhausted, then @code{Storage_Error} will be raised (if stack
12030 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
12031 or a @code{Storage_Size} pragma in the task definition to set the
12032 appropriate required size. A useful technique is to include in every
12033 task definition a pragma of the form:
12035 @smallexample @c ada
12036 pragma Storage_Size (Default_Stack_Size);
12040 Then @code{Default_Stack_Size} can be defined in a global package, and
12041 modified as required. Any tasks requiring stack sizes different from the
12042 default can have an appropriate alternative reference in the pragma.
12044 You can also use the @option{-d} binder switch to modify the default stack
12047 For access types, the @code{Storage_Size} clause specifies the maximum
12048 space available for allocation of objects of the type. If this space is
12049 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
12050 In the case where the access type is declared local to a subprogram, the
12051 use of a @code{Storage_Size} clause triggers automatic use of a special
12052 predefined storage pool (@code{System.Pool_Size}) that ensures that all
12053 space for the pool is automatically reclaimed on exit from the scope in
12054 which the type is declared.
12056 A special case recognized by the compiler is the specification of a
12057 @code{Storage_Size} of zero for an access type. This means that no
12058 items can be allocated from the pool, and this is recognized at compile
12059 time, and all the overhead normally associated with maintaining a fixed
12060 size storage pool is eliminated. Consider the following example:
12062 @smallexample @c ada
12064 type R is array (Natural) of Character;
12065 type P is access all R;
12066 for P'Storage_Size use 0;
12067 -- Above access type intended only for interfacing purposes
12071 procedure g (m : P);
12072 pragma Import (C, g);
12083 As indicated in this example, these dummy storage pools are often useful in
12084 connection with interfacing where no object will ever be allocated. If you
12085 compile the above example, you get the warning:
12088 p.adb:16:09: warning: allocation from empty storage pool
12089 p.adb:16:09: warning: Storage_Error will be raised at run time
12093 Of course in practice, there will not be any explicit allocators in the
12094 case of such an access declaration.
12096 @node Size of Variant Record Objects
12097 @section Size of Variant Record Objects
12098 @cindex Size, variant record objects
12099 @cindex Variant record objects, size
12102 In the case of variant record objects, there is a question whether Size gives
12103 information about a particular variant, or the maximum size required
12104 for any variant. Consider the following program
12106 @smallexample @c ada
12107 with Text_IO; use Text_IO;
12109 type R1 (A : Boolean := False) is record
12111 when True => X : Character;
12112 when False => null;
12120 Put_Line (Integer'Image (V1'Size));
12121 Put_Line (Integer'Image (V2'Size));
12126 Here we are dealing with a variant record, where the True variant
12127 requires 16 bits, and the False variant requires 8 bits.
12128 In the above example, both V1 and V2 contain the False variant,
12129 which is only 8 bits long. However, the result of running the
12138 The reason for the difference here is that the discriminant value of
12139 V1 is fixed, and will always be False. It is not possible to assign
12140 a True variant value to V1, therefore 8 bits is sufficient. On the
12141 other hand, in the case of V2, the initial discriminant value is
12142 False (from the default), but it is possible to assign a True
12143 variant value to V2, therefore 16 bits must be allocated for V2
12144 in the general case, even fewer bits may be needed at any particular
12145 point during the program execution.
12147 As can be seen from the output of this program, the @code{'Size}
12148 attribute applied to such an object in GNAT gives the actual allocated
12149 size of the variable, which is the largest size of any of the variants.
12150 The Ada Reference Manual is not completely clear on what choice should
12151 be made here, but the GNAT behavior seems most consistent with the
12152 language in the RM@.
12154 In some cases, it may be desirable to obtain the size of the current
12155 variant, rather than the size of the largest variant. This can be
12156 achieved in GNAT by making use of the fact that in the case of a
12157 subprogram parameter, GNAT does indeed return the size of the current
12158 variant (because a subprogram has no way of knowing how much space
12159 is actually allocated for the actual).
12161 Consider the following modified version of the above program:
12163 @smallexample @c ada
12164 with Text_IO; use Text_IO;
12166 type R1 (A : Boolean := False) is record
12168 when True => X : Character;
12169 when False => null;
12175 function Size (V : R1) return Integer is
12181 Put_Line (Integer'Image (V2'Size));
12182 Put_Line (Integer'IMage (Size (V2)));
12184 Put_Line (Integer'Image (V2'Size));
12185 Put_Line (Integer'IMage (Size (V2)));
12190 The output from this program is
12200 Here we see that while the @code{'Size} attribute always returns
12201 the maximum size, regardless of the current variant value, the
12202 @code{Size} function does indeed return the size of the current
12205 @node Biased Representation
12206 @section Biased Representation
12207 @cindex Size for biased representation
12208 @cindex Biased representation
12211 In the case of scalars with a range starting at other than zero, it is
12212 possible in some cases to specify a size smaller than the default minimum
12213 value, and in such cases, GNAT uses an unsigned biased representation,
12214 in which zero is used to represent the lower bound, and successive values
12215 represent successive values of the type.
12217 For example, suppose we have the declaration:
12219 @smallexample @c ada
12220 type Small is range -7 .. -4;
12221 for Small'Size use 2;
12225 Although the default size of type @code{Small} is 4, the @code{Size}
12226 clause is accepted by GNAT and results in the following representation
12230 -7 is represented as 2#00#
12231 -6 is represented as 2#01#
12232 -5 is represented as 2#10#
12233 -4 is represented as 2#11#
12237 Biased representation is only used if the specified @code{Size} clause
12238 cannot be accepted in any other manner. These reduced sizes that force
12239 biased representation can be used for all discrete types except for
12240 enumeration types for which a representation clause is given.
12242 @node Value_Size and Object_Size Clauses
12243 @section Value_Size and Object_Size Clauses
12245 @findex Object_Size
12246 @cindex Size, of objects
12249 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
12250 number of bits required to hold values of type @code{T}.
12251 Although this interpretation was allowed in Ada 83, it was not required,
12252 and this requirement in practice can cause some significant difficulties.
12253 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
12254 However, in Ada 95 and Ada 2005,
12255 @code{Natural'Size} is
12256 typically 31. This means that code may change in behavior when moving
12257 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
12259 @smallexample @c ada
12260 type Rec is record;
12266 at 0 range 0 .. Natural'Size - 1;
12267 at 0 range Natural'Size .. 2 * Natural'Size - 1;
12272 In the above code, since the typical size of @code{Natural} objects
12273 is 32 bits and @code{Natural'Size} is 31, the above code can cause
12274 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
12275 there are cases where the fact that the object size can exceed the
12276 size of the type causes surprises.
12278 To help get around this problem GNAT provides two implementation
12279 defined attributes, @code{Value_Size} and @code{Object_Size}. When
12280 applied to a type, these attributes yield the size of the type
12281 (corresponding to the RM defined size attribute), and the size of
12282 objects of the type respectively.
12284 The @code{Object_Size} is used for determining the default size of
12285 objects and components. This size value can be referred to using the
12286 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
12287 the basis of the determination of the size. The backend is free to
12288 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
12289 character might be stored in 32 bits on a machine with no efficient
12290 byte access instructions such as the Alpha.
12292 The default rules for the value of @code{Object_Size} for
12293 discrete types are as follows:
12297 The @code{Object_Size} for base subtypes reflect the natural hardware
12298 size in bits (run the compiler with @option{-gnatS} to find those values
12299 for numeric types). Enumeration types and fixed-point base subtypes have
12300 8, 16, 32 or 64 bits for this size, depending on the range of values
12304 The @code{Object_Size} of a subtype is the same as the
12305 @code{Object_Size} of
12306 the type from which it is obtained.
12309 The @code{Object_Size} of a derived base type is copied from the parent
12310 base type, and the @code{Object_Size} of a derived first subtype is copied
12311 from the parent first subtype.
12315 The @code{Value_Size} attribute
12316 is the (minimum) number of bits required to store a value
12318 This value is used to determine how tightly to pack
12319 records or arrays with components of this type, and also affects
12320 the semantics of unchecked conversion (unchecked conversions where
12321 the @code{Value_Size} values differ generate a warning, and are potentially
12324 The default rules for the value of @code{Value_Size} are as follows:
12328 The @code{Value_Size} for a base subtype is the minimum number of bits
12329 required to store all values of the type (including the sign bit
12330 only if negative values are possible).
12333 If a subtype statically matches the first subtype of a given type, then it has
12334 by default the same @code{Value_Size} as the first subtype. This is a
12335 consequence of RM 13.1(14) (``if two subtypes statically match,
12336 then their subtype-specific aspects are the same''.)
12339 All other subtypes have a @code{Value_Size} corresponding to the minimum
12340 number of bits required to store all values of the subtype. For
12341 dynamic bounds, it is assumed that the value can range down or up
12342 to the corresponding bound of the ancestor
12346 The RM defined attribute @code{Size} corresponds to the
12347 @code{Value_Size} attribute.
12349 The @code{Size} attribute may be defined for a first-named subtype. This sets
12350 the @code{Value_Size} of
12351 the first-named subtype to the given value, and the
12352 @code{Object_Size} of this first-named subtype to the given value padded up
12353 to an appropriate boundary. It is a consequence of the default rules
12354 above that this @code{Object_Size} will apply to all further subtypes. On the
12355 other hand, @code{Value_Size} is affected only for the first subtype, any
12356 dynamic subtypes obtained from it directly, and any statically matching
12357 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
12359 @code{Value_Size} and
12360 @code{Object_Size} may be explicitly set for any subtype using
12361 an attribute definition clause. Note that the use of these attributes
12362 can cause the RM 13.1(14) rule to be violated. If two access types
12363 reference aliased objects whose subtypes have differing @code{Object_Size}
12364 values as a result of explicit attribute definition clauses, then it
12365 is erroneous to convert from one access subtype to the other.
12367 At the implementation level, Esize stores the Object_Size and the
12368 RM_Size field stores the @code{Value_Size} (and hence the value of the
12369 @code{Size} attribute,
12370 which, as noted above, is equivalent to @code{Value_Size}).
12372 To get a feel for the difference, consider the following examples (note
12373 that in each case the base is @code{Short_Short_Integer} with a size of 8):
12376 Object_Size Value_Size
12378 type x1 is range 0 .. 5; 8 3
12380 type x2 is range 0 .. 5;
12381 for x2'size use 12; 16 12
12383 subtype x3 is x2 range 0 .. 3; 16 2
12385 subtype x4 is x2'base range 0 .. 10; 8 4
12387 subtype x5 is x2 range 0 .. dynamic; 16 3*
12389 subtype x6 is x2'base range 0 .. dynamic; 8 3*
12394 Note: the entries marked ``3*'' are not actually specified by the Ada
12395 Reference Manual, but it seems in the spirit of the RM rules to allocate
12396 the minimum number of bits (here 3, given the range for @code{x2})
12397 known to be large enough to hold the given range of values.
12399 So far, so good, but GNAT has to obey the RM rules, so the question is
12400 under what conditions must the RM @code{Size} be used.
12401 The following is a list
12402 of the occasions on which the RM @code{Size} must be used:
12406 Component size for packed arrays or records
12409 Value of the attribute @code{Size} for a type
12412 Warning about sizes not matching for unchecked conversion
12416 For record types, the @code{Object_Size} is always a multiple of the
12417 alignment of the type (this is true for all types). In some cases the
12418 @code{Value_Size} can be smaller. Consider:
12428 On a typical 32-bit architecture, the X component will be four bytes, and
12429 require four-byte alignment, and the Y component will be one byte. In this
12430 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
12431 required to store a value of this type, and for example, it is permissible
12432 to have a component of type R in an outer array whose component size is
12433 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
12434 since it must be rounded up so that this value is a multiple of the
12435 alignment (4 bytes = 32 bits).
12438 For all other types, the @code{Object_Size}
12439 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
12440 Only @code{Size} may be specified for such types.
12442 @node Component_Size Clauses
12443 @section Component_Size Clauses
12444 @cindex Component_Size Clause
12447 Normally, the value specified in a component size clause must be consistent
12448 with the subtype of the array component with regard to size and alignment.
12449 In other words, the value specified must be at least equal to the size
12450 of this subtype, and must be a multiple of the alignment value.
12452 In addition, component size clauses are allowed which cause the array
12453 to be packed, by specifying a smaller value. A first case is for
12454 component size values in the range 1 through 63. The value specified
12455 must not be smaller than the Size of the subtype. GNAT will accurately
12456 honor all packing requests in this range. For example, if we have:
12458 @smallexample @c ada
12459 type r is array (1 .. 8) of Natural;
12460 for r'Component_Size use 31;
12464 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
12465 Of course access to the components of such an array is considerably
12466 less efficient than if the natural component size of 32 is used.
12467 A second case is when the subtype of the component is a record type
12468 padded because of its default alignment. For example, if we have:
12470 @smallexample @c ada
12477 type a is array (1 .. 8) of r;
12478 for a'Component_Size use 72;
12482 then the resulting array has a length of 72 bytes, instead of 96 bytes
12483 if the alignment of the record (4) was obeyed.
12485 Note that there is no point in giving both a component size clause
12486 and a pragma Pack for the same array type. if such duplicate
12487 clauses are given, the pragma Pack will be ignored.
12489 @node Bit_Order Clauses
12490 @section Bit_Order Clauses
12491 @cindex Bit_Order Clause
12492 @cindex bit ordering
12493 @cindex ordering, of bits
12496 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
12497 attribute. The specification may either correspond to the default bit
12498 order for the target, in which case the specification has no effect and
12499 places no additional restrictions, or it may be for the non-standard
12500 setting (that is the opposite of the default).
12502 In the case where the non-standard value is specified, the effect is
12503 to renumber bits within each byte, but the ordering of bytes is not
12504 affected. There are certain
12505 restrictions placed on component clauses as follows:
12509 @item Components fitting within a single storage unit.
12511 These are unrestricted, and the effect is merely to renumber bits. For
12512 example if we are on a little-endian machine with @code{Low_Order_First}
12513 being the default, then the following two declarations have exactly
12516 @smallexample @c ada
12519 B : Integer range 1 .. 120;
12523 A at 0 range 0 .. 0;
12524 B at 0 range 1 .. 7;
12529 B : Integer range 1 .. 120;
12532 for R2'Bit_Order use High_Order_First;
12535 A at 0 range 7 .. 7;
12536 B at 0 range 0 .. 6;
12541 The useful application here is to write the second declaration with the
12542 @code{Bit_Order} attribute definition clause, and know that it will be treated
12543 the same, regardless of whether the target is little-endian or big-endian.
12545 @item Components occupying an integral number of bytes.
12547 These are components that exactly fit in two or more bytes. Such component
12548 declarations are allowed, but have no effect, since it is important to realize
12549 that the @code{Bit_Order} specification does not affect the ordering of bytes.
12550 In particular, the following attempt at getting an endian-independent integer
12553 @smallexample @c ada
12558 for R2'Bit_Order use High_Order_First;
12561 A at 0 range 0 .. 31;
12566 This declaration will result in a little-endian integer on a
12567 little-endian machine, and a big-endian integer on a big-endian machine.
12568 If byte flipping is required for interoperability between big- and
12569 little-endian machines, this must be explicitly programmed. This capability
12570 is not provided by @code{Bit_Order}.
12572 @item Components that are positioned across byte boundaries
12574 but do not occupy an integral number of bytes. Given that bytes are not
12575 reordered, such fields would occupy a non-contiguous sequence of bits
12576 in memory, requiring non-trivial code to reassemble. They are for this
12577 reason not permitted, and any component clause specifying such a layout
12578 will be flagged as illegal by GNAT@.
12583 Since the misconception that Bit_Order automatically deals with all
12584 endian-related incompatibilities is a common one, the specification of
12585 a component field that is an integral number of bytes will always
12586 generate a warning. This warning may be suppressed using @code{pragma
12587 Warnings (Off)} if desired. The following section contains additional
12588 details regarding the issue of byte ordering.
12590 @node Effect of Bit_Order on Byte Ordering
12591 @section Effect of Bit_Order on Byte Ordering
12592 @cindex byte ordering
12593 @cindex ordering, of bytes
12596 In this section we will review the effect of the @code{Bit_Order} attribute
12597 definition clause on byte ordering. Briefly, it has no effect at all, but
12598 a detailed example will be helpful. Before giving this
12599 example, let us review the precise
12600 definition of the effect of defining @code{Bit_Order}. The effect of a
12601 non-standard bit order is described in section 15.5.3 of the Ada
12605 2 A bit ordering is a method of interpreting the meaning of
12606 the storage place attributes.
12610 To understand the precise definition of storage place attributes in
12611 this context, we visit section 13.5.1 of the manual:
12614 13 A record_representation_clause (without the mod_clause)
12615 specifies the layout. The storage place attributes (see 13.5.2)
12616 are taken from the values of the position, first_bit, and last_bit
12617 expressions after normalizing those values so that first_bit is
12618 less than Storage_Unit.
12622 The critical point here is that storage places are taken from
12623 the values after normalization, not before. So the @code{Bit_Order}
12624 interpretation applies to normalized values. The interpretation
12625 is described in the later part of the 15.5.3 paragraph:
12628 2 A bit ordering is a method of interpreting the meaning of
12629 the storage place attributes. High_Order_First (known in the
12630 vernacular as ``big endian'') means that the first bit of a
12631 storage element (bit 0) is the most significant bit (interpreting
12632 the sequence of bits that represent a component as an unsigned
12633 integer value). Low_Order_First (known in the vernacular as
12634 ``little endian'') means the opposite: the first bit is the
12639 Note that the numbering is with respect to the bits of a storage
12640 unit. In other words, the specification affects only the numbering
12641 of bits within a single storage unit.
12643 We can make the effect clearer by giving an example.
12645 Suppose that we have an external device which presents two bytes, the first
12646 byte presented, which is the first (low addressed byte) of the two byte
12647 record is called Master, and the second byte is called Slave.
12649 The left most (most significant bit is called Control for each byte, and
12650 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
12651 (least significant) bit.
12653 On a big-endian machine, we can write the following representation clause
12655 @smallexample @c ada
12656 type Data is record
12657 Master_Control : Bit;
12665 Slave_Control : Bit;
12675 for Data use record
12676 Master_Control at 0 range 0 .. 0;
12677 Master_V1 at 0 range 1 .. 1;
12678 Master_V2 at 0 range 2 .. 2;
12679 Master_V3 at 0 range 3 .. 3;
12680 Master_V4 at 0 range 4 .. 4;
12681 Master_V5 at 0 range 5 .. 5;
12682 Master_V6 at 0 range 6 .. 6;
12683 Master_V7 at 0 range 7 .. 7;
12684 Slave_Control at 1 range 0 .. 0;
12685 Slave_V1 at 1 range 1 .. 1;
12686 Slave_V2 at 1 range 2 .. 2;
12687 Slave_V3 at 1 range 3 .. 3;
12688 Slave_V4 at 1 range 4 .. 4;
12689 Slave_V5 at 1 range 5 .. 5;
12690 Slave_V6 at 1 range 6 .. 6;
12691 Slave_V7 at 1 range 7 .. 7;
12696 Now if we move this to a little endian machine, then the bit ordering within
12697 the byte is backwards, so we have to rewrite the record rep clause as:
12699 @smallexample @c ada
12700 for Data use record
12701 Master_Control at 0 range 7 .. 7;
12702 Master_V1 at 0 range 6 .. 6;
12703 Master_V2 at 0 range 5 .. 5;
12704 Master_V3 at 0 range 4 .. 4;
12705 Master_V4 at 0 range 3 .. 3;
12706 Master_V5 at 0 range 2 .. 2;
12707 Master_V6 at 0 range 1 .. 1;
12708 Master_V7 at 0 range 0 .. 0;
12709 Slave_Control at 1 range 7 .. 7;
12710 Slave_V1 at 1 range 6 .. 6;
12711 Slave_V2 at 1 range 5 .. 5;
12712 Slave_V3 at 1 range 4 .. 4;
12713 Slave_V4 at 1 range 3 .. 3;
12714 Slave_V5 at 1 range 2 .. 2;
12715 Slave_V6 at 1 range 1 .. 1;
12716 Slave_V7 at 1 range 0 .. 0;
12721 It is a nuisance to have to rewrite the clause, especially if
12722 the code has to be maintained on both machines. However,
12723 this is a case that we can handle with the
12724 @code{Bit_Order} attribute if it is implemented.
12725 Note that the implementation is not required on byte addressed
12726 machines, but it is indeed implemented in GNAT.
12727 This means that we can simply use the
12728 first record clause, together with the declaration
12730 @smallexample @c ada
12731 for Data'Bit_Order use High_Order_First;
12735 and the effect is what is desired, namely the layout is exactly the same,
12736 independent of whether the code is compiled on a big-endian or little-endian
12739 The important point to understand is that byte ordering is not affected.
12740 A @code{Bit_Order} attribute definition never affects which byte a field
12741 ends up in, only where it ends up in that byte.
12742 To make this clear, let us rewrite the record rep clause of the previous
12745 @smallexample @c ada
12746 for Data'Bit_Order use High_Order_First;
12747 for Data use record
12748 Master_Control at 0 range 0 .. 0;
12749 Master_V1 at 0 range 1 .. 1;
12750 Master_V2 at 0 range 2 .. 2;
12751 Master_V3 at 0 range 3 .. 3;
12752 Master_V4 at 0 range 4 .. 4;
12753 Master_V5 at 0 range 5 .. 5;
12754 Master_V6 at 0 range 6 .. 6;
12755 Master_V7 at 0 range 7 .. 7;
12756 Slave_Control at 0 range 8 .. 8;
12757 Slave_V1 at 0 range 9 .. 9;
12758 Slave_V2 at 0 range 10 .. 10;
12759 Slave_V3 at 0 range 11 .. 11;
12760 Slave_V4 at 0 range 12 .. 12;
12761 Slave_V5 at 0 range 13 .. 13;
12762 Slave_V6 at 0 range 14 .. 14;
12763 Slave_V7 at 0 range 15 .. 15;
12768 This is exactly equivalent to saying (a repeat of the first example):
12770 @smallexample @c ada
12771 for Data'Bit_Order use High_Order_First;
12772 for Data use record
12773 Master_Control at 0 range 0 .. 0;
12774 Master_V1 at 0 range 1 .. 1;
12775 Master_V2 at 0 range 2 .. 2;
12776 Master_V3 at 0 range 3 .. 3;
12777 Master_V4 at 0 range 4 .. 4;
12778 Master_V5 at 0 range 5 .. 5;
12779 Master_V6 at 0 range 6 .. 6;
12780 Master_V7 at 0 range 7 .. 7;
12781 Slave_Control at 1 range 0 .. 0;
12782 Slave_V1 at 1 range 1 .. 1;
12783 Slave_V2 at 1 range 2 .. 2;
12784 Slave_V3 at 1 range 3 .. 3;
12785 Slave_V4 at 1 range 4 .. 4;
12786 Slave_V5 at 1 range 5 .. 5;
12787 Slave_V6 at 1 range 6 .. 6;
12788 Slave_V7 at 1 range 7 .. 7;
12793 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
12794 field. The storage place attributes are obtained by normalizing the
12795 values given so that the @code{First_Bit} value is less than 8. After
12796 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
12797 we specified in the other case.
12799 Now one might expect that the @code{Bit_Order} attribute might affect
12800 bit numbering within the entire record component (two bytes in this
12801 case, thus affecting which byte fields end up in), but that is not
12802 the way this feature is defined, it only affects numbering of bits,
12803 not which byte they end up in.
12805 Consequently it never makes sense to specify a starting bit number
12806 greater than 7 (for a byte addressable field) if an attribute
12807 definition for @code{Bit_Order} has been given, and indeed it
12808 may be actively confusing to specify such a value, so the compiler
12809 generates a warning for such usage.
12811 If you do need to control byte ordering then appropriate conditional
12812 values must be used. If in our example, the slave byte came first on
12813 some machines we might write:
12815 @smallexample @c ada
12816 Master_Byte_First constant Boolean := @dots{};
12818 Master_Byte : constant Natural :=
12819 1 - Boolean'Pos (Master_Byte_First);
12820 Slave_Byte : constant Natural :=
12821 Boolean'Pos (Master_Byte_First);
12823 for Data'Bit_Order use High_Order_First;
12824 for Data use record
12825 Master_Control at Master_Byte range 0 .. 0;
12826 Master_V1 at Master_Byte range 1 .. 1;
12827 Master_V2 at Master_Byte range 2 .. 2;
12828 Master_V3 at Master_Byte range 3 .. 3;
12829 Master_V4 at Master_Byte range 4 .. 4;
12830 Master_V5 at Master_Byte range 5 .. 5;
12831 Master_V6 at Master_Byte range 6 .. 6;
12832 Master_V7 at Master_Byte range 7 .. 7;
12833 Slave_Control at Slave_Byte range 0 .. 0;
12834 Slave_V1 at Slave_Byte range 1 .. 1;
12835 Slave_V2 at Slave_Byte range 2 .. 2;
12836 Slave_V3 at Slave_Byte range 3 .. 3;
12837 Slave_V4 at Slave_Byte range 4 .. 4;
12838 Slave_V5 at Slave_Byte range 5 .. 5;
12839 Slave_V6 at Slave_Byte range 6 .. 6;
12840 Slave_V7 at Slave_Byte range 7 .. 7;
12845 Now to switch between machines, all that is necessary is
12846 to set the boolean constant @code{Master_Byte_First} in
12847 an appropriate manner.
12849 @node Pragma Pack for Arrays
12850 @section Pragma Pack for Arrays
12851 @cindex Pragma Pack (for arrays)
12854 Pragma @code{Pack} applied to an array has no effect unless the component type
12855 is packable. For a component type to be packable, it must be one of the
12862 Any type whose size is specified with a size clause
12864 Any packed array type with a static size
12866 Any record type padded because of its default alignment
12870 For all these cases, if the component subtype size is in the range
12871 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
12872 component size were specified giving the component subtype size.
12873 For example if we have:
12875 @smallexample @c ada
12876 type r is range 0 .. 17;
12878 type ar is array (1 .. 8) of r;
12883 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
12884 and the size of the array @code{ar} will be exactly 40 bits.
12886 Note that in some cases this rather fierce approach to packing can produce
12887 unexpected effects. For example, in Ada 95 and Ada 2005,
12888 subtype @code{Natural} typically has a size of 31, meaning that if you
12889 pack an array of @code{Natural}, you get 31-bit
12890 close packing, which saves a few bits, but results in far less efficient
12891 access. Since many other Ada compilers will ignore such a packing request,
12892 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
12893 might not be what is intended. You can easily remove this warning by
12894 using an explicit @code{Component_Size} setting instead, which never generates
12895 a warning, since the intention of the programmer is clear in this case.
12897 GNAT treats packed arrays in one of two ways. If the size of the array is
12898 known at compile time and is less than 64 bits, then internally the array
12899 is represented as a single modular type, of exactly the appropriate number
12900 of bits. If the length is greater than 63 bits, or is not known at compile
12901 time, then the packed array is represented as an array of bytes, and the
12902 length is always a multiple of 8 bits.
12904 Note that to represent a packed array as a modular type, the alignment must
12905 be suitable for the modular type involved. For example, on typical machines
12906 a 32-bit packed array will be represented by a 32-bit modular integer with
12907 an alignment of four bytes. If you explicitly override the default alignment
12908 with an alignment clause that is too small, the modular representation
12909 cannot be used. For example, consider the following set of declarations:
12911 @smallexample @c ada
12912 type R is range 1 .. 3;
12913 type S is array (1 .. 31) of R;
12914 for S'Component_Size use 2;
12916 for S'Alignment use 1;
12920 If the alignment clause were not present, then a 62-bit modular
12921 representation would be chosen (typically with an alignment of 4 or 8
12922 bytes depending on the target). But the default alignment is overridden
12923 with the explicit alignment clause. This means that the modular
12924 representation cannot be used, and instead the array of bytes
12925 representation must be used, meaning that the length must be a multiple
12926 of 8. Thus the above set of declarations will result in a diagnostic
12927 rejecting the size clause and noting that the minimum size allowed is 64.
12929 @cindex Pragma Pack (for type Natural)
12930 @cindex Pragma Pack warning
12932 One special case that is worth noting occurs when the base type of the
12933 component size is 8/16/32 and the subtype is one bit less. Notably this
12934 occurs with subtype @code{Natural}. Consider:
12936 @smallexample @c ada
12937 type Arr is array (1 .. 32) of Natural;
12942 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
12943 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
12944 Ada 83 compilers did not attempt 31 bit packing.
12946 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
12947 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
12948 substantial unintended performance penalty when porting legacy Ada 83 code.
12949 To help prevent this, GNAT generates a warning in such cases. If you really
12950 want 31 bit packing in a case like this, you can set the component size
12953 @smallexample @c ada
12954 type Arr is array (1 .. 32) of Natural;
12955 for Arr'Component_Size use 31;
12959 Here 31-bit packing is achieved as required, and no warning is generated,
12960 since in this case the programmer intention is clear.
12962 @node Pragma Pack for Records
12963 @section Pragma Pack for Records
12964 @cindex Pragma Pack (for records)
12967 Pragma @code{Pack} applied to a record will pack the components to reduce
12968 wasted space from alignment gaps and by reducing the amount of space
12969 taken by components. We distinguish between @emph{packable} components and
12970 @emph{non-packable} components.
12971 Components of the following types are considered packable:
12974 All primitive types are packable.
12977 Small packed arrays, whose size does not exceed 64 bits, and where the
12978 size is statically known at compile time, are represented internally
12979 as modular integers, and so they are also packable.
12984 All packable components occupy the exact number of bits corresponding to
12985 their @code{Size} value, and are packed with no padding bits, i.e.@: they
12986 can start on an arbitrary bit boundary.
12988 All other types are non-packable, they occupy an integral number of
12990 are placed at a boundary corresponding to their alignment requirements.
12992 For example, consider the record
12994 @smallexample @c ada
12995 type Rb1 is array (1 .. 13) of Boolean;
12998 type Rb2 is array (1 .. 65) of Boolean;
13013 The representation for the record x2 is as follows:
13015 @smallexample @c ada
13016 for x2'Size use 224;
13018 l1 at 0 range 0 .. 0;
13019 l2 at 0 range 1 .. 64;
13020 l3 at 12 range 0 .. 31;
13021 l4 at 16 range 0 .. 0;
13022 l5 at 16 range 1 .. 13;
13023 l6 at 18 range 0 .. 71;
13028 Studying this example, we see that the packable fields @code{l1}
13030 of length equal to their sizes, and placed at specific bit boundaries (and
13031 not byte boundaries) to
13032 eliminate padding. But @code{l3} is of a non-packable float type, so
13033 it is on the next appropriate alignment boundary.
13035 The next two fields are fully packable, so @code{l4} and @code{l5} are
13036 minimally packed with no gaps. However, type @code{Rb2} is a packed
13037 array that is longer than 64 bits, so it is itself non-packable. Thus
13038 the @code{l6} field is aligned to the next byte boundary, and takes an
13039 integral number of bytes, i.e.@: 72 bits.
13041 @node Record Representation Clauses
13042 @section Record Representation Clauses
13043 @cindex Record Representation Clause
13046 Record representation clauses may be given for all record types, including
13047 types obtained by record extension. Component clauses are allowed for any
13048 static component. The restrictions on component clauses depend on the type
13051 @cindex Component Clause
13052 For all components of an elementary type, the only restriction on component
13053 clauses is that the size must be at least the 'Size value of the type
13054 (actually the Value_Size). There are no restrictions due to alignment,
13055 and such components may freely cross storage boundaries.
13057 Packed arrays with a size up to and including 64 bits are represented
13058 internally using a modular type with the appropriate number of bits, and
13059 thus the same lack of restriction applies. For example, if you declare:
13061 @smallexample @c ada
13062 type R is array (1 .. 49) of Boolean;
13068 then a component clause for a component of type R may start on any
13069 specified bit boundary, and may specify a value of 49 bits or greater.
13071 For packed bit arrays that are longer than 64 bits, there are two
13072 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
13073 including the important case of single bits or boolean values, then
13074 there are no limitations on placement of such components, and they
13075 may start and end at arbitrary bit boundaries.
13077 If the component size is not a power of 2 (e.g.@: 3 or 5), then
13078 an array of this type longer than 64 bits must always be placed on
13079 on a storage unit (byte) boundary and occupy an integral number
13080 of storage units (bytes). Any component clause that does not
13081 meet this requirement will be rejected.
13083 Any aliased component, or component of an aliased type, must
13084 have its normal alignment and size. A component clause that
13085 does not meet this requirement will be rejected.
13087 The tag field of a tagged type always occupies an address sized field at
13088 the start of the record. No component clause may attempt to overlay this
13089 tag. When a tagged type appears as a component, the tag field must have
13092 In the case of a record extension T1, of a type T, no component clause applied
13093 to the type T1 can specify a storage location that would overlap the first
13094 T'Size bytes of the record.
13096 For all other component types, including non-bit-packed arrays,
13097 the component can be placed at an arbitrary bit boundary,
13098 so for example, the following is permitted:
13100 @smallexample @c ada
13101 type R is array (1 .. 10) of Boolean;
13110 G at 0 range 0 .. 0;
13111 H at 0 range 1 .. 1;
13112 L at 0 range 2 .. 81;
13113 R at 0 range 82 .. 161;
13118 Note: the above rules apply to recent releases of GNAT 5.
13119 In GNAT 3, there are more severe restrictions on larger components.
13120 For non-primitive types, including packed arrays with a size greater than
13121 64 bits, component clauses must respect the alignment requirement of the
13122 type, in particular, always starting on a byte boundary, and the length
13123 must be a multiple of the storage unit.
13125 @node Enumeration Clauses
13126 @section Enumeration Clauses
13128 The only restriction on enumeration clauses is that the range of values
13129 must be representable. For the signed case, if one or more of the
13130 representation values are negative, all values must be in the range:
13132 @smallexample @c ada
13133 System.Min_Int .. System.Max_Int
13137 For the unsigned case, where all values are nonnegative, the values must
13140 @smallexample @c ada
13141 0 .. System.Max_Binary_Modulus;
13145 A @emph{confirming} representation clause is one in which the values range
13146 from 0 in sequence, i.e.@: a clause that confirms the default representation
13147 for an enumeration type.
13148 Such a confirming representation
13149 is permitted by these rules, and is specially recognized by the compiler so
13150 that no extra overhead results from the use of such a clause.
13152 If an array has an index type which is an enumeration type to which an
13153 enumeration clause has been applied, then the array is stored in a compact
13154 manner. Consider the declarations:
13156 @smallexample @c ada
13157 type r is (A, B, C);
13158 for r use (A => 1, B => 5, C => 10);
13159 type t is array (r) of Character;
13163 The array type t corresponds to a vector with exactly three elements and
13164 has a default size equal to @code{3*Character'Size}. This ensures efficient
13165 use of space, but means that accesses to elements of the array will incur
13166 the overhead of converting representation values to the corresponding
13167 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
13169 @node Address Clauses
13170 @section Address Clauses
13171 @cindex Address Clause
13173 The reference manual allows a general restriction on representation clauses,
13174 as found in RM 13.1(22):
13177 An implementation need not support representation
13178 items containing nonstatic expressions, except that
13179 an implementation should support a representation item
13180 for a given entity if each nonstatic expression in the
13181 representation item is a name that statically denotes
13182 a constant declared before the entity.
13186 In practice this is applicable only to address clauses, since this is the
13187 only case in which a non-static expression is permitted by the syntax. As
13188 the AARM notes in sections 13.1 (22.a-22.h):
13191 22.a Reason: This is to avoid the following sort of thing:
13193 22.b X : Integer := F(@dots{});
13194 Y : Address := G(@dots{});
13195 for X'Address use Y;
13197 22.c In the above, we have to evaluate the
13198 initialization expression for X before we
13199 know where to put the result. This seems
13200 like an unreasonable implementation burden.
13202 22.d The above code should instead be written
13205 22.e Y : constant Address := G(@dots{});
13206 X : Integer := F(@dots{});
13207 for X'Address use Y;
13209 22.f This allows the expression ``Y'' to be safely
13210 evaluated before X is created.
13212 22.g The constant could be a formal parameter of mode in.
13214 22.h An implementation can support other nonstatic
13215 expressions if it wants to. Expressions of type
13216 Address are hardly ever static, but their value
13217 might be known at compile time anyway in many
13222 GNAT does indeed permit many additional cases of non-static expressions. In
13223 particular, if the type involved is elementary there are no restrictions
13224 (since in this case, holding a temporary copy of the initialization value,
13225 if one is present, is inexpensive). In addition, if there is no implicit or
13226 explicit initialization, then there are no restrictions. GNAT will reject
13227 only the case where all three of these conditions hold:
13232 The type of the item is non-elementary (e.g.@: a record or array).
13235 There is explicit or implicit initialization required for the object.
13236 Note that access values are always implicitly initialized.
13239 The address value is non-static. Here GNAT is more permissive than the
13240 RM, and allows the address value to be the address of a previously declared
13241 stand-alone variable, as long as it does not itself have an address clause.
13243 @smallexample @c ada
13244 Anchor : Some_Initialized_Type;
13245 Overlay : Some_Initialized_Type;
13246 for Overlay'Address use Anchor'Address;
13250 However, the prefix of the address clause cannot be an array component, or
13251 a component of a discriminated record.
13256 As noted above in section 22.h, address values are typically non-static. In
13257 particular the To_Address function, even if applied to a literal value, is
13258 a non-static function call. To avoid this minor annoyance, GNAT provides
13259 the implementation defined attribute 'To_Address. The following two
13260 expressions have identical values:
13264 @smallexample @c ada
13265 To_Address (16#1234_0000#)
13266 System'To_Address (16#1234_0000#);
13270 except that the second form is considered to be a static expression, and
13271 thus when used as an address clause value is always permitted.
13274 Additionally, GNAT treats as static an address clause that is an
13275 unchecked_conversion of a static integer value. This simplifies the porting
13276 of legacy code, and provides a portable equivalent to the GNAT attribute
13279 Another issue with address clauses is the interaction with alignment
13280 requirements. When an address clause is given for an object, the address
13281 value must be consistent with the alignment of the object (which is usually
13282 the same as the alignment of the type of the object). If an address clause
13283 is given that specifies an inappropriately aligned address value, then the
13284 program execution is erroneous.
13286 Since this source of erroneous behavior can have unfortunate effects, GNAT
13287 checks (at compile time if possible, generating a warning, or at execution
13288 time with a run-time check) that the alignment is appropriate. If the
13289 run-time check fails, then @code{Program_Error} is raised. This run-time
13290 check is suppressed if range checks are suppressed, or if the special GNAT
13291 check Alignment_Check is suppressed, or if
13292 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
13294 Finally, GNAT does not permit overlaying of objects of controlled types or
13295 composite types containing a controlled component. In most cases, the compiler
13296 can detect an attempt at such overlays and will generate a warning at compile
13297 time and a Program_Error exception at run time.
13300 An address clause cannot be given for an exported object. More
13301 understandably the real restriction is that objects with an address
13302 clause cannot be exported. This is because such variables are not
13303 defined by the Ada program, so there is no external object to export.
13306 It is permissible to give an address clause and a pragma Import for the
13307 same object. In this case, the variable is not really defined by the
13308 Ada program, so there is no external symbol to be linked. The link name
13309 and the external name are ignored in this case. The reason that we allow this
13310 combination is that it provides a useful idiom to avoid unwanted
13311 initializations on objects with address clauses.
13313 When an address clause is given for an object that has implicit or
13314 explicit initialization, then by default initialization takes place. This
13315 means that the effect of the object declaration is to overwrite the
13316 memory at the specified address. This is almost always not what the
13317 programmer wants, so GNAT will output a warning:
13327 for Ext'Address use System'To_Address (16#1234_1234#);
13329 >>> warning: implicit initialization of "Ext" may
13330 modify overlaid storage
13331 >>> warning: use pragma Import for "Ext" to suppress
13332 initialization (RM B(24))
13338 As indicated by the warning message, the solution is to use a (dummy) pragma
13339 Import to suppress this initialization. The pragma tell the compiler that the
13340 object is declared and initialized elsewhere. The following package compiles
13341 without warnings (and the initialization is suppressed):
13343 @smallexample @c ada
13351 for Ext'Address use System'To_Address (16#1234_1234#);
13352 pragma Import (Ada, Ext);
13357 A final issue with address clauses involves their use for overlaying
13358 variables, as in the following example:
13359 @cindex Overlaying of objects
13361 @smallexample @c ada
13364 for B'Address use A'Address;
13368 or alternatively, using the form recommended by the RM:
13370 @smallexample @c ada
13372 Addr : constant Address := A'Address;
13374 for B'Address use Addr;
13378 In both of these cases, @code{A}
13379 and @code{B} become aliased to one another via the
13380 address clause. This use of address clauses to overlay
13381 variables, achieving an effect similar to unchecked
13382 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
13383 the effect is implementation defined. Furthermore, the
13384 Ada RM specifically recommends that in a situation
13385 like this, @code{B} should be subject to the following
13386 implementation advice (RM 13.3(19)):
13389 19 If the Address of an object is specified, or it is imported
13390 or exported, then the implementation should not perform
13391 optimizations based on assumptions of no aliases.
13395 GNAT follows this recommendation, and goes further by also applying
13396 this recommendation to the overlaid variable (@code{A}
13397 in the above example) in this case. This means that the overlay
13398 works "as expected", in that a modification to one of the variables
13399 will affect the value of the other.
13401 @node Effect of Convention on Representation
13402 @section Effect of Convention on Representation
13403 @cindex Convention, effect on representation
13406 Normally the specification of a foreign language convention for a type or
13407 an object has no effect on the chosen representation. In particular, the
13408 representation chosen for data in GNAT generally meets the standard system
13409 conventions, and for example records are laid out in a manner that is
13410 consistent with C@. This means that specifying convention C (for example)
13413 There are four exceptions to this general rule:
13417 @item Convention Fortran and array subtypes
13418 If pragma Convention Fortran is specified for an array subtype, then in
13419 accordance with the implementation advice in section 3.6.2(11) of the
13420 Ada Reference Manual, the array will be stored in a Fortran-compatible
13421 column-major manner, instead of the normal default row-major order.
13423 @item Convention C and enumeration types
13424 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
13425 to accommodate all values of the type. For example, for the enumeration
13428 @smallexample @c ada
13429 type Color is (Red, Green, Blue);
13433 8 bits is sufficient to store all values of the type, so by default, objects
13434 of type @code{Color} will be represented using 8 bits. However, normal C
13435 convention is to use 32 bits for all enum values in C, since enum values
13436 are essentially of type int. If pragma @code{Convention C} is specified for an
13437 Ada enumeration type, then the size is modified as necessary (usually to
13438 32 bits) to be consistent with the C convention for enum values.
13440 Note that this treatment applies only to types. If Convention C is given for
13441 an enumeration object, where the enumeration type is not Convention C, then
13442 Object_Size bits are allocated. For example, for a normal enumeration type,
13443 with less than 256 elements, only 8 bits will be allocated for the object.
13444 Since this may be a surprise in terms of what C expects, GNAT will issue a
13445 warning in this situation. The warning can be suppressed by giving an explicit
13446 size clause specifying the desired size.
13448 @item Convention C/Fortran and Boolean types
13449 In C, the usual convention for boolean values, that is values used for
13450 conditions, is that zero represents false, and nonzero values represent
13451 true. In Ada, the normal convention is that two specific values, typically
13452 0/1, are used to represent false/true respectively.
13454 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
13455 value represents true).
13457 To accommodate the Fortran and C conventions, if a pragma Convention specifies
13458 C or Fortran convention for a derived Boolean, as in the following example:
13460 @smallexample @c ada
13461 type C_Switch is new Boolean;
13462 pragma Convention (C, C_Switch);
13466 then the GNAT generated code will treat any nonzero value as true. For truth
13467 values generated by GNAT, the conventional value 1 will be used for True, but
13468 when one of these values is read, any nonzero value is treated as True.
13470 @item Access types on OpenVMS
13471 For 64-bit OpenVMS systems, access types (other than those for unconstrained
13472 arrays) are 64-bits long. An exception to this rule is for the case of
13473 C-convention access types where there is no explicit size clause present (or
13474 inherited for derived types). In this case, GNAT chooses to make these
13475 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
13476 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
13480 @node Determining the Representations chosen by GNAT
13481 @section Determining the Representations chosen by GNAT
13482 @cindex Representation, determination of
13483 @cindex @option{-gnatR} switch
13486 Although the descriptions in this section are intended to be complete, it is
13487 often easier to simply experiment to see what GNAT accepts and what the
13488 effect is on the layout of types and objects.
13490 As required by the Ada RM, if a representation clause is not accepted, then
13491 it must be rejected as illegal by the compiler. However, when a
13492 representation clause or pragma is accepted, there can still be questions
13493 of what the compiler actually does. For example, if a partial record
13494 representation clause specifies the location of some components and not
13495 others, then where are the non-specified components placed? Or if pragma
13496 @code{Pack} is used on a record, then exactly where are the resulting
13497 fields placed? The section on pragma @code{Pack} in this chapter can be
13498 used to answer the second question, but it is often easier to just see
13499 what the compiler does.
13501 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
13502 with this option, then the compiler will output information on the actual
13503 representations chosen, in a format similar to source representation
13504 clauses. For example, if we compile the package:
13506 @smallexample @c ada
13508 type r (x : boolean) is tagged record
13510 when True => S : String (1 .. 100);
13511 when False => null;
13515 type r2 is new r (false) with record
13520 y2 at 16 range 0 .. 31;
13527 type x1 is array (1 .. 10) of x;
13528 for x1'component_size use 11;
13530 type ia is access integer;
13532 type Rb1 is array (1 .. 13) of Boolean;
13535 type Rb2 is array (1 .. 65) of Boolean;
13551 using the switch @option{-gnatR} we obtain the following output:
13554 Representation information for unit q
13555 -------------------------------------
13558 for r'Alignment use 4;
13560 x at 4 range 0 .. 7;
13561 _tag at 0 range 0 .. 31;
13562 s at 5 range 0 .. 799;
13565 for r2'Size use 160;
13566 for r2'Alignment use 4;
13568 x at 4 range 0 .. 7;
13569 _tag at 0 range 0 .. 31;
13570 _parent at 0 range 0 .. 63;
13571 y2 at 16 range 0 .. 31;
13575 for x'Alignment use 1;
13577 y at 0 range 0 .. 7;
13580 for x1'Size use 112;
13581 for x1'Alignment use 1;
13582 for x1'Component_Size use 11;
13584 for rb1'Size use 13;
13585 for rb1'Alignment use 2;
13586 for rb1'Component_Size use 1;
13588 for rb2'Size use 72;
13589 for rb2'Alignment use 1;
13590 for rb2'Component_Size use 1;
13592 for x2'Size use 224;
13593 for x2'Alignment use 4;
13595 l1 at 0 range 0 .. 0;
13596 l2 at 0 range 1 .. 64;
13597 l3 at 12 range 0 .. 31;
13598 l4 at 16 range 0 .. 0;
13599 l5 at 16 range 1 .. 13;
13600 l6 at 18 range 0 .. 71;
13605 The Size values are actually the Object_Size, i.e.@: the default size that
13606 will be allocated for objects of the type.
13607 The ?? size for type r indicates that we have a variant record, and the
13608 actual size of objects will depend on the discriminant value.
13610 The Alignment values show the actual alignment chosen by the compiler
13611 for each record or array type.
13613 The record representation clause for type r shows where all fields
13614 are placed, including the compiler generated tag field (whose location
13615 cannot be controlled by the programmer).
13617 The record representation clause for the type extension r2 shows all the
13618 fields present, including the parent field, which is a copy of the fields
13619 of the parent type of r2, i.e.@: r1.
13621 The component size and size clauses for types rb1 and rb2 show
13622 the exact effect of pragma @code{Pack} on these arrays, and the record
13623 representation clause for type x2 shows how pragma @code{Pack} affects
13626 In some cases, it may be useful to cut and paste the representation clauses
13627 generated by the compiler into the original source to fix and guarantee
13628 the actual representation to be used.
13630 @node Standard Library Routines
13631 @chapter Standard Library Routines
13634 The Ada Reference Manual contains in Annex A a full description of an
13635 extensive set of standard library routines that can be used in any Ada
13636 program, and which must be provided by all Ada compilers. They are
13637 analogous to the standard C library used by C programs.
13639 GNAT implements all of the facilities described in annex A, and for most
13640 purposes the description in the Ada Reference Manual, or appropriate Ada
13641 text book, will be sufficient for making use of these facilities.
13643 In the case of the input-output facilities,
13644 @xref{The Implementation of Standard I/O},
13645 gives details on exactly how GNAT interfaces to the
13646 file system. For the remaining packages, the Ada Reference Manual
13647 should be sufficient. The following is a list of the packages included,
13648 together with a brief description of the functionality that is provided.
13650 For completeness, references are included to other predefined library
13651 routines defined in other sections of the Ada Reference Manual (these are
13652 cross-indexed from Annex A).
13656 This is a parent package for all the standard library packages. It is
13657 usually included implicitly in your program, and itself contains no
13658 useful data or routines.
13660 @item Ada.Calendar (9.6)
13661 @code{Calendar} provides time of day access, and routines for
13662 manipulating times and durations.
13664 @item Ada.Characters (A.3.1)
13665 This is a dummy parent package that contains no useful entities
13667 @item Ada.Characters.Handling (A.3.2)
13668 This package provides some basic character handling capabilities,
13669 including classification functions for classes of characters (e.g.@: test
13670 for letters, or digits).
13672 @item Ada.Characters.Latin_1 (A.3.3)
13673 This package includes a complete set of definitions of the characters
13674 that appear in type CHARACTER@. It is useful for writing programs that
13675 will run in international environments. For example, if you want an
13676 upper case E with an acute accent in a string, it is often better to use
13677 the definition of @code{UC_E_Acute} in this package. Then your program
13678 will print in an understandable manner even if your environment does not
13679 support these extended characters.
13681 @item Ada.Command_Line (A.15)
13682 This package provides access to the command line parameters and the name
13683 of the current program (analogous to the use of @code{argc} and @code{argv}
13684 in C), and also allows the exit status for the program to be set in a
13685 system-independent manner.
13687 @item Ada.Decimal (F.2)
13688 This package provides constants describing the range of decimal numbers
13689 implemented, and also a decimal divide routine (analogous to the COBOL
13690 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
13692 @item Ada.Direct_IO (A.8.4)
13693 This package provides input-output using a model of a set of records of
13694 fixed-length, containing an arbitrary definite Ada type, indexed by an
13695 integer record number.
13697 @item Ada.Dynamic_Priorities (D.5)
13698 This package allows the priorities of a task to be adjusted dynamically
13699 as the task is running.
13701 @item Ada.Exceptions (11.4.1)
13702 This package provides additional information on exceptions, and also
13703 contains facilities for treating exceptions as data objects, and raising
13704 exceptions with associated messages.
13706 @item Ada.Finalization (7.6)
13707 This package contains the declarations and subprograms to support the
13708 use of controlled types, providing for automatic initialization and
13709 finalization (analogous to the constructors and destructors of C++)
13711 @item Ada.Interrupts (C.3.2)
13712 This package provides facilities for interfacing to interrupts, which
13713 includes the set of signals or conditions that can be raised and
13714 recognized as interrupts.
13716 @item Ada.Interrupts.Names (C.3.2)
13717 This package provides the set of interrupt names (actually signal
13718 or condition names) that can be handled by GNAT@.
13720 @item Ada.IO_Exceptions (A.13)
13721 This package defines the set of exceptions that can be raised by use of
13722 the standard IO packages.
13725 This package contains some standard constants and exceptions used
13726 throughout the numerics packages. Note that the constants pi and e are
13727 defined here, and it is better to use these definitions than rolling
13730 @item Ada.Numerics.Complex_Elementary_Functions
13731 Provides the implementation of standard elementary functions (such as
13732 log and trigonometric functions) operating on complex numbers using the
13733 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
13734 created by the package @code{Numerics.Complex_Types}.
13736 @item Ada.Numerics.Complex_Types
13737 This is a predefined instantiation of
13738 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
13739 build the type @code{Complex} and @code{Imaginary}.
13741 @item Ada.Numerics.Discrete_Random
13742 This generic package provides a random number generator suitable for generating
13743 uniformly distributed values of a specified discrete subtype.
13745 @item Ada.Numerics.Float_Random
13746 This package provides a random number generator suitable for generating
13747 uniformly distributed floating point values in the unit interval.
13749 @item Ada.Numerics.Generic_Complex_Elementary_Functions
13750 This is a generic version of the package that provides the
13751 implementation of standard elementary functions (such as log and
13752 trigonometric functions) for an arbitrary complex type.
13754 The following predefined instantiations of this package are provided:
13758 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
13760 @code{Ada.Numerics.Complex_Elementary_Functions}
13762 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
13765 @item Ada.Numerics.Generic_Complex_Types
13766 This is a generic package that allows the creation of complex types,
13767 with associated complex arithmetic operations.
13769 The following predefined instantiations of this package exist
13772 @code{Ada.Numerics.Short_Complex_Complex_Types}
13774 @code{Ada.Numerics.Complex_Complex_Types}
13776 @code{Ada.Numerics.Long_Complex_Complex_Types}
13779 @item Ada.Numerics.Generic_Elementary_Functions
13780 This is a generic package that provides the implementation of standard
13781 elementary functions (such as log an trigonometric functions) for an
13782 arbitrary float type.
13784 The following predefined instantiations of this package exist
13788 @code{Ada.Numerics.Short_Elementary_Functions}
13790 @code{Ada.Numerics.Elementary_Functions}
13792 @code{Ada.Numerics.Long_Elementary_Functions}
13795 @item Ada.Real_Time (D.8)
13796 This package provides facilities similar to those of @code{Calendar}, but
13797 operating with a finer clock suitable for real time control. Note that
13798 annex D requires that there be no backward clock jumps, and GNAT generally
13799 guarantees this behavior, but of course if the external clock on which
13800 the GNAT runtime depends is deliberately reset by some external event,
13801 then such a backward jump may occur.
13803 @item Ada.Sequential_IO (A.8.1)
13804 This package provides input-output facilities for sequential files,
13805 which can contain a sequence of values of a single type, which can be
13806 any Ada type, including indefinite (unconstrained) types.
13808 @item Ada.Storage_IO (A.9)
13809 This package provides a facility for mapping arbitrary Ada types to and
13810 from a storage buffer. It is primarily intended for the creation of new
13813 @item Ada.Streams (13.13.1)
13814 This is a generic package that provides the basic support for the
13815 concept of streams as used by the stream attributes (@code{Input},
13816 @code{Output}, @code{Read} and @code{Write}).
13818 @item Ada.Streams.Stream_IO (A.12.1)
13819 This package is a specialization of the type @code{Streams} defined in
13820 package @code{Streams} together with a set of operations providing
13821 Stream_IO capability. The Stream_IO model permits both random and
13822 sequential access to a file which can contain an arbitrary set of values
13823 of one or more Ada types.
13825 @item Ada.Strings (A.4.1)
13826 This package provides some basic constants used by the string handling
13829 @item Ada.Strings.Bounded (A.4.4)
13830 This package provides facilities for handling variable length
13831 strings. The bounded model requires a maximum length. It is thus
13832 somewhat more limited than the unbounded model, but avoids the use of
13833 dynamic allocation or finalization.
13835 @item Ada.Strings.Fixed (A.4.3)
13836 This package provides facilities for handling fixed length strings.
13838 @item Ada.Strings.Maps (A.4.2)
13839 This package provides facilities for handling character mappings and
13840 arbitrarily defined subsets of characters. For instance it is useful in
13841 defining specialized translation tables.
13843 @item Ada.Strings.Maps.Constants (A.4.6)
13844 This package provides a standard set of predefined mappings and
13845 predefined character sets. For example, the standard upper to lower case
13846 conversion table is found in this package. Note that upper to lower case
13847 conversion is non-trivial if you want to take the entire set of
13848 characters, including extended characters like E with an acute accent,
13849 into account. You should use the mappings in this package (rather than
13850 adding 32 yourself) to do case mappings.
13852 @item Ada.Strings.Unbounded (A.4.5)
13853 This package provides facilities for handling variable length
13854 strings. The unbounded model allows arbitrary length strings, but
13855 requires the use of dynamic allocation and finalization.
13857 @item Ada.Strings.Wide_Bounded (A.4.7)
13858 @itemx Ada.Strings.Wide_Fixed (A.4.7)
13859 @itemx Ada.Strings.Wide_Maps (A.4.7)
13860 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
13861 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
13862 These packages provide analogous capabilities to the corresponding
13863 packages without @samp{Wide_} in the name, but operate with the types
13864 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
13865 and @code{Character}.
13867 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
13868 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
13869 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
13870 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
13871 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
13872 These packages provide analogous capabilities to the corresponding
13873 packages without @samp{Wide_} in the name, but operate with the types
13874 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
13875 of @code{String} and @code{Character}.
13877 @item Ada.Synchronous_Task_Control (D.10)
13878 This package provides some standard facilities for controlling task
13879 communication in a synchronous manner.
13882 This package contains definitions for manipulation of the tags of tagged
13885 @item Ada.Task_Attributes
13886 This package provides the capability of associating arbitrary
13887 task-specific data with separate tasks.
13890 This package provides basic text input-output capabilities for
13891 character, string and numeric data. The subpackages of this
13892 package are listed next.
13894 @item Ada.Text_IO.Decimal_IO
13895 Provides input-output facilities for decimal fixed-point types
13897 @item Ada.Text_IO.Enumeration_IO
13898 Provides input-output facilities for enumeration types.
13900 @item Ada.Text_IO.Fixed_IO
13901 Provides input-output facilities for ordinary fixed-point types.
13903 @item Ada.Text_IO.Float_IO
13904 Provides input-output facilities for float types. The following
13905 predefined instantiations of this generic package are available:
13909 @code{Short_Float_Text_IO}
13911 @code{Float_Text_IO}
13913 @code{Long_Float_Text_IO}
13916 @item Ada.Text_IO.Integer_IO
13917 Provides input-output facilities for integer types. The following
13918 predefined instantiations of this generic package are available:
13921 @item Short_Short_Integer
13922 @code{Ada.Short_Short_Integer_Text_IO}
13923 @item Short_Integer
13924 @code{Ada.Short_Integer_Text_IO}
13926 @code{Ada.Integer_Text_IO}
13928 @code{Ada.Long_Integer_Text_IO}
13929 @item Long_Long_Integer
13930 @code{Ada.Long_Long_Integer_Text_IO}
13933 @item Ada.Text_IO.Modular_IO
13934 Provides input-output facilities for modular (unsigned) types
13936 @item Ada.Text_IO.Complex_IO (G.1.3)
13937 This package provides basic text input-output capabilities for complex
13940 @item Ada.Text_IO.Editing (F.3.3)
13941 This package contains routines for edited output, analogous to the use
13942 of pictures in COBOL@. The picture formats used by this package are a
13943 close copy of the facility in COBOL@.
13945 @item Ada.Text_IO.Text_Streams (A.12.2)
13946 This package provides a facility that allows Text_IO files to be treated
13947 as streams, so that the stream attributes can be used for writing
13948 arbitrary data, including binary data, to Text_IO files.
13950 @item Ada.Unchecked_Conversion (13.9)
13951 This generic package allows arbitrary conversion from one type to
13952 another of the same size, providing for breaking the type safety in
13953 special circumstances.
13955 If the types have the same Size (more accurately the same Value_Size),
13956 then the effect is simply to transfer the bits from the source to the
13957 target type without any modification. This usage is well defined, and
13958 for simple types whose representation is typically the same across
13959 all implementations, gives a portable method of performing such
13962 If the types do not have the same size, then the result is implementation
13963 defined, and thus may be non-portable. The following describes how GNAT
13964 handles such unchecked conversion cases.
13966 If the types are of different sizes, and are both discrete types, then
13967 the effect is of a normal type conversion without any constraint checking.
13968 In particular if the result type has a larger size, the result will be
13969 zero or sign extended. If the result type has a smaller size, the result
13970 will be truncated by ignoring high order bits.
13972 If the types are of different sizes, and are not both discrete types,
13973 then the conversion works as though pointers were created to the source
13974 and target, and the pointer value is converted. The effect is that bits
13975 are copied from successive low order storage units and bits of the source
13976 up to the length of the target type.
13978 A warning is issued if the lengths differ, since the effect in this
13979 case is implementation dependent, and the above behavior may not match
13980 that of some other compiler.
13982 A pointer to one type may be converted to a pointer to another type using
13983 unchecked conversion. The only case in which the effect is undefined is
13984 when one or both pointers are pointers to unconstrained array types. In
13985 this case, the bounds information may get incorrectly transferred, and in
13986 particular, GNAT uses double size pointers for such types, and it is
13987 meaningless to convert between such pointer types. GNAT will issue a
13988 warning if the alignment of the target designated type is more strict
13989 than the alignment of the source designated type (since the result may
13990 be unaligned in this case).
13992 A pointer other than a pointer to an unconstrained array type may be
13993 converted to and from System.Address. Such usage is common in Ada 83
13994 programs, but note that Ada.Address_To_Access_Conversions is the
13995 preferred method of performing such conversions in Ada 95 and Ada 2005.
13997 unchecked conversion nor Ada.Address_To_Access_Conversions should be
13998 used in conjunction with pointers to unconstrained objects, since
13999 the bounds information cannot be handled correctly in this case.
14001 @item Ada.Unchecked_Deallocation (13.11.2)
14002 This generic package allows explicit freeing of storage previously
14003 allocated by use of an allocator.
14005 @item Ada.Wide_Text_IO (A.11)
14006 This package is similar to @code{Ada.Text_IO}, except that the external
14007 file supports wide character representations, and the internal types are
14008 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
14009 and @code{String}. It contains generic subpackages listed next.
14011 @item Ada.Wide_Text_IO.Decimal_IO
14012 Provides input-output facilities for decimal fixed-point types
14014 @item Ada.Wide_Text_IO.Enumeration_IO
14015 Provides input-output facilities for enumeration types.
14017 @item Ada.Wide_Text_IO.Fixed_IO
14018 Provides input-output facilities for ordinary fixed-point types.
14020 @item Ada.Wide_Text_IO.Float_IO
14021 Provides input-output facilities for float types. The following
14022 predefined instantiations of this generic package are available:
14026 @code{Short_Float_Wide_Text_IO}
14028 @code{Float_Wide_Text_IO}
14030 @code{Long_Float_Wide_Text_IO}
14033 @item Ada.Wide_Text_IO.Integer_IO
14034 Provides input-output facilities for integer types. The following
14035 predefined instantiations of this generic package are available:
14038 @item Short_Short_Integer
14039 @code{Ada.Short_Short_Integer_Wide_Text_IO}
14040 @item Short_Integer
14041 @code{Ada.Short_Integer_Wide_Text_IO}
14043 @code{Ada.Integer_Wide_Text_IO}
14045 @code{Ada.Long_Integer_Wide_Text_IO}
14046 @item Long_Long_Integer
14047 @code{Ada.Long_Long_Integer_Wide_Text_IO}
14050 @item Ada.Wide_Text_IO.Modular_IO
14051 Provides input-output facilities for modular (unsigned) types
14053 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
14054 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
14055 external file supports wide character representations.
14057 @item Ada.Wide_Text_IO.Editing (F.3.4)
14058 This package is similar to @code{Ada.Text_IO.Editing}, except that the
14059 types are @code{Wide_Character} and @code{Wide_String} instead of
14060 @code{Character} and @code{String}.
14062 @item Ada.Wide_Text_IO.Streams (A.12.3)
14063 This package is similar to @code{Ada.Text_IO.Streams}, except that the
14064 types are @code{Wide_Character} and @code{Wide_String} instead of
14065 @code{Character} and @code{String}.
14067 @item Ada.Wide_Wide_Text_IO (A.11)
14068 This package is similar to @code{Ada.Text_IO}, except that the external
14069 file supports wide character representations, and the internal types are
14070 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
14071 and @code{String}. It contains generic subpackages listed next.
14073 @item Ada.Wide_Wide_Text_IO.Decimal_IO
14074 Provides input-output facilities for decimal fixed-point types
14076 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
14077 Provides input-output facilities for enumeration types.
14079 @item Ada.Wide_Wide_Text_IO.Fixed_IO
14080 Provides input-output facilities for ordinary fixed-point types.
14082 @item Ada.Wide_Wide_Text_IO.Float_IO
14083 Provides input-output facilities for float types. The following
14084 predefined instantiations of this generic package are available:
14088 @code{Short_Float_Wide_Wide_Text_IO}
14090 @code{Float_Wide_Wide_Text_IO}
14092 @code{Long_Float_Wide_Wide_Text_IO}
14095 @item Ada.Wide_Wide_Text_IO.Integer_IO
14096 Provides input-output facilities for integer types. The following
14097 predefined instantiations of this generic package are available:
14100 @item Short_Short_Integer
14101 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
14102 @item Short_Integer
14103 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
14105 @code{Ada.Integer_Wide_Wide_Text_IO}
14107 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
14108 @item Long_Long_Integer
14109 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
14112 @item Ada.Wide_Wide_Text_IO.Modular_IO
14113 Provides input-output facilities for modular (unsigned) types
14115 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
14116 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
14117 external file supports wide character representations.
14119 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
14120 This package is similar to @code{Ada.Text_IO.Editing}, except that the
14121 types are @code{Wide_Character} and @code{Wide_String} instead of
14122 @code{Character} and @code{String}.
14124 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
14125 This package is similar to @code{Ada.Text_IO.Streams}, except that the
14126 types are @code{Wide_Character} and @code{Wide_String} instead of
14127 @code{Character} and @code{String}.
14130 @node The Implementation of Standard I/O
14131 @chapter The Implementation of Standard I/O
14134 GNAT implements all the required input-output facilities described in
14135 A.6 through A.14. These sections of the Ada Reference Manual describe the
14136 required behavior of these packages from the Ada point of view, and if
14137 you are writing a portable Ada program that does not need to know the
14138 exact manner in which Ada maps to the outside world when it comes to
14139 reading or writing external files, then you do not need to read this
14140 chapter. As long as your files are all regular files (not pipes or
14141 devices), and as long as you write and read the files only from Ada, the
14142 description in the Ada Reference Manual is sufficient.
14144 However, if you want to do input-output to pipes or other devices, such
14145 as the keyboard or screen, or if the files you are dealing with are
14146 either generated by some other language, or to be read by some other
14147 language, then you need to know more about the details of how the GNAT
14148 implementation of these input-output facilities behaves.
14150 In this chapter we give a detailed description of exactly how GNAT
14151 interfaces to the file system. As always, the sources of the system are
14152 available to you for answering questions at an even more detailed level,
14153 but for most purposes the information in this chapter will suffice.
14155 Another reason that you may need to know more about how input-output is
14156 implemented arises when you have a program written in mixed languages
14157 where, for example, files are shared between the C and Ada sections of
14158 the same program. GNAT provides some additional facilities, in the form
14159 of additional child library packages, that facilitate this sharing, and
14160 these additional facilities are also described in this chapter.
14163 * Standard I/O Packages::
14169 * Wide_Wide_Text_IO::
14171 * Text Translation::
14173 * Filenames encoding::
14175 * Operations on C Streams::
14176 * Interfacing to C Streams::
14179 @node Standard I/O Packages
14180 @section Standard I/O Packages
14183 The Standard I/O packages described in Annex A for
14189 Ada.Text_IO.Complex_IO
14191 Ada.Text_IO.Text_Streams
14195 Ada.Wide_Text_IO.Complex_IO
14197 Ada.Wide_Text_IO.Text_Streams
14199 Ada.Wide_Wide_Text_IO
14201 Ada.Wide_Wide_Text_IO.Complex_IO
14203 Ada.Wide_Wide_Text_IO.Text_Streams
14213 are implemented using the C
14214 library streams facility; where
14218 All files are opened using @code{fopen}.
14220 All input/output operations use @code{fread}/@code{fwrite}.
14224 There is no internal buffering of any kind at the Ada library level. The only
14225 buffering is that provided at the system level in the implementation of the
14226 library routines that support streams. This facilitates shared use of these
14227 streams by mixed language programs. Note though that system level buffering is
14228 explicitly enabled at elaboration of the standard I/O packages and that can
14229 have an impact on mixed language programs, in particular those using I/O before
14230 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
14231 the Ada elaboration routine before performing any I/O or when impractical,
14232 flush the common I/O streams and in particular Standard_Output before
14233 elaborating the Ada code.
14236 @section FORM Strings
14239 The format of a FORM string in GNAT is:
14242 "keyword=value,keyword=value,@dots{},keyword=value"
14246 where letters may be in upper or lower case, and there are no spaces
14247 between values. The order of the entries is not important. Currently
14248 the following keywords defined.
14251 TEXT_TRANSLATION=[YES|NO]
14253 WCEM=[n|h|u|s|e|8|b]
14254 ENCODING=[UTF8|8BITS]
14258 The use of these parameters is described later in this section. If an
14259 unrecognized keyword appears in a form string, it is silently ignored
14260 and not considered invalid.
14266 Direct_IO can only be instantiated for definite types. This is a
14267 restriction of the Ada language, which means that the records are fixed
14268 length (the length being determined by @code{@var{type}'Size}, rounded
14269 up to the next storage unit boundary if necessary).
14271 The records of a Direct_IO file are simply written to the file in index
14272 sequence, with the first record starting at offset zero, and subsequent
14273 records following. There is no control information of any kind. For
14274 example, if 32-bit integers are being written, each record takes
14275 4-bytes, so the record at index @var{K} starts at offset
14276 (@var{K}@minus{}1)*4.
14278 There is no limit on the size of Direct_IO files, they are expanded as
14279 necessary to accommodate whatever records are written to the file.
14281 @node Sequential_IO
14282 @section Sequential_IO
14285 Sequential_IO may be instantiated with either a definite (constrained)
14286 or indefinite (unconstrained) type.
14288 For the definite type case, the elements written to the file are simply
14289 the memory images of the data values with no control information of any
14290 kind. The resulting file should be read using the same type, no validity
14291 checking is performed on input.
14293 For the indefinite type case, the elements written consist of two
14294 parts. First is the size of the data item, written as the memory image
14295 of a @code{Interfaces.C.size_t} value, followed by the memory image of
14296 the data value. The resulting file can only be read using the same
14297 (unconstrained) type. Normal assignment checks are performed on these
14298 read operations, and if these checks fail, @code{Data_Error} is
14299 raised. In particular, in the array case, the lengths must match, and in
14300 the variant record case, if the variable for a particular read operation
14301 is constrained, the discriminants must match.
14303 Note that it is not possible to use Sequential_IO to write variable
14304 length array items, and then read the data back into different length
14305 arrays. For example, the following will raise @code{Data_Error}:
14307 @smallexample @c ada
14308 package IO is new Sequential_IO (String);
14313 IO.Write (F, "hello!")
14314 IO.Reset (F, Mode=>In_File);
14321 On some Ada implementations, this will print @code{hell}, but the program is
14322 clearly incorrect, since there is only one element in the file, and that
14323 element is the string @code{hello!}.
14325 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
14326 using Stream_IO, and this is the preferred mechanism. In particular, the
14327 above program fragment rewritten to use Stream_IO will work correctly.
14333 Text_IO files consist of a stream of characters containing the following
14334 special control characters:
14337 LF (line feed, 16#0A#) Line Mark
14338 FF (form feed, 16#0C#) Page Mark
14342 A canonical Text_IO file is defined as one in which the following
14343 conditions are met:
14347 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
14351 The character @code{FF} is used only as a page mark, i.e.@: to mark the
14352 end of a page and consequently can appear only immediately following a
14353 @code{LF} (line mark) character.
14356 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
14357 (line mark, page mark). In the former case, the page mark is implicitly
14358 assumed to be present.
14362 A file written using Text_IO will be in canonical form provided that no
14363 explicit @code{LF} or @code{FF} characters are written using @code{Put}
14364 or @code{Put_Line}. There will be no @code{FF} character at the end of
14365 the file unless an explicit @code{New_Page} operation was performed
14366 before closing the file.
14368 A canonical Text_IO file that is a regular file (i.e., not a device or a
14369 pipe) can be read using any of the routines in Text_IO@. The
14370 semantics in this case will be exactly as defined in the Ada Reference
14371 Manual, and all the routines in Text_IO are fully implemented.
14373 A text file that does not meet the requirements for a canonical Text_IO
14374 file has one of the following:
14378 The file contains @code{FF} characters not immediately following a
14379 @code{LF} character.
14382 The file contains @code{LF} or @code{FF} characters written by
14383 @code{Put} or @code{Put_Line}, which are not logically considered to be
14384 line marks or page marks.
14387 The file ends in a character other than @code{LF} or @code{FF},
14388 i.e.@: there is no explicit line mark or page mark at the end of the file.
14392 Text_IO can be used to read such non-standard text files but subprograms
14393 to do with line or page numbers do not have defined meanings. In
14394 particular, a @code{FF} character that does not follow a @code{LF}
14395 character may or may not be treated as a page mark from the point of
14396 view of page and line numbering. Every @code{LF} character is considered
14397 to end a line, and there is an implied @code{LF} character at the end of
14401 * Text_IO Stream Pointer Positioning::
14402 * Text_IO Reading and Writing Non-Regular Files::
14404 * Treating Text_IO Files as Streams::
14405 * Text_IO Extensions::
14406 * Text_IO Facilities for Unbounded Strings::
14409 @node Text_IO Stream Pointer Positioning
14410 @subsection Stream Pointer Positioning
14413 @code{Ada.Text_IO} has a definition of current position for a file that
14414 is being read. No internal buffering occurs in Text_IO, and usually the
14415 physical position in the stream used to implement the file corresponds
14416 to this logical position defined by Text_IO@. There are two exceptions:
14420 After a call to @code{End_Of_Page} that returns @code{True}, the stream
14421 is positioned past the @code{LF} (line mark) that precedes the page
14422 mark. Text_IO maintains an internal flag so that subsequent read
14423 operations properly handle the logical position which is unchanged by
14424 the @code{End_Of_Page} call.
14427 After a call to @code{End_Of_File} that returns @code{True}, if the
14428 Text_IO file was positioned before the line mark at the end of file
14429 before the call, then the logical position is unchanged, but the stream
14430 is physically positioned right at the end of file (past the line mark,
14431 and past a possible page mark following the line mark. Again Text_IO
14432 maintains internal flags so that subsequent read operations properly
14433 handle the logical position.
14437 These discrepancies have no effect on the observable behavior of
14438 Text_IO, but if a single Ada stream is shared between a C program and
14439 Ada program, or shared (using @samp{shared=yes} in the form string)
14440 between two Ada files, then the difference may be observable in some
14443 @node Text_IO Reading and Writing Non-Regular Files
14444 @subsection Reading and Writing Non-Regular Files
14447 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
14448 can be used for reading and writing. Writing is not affected and the
14449 sequence of characters output is identical to the normal file case, but
14450 for reading, the behavior of Text_IO is modified to avoid undesirable
14451 look-ahead as follows:
14453 An input file that is not a regular file is considered to have no page
14454 marks. Any @code{Ascii.FF} characters (the character normally used for a
14455 page mark) appearing in the file are considered to be data
14456 characters. In particular:
14460 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
14461 following a line mark. If a page mark appears, it will be treated as a
14465 This avoids the need to wait for an extra character to be typed or
14466 entered from the pipe to complete one of these operations.
14469 @code{End_Of_Page} always returns @code{False}
14472 @code{End_Of_File} will return @code{False} if there is a page mark at
14473 the end of the file.
14477 Output to non-regular files is the same as for regular files. Page marks
14478 may be written to non-regular files using @code{New_Page}, but as noted
14479 above they will not be treated as page marks on input if the output is
14480 piped to another Ada program.
14482 Another important discrepancy when reading non-regular files is that the end
14483 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
14484 pressing the @key{EOT} key,
14486 is signaled once (i.e.@: the test @code{End_Of_File}
14487 will yield @code{True}, or a read will
14488 raise @code{End_Error}), but then reading can resume
14489 to read data past that end of
14490 file indication, until another end of file indication is entered.
14492 @node Get_Immediate
14493 @subsection Get_Immediate
14494 @cindex Get_Immediate
14497 Get_Immediate returns the next character (including control characters)
14498 from the input file. In particular, Get_Immediate will return LF or FF
14499 characters used as line marks or page marks. Such operations leave the
14500 file positioned past the control character, and it is thus not treated
14501 as having its normal function. This means that page, line and column
14502 counts after this kind of Get_Immediate call are set as though the mark
14503 did not occur. In the case where a Get_Immediate leaves the file
14504 positioned between the line mark and page mark (which is not normally
14505 possible), it is undefined whether the FF character will be treated as a
14508 @node Treating Text_IO Files as Streams
14509 @subsection Treating Text_IO Files as Streams
14510 @cindex Stream files
14513 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
14514 as a stream. Data written to a Text_IO file in this stream mode is
14515 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
14516 16#0C# (@code{FF}), the resulting file may have non-standard
14517 format. Similarly if read operations are used to read from a Text_IO
14518 file treated as a stream, then @code{LF} and @code{FF} characters may be
14519 skipped and the effect is similar to that described above for
14520 @code{Get_Immediate}.
14522 @node Text_IO Extensions
14523 @subsection Text_IO Extensions
14524 @cindex Text_IO extensions
14527 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
14528 to the standard @code{Text_IO} package:
14531 @item function File_Exists (Name : String) return Boolean;
14532 Determines if a file of the given name exists.
14534 @item function Get_Line return String;
14535 Reads a string from the standard input file. The value returned is exactly
14536 the length of the line that was read.
14538 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
14539 Similar, except that the parameter File specifies the file from which
14540 the string is to be read.
14544 @node Text_IO Facilities for Unbounded Strings
14545 @subsection Text_IO Facilities for Unbounded Strings
14546 @cindex Text_IO for unbounded strings
14547 @cindex Unbounded_String, Text_IO operations
14550 The package @code{Ada.Strings.Unbounded.Text_IO}
14551 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
14552 subprograms useful for Text_IO operations on unbounded strings:
14556 @item function Get_Line (File : File_Type) return Unbounded_String;
14557 Reads a line from the specified file
14558 and returns the result as an unbounded string.
14560 @item procedure Put (File : File_Type; U : Unbounded_String);
14561 Writes the value of the given unbounded string to the specified file
14562 Similar to the effect of
14563 @code{Put (To_String (U))} except that an extra copy is avoided.
14565 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
14566 Writes the value of the given unbounded string to the specified file,
14567 followed by a @code{New_Line}.
14568 Similar to the effect of @code{Put_Line (To_String (U))} except
14569 that an extra copy is avoided.
14573 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
14574 and is optional. If the parameter is omitted, then the standard input or
14575 output file is referenced as appropriate.
14577 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
14578 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
14579 @code{Wide_Text_IO} functionality for unbounded wide strings.
14581 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
14582 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
14583 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
14586 @section Wide_Text_IO
14589 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
14590 both input and output files may contain special sequences that represent
14591 wide character values. The encoding scheme for a given file may be
14592 specified using a FORM parameter:
14599 as part of the FORM string (WCEM = wide character encoding method),
14600 where @var{x} is one of the following characters
14606 Upper half encoding
14618 The encoding methods match those that
14619 can be used in a source
14620 program, but there is no requirement that the encoding method used for
14621 the source program be the same as the encoding method used for files,
14622 and different files may use different encoding methods.
14624 The default encoding method for the standard files, and for opened files
14625 for which no WCEM parameter is given in the FORM string matches the
14626 wide character encoding specified for the main program (the default
14627 being brackets encoding if no coding method was specified with -gnatW).
14631 In this encoding, a wide character is represented by a five character
14639 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
14640 characters (using upper case letters) of the wide character code. For
14641 example, ESC A345 is used to represent the wide character with code
14642 16#A345#. This scheme is compatible with use of the full
14643 @code{Wide_Character} set.
14645 @item Upper Half Coding
14646 The wide character with encoding 16#abcd#, where the upper bit is on
14647 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
14648 16#cd#. The second byte may never be a format control character, but is
14649 not required to be in the upper half. This method can be also used for
14650 shift-JIS or EUC where the internal coding matches the external coding.
14652 @item Shift JIS Coding
14653 A wide character is represented by a two character sequence 16#ab# and
14654 16#cd#, with the restrictions described for upper half encoding as
14655 described above. The internal character code is the corresponding JIS
14656 character according to the standard algorithm for Shift-JIS
14657 conversion. Only characters defined in the JIS code set table can be
14658 used with this encoding method.
14661 A wide character is represented by a two character sequence 16#ab# and
14662 16#cd#, with both characters being in the upper half. The internal
14663 character code is the corresponding JIS character according to the EUC
14664 encoding algorithm. Only characters defined in the JIS code set table
14665 can be used with this encoding method.
14668 A wide character is represented using
14669 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14670 10646-1/Am.2. Depending on the character value, the representation
14671 is a one, two, or three byte sequence:
14674 16#0000#-16#007f#: 2#0xxxxxxx#
14675 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
14676 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14680 where the @var{xxx} bits correspond to the left-padded bits of the
14681 16-bit character value. Note that all lower half ASCII characters
14682 are represented as ASCII bytes and all upper half characters and
14683 other wide characters are represented as sequences of upper-half
14684 (The full UTF-8 scheme allows for encoding 31-bit characters as
14685 6-byte sequences, but in this implementation, all UTF-8 sequences
14686 of four or more bytes length will raise a Constraint_Error, as
14687 will all invalid UTF-8 sequences.)
14689 @item Brackets Coding
14690 In this encoding, a wide character is represented by the following eight
14691 character sequence:
14698 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
14699 characters (using uppercase letters) of the wide character code. For
14700 example, @code{["A345"]} is used to represent the wide character with code
14702 This scheme is compatible with use of the full Wide_Character set.
14703 On input, brackets coding can also be used for upper half characters,
14704 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14705 is only used for wide characters with a code greater than @code{16#FF#}.
14707 Note that brackets coding is not normally used in the context of
14708 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
14709 a portable way of encoding source files. In the context of Wide_Text_IO
14710 or Wide_Wide_Text_IO, it can only be used if the file does not contain
14711 any instance of the left bracket character other than to encode wide
14712 character values using the brackets encoding method. In practice it is
14713 expected that some standard wide character encoding method such
14714 as UTF-8 will be used for text input output.
14716 If brackets notation is used, then any occurrence of a left bracket
14717 in the input file which is not the start of a valid wide character
14718 sequence will cause Constraint_Error to be raised. It is possible to
14719 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
14720 input will interpret this as a left bracket.
14722 However, when a left bracket is output, it will be output as a left bracket
14723 and not as ["5B"]. We make this decision because for normal use of
14724 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
14725 brackets. For example, if we write:
14728 Put_Line ("Start of output [first run]");
14732 we really do not want to have the left bracket in this message clobbered so
14733 that the output reads:
14736 Start of output ["5B"]first run]
14740 In practice brackets encoding is reasonably useful for normal Put_Line use
14741 since we won't get confused between left brackets and wide character
14742 sequences in the output. But for input, or when files are written out
14743 and read back in, it really makes better sense to use one of the standard
14744 encoding methods such as UTF-8.
14749 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
14750 not all wide character
14751 values can be represented. An attempt to output a character that cannot
14752 be represented using the encoding scheme for the file causes
14753 Constraint_Error to be raised. An invalid wide character sequence on
14754 input also causes Constraint_Error to be raised.
14757 * Wide_Text_IO Stream Pointer Positioning::
14758 * Wide_Text_IO Reading and Writing Non-Regular Files::
14761 @node Wide_Text_IO Stream Pointer Positioning
14762 @subsection Stream Pointer Positioning
14765 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14766 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14769 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
14770 normal lower ASCII set (i.e.@: a character in the range:
14772 @smallexample @c ada
14773 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
14777 then although the logical position of the file pointer is unchanged by
14778 the @code{Look_Ahead} call, the stream is physically positioned past the
14779 wide character sequence. Again this is to avoid the need for buffering
14780 or backup, and all @code{Wide_Text_IO} routines check the internal
14781 indication that this situation has occurred so that this is not visible
14782 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
14783 can be observed if the wide text file shares a stream with another file.
14785 @node Wide_Text_IO Reading and Writing Non-Regular Files
14786 @subsection Reading and Writing Non-Regular Files
14789 As in the case of Text_IO, when a non-regular file is read, it is
14790 assumed that the file contains no page marks (any form characters are
14791 treated as data characters), and @code{End_Of_Page} always returns
14792 @code{False}. Similarly, the end of file indication is not sticky, so
14793 it is possible to read beyond an end of file.
14795 @node Wide_Wide_Text_IO
14796 @section Wide_Wide_Text_IO
14799 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
14800 both input and output files may contain special sequences that represent
14801 wide wide character values. The encoding scheme for a given file may be
14802 specified using a FORM parameter:
14809 as part of the FORM string (WCEM = wide character encoding method),
14810 where @var{x} is one of the following characters
14816 Upper half encoding
14828 The encoding methods match those that
14829 can be used in a source
14830 program, but there is no requirement that the encoding method used for
14831 the source program be the same as the encoding method used for files,
14832 and different files may use different encoding methods.
14834 The default encoding method for the standard files, and for opened files
14835 for which no WCEM parameter is given in the FORM string matches the
14836 wide character encoding specified for the main program (the default
14837 being brackets encoding if no coding method was specified with -gnatW).
14842 A wide character is represented using
14843 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14844 10646-1/Am.2. Depending on the character value, the representation
14845 is a one, two, three, or four byte sequence:
14848 16#000000#-16#00007f#: 2#0xxxxxxx#
14849 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
14850 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14851 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
14855 where the @var{xxx} bits correspond to the left-padded bits of the
14856 21-bit character value. Note that all lower half ASCII characters
14857 are represented as ASCII bytes and all upper half characters and
14858 other wide characters are represented as sequences of upper-half
14861 @item Brackets Coding
14862 In this encoding, a wide wide character is represented by the following eight
14863 character sequence if is in wide character range
14869 and by the following ten character sequence if not
14872 [ " a b c d e f " ]
14876 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
14877 are the four or six hexadecimal
14878 characters (using uppercase letters) of the wide wide character code. For
14879 example, @code{["01A345"]} is used to represent the wide wide character
14880 with code @code{16#01A345#}.
14882 This scheme is compatible with use of the full Wide_Wide_Character set.
14883 On input, brackets coding can also be used for upper half characters,
14884 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14885 is only used for wide characters with a code greater than @code{16#FF#}.
14890 If is also possible to use the other Wide_Character encoding methods,
14891 such as Shift-JIS, but the other schemes cannot support the full range
14892 of wide wide characters.
14893 An attempt to output a character that cannot
14894 be represented using the encoding scheme for the file causes
14895 Constraint_Error to be raised. An invalid wide character sequence on
14896 input also causes Constraint_Error to be raised.
14899 * Wide_Wide_Text_IO Stream Pointer Positioning::
14900 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
14903 @node Wide_Wide_Text_IO Stream Pointer Positioning
14904 @subsection Stream Pointer Positioning
14907 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14908 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14911 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
14912 normal lower ASCII set (i.e.@: a character in the range:
14914 @smallexample @c ada
14915 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
14919 then although the logical position of the file pointer is unchanged by
14920 the @code{Look_Ahead} call, the stream is physically positioned past the
14921 wide character sequence. Again this is to avoid the need for buffering
14922 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
14923 indication that this situation has occurred so that this is not visible
14924 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
14925 can be observed if the wide text file shares a stream with another file.
14927 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
14928 @subsection Reading and Writing Non-Regular Files
14931 As in the case of Text_IO, when a non-regular file is read, it is
14932 assumed that the file contains no page marks (any form characters are
14933 treated as data characters), and @code{End_Of_Page} always returns
14934 @code{False}. Similarly, the end of file indication is not sticky, so
14935 it is possible to read beyond an end of file.
14941 A stream file is a sequence of bytes, where individual elements are
14942 written to the file as described in the Ada Reference Manual. The type
14943 @code{Stream_Element} is simply a byte. There are two ways to read or
14944 write a stream file.
14948 The operations @code{Read} and @code{Write} directly read or write a
14949 sequence of stream elements with no control information.
14952 The stream attributes applied to a stream file transfer data in the
14953 manner described for stream attributes.
14956 @node Text Translation
14957 @section Text Translation
14960 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
14961 passed to Text_IO.Create and Text_IO.Open:
14962 @samp{Text_Translation=@var{Yes}} is the default, which means to
14963 translate LF to/from CR/LF on Windows systems.
14964 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
14965 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
14966 may be used to create Unix-style files on
14967 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
14971 @section Shared Files
14974 Section A.14 of the Ada Reference Manual allows implementations to
14975 provide a wide variety of behavior if an attempt is made to access the
14976 same external file with two or more internal files.
14978 To provide a full range of functionality, while at the same time
14979 minimizing the problems of portability caused by this implementation
14980 dependence, GNAT handles file sharing as follows:
14984 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
14985 to open two or more files with the same full name is considered an error
14986 and is not supported. The exception @code{Use_Error} will be
14987 raised. Note that a file that is not explicitly closed by the program
14988 remains open until the program terminates.
14991 If the form parameter @samp{shared=no} appears in the form string, the
14992 file can be opened or created with its own separate stream identifier,
14993 regardless of whether other files sharing the same external file are
14994 opened. The exact effect depends on how the C stream routines handle
14995 multiple accesses to the same external files using separate streams.
14998 If the form parameter @samp{shared=yes} appears in the form string for
14999 each of two or more files opened using the same full name, the same
15000 stream is shared between these files, and the semantics are as described
15001 in Ada Reference Manual, Section A.14.
15005 When a program that opens multiple files with the same name is ported
15006 from another Ada compiler to GNAT, the effect will be that
15007 @code{Use_Error} is raised.
15009 The documentation of the original compiler and the documentation of the
15010 program should then be examined to determine if file sharing was
15011 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
15012 and @code{Create} calls as required.
15014 When a program is ported from GNAT to some other Ada compiler, no
15015 special attention is required unless the @samp{shared=@var{xxx}} form
15016 parameter is used in the program. In this case, you must examine the
15017 documentation of the new compiler to see if it supports the required
15018 file sharing semantics, and form strings modified appropriately. Of
15019 course it may be the case that the program cannot be ported if the
15020 target compiler does not support the required functionality. The best
15021 approach in writing portable code is to avoid file sharing (and hence
15022 the use of the @samp{shared=@var{xxx}} parameter in the form string)
15025 One common use of file sharing in Ada 83 is the use of instantiations of
15026 Sequential_IO on the same file with different types, to achieve
15027 heterogeneous input-output. Although this approach will work in GNAT if
15028 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
15029 for this purpose (using the stream attributes)
15031 @node Filenames encoding
15032 @section Filenames encoding
15035 An encoding form parameter can be used to specify the filename
15036 encoding @samp{encoding=@var{xxx}}.
15040 If the form parameter @samp{encoding=utf8} appears in the form string, the
15041 filename must be encoded in UTF-8.
15044 If the form parameter @samp{encoding=8bits} appears in the form
15045 string, the filename must be a standard 8bits string.
15048 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
15049 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
15050 variable. And if not set @samp{utf8} is assumed.
15054 The current system Windows ANSI code page.
15059 This encoding form parameter is only supported on the Windows
15060 platform. On the other Operating Systems the run-time is supporting
15064 @section Open Modes
15067 @code{Open} and @code{Create} calls result in a call to @code{fopen}
15068 using the mode shown in the following table:
15071 @center @code{Open} and @code{Create} Call Modes
15073 @b{OPEN } @b{CREATE}
15074 Append_File "r+" "w+"
15076 Out_File (Direct_IO) "r+" "w"
15077 Out_File (all other cases) "w" "w"
15078 Inout_File "r+" "w+"
15082 If text file translation is required, then either @samp{b} or @samp{t}
15083 is added to the mode, depending on the setting of Text. Text file
15084 translation refers to the mapping of CR/LF sequences in an external file
15085 to LF characters internally. This mapping only occurs in DOS and
15086 DOS-like systems, and is not relevant to other systems.
15088 A special case occurs with Stream_IO@. As shown in the above table, the
15089 file is initially opened in @samp{r} or @samp{w} mode for the
15090 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
15091 subsequently requires switching from reading to writing or vice-versa,
15092 then the file is reopened in @samp{r+} mode to permit the required operation.
15094 @node Operations on C Streams
15095 @section Operations on C Streams
15096 The package @code{Interfaces.C_Streams} provides an Ada program with direct
15097 access to the C library functions for operations on C streams:
15099 @smallexample @c adanocomment
15100 package Interfaces.C_Streams is
15101 -- Note: the reason we do not use the types that are in
15102 -- Interfaces.C is that we want to avoid dragging in the
15103 -- code in this unit if possible.
15104 subtype chars is System.Address;
15105 -- Pointer to null-terminated array of characters
15106 subtype FILEs is System.Address;
15107 -- Corresponds to the C type FILE*
15108 subtype voids is System.Address;
15109 -- Corresponds to the C type void*
15110 subtype int is Integer;
15111 subtype long is Long_Integer;
15112 -- Note: the above types are subtypes deliberately, and it
15113 -- is part of this spec that the above correspondences are
15114 -- guaranteed. This means that it is legitimate to, for
15115 -- example, use Integer instead of int. We provide these
15116 -- synonyms for clarity, but in some cases it may be
15117 -- convenient to use the underlying types (for example to
15118 -- avoid an unnecessary dependency of a spec on the spec
15120 type size_t is mod 2 ** Standard'Address_Size;
15121 NULL_Stream : constant FILEs;
15122 -- Value returned (NULL in C) to indicate an
15123 -- fdopen/fopen/tmpfile error
15124 ----------------------------------
15125 -- Constants Defined in stdio.h --
15126 ----------------------------------
15127 EOF : constant int;
15128 -- Used by a number of routines to indicate error or
15130 IOFBF : constant int;
15131 IOLBF : constant int;
15132 IONBF : constant int;
15133 -- Used to indicate buffering mode for setvbuf call
15134 SEEK_CUR : constant int;
15135 SEEK_END : constant int;
15136 SEEK_SET : constant int;
15137 -- Used to indicate origin for fseek call
15138 function stdin return FILEs;
15139 function stdout return FILEs;
15140 function stderr return FILEs;
15141 -- Streams associated with standard files
15142 --------------------------
15143 -- Standard C functions --
15144 --------------------------
15145 -- The functions selected below are ones that are
15146 -- available in UNIX (but not necessarily in ANSI C).
15147 -- These are very thin interfaces
15148 -- which copy exactly the C headers. For more
15149 -- documentation on these functions, see the Microsoft C
15150 -- "Run-Time Library Reference" (Microsoft Press, 1990,
15151 -- ISBN 1-55615-225-6), which includes useful information
15152 -- on system compatibility.
15153 procedure clearerr (stream : FILEs);
15154 function fclose (stream : FILEs) return int;
15155 function fdopen (handle : int; mode : chars) return FILEs;
15156 function feof (stream : FILEs) return int;
15157 function ferror (stream : FILEs) return int;
15158 function fflush (stream : FILEs) return int;
15159 function fgetc (stream : FILEs) return int;
15160 function fgets (strng : chars; n : int; stream : FILEs)
15162 function fileno (stream : FILEs) return int;
15163 function fopen (filename : chars; Mode : chars)
15165 -- Note: to maintain target independence, use
15166 -- text_translation_required, a boolean variable defined in
15167 -- a-sysdep.c to deal with the target dependent text
15168 -- translation requirement. If this variable is set,
15169 -- then b/t should be appended to the standard mode
15170 -- argument to set the text translation mode off or on
15172 function fputc (C : int; stream : FILEs) return int;
15173 function fputs (Strng : chars; Stream : FILEs) return int;
15190 function ftell (stream : FILEs) return long;
15197 function isatty (handle : int) return int;
15198 procedure mktemp (template : chars);
15199 -- The return value (which is just a pointer to template)
15201 procedure rewind (stream : FILEs);
15202 function rmtmp return int;
15210 function tmpfile return FILEs;
15211 function ungetc (c : int; stream : FILEs) return int;
15212 function unlink (filename : chars) return int;
15213 ---------------------
15214 -- Extra functions --
15215 ---------------------
15216 -- These functions supply slightly thicker bindings than
15217 -- those above. They are derived from functions in the
15218 -- C Run-Time Library, but may do a bit more work than
15219 -- just directly calling one of the Library functions.
15220 function is_regular_file (handle : int) return int;
15221 -- Tests if given handle is for a regular file (result 1)
15222 -- or for a non-regular file (pipe or device, result 0).
15223 ---------------------------------
15224 -- Control of Text/Binary Mode --
15225 ---------------------------------
15226 -- If text_translation_required is true, then the following
15227 -- functions may be used to dynamically switch a file from
15228 -- binary to text mode or vice versa. These functions have
15229 -- no effect if text_translation_required is false (i.e.@: in
15230 -- normal UNIX mode). Use fileno to get a stream handle.
15231 procedure set_binary_mode (handle : int);
15232 procedure set_text_mode (handle : int);
15233 ----------------------------
15234 -- Full Path Name support --
15235 ----------------------------
15236 procedure full_name (nam : chars; buffer : chars);
15237 -- Given a NUL terminated string representing a file
15238 -- name, returns in buffer a NUL terminated string
15239 -- representing the full path name for the file name.
15240 -- On systems where it is relevant the drive is also
15241 -- part of the full path name. It is the responsibility
15242 -- of the caller to pass an actual parameter for buffer
15243 -- that is big enough for any full path name. Use
15244 -- max_path_len given below as the size of buffer.
15245 max_path_len : integer;
15246 -- Maximum length of an allowable full path name on the
15247 -- system, including a terminating NUL character.
15248 end Interfaces.C_Streams;
15251 @node Interfacing to C Streams
15252 @section Interfacing to C Streams
15255 The packages in this section permit interfacing Ada files to C Stream
15258 @smallexample @c ada
15259 with Interfaces.C_Streams;
15260 package Ada.Sequential_IO.C_Streams is
15261 function C_Stream (F : File_Type)
15262 return Interfaces.C_Streams.FILEs;
15264 (File : in out File_Type;
15265 Mode : in File_Mode;
15266 C_Stream : in Interfaces.C_Streams.FILEs;
15267 Form : in String := "");
15268 end Ada.Sequential_IO.C_Streams;
15270 with Interfaces.C_Streams;
15271 package Ada.Direct_IO.C_Streams is
15272 function C_Stream (F : File_Type)
15273 return Interfaces.C_Streams.FILEs;
15275 (File : in out File_Type;
15276 Mode : in File_Mode;
15277 C_Stream : in Interfaces.C_Streams.FILEs;
15278 Form : in String := "");
15279 end Ada.Direct_IO.C_Streams;
15281 with Interfaces.C_Streams;
15282 package Ada.Text_IO.C_Streams is
15283 function C_Stream (F : File_Type)
15284 return Interfaces.C_Streams.FILEs;
15286 (File : in out File_Type;
15287 Mode : in File_Mode;
15288 C_Stream : in Interfaces.C_Streams.FILEs;
15289 Form : in String := "");
15290 end Ada.Text_IO.C_Streams;
15292 with Interfaces.C_Streams;
15293 package Ada.Wide_Text_IO.C_Streams is
15294 function C_Stream (F : File_Type)
15295 return Interfaces.C_Streams.FILEs;
15297 (File : in out File_Type;
15298 Mode : in File_Mode;
15299 C_Stream : in Interfaces.C_Streams.FILEs;
15300 Form : in String := "");
15301 end Ada.Wide_Text_IO.C_Streams;
15303 with Interfaces.C_Streams;
15304 package Ada.Wide_Wide_Text_IO.C_Streams is
15305 function C_Stream (F : File_Type)
15306 return Interfaces.C_Streams.FILEs;
15308 (File : in out File_Type;
15309 Mode : in File_Mode;
15310 C_Stream : in Interfaces.C_Streams.FILEs;
15311 Form : in String := "");
15312 end Ada.Wide_Wide_Text_IO.C_Streams;
15314 with Interfaces.C_Streams;
15315 package Ada.Stream_IO.C_Streams is
15316 function C_Stream (F : File_Type)
15317 return Interfaces.C_Streams.FILEs;
15319 (File : in out File_Type;
15320 Mode : in File_Mode;
15321 C_Stream : in Interfaces.C_Streams.FILEs;
15322 Form : in String := "");
15323 end Ada.Stream_IO.C_Streams;
15327 In each of these six packages, the @code{C_Stream} function obtains the
15328 @code{FILE} pointer from a currently opened Ada file. It is then
15329 possible to use the @code{Interfaces.C_Streams} package to operate on
15330 this stream, or the stream can be passed to a C program which can
15331 operate on it directly. Of course the program is responsible for
15332 ensuring that only appropriate sequences of operations are executed.
15334 One particular use of relevance to an Ada program is that the
15335 @code{setvbuf} function can be used to control the buffering of the
15336 stream used by an Ada file. In the absence of such a call the standard
15337 default buffering is used.
15339 The @code{Open} procedures in these packages open a file giving an
15340 existing C Stream instead of a file name. Typically this stream is
15341 imported from a C program, allowing an Ada file to operate on an
15344 @node The GNAT Library
15345 @chapter The GNAT Library
15348 The GNAT library contains a number of general and special purpose packages.
15349 It represents functionality that the GNAT developers have found useful, and
15350 which is made available to GNAT users. The packages described here are fully
15351 supported, and upwards compatibility will be maintained in future releases,
15352 so you can use these facilities with the confidence that the same functionality
15353 will be available in future releases.
15355 The chapter here simply gives a brief summary of the facilities available.
15356 The full documentation is found in the spec file for the package. The full
15357 sources of these library packages, including both spec and body, are provided
15358 with all GNAT releases. For example, to find out the full specifications of
15359 the SPITBOL pattern matching capability, including a full tutorial and
15360 extensive examples, look in the @file{g-spipat.ads} file in the library.
15362 For each entry here, the package name (as it would appear in a @code{with}
15363 clause) is given, followed by the name of the corresponding spec file in
15364 parentheses. The packages are children in four hierarchies, @code{Ada},
15365 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
15366 GNAT-specific hierarchy.
15368 Note that an application program should only use packages in one of these
15369 four hierarchies if the package is defined in the Ada Reference Manual,
15370 or is listed in this section of the GNAT Programmers Reference Manual.
15371 All other units should be considered internal implementation units and
15372 should not be directly @code{with}'ed by application code. The use of
15373 a @code{with} statement that references one of these internal implementation
15374 units makes an application potentially dependent on changes in versions
15375 of GNAT, and will generate a warning message.
15378 * Ada.Characters.Latin_9 (a-chlat9.ads)::
15379 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
15380 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
15381 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
15382 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
15383 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
15384 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
15385 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
15386 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
15387 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
15388 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
15389 * Ada.Command_Line.Environment (a-colien.ads)::
15390 * Ada.Command_Line.Remove (a-colire.ads)::
15391 * Ada.Command_Line.Response_File (a-clrefi.ads)::
15392 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
15393 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
15394 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
15395 * Ada.Exceptions.Traceback (a-exctra.ads)::
15396 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
15397 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
15398 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
15399 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
15400 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
15401 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
15402 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
15403 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
15404 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
15405 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
15406 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
15407 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
15408 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
15409 * GNAT.Altivec (g-altive.ads)::
15410 * GNAT.Altivec.Conversions (g-altcon.ads)::
15411 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
15412 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
15413 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
15414 * GNAT.Array_Split (g-arrspl.ads)::
15415 * GNAT.AWK (g-awk.ads)::
15416 * GNAT.Bounded_Buffers (g-boubuf.ads)::
15417 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
15418 * GNAT.Bubble_Sort (g-bubsor.ads)::
15419 * GNAT.Bubble_Sort_A (g-busora.ads)::
15420 * GNAT.Bubble_Sort_G (g-busorg.ads)::
15421 * GNAT.Byte_Order_Mark (g-byorma.ads)::
15422 * GNAT.Byte_Swapping (g-bytswa.ads)::
15423 * GNAT.Calendar (g-calend.ads)::
15424 * GNAT.Calendar.Time_IO (g-catiio.ads)::
15425 * GNAT.Case_Util (g-casuti.ads)::
15426 * GNAT.CGI (g-cgi.ads)::
15427 * GNAT.CGI.Cookie (g-cgicoo.ads)::
15428 * GNAT.CGI.Debug (g-cgideb.ads)::
15429 * GNAT.Command_Line (g-comlin.ads)::
15430 * GNAT.Compiler_Version (g-comver.ads)::
15431 * GNAT.Ctrl_C (g-ctrl_c.ads)::
15432 * GNAT.CRC32 (g-crc32.ads)::
15433 * GNAT.Current_Exception (g-curexc.ads)::
15434 * GNAT.Debug_Pools (g-debpoo.ads)::
15435 * GNAT.Debug_Utilities (g-debuti.ads)::
15436 * GNAT.Decode_String (g-decstr.ads)::
15437 * GNAT.Decode_UTF8_String (g-deutst.ads)::
15438 * GNAT.Directory_Operations (g-dirope.ads)::
15439 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
15440 * GNAT.Dynamic_HTables (g-dynhta.ads)::
15441 * GNAT.Dynamic_Tables (g-dyntab.ads)::
15442 * GNAT.Encode_String (g-encstr.ads)::
15443 * GNAT.Encode_UTF8_String (g-enutst.ads)::
15444 * GNAT.Exception_Actions (g-excact.ads)::
15445 * GNAT.Exception_Traces (g-exctra.ads)::
15446 * GNAT.Exceptions (g-except.ads)::
15447 * GNAT.Expect (g-expect.ads)::
15448 * GNAT.Expect.TTY (g-exptty.ads)::
15449 * GNAT.Float_Control (g-flocon.ads)::
15450 * GNAT.Heap_Sort (g-heasor.ads)::
15451 * GNAT.Heap_Sort_A (g-hesora.ads)::
15452 * GNAT.Heap_Sort_G (g-hesorg.ads)::
15453 * GNAT.HTable (g-htable.ads)::
15454 * GNAT.IO (g-io.ads)::
15455 * GNAT.IO_Aux (g-io_aux.ads)::
15456 * GNAT.Lock_Files (g-locfil.ads)::
15457 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
15458 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
15459 * GNAT.MD5 (g-md5.ads)::
15460 * GNAT.Memory_Dump (g-memdum.ads)::
15461 * GNAT.Most_Recent_Exception (g-moreex.ads)::
15462 * GNAT.OS_Lib (g-os_lib.ads)::
15463 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
15464 * GNAT.Random_Numbers (g-rannum.ads)::
15465 * GNAT.Regexp (g-regexp.ads)::
15466 * GNAT.Registry (g-regist.ads)::
15467 * GNAT.Regpat (g-regpat.ads)::
15468 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
15469 * GNAT.Semaphores (g-semaph.ads)::
15470 * GNAT.Serial_Communications (g-sercom.ads)::
15471 * GNAT.SHA1 (g-sha1.ads)::
15472 * GNAT.SHA224 (g-sha224.ads)::
15473 * GNAT.SHA256 (g-sha256.ads)::
15474 * GNAT.SHA384 (g-sha384.ads)::
15475 * GNAT.SHA512 (g-sha512.ads)::
15476 * GNAT.Signals (g-signal.ads)::
15477 * GNAT.Sockets (g-socket.ads)::
15478 * GNAT.Source_Info (g-souinf.ads)::
15479 * GNAT.Spelling_Checker (g-speche.ads)::
15480 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
15481 * GNAT.Spitbol.Patterns (g-spipat.ads)::
15482 * GNAT.Spitbol (g-spitbo.ads)::
15483 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
15484 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
15485 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
15486 * GNAT.SSE (g-sse.ads)::
15487 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
15488 * GNAT.Strings (g-string.ads)::
15489 * GNAT.String_Split (g-strspl.ads)::
15490 * GNAT.Table (g-table.ads)::
15491 * GNAT.Task_Lock (g-tasloc.ads)::
15492 * GNAT.Threads (g-thread.ads)::
15493 * GNAT.Time_Stamp (g-timsta.ads)::
15494 * GNAT.Traceback (g-traceb.ads)::
15495 * GNAT.Traceback.Symbolic (g-trasym.ads)::
15496 * GNAT.UTF_32 (g-utf_32.ads)::
15497 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
15498 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
15499 * GNAT.Wide_String_Split (g-wistsp.ads)::
15500 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
15501 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
15502 * Interfaces.C.Extensions (i-cexten.ads)::
15503 * Interfaces.C.Streams (i-cstrea.ads)::
15504 * Interfaces.CPP (i-cpp.ads)::
15505 * Interfaces.Packed_Decimal (i-pacdec.ads)::
15506 * Interfaces.VxWorks (i-vxwork.ads)::
15507 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
15508 * System.Address_Image (s-addima.ads)::
15509 * System.Assertions (s-assert.ads)::
15510 * System.Memory (s-memory.ads)::
15511 * System.Partition_Interface (s-parint.ads)::
15512 * System.Pool_Global (s-pooglo.ads)::
15513 * System.Pool_Local (s-pooloc.ads)::
15514 * System.Restrictions (s-restri.ads)::
15515 * System.Rident (s-rident.ads)::
15516 * System.Strings.Stream_Ops (s-ststop.ads)::
15517 * System.Task_Info (s-tasinf.ads)::
15518 * System.Wch_Cnv (s-wchcnv.ads)::
15519 * System.Wch_Con (s-wchcon.ads)::
15522 @node Ada.Characters.Latin_9 (a-chlat9.ads)
15523 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15524 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15525 @cindex Latin_9 constants for Character
15528 This child of @code{Ada.Characters}
15529 provides a set of definitions corresponding to those in the
15530 RM-defined package @code{Ada.Characters.Latin_1} but with the
15531 few modifications required for @code{Latin-9}
15532 The provision of such a package
15533 is specifically authorized by the Ada Reference Manual
15536 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
15537 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15538 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15539 @cindex Latin_1 constants for Wide_Character
15542 This child of @code{Ada.Characters}
15543 provides a set of definitions corresponding to those in the
15544 RM-defined package @code{Ada.Characters.Latin_1} but with the
15545 types of the constants being @code{Wide_Character}
15546 instead of @code{Character}. The provision of such a package
15547 is specifically authorized by the Ada Reference Manual
15550 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
15551 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15552 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15553 @cindex Latin_9 constants for Wide_Character
15556 This child of @code{Ada.Characters}
15557 provides a set of definitions corresponding to those in the
15558 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15559 types of the constants being @code{Wide_Character}
15560 instead of @code{Character}. The provision of such a package
15561 is specifically authorized by the Ada Reference Manual
15564 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
15565 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15566 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15567 @cindex Latin_1 constants for Wide_Wide_Character
15570 This child of @code{Ada.Characters}
15571 provides a set of definitions corresponding to those in the
15572 RM-defined package @code{Ada.Characters.Latin_1} but with the
15573 types of the constants being @code{Wide_Wide_Character}
15574 instead of @code{Character}. The provision of such a package
15575 is specifically authorized by the Ada Reference Manual
15578 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
15579 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15580 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15581 @cindex Latin_9 constants for Wide_Wide_Character
15584 This child of @code{Ada.Characters}
15585 provides a set of definitions corresponding to those in the
15586 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15587 types of the constants being @code{Wide_Wide_Character}
15588 instead of @code{Character}. The provision of such a package
15589 is specifically authorized by the Ada Reference Manual
15592 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
15593 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15594 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15595 @cindex Formal container for doubly linked lists
15598 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15599 container for doubly linked lists, meant to facilitate formal verification of
15600 code using such containers.
15602 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
15603 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15604 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15605 @cindex Formal container for hashed maps
15608 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15609 container for hashed maps, meant to facilitate formal verification of
15610 code using such containers.
15612 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
15613 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15614 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15615 @cindex Formal container for hashed sets
15618 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15619 container for hashed sets, meant to facilitate formal verification of
15620 code using such containers.
15622 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
15623 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15624 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15625 @cindex Formal container for ordered maps
15628 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15629 container for ordered maps, meant to facilitate formal verification of
15630 code using such containers.
15632 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
15633 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15634 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15635 @cindex Formal container for ordered sets
15638 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15639 container for ordered sets, meant to facilitate formal verification of
15640 code using such containers.
15642 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
15643 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15644 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15645 @cindex Formal container for vectors
15648 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15649 container for vectors, meant to facilitate formal verification of
15650 code using such containers.
15652 @node Ada.Command_Line.Environment (a-colien.ads)
15653 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15654 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15655 @cindex Environment entries
15658 This child of @code{Ada.Command_Line}
15659 provides a mechanism for obtaining environment values on systems
15660 where this concept makes sense.
15662 @node Ada.Command_Line.Remove (a-colire.ads)
15663 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15664 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15665 @cindex Removing command line arguments
15666 @cindex Command line, argument removal
15669 This child of @code{Ada.Command_Line}
15670 provides a mechanism for logically removing
15671 arguments from the argument list. Once removed, an argument is not visible
15672 to further calls on the subprograms in @code{Ada.Command_Line} will not
15673 see the removed argument.
15675 @node Ada.Command_Line.Response_File (a-clrefi.ads)
15676 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15677 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15678 @cindex Response file for command line
15679 @cindex Command line, response file
15680 @cindex Command line, handling long command lines
15683 This child of @code{Ada.Command_Line} provides a mechanism facilities for
15684 getting command line arguments from a text file, called a "response file".
15685 Using a response file allow passing a set of arguments to an executable longer
15686 than the maximum allowed by the system on the command line.
15688 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
15689 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15690 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15691 @cindex C Streams, Interfacing with Direct_IO
15694 This package provides subprograms that allow interfacing between
15695 C streams and @code{Direct_IO}. The stream identifier can be
15696 extracted from a file opened on the Ada side, and an Ada file
15697 can be constructed from a stream opened on the C side.
15699 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
15700 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15701 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15702 @cindex Null_Occurrence, testing for
15705 This child subprogram provides a way of testing for the null
15706 exception occurrence (@code{Null_Occurrence}) without raising
15709 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
15710 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15711 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15712 @cindex Null_Occurrence, testing for
15715 This child subprogram is used for handling otherwise unhandled
15716 exceptions (hence the name last chance), and perform clean ups before
15717 terminating the program. Note that this subprogram never returns.
15719 @node Ada.Exceptions.Traceback (a-exctra.ads)
15720 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15721 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15722 @cindex Traceback for Exception Occurrence
15725 This child package provides the subprogram (@code{Tracebacks}) to
15726 give a traceback array of addresses based on an exception
15729 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
15730 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15731 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15732 @cindex C Streams, Interfacing with Sequential_IO
15735 This package provides subprograms that allow interfacing between
15736 C streams and @code{Sequential_IO}. The stream identifier can be
15737 extracted from a file opened on the Ada side, and an Ada file
15738 can be constructed from a stream opened on the C side.
15740 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
15741 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15742 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15743 @cindex C Streams, Interfacing with Stream_IO
15746 This package provides subprograms that allow interfacing between
15747 C streams and @code{Stream_IO}. The stream identifier can be
15748 extracted from a file opened on the Ada side, and an Ada file
15749 can be constructed from a stream opened on the C side.
15751 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
15752 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15753 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15754 @cindex @code{Unbounded_String}, IO support
15755 @cindex @code{Text_IO}, extensions for unbounded strings
15758 This package provides subprograms for Text_IO for unbounded
15759 strings, avoiding the necessity for an intermediate operation
15760 with ordinary strings.
15762 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
15763 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15764 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15765 @cindex @code{Unbounded_Wide_String}, IO support
15766 @cindex @code{Text_IO}, extensions for unbounded wide strings
15769 This package provides subprograms for Text_IO for unbounded
15770 wide strings, avoiding the necessity for an intermediate operation
15771 with ordinary wide strings.
15773 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
15774 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15775 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15776 @cindex @code{Unbounded_Wide_Wide_String}, IO support
15777 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
15780 This package provides subprograms for Text_IO for unbounded
15781 wide wide strings, avoiding the necessity for an intermediate operation
15782 with ordinary wide wide strings.
15784 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
15785 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15786 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15787 @cindex C Streams, Interfacing with @code{Text_IO}
15790 This package provides subprograms that allow interfacing between
15791 C streams and @code{Text_IO}. The stream identifier can be
15792 extracted from a file opened on the Ada side, and an Ada file
15793 can be constructed from a stream opened on the C side.
15795 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
15796 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15797 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15798 @cindex @code{Text_IO} resetting standard files
15801 This procedure is used to reset the status of the standard files used
15802 by Ada.Text_IO. This is useful in a situation (such as a restart in an
15803 embedded application) where the status of the files may change during
15804 execution (for example a standard input file may be redefined to be
15807 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
15808 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15809 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15810 @cindex Unicode categorization, Wide_Character
15813 This package provides subprograms that allow categorization of
15814 Wide_Character values according to Unicode categories.
15816 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
15817 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15818 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15819 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
15822 This package provides subprograms that allow interfacing between
15823 C streams and @code{Wide_Text_IO}. The stream identifier can be
15824 extracted from a file opened on the Ada side, and an Ada file
15825 can be constructed from a stream opened on the C side.
15827 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
15828 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15829 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15830 @cindex @code{Wide_Text_IO} resetting standard files
15833 This procedure is used to reset the status of the standard files used
15834 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
15835 embedded application) where the status of the files may change during
15836 execution (for example a standard input file may be redefined to be
15839 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
15840 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15841 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15842 @cindex Unicode categorization, Wide_Wide_Character
15845 This package provides subprograms that allow categorization of
15846 Wide_Wide_Character values according to Unicode categories.
15848 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
15849 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15850 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15851 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
15854 This package provides subprograms that allow interfacing between
15855 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
15856 extracted from a file opened on the Ada side, and an Ada file
15857 can be constructed from a stream opened on the C side.
15859 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
15860 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15861 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15862 @cindex @code{Wide_Wide_Text_IO} resetting standard files
15865 This procedure is used to reset the status of the standard files used
15866 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
15867 restart in an embedded application) where the status of the files may
15868 change during execution (for example a standard input file may be
15869 redefined to be interactive).
15871 @node GNAT.Altivec (g-altive.ads)
15872 @section @code{GNAT.Altivec} (@file{g-altive.ads})
15873 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
15877 This is the root package of the GNAT AltiVec binding. It provides
15878 definitions of constants and types common to all the versions of the
15881 @node GNAT.Altivec.Conversions (g-altcon.ads)
15882 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15883 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15887 This package provides the Vector/View conversion routines.
15889 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
15890 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15891 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15895 This package exposes the Ada interface to the AltiVec operations on
15896 vector objects. A soft emulation is included by default in the GNAT
15897 library. The hard binding is provided as a separate package. This unit
15898 is common to both bindings.
15900 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
15901 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15902 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15906 This package exposes the various vector types part of the Ada binding
15907 to AltiVec facilities.
15909 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
15910 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15911 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15915 This package provides public 'View' data types from/to which private
15916 vector representations can be converted via
15917 GNAT.Altivec.Conversions. This allows convenient access to individual
15918 vector elements and provides a simple way to initialize vector
15921 @node GNAT.Array_Split (g-arrspl.ads)
15922 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15923 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15924 @cindex Array splitter
15927 Useful array-manipulation routines: given a set of separators, split
15928 an array wherever the separators appear, and provide direct access
15929 to the resulting slices.
15931 @node GNAT.AWK (g-awk.ads)
15932 @section @code{GNAT.AWK} (@file{g-awk.ads})
15933 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
15938 Provides AWK-like parsing functions, with an easy interface for parsing one
15939 or more files containing formatted data. The file is viewed as a database
15940 where each record is a line and a field is a data element in this line.
15942 @node GNAT.Bounded_Buffers (g-boubuf.ads)
15943 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15944 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15946 @cindex Bounded Buffers
15949 Provides a concurrent generic bounded buffer abstraction. Instances are
15950 useful directly or as parts of the implementations of other abstractions,
15953 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
15954 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15955 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15960 Provides a thread-safe asynchronous intertask mailbox communication facility.
15962 @node GNAT.Bubble_Sort (g-bubsor.ads)
15963 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15964 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15966 @cindex Bubble sort
15969 Provides a general implementation of bubble sort usable for sorting arbitrary
15970 data items. Exchange and comparison procedures are provided by passing
15971 access-to-procedure values.
15973 @node GNAT.Bubble_Sort_A (g-busora.ads)
15974 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15975 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15977 @cindex Bubble sort
15980 Provides a general implementation of bubble sort usable for sorting arbitrary
15981 data items. Move and comparison procedures are provided by passing
15982 access-to-procedure values. This is an older version, retained for
15983 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
15985 @node GNAT.Bubble_Sort_G (g-busorg.ads)
15986 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15987 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15989 @cindex Bubble sort
15992 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
15993 are provided as generic parameters, this improves efficiency, especially
15994 if the procedures can be inlined, at the expense of duplicating code for
15995 multiple instantiations.
15997 @node GNAT.Byte_Order_Mark (g-byorma.ads)
15998 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15999 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
16000 @cindex UTF-8 representation
16001 @cindex Wide characte representations
16004 Provides a routine which given a string, reads the start of the string to
16005 see whether it is one of the standard byte order marks (BOM's) which signal
16006 the encoding of the string. The routine includes detection of special XML
16007 sequences for various UCS input formats.
16009 @node GNAT.Byte_Swapping (g-bytswa.ads)
16010 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
16011 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
16012 @cindex Byte swapping
16016 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
16017 Machine-specific implementations are available in some cases.
16019 @node GNAT.Calendar (g-calend.ads)
16020 @section @code{GNAT.Calendar} (@file{g-calend.ads})
16021 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
16022 @cindex @code{Calendar}
16025 Extends the facilities provided by @code{Ada.Calendar} to include handling
16026 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
16027 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
16028 C @code{timeval} format.
16030 @node GNAT.Calendar.Time_IO (g-catiio.ads)
16031 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
16032 @cindex @code{Calendar}
16034 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
16036 @node GNAT.CRC32 (g-crc32.ads)
16037 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
16038 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
16040 @cindex Cyclic Redundancy Check
16043 This package implements the CRC-32 algorithm. For a full description
16044 of this algorithm see
16045 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
16046 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
16047 Aug.@: 1988. Sarwate, D.V@.
16049 @node GNAT.Case_Util (g-casuti.ads)
16050 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
16051 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
16052 @cindex Casing utilities
16053 @cindex Character handling (@code{GNAT.Case_Util})
16056 A set of simple routines for handling upper and lower casing of strings
16057 without the overhead of the full casing tables
16058 in @code{Ada.Characters.Handling}.
16060 @node GNAT.CGI (g-cgi.ads)
16061 @section @code{GNAT.CGI} (@file{g-cgi.ads})
16062 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
16063 @cindex CGI (Common Gateway Interface)
16066 This is a package for interfacing a GNAT program with a Web server via the
16067 Common Gateway Interface (CGI)@. Basically this package parses the CGI
16068 parameters, which are a set of key/value pairs sent by the Web server. It
16069 builds a table whose index is the key and provides some services to deal
16072 @node GNAT.CGI.Cookie (g-cgicoo.ads)
16073 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
16074 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
16075 @cindex CGI (Common Gateway Interface) cookie support
16076 @cindex Cookie support in CGI
16079 This is a package to interface a GNAT program with a Web server via the
16080 Common Gateway Interface (CGI). It exports services to deal with Web
16081 cookies (piece of information kept in the Web client software).
16083 @node GNAT.CGI.Debug (g-cgideb.ads)
16084 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
16085 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
16086 @cindex CGI (Common Gateway Interface) debugging
16089 This is a package to help debugging CGI (Common Gateway Interface)
16090 programs written in Ada.
16092 @node GNAT.Command_Line (g-comlin.ads)
16093 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
16094 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
16095 @cindex Command line
16098 Provides a high level interface to @code{Ada.Command_Line} facilities,
16099 including the ability to scan for named switches with optional parameters
16100 and expand file names using wild card notations.
16102 @node GNAT.Compiler_Version (g-comver.ads)
16103 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
16104 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
16105 @cindex Compiler Version
16106 @cindex Version, of compiler
16109 Provides a routine for obtaining the version of the compiler used to
16110 compile the program. More accurately this is the version of the binder
16111 used to bind the program (this will normally be the same as the version
16112 of the compiler if a consistent tool set is used to compile all units
16115 @node GNAT.Ctrl_C (g-ctrl_c.ads)
16116 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
16117 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
16121 Provides a simple interface to handle Ctrl-C keyboard events.
16123 @node GNAT.Current_Exception (g-curexc.ads)
16124 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
16125 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
16126 @cindex Current exception
16127 @cindex Exception retrieval
16130 Provides access to information on the current exception that has been raised
16131 without the need for using the Ada 95 / Ada 2005 exception choice parameter
16132 specification syntax.
16133 This is particularly useful in simulating typical facilities for
16134 obtaining information about exceptions provided by Ada 83 compilers.
16136 @node GNAT.Debug_Pools (g-debpoo.ads)
16137 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
16138 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
16140 @cindex Debug pools
16141 @cindex Memory corruption debugging
16144 Provide a debugging storage pools that helps tracking memory corruption
16145 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
16146 @value{EDITION} User's Guide}.
16148 @node GNAT.Debug_Utilities (g-debuti.ads)
16149 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
16150 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
16154 Provides a few useful utilities for debugging purposes, including conversion
16155 to and from string images of address values. Supports both C and Ada formats
16156 for hexadecimal literals.
16158 @node GNAT.Decode_String (g-decstr.ads)
16159 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
16160 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
16161 @cindex Decoding strings
16162 @cindex String decoding
16163 @cindex Wide character encoding
16168 A generic package providing routines for decoding wide character and wide wide
16169 character strings encoded as sequences of 8-bit characters using a specified
16170 encoding method. Includes validation routines, and also routines for stepping
16171 to next or previous encoded character in an encoded string.
16172 Useful in conjunction with Unicode character coding. Note there is a
16173 preinstantiation for UTF-8. See next entry.
16175 @node GNAT.Decode_UTF8_String (g-deutst.ads)
16176 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
16177 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
16178 @cindex Decoding strings
16179 @cindex Decoding UTF-8 strings
16180 @cindex UTF-8 string decoding
16181 @cindex Wide character decoding
16186 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
16188 @node GNAT.Directory_Operations (g-dirope.ads)
16189 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
16190 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
16191 @cindex Directory operations
16194 Provides a set of routines for manipulating directories, including changing
16195 the current directory, making new directories, and scanning the files in a
16198 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
16199 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
16200 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
16201 @cindex Directory operations iteration
16204 A child unit of GNAT.Directory_Operations providing additional operations
16205 for iterating through directories.
16207 @node GNAT.Dynamic_HTables (g-dynhta.ads)
16208 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
16209 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
16210 @cindex Hash tables
16213 A generic implementation of hash tables that can be used to hash arbitrary
16214 data. Provided in two forms, a simple form with built in hash functions,
16215 and a more complex form in which the hash function is supplied.
16218 This package provides a facility similar to that of @code{GNAT.HTable},
16219 except that this package declares a type that can be used to define
16220 dynamic instances of the hash table, while an instantiation of
16221 @code{GNAT.HTable} creates a single instance of the hash table.
16223 @node GNAT.Dynamic_Tables (g-dyntab.ads)
16224 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
16225 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
16226 @cindex Table implementation
16227 @cindex Arrays, extendable
16230 A generic package providing a single dimension array abstraction where the
16231 length of the array can be dynamically modified.
16234 This package provides a facility similar to that of @code{GNAT.Table},
16235 except that this package declares a type that can be used to define
16236 dynamic instances of the table, while an instantiation of
16237 @code{GNAT.Table} creates a single instance of the table type.
16239 @node GNAT.Encode_String (g-encstr.ads)
16240 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
16241 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
16242 @cindex Encoding strings
16243 @cindex String encoding
16244 @cindex Wide character encoding
16249 A generic package providing routines for encoding wide character and wide
16250 wide character strings as sequences of 8-bit characters using a specified
16251 encoding method. Useful in conjunction with Unicode character coding.
16252 Note there is a preinstantiation for UTF-8. See next entry.
16254 @node GNAT.Encode_UTF8_String (g-enutst.ads)
16255 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
16256 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
16257 @cindex Encoding strings
16258 @cindex Encoding UTF-8 strings
16259 @cindex UTF-8 string encoding
16260 @cindex Wide character encoding
16265 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
16267 @node GNAT.Exception_Actions (g-excact.ads)
16268 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
16269 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
16270 @cindex Exception actions
16273 Provides callbacks when an exception is raised. Callbacks can be registered
16274 for specific exceptions, or when any exception is raised. This
16275 can be used for instance to force a core dump to ease debugging.
16277 @node GNAT.Exception_Traces (g-exctra.ads)
16278 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
16279 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
16280 @cindex Exception traces
16284 Provides an interface allowing to control automatic output upon exception
16287 @node GNAT.Exceptions (g-except.ads)
16288 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
16289 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
16290 @cindex Exceptions, Pure
16291 @cindex Pure packages, exceptions
16294 Normally it is not possible to raise an exception with
16295 a message from a subprogram in a pure package, since the
16296 necessary types and subprograms are in @code{Ada.Exceptions}
16297 which is not a pure unit. @code{GNAT.Exceptions} provides a
16298 facility for getting around this limitation for a few
16299 predefined exceptions, and for example allow raising
16300 @code{Constraint_Error} with a message from a pure subprogram.
16302 @node GNAT.Expect (g-expect.ads)
16303 @section @code{GNAT.Expect} (@file{g-expect.ads})
16304 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
16307 Provides a set of subprograms similar to what is available
16308 with the standard Tcl Expect tool.
16309 It allows you to easily spawn and communicate with an external process.
16310 You can send commands or inputs to the process, and compare the output
16311 with some expected regular expression. Currently @code{GNAT.Expect}
16312 is implemented on all native GNAT ports except for OpenVMS@.
16313 It is not implemented for cross ports, and in particular is not
16314 implemented for VxWorks or LynxOS@.
16316 @node GNAT.Expect.TTY (g-exptty.ads)
16317 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
16318 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
16321 As GNAT.Expect but using pseudo-terminal.
16322 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
16323 ports except for OpenVMS@. It is not implemented for cross ports, and
16324 in particular is not implemented for VxWorks or LynxOS@.
16326 @node GNAT.Float_Control (g-flocon.ads)
16327 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
16328 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
16329 @cindex Floating-Point Processor
16332 Provides an interface for resetting the floating-point processor into the
16333 mode required for correct semantic operation in Ada. Some third party
16334 library calls may cause this mode to be modified, and the Reset procedure
16335 in this package can be used to reestablish the required mode.
16337 @node GNAT.Heap_Sort (g-heasor.ads)
16338 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
16339 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
16343 Provides a general implementation of heap sort usable for sorting arbitrary
16344 data items. Exchange and comparison procedures are provided by passing
16345 access-to-procedure values. The algorithm used is a modified heap sort
16346 that performs approximately N*log(N) comparisons in the worst case.
16348 @node GNAT.Heap_Sort_A (g-hesora.ads)
16349 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
16350 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
16354 Provides a general implementation of heap sort usable for sorting arbitrary
16355 data items. Move and comparison procedures are provided by passing
16356 access-to-procedure values. The algorithm used is a modified heap sort
16357 that performs approximately N*log(N) comparisons in the worst case.
16358 This differs from @code{GNAT.Heap_Sort} in having a less convenient
16359 interface, but may be slightly more efficient.
16361 @node GNAT.Heap_Sort_G (g-hesorg.ads)
16362 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
16363 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
16367 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
16368 are provided as generic parameters, this improves efficiency, especially
16369 if the procedures can be inlined, at the expense of duplicating code for
16370 multiple instantiations.
16372 @node GNAT.HTable (g-htable.ads)
16373 @section @code{GNAT.HTable} (@file{g-htable.ads})
16374 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
16375 @cindex Hash tables
16378 A generic implementation of hash tables that can be used to hash arbitrary
16379 data. Provides two approaches, one a simple static approach, and the other
16380 allowing arbitrary dynamic hash tables.
16382 @node GNAT.IO (g-io.ads)
16383 @section @code{GNAT.IO} (@file{g-io.ads})
16384 @cindex @code{GNAT.IO} (@file{g-io.ads})
16386 @cindex Input/Output facilities
16389 A simple preelaborable input-output package that provides a subset of
16390 simple Text_IO functions for reading characters and strings from
16391 Standard_Input, and writing characters, strings and integers to either
16392 Standard_Output or Standard_Error.
16394 @node GNAT.IO_Aux (g-io_aux.ads)
16395 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
16396 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
16398 @cindex Input/Output facilities
16400 Provides some auxiliary functions for use with Text_IO, including a test
16401 for whether a file exists, and functions for reading a line of text.
16403 @node GNAT.Lock_Files (g-locfil.ads)
16404 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
16405 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
16406 @cindex File locking
16407 @cindex Locking using files
16410 Provides a general interface for using files as locks. Can be used for
16411 providing program level synchronization.
16413 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
16414 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
16415 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
16416 @cindex Random number generation
16419 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
16420 a modified version of the Blum-Blum-Shub generator.
16422 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
16423 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
16424 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
16425 @cindex Random number generation
16428 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
16429 a modified version of the Blum-Blum-Shub generator.
16431 @node GNAT.MD5 (g-md5.ads)
16432 @section @code{GNAT.MD5} (@file{g-md5.ads})
16433 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
16434 @cindex Message Digest MD5
16437 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
16439 @node GNAT.Memory_Dump (g-memdum.ads)
16440 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
16441 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
16442 @cindex Dump Memory
16445 Provides a convenient routine for dumping raw memory to either the
16446 standard output or standard error files. Uses GNAT.IO for actual
16449 @node GNAT.Most_Recent_Exception (g-moreex.ads)
16450 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
16451 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
16452 @cindex Exception, obtaining most recent
16455 Provides access to the most recently raised exception. Can be used for
16456 various logging purposes, including duplicating functionality of some
16457 Ada 83 implementation dependent extensions.
16459 @node GNAT.OS_Lib (g-os_lib.ads)
16460 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
16461 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
16462 @cindex Operating System interface
16463 @cindex Spawn capability
16466 Provides a range of target independent operating system interface functions,
16467 including time/date management, file operations, subprocess management,
16468 including a portable spawn procedure, and access to environment variables
16469 and error return codes.
16471 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
16472 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
16473 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
16474 @cindex Hash functions
16477 Provides a generator of static minimal perfect hash functions. No
16478 collisions occur and each item can be retrieved from the table in one
16479 probe (perfect property). The hash table size corresponds to the exact
16480 size of the key set and no larger (minimal property). The key set has to
16481 be know in advance (static property). The hash functions are also order
16482 preserving. If w2 is inserted after w1 in the generator, their
16483 hashcode are in the same order. These hashing functions are very
16484 convenient for use with realtime applications.
16486 @node GNAT.Random_Numbers (g-rannum.ads)
16487 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
16488 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
16489 @cindex Random number generation
16492 Provides random number capabilities which extend those available in the
16493 standard Ada library and are more convenient to use.
16495 @node GNAT.Regexp (g-regexp.ads)
16496 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
16497 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
16498 @cindex Regular expressions
16499 @cindex Pattern matching
16502 A simple implementation of regular expressions, using a subset of regular
16503 expression syntax copied from familiar Unix style utilities. This is the
16504 simples of the three pattern matching packages provided, and is particularly
16505 suitable for ``file globbing'' applications.
16507 @node GNAT.Registry (g-regist.ads)
16508 @section @code{GNAT.Registry} (@file{g-regist.ads})
16509 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
16510 @cindex Windows Registry
16513 This is a high level binding to the Windows registry. It is possible to
16514 do simple things like reading a key value, creating a new key. For full
16515 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
16516 package provided with the Win32Ada binding
16518 @node GNAT.Regpat (g-regpat.ads)
16519 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
16520 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
16521 @cindex Regular expressions
16522 @cindex Pattern matching
16525 A complete implementation of Unix-style regular expression matching, copied
16526 from the original V7 style regular expression library written in C by
16527 Henry Spencer (and binary compatible with this C library).
16529 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
16530 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16531 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16532 @cindex Secondary Stack Info
16535 Provide the capability to query the high water mark of the current task's
16538 @node GNAT.Semaphores (g-semaph.ads)
16539 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
16540 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
16544 Provides classic counting and binary semaphores using protected types.
16546 @node GNAT.Serial_Communications (g-sercom.ads)
16547 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16548 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16549 @cindex Serial_Communications
16552 Provides a simple interface to send and receive data over a serial
16553 port. This is only supported on GNU/Linux and Windows.
16555 @node GNAT.SHA1 (g-sha1.ads)
16556 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
16557 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
16558 @cindex Secure Hash Algorithm SHA-1
16561 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
16564 @node GNAT.SHA224 (g-sha224.ads)
16565 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
16566 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
16567 @cindex Secure Hash Algorithm SHA-224
16570 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
16572 @node GNAT.SHA256 (g-sha256.ads)
16573 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
16574 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
16575 @cindex Secure Hash Algorithm SHA-256
16578 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
16580 @node GNAT.SHA384 (g-sha384.ads)
16581 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
16582 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
16583 @cindex Secure Hash Algorithm SHA-384
16586 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
16588 @node GNAT.SHA512 (g-sha512.ads)
16589 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
16590 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
16591 @cindex Secure Hash Algorithm SHA-512
16594 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
16596 @node GNAT.Signals (g-signal.ads)
16597 @section @code{GNAT.Signals} (@file{g-signal.ads})
16598 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
16602 Provides the ability to manipulate the blocked status of signals on supported
16605 @node GNAT.Sockets (g-socket.ads)
16606 @section @code{GNAT.Sockets} (@file{g-socket.ads})
16607 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
16611 A high level and portable interface to develop sockets based applications.
16612 This package is based on the sockets thin binding found in
16613 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
16614 on all native GNAT ports except for OpenVMS@. It is not implemented
16615 for the LynxOS@ cross port.
16617 @node GNAT.Source_Info (g-souinf.ads)
16618 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
16619 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
16620 @cindex Source Information
16623 Provides subprograms that give access to source code information known at
16624 compile time, such as the current file name and line number.
16626 @node GNAT.Spelling_Checker (g-speche.ads)
16627 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16628 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16629 @cindex Spell checking
16632 Provides a function for determining whether one string is a plausible
16633 near misspelling of another string.
16635 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
16636 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16637 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16638 @cindex Spell checking
16641 Provides a generic function that can be instantiated with a string type for
16642 determining whether one string is a plausible near misspelling of another
16645 @node GNAT.Spitbol.Patterns (g-spipat.ads)
16646 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16647 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16648 @cindex SPITBOL pattern matching
16649 @cindex Pattern matching
16652 A complete implementation of SNOBOL4 style pattern matching. This is the
16653 most elaborate of the pattern matching packages provided. It fully duplicates
16654 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
16655 efficient algorithm developed by Robert Dewar for the SPITBOL system.
16657 @node GNAT.Spitbol (g-spitbo.ads)
16658 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16659 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16660 @cindex SPITBOL interface
16663 The top level package of the collection of SPITBOL-style functionality, this
16664 package provides basic SNOBOL4 string manipulation functions, such as
16665 Pad, Reverse, Trim, Substr capability, as well as a generic table function
16666 useful for constructing arbitrary mappings from strings in the style of
16667 the SNOBOL4 TABLE function.
16669 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
16670 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16671 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16672 @cindex Sets of strings
16673 @cindex SPITBOL Tables
16676 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16677 for type @code{Standard.Boolean}, giving an implementation of sets of
16680 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
16681 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16682 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16683 @cindex Integer maps
16685 @cindex SPITBOL Tables
16688 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16689 for type @code{Standard.Integer}, giving an implementation of maps
16690 from string to integer values.
16692 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
16693 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16694 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16695 @cindex String maps
16697 @cindex SPITBOL Tables
16700 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
16701 a variable length string type, giving an implementation of general
16702 maps from strings to strings.
16704 @node GNAT.SSE (g-sse.ads)
16705 @section @code{GNAT.SSE} (@file{g-sse.ads})
16706 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
16709 Root of a set of units aimed at offering Ada bindings to a subset of
16710 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
16711 targets. It exposes vector component types together with a general
16712 introduction to the binding contents and use.
16714 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
16715 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16716 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16719 SSE vector types for use with SSE related intrinsics.
16721 @node GNAT.Strings (g-string.ads)
16722 @section @code{GNAT.Strings} (@file{g-string.ads})
16723 @cindex @code{GNAT.Strings} (@file{g-string.ads})
16726 Common String access types and related subprograms. Basically it
16727 defines a string access and an array of string access types.
16729 @node GNAT.String_Split (g-strspl.ads)
16730 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
16731 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
16732 @cindex String splitter
16735 Useful string manipulation routines: given a set of separators, split
16736 a string wherever the separators appear, and provide direct access
16737 to the resulting slices. This package is instantiated from
16738 @code{GNAT.Array_Split}.
16740 @node GNAT.Table (g-table.ads)
16741 @section @code{GNAT.Table} (@file{g-table.ads})
16742 @cindex @code{GNAT.Table} (@file{g-table.ads})
16743 @cindex Table implementation
16744 @cindex Arrays, extendable
16747 A generic package providing a single dimension array abstraction where the
16748 length of the array can be dynamically modified.
16751 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
16752 except that this package declares a single instance of the table type,
16753 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
16754 used to define dynamic instances of the table.
16756 @node GNAT.Task_Lock (g-tasloc.ads)
16757 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16758 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16759 @cindex Task synchronization
16760 @cindex Task locking
16764 A very simple facility for locking and unlocking sections of code using a
16765 single global task lock. Appropriate for use in situations where contention
16766 between tasks is very rarely expected.
16768 @node GNAT.Time_Stamp (g-timsta.ads)
16769 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16770 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16772 @cindex Current time
16775 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
16776 represents the current date and time in ISO 8601 format. This is a very simple
16777 routine with minimal code and there are no dependencies on any other unit.
16779 @node GNAT.Threads (g-thread.ads)
16780 @section @code{GNAT.Threads} (@file{g-thread.ads})
16781 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
16782 @cindex Foreign threads
16783 @cindex Threads, foreign
16786 Provides facilities for dealing with foreign threads which need to be known
16787 by the GNAT run-time system. Consult the documentation of this package for
16788 further details if your program has threads that are created by a non-Ada
16789 environment which then accesses Ada code.
16791 @node GNAT.Traceback (g-traceb.ads)
16792 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
16793 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
16794 @cindex Trace back facilities
16797 Provides a facility for obtaining non-symbolic traceback information, useful
16798 in various debugging situations.
16800 @node GNAT.Traceback.Symbolic (g-trasym.ads)
16801 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16802 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16803 @cindex Trace back facilities
16805 @node GNAT.UTF_32 (g-utf_32.ads)
16806 @section @code{GNAT.UTF_32} (@file{g-table.ads})
16807 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
16808 @cindex Wide character codes
16811 This is a package intended to be used in conjunction with the
16812 @code{Wide_Character} type in Ada 95 and the
16813 @code{Wide_Wide_Character} type in Ada 2005 (available
16814 in @code{GNAT} in Ada 2005 mode). This package contains
16815 Unicode categorization routines, as well as lexical
16816 categorization routines corresponding to the Ada 2005
16817 lexical rules for identifiers and strings, and also a
16818 lower case to upper case fold routine corresponding to
16819 the Ada 2005 rules for identifier equivalence.
16821 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
16822 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16823 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16824 @cindex Spell checking
16827 Provides a function for determining whether one wide wide string is a plausible
16828 near misspelling of another wide wide string, where the strings are represented
16829 using the UTF_32_String type defined in System.Wch_Cnv.
16831 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
16832 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16833 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16834 @cindex Spell checking
16837 Provides a function for determining whether one wide string is a plausible
16838 near misspelling of another wide string.
16840 @node GNAT.Wide_String_Split (g-wistsp.ads)
16841 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16842 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16843 @cindex Wide_String splitter
16846 Useful wide string manipulation routines: given a set of separators, split
16847 a wide string wherever the separators appear, and provide direct access
16848 to the resulting slices. This package is instantiated from
16849 @code{GNAT.Array_Split}.
16851 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
16852 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16853 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16854 @cindex Spell checking
16857 Provides a function for determining whether one wide wide string is a plausible
16858 near misspelling of another wide wide string.
16860 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
16861 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16862 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16863 @cindex Wide_Wide_String splitter
16866 Useful wide wide string manipulation routines: given a set of separators, split
16867 a wide wide string wherever the separators appear, and provide direct access
16868 to the resulting slices. This package is instantiated from
16869 @code{GNAT.Array_Split}.
16871 @node Interfaces.C.Extensions (i-cexten.ads)
16872 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16873 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16876 This package contains additional C-related definitions, intended
16877 for use with either manually or automatically generated bindings
16880 @node Interfaces.C.Streams (i-cstrea.ads)
16881 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16882 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16883 @cindex C streams, interfacing
16886 This package is a binding for the most commonly used operations
16889 @node Interfaces.CPP (i-cpp.ads)
16890 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
16891 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
16892 @cindex C++ interfacing
16893 @cindex Interfacing, to C++
16896 This package provides facilities for use in interfacing to C++. It
16897 is primarily intended to be used in connection with automated tools
16898 for the generation of C++ interfaces.
16900 @node Interfaces.Packed_Decimal (i-pacdec.ads)
16901 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16902 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16903 @cindex IBM Packed Format
16904 @cindex Packed Decimal
16907 This package provides a set of routines for conversions to and
16908 from a packed decimal format compatible with that used on IBM
16911 @node Interfaces.VxWorks (i-vxwork.ads)
16912 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16913 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16914 @cindex Interfacing to VxWorks
16915 @cindex VxWorks, interfacing
16918 This package provides a limited binding to the VxWorks API.
16919 In particular, it interfaces with the
16920 VxWorks hardware interrupt facilities.
16922 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
16923 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16924 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16925 @cindex Interfacing to VxWorks' I/O
16926 @cindex VxWorks, I/O interfacing
16927 @cindex VxWorks, Get_Immediate
16928 @cindex Get_Immediate, VxWorks
16931 This package provides a binding to the ioctl (IO/Control)
16932 function of VxWorks, defining a set of option values and
16933 function codes. A particular use of this package is
16934 to enable the use of Get_Immediate under VxWorks.
16936 @node System.Address_Image (s-addima.ads)
16937 @section @code{System.Address_Image} (@file{s-addima.ads})
16938 @cindex @code{System.Address_Image} (@file{s-addima.ads})
16939 @cindex Address image
16940 @cindex Image, of an address
16943 This function provides a useful debugging
16944 function that gives an (implementation dependent)
16945 string which identifies an address.
16947 @node System.Assertions (s-assert.ads)
16948 @section @code{System.Assertions} (@file{s-assert.ads})
16949 @cindex @code{System.Assertions} (@file{s-assert.ads})
16951 @cindex Assert_Failure, exception
16954 This package provides the declaration of the exception raised
16955 by an run-time assertion failure, as well as the routine that
16956 is used internally to raise this assertion.
16958 @node System.Memory (s-memory.ads)
16959 @section @code{System.Memory} (@file{s-memory.ads})
16960 @cindex @code{System.Memory} (@file{s-memory.ads})
16961 @cindex Memory allocation
16964 This package provides the interface to the low level routines used
16965 by the generated code for allocation and freeing storage for the
16966 default storage pool (analogous to the C routines malloc and free.
16967 It also provides a reallocation interface analogous to the C routine
16968 realloc. The body of this unit may be modified to provide alternative
16969 allocation mechanisms for the default pool, and in addition, direct
16970 calls to this unit may be made for low level allocation uses (for
16971 example see the body of @code{GNAT.Tables}).
16973 @node System.Partition_Interface (s-parint.ads)
16974 @section @code{System.Partition_Interface} (@file{s-parint.ads})
16975 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
16976 @cindex Partition interfacing functions
16979 This package provides facilities for partition interfacing. It
16980 is used primarily in a distribution context when using Annex E
16983 @node System.Pool_Global (s-pooglo.ads)
16984 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
16985 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
16986 @cindex Storage pool, global
16987 @cindex Global storage pool
16990 This package provides a storage pool that is equivalent to the default
16991 storage pool used for access types for which no pool is specifically
16992 declared. It uses malloc/free to allocate/free and does not attempt to
16993 do any automatic reclamation.
16995 @node System.Pool_Local (s-pooloc.ads)
16996 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
16997 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
16998 @cindex Storage pool, local
16999 @cindex Local storage pool
17002 This package provides a storage pool that is intended for use with locally
17003 defined access types. It uses malloc/free for allocate/free, and maintains
17004 a list of allocated blocks, so that all storage allocated for the pool can
17005 be freed automatically when the pool is finalized.
17007 @node System.Restrictions (s-restri.ads)
17008 @section @code{System.Restrictions} (@file{s-restri.ads})
17009 @cindex @code{System.Restrictions} (@file{s-restri.ads})
17010 @cindex Run-time restrictions access
17013 This package provides facilities for accessing at run time
17014 the status of restrictions specified at compile time for
17015 the partition. Information is available both with regard
17016 to actual restrictions specified, and with regard to
17017 compiler determined information on which restrictions
17018 are violated by one or more packages in the partition.
17020 @node System.Rident (s-rident.ads)
17021 @section @code{System.Rident} (@file{s-rident.ads})
17022 @cindex @code{System.Rident} (@file{s-rident.ads})
17023 @cindex Restrictions definitions
17026 This package provides definitions of the restrictions
17027 identifiers supported by GNAT, and also the format of
17028 the restrictions provided in package System.Restrictions.
17029 It is not normally necessary to @code{with} this generic package
17030 since the necessary instantiation is included in
17031 package System.Restrictions.
17033 @node System.Strings.Stream_Ops (s-ststop.ads)
17034 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
17035 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
17036 @cindex Stream operations
17037 @cindex String stream operations
17040 This package provides a set of stream subprograms for standard string types.
17041 It is intended primarily to support implicit use of such subprograms when
17042 stream attributes are applied to string types, but the subprograms in this
17043 package can be used directly by application programs.
17045 @node System.Task_Info (s-tasinf.ads)
17046 @section @code{System.Task_Info} (@file{s-tasinf.ads})
17047 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
17048 @cindex Task_Info pragma
17051 This package provides target dependent functionality that is used
17052 to support the @code{Task_Info} pragma
17054 @node System.Wch_Cnv (s-wchcnv.ads)
17055 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
17056 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
17057 @cindex Wide Character, Representation
17058 @cindex Wide String, Conversion
17059 @cindex Representation of wide characters
17062 This package provides routines for converting between
17063 wide and wide wide characters and a representation as a value of type
17064 @code{Standard.String}, using a specified wide character
17065 encoding method. It uses definitions in
17066 package @code{System.Wch_Con}.
17068 @node System.Wch_Con (s-wchcon.ads)
17069 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
17070 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
17073 This package provides definitions and descriptions of
17074 the various methods used for encoding wide characters
17075 in ordinary strings. These definitions are used by
17076 the package @code{System.Wch_Cnv}.
17078 @node Interfacing to Other Languages
17079 @chapter Interfacing to Other Languages
17081 The facilities in annex B of the Ada Reference Manual are fully
17082 implemented in GNAT, and in addition, a full interface to C++ is
17086 * Interfacing to C::
17087 * Interfacing to C++::
17088 * Interfacing to COBOL::
17089 * Interfacing to Fortran::
17090 * Interfacing to non-GNAT Ada code::
17093 @node Interfacing to C
17094 @section Interfacing to C
17097 Interfacing to C with GNAT can use one of two approaches:
17101 The types in the package @code{Interfaces.C} may be used.
17103 Standard Ada types may be used directly. This may be less portable to
17104 other compilers, but will work on all GNAT compilers, which guarantee
17105 correspondence between the C and Ada types.
17109 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
17110 effect, since this is the default. The following table shows the
17111 correspondence between Ada scalar types and the corresponding C types.
17116 @item Short_Integer
17118 @item Short_Short_Integer
17122 @item Long_Long_Integer
17130 @item Long_Long_Float
17131 This is the longest floating-point type supported by the hardware.
17135 Additionally, there are the following general correspondences between Ada
17139 Ada enumeration types map to C enumeration types directly if pragma
17140 @code{Convention C} is specified, which causes them to have int
17141 length. Without pragma @code{Convention C}, Ada enumeration types map to
17142 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
17143 @code{int}, respectively) depending on the number of values passed.
17144 This is the only case in which pragma @code{Convention C} affects the
17145 representation of an Ada type.
17148 Ada access types map to C pointers, except for the case of pointers to
17149 unconstrained types in Ada, which have no direct C equivalent.
17152 Ada arrays map directly to C arrays.
17155 Ada records map directly to C structures.
17158 Packed Ada records map to C structures where all members are bit fields
17159 of the length corresponding to the @code{@var{type}'Size} value in Ada.
17162 @node Interfacing to C++
17163 @section Interfacing to C++
17166 The interface to C++ makes use of the following pragmas, which are
17167 primarily intended to be constructed automatically using a binding generator
17168 tool, although it is possible to construct them by hand.
17170 Using these pragmas it is possible to achieve complete
17171 inter-operability between Ada tagged types and C++ class definitions.
17172 See @ref{Implementation Defined Pragmas}, for more details.
17175 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
17176 The argument denotes an entity in the current declarative region that is
17177 declared as a tagged or untagged record type. It indicates that the type
17178 corresponds to an externally declared C++ class type, and is to be laid
17179 out the same way that C++ would lay out the type.
17181 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
17182 for backward compatibility but its functionality is available
17183 using pragma @code{Import} with @code{Convention} = @code{CPP}.
17185 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
17186 This pragma identifies an imported function (imported in the usual way
17187 with pragma @code{Import}) as corresponding to a C++ constructor.
17190 A few restrictions are placed on the use of the @code{Access} attribute
17191 in conjunction with subprograms subject to convention @code{CPP}: the
17192 attribute may be used neither on primitive operations of a tagged
17193 record type with convention @code{CPP}, imported or not, nor on
17194 subprograms imported with pragma @code{CPP_Constructor}.
17196 In addition, C++ exceptions are propagated and can be handled in an
17197 @code{others} choice of an exception handler. The corresponding Ada
17198 occurrence has no message, and the simple name of the exception identity
17199 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
17200 tasks works properly when such foreign exceptions are propagated.
17202 @node Interfacing to COBOL
17203 @section Interfacing to COBOL
17206 Interfacing to COBOL is achieved as described in section B.4 of
17207 the Ada Reference Manual.
17209 @node Interfacing to Fortran
17210 @section Interfacing to Fortran
17213 Interfacing to Fortran is achieved as described in section B.5 of the
17214 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
17215 multi-dimensional array causes the array to be stored in column-major
17216 order as required for convenient interface to Fortran.
17218 @node Interfacing to non-GNAT Ada code
17219 @section Interfacing to non-GNAT Ada code
17221 It is possible to specify the convention @code{Ada} in a pragma
17222 @code{Import} or pragma @code{Export}. However this refers to
17223 the calling conventions used by GNAT, which may or may not be
17224 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
17225 compiler to allow interoperation.
17227 If arguments types are kept simple, and if the foreign compiler generally
17228 follows system calling conventions, then it may be possible to integrate
17229 files compiled by other Ada compilers, provided that the elaboration
17230 issues are adequately addressed (for example by eliminating the
17231 need for any load time elaboration).
17233 In particular, GNAT running on VMS is designed to
17234 be highly compatible with the DEC Ada 83 compiler, so this is one
17235 case in which it is possible to import foreign units of this type,
17236 provided that the data items passed are restricted to simple scalar
17237 values or simple record types without variants, or simple array
17238 types with fixed bounds.
17240 @node Specialized Needs Annexes
17241 @chapter Specialized Needs Annexes
17244 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
17245 required in all implementations. However, as described in this chapter,
17246 GNAT implements all of these annexes:
17249 @item Systems Programming (Annex C)
17250 The Systems Programming Annex is fully implemented.
17252 @item Real-Time Systems (Annex D)
17253 The Real-Time Systems Annex is fully implemented.
17255 @item Distributed Systems (Annex E)
17256 Stub generation is fully implemented in the GNAT compiler. In addition,
17257 a complete compatible PCS is available as part of the GLADE system,
17258 a separate product. When the two
17259 products are used in conjunction, this annex is fully implemented.
17261 @item Information Systems (Annex F)
17262 The Information Systems annex is fully implemented.
17264 @item Numerics (Annex G)
17265 The Numerics Annex is fully implemented.
17267 @item Safety and Security / High-Integrity Systems (Annex H)
17268 The Safety and Security Annex (termed the High-Integrity Systems Annex
17269 in Ada 2005) is fully implemented.
17272 @node Implementation of Specific Ada Features
17273 @chapter Implementation of Specific Ada Features
17276 This chapter describes the GNAT implementation of several Ada language
17280 * Machine Code Insertions::
17281 * GNAT Implementation of Tasking::
17282 * GNAT Implementation of Shared Passive Packages::
17283 * Code Generation for Array Aggregates::
17284 * The Size of Discriminated Records with Default Discriminants::
17285 * Strict Conformance to the Ada Reference Manual::
17288 @node Machine Code Insertions
17289 @section Machine Code Insertions
17290 @cindex Machine Code insertions
17293 Package @code{Machine_Code} provides machine code support as described
17294 in the Ada Reference Manual in two separate forms:
17297 Machine code statements, consisting of qualified expressions that
17298 fit the requirements of RM section 13.8.
17300 An intrinsic callable procedure, providing an alternative mechanism of
17301 including machine instructions in a subprogram.
17305 The two features are similar, and both are closely related to the mechanism
17306 provided by the asm instruction in the GNU C compiler. Full understanding
17307 and use of the facilities in this package requires understanding the asm
17308 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
17309 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
17311 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
17312 semantic restrictions and effects as described below. Both are provided so
17313 that the procedure call can be used as a statement, and the function call
17314 can be used to form a code_statement.
17316 The first example given in the GCC documentation is the C @code{asm}
17319 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
17323 The equivalent can be written for GNAT as:
17325 @smallexample @c ada
17326 Asm ("fsinx %1 %0",
17327 My_Float'Asm_Output ("=f", result),
17328 My_Float'Asm_Input ("f", angle));
17332 The first argument to @code{Asm} is the assembler template, and is
17333 identical to what is used in GNU C@. This string must be a static
17334 expression. The second argument is the output operand list. It is
17335 either a single @code{Asm_Output} attribute reference, or a list of such
17336 references enclosed in parentheses (technically an array aggregate of
17339 The @code{Asm_Output} attribute denotes a function that takes two
17340 parameters. The first is a string, the second is the name of a variable
17341 of the type designated by the attribute prefix. The first (string)
17342 argument is required to be a static expression and designates the
17343 constraint for the parameter (e.g.@: what kind of register is
17344 required). The second argument is the variable to be updated with the
17345 result. The possible values for constraint are the same as those used in
17346 the RTL, and are dependent on the configuration file used to build the
17347 GCC back end. If there are no output operands, then this argument may
17348 either be omitted, or explicitly given as @code{No_Output_Operands}.
17350 The second argument of @code{@var{my_float}'Asm_Output} functions as
17351 though it were an @code{out} parameter, which is a little curious, but
17352 all names have the form of expressions, so there is no syntactic
17353 irregularity, even though normally functions would not be permitted
17354 @code{out} parameters. The third argument is the list of input
17355 operands. It is either a single @code{Asm_Input} attribute reference, or
17356 a list of such references enclosed in parentheses (technically an array
17357 aggregate of such references).
17359 The @code{Asm_Input} attribute denotes a function that takes two
17360 parameters. The first is a string, the second is an expression of the
17361 type designated by the prefix. The first (string) argument is required
17362 to be a static expression, and is the constraint for the parameter,
17363 (e.g.@: what kind of register is required). The second argument is the
17364 value to be used as the input argument. The possible values for the
17365 constant are the same as those used in the RTL, and are dependent on
17366 the configuration file used to built the GCC back end.
17368 If there are no input operands, this argument may either be omitted, or
17369 explicitly given as @code{No_Input_Operands}. The fourth argument, not
17370 present in the above example, is a list of register names, called the
17371 @dfn{clobber} argument. This argument, if given, must be a static string
17372 expression, and is a space or comma separated list of names of registers
17373 that must be considered destroyed as a result of the @code{Asm} call. If
17374 this argument is the null string (the default value), then the code
17375 generator assumes that no additional registers are destroyed.
17377 The fifth argument, not present in the above example, called the
17378 @dfn{volatile} argument, is by default @code{False}. It can be set to
17379 the literal value @code{True} to indicate to the code generator that all
17380 optimizations with respect to the instruction specified should be
17381 suppressed, and that in particular, for an instruction that has outputs,
17382 the instruction will still be generated, even if none of the outputs are
17383 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
17384 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
17385 Generally it is strongly advisable to use Volatile for any ASM statement
17386 that is missing either input or output operands, or when two or more ASM
17387 statements appear in sequence, to avoid unwanted optimizations. A warning
17388 is generated if this advice is not followed.
17390 The @code{Asm} subprograms may be used in two ways. First the procedure
17391 forms can be used anywhere a procedure call would be valid, and
17392 correspond to what the RM calls ``intrinsic'' routines. Such calls can
17393 be used to intersperse machine instructions with other Ada statements.
17394 Second, the function forms, which return a dummy value of the limited
17395 private type @code{Asm_Insn}, can be used in code statements, and indeed
17396 this is the only context where such calls are allowed. Code statements
17397 appear as aggregates of the form:
17399 @smallexample @c ada
17400 Asm_Insn'(Asm (@dots{}));
17401 Asm_Insn'(Asm_Volatile (@dots{}));
17405 In accordance with RM rules, such code statements are allowed only
17406 within subprograms whose entire body consists of such statements. It is
17407 not permissible to intermix such statements with other Ada statements.
17409 Typically the form using intrinsic procedure calls is more convenient
17410 and more flexible. The code statement form is provided to meet the RM
17411 suggestion that such a facility should be made available. The following
17412 is the exact syntax of the call to @code{Asm}. As usual, if named notation
17413 is used, the arguments may be given in arbitrary order, following the
17414 normal rules for use of positional and named arguments)
17418 [Template =>] static_string_EXPRESSION
17419 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
17420 [,[Inputs =>] INPUT_OPERAND_LIST ]
17421 [,[Clobber =>] static_string_EXPRESSION ]
17422 [,[Volatile =>] static_boolean_EXPRESSION] )
17424 OUTPUT_OPERAND_LIST ::=
17425 [PREFIX.]No_Output_Operands
17426 | OUTPUT_OPERAND_ATTRIBUTE
17427 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
17429 OUTPUT_OPERAND_ATTRIBUTE ::=
17430 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
17432 INPUT_OPERAND_LIST ::=
17433 [PREFIX.]No_Input_Operands
17434 | INPUT_OPERAND_ATTRIBUTE
17435 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
17437 INPUT_OPERAND_ATTRIBUTE ::=
17438 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
17442 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
17443 are declared in the package @code{Machine_Code} and must be referenced
17444 according to normal visibility rules. In particular if there is no
17445 @code{use} clause for this package, then appropriate package name
17446 qualification is required.
17448 @node GNAT Implementation of Tasking
17449 @section GNAT Implementation of Tasking
17452 This chapter outlines the basic GNAT approach to tasking (in particular,
17453 a multi-layered library for portability) and discusses issues related
17454 to compliance with the Real-Time Systems Annex.
17457 * Mapping Ada Tasks onto the Underlying Kernel Threads::
17458 * Ensuring Compliance with the Real-Time Annex::
17461 @node Mapping Ada Tasks onto the Underlying Kernel Threads
17462 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
17465 GNAT's run-time support comprises two layers:
17468 @item GNARL (GNAT Run-time Layer)
17469 @item GNULL (GNAT Low-level Library)
17473 In GNAT, Ada's tasking services rely on a platform and OS independent
17474 layer known as GNARL@. This code is responsible for implementing the
17475 correct semantics of Ada's task creation, rendezvous, protected
17478 GNARL decomposes Ada's tasking semantics into simpler lower level
17479 operations such as create a thread, set the priority of a thread,
17480 yield, create a lock, lock/unlock, etc. The spec for these low-level
17481 operations constitutes GNULLI, the GNULL Interface. This interface is
17482 directly inspired from the POSIX real-time API@.
17484 If the underlying executive or OS implements the POSIX standard
17485 faithfully, the GNULL Interface maps as is to the services offered by
17486 the underlying kernel. Otherwise, some target dependent glue code maps
17487 the services offered by the underlying kernel to the semantics expected
17490 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
17491 key point is that each Ada task is mapped on a thread in the underlying
17492 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
17494 In addition Ada task priorities map onto the underlying thread priorities.
17495 Mapping Ada tasks onto the underlying kernel threads has several advantages:
17499 The underlying scheduler is used to schedule the Ada tasks. This
17500 makes Ada tasks as efficient as kernel threads from a scheduling
17504 Interaction with code written in C containing threads is eased
17505 since at the lowest level Ada tasks and C threads map onto the same
17506 underlying kernel concept.
17509 When an Ada task is blocked during I/O the remaining Ada tasks are
17513 On multiprocessor systems Ada tasks can execute in parallel.
17517 Some threads libraries offer a mechanism to fork a new process, with the
17518 child process duplicating the threads from the parent.
17520 support this functionality when the parent contains more than one task.
17521 @cindex Forking a new process
17523 @node Ensuring Compliance with the Real-Time Annex
17524 @subsection Ensuring Compliance with the Real-Time Annex
17525 @cindex Real-Time Systems Annex compliance
17528 Although mapping Ada tasks onto
17529 the underlying threads has significant advantages, it does create some
17530 complications when it comes to respecting the scheduling semantics
17531 specified in the real-time annex (Annex D).
17533 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
17534 scheduling policy states:
17537 @emph{When the active priority of a ready task that is not running
17538 changes, or the setting of its base priority takes effect, the
17539 task is removed from the ready queue for its old active priority
17540 and is added at the tail of the ready queue for its new active
17541 priority, except in the case where the active priority is lowered
17542 due to the loss of inherited priority, in which case the task is
17543 added at the head of the ready queue for its new active priority.}
17547 While most kernels do put tasks at the end of the priority queue when
17548 a task changes its priority, (which respects the main
17549 FIFO_Within_Priorities requirement), almost none keep a thread at the
17550 beginning of its priority queue when its priority drops from the loss
17551 of inherited priority.
17553 As a result most vendors have provided incomplete Annex D implementations.
17555 The GNAT run-time, has a nice cooperative solution to this problem
17556 which ensures that accurate FIFO_Within_Priorities semantics are
17559 The principle is as follows. When an Ada task T is about to start
17560 running, it checks whether some other Ada task R with the same
17561 priority as T has been suspended due to the loss of priority
17562 inheritance. If this is the case, T yields and is placed at the end of
17563 its priority queue. When R arrives at the front of the queue it
17566 Note that this simple scheme preserves the relative order of the tasks
17567 that were ready to execute in the priority queue where R has been
17570 @node GNAT Implementation of Shared Passive Packages
17571 @section GNAT Implementation of Shared Passive Packages
17572 @cindex Shared passive packages
17575 GNAT fully implements the pragma @code{Shared_Passive} for
17576 @cindex pragma @code{Shared_Passive}
17577 the purpose of designating shared passive packages.
17578 This allows the use of passive partitions in the
17579 context described in the Ada Reference Manual; i.e., for communication
17580 between separate partitions of a distributed application using the
17581 features in Annex E.
17583 @cindex Distribution Systems Annex
17585 However, the implementation approach used by GNAT provides for more
17586 extensive usage as follows:
17589 @item Communication between separate programs
17591 This allows separate programs to access the data in passive
17592 partitions, using protected objects for synchronization where
17593 needed. The only requirement is that the two programs have a
17594 common shared file system. It is even possible for programs
17595 running on different machines with different architectures
17596 (e.g.@: different endianness) to communicate via the data in
17597 a passive partition.
17599 @item Persistence between program runs
17601 The data in a passive package can persist from one run of a
17602 program to another, so that a later program sees the final
17603 values stored by a previous run of the same program.
17608 The implementation approach used is to store the data in files. A
17609 separate stream file is created for each object in the package, and
17610 an access to an object causes the corresponding file to be read or
17613 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
17614 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
17615 set to the directory to be used for these files.
17616 The files in this directory
17617 have names that correspond to their fully qualified names. For
17618 example, if we have the package
17620 @smallexample @c ada
17622 pragma Shared_Passive (X);
17629 and the environment variable is set to @code{/stemp/}, then the files created
17630 will have the names:
17638 These files are created when a value is initially written to the object, and
17639 the files are retained until manually deleted. This provides the persistence
17640 semantics. If no file exists, it means that no partition has assigned a value
17641 to the variable; in this case the initial value declared in the package
17642 will be used. This model ensures that there are no issues in synchronizing
17643 the elaboration process, since elaboration of passive packages elaborates the
17644 initial values, but does not create the files.
17646 The files are written using normal @code{Stream_IO} access.
17647 If you want to be able
17648 to communicate between programs or partitions running on different
17649 architectures, then you should use the XDR versions of the stream attribute
17650 routines, since these are architecture independent.
17652 If active synchronization is required for access to the variables in the
17653 shared passive package, then as described in the Ada Reference Manual, the
17654 package may contain protected objects used for this purpose. In this case
17655 a lock file (whose name is @file{___lock} (three underscores)
17656 is created in the shared memory directory.
17657 @cindex @file{___lock} file (for shared passive packages)
17658 This is used to provide the required locking
17659 semantics for proper protected object synchronization.
17661 As of January 2003, GNAT supports shared passive packages on all platforms
17662 except for OpenVMS.
17664 @node Code Generation for Array Aggregates
17665 @section Code Generation for Array Aggregates
17668 * Static constant aggregates with static bounds::
17669 * Constant aggregates with unconstrained nominal types::
17670 * Aggregates with static bounds::
17671 * Aggregates with non-static bounds::
17672 * Aggregates in assignment statements::
17676 Aggregates have a rich syntax and allow the user to specify the values of
17677 complex data structures by means of a single construct. As a result, the
17678 code generated for aggregates can be quite complex and involve loops, case
17679 statements and multiple assignments. In the simplest cases, however, the
17680 compiler will recognize aggregates whose components and constraints are
17681 fully static, and in those cases the compiler will generate little or no
17682 executable code. The following is an outline of the code that GNAT generates
17683 for various aggregate constructs. For further details, you will find it
17684 useful to examine the output produced by the -gnatG flag to see the expanded
17685 source that is input to the code generator. You may also want to examine
17686 the assembly code generated at various levels of optimization.
17688 The code generated for aggregates depends on the context, the component values,
17689 and the type. In the context of an object declaration the code generated is
17690 generally simpler than in the case of an assignment. As a general rule, static
17691 component values and static subtypes also lead to simpler code.
17693 @node Static constant aggregates with static bounds
17694 @subsection Static constant aggregates with static bounds
17697 For the declarations:
17698 @smallexample @c ada
17699 type One_Dim is array (1..10) of integer;
17700 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
17704 GNAT generates no executable code: the constant ar0 is placed in static memory.
17705 The same is true for constant aggregates with named associations:
17707 @smallexample @c ada
17708 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
17709 Cr3 : constant One_Dim := (others => 7777);
17713 The same is true for multidimensional constant arrays such as:
17715 @smallexample @c ada
17716 type two_dim is array (1..3, 1..3) of integer;
17717 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
17721 The same is true for arrays of one-dimensional arrays: the following are
17724 @smallexample @c ada
17725 type ar1b is array (1..3) of boolean;
17726 type ar_ar is array (1..3) of ar1b;
17727 None : constant ar1b := (others => false); -- fully static
17728 None2 : constant ar_ar := (1..3 => None); -- fully static
17732 However, for multidimensional aggregates with named associations, GNAT will
17733 generate assignments and loops, even if all associations are static. The
17734 following two declarations generate a loop for the first dimension, and
17735 individual component assignments for the second dimension:
17737 @smallexample @c ada
17738 Zero1: constant two_dim := (1..3 => (1..3 => 0));
17739 Zero2: constant two_dim := (others => (others => 0));
17742 @node Constant aggregates with unconstrained nominal types
17743 @subsection Constant aggregates with unconstrained nominal types
17746 In such cases the aggregate itself establishes the subtype, so that
17747 associations with @code{others} cannot be used. GNAT determines the
17748 bounds for the actual subtype of the aggregate, and allocates the
17749 aggregate statically as well. No code is generated for the following:
17751 @smallexample @c ada
17752 type One_Unc is array (natural range <>) of integer;
17753 Cr_Unc : constant One_Unc := (12,24,36);
17756 @node Aggregates with static bounds
17757 @subsection Aggregates with static bounds
17760 In all previous examples the aggregate was the initial (and immutable) value
17761 of a constant. If the aggregate initializes a variable, then code is generated
17762 for it as a combination of individual assignments and loops over the target
17763 object. The declarations
17765 @smallexample @c ada
17766 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
17767 Cr_Var2 : One_Dim := (others > -1);
17771 generate the equivalent of
17773 @smallexample @c ada
17779 for I in Cr_Var2'range loop
17784 @node Aggregates with non-static bounds
17785 @subsection Aggregates with non-static bounds
17788 If the bounds of the aggregate are not statically compatible with the bounds
17789 of the nominal subtype of the target, then constraint checks have to be
17790 generated on the bounds. For a multidimensional array, constraint checks may
17791 have to be applied to sub-arrays individually, if they do not have statically
17792 compatible subtypes.
17794 @node Aggregates in assignment statements
17795 @subsection Aggregates in assignment statements
17798 In general, aggregate assignment requires the construction of a temporary,
17799 and a copy from the temporary to the target of the assignment. This is because
17800 it is not always possible to convert the assignment into a series of individual
17801 component assignments. For example, consider the simple case:
17803 @smallexample @c ada
17808 This cannot be converted into:
17810 @smallexample @c ada
17816 So the aggregate has to be built first in a separate location, and then
17817 copied into the target. GNAT recognizes simple cases where this intermediate
17818 step is not required, and the assignments can be performed in place, directly
17819 into the target. The following sufficient criteria are applied:
17823 The bounds of the aggregate are static, and the associations are static.
17825 The components of the aggregate are static constants, names of
17826 simple variables that are not renamings, or expressions not involving
17827 indexed components whose operands obey these rules.
17831 If any of these conditions are violated, the aggregate will be built in
17832 a temporary (created either by the front-end or the code generator) and then
17833 that temporary will be copied onto the target.
17835 @node The Size of Discriminated Records with Default Discriminants
17836 @section The Size of Discriminated Records with Default Discriminants
17839 If a discriminated type @code{T} has discriminants with default values, it is
17840 possible to declare an object of this type without providing an explicit
17843 @smallexample @c ada
17845 type Size is range 1..100;
17847 type Rec (D : Size := 15) is record
17848 Name : String (1..D);
17856 Such an object is said to be @emph{unconstrained}.
17857 The discriminant of the object
17858 can be modified by a full assignment to the object, as long as it preserves the
17859 relation between the value of the discriminant, and the value of the components
17862 @smallexample @c ada
17864 Word := (3, "yes");
17866 Word := (5, "maybe");
17868 Word := (5, "no"); -- raises Constraint_Error
17873 In order to support this behavior efficiently, an unconstrained object is
17874 given the maximum size that any value of the type requires. In the case
17875 above, @code{Word} has storage for the discriminant and for
17876 a @code{String} of length 100.
17877 It is important to note that unconstrained objects do not require dynamic
17878 allocation. It would be an improper implementation to place on the heap those
17879 components whose size depends on discriminants. (This improper implementation
17880 was used by some Ada83 compilers, where the @code{Name} component above
17882 been stored as a pointer to a dynamic string). Following the principle that
17883 dynamic storage management should never be introduced implicitly,
17884 an Ada compiler should reserve the full size for an unconstrained declared
17885 object, and place it on the stack.
17887 This maximum size approach
17888 has been a source of surprise to some users, who expect the default
17889 values of the discriminants to determine the size reserved for an
17890 unconstrained object: ``If the default is 15, why should the object occupy
17892 The answer, of course, is that the discriminant may be later modified,
17893 and its full range of values must be taken into account. This is why the
17898 type Rec (D : Positive := 15) is record
17899 Name : String (1..D);
17907 is flagged by the compiler with a warning:
17908 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
17909 because the required size includes @code{Positive'Last}
17910 bytes. As the first example indicates, the proper approach is to declare an
17911 index type of ``reasonable'' range so that unconstrained objects are not too
17914 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
17915 created in the heap by means of an allocator, then it is @emph{not}
17917 it is constrained by the default values of the discriminants, and those values
17918 cannot be modified by full assignment. This is because in the presence of
17919 aliasing all views of the object (which may be manipulated by different tasks,
17920 say) must be consistent, so it is imperative that the object, once created,
17923 @node Strict Conformance to the Ada Reference Manual
17924 @section Strict Conformance to the Ada Reference Manual
17927 The dynamic semantics defined by the Ada Reference Manual impose a set of
17928 run-time checks to be generated. By default, the GNAT compiler will insert many
17929 run-time checks into the compiled code, including most of those required by the
17930 Ada Reference Manual. However, there are three checks that are not enabled
17931 in the default mode for efficiency reasons: arithmetic overflow checking for
17932 integer operations (including division by zero), checks for access before
17933 elaboration on subprogram calls, and stack overflow checking (most operating
17934 systems do not perform this check by default).
17936 Strict conformance to the Ada Reference Manual can be achieved by adding
17937 three compiler options for overflow checking for integer operations
17938 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
17939 calls and generic instantiations (@option{-gnatE}), and stack overflow
17940 checking (@option{-fstack-check}).
17942 Note that the result of a floating point arithmetic operation in overflow and
17943 invalid situations, when the @code{Machine_Overflows} attribute of the result
17944 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
17945 case for machines compliant with the IEEE floating-point standard, but on
17946 machines that are not fully compliant with this standard, such as Alpha, the
17947 @option{-mieee} compiler flag must be used for achieving IEEE confirming
17948 behavior (although at the cost of a significant performance penalty), so
17949 infinite and NaN values are properly generated.
17952 @node Implementation of Ada 2012 Features
17953 @chapter Implementation of Ada 2012 Features
17954 @cindex Ada 2012 implementation status
17956 This chapter contains a complete list of Ada 2012 features that have been
17957 implemented as of GNAT version 6.4. Generally, these features are only
17958 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
17959 @cindex @option{-gnat12} option
17960 or if the configuration pragma @code{Ada_2012} is used.
17961 @cindex pragma @code{Ada_2012}
17962 @cindex configuration pragma @code{Ada_2012}
17963 @cindex @code{Ada_2012} configuration pragma
17964 However, new pragmas, attributes, and restrictions are
17965 unconditionally available, since the Ada 95 standard allows the addition of
17966 new pragmas, attributes, and restrictions (there are exceptions, which are
17967 documented in the individual descriptions), and also certain packages
17968 were made available in earlier versions of Ada.
17970 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
17971 This date shows the implementation date of the feature. Any wavefront
17972 subsequent to this date will contain the indicated feature, as will any
17973 subsequent releases. A date of 0000-00-00 means that GNAT has always
17974 implemented the feature, or implemented it as soon as it appeared as a
17975 binding interpretation.
17977 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
17978 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
17979 The features are ordered based on the relevant sections of the Ada
17980 Reference Manual (``RM''). When a given AI relates to multiple points
17981 in the RM, the earliest is used.
17983 A complete description of the AIs may be found in
17984 @url{www.ada-auth.org/ai05-summary.html}.
17989 @emph{AI-0176 Quantified expressions (2010-09-29)}
17990 @cindex AI-0176 (Ada 2012 feature)
17993 Both universally and existentially quantified expressions are implemented.
17994 They use the new syntax for iterators proposed in AI05-139-2, as well as
17995 the standard Ada loop syntax.
17998 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
18001 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
18002 @cindex AI-0079 (Ada 2012 feature)
18005 Wide characters in the unicode category @i{other_format} are now allowed in
18006 source programs between tokens, but not within a token such as an identifier.
18009 RM References: 2.01 (4/2) 2.02 (7)
18012 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
18013 @cindex AI-0091 (Ada 2012 feature)
18016 Wide characters in the unicode category @i{other_format} are not permitted
18017 within an identifier, since this can be a security problem. The error
18018 message for this case has been improved to be more specific, but GNAT has
18019 never allowed such characters to appear in identifiers.
18022 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)
18025 @emph{AI-0100 Placement of pragmas (2010-07-01)}
18026 @cindex AI-0100 (Ada 2012 feature)
18029 This AI is an earlier version of AI-163. It simplifies the rules
18030 for legal placement of pragmas. In the case of lists that allow pragmas, if
18031 the list may have no elements, then the list may consist solely of pragmas.
18034 RM References: 2.08 (7)
18037 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
18038 @cindex AI-0163 (Ada 2012 feature)
18041 A statement sequence may be composed entirely of pragmas. It is no longer
18042 necessary to add a dummy @code{null} statement to make the sequence legal.
18045 RM References: 2.08 (7) 2.08 (16)
18049 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
18050 @cindex AI-0080 (Ada 2012 feature)
18053 This is an editorial change only, described as non-testable in the AI.
18056 RM References: 3.01 (7)
18060 @emph{AI-0183 Aspect specifications (2010-08-16)}
18061 @cindex AI-0183 (Ada 2012 feature)
18064 Aspect specifications have been fully implemented except for pre and post-
18065 conditions, and type invariants, which have their own separate AI's. All
18066 forms of declarations listed in the AI are supported. The following is a
18067 list of the aspects supported (with GNAT implementation aspects marked)
18069 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
18070 @item @code{Ada_2005} @tab -- GNAT
18071 @item @code{Ada_2012} @tab -- GNAT
18072 @item @code{Address} @tab
18073 @item @code{Alignment} @tab
18074 @item @code{Atomic} @tab
18075 @item @code{Atomic_Components} @tab
18076 @item @code{Bit_Order} @tab
18077 @item @code{Component_Size} @tab
18078 @item @code{Contract_Case} @tab -- GNAT
18079 @item @code{Discard_Names} @tab
18080 @item @code{External_Tag} @tab
18081 @item @code{Favor_Top_Level} @tab -- GNAT
18082 @item @code{Inline} @tab
18083 @item @code{Inline_Always} @tab -- GNAT
18084 @item @code{Invariant} @tab -- GNAT
18085 @item @code{Machine_Radix} @tab
18086 @item @code{No_Return} @tab
18087 @item @code{Object_Size} @tab -- GNAT
18088 @item @code{Pack} @tab
18089 @item @code{Persistent_BSS} @tab -- GNAT
18090 @item @code{Post} @tab
18091 @item @code{Pre} @tab
18092 @item @code{Predicate} @tab
18093 @item @code{Preelaborable_Initialization} @tab
18094 @item @code{Pure_Function} @tab -- GNAT
18095 @item @code{Remote_Access_Type} @tab -- GNAT
18096 @item @code{Shared} @tab -- GNAT
18097 @item @code{Size} @tab
18098 @item @code{Storage_Pool} @tab
18099 @item @code{Storage_Size} @tab
18100 @item @code{Stream_Size} @tab
18101 @item @code{Suppress} @tab
18102 @item @code{Suppress_Debug_Info} @tab -- GNAT
18103 @item @code{Test_Case} @tab -- GNAT
18104 @item @code{Type_Invariant} @tab
18105 @item @code{Unchecked_Union} @tab
18106 @item @code{Universal_Aliasing} @tab -- GNAT
18107 @item @code{Unmodified} @tab -- GNAT
18108 @item @code{Unreferenced} @tab -- GNAT
18109 @item @code{Unreferenced_Objects} @tab -- GNAT
18110 @item @code{Unsuppress} @tab
18111 @item @code{Value_Size} @tab -- GNAT
18112 @item @code{Volatile} @tab
18113 @item @code{Volatile_Components}
18114 @item @code{Warnings} @tab -- GNAT
18118 Note that for aspects with an expression, e.g. @code{Size}, the expression is
18119 treated like a default expression (visibility is analyzed at the point of
18120 occurrence of the aspect, but evaluation of the expression occurs at the
18121 freeze point of the entity involved.
18124 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
18125 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
18126 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
18127 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
18128 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
18133 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
18134 @cindex AI-0128 (Ada 2012 feature)
18137 If an equality operator ("=") is declared for a type, then the implicitly
18138 declared inequality operator ("/=") is a primitive operation of the type.
18139 This is the only reasonable interpretation, and is the one always implemented
18140 by GNAT, but the RM was not entirely clear in making this point.
18143 RM References: 3.02.03 (6) 6.06 (6)
18146 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
18147 @cindex AI-0003 (Ada 2012 feature)
18150 In Ada 2012, a qualified expression is considered to be syntactically a name,
18151 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
18152 useful in disambiguating some cases of overloading.
18155 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
18159 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
18160 @cindex AI-0120 (Ada 2012 feature)
18163 This is an RM editorial change only. The section that lists objects that are
18164 constant failed to include the current instance of a protected object
18165 within a protected function. This has always been treated as a constant
18169 RM References: 3.03 (21)
18172 @emph{AI-0008 General access to constrained objects (0000-00-00)}
18173 @cindex AI-0008 (Ada 2012 feature)
18176 The wording in the RM implied that if you have a general access to a
18177 constrained object, it could be used to modify the discriminants. This was
18178 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
18179 has always done so in this situation.
18182 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
18186 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
18187 @cindex AI-0093 (Ada 2012 feature)
18190 This is an editorial change only, to make more widespread use of the Ada 2012
18191 ``immutably limited''.
18194 RM References: 3.03 (23.4/3)
18199 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
18200 @cindex AI-0096 (Ada 2012 feature)
18203 In general it is illegal for a type derived from a formal limited type to be
18204 nonlimited. This AI makes an exception to this rule: derivation is legal
18205 if it appears in the private part of the generic, and the formal type is not
18206 tagged. If the type is tagged, the legality check must be applied to the
18207 private part of the package.
18210 RM References: 3.04 (5.1/2) 6.02 (7)
18214 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
18215 @cindex AI-0181 (Ada 2012 feature)
18218 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
18219 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
18220 @code{Image} and @code{Value} attributes for the character types. Strictly
18221 speaking this is an inconsistency with Ada 95, but in practice the use of
18222 these attributes is so obscure that it will not cause problems.
18225 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
18229 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
18230 @cindex AI-0182 (Ada 2012 feature)
18233 This AI allows @code{Character'Value} to accept the string @code{'?'} where
18234 @code{?} is any character including non-graphic control characters. GNAT has
18235 always accepted such strings. It also allows strings such as
18236 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
18237 permission and raises @code{Constraint_Error}, as is certainly still
18241 RM References: 3.05 (56/2)
18245 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
18246 @cindex AI-0214 (Ada 2012 feature)
18249 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
18250 to have default expressions by allowing them when the type is limited. It
18251 is often useful to define a default value for a discriminant even though
18252 it can't be changed by assignment.
18255 RM References: 3.07 (9.1/2) 3.07.02 (3)
18259 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
18260 @cindex AI-0102 (Ada 2012 feature)
18263 It is illegal to assign an anonymous access constant to an anonymous access
18264 variable. The RM did not have a clear rule to prevent this, but GNAT has
18265 always generated an error for this usage.
18268 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
18272 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
18273 @cindex AI-0158 (Ada 2012 feature)
18276 This AI extends the syntax of membership tests to simplify complex conditions
18277 that can be expressed as membership in a subset of values of any type. It
18278 introduces syntax for a list of expressions that may be used in loop contexts
18282 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
18286 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
18287 @cindex AI-0173 (Ada 2012 feature)
18290 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
18291 with the tag of an abstract type, and @code{False} otherwise.
18294 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
18299 @emph{AI-0076 function with controlling result (0000-00-00)}
18300 @cindex AI-0076 (Ada 2012 feature)
18303 This is an editorial change only. The RM defines calls with controlling
18304 results, but uses the term ``function with controlling result'' without an
18305 explicit definition.
18308 RM References: 3.09.02 (2/2)
18312 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
18313 @cindex AI-0126 (Ada 2012 feature)
18316 This AI clarifies dispatching rules, and simply confirms that dispatching
18317 executes the operation of the parent type when there is no explicitly or
18318 implicitly declared operation for the descendant type. This has always been
18319 the case in all versions of GNAT.
18322 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
18326 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
18327 @cindex AI-0097 (Ada 2012 feature)
18330 The RM as written implied that in some cases it was possible to create an
18331 object of an abstract type, by having an abstract extension inherit a non-
18332 abstract constructor from its parent type. This mistake has been corrected
18333 in GNAT and in the RM, and this construct is now illegal.
18336 RM References: 3.09.03 (4/2)
18340 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
18341 @cindex AI-0203 (Ada 2012 feature)
18344 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
18345 permitted such usage.
18348 RM References: 3.09.03 (8/3)
18352 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
18353 @cindex AI-0198 (Ada 2012 feature)
18356 This AI resolves a conflict between two rules involving inherited abstract
18357 operations and predefined operators. If a derived numeric type inherits
18358 an abstract operator, it overrides the predefined one. This interpretation
18359 was always the one implemented in GNAT.
18362 RM References: 3.09.03 (4/3)
18365 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
18366 @cindex AI-0073 (Ada 2012 feature)
18369 This AI covers a number of issues regarding returning abstract types. In
18370 particular generic functions cannot have abstract result types or access
18371 result types designated an abstract type. There are some other cases which
18372 are detailed in the AI. Note that this binding interpretation has not been
18373 retrofitted to operate before Ada 2012 mode, since it caused a significant
18374 number of regressions.
18377 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
18381 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
18382 @cindex AI-0070 (Ada 2012 feature)
18385 This is an editorial change only, there are no testable consequences short of
18386 checking for the absence of generated code for an interface declaration.
18389 RM References: 3.09.04 (18/2)
18393 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
18394 @cindex AI-0208 (Ada 2012 feature)
18397 The wording in the Ada 2005 RM concerning characteristics of incomplete views
18398 was incorrect and implied that some programs intended to be legal were now
18399 illegal. GNAT had never considered such programs illegal, so it has always
18400 implemented the intent of this AI.
18403 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
18407 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
18408 @cindex AI-0162 (Ada 2012 feature)
18411 Incomplete types are made more useful by allowing them to be completed by
18412 private types and private extensions.
18415 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
18420 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
18421 @cindex AI-0098 (Ada 2012 feature)
18424 An unintentional omission in the RM implied some inconsistent restrictions on
18425 the use of anonymous access to subprogram values. These restrictions were not
18426 intentional, and have never been enforced by GNAT.
18429 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
18433 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
18434 @cindex AI-0199 (Ada 2012 feature)
18437 A choice list in a record aggregate can include several components of
18438 (distinct) anonymous access types as long as they have matching designated
18442 RM References: 4.03.01 (16)
18446 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
18447 @cindex AI-0220 (Ada 2012 feature)
18450 This AI addresses a wording problem in the RM that appears to permit some
18451 complex cases of aggregates with non-static discriminants. GNAT has always
18452 implemented the intended semantics.
18455 RM References: 4.03.01 (17)
18458 @emph{AI-0147 Conditional expressions (2009-03-29)}
18459 @cindex AI-0147 (Ada 2012 feature)
18462 Conditional expressions are permitted. The form of such an expression is:
18465 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
18468 The parentheses can be omitted in contexts where parentheses are present
18469 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
18470 clause is omitted, @b{else True} is assumed;
18471 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
18472 @emph{(A implies B)} in standard logic.
18475 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
18476 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
18480 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
18481 @cindex AI-0037 (Ada 2012 feature)
18484 This AI confirms that an association of the form @code{Indx => <>} in an
18485 array aggregate must raise @code{Constraint_Error} if @code{Indx}
18486 is out of range. The RM specified a range check on other associations, but
18487 not when the value of the association was defaulted. GNAT has always inserted
18488 a constraint check on the index value.
18491 RM References: 4.03.03 (29)
18495 @emph{AI-0123 Composability of equality (2010-04-13)}
18496 @cindex AI-0123 (Ada 2012 feature)
18499 Equality of untagged record composes, so that the predefined equality for a
18500 composite type that includes a component of some untagged record type
18501 @code{R} uses the equality operation of @code{R} (which may be user-defined
18502 or predefined). This makes the behavior of untagged records identical to that
18503 of tagged types in this respect.
18505 This change is an incompatibility with previous versions of Ada, but it
18506 corrects a non-uniformity that was often a source of confusion. Analysis of
18507 a large number of industrial programs indicates that in those rare cases
18508 where a composite type had an untagged record component with a user-defined
18509 equality, either there was no use of the composite equality, or else the code
18510 expected the same composability as for tagged types, and thus had a bug that
18511 would be fixed by this change.
18514 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
18519 @emph{AI-0088 The value of exponentiation (0000-00-00)}
18520 @cindex AI-0088 (Ada 2012 feature)
18523 This AI clarifies the equivalence rule given for the dynamic semantics of
18524 exponentiation: the value of the operation can be obtained by repeated
18525 multiplication, but the operation can be implemented otherwise (for example
18526 using the familiar divide-by-two-and-square algorithm, even if this is less
18527 accurate), and does not imply repeated reads of a volatile base.
18530 RM References: 4.05.06 (11)
18533 @emph{AI-0188 Case expressions (2010-01-09)}
18534 @cindex AI-0188 (Ada 2012 feature)
18537 Case expressions are permitted. This allows use of constructs such as:
18539 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
18543 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
18546 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
18547 @cindex AI-0104 (Ada 2012 feature)
18550 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
18551 @code{Constraint_Error} because the default value of the allocated object is
18552 @b{null}. This useless construct is illegal in Ada 2012.
18555 RM References: 4.08 (2)
18558 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
18559 @cindex AI-0157 (Ada 2012 feature)
18562 Allocation and Deallocation from an empty storage pool (i.e. allocation or
18563 deallocation of a pointer for which a static storage size clause of zero
18564 has been given) is now illegal and is detected as such. GNAT
18565 previously gave a warning but not an error.
18568 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
18571 @emph{AI-0179 Statement not required after label (2010-04-10)}
18572 @cindex AI-0179 (Ada 2012 feature)
18575 It is not necessary to have a statement following a label, so a label
18576 can appear at the end of a statement sequence without the need for putting a
18577 null statement afterwards, but it is not allowable to have only labels and
18578 no real statements in a statement sequence.
18581 RM References: 5.01 (2)
18585 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
18586 @cindex AI-139-2 (Ada 2012 feature)
18589 The new syntax for iterating over arrays and containers is now implemented.
18590 Iteration over containers is for now limited to read-only iterators. Only
18591 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
18594 RM References: 5.05
18597 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
18598 @cindex AI-0134 (Ada 2012 feature)
18601 For full conformance, the profiles of anonymous-access-to-subprogram
18602 parameters must match. GNAT has always enforced this rule.
18605 RM References: 6.03.01 (18)
18608 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
18609 @cindex AI-0207 (Ada 2012 feature)
18612 This AI confirms that access_to_constant indication must match for mode
18613 conformance. This was implemented in GNAT when the qualifier was originally
18614 introduced in Ada 2005.
18617 RM References: 6.03.01 (16/2)
18621 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
18622 @cindex AI-0046 (Ada 2012 feature)
18625 For full conformance, in the case of access parameters, the null exclusion
18626 must match (either both or neither must have @code{@b{not null}}).
18629 RM References: 6.03.02 (18)
18633 @emph{AI-0118 The association of parameter associations (0000-00-00)}
18634 @cindex AI-0118 (Ada 2012 feature)
18637 This AI clarifies the rules for named associations in subprogram calls and
18638 generic instantiations. The rules have been in place since Ada 83.
18641 RM References: 6.04.01 (2) 12.03 (9)
18645 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
18646 @cindex AI-0196 (Ada 2012 feature)
18649 Null exclusion checks are not made for @code{@b{out}} parameters when
18650 evaluating the actual parameters. GNAT has never generated these checks.
18653 RM References: 6.04.01 (13)
18656 @emph{AI-0015 Constant return objects (0000-00-00)}
18657 @cindex AI-0015 (Ada 2012 feature)
18660 The return object declared in an @i{extended_return_statement} may be
18661 declared constant. This was always intended, and GNAT has always allowed it.
18664 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
18669 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
18670 @cindex AI-0032 (Ada 2012 feature)
18673 If a function returns a class-wide type, the object of an extended return
18674 statement can be declared with a specific type that is covered by the class-
18675 wide type. This has been implemented in GNAT since the introduction of
18676 extended returns. Note AI-0103 complements this AI by imposing matching
18677 rules for constrained return types.
18680 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
18684 @emph{AI-0103 Static matching for extended return (2010-07-23)}
18685 @cindex AI-0103 (Ada 2012 feature)
18688 If the return subtype of a function is an elementary type or a constrained
18689 type, the subtype indication in an extended return statement must match
18690 statically this return subtype.
18693 RM References: 6.05 (5.2/2)
18697 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
18698 @cindex AI-0058 (Ada 2012 feature)
18701 The RM had some incorrect wording implying wrong treatment of abnormal
18702 completion in an extended return. GNAT has always implemented the intended
18703 correct semantics as described by this AI.
18706 RM References: 6.05 (22/2)
18710 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
18711 @cindex AI-0050 (Ada 2012 feature)
18714 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
18715 not take advantage of these incorrect permissions in any case.
18718 RM References: 6.05 (24/2)
18722 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
18723 @cindex AI-0125 (Ada 2012 feature)
18726 In Ada 2012, the declaration of a primitive operation of a type extension
18727 or private extension can also override an inherited primitive that is not
18728 visible at the point of this declaration.
18731 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
18734 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
18735 @cindex AI-0062 (Ada 2012 feature)
18738 A full constant may have a null exclusion even if its associated deferred
18739 constant does not. GNAT has always allowed this.
18742 RM References: 7.04 (6/2) 7.04 (7.1/2)
18746 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
18747 @cindex AI-0178 (Ada 2012 feature)
18750 This AI clarifies the role of incomplete views and plugs an omission in the
18751 RM. GNAT always correctly restricted the use of incomplete views and types.
18754 RM References: 7.05 (3/2) 7.05 (6/2)
18757 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
18758 @cindex AI-0087 (Ada 2012 feature)
18761 The actual for a formal nonlimited derived type cannot be limited. In
18762 particular, a formal derived type that extends a limited interface but which
18763 is not explicitly limited cannot be instantiated with a limited type.
18766 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
18769 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
18770 @cindex AI-0099 (Ada 2012 feature)
18773 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
18774 and therefore depends on the run-time characteristics of an object (i.e. its
18775 tag) and not on its nominal type. As the AI indicates: ``we do not expect
18776 this to affect any implementation''.
18779 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
18784 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
18785 @cindex AI-0064 (Ada 2012 feature)
18788 This is an editorial change only. The intended behavior is already checked
18789 by an existing ACATS test, which GNAT has always executed correctly.
18792 RM References: 7.06.01 (17.1/1)
18795 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
18796 @cindex AI-0026 (Ada 2012 feature)
18799 Record representation clauses concerning Unchecked_Union types cannot mention
18800 the discriminant of the type. The type of a component declared in the variant
18801 part of an Unchecked_Union cannot be controlled, have controlled components,
18802 nor have protected or task parts. If an Unchecked_Union type is declared
18803 within the body of a generic unit or its descendants, then the type of a
18804 component declared in the variant part cannot be a formal private type or a
18805 formal private extension declared within the same generic unit.
18808 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
18812 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
18813 @cindex AI-0205 (Ada 2012 feature)
18816 This AI corrects a simple omission in the RM. Return objects have always
18817 been visible within an extended return statement.
18820 RM References: 8.03 (17)
18824 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
18825 @cindex AI-0042 (Ada 2012 feature)
18828 This AI fixes a wording gap in the RM. An operation of a synchronized
18829 interface can be implemented by a protected or task entry, but the abstract
18830 operation is not being overridden in the usual sense, and it must be stated
18831 separately that this implementation is legal. This has always been the case
18835 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
18838 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
18839 @cindex AI-0030 (Ada 2012 feature)
18842 Requeue is permitted to a protected, synchronized or task interface primitive
18843 providing it is known that the overriding operation is an entry. Otherwise
18844 the requeue statement has the same effect as a procedure call. Use of pragma
18845 @code{Implemented} provides a way to impose a static requirement on the
18846 overriding operation by adhering to one of the implementation kinds: entry,
18847 protected procedure or any of the above.
18850 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
18851 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
18855 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
18856 @cindex AI-0201 (Ada 2012 feature)
18859 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
18860 attribute, then individual components may not be addressable by independent
18861 tasks. However, if the representation clause has no effect (is confirming),
18862 then independence is not compromised. Furthermore, in GNAT, specification of
18863 other appropriately addressable component sizes (e.g. 16 for 8-bit
18864 characters) also preserves independence. GNAT now gives very clear warnings
18865 both for the declaration of such a type, and for any assignment to its components.
18868 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
18871 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
18872 @cindex AI-0009 (Ada 2012 feature)
18875 This AI introduces the new pragmas @code{Independent} and
18876 @code{Independent_Components},
18877 which control guaranteeing independence of access to objects and components.
18878 The AI also requires independence not unaffected by confirming rep clauses.
18881 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
18882 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
18886 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
18887 @cindex AI-0072 (Ada 2012 feature)
18890 This AI clarifies that task signalling for reading @code{'Terminated} only
18891 occurs if the result is True. GNAT semantics has always been consistent with
18892 this notion of task signalling.
18895 RM References: 9.10 (6.1/1)
18898 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
18899 @cindex AI-0108 (Ada 2012 feature)
18902 This AI confirms that an incomplete type from a limited view does not have
18903 discriminants. This has always been the case in GNAT.
18906 RM References: 10.01.01 (12.3/2)
18909 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
18910 @cindex AI-0129 (Ada 2012 feature)
18913 This AI clarifies the description of limited views: a limited view of a
18914 package includes only one view of a type that has an incomplete declaration
18915 and a full declaration (there is no possible ambiguity in a client package).
18916 This AI also fixes an omission: a nested package in the private part has no
18917 limited view. GNAT always implemented this correctly.
18920 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
18925 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
18926 @cindex AI-0077 (Ada 2012 feature)
18929 This AI clarifies that a declaration does not include a context clause,
18930 and confirms that it is illegal to have a context in which both a limited
18931 and a nonlimited view of a package are accessible. Such double visibility
18932 was always rejected by GNAT.
18935 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
18938 @emph{AI-0122 Private with and children of generics (0000-00-00)}
18939 @cindex AI-0122 (Ada 2012 feature)
18942 This AI clarifies the visibility of private children of generic units within
18943 instantiations of a parent. GNAT has always handled this correctly.
18946 RM References: 10.01.02 (12/2)
18951 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
18952 @cindex AI-0040 (Ada 2012 feature)
18955 This AI confirms that a limited with clause in a child unit cannot name
18956 an ancestor of the unit. This has always been checked in GNAT.
18959 RM References: 10.01.02 (20/2)
18962 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
18963 @cindex AI-0132 (Ada 2012 feature)
18966 This AI fills a gap in the description of library unit pragmas. The pragma
18967 clearly must apply to a library unit, even if it does not carry the name
18968 of the enclosing unit. GNAT has always enforced the required check.
18971 RM References: 10.01.05 (7)
18975 @emph{AI-0034 Categorization of limited views (0000-00-00)}
18976 @cindex AI-0034 (Ada 2012 feature)
18979 The RM makes certain limited with clauses illegal because of categorization
18980 considerations, when the corresponding normal with would be legal. This is
18981 not intended, and GNAT has always implemented the recommended behavior.
18984 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
18988 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
18989 @cindex AI-0035 (Ada 2012 feature)
18992 This AI remedies some inconsistencies in the legality rules for Pure units.
18993 Derived access types are legal in a pure unit (on the assumption that the
18994 rule for a zero storage pool size has been enforced on the ancestor type).
18995 The rules are enforced in generic instances and in subunits. GNAT has always
18996 implemented the recommended behavior.
18999 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)
19003 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
19004 @cindex AI-0219 (Ada 2012 feature)
19007 This AI refines the rules for the cases with limited parameters which do not
19008 allow the implementations to omit ``redundant''. GNAT now properly conforms
19009 to the requirements of this binding interpretation.
19012 RM References: 10.02.01 (18/2)
19015 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
19016 @cindex AI-0043 (Ada 2012 feature)
19019 This AI covers various omissions in the RM regarding the raising of
19020 exceptions. GNAT has always implemented the intended semantics.
19023 RM References: 11.04.01 (10.1/2) 11 (2)
19027 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
19028 @cindex AI-0200 (Ada 2012 feature)
19031 This AI plugs a gap in the RM which appeared to allow some obviously intended
19032 illegal instantiations. GNAT has never allowed these instantiations.
19035 RM References: 12.07 (16)
19039 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
19040 @cindex AI-0112 (Ada 2012 feature)
19043 This AI concerns giving names to various representation aspects, but the
19044 practical effect is simply to make the use of duplicate
19045 @code{Atomic}[@code{_Components}],
19046 @code{Volatile}[@code{_Components}] and
19047 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
19048 now performs this required check.
19051 RM References: 13.01 (8)
19054 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
19055 @cindex AI-0106 (Ada 2012 feature)
19058 The RM appeared to allow representation pragmas on generic formal parameters,
19059 but this was not intended, and GNAT has never permitted this usage.
19062 RM References: 13.01 (9.1/1)
19066 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
19067 @cindex AI-0012 (Ada 2012 feature)
19070 It is now illegal to give an inappropriate component size or a pragma
19071 @code{Pack} that attempts to change the component size in the case of atomic
19072 or aliased components. Previously GNAT ignored such an attempt with a
19076 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
19080 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
19081 @cindex AI-0039 (Ada 2012 feature)
19084 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
19085 for stream attributes, but these were never useful and are now illegal. GNAT
19086 has always regarded such expressions as illegal.
19089 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
19093 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
19094 @cindex AI-0095 (Ada 2012 feature)
19097 The prefix of @code{'Address} cannot statically denote a subprogram with
19098 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
19099 @code{Program_Error} if the prefix denotes a subprogram with convention
19103 RM References: 13.03 (11/1)
19107 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
19108 @cindex AI-0116 (Ada 2012 feature)
19111 This AI requires that the alignment of a class-wide object be no greater
19112 than the alignment of any type in the class. GNAT has always followed this
19116 RM References: 13.03 (29) 13.11 (16)
19120 @emph{AI-0146 Type invariants (2009-09-21)}
19121 @cindex AI-0146 (Ada 2012 feature)
19124 Type invariants may be specified for private types using the aspect notation.
19125 Aspect @code{Type_Invariant} may be specified for any private type,
19126 @code{Type_Invariant'Class} can
19127 only be specified for tagged types, and is inherited by any descendent of the
19128 tagged types. The invariant is a boolean expression that is tested for being
19129 true in the following situations: conversions to the private type, object
19130 declarations for the private type that are default initialized, and
19132 parameters and returned result on return from any primitive operation for
19133 the type that is visible to a client.
19134 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
19135 @code{Invariant'Class} for @code{Type_Invariant'Class}.
19138 RM References: 13.03.03 (00)
19141 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
19142 @cindex AI-0078 (Ada 2012 feature)
19145 In Ada 2012, compilers are required to support unchecked conversion where the
19146 target alignment is a multiple of the source alignment. GNAT always supported
19147 this case (and indeed all cases of differing alignments, doing copies where
19148 required if the alignment was reduced).
19151 RM References: 13.09 (7)
19155 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
19156 @cindex AI-0195 (Ada 2012 feature)
19159 The handling of invalid values is now designated to be implementation
19160 defined. This is a documentation change only, requiring Annex M in the GNAT
19161 Reference Manual to document this handling.
19162 In GNAT, checks for invalid values are made
19163 only when necessary to avoid erroneous behavior. Operations like assignments
19164 which cannot cause erroneous behavior ignore the possibility of invalid
19165 values and do not do a check. The date given above applies only to the
19166 documentation change, this behavior has always been implemented by GNAT.
19169 RM References: 13.09.01 (10)
19172 @emph{AI-0193 Alignment of allocators (2010-09-16)}
19173 @cindex AI-0193 (Ada 2012 feature)
19176 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
19177 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
19181 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
19182 13.11.01 (2) 13.11.01 (3)
19186 @emph{AI-0177 Parameterized expressions (2010-07-10)}
19187 @cindex AI-0177 (Ada 2012 feature)
19190 The new Ada 2012 notion of parameterized expressions is implemented. The form
19193 @i{function specification} @b{is} (@i{expression})
19197 This is exactly equivalent to the
19198 corresponding function body that returns the expression, but it can appear
19199 in a package spec. Note that the expression must be parenthesized.
19202 RM References: 13.11.01 (3/2)
19205 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
19206 @cindex AI-0033 (Ada 2012 feature)
19209 Neither of these two pragmas may appear within a generic template, because
19210 the generic might be instantiated at other than the library level.
19213 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
19217 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
19218 @cindex AI-0161 (Ada 2012 feature)
19221 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
19222 of the default stream attributes for elementary types. If this restriction is
19223 in force, then it is necessary to provide explicit subprograms for any
19224 stream attributes used.
19227 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
19230 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
19231 @cindex AI-0194 (Ada 2012 feature)
19234 The @code{Stream_Size} attribute returns the default number of bits in the
19235 stream representation of the given type.
19236 This value is not affected by the presence
19237 of stream subprogram attributes for the type. GNAT has always implemented
19238 this interpretation.
19241 RM References: 13.13.02 (1.2/2)
19244 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
19245 @cindex AI-0109 (Ada 2012 feature)
19248 This AI is an editorial change only. It removes the need for a tag check
19249 that can never fail.
19252 RM References: 13.13.02 (34/2)
19255 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
19256 @cindex AI-0007 (Ada 2012 feature)
19259 The RM as written appeared to limit the possibilities of declaring read
19260 attribute procedures for private scalar types. This limitation was not
19261 intended, and has never been enforced by GNAT.
19264 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
19268 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
19269 @cindex AI-0065 (Ada 2012 feature)
19272 This AI clarifies the fact that all remote access types support external
19273 streaming. This fixes an obvious oversight in the definition of the
19274 language, and GNAT always implemented the intended correct rules.
19277 RM References: 13.13.02 (52/2)
19280 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
19281 @cindex AI-0019 (Ada 2012 feature)
19284 The RM suggests that primitive subprograms of a specific tagged type are
19285 frozen when the tagged type is frozen. This would be an incompatible change
19286 and is not intended. GNAT has never attempted this kind of freezing and its
19287 behavior is consistent with the recommendation of this AI.
19290 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)
19293 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
19294 @cindex AI-0017 (Ada 2012 feature)
19297 So-called ``Taft-amendment types'' (i.e., types that are completed in package
19298 bodies) are not frozen by the occurrence of bodies in the
19299 enclosing declarative part. GNAT always implemented this properly.
19302 RM References: 13.14 (3/1)
19306 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
19307 @cindex AI-0060 (Ada 2012 feature)
19310 This AI extends the definition of remote access types to include access
19311 to limited, synchronized, protected or task class-wide interface types.
19312 GNAT already implemented this extension.
19315 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
19318 @emph{AI-0114 Classification of letters (0000-00-00)}
19319 @cindex AI-0114 (Ada 2012 feature)
19322 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
19323 181 (@code{MICRO SIGN}), and
19324 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
19325 lower case letters by Unicode.
19326 However, they are not allowed in identifiers, and they
19327 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
19328 This behavior is consistent with that defined in Ada 95.
19331 RM References: A.03.02 (59) A.04.06 (7)
19335 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
19336 @cindex AI-0185 (Ada 2012 feature)
19339 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
19340 classification functions for @code{Wide_Character} and
19341 @code{Wide_Wide_Character}, as well as providing
19342 case folding routines for @code{Wide_[Wide_]Character} and
19343 @code{Wide_[Wide_]String}.
19346 RM References: A.03.05 (0) A.03.06 (0)
19350 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
19351 @cindex AI-0031 (Ada 2012 feature)
19354 A new version of @code{Find_Token} is added to all relevant string packages,
19355 with an extra parameter @code{From}. Instead of starting at the first
19356 character of the string, the search for a matching Token starts at the
19357 character indexed by the value of @code{From}.
19358 These procedures are available in all versions of Ada
19359 but if used in versions earlier than Ada 2012 they will generate a warning
19360 that an Ada 2012 subprogram is being used.
19363 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
19368 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
19369 @cindex AI-0056 (Ada 2012 feature)
19372 The wording in the Ada 2005 RM implied an incompatible handling of the
19373 @code{Index} functions, resulting in raising an exception instead of
19374 returning zero in some situations.
19375 This was not intended and has been corrected.
19376 GNAT always returned zero, and is thus consistent with this AI.
19379 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
19383 @emph{AI-0137 String encoding package (2010-03-25)}
19384 @cindex AI-0137 (Ada 2012 feature)
19387 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
19388 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
19389 and @code{Wide_Wide_Strings} have been
19390 implemented. These packages (whose documentation can be found in the spec
19391 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
19392 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
19393 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
19394 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
19395 UTF-16), as well as conversions between the different UTF encodings. With
19396 the exception of @code{Wide_Wide_Strings}, these packages are available in
19397 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
19398 The @code{Wide_Wide_Strings package}
19399 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
19400 mode since it uses @code{Wide_Wide_Character}).
19403 RM References: A.04.11
19406 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
19407 @cindex AI-0038 (Ada 2012 feature)
19410 These are minor errors in the description on three points. The intent on
19411 all these points has always been clear, and GNAT has always implemented the
19412 correct intended semantics.
19415 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)
19418 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
19419 @cindex AI-0044 (Ada 2012 feature)
19422 This AI places restrictions on allowed instantiations of generic containers.
19423 These restrictions are not checked by the compiler, so there is nothing to
19424 change in the implementation. This affects only the RM documentation.
19427 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)
19430 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
19431 @cindex AI-0127 (Ada 2012 feature)
19434 This package provides an interface for identifying the current locale.
19437 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
19438 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
19443 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
19444 @cindex AI-0002 (Ada 2012 feature)
19447 The compiler is not required to support exporting an Ada subprogram with
19448 convention C if there are parameters or a return type of an unconstrained
19449 array type (such as @code{String}). GNAT allows such declarations but
19450 generates warnings. It is possible, but complicated, to write the
19451 corresponding C code and certainly such code would be specific to GNAT and
19455 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
19459 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
19460 @cindex AI05-0216 (Ada 2012 feature)
19463 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
19464 forbid tasks declared locally within subprograms, or functions returning task
19465 objects, and that is the implementation that GNAT has always provided.
19466 However the language in the RM was not sufficiently clear on this point.
19467 Thus this is a documentation change in the RM only.
19470 RM References: D.07 (3/3)
19473 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
19474 @cindex AI-0211 (Ada 2012 feature)
19477 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
19478 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
19481 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
19484 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
19485 @cindex AI-0190 (Ada 2012 feature)
19488 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
19489 used to control storage pools globally.
19490 In particular, you can force every access
19491 type that is used for allocation (@b{new}) to have an explicit storage pool,
19492 or you can declare a pool globally to be used for all access types that lack
19496 RM References: D.07 (8)
19499 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
19500 @cindex AI-0189 (Ada 2012 feature)
19503 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
19504 which says that no dynamic allocation will occur once elaboration is
19506 In general this requires a run-time check, which is not required, and which
19507 GNAT does not attempt. But the static cases of allocators in a task body or
19508 in the body of the main program are detected and flagged at compile or bind
19512 RM References: D.07 (19.1/2) H.04 (23.3/2)
19515 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
19516 @cindex AI-0171 (Ada 2012 feature)
19519 A new package @code{System.Multiprocessors} is added, together with the
19520 definition of pragma @code{CPU} for controlling task affinity. A new no
19521 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
19522 is added to the Ravenscar profile.
19525 RM References: D.13.01 (4/2) D.16
19529 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
19530 @cindex AI-0210 (Ada 2012 feature)
19533 This is a documentation only issue regarding wording of metric requirements,
19534 that does not affect the implementation of the compiler.
19537 RM References: D.15 (24/2)
19541 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
19542 @cindex AI-0206 (Ada 2012 feature)
19545 Remote types packages are now allowed to depend on preelaborated packages.
19546 This was formerly considered illegal.
19549 RM References: E.02.02 (6)
19554 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
19555 @cindex AI-0152 (Ada 2012 feature)
19558 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
19559 where the type of the returned value is an anonymous access type.
19562 RM References: H.04 (8/1)
19566 @node Obsolescent Features
19567 @chapter Obsolescent Features
19570 This chapter describes features that are provided by GNAT, but are
19571 considered obsolescent since there are preferred ways of achieving
19572 the same effect. These features are provided solely for historical
19573 compatibility purposes.
19576 * pragma No_Run_Time::
19577 * pragma Ravenscar::
19578 * pragma Restricted_Run_Time::
19581 @node pragma No_Run_Time
19582 @section pragma No_Run_Time
19584 The pragma @code{No_Run_Time} is used to achieve an affect similar
19585 to the use of the "Zero Foot Print" configurable run time, but without
19586 requiring a specially configured run time. The result of using this
19587 pragma, which must be used for all units in a partition, is to restrict
19588 the use of any language features requiring run-time support code. The
19589 preferred usage is to use an appropriately configured run-time that
19590 includes just those features that are to be made accessible.
19592 @node pragma Ravenscar
19593 @section pragma Ravenscar
19595 The pragma @code{Ravenscar} has exactly the same effect as pragma
19596 @code{Profile (Ravenscar)}. The latter usage is preferred since it
19597 is part of the new Ada 2005 standard.
19599 @node pragma Restricted_Run_Time
19600 @section pragma Restricted_Run_Time
19602 The pragma @code{Restricted_Run_Time} has exactly the same effect as
19603 pragma @code{Profile (Restricted)}. The latter usage is
19604 preferred since the Ada 2005 pragma @code{Profile} is intended for
19605 this kind of implementation dependent addition.
19608 @c GNU Free Documentation License
19610 @node Index,,GNU Free Documentation License, Top