1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
15 @setfilename gnat_rm.info
18 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts. A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
32 @settitle GNAT Reference Manual
34 @setchapternewpage odd
37 @include gcc-common.texi
39 @dircategory GNU Ada tools
41 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
50 @vskip 0pt plus 1filll
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Implementation of Ada 2012 Features::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
89 --- The Detailed Node Listing ---
93 * What This Reference Manual Contains::
94 * Related Information::
96 Implementation Defined Pragmas
98 * Pragma Abort_Defer::
107 * Pragma Assume_No_Invalid_Values::
109 * Pragma C_Pass_By_Copy::
111 * Pragma Check_Name::
112 * Pragma Check_Policy::
114 * Pragma Common_Object::
115 * Pragma Compile_Time_Error::
116 * Pragma Compile_Time_Warning::
117 * Pragma Compiler_Unit::
118 * Pragma Complete_Representation::
119 * Pragma Complex_Representation::
120 * Pragma Component_Alignment::
121 * Pragma Convention_Identifier::
123 * Pragma CPP_Constructor::
124 * Pragma CPP_Virtual::
125 * Pragma CPP_Vtable::
127 * Pragma Debug_Policy::
128 * Pragma Detect_Blocking::
129 * Pragma Elaboration_Checks::
131 * Pragma Export_Exception::
132 * Pragma Export_Function::
133 * Pragma Export_Object::
134 * Pragma Export_Procedure::
135 * Pragma Export_Value::
136 * Pragma Export_Valued_Procedure::
137 * Pragma Extend_System::
138 * Pragma Extensions_Allowed::
140 * Pragma External_Name_Casing::
142 * Pragma Favor_Top_Level::
143 * Pragma Finalize_Storage_Only::
144 * Pragma Float_Representation::
146 * Pragma Implemented::
147 * Pragma Implicit_Packing::
148 * Pragma Import_Exception::
149 * Pragma Import_Function::
150 * Pragma Import_Object::
151 * Pragma Import_Procedure::
152 * Pragma Import_Valued_Procedure::
153 * Pragma Initialize_Scalars::
154 * Pragma Inline_Always::
155 * Pragma Inline_Generic::
157 * Pragma Interface_Name::
158 * Pragma Interrupt_Handler::
159 * Pragma Interrupt_State::
161 * Pragma Keep_Names::
164 * Pragma Linker_Alias::
165 * Pragma Linker_Constructor::
166 * Pragma Linker_Destructor::
167 * Pragma Linker_Section::
168 * Pragma Long_Float::
169 * Pragma Machine_Attribute::
171 * Pragma Main_Storage::
174 * Pragma No_Strict_Aliasing ::
175 * Pragma Normalize_Scalars::
176 * Pragma Obsolescent::
177 * Pragma Optimize_Alignment::
180 * Pragma Persistent_BSS::
182 * Pragma Postcondition::
183 * Pragma Precondition::
184 * Pragma Profile (Ravenscar)::
185 * Pragma Profile (Restricted)::
186 * Pragma Psect_Object::
187 * Pragma Pure_Function::
188 * Pragma Restriction_Warnings::
190 * Pragma Short_Circuit_And_Or::
191 * Pragma Short_Descriptors::
192 * Pragma Source_File_Name::
193 * Pragma Source_File_Name_Project::
194 * Pragma Source_Reference::
195 * Pragma Stream_Convert::
196 * Pragma Style_Checks::
199 * Pragma Suppress_All::
200 * Pragma Suppress_Exception_Locations::
201 * Pragma Suppress_Initialization::
204 * Pragma Task_Storage::
205 * Pragma Thread_Local_Storage::
206 * Pragma Time_Slice::
208 * Pragma Unchecked_Union::
209 * Pragma Unimplemented_Unit::
210 * Pragma Universal_Aliasing ::
211 * Pragma Universal_Data::
212 * Pragma Unmodified::
213 * Pragma Unreferenced::
214 * Pragma Unreferenced_Objects::
215 * Pragma Unreserve_All_Interrupts::
216 * Pragma Unsuppress::
217 * Pragma Use_VADS_Size::
218 * Pragma Validity_Checks::
221 * Pragma Weak_External::
222 * Pragma Wide_Character_Encoding::
224 Implementation Defined Attributes
235 * Default_Bit_Order::
245 * Has_Access_Values::
246 * Has_Discriminants::
253 * Max_Interrupt_Priority::
255 * Maximum_Alignment::
260 * Passed_By_Reference::
274 * Unconstrained_Array::
275 * Universal_Literal_String::
276 * Unrestricted_Access::
282 The Implementation of Standard I/O
284 * Standard I/O Packages::
290 * Wide_Wide_Text_IO::
294 * Filenames encoding::
296 * Operations on C Streams::
297 * Interfacing to C Streams::
301 * Ada.Characters.Latin_9 (a-chlat9.ads)::
302 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
303 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
304 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
305 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
306 * Ada.Command_Line.Environment (a-colien.ads)::
307 * Ada.Command_Line.Remove (a-colire.ads)::
308 * Ada.Command_Line.Response_File (a-clrefi.ads)::
309 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
310 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
311 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
312 * Ada.Exceptions.Traceback (a-exctra.ads)::
313 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
314 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
315 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
316 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
317 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
318 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
319 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
320 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
321 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
322 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
323 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
324 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
325 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
326 * GNAT.Altivec (g-altive.ads)::
327 * GNAT.Altivec.Conversions (g-altcon.ads)::
328 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
329 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
330 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
331 * GNAT.Array_Split (g-arrspl.ads)::
332 * GNAT.AWK (g-awk.ads)::
333 * GNAT.Bounded_Buffers (g-boubuf.ads)::
334 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
335 * GNAT.Bubble_Sort (g-bubsor.ads)::
336 * GNAT.Bubble_Sort_A (g-busora.ads)::
337 * GNAT.Bubble_Sort_G (g-busorg.ads)::
338 * GNAT.Byte_Order_Mark (g-byorma.ads)::
339 * GNAT.Byte_Swapping (g-bytswa.ads)::
340 * GNAT.Calendar (g-calend.ads)::
341 * GNAT.Calendar.Time_IO (g-catiio.ads)::
342 * GNAT.Case_Util (g-casuti.ads)::
343 * GNAT.CGI (g-cgi.ads)::
344 * GNAT.CGI.Cookie (g-cgicoo.ads)::
345 * GNAT.CGI.Debug (g-cgideb.ads)::
346 * GNAT.Command_Line (g-comlin.ads)::
347 * GNAT.Compiler_Version (g-comver.ads)::
348 * GNAT.Ctrl_C (g-ctrl_c.ads)::
349 * GNAT.CRC32 (g-crc32.ads)::
350 * GNAT.Current_Exception (g-curexc.ads)::
351 * GNAT.Debug_Pools (g-debpoo.ads)::
352 * GNAT.Debug_Utilities (g-debuti.ads)::
353 * GNAT.Decode_String (g-decstr.ads)::
354 * GNAT.Decode_UTF8_String (g-deutst.ads)::
355 * GNAT.Directory_Operations (g-dirope.ads)::
356 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
357 * GNAT.Dynamic_HTables (g-dynhta.ads)::
358 * GNAT.Dynamic_Tables (g-dyntab.ads)::
359 * GNAT.Encode_String (g-encstr.ads)::
360 * GNAT.Encode_UTF8_String (g-enutst.ads)::
361 * GNAT.Exception_Actions (g-excact.ads)::
362 * GNAT.Exception_Traces (g-exctra.ads)::
363 * GNAT.Exceptions (g-except.ads)::
364 * GNAT.Expect (g-expect.ads)::
365 * GNAT.Float_Control (g-flocon.ads)::
366 * GNAT.Heap_Sort (g-heasor.ads)::
367 * GNAT.Heap_Sort_A (g-hesora.ads)::
368 * GNAT.Heap_Sort_G (g-hesorg.ads)::
369 * GNAT.HTable (g-htable.ads)::
370 * GNAT.IO (g-io.ads)::
371 * GNAT.IO_Aux (g-io_aux.ads)::
372 * GNAT.Lock_Files (g-locfil.ads)::
373 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
374 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
375 * GNAT.MD5 (g-md5.ads)::
376 * GNAT.Memory_Dump (g-memdum.ads)::
377 * GNAT.Most_Recent_Exception (g-moreex.ads)::
378 * GNAT.OS_Lib (g-os_lib.ads)::
379 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
380 * GNAT.Random_Numbers (g-rannum.ads)::
381 * GNAT.Regexp (g-regexp.ads)::
382 * GNAT.Registry (g-regist.ads)::
383 * GNAT.Regpat (g-regpat.ads)::
384 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
385 * GNAT.Semaphores (g-semaph.ads)::
386 * GNAT.Serial_Communications (g-sercom.ads)::
387 * GNAT.SHA1 (g-sha1.ads)::
388 * GNAT.SHA224 (g-sha224.ads)::
389 * GNAT.SHA256 (g-sha256.ads)::
390 * GNAT.SHA384 (g-sha384.ads)::
391 * GNAT.SHA512 (g-sha512.ads)::
392 * GNAT.Signals (g-signal.ads)::
393 * GNAT.Sockets (g-socket.ads)::
394 * GNAT.Source_Info (g-souinf.ads)::
395 * GNAT.Spelling_Checker (g-speche.ads)::
396 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
397 * GNAT.Spitbol.Patterns (g-spipat.ads)::
398 * GNAT.Spitbol (g-spitbo.ads)::
399 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
400 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
401 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
402 * GNAT.SSE (g-sse.ads)::
403 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
404 * GNAT.Strings (g-string.ads)::
405 * GNAT.String_Split (g-strspl.ads)::
406 * GNAT.Table (g-table.ads)::
407 * GNAT.Task_Lock (g-tasloc.ads)::
408 * GNAT.Threads (g-thread.ads)::
409 * GNAT.Time_Stamp (g-timsta.ads)::
410 * GNAT.Traceback (g-traceb.ads)::
411 * GNAT.Traceback.Symbolic (g-trasym.ads)::
412 * GNAT.UTF_32 (g-utf_32.ads)::
413 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
414 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
415 * GNAT.Wide_String_Split (g-wistsp.ads)::
416 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
417 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
418 * Interfaces.C.Extensions (i-cexten.ads)::
419 * Interfaces.C.Streams (i-cstrea.ads)::
420 * Interfaces.CPP (i-cpp.ads)::
421 * Interfaces.Packed_Decimal (i-pacdec.ads)::
422 * Interfaces.VxWorks (i-vxwork.ads)::
423 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
424 * System.Address_Image (s-addima.ads)::
425 * System.Assertions (s-assert.ads)::
426 * System.Memory (s-memory.ads)::
427 * System.Partition_Interface (s-parint.ads)::
428 * System.Pool_Global (s-pooglo.ads)::
429 * System.Pool_Local (s-pooloc.ads)::
430 * System.Restrictions (s-restri.ads)::
431 * System.Rident (s-rident.ads)::
432 * System.Strings.Stream_Ops (s-ststop.ads)::
433 * System.Task_Info (s-tasinf.ads)::
434 * System.Wch_Cnv (s-wchcnv.ads)::
435 * System.Wch_Con (s-wchcon.ads)::
439 * Text_IO Stream Pointer Positioning::
440 * Text_IO Reading and Writing Non-Regular Files::
442 * Treating Text_IO Files as Streams::
443 * Text_IO Extensions::
444 * Text_IO Facilities for Unbounded Strings::
448 * Wide_Text_IO Stream Pointer Positioning::
449 * Wide_Text_IO Reading and Writing Non-Regular Files::
453 * Wide_Wide_Text_IO Stream Pointer Positioning::
454 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
456 Interfacing to Other Languages
459 * Interfacing to C++::
460 * Interfacing to COBOL::
461 * Interfacing to Fortran::
462 * Interfacing to non-GNAT Ada code::
464 Specialized Needs Annexes
466 Implementation of Specific Ada Features
467 * Machine Code Insertions::
468 * GNAT Implementation of Tasking::
469 * GNAT Implementation of Shared Passive Packages::
470 * Code Generation for Array Aggregates::
471 * The Size of Discriminated Records with Default Discriminants::
472 * Strict Conformance to the Ada Reference Manual::
474 Implementation of Ada 2012 Features
478 GNU Free Documentation License
485 @node About This Guide
486 @unnumbered About This Guide
489 This manual contains useful information in writing programs using the
490 @value{EDITION} compiler. It includes information on implementation dependent
491 characteristics of @value{EDITION}, including all the information required by
492 Annex M of the Ada language standard.
494 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
495 Ada 83 compatibility mode.
496 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
497 but you can override with a compiler switch
498 to explicitly specify the language version.
499 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
500 @value{EDITION} User's Guide}, for details on these switches.)
501 Throughout this manual, references to ``Ada'' without a year suffix
502 apply to both the Ada 95 and Ada 2005 versions of the language.
504 Ada is designed to be highly portable.
505 In general, a program will have the same effect even when compiled by
506 different compilers on different platforms.
507 However, since Ada is designed to be used in a
508 wide variety of applications, it also contains a number of system
509 dependent features to be used in interfacing to the external world.
510 @cindex Implementation-dependent features
513 Note: Any program that makes use of implementation-dependent features
514 may be non-portable. You should follow good programming practice and
515 isolate and clearly document any sections of your program that make use
516 of these features in a non-portable manner.
519 For ease of exposition, ``GNAT Pro'' will be referred to simply as
520 ``GNAT'' in the remainder of this document.
524 * What This Reference Manual Contains::
526 * Related Information::
529 @node What This Reference Manual Contains
530 @unnumberedsec What This Reference Manual Contains
533 This reference manual contains the following chapters:
537 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
538 pragmas, which can be used to extend and enhance the functionality of the
542 @ref{Implementation Defined Attributes}, lists GNAT
543 implementation-dependent attributes which can be used to extend and
544 enhance the functionality of the compiler.
547 @ref{Implementation Advice}, provides information on generally
548 desirable behavior which are not requirements that all compilers must
549 follow since it cannot be provided on all systems, or which may be
550 undesirable on some systems.
553 @ref{Implementation Defined Characteristics}, provides a guide to
554 minimizing implementation dependent features.
557 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
558 implemented by GNAT, and how they can be imported into user
559 application programs.
562 @ref{Representation Clauses and Pragmas}, describes in detail the
563 way that GNAT represents data, and in particular the exact set
564 of representation clauses and pragmas that is accepted.
567 @ref{Standard Library Routines}, provides a listing of packages and a
568 brief description of the functionality that is provided by Ada's
569 extensive set of standard library routines as implemented by GNAT@.
572 @ref{The Implementation of Standard I/O}, details how the GNAT
573 implementation of the input-output facilities.
576 @ref{The GNAT Library}, is a catalog of packages that complement
577 the Ada predefined library.
580 @ref{Interfacing to Other Languages}, describes how programs
581 written in Ada using GNAT can be interfaced to other programming
584 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
585 of the specialized needs annexes.
588 @ref{Implementation of Specific Ada Features}, discusses issues related
589 to GNAT's implementation of machine code insertions, tasking, and several
593 @ref{Implementation of Ada 2012 Features}, describes the status of the
594 GNAT implementation of the Ada 2012 language standard.
597 @ref{Obsolescent Features} documents implementation dependent features,
598 including pragmas and attributes, which are considered obsolescent, since
599 there are other preferred ways of achieving the same results. These
600 obsolescent forms are retained for backwards compatibility.
604 @cindex Ada 95 Language Reference Manual
605 @cindex Ada 2005 Language Reference Manual
607 This reference manual assumes a basic familiarity with the Ada 95 language, as
608 described in the International Standard ANSI/ISO/IEC-8652:1995,
610 It does not require knowledge of the new features introduced by Ada 2005,
611 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
613 Both reference manuals are included in the GNAT documentation
617 @unnumberedsec Conventions
618 @cindex Conventions, typographical
619 @cindex Typographical conventions
622 Following are examples of the typographical and graphic conventions used
627 @code{Functions}, @code{utility program names}, @code{standard names},
634 @file{File names}, @samp{button names}, and @samp{field names}.
637 @code{Variables}, @env{environment variables}, and @var{metasyntactic
644 [optional information or parameters]
647 Examples are described by text
649 and then shown this way.
654 Commands that are entered by the user are preceded in this manual by the
655 characters @samp{$ } (dollar sign followed by space). If your system uses this
656 sequence as a prompt, then the commands will appear exactly as you see them
657 in the manual. If your system uses some other prompt, then the command will
658 appear with the @samp{$} replaced by whatever prompt character you are using.
660 @node Related Information
661 @unnumberedsec Related Information
663 See the following documents for further information on GNAT:
667 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
668 @value{EDITION} User's Guide}, which provides information on how to use the
669 GNAT compiler system.
672 @cite{Ada 95 Reference Manual}, which contains all reference
673 material for the Ada 95 programming language.
676 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
677 of the Ada 95 standard. The annotations describe
678 detailed aspects of the design decision, and in particular contain useful
679 sections on Ada 83 compatibility.
682 @cite{Ada 2005 Reference Manual}, which contains all reference
683 material for the Ada 2005 programming language.
686 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
687 of the Ada 2005 standard. The annotations describe
688 detailed aspects of the design decision, and in particular contain useful
689 sections on Ada 83 and Ada 95 compatibility.
692 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
693 which contains specific information on compatibility between GNAT and
697 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
698 describes in detail the pragmas and attributes provided by the DEC Ada 83
703 @node Implementation Defined Pragmas
704 @chapter Implementation Defined Pragmas
707 Ada defines a set of pragmas that can be used to supply additional
708 information to the compiler. These language defined pragmas are
709 implemented in GNAT and work as described in the Ada Reference Manual.
711 In addition, Ada allows implementations to define additional pragmas
712 whose meaning is defined by the implementation. GNAT provides a number
713 of these implementation-defined pragmas, which can be used to extend
714 and enhance the functionality of the compiler. This section of the GNAT
715 Reference Manual describes these additional pragmas.
717 Note that any program using these pragmas might not be portable to other
718 compilers (although GNAT implements this set of pragmas on all
719 platforms). Therefore if portability to other compilers is an important
720 consideration, the use of these pragmas should be minimized.
723 * Pragma Abort_Defer::
732 * Pragma Assume_No_Invalid_Values::
734 * Pragma C_Pass_By_Copy::
736 * Pragma Check_Name::
737 * Pragma Check_Policy::
739 * Pragma Common_Object::
740 * Pragma Compile_Time_Error::
741 * Pragma Compile_Time_Warning::
742 * Pragma Compiler_Unit::
743 * Pragma Complete_Representation::
744 * Pragma Complex_Representation::
745 * Pragma Component_Alignment::
746 * Pragma Convention_Identifier::
748 * Pragma CPP_Constructor::
749 * Pragma CPP_Virtual::
750 * Pragma CPP_Vtable::
752 * Pragma Debug_Policy::
753 * Pragma Detect_Blocking::
754 * Pragma Elaboration_Checks::
756 * Pragma Export_Exception::
757 * Pragma Export_Function::
758 * Pragma Export_Object::
759 * Pragma Export_Procedure::
760 * Pragma Export_Value::
761 * Pragma Export_Valued_Procedure::
762 * Pragma Extend_System::
763 * Pragma Extensions_Allowed::
765 * Pragma External_Name_Casing::
767 * Pragma Favor_Top_Level::
768 * Pragma Finalize_Storage_Only::
769 * Pragma Float_Representation::
771 * Pragma Implemented::
772 * Pragma Implicit_Packing::
773 * Pragma Import_Exception::
774 * Pragma Import_Function::
775 * Pragma Import_Object::
776 * Pragma Import_Procedure::
777 * Pragma Import_Valued_Procedure::
778 * Pragma Initialize_Scalars::
779 * Pragma Inline_Always::
780 * Pragma Inline_Generic::
782 * Pragma Interface_Name::
783 * Pragma Interrupt_Handler::
784 * Pragma Interrupt_State::
786 * Pragma Keep_Names::
789 * Pragma Linker_Alias::
790 * Pragma Linker_Constructor::
791 * Pragma Linker_Destructor::
792 * Pragma Linker_Section::
793 * Pragma Long_Float::
794 * Pragma Machine_Attribute::
796 * Pragma Main_Storage::
799 * Pragma No_Strict_Aliasing::
800 * Pragma Normalize_Scalars::
801 * Pragma Obsolescent::
802 * Pragma Optimize_Alignment::
805 * Pragma Persistent_BSS::
807 * Pragma Postcondition::
808 * Pragma Precondition::
809 * Pragma Profile (Ravenscar)::
810 * Pragma Profile (Restricted)::
811 * Pragma Psect_Object::
812 * Pragma Pure_Function::
813 * Pragma Restriction_Warnings::
815 * Pragma Short_Circuit_And_Or::
816 * Pragma Short_Descriptors::
817 * Pragma Source_File_Name::
818 * Pragma Source_File_Name_Project::
819 * Pragma Source_Reference::
820 * Pragma Stream_Convert::
821 * Pragma Style_Checks::
824 * Pragma Suppress_All::
825 * Pragma Suppress_Exception_Locations::
826 * Pragma Suppress_Initialization::
829 * Pragma Task_Storage::
830 * Pragma Thread_Local_Storage::
831 * Pragma Time_Slice::
833 * Pragma Unchecked_Union::
834 * Pragma Unimplemented_Unit::
835 * Pragma Universal_Aliasing ::
836 * Pragma Universal_Data::
837 * Pragma Unmodified::
838 * Pragma Unreferenced::
839 * Pragma Unreferenced_Objects::
840 * Pragma Unreserve_All_Interrupts::
841 * Pragma Unsuppress::
842 * Pragma Use_VADS_Size::
843 * Pragma Validity_Checks::
846 * Pragma Weak_External::
847 * Pragma Wide_Character_Encoding::
850 @node Pragma Abort_Defer
851 @unnumberedsec Pragma Abort_Defer
853 @cindex Deferring aborts
861 This pragma must appear at the start of the statement sequence of a
862 handled sequence of statements (right after the @code{begin}). It has
863 the effect of deferring aborts for the sequence of statements (but not
864 for the declarations or handlers, if any, associated with this statement
868 @unnumberedsec Pragma Ada_83
877 A configuration pragma that establishes Ada 83 mode for the unit to
878 which it applies, regardless of the mode set by the command line
879 switches. In Ada 83 mode, GNAT attempts to be as compatible with
880 the syntax and semantics of Ada 83, as defined in the original Ada
881 83 Reference Manual as possible. In particular, the keywords added by Ada 95
882 and Ada 2005 are not recognized, optional package bodies are allowed,
883 and generics may name types with unknown discriminants without using
884 the @code{(<>)} notation. In addition, some but not all of the additional
885 restrictions of Ada 83 are enforced.
887 Ada 83 mode is intended for two purposes. Firstly, it allows existing
888 Ada 83 code to be compiled and adapted to GNAT with less effort.
889 Secondly, it aids in keeping code backwards compatible with Ada 83.
890 However, there is no guarantee that code that is processed correctly
891 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
892 83 compiler, since GNAT does not enforce all the additional checks
896 @unnumberedsec Pragma Ada_95
905 A configuration pragma that establishes Ada 95 mode for the unit to which
906 it applies, regardless of the mode set by the command line switches.
907 This mode is set automatically for the @code{Ada} and @code{System}
908 packages and their children, so you need not specify it in these
909 contexts. This pragma is useful when writing a reusable component that
910 itself uses Ada 95 features, but which is intended to be usable from
911 either Ada 83 or Ada 95 programs.
914 @unnumberedsec Pragma Ada_05
923 A configuration pragma that establishes Ada 2005 mode for the unit to which
924 it applies, regardless of the mode set by the command line switches.
925 This pragma is useful when writing a reusable component that
926 itself uses Ada 2005 features, but which is intended to be usable from
927 either Ada 83 or Ada 95 programs.
929 @node Pragma Ada_2005
930 @unnumberedsec Pragma Ada_2005
939 This configuration pragma is a synonym for pragma Ada_05 and has the
940 same syntax and effect.
943 @unnumberedsec Pragma Ada_12
952 A configuration pragma that establishes Ada 2012 mode for the unit to which
953 it applies, regardless of the mode set by the command line switches.
954 This mode is set automatically for the @code{Ada} and @code{System}
955 packages and their children, so you need not specify it in these
956 contexts. This pragma is useful when writing a reusable component that
957 itself uses Ada 2012 features, but which is intended to be usable from
958 Ada 83, Ada 95, or Ada 2005 programs.
960 @node Pragma Ada_2012
961 @unnumberedsec Pragma Ada_2012
970 This configuration pragma is a synonym for pragma Ada_12 and has the
971 same syntax and effect.
973 @node Pragma Annotate
974 @unnumberedsec Pragma Annotate
979 pragma Annotate (IDENTIFIER [,IDENTIFIER] @{, ARG@});
981 ARG ::= NAME | EXPRESSION
985 This pragma is used to annotate programs. @var{identifier} identifies
986 the type of annotation. GNAT verifies that it is an identifier, but does
987 not otherwise analyze it. The second optional identifier is also left
988 unanalyzed, and by convention is used to control the action of the tool to
989 which the annotation is addressed. The remaining @var{arg} arguments
990 can be either string literals or more generally expressions.
991 String literals are assumed to be either of type
992 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
993 depending on the character literals they contain.
994 All other kinds of arguments are analyzed as expressions, and must be
997 The analyzed pragma is retained in the tree, but not otherwise processed
998 by any part of the GNAT compiler. This pragma is intended for use by
999 external tools, including ASIS@.
1002 @unnumberedsec Pragma Assert
1006 @smallexample @c ada
1009 [, string_EXPRESSION]);
1013 The effect of this pragma depends on whether the corresponding command
1014 line switch is set to activate assertions. The pragma expands into code
1015 equivalent to the following:
1017 @smallexample @c ada
1018 if assertions-enabled then
1019 if not boolean_EXPRESSION then
1020 System.Assertions.Raise_Assert_Failure
1021 (string_EXPRESSION);
1027 The string argument, if given, is the message that will be associated
1028 with the exception occurrence if the exception is raised. If no second
1029 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1030 where @var{file} is the name of the source file containing the assert,
1031 and @var{nnn} is the line number of the assert. A pragma is not a
1032 statement, so if a statement sequence contains nothing but a pragma
1033 assert, then a null statement is required in addition, as in:
1035 @smallexample @c ada
1038 pragma Assert (K > 3, "Bad value for K");
1044 Note that, as with the @code{if} statement to which it is equivalent, the
1045 type of the expression is either @code{Standard.Boolean}, or any type derived
1046 from this standard type.
1048 If assertions are disabled (switch @option{-gnata} not used), then there
1049 is no run-time effect (and in particular, any side effects from the
1050 expression will not occur at run time). (The expression is still
1051 analyzed at compile time, and may cause types to be frozen if they are
1052 mentioned here for the first time).
1054 If assertions are enabled, then the given expression is tested, and if
1055 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1056 which results in the raising of @code{Assert_Failure} with the given message.
1058 You should generally avoid side effects in the expression arguments of
1059 this pragma, because these side effects will turn on and off with the
1060 setting of the assertions mode, resulting in assertions that have an
1061 effect on the program. However, the expressions are analyzed for
1062 semantic correctness whether or not assertions are enabled, so turning
1063 assertions on and off cannot affect the legality of a program.
1065 @node Pragma Assume_No_Invalid_Values
1066 @unnumberedsec Pragma Assume_No_Invalid_Values
1067 @findex Assume_No_Invalid_Values
1068 @cindex Invalid representations
1069 @cindex Invalid values
1072 @smallexample @c ada
1073 pragma Assume_No_Invalid_Values (On | Off);
1077 This is a configuration pragma that controls the assumptions made by the
1078 compiler about the occurrence of invalid representations (invalid values)
1081 The default behavior (corresponding to an Off argument for this pragma), is
1082 to assume that values may in general be invalid unless the compiler can
1083 prove they are valid. Consider the following example:
1085 @smallexample @c ada
1086 V1 : Integer range 1 .. 10;
1087 V2 : Integer range 11 .. 20;
1089 for J in V2 .. V1 loop
1095 if V1 and V2 have valid values, then the loop is known at compile
1096 time not to execute since the lower bound must be greater than the
1097 upper bound. However in default mode, no such assumption is made,
1098 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1099 is given, the compiler will assume that any occurrence of a variable
1100 other than in an explicit @code{'Valid} test always has a valid
1101 value, and the loop above will be optimized away.
1103 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1104 you know your code is free of uninitialized variables and other
1105 possible sources of invalid representations, and may result in
1106 more efficient code. A program that accesses an invalid representation
1107 with this pragma in effect is erroneous, so no guarantees can be made
1110 It is peculiar though permissible to use this pragma in conjunction
1111 with validity checking (-gnatVa). In such cases, accessing invalid
1112 values will generally give an exception, though formally the program
1113 is erroneous so there are no guarantees that this will always be the
1114 case, and it is recommended that these two options not be used together.
1116 @node Pragma Ast_Entry
1117 @unnumberedsec Pragma Ast_Entry
1122 @smallexample @c ada
1123 pragma AST_Entry (entry_IDENTIFIER);
1127 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1128 argument is the simple name of a single entry; at most one @code{AST_Entry}
1129 pragma is allowed for any given entry. This pragma must be used in
1130 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1131 the entry declaration and in the same task type specification or single task
1132 as the entry to which it applies. This pragma specifies that the given entry
1133 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1134 resulting from an OpenVMS system service call. The pragma does not affect
1135 normal use of the entry. For further details on this pragma, see the
1136 DEC Ada Language Reference Manual, section 9.12a.
1138 @node Pragma C_Pass_By_Copy
1139 @unnumberedsec Pragma C_Pass_By_Copy
1140 @cindex Passing by copy
1141 @findex C_Pass_By_Copy
1144 @smallexample @c ada
1145 pragma C_Pass_By_Copy
1146 ([Max_Size =>] static_integer_EXPRESSION);
1150 Normally the default mechanism for passing C convention records to C
1151 convention subprograms is to pass them by reference, as suggested by RM
1152 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1153 this default, by requiring that record formal parameters be passed by
1154 copy if all of the following conditions are met:
1158 The size of the record type does not exceed the value specified for
1161 The record type has @code{Convention C}.
1163 The formal parameter has this record type, and the subprogram has a
1164 foreign (non-Ada) convention.
1168 If these conditions are met the argument is passed by copy, i.e.@: in a
1169 manner consistent with what C expects if the corresponding formal in the
1170 C prototype is a struct (rather than a pointer to a struct).
1172 You can also pass records by copy by specifying the convention
1173 @code{C_Pass_By_Copy} for the record type, or by using the extended
1174 @code{Import} and @code{Export} pragmas, which allow specification of
1175 passing mechanisms on a parameter by parameter basis.
1178 @unnumberedsec Pragma Check
1180 @cindex Named assertions
1184 @smallexample @c ada
1186 [Name =>] Identifier,
1187 [Check =>] Boolean_EXPRESSION
1188 [, [Message =>] string_EXPRESSION] );
1192 This pragma is similar to the predefined pragma @code{Assert} except that an
1193 extra identifier argument is present. In conjunction with pragma
1194 @code{Check_Policy}, this can be used to define groups of assertions that can
1195 be independently controlled. The identifier @code{Assertion} is special, it
1196 refers to the normal set of pragma @code{Assert} statements. The identifiers
1197 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1198 names, so these three names would normally not be used directly in a pragma
1201 Checks introduced by this pragma are normally deactivated by default. They can
1202 be activated either by the command line option @option{-gnata}, which turns on
1203 all checks, or individually controlled using pragma @code{Check_Policy}.
1205 @node Pragma Check_Name
1206 @unnumberedsec Pragma Check_Name
1207 @cindex Defining check names
1208 @cindex Check names, defining
1212 @smallexample @c ada
1213 pragma Check_Name (check_name_IDENTIFIER);
1217 This is a configuration pragma that defines a new implementation
1218 defined check name (unless IDENTIFIER matches one of the predefined
1219 check names, in which case the pragma has no effect). Check names
1220 are global to a partition, so if two or more configuration pragmas
1221 are present in a partition mentioning the same name, only one new
1222 check name is introduced.
1224 An implementation defined check name introduced with this pragma may
1225 be used in only three contexts: @code{pragma Suppress},
1226 @code{pragma Unsuppress},
1227 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1228 any of these three cases, the check name must be visible. A check
1229 name is visible if it is in the configuration pragmas applying to
1230 the current unit, or if it appears at the start of any unit that
1231 is part of the dependency set of the current unit (e.g., units that
1232 are mentioned in @code{with} clauses).
1234 @node Pragma Check_Policy
1235 @unnumberedsec Pragma Check_Policy
1236 @cindex Controlling assertions
1237 @cindex Assertions, control
1238 @cindex Check pragma control
1239 @cindex Named assertions
1243 @smallexample @c ada
1245 ([Name =>] Identifier,
1246 [Policy =>] POLICY_IDENTIFIER);
1248 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1252 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1253 except that it controls sets of named assertions introduced using the
1254 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1255 @code{Assertion_Policy}) can be used within a declarative part, in which case
1256 it controls the status to the end of the corresponding construct (in a manner
1257 identical to pragma @code{Suppress)}.
1259 The identifier given as the first argument corresponds to a name used in
1260 associated @code{Check} pragmas. For example, if the pragma:
1262 @smallexample @c ada
1263 pragma Check_Policy (Critical_Error, Off);
1267 is given, then subsequent @code{Check} pragmas whose first argument is also
1268 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1269 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1270 @code{Check_Policy} with this identifier is similar to the normal
1271 @code{Assertion_Policy} pragma except that it can appear within a
1274 The special identifiers @code{Precondition} and @code{Postcondition} control
1275 the status of preconditions and postconditions. If a @code{Precondition} pragma
1276 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1277 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1278 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1281 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1282 to turn on corresponding checks. The default for a set of checks for which no
1283 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1284 @option{-gnata} is given, which turns on all checks by default.
1286 The check policy settings @code{Check} and @code{Ignore} are also recognized
1287 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1288 compatibility with the standard @code{Assertion_Policy} pragma.
1290 @node Pragma Comment
1291 @unnumberedsec Pragma Comment
1296 @smallexample @c ada
1297 pragma Comment (static_string_EXPRESSION);
1301 This is almost identical in effect to pragma @code{Ident}. It allows the
1302 placement of a comment into the object file and hence into the
1303 executable file if the operating system permits such usage. The
1304 difference is that @code{Comment}, unlike @code{Ident}, has
1305 no limitations on placement of the pragma (it can be placed
1306 anywhere in the main source unit), and if more than one pragma
1307 is used, all comments are retained.
1309 @node Pragma Common_Object
1310 @unnumberedsec Pragma Common_Object
1311 @findex Common_Object
1315 @smallexample @c ada
1316 pragma Common_Object (
1317 [Internal =>] LOCAL_NAME
1318 [, [External =>] EXTERNAL_SYMBOL]
1319 [, [Size =>] EXTERNAL_SYMBOL] );
1323 | static_string_EXPRESSION
1327 This pragma enables the shared use of variables stored in overlaid
1328 linker areas corresponding to the use of @code{COMMON}
1329 in Fortran. The single
1330 object @var{LOCAL_NAME} is assigned to the area designated by
1331 the @var{External} argument.
1332 You may define a record to correspond to a series
1333 of fields. The @var{Size} argument
1334 is syntax checked in GNAT, but otherwise ignored.
1336 @code{Common_Object} is not supported on all platforms. If no
1337 support is available, then the code generator will issue a message
1338 indicating that the necessary attribute for implementation of this
1339 pragma is not available.
1341 @node Pragma Compile_Time_Error
1342 @unnumberedsec Pragma Compile_Time_Error
1343 @findex Compile_Time_Error
1347 @smallexample @c ada
1348 pragma Compile_Time_Error
1349 (boolean_EXPRESSION, static_string_EXPRESSION);
1353 This pragma can be used to generate additional compile time
1355 is particularly useful in generics, where errors can be issued for
1356 specific problematic instantiations. The first parameter is a boolean
1357 expression. The pragma is effective only if the value of this expression
1358 is known at compile time, and has the value True. The set of expressions
1359 whose values are known at compile time includes all static boolean
1360 expressions, and also other values which the compiler can determine
1361 at compile time (e.g., the size of a record type set by an explicit
1362 size representation clause, or the value of a variable which was
1363 initialized to a constant and is known not to have been modified).
1364 If these conditions are met, an error message is generated using
1365 the value given as the second argument. This string value may contain
1366 embedded ASCII.LF characters to break the message into multiple lines.
1368 @node Pragma Compile_Time_Warning
1369 @unnumberedsec Pragma Compile_Time_Warning
1370 @findex Compile_Time_Warning
1374 @smallexample @c ada
1375 pragma Compile_Time_Warning
1376 (boolean_EXPRESSION, static_string_EXPRESSION);
1380 Same as pragma Compile_Time_Error, except a warning is issued instead
1381 of an error message. Note that if this pragma is used in a package that
1382 is with'ed by a client, the client will get the warning even though it
1383 is issued by a with'ed package (normally warnings in with'ed units are
1384 suppressed, but this is a special exception to that rule).
1386 One typical use is within a generic where compile time known characteristics
1387 of formal parameters are tested, and warnings given appropriately. Another use
1388 with a first parameter of True is to warn a client about use of a package,
1389 for example that it is not fully implemented.
1391 @node Pragma Compiler_Unit
1392 @unnumberedsec Pragma Compiler_Unit
1393 @findex Compiler_Unit
1397 @smallexample @c ada
1398 pragma Compiler_Unit;
1402 This pragma is intended only for internal use in the GNAT run-time library.
1403 It indicates that the unit is used as part of the compiler build. The effect
1404 is to disallow constructs (raise with message, conditional expressions etc)
1405 that would cause trouble when bootstrapping using an older version of GNAT.
1406 For the exact list of restrictions, see the compiler sources and references
1407 to Is_Compiler_Unit.
1409 @node Pragma Complete_Representation
1410 @unnumberedsec Pragma Complete_Representation
1411 @findex Complete_Representation
1415 @smallexample @c ada
1416 pragma Complete_Representation;
1420 This pragma must appear immediately within a record representation
1421 clause. Typical placements are before the first component clause
1422 or after the last component clause. The effect is to give an error
1423 message if any component is missing a component clause. This pragma
1424 may be used to ensure that a record representation clause is
1425 complete, and that this invariant is maintained if fields are
1426 added to the record in the future.
1428 @node Pragma Complex_Representation
1429 @unnumberedsec Pragma Complex_Representation
1430 @findex Complex_Representation
1434 @smallexample @c ada
1435 pragma Complex_Representation
1436 ([Entity =>] LOCAL_NAME);
1440 The @var{Entity} argument must be the name of a record type which has
1441 two fields of the same floating-point type. The effect of this pragma is
1442 to force gcc to use the special internal complex representation form for
1443 this record, which may be more efficient. Note that this may result in
1444 the code for this type not conforming to standard ABI (application
1445 binary interface) requirements for the handling of record types. For
1446 example, in some environments, there is a requirement for passing
1447 records by pointer, and the use of this pragma may result in passing
1448 this type in floating-point registers.
1450 @node Pragma Component_Alignment
1451 @unnumberedsec Pragma Component_Alignment
1452 @cindex Alignments of components
1453 @findex Component_Alignment
1457 @smallexample @c ada
1458 pragma Component_Alignment (
1459 [Form =>] ALIGNMENT_CHOICE
1460 [, [Name =>] type_LOCAL_NAME]);
1462 ALIGNMENT_CHOICE ::=
1470 Specifies the alignment of components in array or record types.
1471 The meaning of the @var{Form} argument is as follows:
1474 @findex Component_Size
1475 @item Component_Size
1476 Aligns scalar components and subcomponents of the array or record type
1477 on boundaries appropriate to their inherent size (naturally
1478 aligned). For example, 1-byte components are aligned on byte boundaries,
1479 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1480 integer components are aligned on 4-byte boundaries and so on. These
1481 alignment rules correspond to the normal rules for C compilers on all
1482 machines except the VAX@.
1484 @findex Component_Size_4
1485 @item Component_Size_4
1486 Naturally aligns components with a size of four or fewer
1487 bytes. Components that are larger than 4 bytes are placed on the next
1490 @findex Storage_Unit
1492 Specifies that array or record components are byte aligned, i.e.@:
1493 aligned on boundaries determined by the value of the constant
1494 @code{System.Storage_Unit}.
1498 Specifies that array or record components are aligned on default
1499 boundaries, appropriate to the underlying hardware or operating system or
1500 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1501 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1502 the @code{Default} choice is the same as @code{Component_Size} (natural
1507 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1508 refer to a local record or array type, and the specified alignment
1509 choice applies to the specified type. The use of
1510 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1511 @code{Component_Alignment} pragma to be ignored. The use of
1512 @code{Component_Alignment} together with a record representation clause
1513 is only effective for fields not specified by the representation clause.
1515 If the @code{Name} parameter is absent, the pragma can be used as either
1516 a configuration pragma, in which case it applies to one or more units in
1517 accordance with the normal rules for configuration pragmas, or it can be
1518 used within a declarative part, in which case it applies to types that
1519 are declared within this declarative part, or within any nested scope
1520 within this declarative part. In either case it specifies the alignment
1521 to be applied to any record or array type which has otherwise standard
1524 If the alignment for a record or array type is not specified (using
1525 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1526 clause), the GNAT uses the default alignment as described previously.
1528 @node Pragma Convention_Identifier
1529 @unnumberedsec Pragma Convention_Identifier
1530 @findex Convention_Identifier
1531 @cindex Conventions, synonyms
1535 @smallexample @c ada
1536 pragma Convention_Identifier (
1537 [Name =>] IDENTIFIER,
1538 [Convention =>] convention_IDENTIFIER);
1542 This pragma provides a mechanism for supplying synonyms for existing
1543 convention identifiers. The @code{Name} identifier can subsequently
1544 be used as a synonym for the given convention in other pragmas (including
1545 for example pragma @code{Import} or another @code{Convention_Identifier}
1546 pragma). As an example of the use of this, suppose you had legacy code
1547 which used Fortran77 as the identifier for Fortran. Then the pragma:
1549 @smallexample @c ada
1550 pragma Convention_Identifier (Fortran77, Fortran);
1554 would allow the use of the convention identifier @code{Fortran77} in
1555 subsequent code, avoiding the need to modify the sources. As another
1556 example, you could use this to parameterize convention requirements
1557 according to systems. Suppose you needed to use @code{Stdcall} on
1558 windows systems, and @code{C} on some other system, then you could
1559 define a convention identifier @code{Library} and use a single
1560 @code{Convention_Identifier} pragma to specify which convention
1561 would be used system-wide.
1563 @node Pragma CPP_Class
1564 @unnumberedsec Pragma CPP_Class
1566 @cindex Interfacing with C++
1570 @smallexample @c ada
1571 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1575 The argument denotes an entity in the current declarative region that is
1576 declared as a record type. It indicates that the type corresponds to an
1577 externally declared C++ class type, and is to be laid out the same way
1578 that C++ would lay out the type. If the C++ class has virtual primitives
1579 then the record must be declared as a tagged record type.
1581 Types for which @code{CPP_Class} is specified do not have assignment or
1582 equality operators defined (such operations can be imported or declared
1583 as subprograms as required). Initialization is allowed only by constructor
1584 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1585 limited if not explicitly declared as limited or derived from a limited
1586 type, and an error is issued in that case.
1588 Pragma @code{CPP_Class} is intended primarily for automatic generation
1589 using an automatic binding generator tool.
1590 See @ref{Interfacing to C++} for related information.
1592 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1593 for backward compatibility but its functionality is available
1594 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1596 @node Pragma CPP_Constructor
1597 @unnumberedsec Pragma CPP_Constructor
1598 @cindex Interfacing with C++
1599 @findex CPP_Constructor
1603 @smallexample @c ada
1604 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1605 [, [External_Name =>] static_string_EXPRESSION ]
1606 [, [Link_Name =>] static_string_EXPRESSION ]);
1610 This pragma identifies an imported function (imported in the usual way
1611 with pragma @code{Import}) as corresponding to a C++ constructor. If
1612 @code{External_Name} and @code{Link_Name} are not specified then the
1613 @code{Entity} argument is a name that must have been previously mentioned
1614 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1615 must be of one of the following forms:
1619 @code{function @var{Fname} return @var{T}}
1623 @code{function @var{Fname} return @var{T}'Class}
1626 @code{function @var{Fname} (@dots{}) return @var{T}}
1630 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1634 where @var{T} is a limited record type imported from C++ with pragma
1635 @code{Import} and @code{Convention} = @code{CPP}.
1637 The first two forms import the default constructor, used when an object
1638 of type @var{T} is created on the Ada side with no explicit constructor.
1639 The latter two forms cover all the non-default constructors of the type.
1640 See the GNAT users guide for details.
1642 If no constructors are imported, it is impossible to create any objects
1643 on the Ada side and the type is implicitly declared abstract.
1645 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1646 using an automatic binding generator tool.
1647 See @ref{Interfacing to C++} for more related information.
1649 Note: The use of functions returning class-wide types for constructors is
1650 currently obsolete. They are supported for backward compatibility. The
1651 use of functions returning the type T leave the Ada sources more clear
1652 because the imported C++ constructors always return an object of type T;
1653 that is, they never return an object whose type is a descendant of type T.
1655 @node Pragma CPP_Virtual
1656 @unnumberedsec Pragma CPP_Virtual
1657 @cindex Interfacing to C++
1660 This pragma is now obsolete has has no effect because GNAT generates
1661 the same object layout than the G++ compiler.
1663 See @ref{Interfacing to C++} for related information.
1665 @node Pragma CPP_Vtable
1666 @unnumberedsec Pragma CPP_Vtable
1667 @cindex Interfacing with C++
1670 This pragma is now obsolete has has no effect because GNAT generates
1671 the same object layout than the G++ compiler.
1673 See @ref{Interfacing to C++} for related information.
1676 @unnumberedsec Pragma Debug
1681 @smallexample @c ada
1682 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1684 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1686 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1690 The procedure call argument has the syntactic form of an expression, meeting
1691 the syntactic requirements for pragmas.
1693 If debug pragmas are not enabled or if the condition is present and evaluates
1694 to False, this pragma has no effect. If debug pragmas are enabled, the
1695 semantics of the pragma is exactly equivalent to the procedure call statement
1696 corresponding to the argument with a terminating semicolon. Pragmas are
1697 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1698 intersperse calls to debug procedures in the middle of declarations. Debug
1699 pragmas can be enabled either by use of the command line switch @option{-gnata}
1700 or by use of the configuration pragma @code{Debug_Policy}.
1702 @node Pragma Debug_Policy
1703 @unnumberedsec Pragma Debug_Policy
1704 @findex Debug_Policy
1708 @smallexample @c ada
1709 pragma Debug_Policy (CHECK | IGNORE);
1713 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1714 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1715 This pragma overrides the effect of the @option{-gnata} switch on the
1718 @node Pragma Detect_Blocking
1719 @unnumberedsec Pragma Detect_Blocking
1720 @findex Detect_Blocking
1724 @smallexample @c ada
1725 pragma Detect_Blocking;
1729 This is a configuration pragma that forces the detection of potentially
1730 blocking operations within a protected operation, and to raise Program_Error
1733 @node Pragma Elaboration_Checks
1734 @unnumberedsec Pragma Elaboration_Checks
1735 @cindex Elaboration control
1736 @findex Elaboration_Checks
1740 @smallexample @c ada
1741 pragma Elaboration_Checks (Dynamic | Static);
1745 This is a configuration pragma that provides control over the
1746 elaboration model used by the compilation affected by the
1747 pragma. If the parameter is @code{Dynamic},
1748 then the dynamic elaboration
1749 model described in the Ada Reference Manual is used, as though
1750 the @option{-gnatE} switch had been specified on the command
1751 line. If the parameter is @code{Static}, then the default GNAT static
1752 model is used. This configuration pragma overrides the setting
1753 of the command line. For full details on the elaboration models
1754 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1755 gnat_ugn, @value{EDITION} User's Guide}.
1757 @node Pragma Eliminate
1758 @unnumberedsec Pragma Eliminate
1759 @cindex Elimination of unused subprograms
1764 @smallexample @c ada
1765 pragma Eliminate (UNIT_NAME, ENTITY, Source_Location => SOURCE_TRACE)
1767 UNIT_NAME ::= IDENTIFIER |
1770 ENTITY ::= IDENTIFIER |
1773 SOURCE_TRACE ::= SOURCE_REFERENCE |
1774 SOURCE_REFERENCE LBRACKET SOURCE_TRACE RBRACKET
1779 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
1781 FILE_NAME ::= STRING_LITERAL
1782 LINE_NUMBER ::= INTEGER_LITERAL
1786 This pragma indicates that the given entity is not used in the program
1787 to be compiled and built. The entity must be an explicitly declared
1788 subprogram; this includes generic subprogram instances and
1789 subprograms declared in generic package instances. @code{Unit_Name}
1790 must be the name of the compilation unit in which the entity is declared.
1792 The @code{Source_Location} argument is used to resolve overloading
1793 in case more then one callable entity with the same name is declared
1794 in the given compilation unit. Each file name must be the short name of the
1795 source file (with no directory information).
1796 If an entity is not declared in
1797 a generic instantiation (this includes generic subprogram instances),
1798 the source trace includes only one source
1799 reference. If an entity is declared inside a generic instantiation,
1800 its source trace starts from the source location in the instantiation and
1801 ends with the source location of the declaration of the corresponding
1802 entity in the generic
1803 unit. This approach is recursively used in case of nested instantiations:
1804 the leftmost element of the
1805 source trace is the location of the outermost instantiation, the next
1806 element is the location of the next (first nested) instantiation in the
1807 code of the corresponding generic unit, and so on.
1809 The effect of the pragma is to allow the compiler to eliminate
1810 the code or data associated with the named entity. Any reference to
1811 an eliminated entity outside the compilation unit where it is defined
1812 causes a compile-time or link-time error.
1814 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1815 in a system-independent manner, with unused entities eliminated, without
1816 needing to modify the source text. Normally the required set
1817 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1818 tool. Elimination of unused entities local to a compilation unit is
1819 automatic, without requiring the use of pragma @code{Eliminate}.
1821 Any source file change that removes, splits, or
1822 adds lines may make the set of Eliminate pragmas invalid because their
1823 @code{Source_Location} argument values may get out of date.
1825 Pragma Eliminate may be used where the referenced entity is a
1826 dispatching operation. In this case all the subprograms to which the
1827 given operation can dispatch are considered to be unused (are never called
1828 as a result of a direct or a dispatching call).
1830 @node Pragma Export_Exception
1831 @unnumberedsec Pragma Export_Exception
1833 @findex Export_Exception
1837 @smallexample @c ada
1838 pragma Export_Exception (
1839 [Internal =>] LOCAL_NAME
1840 [, [External =>] EXTERNAL_SYMBOL]
1841 [, [Form =>] Ada | VMS]
1842 [, [Code =>] static_integer_EXPRESSION]);
1846 | static_string_EXPRESSION
1850 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1851 causes the specified exception to be propagated outside of the Ada program,
1852 so that it can be handled by programs written in other OpenVMS languages.
1853 This pragma establishes an external name for an Ada exception and makes the
1854 name available to the OpenVMS Linker as a global symbol. For further details
1855 on this pragma, see the
1856 DEC Ada Language Reference Manual, section 13.9a3.2.
1858 @node Pragma Export_Function
1859 @unnumberedsec Pragma Export_Function
1860 @cindex Argument passing mechanisms
1861 @findex Export_Function
1866 @smallexample @c ada
1867 pragma Export_Function (
1868 [Internal =>] LOCAL_NAME
1869 [, [External =>] EXTERNAL_SYMBOL]
1870 [, [Parameter_Types =>] PARAMETER_TYPES]
1871 [, [Result_Type =>] result_SUBTYPE_MARK]
1872 [, [Mechanism =>] MECHANISM]
1873 [, [Result_Mechanism =>] MECHANISM_NAME]);
1877 | static_string_EXPRESSION
1882 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1886 | subtype_Name ' Access
1890 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1892 MECHANISM_ASSOCIATION ::=
1893 [formal_parameter_NAME =>] MECHANISM_NAME
1898 | Descriptor [([Class =>] CLASS_NAME)]
1899 | Short_Descriptor [([Class =>] CLASS_NAME)]
1901 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1905 Use this pragma to make a function externally callable and optionally
1906 provide information on mechanisms to be used for passing parameter and
1907 result values. We recommend, for the purposes of improving portability,
1908 this pragma always be used in conjunction with a separate pragma
1909 @code{Export}, which must precede the pragma @code{Export_Function}.
1910 GNAT does not require a separate pragma @code{Export}, but if none is
1911 present, @code{Convention Ada} is assumed, which is usually
1912 not what is wanted, so it is usually appropriate to use this
1913 pragma in conjunction with a @code{Export} or @code{Convention}
1914 pragma that specifies the desired foreign convention.
1915 Pragma @code{Export_Function}
1916 (and @code{Export}, if present) must appear in the same declarative
1917 region as the function to which they apply.
1919 @var{internal_name} must uniquely designate the function to which the
1920 pragma applies. If more than one function name exists of this name in
1921 the declarative part you must use the @code{Parameter_Types} and
1922 @code{Result_Type} parameters is mandatory to achieve the required
1923 unique designation. @var{subtype_mark}s in these parameters must
1924 exactly match the subtypes in the corresponding function specification,
1925 using positional notation to match parameters with subtype marks.
1926 The form with an @code{'Access} attribute can be used to match an
1927 anonymous access parameter.
1930 @cindex Passing by descriptor
1931 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1932 The default behavior for Export_Function is to accept either 64bit or
1933 32bit descriptors unless short_descriptor is specified, then only 32bit
1934 descriptors are accepted.
1936 @cindex Suppressing external name
1937 Special treatment is given if the EXTERNAL is an explicit null
1938 string or a static string expressions that evaluates to the null
1939 string. In this case, no external name is generated. This form
1940 still allows the specification of parameter mechanisms.
1942 @node Pragma Export_Object
1943 @unnumberedsec Pragma Export_Object
1944 @findex Export_Object
1948 @smallexample @c ada
1949 pragma Export_Object
1950 [Internal =>] LOCAL_NAME
1951 [, [External =>] EXTERNAL_SYMBOL]
1952 [, [Size =>] EXTERNAL_SYMBOL]
1956 | static_string_EXPRESSION
1960 This pragma designates an object as exported, and apart from the
1961 extended rules for external symbols, is identical in effect to the use of
1962 the normal @code{Export} pragma applied to an object. You may use a
1963 separate Export pragma (and you probably should from the point of view
1964 of portability), but it is not required. @var{Size} is syntax checked,
1965 but otherwise ignored by GNAT@.
1967 @node Pragma Export_Procedure
1968 @unnumberedsec Pragma Export_Procedure
1969 @findex Export_Procedure
1973 @smallexample @c ada
1974 pragma Export_Procedure (
1975 [Internal =>] LOCAL_NAME
1976 [, [External =>] EXTERNAL_SYMBOL]
1977 [, [Parameter_Types =>] PARAMETER_TYPES]
1978 [, [Mechanism =>] MECHANISM]);
1982 | static_string_EXPRESSION
1987 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1991 | subtype_Name ' Access
1995 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1997 MECHANISM_ASSOCIATION ::=
1998 [formal_parameter_NAME =>] MECHANISM_NAME
2003 | Descriptor [([Class =>] CLASS_NAME)]
2004 | Short_Descriptor [([Class =>] CLASS_NAME)]
2006 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2010 This pragma is identical to @code{Export_Function} except that it
2011 applies to a procedure rather than a function and the parameters
2012 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2013 GNAT does not require a separate pragma @code{Export}, but if none is
2014 present, @code{Convention Ada} is assumed, which is usually
2015 not what is wanted, so it is usually appropriate to use this
2016 pragma in conjunction with a @code{Export} or @code{Convention}
2017 pragma that specifies the desired foreign convention.
2020 @cindex Passing by descriptor
2021 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2022 The default behavior for Export_Procedure is to accept either 64bit or
2023 32bit descriptors unless short_descriptor is specified, then only 32bit
2024 descriptors are accepted.
2026 @cindex Suppressing external name
2027 Special treatment is given if the EXTERNAL is an explicit null
2028 string or a static string expressions that evaluates to the null
2029 string. In this case, no external name is generated. This form
2030 still allows the specification of parameter mechanisms.
2032 @node Pragma Export_Value
2033 @unnumberedsec Pragma Export_Value
2034 @findex Export_Value
2038 @smallexample @c ada
2039 pragma Export_Value (
2040 [Value =>] static_integer_EXPRESSION,
2041 [Link_Name =>] static_string_EXPRESSION);
2045 This pragma serves to export a static integer value for external use.
2046 The first argument specifies the value to be exported. The Link_Name
2047 argument specifies the symbolic name to be associated with the integer
2048 value. This pragma is useful for defining a named static value in Ada
2049 that can be referenced in assembly language units to be linked with
2050 the application. This pragma is currently supported only for the
2051 AAMP target and is ignored for other targets.
2053 @node Pragma Export_Valued_Procedure
2054 @unnumberedsec Pragma Export_Valued_Procedure
2055 @findex Export_Valued_Procedure
2059 @smallexample @c ada
2060 pragma Export_Valued_Procedure (
2061 [Internal =>] LOCAL_NAME
2062 [, [External =>] EXTERNAL_SYMBOL]
2063 [, [Parameter_Types =>] PARAMETER_TYPES]
2064 [, [Mechanism =>] MECHANISM]);
2068 | static_string_EXPRESSION
2073 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2077 | subtype_Name ' Access
2081 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2083 MECHANISM_ASSOCIATION ::=
2084 [formal_parameter_NAME =>] MECHANISM_NAME
2089 | Descriptor [([Class =>] CLASS_NAME)]
2090 | Short_Descriptor [([Class =>] CLASS_NAME)]
2092 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2096 This pragma is identical to @code{Export_Procedure} except that the
2097 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2098 mode @code{OUT}, and externally the subprogram is treated as a function
2099 with this parameter as the result of the function. GNAT provides for
2100 this capability to allow the use of @code{OUT} and @code{IN OUT}
2101 parameters in interfacing to external functions (which are not permitted
2103 GNAT does not require a separate pragma @code{Export}, but if none is
2104 present, @code{Convention Ada} is assumed, which is almost certainly
2105 not what is wanted since the whole point of this pragma is to interface
2106 with foreign language functions, so it is usually appropriate to use this
2107 pragma in conjunction with a @code{Export} or @code{Convention}
2108 pragma that specifies the desired foreign convention.
2111 @cindex Passing by descriptor
2112 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2113 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2114 32bit descriptors unless short_descriptor is specified, then only 32bit
2115 descriptors are accepted.
2117 @cindex Suppressing external name
2118 Special treatment is given if the EXTERNAL is an explicit null
2119 string or a static string expressions that evaluates to the null
2120 string. In this case, no external name is generated. This form
2121 still allows the specification of parameter mechanisms.
2123 @node Pragma Extend_System
2124 @unnumberedsec Pragma Extend_System
2125 @cindex @code{system}, extending
2127 @findex Extend_System
2131 @smallexample @c ada
2132 pragma Extend_System ([Name =>] IDENTIFIER);
2136 This pragma is used to provide backwards compatibility with other
2137 implementations that extend the facilities of package @code{System}. In
2138 GNAT, @code{System} contains only the definitions that are present in
2139 the Ada RM@. However, other implementations, notably the DEC Ada 83
2140 implementation, provide many extensions to package @code{System}.
2142 For each such implementation accommodated by this pragma, GNAT provides a
2143 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2144 implementation, which provides the required additional definitions. You
2145 can use this package in two ways. You can @code{with} it in the normal
2146 way and access entities either by selection or using a @code{use}
2147 clause. In this case no special processing is required.
2149 However, if existing code contains references such as
2150 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2151 definitions provided in package @code{System}, you may use this pragma
2152 to extend visibility in @code{System} in a non-standard way that
2153 provides greater compatibility with the existing code. Pragma
2154 @code{Extend_System} is a configuration pragma whose single argument is
2155 the name of the package containing the extended definition
2156 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2157 control of this pragma will be processed using special visibility
2158 processing that looks in package @code{System.Aux_@var{xxx}} where
2159 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2160 package @code{System}, but not found in package @code{System}.
2162 You can use this pragma either to access a predefined @code{System}
2163 extension supplied with the compiler, for example @code{Aux_DEC} or
2164 you can construct your own extension unit following the above
2165 definition. Note that such a package is a child of @code{System}
2166 and thus is considered part of the implementation. To compile
2167 it you will have to use the appropriate switch for compiling
2169 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2172 @node Pragma Extensions_Allowed
2173 @unnumberedsec Pragma Extensions_Allowed
2174 @cindex Ada Extensions
2175 @cindex GNAT Extensions
2176 @findex Extensions_Allowed
2180 @smallexample @c ada
2181 pragma Extensions_Allowed (On | Off);
2185 This configuration pragma enables or disables the implementation
2186 extension mode (the use of Off as a parameter cancels the effect
2187 of the @option{-gnatX} command switch).
2189 In extension mode, the latest version of the Ada language is
2190 implemented (currently Ada 2012), and in addition a small number
2191 of GNAT specific extensions are recognized as follows:
2194 @item Constrained attribute for generic objects
2195 The @code{Constrained} attribute is permitted for objects of
2196 generic types. The result indicates if the corresponding actual
2201 @node Pragma External
2202 @unnumberedsec Pragma External
2207 @smallexample @c ada
2209 [ Convention =>] convention_IDENTIFIER,
2210 [ Entity =>] LOCAL_NAME
2211 [, [External_Name =>] static_string_EXPRESSION ]
2212 [, [Link_Name =>] static_string_EXPRESSION ]);
2216 This pragma is identical in syntax and semantics to pragma
2217 @code{Export} as defined in the Ada Reference Manual. It is
2218 provided for compatibility with some Ada 83 compilers that
2219 used this pragma for exactly the same purposes as pragma
2220 @code{Export} before the latter was standardized.
2222 @node Pragma External_Name_Casing
2223 @unnumberedsec Pragma External_Name_Casing
2224 @cindex Dec Ada 83 casing compatibility
2225 @cindex External Names, casing
2226 @cindex Casing of External names
2227 @findex External_Name_Casing
2231 @smallexample @c ada
2232 pragma External_Name_Casing (
2233 Uppercase | Lowercase
2234 [, Uppercase | Lowercase | As_Is]);
2238 This pragma provides control over the casing of external names associated
2239 with Import and Export pragmas. There are two cases to consider:
2242 @item Implicit external names
2243 Implicit external names are derived from identifiers. The most common case
2244 arises when a standard Ada Import or Export pragma is used with only two
2247 @smallexample @c ada
2248 pragma Import (C, C_Routine);
2252 Since Ada is a case-insensitive language, the spelling of the identifier in
2253 the Ada source program does not provide any information on the desired
2254 casing of the external name, and so a convention is needed. In GNAT the
2255 default treatment is that such names are converted to all lower case
2256 letters. This corresponds to the normal C style in many environments.
2257 The first argument of pragma @code{External_Name_Casing} can be used to
2258 control this treatment. If @code{Uppercase} is specified, then the name
2259 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2260 then the normal default of all lower case letters will be used.
2262 This same implicit treatment is also used in the case of extended DEC Ada 83
2263 compatible Import and Export pragmas where an external name is explicitly
2264 specified using an identifier rather than a string.
2266 @item Explicit external names
2267 Explicit external names are given as string literals. The most common case
2268 arises when a standard Ada Import or Export pragma is used with three
2271 @smallexample @c ada
2272 pragma Import (C, C_Routine, "C_routine");
2276 In this case, the string literal normally provides the exact casing required
2277 for the external name. The second argument of pragma
2278 @code{External_Name_Casing} may be used to modify this behavior.
2279 If @code{Uppercase} is specified, then the name
2280 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2281 then the name will be forced to all lowercase letters. A specification of
2282 @code{As_Is} provides the normal default behavior in which the casing is
2283 taken from the string provided.
2287 This pragma may appear anywhere that a pragma is valid. In particular, it
2288 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2289 case it applies to all subsequent compilations, or it can be used as a program
2290 unit pragma, in which case it only applies to the current unit, or it can
2291 be used more locally to control individual Import/Export pragmas.
2293 It is primarily intended for use with OpenVMS systems, where many
2294 compilers convert all symbols to upper case by default. For interfacing to
2295 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2298 @smallexample @c ada
2299 pragma External_Name_Casing (Uppercase, Uppercase);
2303 to enforce the upper casing of all external symbols.
2305 @node Pragma Fast_Math
2306 @unnumberedsec Pragma Fast_Math
2311 @smallexample @c ada
2316 This is a configuration pragma which activates a mode in which speed is
2317 considered more important for floating-point operations than absolutely
2318 accurate adherence to the requirements of the standard. Currently the
2319 following operations are affected:
2322 @item Complex Multiplication
2323 The normal simple formula for complex multiplication can result in intermediate
2324 overflows for numbers near the end of the range. The Ada standard requires that
2325 this situation be detected and corrected by scaling, but in Fast_Math mode such
2326 cases will simply result in overflow. Note that to take advantage of this you
2327 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2328 under control of the pragma, rather than use the preinstantiated versions.
2331 @node Pragma Favor_Top_Level
2332 @unnumberedsec Pragma Favor_Top_Level
2333 @findex Favor_Top_Level
2337 @smallexample @c ada
2338 pragma Favor_Top_Level (type_NAME);
2342 The named type must be an access-to-subprogram type. This pragma is an
2343 efficiency hint to the compiler, regarding the use of 'Access or
2344 'Unrestricted_Access on nested (non-library-level) subprograms. The
2345 pragma means that nested subprograms are not used with this type, or
2346 are rare, so that the generated code should be efficient in the
2347 top-level case. When this pragma is used, dynamically generated
2348 trampolines may be used on some targets for nested subprograms.
2349 See also the No_Implicit_Dynamic_Code restriction.
2351 @node Pragma Finalize_Storage_Only
2352 @unnumberedsec Pragma Finalize_Storage_Only
2353 @findex Finalize_Storage_Only
2357 @smallexample @c ada
2358 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2362 This pragma allows the compiler not to emit a Finalize call for objects
2363 defined at the library level. This is mostly useful for types where
2364 finalization is only used to deal with storage reclamation since in most
2365 environments it is not necessary to reclaim memory just before terminating
2366 execution, hence the name.
2368 @node Pragma Float_Representation
2369 @unnumberedsec Pragma Float_Representation
2371 @findex Float_Representation
2375 @smallexample @c ada
2376 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2378 FLOAT_REP ::= VAX_Float | IEEE_Float
2382 In the one argument form, this pragma is a configuration pragma which
2383 allows control over the internal representation chosen for the predefined
2384 floating point types declared in the packages @code{Standard} and
2385 @code{System}. On all systems other than OpenVMS, the argument must
2386 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2387 argument may be @code{VAX_Float} to specify the use of the VAX float
2388 format for the floating-point types in Standard. This requires that
2389 the standard runtime libraries be recompiled.
2391 The two argument form specifies the representation to be used for
2392 the specified floating-point type. On all systems other than OpenVMS,
2394 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2395 argument may be @code{VAX_Float} to specify the use of the VAX float
2400 For digits values up to 6, F float format will be used.
2402 For digits values from 7 to 9, D float format will be used.
2404 For digits values from 10 to 15, G float format will be used.
2406 Digits values above 15 are not allowed.
2410 @unnumberedsec Pragma Ident
2415 @smallexample @c ada
2416 pragma Ident (static_string_EXPRESSION);
2420 This pragma provides a string identification in the generated object file,
2421 if the system supports the concept of this kind of identification string.
2422 This pragma is allowed only in the outermost declarative part or
2423 declarative items of a compilation unit. If more than one @code{Ident}
2424 pragma is given, only the last one processed is effective.
2426 On OpenVMS systems, the effect of the pragma is identical to the effect of
2427 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2428 maximum allowed length is 31 characters, so if it is important to
2429 maintain compatibility with this compiler, you should obey this length
2432 @node Pragma Implemented
2433 @unnumberedsec Pragma Implemented
2438 @smallexample @c ada
2439 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2441 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2445 This is an Ada 2012 representation pragma which applies to protected, task
2446 and synchronized interface primitives. The use of pragma Implemented provides
2447 a way to impose a static requirement on the overriding opreration by adhering
2448 to one of the three implementation kids: entry, protected procedure or any of
2451 @smallexample @c ada
2452 type Synch_Iface is synchronized interface;
2453 procedure Prim_Op (Obj : in out Iface) is abstract;
2454 pragma Implemented (Prim_Op, By_Protected_Procedure);
2456 protected type Prot_1 is new Synch_Iface with
2457 procedure Prim_Op; -- Legal
2460 protected type Prot_2 is new Synch_Iface with
2461 entry Prim_Op; -- Illegal
2464 task type Task_Typ is new Synch_Iface with
2465 entry Prim_Op; -- Illegal
2470 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2471 Implemented determines the runtime behavior of the requeue. Implementation kind
2472 By_Entry guarantees that the action of requeueing will procede from an entry to
2473 another entry. Implementation kind By_Protected_Procedure transforms the
2474 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2475 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2476 the target's overriding subprogram kind.
2478 @node Pragma Implicit_Packing
2479 @unnumberedsec Pragma Implicit_Packing
2480 @findex Implicit_Packing
2484 @smallexample @c ada
2485 pragma Implicit_Packing;
2489 This is a configuration pragma that requests implicit packing for packed
2490 arrays for which a size clause is given but no explicit pragma Pack or
2491 specification of Component_Size is present. It also applies to records
2492 where no record representation clause is present. Consider this example:
2494 @smallexample @c ada
2495 type R is array (0 .. 7) of Boolean;
2500 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2501 does not change the layout of a composite object. So the Size clause in the
2502 above example is normally rejected, since the default layout of the array uses
2503 8-bit components, and thus the array requires a minimum of 64 bits.
2505 If this declaration is compiled in a region of code covered by an occurrence
2506 of the configuration pragma Implicit_Packing, then the Size clause in this
2507 and similar examples will cause implicit packing and thus be accepted. For
2508 this implicit packing to occur, the type in question must be an array of small
2509 components whose size is known at compile time, and the Size clause must
2510 specify the exact size that corresponds to the length of the array multiplied
2511 by the size in bits of the component type.
2512 @cindex Array packing
2514 Similarly, the following example shows the use in the record case
2516 @smallexample @c ada
2518 a, b, c, d, e, f, g, h : boolean;
2525 Without a pragma Pack, each Boolean field requires 8 bits, so the
2526 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2527 sufficient. The use of pragma Implciit_Packing allows this record
2528 declaration to compile without an explicit pragma Pack.
2529 @node Pragma Import_Exception
2530 @unnumberedsec Pragma Import_Exception
2532 @findex Import_Exception
2536 @smallexample @c ada
2537 pragma Import_Exception (
2538 [Internal =>] LOCAL_NAME
2539 [, [External =>] EXTERNAL_SYMBOL]
2540 [, [Form =>] Ada | VMS]
2541 [, [Code =>] static_integer_EXPRESSION]);
2545 | static_string_EXPRESSION
2549 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2550 It allows OpenVMS conditions (for example, from OpenVMS system services or
2551 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2552 The pragma specifies that the exception associated with an exception
2553 declaration in an Ada program be defined externally (in non-Ada code).
2554 For further details on this pragma, see the
2555 DEC Ada Language Reference Manual, section 13.9a.3.1.
2557 @node Pragma Import_Function
2558 @unnumberedsec Pragma Import_Function
2559 @findex Import_Function
2563 @smallexample @c ada
2564 pragma Import_Function (
2565 [Internal =>] LOCAL_NAME,
2566 [, [External =>] EXTERNAL_SYMBOL]
2567 [, [Parameter_Types =>] PARAMETER_TYPES]
2568 [, [Result_Type =>] SUBTYPE_MARK]
2569 [, [Mechanism =>] MECHANISM]
2570 [, [Result_Mechanism =>] MECHANISM_NAME]
2571 [, [First_Optional_Parameter =>] IDENTIFIER]);
2575 | static_string_EXPRESSION
2579 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2583 | subtype_Name ' Access
2587 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2589 MECHANISM_ASSOCIATION ::=
2590 [formal_parameter_NAME =>] MECHANISM_NAME
2595 | Descriptor [([Class =>] CLASS_NAME)]
2596 | Short_Descriptor [([Class =>] CLASS_NAME)]
2598 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2602 This pragma is used in conjunction with a pragma @code{Import} to
2603 specify additional information for an imported function. The pragma
2604 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2605 @code{Import_Function} pragma and both must appear in the same
2606 declarative part as the function specification.
2608 The @var{Internal} argument must uniquely designate
2609 the function to which the
2610 pragma applies. If more than one function name exists of this name in
2611 the declarative part you must use the @code{Parameter_Types} and
2612 @var{Result_Type} parameters to achieve the required unique
2613 designation. Subtype marks in these parameters must exactly match the
2614 subtypes in the corresponding function specification, using positional
2615 notation to match parameters with subtype marks.
2616 The form with an @code{'Access} attribute can be used to match an
2617 anonymous access parameter.
2619 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2620 parameters to specify passing mechanisms for the
2621 parameters and result. If you specify a single mechanism name, it
2622 applies to all parameters. Otherwise you may specify a mechanism on a
2623 parameter by parameter basis using either positional or named
2624 notation. If the mechanism is not specified, the default mechanism
2628 @cindex Passing by descriptor
2629 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2630 The default behavior for Import_Function is to pass a 64bit descriptor
2631 unless short_descriptor is specified, then a 32bit descriptor is passed.
2633 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2634 It specifies that the designated parameter and all following parameters
2635 are optional, meaning that they are not passed at the generated code
2636 level (this is distinct from the notion of optional parameters in Ada
2637 where the parameters are passed anyway with the designated optional
2638 parameters). All optional parameters must be of mode @code{IN} and have
2639 default parameter values that are either known at compile time
2640 expressions, or uses of the @code{'Null_Parameter} attribute.
2642 @node Pragma Import_Object
2643 @unnumberedsec Pragma Import_Object
2644 @findex Import_Object
2648 @smallexample @c ada
2649 pragma Import_Object
2650 [Internal =>] LOCAL_NAME
2651 [, [External =>] EXTERNAL_SYMBOL]
2652 [, [Size =>] EXTERNAL_SYMBOL]);
2656 | static_string_EXPRESSION
2660 This pragma designates an object as imported, and apart from the
2661 extended rules for external symbols, is identical in effect to the use of
2662 the normal @code{Import} pragma applied to an object. Unlike the
2663 subprogram case, you need not use a separate @code{Import} pragma,
2664 although you may do so (and probably should do so from a portability
2665 point of view). @var{size} is syntax checked, but otherwise ignored by
2668 @node Pragma Import_Procedure
2669 @unnumberedsec Pragma Import_Procedure
2670 @findex Import_Procedure
2674 @smallexample @c ada
2675 pragma Import_Procedure (
2676 [Internal =>] LOCAL_NAME
2677 [, [External =>] EXTERNAL_SYMBOL]
2678 [, [Parameter_Types =>] PARAMETER_TYPES]
2679 [, [Mechanism =>] MECHANISM]
2680 [, [First_Optional_Parameter =>] IDENTIFIER]);
2684 | static_string_EXPRESSION
2688 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2692 | subtype_Name ' Access
2696 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2698 MECHANISM_ASSOCIATION ::=
2699 [formal_parameter_NAME =>] MECHANISM_NAME
2704 | Descriptor [([Class =>] CLASS_NAME)]
2705 | Short_Descriptor [([Class =>] CLASS_NAME)]
2707 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2711 This pragma is identical to @code{Import_Function} except that it
2712 applies to a procedure rather than a function and the parameters
2713 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2715 @node Pragma Import_Valued_Procedure
2716 @unnumberedsec Pragma Import_Valued_Procedure
2717 @findex Import_Valued_Procedure
2721 @smallexample @c ada
2722 pragma Import_Valued_Procedure (
2723 [Internal =>] LOCAL_NAME
2724 [, [External =>] EXTERNAL_SYMBOL]
2725 [, [Parameter_Types =>] PARAMETER_TYPES]
2726 [, [Mechanism =>] MECHANISM]
2727 [, [First_Optional_Parameter =>] IDENTIFIER]);
2731 | static_string_EXPRESSION
2735 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2739 | subtype_Name ' Access
2743 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2745 MECHANISM_ASSOCIATION ::=
2746 [formal_parameter_NAME =>] MECHANISM_NAME
2751 | Descriptor [([Class =>] CLASS_NAME)]
2752 | Short_Descriptor [([Class =>] CLASS_NAME)]
2754 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2758 This pragma is identical to @code{Import_Procedure} except that the
2759 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2760 mode @code{OUT}, and externally the subprogram is treated as a function
2761 with this parameter as the result of the function. The purpose of this
2762 capability is to allow the use of @code{OUT} and @code{IN OUT}
2763 parameters in interfacing to external functions (which are not permitted
2764 in Ada functions). You may optionally use the @code{Mechanism}
2765 parameters to specify passing mechanisms for the parameters.
2766 If you specify a single mechanism name, it applies to all parameters.
2767 Otherwise you may specify a mechanism on a parameter by parameter
2768 basis using either positional or named notation. If the mechanism is not
2769 specified, the default mechanism is used.
2771 Note that it is important to use this pragma in conjunction with a separate
2772 pragma Import that specifies the desired convention, since otherwise the
2773 default convention is Ada, which is almost certainly not what is required.
2775 @node Pragma Initialize_Scalars
2776 @unnumberedsec Pragma Initialize_Scalars
2777 @findex Initialize_Scalars
2778 @cindex debugging with Initialize_Scalars
2782 @smallexample @c ada
2783 pragma Initialize_Scalars;
2787 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2788 two important differences. First, there is no requirement for the pragma
2789 to be used uniformly in all units of a partition, in particular, it is fine
2790 to use this just for some or all of the application units of a partition,
2791 without needing to recompile the run-time library.
2793 In the case where some units are compiled with the pragma, and some without,
2794 then a declaration of a variable where the type is defined in package
2795 Standard or is locally declared will always be subject to initialization,
2796 as will any declaration of a scalar variable. For composite variables,
2797 whether the variable is initialized may also depend on whether the package
2798 in which the type of the variable is declared is compiled with the pragma.
2800 The other important difference is that you can control the value used
2801 for initializing scalar objects. At bind time, you can select several
2802 options for initialization. You can
2803 initialize with invalid values (similar to Normalize_Scalars, though for
2804 Initialize_Scalars it is not always possible to determine the invalid
2805 values in complex cases like signed component fields with non-standard
2806 sizes). You can also initialize with high or
2807 low values, or with a specified bit pattern. See the users guide for binder
2808 options for specifying these cases.
2810 This means that you can compile a program, and then without having to
2811 recompile the program, you can run it with different values being used
2812 for initializing otherwise uninitialized values, to test if your program
2813 behavior depends on the choice. Of course the behavior should not change,
2814 and if it does, then most likely you have an erroneous reference to an
2815 uninitialized value.
2817 It is even possible to change the value at execution time eliminating even
2818 the need to rebind with a different switch using an environment variable.
2819 See the GNAT users guide for details.
2821 Note that pragma @code{Initialize_Scalars} is particularly useful in
2822 conjunction with the enhanced validity checking that is now provided
2823 in GNAT, which checks for invalid values under more conditions.
2824 Using this feature (see description of the @option{-gnatV} flag in the
2825 users guide) in conjunction with pragma @code{Initialize_Scalars}
2826 provides a powerful new tool to assist in the detection of problems
2827 caused by uninitialized variables.
2829 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2830 effect on the generated code. This may cause your code to be
2831 substantially larger. It may also cause an increase in the amount
2832 of stack required, so it is probably a good idea to turn on stack
2833 checking (see description of stack checking in the GNAT users guide)
2834 when using this pragma.
2836 @node Pragma Inline_Always
2837 @unnumberedsec Pragma Inline_Always
2838 @findex Inline_Always
2842 @smallexample @c ada
2843 pragma Inline_Always (NAME [, NAME]);
2847 Similar to pragma @code{Inline} except that inlining is not subject to
2848 the use of option @option{-gnatn} and the inlining happens regardless of
2849 whether this option is used.
2851 @node Pragma Inline_Generic
2852 @unnumberedsec Pragma Inline_Generic
2853 @findex Inline_Generic
2857 @smallexample @c ada
2858 pragma Inline_Generic (generic_package_NAME);
2862 This is implemented for compatibility with DEC Ada 83 and is recognized,
2863 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2864 by default when using GNAT@.
2866 @node Pragma Interface
2867 @unnumberedsec Pragma Interface
2872 @smallexample @c ada
2874 [Convention =>] convention_identifier,
2875 [Entity =>] local_NAME
2876 [, [External_Name =>] static_string_expression]
2877 [, [Link_Name =>] static_string_expression]);
2881 This pragma is identical in syntax and semantics to
2882 the standard Ada pragma @code{Import}. It is provided for compatibility
2883 with Ada 83. The definition is upwards compatible both with pragma
2884 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2885 with some extended implementations of this pragma in certain Ada 83
2886 implementations. The only difference between pragma @code{Interface}
2887 and pragma @code{Import} is that there is special circuitry to allow
2888 both pragmas to appear for the same subprogram entity (normally it
2889 is illegal to have multiple @code{Import} pragmas. This is useful in
2890 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2893 @node Pragma Interface_Name
2894 @unnumberedsec Pragma Interface_Name
2895 @findex Interface_Name
2899 @smallexample @c ada
2900 pragma Interface_Name (
2901 [Entity =>] LOCAL_NAME
2902 [, [External_Name =>] static_string_EXPRESSION]
2903 [, [Link_Name =>] static_string_EXPRESSION]);
2907 This pragma provides an alternative way of specifying the interface name
2908 for an interfaced subprogram, and is provided for compatibility with Ada
2909 83 compilers that use the pragma for this purpose. You must provide at
2910 least one of @var{External_Name} or @var{Link_Name}.
2912 @node Pragma Interrupt_Handler
2913 @unnumberedsec Pragma Interrupt_Handler
2914 @findex Interrupt_Handler
2918 @smallexample @c ada
2919 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2923 This program unit pragma is supported for parameterless protected procedures
2924 as described in Annex C of the Ada Reference Manual. On the AAMP target
2925 the pragma can also be specified for nonprotected parameterless procedures
2926 that are declared at the library level (which includes procedures
2927 declared at the top level of a library package). In the case of AAMP,
2928 when this pragma is applied to a nonprotected procedure, the instruction
2929 @code{IERET} is generated for returns from the procedure, enabling
2930 maskable interrupts, in place of the normal return instruction.
2932 @node Pragma Interrupt_State
2933 @unnumberedsec Pragma Interrupt_State
2934 @findex Interrupt_State
2938 @smallexample @c ada
2939 pragma Interrupt_State
2941 [State =>] SYSTEM | RUNTIME | USER);
2945 Normally certain interrupts are reserved to the implementation. Any attempt
2946 to attach an interrupt causes Program_Error to be raised, as described in
2947 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2948 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2949 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2950 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2951 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2952 Ada exceptions, or used to implement run-time functions such as the
2953 @code{abort} statement and stack overflow checking.
2955 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2956 such uses of interrupts. It subsumes the functionality of pragma
2957 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2958 available on Windows or VMS. On all other platforms than VxWorks,
2959 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2960 and may be used to mark interrupts required by the board support package
2963 Interrupts can be in one of three states:
2967 The interrupt is reserved (no Ada handler can be installed), and the
2968 Ada run-time may not install a handler. As a result you are guaranteed
2969 standard system default action if this interrupt is raised.
2973 The interrupt is reserved (no Ada handler can be installed). The run time
2974 is allowed to install a handler for internal control purposes, but is
2975 not required to do so.
2979 The interrupt is unreserved. The user may install a handler to provide
2984 These states are the allowed values of the @code{State} parameter of the
2985 pragma. The @code{Name} parameter is a value of the type
2986 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2987 @code{Ada.Interrupts.Names}.
2989 This is a configuration pragma, and the binder will check that there
2990 are no inconsistencies between different units in a partition in how a
2991 given interrupt is specified. It may appear anywhere a pragma is legal.
2993 The effect is to move the interrupt to the specified state.
2995 By declaring interrupts to be SYSTEM, you guarantee the standard system
2996 action, such as a core dump.
2998 By declaring interrupts to be USER, you guarantee that you can install
3001 Note that certain signals on many operating systems cannot be caught and
3002 handled by applications. In such cases, the pragma is ignored. See the
3003 operating system documentation, or the value of the array @code{Reserved}
3004 declared in the spec of package @code{System.OS_Interface}.
3006 Overriding the default state of signals used by the Ada runtime may interfere
3007 with an application's runtime behavior in the cases of the synchronous signals,
3008 and in the case of the signal used to implement the @code{abort} statement.
3010 @node Pragma Invariant
3011 @unnumberedsec Pragma Invariant
3016 @smallexample @c ada
3018 ([Entity =>] private_type_LOCAL_NAME,
3019 [Check =>] EXPRESSION
3020 [,[Message =>] String_Expression]);
3024 This pragma provides exactly the same capabilities as the Invariant aspect
3025 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The Invariant
3026 aspect is fully implemented in Ada 2012 mode, but since it requires the use
3027 of the aspect syntax, which is not available exception in 2012 mode, it is
3028 not possible to use the Invariant aspect in earlier versions of Ada. However
3029 the Invariant pragma may be used in any version of Ada.
3031 The pragma must appear within the visible part of the package specification,
3032 after the type to which its Entity argument appears. As with the Invariant
3033 aspect, the Check expression is not analyzed until the end of the visible
3034 part of the package, so it may contain forward references. The Message
3035 argument, if present, provides the exception message used if the invariant
3036 is violated. If no Message parameter is provided, a default message that
3037 identifies the line on which the pragma appears is used.
3039 It is permissible to have multiple Invariants for the same type entity, in
3040 which case they are and'ed together. It is permissible to use this pragma
3041 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3042 invariant pragma for the same entity.
3044 For further details on the use of this pragma, see the Ada 2012 documentation
3045 of the Invariant aspect.
3047 @node Pragma Keep_Names
3048 @unnumberedsec Pragma Keep_Names
3053 @smallexample @c ada
3054 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3058 The @var{LOCAL_NAME} argument
3059 must refer to an enumeration first subtype
3060 in the current declarative part. The effect is to retain the enumeration
3061 literal names for use by @code{Image} and @code{Value} even if a global
3062 @code{Discard_Names} pragma applies. This is useful when you want to
3063 generally suppress enumeration literal names and for example you therefore
3064 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3065 want to retain the names for specific enumeration types.
3067 @node Pragma License
3068 @unnumberedsec Pragma License
3070 @cindex License checking
3074 @smallexample @c ada
3075 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3079 This pragma is provided to allow automated checking for appropriate license
3080 conditions with respect to the standard and modified GPL@. A pragma
3081 @code{License}, which is a configuration pragma that typically appears at
3082 the start of a source file or in a separate @file{gnat.adc} file, specifies
3083 the licensing conditions of a unit as follows:
3087 This is used for a unit that can be freely used with no license restrictions.
3088 Examples of such units are public domain units, and units from the Ada
3092 This is used for a unit that is licensed under the unmodified GPL, and which
3093 therefore cannot be @code{with}'ed by a restricted unit.
3096 This is used for a unit licensed under the GNAT modified GPL that includes
3097 a special exception paragraph that specifically permits the inclusion of
3098 the unit in programs without requiring the entire program to be released
3102 This is used for a unit that is restricted in that it is not permitted to
3103 depend on units that are licensed under the GPL@. Typical examples are
3104 proprietary code that is to be released under more restrictive license
3105 conditions. Note that restricted units are permitted to @code{with} units
3106 which are licensed under the modified GPL (this is the whole point of the
3112 Normally a unit with no @code{License} pragma is considered to have an
3113 unknown license, and no checking is done. However, standard GNAT headers
3114 are recognized, and license information is derived from them as follows.
3118 A GNAT license header starts with a line containing 78 hyphens. The following
3119 comment text is searched for the appearance of any of the following strings.
3121 If the string ``GNU General Public License'' is found, then the unit is assumed
3122 to have GPL license, unless the string ``As a special exception'' follows, in
3123 which case the license is assumed to be modified GPL@.
3125 If one of the strings
3126 ``This specification is adapted from the Ada Semantic Interface'' or
3127 ``This specification is derived from the Ada Reference Manual'' is found
3128 then the unit is assumed to be unrestricted.
3132 These default actions means that a program with a restricted license pragma
3133 will automatically get warnings if a GPL unit is inappropriately
3134 @code{with}'ed. For example, the program:
3136 @smallexample @c ada
3139 procedure Secret_Stuff is
3145 if compiled with pragma @code{License} (@code{Restricted}) in a
3146 @file{gnat.adc} file will generate the warning:
3151 >>> license of withed unit "Sem_Ch3" is incompatible
3153 2. with GNAT.Sockets;
3154 3. procedure Secret_Stuff is
3158 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3159 compiler and is licensed under the
3160 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3161 run time, and is therefore licensed under the modified GPL@.
3163 @node Pragma Link_With
3164 @unnumberedsec Pragma Link_With
3169 @smallexample @c ada
3170 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3174 This pragma is provided for compatibility with certain Ada 83 compilers.
3175 It has exactly the same effect as pragma @code{Linker_Options} except
3176 that spaces occurring within one of the string expressions are treated
3177 as separators. For example, in the following case:
3179 @smallexample @c ada
3180 pragma Link_With ("-labc -ldef");
3184 results in passing the strings @code{-labc} and @code{-ldef} as two
3185 separate arguments to the linker. In addition pragma Link_With allows
3186 multiple arguments, with the same effect as successive pragmas.
3188 @node Pragma Linker_Alias
3189 @unnumberedsec Pragma Linker_Alias
3190 @findex Linker_Alias
3194 @smallexample @c ada
3195 pragma Linker_Alias (
3196 [Entity =>] LOCAL_NAME,
3197 [Target =>] static_string_EXPRESSION);
3201 @var{LOCAL_NAME} must refer to an object that is declared at the library
3202 level. This pragma establishes the given entity as a linker alias for the
3203 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3204 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3205 @var{static_string_EXPRESSION} in the object file, that is to say no space
3206 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3207 to the same address as @var{static_string_EXPRESSION} by the linker.
3209 The actual linker name for the target must be used (e.g.@: the fully
3210 encoded name with qualification in Ada, or the mangled name in C++),
3211 or it must be declared using the C convention with @code{pragma Import}
3212 or @code{pragma Export}.
3214 Not all target machines support this pragma. On some of them it is accepted
3215 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3217 @smallexample @c ada
3218 -- Example of the use of pragma Linker_Alias
3222 pragma Export (C, i);
3224 new_name_for_i : Integer;
3225 pragma Linker_Alias (new_name_for_i, "i");
3229 @node Pragma Linker_Constructor
3230 @unnumberedsec Pragma Linker_Constructor
3231 @findex Linker_Constructor
3235 @smallexample @c ada
3236 pragma Linker_Constructor (procedure_LOCAL_NAME);
3240 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3241 is declared at the library level. A procedure to which this pragma is
3242 applied will be treated as an initialization routine by the linker.
3243 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3244 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3245 of the executable is called (or immediately after the shared library is
3246 loaded if the procedure is linked in a shared library), in particular
3247 before the Ada run-time environment is set up.
3249 Because of these specific contexts, the set of operations such a procedure
3250 can perform is very limited and the type of objects it can manipulate is
3251 essentially restricted to the elementary types. In particular, it must only
3252 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3254 This pragma is used by GNAT to implement auto-initialization of shared Stand
3255 Alone Libraries, which provides a related capability without the restrictions
3256 listed above. Where possible, the use of Stand Alone Libraries is preferable
3257 to the use of this pragma.
3259 @node Pragma Linker_Destructor
3260 @unnumberedsec Pragma Linker_Destructor
3261 @findex Linker_Destructor
3265 @smallexample @c ada
3266 pragma Linker_Destructor (procedure_LOCAL_NAME);
3270 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3271 is declared at the library level. A procedure to which this pragma is
3272 applied will be treated as a finalization routine by the linker.
3273 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3274 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3275 of the executable has exited (or immediately before the shared library
3276 is unloaded if the procedure is linked in a shared library), in particular
3277 after the Ada run-time environment is shut down.
3279 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3280 because of these specific contexts.
3282 @node Pragma Linker_Section
3283 @unnumberedsec Pragma Linker_Section
3284 @findex Linker_Section
3288 @smallexample @c ada
3289 pragma Linker_Section (
3290 [Entity =>] LOCAL_NAME,
3291 [Section =>] static_string_EXPRESSION);
3295 @var{LOCAL_NAME} must refer to an object that is declared at the library
3296 level. This pragma specifies the name of the linker section for the given
3297 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3298 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3299 section of the executable (assuming the linker doesn't rename the section).
3301 The compiler normally places library-level objects in standard sections
3302 depending on their type: procedures and functions generally go in the
3303 @code{.text} section, initialized variables in the @code{.data} section
3304 and uninitialized variables in the @code{.bss} section.
3306 Other, special sections may exist on given target machines to map special
3307 hardware, for example I/O ports or flash memory. This pragma is a means to
3308 defer the final layout of the executable to the linker, thus fully working
3309 at the symbolic level with the compiler.
3311 Some file formats do not support arbitrary sections so not all target
3312 machines support this pragma. The use of this pragma may cause a program
3313 execution to be erroneous if it is used to place an entity into an
3314 inappropriate section (e.g.@: a modified variable into the @code{.text}
3315 section). See also @code{pragma Persistent_BSS}.
3317 @smallexample @c ada
3318 -- Example of the use of pragma Linker_Section
3322 pragma Volatile (Port_A);
3323 pragma Linker_Section (Port_A, ".bss.port_a");
3326 pragma Volatile (Port_B);
3327 pragma Linker_Section (Port_B, ".bss.port_b");
3331 @node Pragma Long_Float
3332 @unnumberedsec Pragma Long_Float
3338 @smallexample @c ada
3339 pragma Long_Float (FLOAT_FORMAT);
3341 FLOAT_FORMAT ::= D_Float | G_Float
3345 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3346 It allows control over the internal representation chosen for the predefined
3347 type @code{Long_Float} and for floating point type representations with
3348 @code{digits} specified in the range 7 through 15.
3349 For further details on this pragma, see the
3350 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3351 this pragma, the standard runtime libraries must be recompiled.
3353 @node Pragma Machine_Attribute
3354 @unnumberedsec Pragma Machine_Attribute
3355 @findex Machine_Attribute
3359 @smallexample @c ada
3360 pragma Machine_Attribute (
3361 [Entity =>] LOCAL_NAME,
3362 [Attribute_Name =>] static_string_EXPRESSION
3363 [, [Info =>] static_EXPRESSION] );
3367 Machine-dependent attributes can be specified for types and/or
3368 declarations. This pragma is semantically equivalent to
3369 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3370 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3371 in GNU C, where @code{@var{attribute_name}} is recognized by the
3372 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3373 specific macro. A string literal for the optional parameter @var{info}
3374 is transformed into an identifier, which may make this pragma unusable
3375 for some attributes. @xref{Target Attributes,, Defining target-specific
3376 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3377 Internals}, further information.
3380 @unnumberedsec Pragma Main
3386 @smallexample @c ada
3388 (MAIN_OPTION [, MAIN_OPTION]);
3391 [Stack_Size =>] static_integer_EXPRESSION
3392 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3393 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3397 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3398 no effect in GNAT, other than being syntax checked.
3400 @node Pragma Main_Storage
3401 @unnumberedsec Pragma Main_Storage
3403 @findex Main_Storage
3407 @smallexample @c ada
3409 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3411 MAIN_STORAGE_OPTION ::=
3412 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3413 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3417 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3418 no effect in GNAT, other than being syntax checked. Note that the pragma
3419 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3421 @node Pragma No_Body
3422 @unnumberedsec Pragma No_Body
3427 @smallexample @c ada
3432 There are a number of cases in which a package spec does not require a body,
3433 and in fact a body is not permitted. GNAT will not permit the spec to be
3434 compiled if there is a body around. The pragma No_Body allows you to provide
3435 a body file, even in a case where no body is allowed. The body file must
3436 contain only comments and a single No_Body pragma. This is recognized by
3437 the compiler as indicating that no body is logically present.
3439 This is particularly useful during maintenance when a package is modified in
3440 such a way that a body needed before is no longer needed. The provision of a
3441 dummy body with a No_Body pragma ensures that there is no interference from
3442 earlier versions of the package body.
3444 @node Pragma No_Return
3445 @unnumberedsec Pragma No_Return
3450 @smallexample @c ada
3451 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3455 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3456 declarations in the current declarative part. A procedure to which this
3457 pragma is applied may not contain any explicit @code{return} statements.
3458 In addition, if the procedure contains any implicit returns from falling
3459 off the end of a statement sequence, then execution of that implicit
3460 return will cause Program_Error to be raised.
3462 One use of this pragma is to identify procedures whose only purpose is to raise
3463 an exception. Another use of this pragma is to suppress incorrect warnings
3464 about missing returns in functions, where the last statement of a function
3465 statement sequence is a call to such a procedure.
3467 Note that in Ada 2005 mode, this pragma is part of the language, and is
3468 identical in effect to the pragma as implemented in Ada 95 mode.
3470 @node Pragma No_Strict_Aliasing
3471 @unnumberedsec Pragma No_Strict_Aliasing
3472 @findex No_Strict_Aliasing
3476 @smallexample @c ada
3477 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3481 @var{type_LOCAL_NAME} must refer to an access type
3482 declaration in the current declarative part. The effect is to inhibit
3483 strict aliasing optimization for the given type. The form with no
3484 arguments is a configuration pragma which applies to all access types
3485 declared in units to which the pragma applies. For a detailed
3486 description of the strict aliasing optimization, and the situations
3487 in which it must be suppressed, see @ref{Optimization and Strict
3488 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3490 @node Pragma Normalize_Scalars
3491 @unnumberedsec Pragma Normalize_Scalars
3492 @findex Normalize_Scalars
3496 @smallexample @c ada
3497 pragma Normalize_Scalars;
3501 This is a language defined pragma which is fully implemented in GNAT@. The
3502 effect is to cause all scalar objects that are not otherwise initialized
3503 to be initialized. The initial values are implementation dependent and
3507 @item Standard.Character
3509 Objects whose root type is Standard.Character are initialized to
3510 Character'Last unless the subtype range excludes NUL (in which case
3511 NUL is used). This choice will always generate an invalid value if
3514 @item Standard.Wide_Character
3516 Objects whose root type is Standard.Wide_Character are initialized to
3517 Wide_Character'Last unless the subtype range excludes NUL (in which case
3518 NUL is used). This choice will always generate an invalid value if
3521 @item Standard.Wide_Wide_Character
3523 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3524 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3525 which case NUL is used). This choice will always generate an invalid value if
3530 Objects of an integer type are treated differently depending on whether
3531 negative values are present in the subtype. If no negative values are
3532 present, then all one bits is used as the initial value except in the
3533 special case where zero is excluded from the subtype, in which case
3534 all zero bits are used. This choice will always generate an invalid
3535 value if one exists.
3537 For subtypes with negative values present, the largest negative number
3538 is used, except in the unusual case where this largest negative number
3539 is in the subtype, and the largest positive number is not, in which case
3540 the largest positive value is used. This choice will always generate
3541 an invalid value if one exists.
3543 @item Floating-Point Types
3544 Objects of all floating-point types are initialized to all 1-bits. For
3545 standard IEEE format, this corresponds to a NaN (not a number) which is
3546 indeed an invalid value.
3548 @item Fixed-Point Types
3549 Objects of all fixed-point types are treated as described above for integers,
3550 with the rules applying to the underlying integer value used to represent
3551 the fixed-point value.
3554 Objects of a modular type are initialized to all one bits, except in
3555 the special case where zero is excluded from the subtype, in which
3556 case all zero bits are used. This choice will always generate an
3557 invalid value if one exists.
3559 @item Enumeration types
3560 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3561 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3562 whose Pos value is zero, in which case a code of zero is used. This choice
3563 will always generate an invalid value if one exists.
3567 @node Pragma Obsolescent
3568 @unnumberedsec Pragma Obsolescent
3573 @smallexample @c ada
3576 pragma Obsolescent (
3577 [Message =>] static_string_EXPRESSION
3578 [,[Version =>] Ada_05]]);
3580 pragma Obsolescent (
3582 [,[Message =>] static_string_EXPRESSION
3583 [,[Version =>] Ada_05]] );
3587 This pragma can occur immediately following a declaration of an entity,
3588 including the case of a record component. If no Entity argument is present,
3589 then this declaration is the one to which the pragma applies. If an Entity
3590 parameter is present, it must either match the name of the entity in this
3591 declaration, or alternatively, the pragma can immediately follow an enumeration
3592 type declaration, where the Entity argument names one of the enumeration
3595 This pragma is used to indicate that the named entity
3596 is considered obsolescent and should not be used. Typically this is
3597 used when an API must be modified by eventually removing or modifying
3598 existing subprograms or other entities. The pragma can be used at an
3599 intermediate stage when the entity is still present, but will be
3602 The effect of this pragma is to output a warning message on a reference to
3603 an entity thus marked that the subprogram is obsolescent if the appropriate
3604 warning option in the compiler is activated. If the Message parameter is
3605 present, then a second warning message is given containing this text. In
3606 addition, a reference to the eneity is considered to be a violation of pragma
3607 Restrictions (No_Obsolescent_Features).
3609 This pragma can also be used as a program unit pragma for a package,
3610 in which case the entity name is the name of the package, and the
3611 pragma indicates that the entire package is considered
3612 obsolescent. In this case a client @code{with}'ing such a package
3613 violates the restriction, and the @code{with} statement is
3614 flagged with warnings if the warning option is set.
3616 If the Version parameter is present (which must be exactly
3617 the identifier Ada_05, no other argument is allowed), then the
3618 indication of obsolescence applies only when compiling in Ada 2005
3619 mode. This is primarily intended for dealing with the situations
3620 in the predefined library where subprograms or packages
3621 have become defined as obsolescent in Ada 2005
3622 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3624 The following examples show typical uses of this pragma:
3626 @smallexample @c ada
3628 pragma Obsolescent (p, Message => "use pp instead of p");
3633 pragma Obsolescent ("use q2new instead");
3635 type R is new integer;
3638 Message => "use RR in Ada 2005",
3648 type E is (a, bc, 'd', quack);
3649 pragma Obsolescent (Entity => bc)
3650 pragma Obsolescent (Entity => 'd')
3653 (a, b : character) return character;
3654 pragma Obsolescent (Entity => "+");
3659 Note that, as for all pragmas, if you use a pragma argument identifier,
3660 then all subsequent parameters must also use a pragma argument identifier.
3661 So if you specify "Entity =>" for the Entity argument, and a Message
3662 argument is present, it must be preceded by "Message =>".
3664 @node Pragma Optimize_Alignment
3665 @unnumberedsec Pragma Optimize_Alignment
3666 @findex Optimize_Alignment
3667 @cindex Alignment, default settings
3671 @smallexample @c ada
3672 pragma Optimize_Alignment (TIME | SPACE | OFF);
3676 This is a configuration pragma which affects the choice of default alignments
3677 for types where no alignment is explicitly specified. There is a time/space
3678 trade-off in the selection of these values. Large alignments result in more
3679 efficient code, at the expense of larger data space, since sizes have to be
3680 increased to match these alignments. Smaller alignments save space, but the
3681 access code is slower. The normal choice of default alignments (which is what
3682 you get if you do not use this pragma, or if you use an argument of OFF),
3683 tries to balance these two requirements.
3685 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3686 First any packed record is given an alignment of 1. Second, if a size is given
3687 for the type, then the alignment is chosen to avoid increasing this size. For
3690 @smallexample @c ada
3700 In the default mode, this type gets an alignment of 4, so that access to the
3701 Integer field X are efficient. But this means that objects of the type end up
3702 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3703 allowed to be bigger than the size of the type, but it can waste space if for
3704 example fields of type R appear in an enclosing record. If the above type is
3705 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3707 Specifying TIME causes larger default alignments to be chosen in the case of
3708 small types with sizes that are not a power of 2. For example, consider:
3710 @smallexample @c ada
3722 The default alignment for this record is normally 1, but if this type is
3723 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3724 to 4, which wastes space for objects of the type, since they are now 4 bytes
3725 long, but results in more efficient access when the whole record is referenced.
3727 As noted above, this is a configuration pragma, and there is a requirement
3728 that all units in a partition be compiled with a consistent setting of the
3729 optimization setting. This would normally be achieved by use of a configuration
3730 pragma file containing the appropriate setting. The exception to this rule is
3731 that units with an explicit configuration pragma in the same file as the source
3732 unit are excluded from the consistency check, as are all predefined units. The
3733 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3734 pragma appears at the start of the file.
3736 @node Pragma Ordered
3737 @unnumberedsec Pragma Ordered
3739 @findex pragma @code{Ordered}
3743 @smallexample @c ada
3744 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3748 Most enumeration types are from a conceptual point of view unordered.
3749 For example, consider:
3751 @smallexample @c ada
3752 type Color is (Red, Blue, Green, Yellow);
3756 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
3757 but really these relations make no sense; the enumeration type merely
3758 specifies a set of possible colors, and the order is unimportant.
3760 For unordered enumeration types, it is generally a good idea if
3761 clients avoid comparisons (other than equality or inequality) and
3762 explicit ranges. (A @emph{client} is a unit where the type is referenced,
3763 other than the unit where the type is declared, its body, and its subunits.)
3764 For example, if code buried in some client says:
3766 @smallexample @c ada
3767 if Current_Color < Yellow then ...
3768 if Current_Color in Blue .. Green then ...
3772 then the client code is relying on the order, which is undesirable.
3773 It makes the code hard to read and creates maintenance difficulties if
3774 entries have to be added to the enumeration type. Instead,
3775 the code in the client should list the possibilities, or an
3776 appropriate subtype should be declared in the unit that declares
3777 the original enumeration type. E.g., the following subtype could
3778 be declared along with the type @code{Color}:
3780 @smallexample @c ada
3781 subtype RBG is Color range Red .. Green;
3785 and then the client could write:
3787 @smallexample @c ada
3788 if Current_Color in RBG then ...
3789 if Current_Color = Blue or Current_Color = Green then ...
3793 However, some enumeration types are legitimately ordered from a conceptual
3794 point of view. For example, if you declare:
3796 @smallexample @c ada
3797 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3801 then the ordering imposed by the language is reasonable, and
3802 clients can depend on it, writing for example:
3804 @smallexample @c ada
3805 if D in Mon .. Fri then ...
3810 The pragma @option{Ordered} is provided to mark enumeration types that
3811 are conceptually ordered, alerting the reader that clients may depend
3812 on the ordering. GNAT provides a pragma to mark enumerations as ordered
3813 rather than one to mark them as unordered, since in our experience,
3814 the great majority of enumeration types are conceptually unordered.
3816 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
3817 and @code{Wide_Wide_Character}
3818 are considered to be ordered types, so each is declared with a
3819 pragma @code{Ordered} in package @code{Standard}.
3821 Normally pragma @code{Ordered} serves only as documentation and a guide for
3822 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
3823 requests warnings for inappropriate uses (comparisons and explicit
3824 subranges) for unordered types. If this switch is used, then any
3825 enumeration type not marked with pragma @code{Ordered} will be considered
3826 as unordered, and will generate warnings for inappropriate uses.
3828 For additional information please refer to the description of the
3829 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
3831 @node Pragma Passive
3832 @unnumberedsec Pragma Passive
3837 @smallexample @c ada
3838 pragma Passive [(Semaphore | No)];
3842 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3843 compatibility with DEC Ada 83 implementations, where it is used within a
3844 task definition to request that a task be made passive. If the argument
3845 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3846 treats the pragma as an assertion that the containing task is passive
3847 and that optimization of context switch with this task is permitted and
3848 desired. If the argument @code{No} is present, the task must not be
3849 optimized. GNAT does not attempt to optimize any tasks in this manner
3850 (since protected objects are available in place of passive tasks).
3852 @node Pragma Persistent_BSS
3853 @unnumberedsec Pragma Persistent_BSS
3854 @findex Persistent_BSS
3858 @smallexample @c ada
3859 pragma Persistent_BSS [(LOCAL_NAME)]
3863 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3864 section. On some targets the linker and loader provide for special
3865 treatment of this section, allowing a program to be reloaded without
3866 affecting the contents of this data (hence the name persistent).
3868 There are two forms of usage. If an argument is given, it must be the
3869 local name of a library level object, with no explicit initialization
3870 and whose type is potentially persistent. If no argument is given, then
3871 the pragma is a configuration pragma, and applies to all library level
3872 objects with no explicit initialization of potentially persistent types.
3874 A potentially persistent type is a scalar type, or a non-tagged,
3875 non-discriminated record, all of whose components have no explicit
3876 initialization and are themselves of a potentially persistent type,
3877 or an array, all of whose constraints are static, and whose component
3878 type is potentially persistent.
3880 If this pragma is used on a target where this feature is not supported,
3881 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3883 @node Pragma Polling
3884 @unnumberedsec Pragma Polling
3889 @smallexample @c ada
3890 pragma Polling (ON | OFF);
3894 This pragma controls the generation of polling code. This is normally off.
3895 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3896 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3897 runtime library, and can be found in file @file{a-excpol.adb}.
3899 Pragma @code{Polling} can appear as a configuration pragma (for example it
3900 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3901 can be used in the statement or declaration sequence to control polling
3904 A call to the polling routine is generated at the start of every loop and
3905 at the start of every subprogram call. This guarantees that the @code{Poll}
3906 routine is called frequently, and places an upper bound (determined by
3907 the complexity of the code) on the period between two @code{Poll} calls.
3909 The primary purpose of the polling interface is to enable asynchronous
3910 aborts on targets that cannot otherwise support it (for example Windows
3911 NT), but it may be used for any other purpose requiring periodic polling.
3912 The standard version is null, and can be replaced by a user program. This
3913 will require re-compilation of the @code{Ada.Exceptions} package that can
3914 be found in files @file{a-except.ads} and @file{a-except.adb}.
3916 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3917 distribution) is used to enable the asynchronous abort capability on
3918 targets that do not normally support the capability. The version of
3919 @code{Poll} in this file makes a call to the appropriate runtime routine
3920 to test for an abort condition.
3922 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3923 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3926 @node Pragma Postcondition
3927 @unnumberedsec Pragma Postcondition
3928 @cindex Postconditions
3929 @cindex Checks, postconditions
3930 @findex Postconditions
3934 @smallexample @c ada
3935 pragma Postcondition (
3936 [Check =>] Boolean_Expression
3937 [,[Message =>] String_Expression]);
3941 The @code{Postcondition} pragma allows specification of automatic
3942 postcondition checks for subprograms. These checks are similar to
3943 assertions, but are automatically inserted just prior to the return
3944 statements of the subprogram with which they are associated (including
3945 implicit returns at the end of procedure bodies and associated
3946 exception handlers).
3948 In addition, the boolean expression which is the condition which
3949 must be true may contain references to function'Result in the case
3950 of a function to refer to the returned value.
3952 @code{Postcondition} pragmas may appear either immediate following the
3953 (separate) declaration of a subprogram, or at the start of the
3954 declarations of a subprogram body. Only other pragmas may intervene
3955 (that is appear between the subprogram declaration and its
3956 postconditions, or appear before the postcondition in the
3957 declaration sequence in a subprogram body). In the case of a
3958 postcondition appearing after a subprogram declaration, the
3959 formal arguments of the subprogram are visible, and can be
3960 referenced in the postcondition expressions.
3962 The postconditions are collected and automatically tested just
3963 before any return (implicit or explicit) in the subprogram body.
3964 A postcondition is only recognized if postconditions are active
3965 at the time the pragma is encountered. The compiler switch @option{gnata}
3966 turns on all postconditions by default, and pragma @code{Check_Policy}
3967 with an identifier of @code{Postcondition} can also be used to
3968 control whether postconditions are active.
3970 The general approach is that postconditions are placed in the spec
3971 if they represent functional aspects which make sense to the client.
3972 For example we might have:
3974 @smallexample @c ada
3975 function Direction return Integer;
3976 pragma Postcondition
3977 (Direction'Result = +1
3979 Direction'Result = -1);
3983 which serves to document that the result must be +1 or -1, and
3984 will test that this is the case at run time if postcondition
3987 Postconditions within the subprogram body can be used to
3988 check that some internal aspect of the implementation,
3989 not visible to the client, is operating as expected.
3990 For instance if a square root routine keeps an internal
3991 counter of the number of times it is called, then we
3992 might have the following postcondition:
3994 @smallexample @c ada
3995 Sqrt_Calls : Natural := 0;
3997 function Sqrt (Arg : Float) return Float is
3998 pragma Postcondition
3999 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4005 As this example, shows, the use of the @code{Old} attribute
4006 is often useful in postconditions to refer to the state on
4007 entry to the subprogram.
4009 Note that postconditions are only checked on normal returns
4010 from the subprogram. If an abnormal return results from
4011 raising an exception, then the postconditions are not checked.
4013 If a postcondition fails, then the exception
4014 @code{System.Assertions.Assert_Failure} is raised. If
4015 a message argument was supplied, then the given string
4016 will be used as the exception message. If no message
4017 argument was supplied, then the default message has
4018 the form "Postcondition failed at file:line". The
4019 exception is raised in the context of the subprogram
4020 body, so it is possible to catch postcondition failures
4021 within the subprogram body itself.
4023 Within a package spec, normal visibility rules
4024 in Ada would prevent forward references within a
4025 postcondition pragma to functions defined later in
4026 the same package. This would introduce undesirable
4027 ordering constraints. To avoid this problem, all
4028 postcondition pragmas are analyzed at the end of
4029 the package spec, allowing forward references.
4031 The following example shows that this even allows
4032 mutually recursive postconditions as in:
4034 @smallexample @c ada
4035 package Parity_Functions is
4036 function Odd (X : Natural) return Boolean;
4037 pragma Postcondition
4041 (x /= 0 and then Even (X - 1))));
4043 function Even (X : Natural) return Boolean;
4044 pragma Postcondition
4048 (x /= 1 and then Odd (X - 1))));
4050 end Parity_Functions;
4054 There are no restrictions on the complexity or form of
4055 conditions used within @code{Postcondition} pragmas.
4056 The following example shows that it is even possible
4057 to verify performance behavior.
4059 @smallexample @c ada
4062 Performance : constant Float;
4063 -- Performance constant set by implementation
4064 -- to match target architecture behavior.
4066 procedure Treesort (Arg : String);
4067 -- Sorts characters of argument using N*logN sort
4068 pragma Postcondition
4069 (Float (Clock - Clock'Old) <=
4070 Float (Arg'Length) *
4071 log (Float (Arg'Length)) *
4077 Note: postcondition pragmas associated with subprograms that are
4078 marked as Inline_Always, or those marked as Inline with front-end
4079 inlining (-gnatN option set) are accepted and legality-checked
4080 by the compiler, but are ignored at run-time even if postcondition
4081 checking is enabled.
4083 @node Pragma Precondition
4084 @unnumberedsec Pragma Precondition
4085 @cindex Preconditions
4086 @cindex Checks, preconditions
4087 @findex Preconditions
4091 @smallexample @c ada
4092 pragma Precondition (
4093 [Check =>] Boolean_Expression
4094 [,[Message =>] String_Expression]);
4098 The @code{Precondition} pragma is similar to @code{Postcondition}
4099 except that the corresponding checks take place immediately upon
4100 entry to the subprogram, and if a precondition fails, the exception
4101 is raised in the context of the caller, and the attribute 'Result
4102 cannot be used within the precondition expression.
4104 Otherwise, the placement and visibility rules are identical to those
4105 described for postconditions. The following is an example of use
4106 within a package spec:
4108 @smallexample @c ada
4109 package Math_Functions is
4111 function Sqrt (Arg : Float) return Float;
4112 pragma Precondition (Arg >= 0.0)
4118 @code{Precondition} pragmas may appear either immediate following the
4119 (separate) declaration of a subprogram, or at the start of the
4120 declarations of a subprogram body. Only other pragmas may intervene
4121 (that is appear between the subprogram declaration and its
4122 postconditions, or appear before the postcondition in the
4123 declaration sequence in a subprogram body).
4125 Note: postcondition pragmas associated with subprograms that are
4126 marked as Inline_Always, or those marked as Inline with front-end
4127 inlining (-gnatN option set) are accepted and legality-checked
4128 by the compiler, but are ignored at run-time even if postcondition
4129 checking is enabled.
4131 @node Pragma Profile (Ravenscar)
4132 @unnumberedsec Pragma Profile (Ravenscar)
4137 @smallexample @c ada
4138 pragma Profile (Ravenscar);
4142 A configuration pragma that establishes the following set of configuration
4146 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4147 [RM D.2.2] Tasks are dispatched following a preemptive
4148 priority-ordered scheduling policy.
4150 @item Locking_Policy (Ceiling_Locking)
4151 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4152 the ceiling priority of the corresponding protected object.
4154 @c @item Detect_Blocking
4155 @c This pragma forces the detection of potentially blocking operations within a
4156 @c protected operation, and to raise Program_Error if that happens.
4160 plus the following set of restrictions:
4163 @item Max_Entry_Queue_Length = 1
4164 Defines the maximum number of calls that are queued on a (protected) entry.
4165 Note that this restrictions is checked at run time. Violation of this
4166 restriction results in the raising of Program_Error exception at the point of
4167 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4168 always 1 and hence no task can be queued on a protected entry.
4170 @item Max_Protected_Entries = 1
4171 [RM D.7] Specifies the maximum number of entries per protected type. The
4172 bounds of every entry family of a protected unit shall be static, or shall be
4173 defined by a discriminant of a subtype whose corresponding bound is static.
4174 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4176 @item Max_Task_Entries = 0
4177 [RM D.7] Specifies the maximum number of entries
4178 per task. The bounds of every entry family
4179 of a task unit shall be static, or shall be
4180 defined by a discriminant of a subtype whose
4181 corresponding bound is static. A value of zero
4182 indicates that no rendezvous are possible. For
4183 the Profile (Ravenscar), the value of Max_Task_Entries is always
4186 @item No_Abort_Statements
4187 [RM D.7] There are no abort_statements, and there are
4188 no calls to Task_Identification.Abort_Task.
4190 @item No_Asynchronous_Control
4191 There are no semantic dependences on the package
4192 Asynchronous_Task_Control.
4195 There are no semantic dependencies on the package Ada.Calendar.
4197 @item No_Dynamic_Attachment
4198 There is no call to any of the operations defined in package Ada.Interrupts
4199 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4200 Detach_Handler, and Reference).
4202 @item No_Dynamic_Priorities
4203 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4205 @item No_Implicit_Heap_Allocations
4206 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4208 @item No_Local_Protected_Objects
4209 Protected objects and access types that designate
4210 such objects shall be declared only at library level.
4212 @item No_Local_Timing_Events
4213 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4214 declared at the library level.
4216 @item No_Protected_Type_Allocators
4217 There are no allocators for protected types or
4218 types containing protected subcomponents.
4220 @item No_Relative_Delay
4221 There are no delay_relative statements.
4223 @item No_Requeue_Statements
4224 Requeue statements are not allowed.
4226 @item No_Select_Statements
4227 There are no select_statements.
4229 @item No_Specific_Termination_Handlers
4230 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4231 or to Ada.Task_Termination.Specific_Handler.
4233 @item No_Task_Allocators
4234 [RM D.7] There are no allocators for task types
4235 or types containing task subcomponents.
4237 @item No_Task_Attributes_Package
4238 There are no semantic dependencies on the Ada.Task_Attributes package.
4240 @item No_Task_Hierarchy
4241 [RM D.7] All (non-environment) tasks depend
4242 directly on the environment task of the partition.
4244 @item No_Task_Termination
4245 Tasks which terminate are erroneous.
4247 @item No_Unchecked_Conversion
4248 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4250 @item No_Unchecked_Deallocation
4251 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4253 @item Simple_Barriers
4254 Entry barrier condition expressions shall be either static
4255 boolean expressions or boolean objects which are declared in
4256 the protected type which contains the entry.
4260 This set of configuration pragmas and restrictions correspond to the
4261 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4262 published by the @cite{International Real-Time Ada Workshop}, 1997,
4263 and whose most recent description is available at
4264 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4266 The original definition of the profile was revised at subsequent IRTAW
4267 meetings. It has been included in the ISO
4268 @cite{Guide for the Use of the Ada Programming Language in High
4269 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4270 the next revision of the standard. The formal definition given by
4271 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4272 AI-305) available at
4273 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4274 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4277 The above set is a superset of the restrictions provided by pragma
4278 @code{Profile (Restricted)}, it includes six additional restrictions
4279 (@code{Simple_Barriers}, @code{No_Select_Statements},
4280 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4281 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4282 that pragma @code{Profile (Ravenscar)}, like the pragma
4283 @code{Profile (Restricted)},
4284 automatically causes the use of a simplified,
4285 more efficient version of the tasking run-time system.
4287 @node Pragma Profile (Restricted)
4288 @unnumberedsec Pragma Profile (Restricted)
4289 @findex Restricted Run Time
4293 @smallexample @c ada
4294 pragma Profile (Restricted);
4298 A configuration pragma that establishes the following set of restrictions:
4301 @item No_Abort_Statements
4302 @item No_Entry_Queue
4303 @item No_Task_Hierarchy
4304 @item No_Task_Allocators
4305 @item No_Dynamic_Priorities
4306 @item No_Terminate_Alternatives
4307 @item No_Dynamic_Attachment
4308 @item No_Protected_Type_Allocators
4309 @item No_Local_Protected_Objects
4310 @item No_Requeue_Statements
4311 @item No_Task_Attributes_Package
4312 @item Max_Asynchronous_Select_Nesting = 0
4313 @item Max_Task_Entries = 0
4314 @item Max_Protected_Entries = 1
4315 @item Max_Select_Alternatives = 0
4319 This set of restrictions causes the automatic selection of a simplified
4320 version of the run time that provides improved performance for the
4321 limited set of tasking functionality permitted by this set of restrictions.
4323 @node Pragma Psect_Object
4324 @unnumberedsec Pragma Psect_Object
4325 @findex Psect_Object
4329 @smallexample @c ada
4330 pragma Psect_Object (
4331 [Internal =>] LOCAL_NAME,
4332 [, [External =>] EXTERNAL_SYMBOL]
4333 [, [Size =>] EXTERNAL_SYMBOL]);
4337 | static_string_EXPRESSION
4341 This pragma is identical in effect to pragma @code{Common_Object}.
4343 @node Pragma Pure_Function
4344 @unnumberedsec Pragma Pure_Function
4345 @findex Pure_Function
4349 @smallexample @c ada
4350 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4354 This pragma appears in the same declarative part as a function
4355 declaration (or a set of function declarations if more than one
4356 overloaded declaration exists, in which case the pragma applies
4357 to all entities). It specifies that the function @code{Entity} is
4358 to be considered pure for the purposes of code generation. This means
4359 that the compiler can assume that there are no side effects, and
4360 in particular that two calls with identical arguments produce the
4361 same result. It also means that the function can be used in an
4364 Note that, quite deliberately, there are no static checks to try
4365 to ensure that this promise is met, so @code{Pure_Function} can be used
4366 with functions that are conceptually pure, even if they do modify
4367 global variables. For example, a square root function that is
4368 instrumented to count the number of times it is called is still
4369 conceptually pure, and can still be optimized, even though it
4370 modifies a global variable (the count). Memo functions are another
4371 example (where a table of previous calls is kept and consulted to
4372 avoid re-computation).
4374 Note also that the normal rules excluding optimization of subprograms
4375 in pure units (when parameter types are descended from System.Address,
4376 or when the full view of a parameter type is limited), do not apply
4377 for the Pure_Function case. If you explicitly specify Pure_Function,
4378 the compiler may optimize away calls with identical arguments, and
4379 if that results in unexpected behavior, the proper action is not to
4380 use the pragma for subprograms that are not (conceptually) pure.
4383 Note: Most functions in a @code{Pure} package are automatically pure, and
4384 there is no need to use pragma @code{Pure_Function} for such functions. One
4385 exception is any function that has at least one formal of type
4386 @code{System.Address} or a type derived from it. Such functions are not
4387 considered pure by default, since the compiler assumes that the
4388 @code{Address} parameter may be functioning as a pointer and that the
4389 referenced data may change even if the address value does not.
4390 Similarly, imported functions are not considered to be pure by default,
4391 since there is no way of checking that they are in fact pure. The use
4392 of pragma @code{Pure_Function} for such a function will override these default
4393 assumption, and cause the compiler to treat a designated subprogram as pure
4396 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4397 applies to the underlying renamed function. This can be used to
4398 disambiguate cases of overloading where some but not all functions
4399 in a set of overloaded functions are to be designated as pure.
4401 If pragma @code{Pure_Function} is applied to a library level function, the
4402 function is also considered pure from an optimization point of view, but the
4403 unit is not a Pure unit in the categorization sense. So for example, a function
4404 thus marked is free to @code{with} non-pure units.
4406 @node Pragma Restriction_Warnings
4407 @unnumberedsec Pragma Restriction_Warnings
4408 @findex Restriction_Warnings
4412 @smallexample @c ada
4413 pragma Restriction_Warnings
4414 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4418 This pragma allows a series of restriction identifiers to be
4419 specified (the list of allowed identifiers is the same as for
4420 pragma @code{Restrictions}). For each of these identifiers
4421 the compiler checks for violations of the restriction, but
4422 generates a warning message rather than an error message
4423 if the restriction is violated.
4426 @unnumberedsec Pragma Shared
4430 This pragma is provided for compatibility with Ada 83. The syntax and
4431 semantics are identical to pragma Atomic.
4433 @node Pragma Short_Circuit_And_Or
4434 @unnumberedsec Pragma Short_Circuit_And_Or
4435 @findex Short_Circuit_And_Or
4438 This configuration pragma causes any occurrence of the AND operator applied to
4439 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4440 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4441 may be useful in the context of certification protocols requiring the use of
4442 short-circuited logical operators. If this configuration pragma occurs locally
4443 within the file being compiled, it applies only to the file being compiled.
4444 There is no requirement that all units in a partition use this option.
4446 @node Pragma Short_Descriptors
4447 @unnumberedsec Pragma Short_Descriptors
4448 @findex Short_Descriptors
4452 @smallexample @c ada
4453 pragma Short_Descriptors
4457 In VMS versions of the compiler, this configuration pragma causes all
4458 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4459 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4460 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4463 @node Pragma Source_File_Name
4464 @unnumberedsec Pragma Source_File_Name
4465 @findex Source_File_Name
4469 @smallexample @c ada
4470 pragma Source_File_Name (
4471 [Unit_Name =>] unit_NAME,
4472 Spec_File_Name => STRING_LITERAL,
4473 [Index => INTEGER_LITERAL]);
4475 pragma Source_File_Name (
4476 [Unit_Name =>] unit_NAME,
4477 Body_File_Name => STRING_LITERAL,
4478 [Index => INTEGER_LITERAL]);
4482 Use this to override the normal naming convention. It is a configuration
4483 pragma, and so has the usual applicability of configuration pragmas
4484 (i.e.@: it applies to either an entire partition, or to all units in a
4485 compilation, or to a single unit, depending on how it is used.
4486 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4487 the second argument is required, and indicates whether this is the file
4488 name for the spec or for the body.
4490 The optional Index argument should be used when a file contains multiple
4491 units, and when you do not want to use @code{gnatchop} to separate then
4492 into multiple files (which is the recommended procedure to limit the
4493 number of recompilations that are needed when some sources change).
4494 For instance, if the source file @file{source.ada} contains
4496 @smallexample @c ada
4508 you could use the following configuration pragmas:
4510 @smallexample @c ada
4511 pragma Source_File_Name
4512 (B, Spec_File_Name => "source.ada", Index => 1);
4513 pragma Source_File_Name
4514 (A, Body_File_Name => "source.ada", Index => 2);
4517 Note that the @code{gnatname} utility can also be used to generate those
4518 configuration pragmas.
4520 Another form of the @code{Source_File_Name} pragma allows
4521 the specification of patterns defining alternative file naming schemes
4522 to apply to all files.
4524 @smallexample @c ada
4525 pragma Source_File_Name
4526 ( [Spec_File_Name =>] STRING_LITERAL
4527 [,[Casing =>] CASING_SPEC]
4528 [,[Dot_Replacement =>] STRING_LITERAL]);
4530 pragma Source_File_Name
4531 ( [Body_File_Name =>] STRING_LITERAL
4532 [,[Casing =>] CASING_SPEC]
4533 [,[Dot_Replacement =>] STRING_LITERAL]);
4535 pragma Source_File_Name
4536 ( [Subunit_File_Name =>] STRING_LITERAL
4537 [,[Casing =>] CASING_SPEC]
4538 [,[Dot_Replacement =>] STRING_LITERAL]);
4540 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4544 The first argument is a pattern that contains a single asterisk indicating
4545 the point at which the unit name is to be inserted in the pattern string
4546 to form the file name. The second argument is optional. If present it
4547 specifies the casing of the unit name in the resulting file name string.
4548 The default is lower case. Finally the third argument allows for systematic
4549 replacement of any dots in the unit name by the specified string literal.
4551 A pragma Source_File_Name cannot appear after a
4552 @ref{Pragma Source_File_Name_Project}.
4554 For more details on the use of the @code{Source_File_Name} pragma,
4555 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4556 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4559 @node Pragma Source_File_Name_Project
4560 @unnumberedsec Pragma Source_File_Name_Project
4561 @findex Source_File_Name_Project
4564 This pragma has the same syntax and semantics as pragma Source_File_Name.
4565 It is only allowed as a stand alone configuration pragma.
4566 It cannot appear after a @ref{Pragma Source_File_Name}, and
4567 most importantly, once pragma Source_File_Name_Project appears,
4568 no further Source_File_Name pragmas are allowed.
4570 The intention is that Source_File_Name_Project pragmas are always
4571 generated by the Project Manager in a manner consistent with the naming
4572 specified in a project file, and when naming is controlled in this manner,
4573 it is not permissible to attempt to modify this naming scheme using
4574 Source_File_Name pragmas (which would not be known to the project manager).
4576 @node Pragma Source_Reference
4577 @unnumberedsec Pragma Source_Reference
4578 @findex Source_Reference
4582 @smallexample @c ada
4583 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4587 This pragma must appear as the first line of a source file.
4588 @var{integer_literal} is the logical line number of the line following
4589 the pragma line (for use in error messages and debugging
4590 information). @var{string_literal} is a static string constant that
4591 specifies the file name to be used in error messages and debugging
4592 information. This is most notably used for the output of @code{gnatchop}
4593 with the @option{-r} switch, to make sure that the original unchopped
4594 source file is the one referred to.
4596 The second argument must be a string literal, it cannot be a static
4597 string expression other than a string literal. This is because its value
4598 is needed for error messages issued by all phases of the compiler.
4600 @node Pragma Stream_Convert
4601 @unnumberedsec Pragma Stream_Convert
4602 @findex Stream_Convert
4606 @smallexample @c ada
4607 pragma Stream_Convert (
4608 [Entity =>] type_LOCAL_NAME,
4609 [Read =>] function_NAME,
4610 [Write =>] function_NAME);
4614 This pragma provides an efficient way of providing stream functions for
4615 types defined in packages. Not only is it simpler to use than declaring
4616 the necessary functions with attribute representation clauses, but more
4617 significantly, it allows the declaration to made in such a way that the
4618 stream packages are not loaded unless they are needed. The use of
4619 the Stream_Convert pragma adds no overhead at all, unless the stream
4620 attributes are actually used on the designated type.
4622 The first argument specifies the type for which stream functions are
4623 provided. The second parameter provides a function used to read values
4624 of this type. It must name a function whose argument type may be any
4625 subtype, and whose returned type must be the type given as the first
4626 argument to the pragma.
4628 The meaning of the @var{Read}
4629 parameter is that if a stream attribute directly
4630 or indirectly specifies reading of the type given as the first parameter,
4631 then a value of the type given as the argument to the Read function is
4632 read from the stream, and then the Read function is used to convert this
4633 to the required target type.
4635 Similarly the @var{Write} parameter specifies how to treat write attributes
4636 that directly or indirectly apply to the type given as the first parameter.
4637 It must have an input parameter of the type specified by the first parameter,
4638 and the return type must be the same as the input type of the Read function.
4639 The effect is to first call the Write function to convert to the given stream
4640 type, and then write the result type to the stream.
4642 The Read and Write functions must not be overloaded subprograms. If necessary
4643 renamings can be supplied to meet this requirement.
4644 The usage of this attribute is best illustrated by a simple example, taken
4645 from the GNAT implementation of package Ada.Strings.Unbounded:
4647 @smallexample @c ada
4648 function To_Unbounded (S : String)
4649 return Unbounded_String
4650 renames To_Unbounded_String;
4652 pragma Stream_Convert
4653 (Unbounded_String, To_Unbounded, To_String);
4657 The specifications of the referenced functions, as given in the Ada
4658 Reference Manual are:
4660 @smallexample @c ada
4661 function To_Unbounded_String (Source : String)
4662 return Unbounded_String;
4664 function To_String (Source : Unbounded_String)
4669 The effect is that if the value of an unbounded string is written to a stream,
4670 then the representation of the item in the stream is in the same format that
4671 would be used for @code{Standard.String'Output}, and this same representation
4672 is expected when a value of this type is read from the stream. Note that the
4673 value written always includes the bounds, even for Unbounded_String'Write,
4674 since Unbounded_String is not an array type.
4676 @node Pragma Style_Checks
4677 @unnumberedsec Pragma Style_Checks
4678 @findex Style_Checks
4682 @smallexample @c ada
4683 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4684 On | Off [, LOCAL_NAME]);
4688 This pragma is used in conjunction with compiler switches to control the
4689 built in style checking provided by GNAT@. The compiler switches, if set,
4690 provide an initial setting for the switches, and this pragma may be used
4691 to modify these settings, or the settings may be provided entirely by
4692 the use of the pragma. This pragma can be used anywhere that a pragma
4693 is legal, including use as a configuration pragma (including use in
4694 the @file{gnat.adc} file).
4696 The form with a string literal specifies which style options are to be
4697 activated. These are additive, so they apply in addition to any previously
4698 set style check options. The codes for the options are the same as those
4699 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4700 For example the following two methods can be used to enable
4705 @smallexample @c ada
4706 pragma Style_Checks ("l");
4711 gcc -c -gnatyl @dots{}
4716 The form ALL_CHECKS activates all standard checks (its use is equivalent
4717 to the use of the @code{gnaty} switch with no options. @xref{Top,
4718 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4719 @value{EDITION} User's Guide}, for details.)
4721 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4722 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4723 options (i.e. equivalent to -gnatyg).
4725 The forms with @code{Off} and @code{On}
4726 can be used to temporarily disable style checks
4727 as shown in the following example:
4729 @smallexample @c ada
4733 pragma Style_Checks ("k"); -- requires keywords in lower case
4734 pragma Style_Checks (Off); -- turn off style checks
4735 NULL; -- this will not generate an error message
4736 pragma Style_Checks (On); -- turn style checks back on
4737 NULL; -- this will generate an error message
4741 Finally the two argument form is allowed only if the first argument is
4742 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4743 for the specified entity, as shown in the following example:
4745 @smallexample @c ada
4749 pragma Style_Checks ("r"); -- require consistency of identifier casing
4751 Rf1 : Integer := ARG; -- incorrect, wrong case
4752 pragma Style_Checks (Off, Arg);
4753 Rf2 : Integer := ARG; -- OK, no error
4756 @node Pragma Subtitle
4757 @unnumberedsec Pragma Subtitle
4762 @smallexample @c ada
4763 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4767 This pragma is recognized for compatibility with other Ada compilers
4768 but is ignored by GNAT@.
4770 @node Pragma Suppress
4771 @unnumberedsec Pragma Suppress
4776 @smallexample @c ada
4777 pragma Suppress (Identifier [, [On =>] Name]);
4781 This is a standard pragma, and supports all the check names required in
4782 the RM. It is included here because GNAT recognizes one additional check
4783 name: @code{Alignment_Check} which can be used to suppress alignment checks
4784 on addresses used in address clauses. Such checks can also be suppressed
4785 by suppressing range checks, but the specific use of @code{Alignment_Check}
4786 allows suppression of alignment checks without suppressing other range checks.
4788 Note that pragma Suppress gives the compiler permission to omit
4789 checks, but does not require the compiler to omit checks. The compiler
4790 will generate checks if they are essentially free, even when they are
4791 suppressed. In particular, if the compiler can prove that a certain
4792 check will necessarily fail, it will generate code to do an
4793 unconditional ``raise'', even if checks are suppressed. The compiler
4796 Of course, run-time checks are omitted whenever the compiler can prove
4797 that they will not fail, whether or not checks are suppressed.
4799 @node Pragma Suppress_All
4800 @unnumberedsec Pragma Suppress_All
4801 @findex Suppress_All
4805 @smallexample @c ada
4806 pragma Suppress_All;
4810 This pragma can appear anywhere within a unit.
4811 The effect is to apply @code{Suppress (All_Checks)} to the unit
4812 in which it appears. This pragma is implemented for compatibility with DEC
4813 Ada 83 usage where it appears at the end of a unit, and for compatibility
4814 with Rational Ada, where it appears as a program unit pragma.
4815 The use of the standard Ada pragma @code{Suppress (All_Checks)}
4816 as a normal configuration pragma is the preferred usage in GNAT@.
4818 @node Pragma Suppress_Exception_Locations
4819 @unnumberedsec Pragma Suppress_Exception_Locations
4820 @findex Suppress_Exception_Locations
4824 @smallexample @c ada
4825 pragma Suppress_Exception_Locations;
4829 In normal mode, a raise statement for an exception by default generates
4830 an exception message giving the file name and line number for the location
4831 of the raise. This is useful for debugging and logging purposes, but this
4832 entails extra space for the strings for the messages. The configuration
4833 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4834 generation of these strings, with the result that space is saved, but the
4835 exception message for such raises is null. This configuration pragma may
4836 appear in a global configuration pragma file, or in a specific unit as
4837 usual. It is not required that this pragma be used consistently within
4838 a partition, so it is fine to have some units within a partition compiled
4839 with this pragma and others compiled in normal mode without it.
4841 @node Pragma Suppress_Initialization
4842 @unnumberedsec Pragma Suppress_Initialization
4843 @findex Suppress_Initialization
4844 @cindex Suppressing initialization
4845 @cindex Initialization, suppression of
4849 @smallexample @c ada
4850 pragma Suppress_Initialization ([Entity =>] type_Name);
4854 This pragma suppresses any implicit or explicit initialization
4855 associated with the given type name for all variables of this type.
4857 @node Pragma Task_Info
4858 @unnumberedsec Pragma Task_Info
4863 @smallexample @c ada
4864 pragma Task_Info (EXPRESSION);
4868 This pragma appears within a task definition (like pragma
4869 @code{Priority}) and applies to the task in which it appears. The
4870 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4871 The @code{Task_Info} pragma provides system dependent control over
4872 aspects of tasking implementation, for example, the ability to map
4873 tasks to specific processors. For details on the facilities available
4874 for the version of GNAT that you are using, see the documentation
4875 in the spec of package System.Task_Info in the runtime
4878 @node Pragma Task_Name
4879 @unnumberedsec Pragma Task_Name
4884 @smallexample @c ada
4885 pragma Task_Name (string_EXPRESSION);
4889 This pragma appears within a task definition (like pragma
4890 @code{Priority}) and applies to the task in which it appears. The
4891 argument must be of type String, and provides a name to be used for
4892 the task instance when the task is created. Note that this expression
4893 is not required to be static, and in particular, it can contain
4894 references to task discriminants. This facility can be used to
4895 provide different names for different tasks as they are created,
4896 as illustrated in the example below.
4898 The task name is recorded internally in the run-time structures
4899 and is accessible to tools like the debugger. In addition the
4900 routine @code{Ada.Task_Identification.Image} will return this
4901 string, with a unique task address appended.
4903 @smallexample @c ada
4904 -- Example of the use of pragma Task_Name
4906 with Ada.Task_Identification;
4907 use Ada.Task_Identification;
4908 with Text_IO; use Text_IO;
4911 type Astring is access String;
4913 task type Task_Typ (Name : access String) is
4914 pragma Task_Name (Name.all);
4917 task body Task_Typ is
4918 Nam : constant String := Image (Current_Task);
4920 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4923 type Ptr_Task is access Task_Typ;
4924 Task_Var : Ptr_Task;
4928 new Task_Typ (new String'("This is task 1"));
4930 new Task_Typ (new String'("This is task 2"));
4934 @node Pragma Task_Storage
4935 @unnumberedsec Pragma Task_Storage
4936 @findex Task_Storage
4939 @smallexample @c ada
4940 pragma Task_Storage (
4941 [Task_Type =>] LOCAL_NAME,
4942 [Top_Guard =>] static_integer_EXPRESSION);
4946 This pragma specifies the length of the guard area for tasks. The guard
4947 area is an additional storage area allocated to a task. A value of zero
4948 means that either no guard area is created or a minimal guard area is
4949 created, depending on the target. This pragma can appear anywhere a
4950 @code{Storage_Size} attribute definition clause is allowed for a task
4953 @node Pragma Thread_Local_Storage
4954 @unnumberedsec Pragma Thread_Local_Storage
4955 @findex Thread_Local_Storage
4956 @cindex Task specific storage
4957 @cindex TLS (Thread Local Storage)
4960 @smallexample @c ada
4961 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4965 This pragma specifies that the specified entity, which must be
4966 a variable declared in a library level package, is to be marked as
4967 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4968 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4969 (and hence each Ada task) to see a distinct copy of the variable.
4971 The variable may not have default initialization, and if there is
4972 an explicit initialization, it must be either @code{null} for an
4973 access variable, or a static expression for a scalar variable.
4974 This provides a low level mechanism similar to that provided by
4975 the @code{Ada.Task_Attributes} package, but much more efficient
4976 and is also useful in writing interface code that will interact
4977 with foreign threads.
4979 If this pragma is used on a system where @code{TLS} is not supported,
4980 then an error message will be generated and the program will be rejected.
4982 @node Pragma Time_Slice
4983 @unnumberedsec Pragma Time_Slice
4988 @smallexample @c ada
4989 pragma Time_Slice (static_duration_EXPRESSION);
4993 For implementations of GNAT on operating systems where it is possible
4994 to supply a time slice value, this pragma may be used for this purpose.
4995 It is ignored if it is used in a system that does not allow this control,
4996 or if it appears in other than the main program unit.
4998 Note that the effect of this pragma is identical to the effect of the
4999 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5002 @unnumberedsec Pragma Title
5007 @smallexample @c ada
5008 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5011 [Title =>] STRING_LITERAL,
5012 | [Subtitle =>] STRING_LITERAL
5016 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5017 pragma used in DEC Ada 83 implementations to provide a title and/or
5018 subtitle for the program listing. The program listing generated by GNAT
5019 does not have titles or subtitles.
5021 Unlike other pragmas, the full flexibility of named notation is allowed
5022 for this pragma, i.e.@: the parameters may be given in any order if named
5023 notation is used, and named and positional notation can be mixed
5024 following the normal rules for procedure calls in Ada.
5026 @node Pragma Unchecked_Union
5027 @unnumberedsec Pragma Unchecked_Union
5029 @findex Unchecked_Union
5033 @smallexample @c ada
5034 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5038 This pragma is used to specify a representation of a record type that is
5039 equivalent to a C union. It was introduced as a GNAT implementation defined
5040 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5041 pragma, making it language defined, and GNAT fully implements this extended
5042 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5043 details, consult the Ada 2005 Reference Manual, section B.3.3.
5045 @node Pragma Unimplemented_Unit
5046 @unnumberedsec Pragma Unimplemented_Unit
5047 @findex Unimplemented_Unit
5051 @smallexample @c ada
5052 pragma Unimplemented_Unit;
5056 If this pragma occurs in a unit that is processed by the compiler, GNAT
5057 aborts with the message @samp{@var{xxx} not implemented}, where
5058 @var{xxx} is the name of the current compilation unit. This pragma is
5059 intended to allow the compiler to handle unimplemented library units in
5062 The abort only happens if code is being generated. Thus you can use
5063 specs of unimplemented packages in syntax or semantic checking mode.
5065 @node Pragma Universal_Aliasing
5066 @unnumberedsec Pragma Universal_Aliasing
5067 @findex Universal_Aliasing
5071 @smallexample @c ada
5072 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5076 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5077 declarative part. The effect is to inhibit strict type-based aliasing
5078 optimization for the given type. In other words, the effect is as though
5079 access types designating this type were subject to pragma No_Strict_Aliasing.
5080 For a detailed description of the strict aliasing optimization, and the
5081 situations in which it must be suppressed, @xref{Optimization and Strict
5082 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5084 @node Pragma Universal_Data
5085 @unnumberedsec Pragma Universal_Data
5086 @findex Universal_Data
5090 @smallexample @c ada
5091 pragma Universal_Data [(library_unit_Name)];
5095 This pragma is supported only for the AAMP target and is ignored for
5096 other targets. The pragma specifies that all library-level objects
5097 (Counter 0 data) associated with the library unit are to be accessed
5098 and updated using universal addressing (24-bit addresses for AAMP5)
5099 rather than the default of 16-bit Data Environment (DENV) addressing.
5100 Use of this pragma will generally result in less efficient code for
5101 references to global data associated with the library unit, but
5102 allows such data to be located anywhere in memory. This pragma is
5103 a library unit pragma, but can also be used as a configuration pragma
5104 (including use in the @file{gnat.adc} file). The functionality
5105 of this pragma is also available by applying the -univ switch on the
5106 compilations of units where universal addressing of the data is desired.
5108 @node Pragma Unmodified
5109 @unnumberedsec Pragma Unmodified
5111 @cindex Warnings, unmodified
5115 @smallexample @c ada
5116 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5120 This pragma signals that the assignable entities (variables,
5121 @code{out} parameters, @code{in out} parameters) whose names are listed are
5122 deliberately not assigned in the current source unit. This
5123 suppresses warnings about the
5124 entities being referenced but not assigned, and in addition a warning will be
5125 generated if one of these entities is in fact assigned in the
5126 same unit as the pragma (or in the corresponding body, or one
5129 This is particularly useful for clearly signaling that a particular
5130 parameter is not modified, even though the spec suggests that it might
5133 @node Pragma Unreferenced
5134 @unnumberedsec Pragma Unreferenced
5135 @findex Unreferenced
5136 @cindex Warnings, unreferenced
5140 @smallexample @c ada
5141 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5142 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5146 This pragma signals that the entities whose names are listed are
5147 deliberately not referenced in the current source unit. This
5148 suppresses warnings about the
5149 entities being unreferenced, and in addition a warning will be
5150 generated if one of these entities is in fact referenced in the
5151 same unit as the pragma (or in the corresponding body, or one
5154 This is particularly useful for clearly signaling that a particular
5155 parameter is not referenced in some particular subprogram implementation
5156 and that this is deliberate. It can also be useful in the case of
5157 objects declared only for their initialization or finalization side
5160 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5161 current scope, then the entity most recently declared is the one to which
5162 the pragma applies. Note that in the case of accept formals, the pragma
5163 Unreferenced may appear immediately after the keyword @code{do} which
5164 allows the indication of whether or not accept formals are referenced
5165 or not to be given individually for each accept statement.
5167 The left hand side of an assignment does not count as a reference for the
5168 purpose of this pragma. Thus it is fine to assign to an entity for which
5169 pragma Unreferenced is given.
5171 Note that if a warning is desired for all calls to a given subprogram,
5172 regardless of whether they occur in the same unit as the subprogram
5173 declaration, then this pragma should not be used (calls from another
5174 unit would not be flagged); pragma Obsolescent can be used instead
5175 for this purpose, see @xref{Pragma Obsolescent}.
5177 The second form of pragma @code{Unreferenced} is used within a context
5178 clause. In this case the arguments must be unit names of units previously
5179 mentioned in @code{with} clauses (similar to the usage of pragma
5180 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5181 units and unreferenced entities within these units.
5183 @node Pragma Unreferenced_Objects
5184 @unnumberedsec Pragma Unreferenced_Objects
5185 @findex Unreferenced_Objects
5186 @cindex Warnings, unreferenced
5190 @smallexample @c ada
5191 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5195 This pragma signals that for the types or subtypes whose names are
5196 listed, objects which are declared with one of these types or subtypes may
5197 not be referenced, and if no references appear, no warnings are given.
5199 This is particularly useful for objects which are declared solely for their
5200 initialization and finalization effect. Such variables are sometimes referred
5201 to as RAII variables (Resource Acquisition Is Initialization). Using this
5202 pragma on the relevant type (most typically a limited controlled type), the
5203 compiler will automatically suppress unwanted warnings about these variables
5204 not being referenced.
5206 @node Pragma Unreserve_All_Interrupts
5207 @unnumberedsec Pragma Unreserve_All_Interrupts
5208 @findex Unreserve_All_Interrupts
5212 @smallexample @c ada
5213 pragma Unreserve_All_Interrupts;
5217 Normally certain interrupts are reserved to the implementation. Any attempt
5218 to attach an interrupt causes Program_Error to be raised, as described in
5219 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5220 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5221 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5222 interrupt execution.
5224 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5225 a program, then all such interrupts are unreserved. This allows the
5226 program to handle these interrupts, but disables their standard
5227 functions. For example, if this pragma is used, then pressing
5228 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5229 a program can then handle the @code{SIGINT} interrupt as it chooses.
5231 For a full list of the interrupts handled in a specific implementation,
5232 see the source code for the spec of @code{Ada.Interrupts.Names} in
5233 file @file{a-intnam.ads}. This is a target dependent file that contains the
5234 list of interrupts recognized for a given target. The documentation in
5235 this file also specifies what interrupts are affected by the use of
5236 the @code{Unreserve_All_Interrupts} pragma.
5238 For a more general facility for controlling what interrupts can be
5239 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5240 of the @code{Unreserve_All_Interrupts} pragma.
5242 @node Pragma Unsuppress
5243 @unnumberedsec Pragma Unsuppress
5248 @smallexample @c ada
5249 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5253 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5254 there is no corresponding pragma @code{Suppress} in effect, it has no
5255 effect. The range of the effect is the same as for pragma
5256 @code{Suppress}. The meaning of the arguments is identical to that used
5257 in pragma @code{Suppress}.
5259 One important application is to ensure that checks are on in cases where
5260 code depends on the checks for its correct functioning, so that the code
5261 will compile correctly even if the compiler switches are set to suppress
5264 @node Pragma Use_VADS_Size
5265 @unnumberedsec Pragma Use_VADS_Size
5266 @cindex @code{Size}, VADS compatibility
5267 @findex Use_VADS_Size
5271 @smallexample @c ada
5272 pragma Use_VADS_Size;
5276 This is a configuration pragma. In a unit to which it applies, any use
5277 of the 'Size attribute is automatically interpreted as a use of the
5278 'VADS_Size attribute. Note that this may result in incorrect semantic
5279 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5280 the handling of existing code which depends on the interpretation of Size
5281 as implemented in the VADS compiler. See description of the VADS_Size
5282 attribute for further details.
5284 @node Pragma Validity_Checks
5285 @unnumberedsec Pragma Validity_Checks
5286 @findex Validity_Checks
5290 @smallexample @c ada
5291 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5295 This pragma is used in conjunction with compiler switches to control the
5296 built-in validity checking provided by GNAT@. The compiler switches, if set
5297 provide an initial setting for the switches, and this pragma may be used
5298 to modify these settings, or the settings may be provided entirely by
5299 the use of the pragma. This pragma can be used anywhere that a pragma
5300 is legal, including use as a configuration pragma (including use in
5301 the @file{gnat.adc} file).
5303 The form with a string literal specifies which validity options are to be
5304 activated. The validity checks are first set to include only the default
5305 reference manual settings, and then a string of letters in the string
5306 specifies the exact set of options required. The form of this string
5307 is exactly as described for the @option{-gnatVx} compiler switch (see the
5308 GNAT users guide for details). For example the following two methods
5309 can be used to enable validity checking for mode @code{in} and
5310 @code{in out} subprogram parameters:
5314 @smallexample @c ada
5315 pragma Validity_Checks ("im");
5320 gcc -c -gnatVim @dots{}
5325 The form ALL_CHECKS activates all standard checks (its use is equivalent
5326 to the use of the @code{gnatva} switch.
5328 The forms with @code{Off} and @code{On}
5329 can be used to temporarily disable validity checks
5330 as shown in the following example:
5332 @smallexample @c ada
5336 pragma Validity_Checks ("c"); -- validity checks for copies
5337 pragma Validity_Checks (Off); -- turn off validity checks
5338 A := B; -- B will not be validity checked
5339 pragma Validity_Checks (On); -- turn validity checks back on
5340 A := C; -- C will be validity checked
5343 @node Pragma Volatile
5344 @unnumberedsec Pragma Volatile
5349 @smallexample @c ada
5350 pragma Volatile (LOCAL_NAME);
5354 This pragma is defined by the Ada Reference Manual, and the GNAT
5355 implementation is fully conformant with this definition. The reason it
5356 is mentioned in this section is that a pragma of the same name was supplied
5357 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5358 implementation of pragma Volatile is upwards compatible with the
5359 implementation in DEC Ada 83.
5361 @node Pragma Warnings
5362 @unnumberedsec Pragma Warnings
5367 @smallexample @c ada
5368 pragma Warnings (On | Off);
5369 pragma Warnings (On | Off, LOCAL_NAME);
5370 pragma Warnings (static_string_EXPRESSION);
5371 pragma Warnings (On | Off, static_string_EXPRESSION);
5375 Normally warnings are enabled, with the output being controlled by
5376 the command line switch. Warnings (@code{Off}) turns off generation of
5377 warnings until a Warnings (@code{On}) is encountered or the end of the
5378 current unit. If generation of warnings is turned off using this
5379 pragma, then no warning messages are output, regardless of the
5380 setting of the command line switches.
5382 The form with a single argument may be used as a configuration pragma.
5384 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5385 the specified entity. This suppression is effective from the point where
5386 it occurs till the end of the extended scope of the variable (similar to
5387 the scope of @code{Suppress}).
5389 The form with a single static_string_EXPRESSION argument provides more precise
5390 control over which warnings are active. The string is a list of letters
5391 specifying which warnings are to be activated and which deactivated. The
5392 code for these letters is the same as the string used in the command
5393 line switch controlling warnings. For a brief summary, use the gnatmake
5394 command with no arguments, which will generate usage information containing
5395 the list of warnings switches supported. For
5396 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5400 The specified warnings will be in effect until the end of the program
5401 or another pragma Warnings is encountered. The effect of the pragma is
5402 cumulative. Initially the set of warnings is the standard default set
5403 as possibly modified by compiler switches. Then each pragma Warning
5404 modifies this set of warnings as specified. This form of the pragma may
5405 also be used as a configuration pragma.
5407 The fourth form, with an On|Off parameter and a string, is used to
5408 control individual messages, based on their text. The string argument
5409 is a pattern that is used to match against the text of individual
5410 warning messages (not including the initial "warning: " tag).
5412 The pattern may contain asterisks, which match zero or more characters in
5413 the message. For example, you can use
5414 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5415 message @code{warning: 960 bits of "a" unused}. No other regular
5416 expression notations are permitted. All characters other than asterisk in
5417 these three specific cases are treated as literal characters in the match.
5419 There are two ways to use this pragma. The OFF form can be used as a
5420 configuration pragma. The effect is to suppress all warnings (if any)
5421 that match the pattern string throughout the compilation.
5423 The second usage is to suppress a warning locally, and in this case, two
5424 pragmas must appear in sequence:
5426 @smallexample @c ada
5427 pragma Warnings (Off, Pattern);
5428 @dots{} code where given warning is to be suppressed
5429 pragma Warnings (On, Pattern);
5433 In this usage, the pattern string must match in the Off and On pragmas,
5434 and at least one matching warning must be suppressed.
5436 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5437 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5438 be useful in checking whether obsolete pragmas in existing programs are hiding
5441 Note: pragma Warnings does not affect the processing of style messages. See
5442 separate entry for pragma Style_Checks for control of style messages.
5444 @node Pragma Weak_External
5445 @unnumberedsec Pragma Weak_External
5446 @findex Weak_External
5450 @smallexample @c ada
5451 pragma Weak_External ([Entity =>] LOCAL_NAME);
5455 @var{LOCAL_NAME} must refer to an object that is declared at the library
5456 level. This pragma specifies that the given entity should be marked as a
5457 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5458 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5459 of a regular symbol, that is to say a symbol that does not have to be
5460 resolved by the linker if used in conjunction with a pragma Import.
5462 When a weak symbol is not resolved by the linker, its address is set to
5463 zero. This is useful in writing interfaces to external modules that may
5464 or may not be linked in the final executable, for example depending on
5465 configuration settings.
5467 If a program references at run time an entity to which this pragma has been
5468 applied, and the corresponding symbol was not resolved at link time, then
5469 the execution of the program is erroneous. It is not erroneous to take the
5470 Address of such an entity, for example to guard potential references,
5471 as shown in the example below.
5473 Some file formats do not support weak symbols so not all target machines
5474 support this pragma.
5476 @smallexample @c ada
5477 -- Example of the use of pragma Weak_External
5479 package External_Module is
5481 pragma Import (C, key);
5482 pragma Weak_External (key);
5483 function Present return boolean;
5484 end External_Module;
5486 with System; use System;
5487 package body External_Module is
5488 function Present return boolean is
5490 return key'Address /= System.Null_Address;
5492 end External_Module;
5495 @node Pragma Wide_Character_Encoding
5496 @unnumberedsec Pragma Wide_Character_Encoding
5497 @findex Wide_Character_Encoding
5501 @smallexample @c ada
5502 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5506 This pragma specifies the wide character encoding to be used in program
5507 source text appearing subsequently. It is a configuration pragma, but may
5508 also be used at any point that a pragma is allowed, and it is permissible
5509 to have more than one such pragma in a file, allowing multiple encodings
5510 to appear within the same file.
5512 The argument can be an identifier or a character literal. In the identifier
5513 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5514 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5515 case it is correspondingly one of the characters @samp{h}, @samp{u},
5516 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5518 Note that when the pragma is used within a file, it affects only the
5519 encoding within that file, and does not affect withed units, specs,
5522 @node Implementation Defined Attributes
5523 @chapter Implementation Defined Attributes
5524 Ada defines (throughout the Ada reference manual,
5525 summarized in Annex K),
5526 a set of attributes that provide useful additional functionality in all
5527 areas of the language. These language defined attributes are implemented
5528 in GNAT and work as described in the Ada Reference Manual.
5530 In addition, Ada allows implementations to define additional
5531 attributes whose meaning is defined by the implementation. GNAT provides
5532 a number of these implementation-dependent attributes which can be used
5533 to extend and enhance the functionality of the compiler. This section of
5534 the GNAT reference manual describes these additional attributes.
5536 Note that any program using these attributes may not be portable to
5537 other compilers (although GNAT implements this set of attributes on all
5538 platforms). Therefore if portability to other compilers is an important
5539 consideration, you should minimize the use of these attributes.
5549 * Compiler_Version::
5551 * Default_Bit_Order::
5561 * Has_Access_Values::
5562 * Has_Discriminants::
5569 * Max_Interrupt_Priority::
5571 * Maximum_Alignment::
5576 * Passed_By_Reference::
5591 * Unconstrained_Array::
5592 * Universal_Literal_String::
5593 * Unrestricted_Access::
5601 @unnumberedsec Abort_Signal
5602 @findex Abort_Signal
5604 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5605 prefix) provides the entity for the special exception used to signal
5606 task abort or asynchronous transfer of control. Normally this attribute
5607 should only be used in the tasking runtime (it is highly peculiar, and
5608 completely outside the normal semantics of Ada, for a user program to
5609 intercept the abort exception).
5612 @unnumberedsec Address_Size
5613 @cindex Size of @code{Address}
5614 @findex Address_Size
5616 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5617 prefix) is a static constant giving the number of bits in an
5618 @code{Address}. It is the same value as System.Address'Size,
5619 but has the advantage of being static, while a direct
5620 reference to System.Address'Size is non-static because Address
5624 @unnumberedsec Asm_Input
5627 The @code{Asm_Input} attribute denotes a function that takes two
5628 parameters. The first is a string, the second is an expression of the
5629 type designated by the prefix. The first (string) argument is required
5630 to be a static expression, and is the constraint for the parameter,
5631 (e.g.@: what kind of register is required). The second argument is the
5632 value to be used as the input argument. The possible values for the
5633 constant are the same as those used in the RTL, and are dependent on
5634 the configuration file used to built the GCC back end.
5635 @ref{Machine Code Insertions}
5638 @unnumberedsec Asm_Output
5641 The @code{Asm_Output} attribute denotes a function that takes two
5642 parameters. The first is a string, the second is the name of a variable
5643 of the type designated by the attribute prefix. The first (string)
5644 argument is required to be a static expression and designates the
5645 constraint for the parameter (e.g.@: what kind of register is
5646 required). The second argument is the variable to be updated with the
5647 result. The possible values for constraint are the same as those used in
5648 the RTL, and are dependent on the configuration file used to build the
5649 GCC back end. If there are no output operands, then this argument may
5650 either be omitted, or explicitly given as @code{No_Output_Operands}.
5651 @ref{Machine Code Insertions}
5654 @unnumberedsec AST_Entry
5658 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5659 the name of an entry, it yields a value of the predefined type AST_Handler
5660 (declared in the predefined package System, as extended by the use of
5661 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5662 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5663 Language Reference Manual}, section 9.12a.
5668 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5669 offset within the storage unit (byte) that contains the first bit of
5670 storage allocated for the object. The value of this attribute is of the
5671 type @code{Universal_Integer}, and is always a non-negative number not
5672 exceeding the value of @code{System.Storage_Unit}.
5674 For an object that is a variable or a constant allocated in a register,
5675 the value is zero. (The use of this attribute does not force the
5676 allocation of a variable to memory).
5678 For an object that is a formal parameter, this attribute applies
5679 to either the matching actual parameter or to a copy of the
5680 matching actual parameter.
5682 For an access object the value is zero. Note that
5683 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5684 designated object. Similarly for a record component
5685 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5686 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5687 are subject to index checks.
5689 This attribute is designed to be compatible with the DEC Ada 83 definition
5690 and implementation of the @code{Bit} attribute.
5693 @unnumberedsec Bit_Position
5694 @findex Bit_Position
5696 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
5697 of the fields of the record type, yields the bit
5698 offset within the record contains the first bit of
5699 storage allocated for the object. The value of this attribute is of the
5700 type @code{Universal_Integer}. The value depends only on the field
5701 @var{C} and is independent of the alignment of
5702 the containing record @var{R}.
5704 @node Compiler_Version
5705 @unnumberedsec Compiler_Version
5706 @findex Compiler_Version
5708 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5709 prefix) yields a static string identifying the version of the compiler
5710 being used to compile the unit containing the attribute reference. A
5711 typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5714 @unnumberedsec Code_Address
5715 @findex Code_Address
5716 @cindex Subprogram address
5717 @cindex Address of subprogram code
5720 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5721 intended effect seems to be to provide
5722 an address value which can be used to call the subprogram by means of
5723 an address clause as in the following example:
5725 @smallexample @c ada
5726 procedure K is @dots{}
5729 for L'Address use K'Address;
5730 pragma Import (Ada, L);
5734 A call to @code{L} is then expected to result in a call to @code{K}@.
5735 In Ada 83, where there were no access-to-subprogram values, this was
5736 a common work-around for getting the effect of an indirect call.
5737 GNAT implements the above use of @code{Address} and the technique
5738 illustrated by the example code works correctly.
5740 However, for some purposes, it is useful to have the address of the start
5741 of the generated code for the subprogram. On some architectures, this is
5742 not necessarily the same as the @code{Address} value described above.
5743 For example, the @code{Address} value may reference a subprogram
5744 descriptor rather than the subprogram itself.
5746 The @code{'Code_Address} attribute, which can only be applied to
5747 subprogram entities, always returns the address of the start of the
5748 generated code of the specified subprogram, which may or may not be
5749 the same value as is returned by the corresponding @code{'Address}
5752 @node Default_Bit_Order
5753 @unnumberedsec Default_Bit_Order
5755 @cindex Little endian
5756 @findex Default_Bit_Order
5758 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5759 permissible prefix), provides the value @code{System.Default_Bit_Order}
5760 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5761 @code{Low_Order_First}). This is used to construct the definition of
5762 @code{Default_Bit_Order} in package @code{System}.
5765 @unnumberedsec Elaborated
5768 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5769 value is a Boolean which indicates whether or not the given unit has been
5770 elaborated. This attribute is primarily intended for internal use by the
5771 generated code for dynamic elaboration checking, but it can also be used
5772 in user programs. The value will always be True once elaboration of all
5773 units has been completed. An exception is for units which need no
5774 elaboration, the value is always False for such units.
5777 @unnumberedsec Elab_Body
5780 This attribute can only be applied to a program unit name. It returns
5781 the entity for the corresponding elaboration procedure for elaborating
5782 the body of the referenced unit. This is used in the main generated
5783 elaboration procedure by the binder and is not normally used in any
5784 other context. However, there may be specialized situations in which it
5785 is useful to be able to call this elaboration procedure from Ada code,
5786 e.g.@: if it is necessary to do selective re-elaboration to fix some
5790 @unnumberedsec Elab_Spec
5793 This attribute can only be applied to a program unit name. It returns
5794 the entity for the corresponding elaboration procedure for elaborating
5795 the spec of the referenced unit. This is used in the main
5796 generated elaboration procedure by the binder and is not normally used
5797 in any other context. However, there may be specialized situations in
5798 which it is useful to be able to call this elaboration procedure from
5799 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5804 @cindex Ada 83 attributes
5807 The @code{Emax} attribute is provided for compatibility with Ada 83. See
5808 the Ada 83 reference manual for an exact description of the semantics of
5812 @unnumberedsec Enabled
5815 The @code{Enabled} attribute allows an application program to check at compile
5816 time to see if the designated check is currently enabled. The prefix is a
5817 simple identifier, referencing any predefined check name (other than
5818 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5819 no argument is given for the attribute, the check is for the general state
5820 of the check, if an argument is given, then it is an entity name, and the
5821 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5822 given naming the entity (if not, then the argument is ignored).
5824 Note that instantiations inherit the check status at the point of the
5825 instantiation, so a useful idiom is to have a library package that
5826 introduces a check name with @code{pragma Check_Name}, and then contains
5827 generic packages or subprograms which use the @code{Enabled} attribute
5828 to see if the check is enabled. A user of this package can then issue
5829 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5830 the package or subprogram, controlling whether the check will be present.
5833 @unnumberedsec Enum_Rep
5834 @cindex Representation of enums
5837 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5838 function with the following spec:
5840 @smallexample @c ada
5841 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5842 return @i{Universal_Integer};
5846 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5847 enumeration type or to a non-overloaded enumeration
5848 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
5849 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5850 enumeration literal or object.
5852 The function returns the representation value for the given enumeration
5853 value. This will be equal to value of the @code{Pos} attribute in the
5854 absence of an enumeration representation clause. This is a static
5855 attribute (i.e.@: the result is static if the argument is static).
5857 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5858 in which case it simply returns the integer value. The reason for this
5859 is to allow it to be used for @code{(<>)} discrete formal arguments in
5860 a generic unit that can be instantiated with either enumeration types
5861 or integer types. Note that if @code{Enum_Rep} is used on a modular
5862 type whose upper bound exceeds the upper bound of the largest signed
5863 integer type, and the argument is a variable, so that the universal
5864 integer calculation is done at run time, then the call to @code{Enum_Rep}
5865 may raise @code{Constraint_Error}.
5868 @unnumberedsec Enum_Val
5869 @cindex Representation of enums
5872 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
5873 function with the following spec:
5875 @smallexample @c ada
5876 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
5877 return @var{S}'Base};
5881 The function returns the enumeration value whose representation matches the
5882 argument, or raises Constraint_Error if no enumeration literal of the type
5883 has the matching value.
5884 This will be equal to value of the @code{Val} attribute in the
5885 absence of an enumeration representation clause. This is a static
5886 attribute (i.e.@: the result is static if the argument is static).
5889 @unnumberedsec Epsilon
5890 @cindex Ada 83 attributes
5893 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
5894 the Ada 83 reference manual for an exact description of the semantics of
5898 @unnumberedsec Fixed_Value
5901 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5902 function with the following specification:
5904 @smallexample @c ada
5905 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5910 The value returned is the fixed-point value @var{V} such that
5912 @smallexample @c ada
5913 @var{V} = Arg * @var{S}'Small
5917 The effect is thus similar to first converting the argument to the
5918 integer type used to represent @var{S}, and then doing an unchecked
5919 conversion to the fixed-point type. The difference is
5920 that there are full range checks, to ensure that the result is in range.
5921 This attribute is primarily intended for use in implementation of the
5922 input-output functions for fixed-point values.
5924 @node Has_Access_Values
5925 @unnumberedsec Has_Access_Values
5926 @cindex Access values, testing for
5927 @findex Has_Access_Values
5929 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5930 is a Boolean value which is True if the is an access type, or is a composite
5931 type with a component (at any nesting depth) that is an access type, and is
5933 The intended use of this attribute is in conjunction with generic
5934 definitions. If the attribute is applied to a generic private type, it
5935 indicates whether or not the corresponding actual type has access values.
5937 @node Has_Discriminants
5938 @unnumberedsec Has_Discriminants
5939 @cindex Discriminants, testing for
5940 @findex Has_Discriminants
5942 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5943 is a Boolean value which is True if the type has discriminants, and False
5944 otherwise. The intended use of this attribute is in conjunction with generic
5945 definitions. If the attribute is applied to a generic private type, it
5946 indicates whether or not the corresponding actual type has discriminants.
5952 The @code{Img} attribute differs from @code{Image} in that it may be
5953 applied to objects as well as types, in which case it gives the
5954 @code{Image} for the subtype of the object. This is convenient for
5957 @smallexample @c ada
5958 Put_Line ("X = " & X'Img);
5962 has the same meaning as the more verbose:
5964 @smallexample @c ada
5965 Put_Line ("X = " & @var{T}'Image (X));
5969 where @var{T} is the (sub)type of the object @code{X}.
5972 @unnumberedsec Integer_Value
5973 @findex Integer_Value
5975 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5976 function with the following spec:
5978 @smallexample @c ada
5979 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5984 The value returned is the integer value @var{V}, such that
5986 @smallexample @c ada
5987 Arg = @var{V} * @var{T}'Small
5991 where @var{T} is the type of @code{Arg}.
5992 The effect is thus similar to first doing an unchecked conversion from
5993 the fixed-point type to its corresponding implementation type, and then
5994 converting the result to the target integer type. The difference is
5995 that there are full range checks, to ensure that the result is in range.
5996 This attribute is primarily intended for use in implementation of the
5997 standard input-output functions for fixed-point values.
6000 @unnumberedsec Invalid_Value
6001 @findex Invalid_Value
6003 For every scalar type S, S'Invalid_Value returns an undefined value of the
6004 type. If possible this value is an invalid representation for the type. The
6005 value returned is identical to the value used to initialize an otherwise
6006 uninitialized value of the type if pragma Initialize_Scalars is used,
6007 including the ability to modify the value with the binder -Sxx flag and
6008 relevant environment variables at run time.
6011 @unnumberedsec Large
6012 @cindex Ada 83 attributes
6015 The @code{Large} attribute is provided for compatibility with Ada 83. See
6016 the Ada 83 reference manual for an exact description of the semantics of
6020 @unnumberedsec Machine_Size
6021 @findex Machine_Size
6023 This attribute is identical to the @code{Object_Size} attribute. It is
6024 provided for compatibility with the DEC Ada 83 attribute of this name.
6027 @unnumberedsec Mantissa
6028 @cindex Ada 83 attributes
6031 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6032 the Ada 83 reference manual for an exact description of the semantics of
6035 @node Max_Interrupt_Priority
6036 @unnumberedsec Max_Interrupt_Priority
6037 @cindex Interrupt priority, maximum
6038 @findex Max_Interrupt_Priority
6040 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6041 permissible prefix), provides the same value as
6042 @code{System.Max_Interrupt_Priority}.
6045 @unnumberedsec Max_Priority
6046 @cindex Priority, maximum
6047 @findex Max_Priority
6049 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6050 prefix) provides the same value as @code{System.Max_Priority}.
6052 @node Maximum_Alignment
6053 @unnumberedsec Maximum_Alignment
6054 @cindex Alignment, maximum
6055 @findex Maximum_Alignment
6057 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6058 permissible prefix) provides the maximum useful alignment value for the
6059 target. This is a static value that can be used to specify the alignment
6060 for an object, guaranteeing that it is properly aligned in all
6063 @node Mechanism_Code
6064 @unnumberedsec Mechanism_Code
6065 @cindex Return values, passing mechanism
6066 @cindex Parameters, passing mechanism
6067 @findex Mechanism_Code
6069 @code{@var{function}'Mechanism_Code} yields an integer code for the
6070 mechanism used for the result of function, and
6071 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6072 used for formal parameter number @var{n} (a static integer value with 1
6073 meaning the first parameter) of @var{subprogram}. The code returned is:
6081 by descriptor (default descriptor class)
6083 by descriptor (UBS: unaligned bit string)
6085 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6087 by descriptor (UBA: unaligned bit array)
6089 by descriptor (S: string, also scalar access type parameter)
6091 by descriptor (SB: string with arbitrary bounds)
6093 by descriptor (A: contiguous array)
6095 by descriptor (NCA: non-contiguous array)
6099 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6102 @node Null_Parameter
6103 @unnumberedsec Null_Parameter
6104 @cindex Zero address, passing
6105 @findex Null_Parameter
6107 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6108 type or subtype @var{T} allocated at machine address zero. The attribute
6109 is allowed only as the default expression of a formal parameter, or as
6110 an actual expression of a subprogram call. In either case, the
6111 subprogram must be imported.
6113 The identity of the object is represented by the address zero in the
6114 argument list, independent of the passing mechanism (explicit or
6117 This capability is needed to specify that a zero address should be
6118 passed for a record or other composite object passed by reference.
6119 There is no way of indicating this without the @code{Null_Parameter}
6123 @unnumberedsec Object_Size
6124 @cindex Size, used for objects
6127 The size of an object is not necessarily the same as the size of the type
6128 of an object. This is because by default object sizes are increased to be
6129 a multiple of the alignment of the object. For example,
6130 @code{Natural'Size} is
6131 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6132 Similarly, a record containing an integer and a character:
6134 @smallexample @c ada
6142 will have a size of 40 (that is @code{Rec'Size} will be 40). The
6143 alignment will be 4, because of the
6144 integer field, and so the default size of record objects for this type
6145 will be 64 (8 bytes).
6149 @cindex Capturing Old values
6150 @cindex Postconditions
6152 The attribute Prefix'Old can be used within a
6153 subprogram body or within a precondition or
6154 postcondition pragma. The effect is to
6155 refer to the value of the prefix on entry. So for
6156 example if you have an argument of a record type X called Arg1,
6157 you can refer to Arg1.Field'Old which yields the value of
6158 Arg1.Field on entry. The implementation simply involves generating
6159 an object declaration which captures the value on entry. Any
6160 prefix is allowed except one of a limited type (since limited
6161 types cannot be copied to capture their values) or an expression
6162 which references a local variable
6163 (since local variables do not exist at subprogram entry time).
6165 The following example shows the use of 'Old to implement
6166 a test of a postcondition:
6168 @smallexample @c ada
6179 package body Old_Pkg is
6180 Count : Natural := 0;
6184 ... code manipulating the value of Count
6186 pragma Assert (Count = Count'Old + 1);
6192 Note that it is allowed to apply 'Old to a constant entity, but this will
6193 result in a warning, since the old and new values will always be the same.
6195 @node Passed_By_Reference
6196 @unnumberedsec Passed_By_Reference
6197 @cindex Parameters, when passed by reference
6198 @findex Passed_By_Reference
6200 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6201 a value of type @code{Boolean} value that is @code{True} if the type is
6202 normally passed by reference and @code{False} if the type is normally
6203 passed by copy in calls. For scalar types, the result is always @code{False}
6204 and is static. For non-scalar types, the result is non-static.
6207 @unnumberedsec Pool_Address
6208 @cindex Parameters, when passed by reference
6209 @findex Pool_Address
6211 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6212 of X within its storage pool. This is the same as
6213 @code{@var{X}'Address}, except that for an unconstrained array whose
6214 bounds are allocated just before the first component,
6215 @code{@var{X}'Pool_Address} returns the address of those bounds,
6216 whereas @code{@var{X}'Address} returns the address of the first
6219 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6220 the object is allocated'', which could be a user-defined storage pool,
6221 the global heap, on the stack, or in a static memory area. For an
6222 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6223 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6226 @unnumberedsec Range_Length
6227 @findex Range_Length
6229 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6230 the number of values represented by the subtype (zero for a null
6231 range). The result is static for static subtypes. @code{Range_Length}
6232 applied to the index subtype of a one dimensional array always gives the
6233 same result as @code{Range} applied to the array itself.
6239 The @code{System.Address'Ref}
6240 (@code{System.Address} is the only permissible prefix)
6241 denotes a function identical to
6242 @code{System.Storage_Elements.To_Address} except that
6243 it is a static attribute. See @ref{To_Address} for more details.
6246 @unnumberedsec Result
6249 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6250 for a function. The prefix must be the name of the corresponding function. This
6251 is used to refer to the result of the function in the postcondition expression.
6252 For a further discussion of the use of this attribute and examples of its use,
6253 see the description of pragma Postcondition.
6256 @unnumberedsec Safe_Emax
6257 @cindex Ada 83 attributes
6260 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6261 the Ada 83 reference manual for an exact description of the semantics of
6265 @unnumberedsec Safe_Large
6266 @cindex Ada 83 attributes
6269 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6270 the Ada 83 reference manual for an exact description of the semantics of
6274 @unnumberedsec Small
6275 @cindex Ada 83 attributes
6278 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6280 GNAT also allows this attribute to be applied to floating-point types
6281 for compatibility with Ada 83. See
6282 the Ada 83 reference manual for an exact description of the semantics of
6283 this attribute when applied to floating-point types.
6286 @unnumberedsec Storage_Unit
6287 @findex Storage_Unit
6289 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6290 prefix) provides the same value as @code{System.Storage_Unit}.
6293 @unnumberedsec Stub_Type
6296 The GNAT implementation of remote access-to-classwide types is
6297 organized as described in AARM section E.4 (20.t): a value of an RACW type
6298 (designating a remote object) is represented as a normal access
6299 value, pointing to a "stub" object which in turn contains the
6300 necessary information to contact the designated remote object. A
6301 call on any dispatching operation of such a stub object does the
6302 remote call, if necessary, using the information in the stub object
6303 to locate the target partition, etc.
6305 For a prefix @code{T} that denotes a remote access-to-classwide type,
6306 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6308 By construction, the layout of @code{T'Stub_Type} is identical to that of
6309 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6310 unit @code{System.Partition_Interface}. Use of this attribute will create
6311 an implicit dependency on this unit.
6314 @unnumberedsec Target_Name
6317 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6318 prefix) provides a static string value that identifies the target
6319 for the current compilation. For GCC implementations, this is the
6320 standard gcc target name without the terminating slash (for
6321 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6327 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6328 provides the same value as @code{System.Tick},
6331 @unnumberedsec To_Address
6334 The @code{System'To_Address}
6335 (@code{System} is the only permissible prefix)
6336 denotes a function identical to
6337 @code{System.Storage_Elements.To_Address} except that
6338 it is a static attribute. This means that if its argument is
6339 a static expression, then the result of the attribute is a
6340 static expression. The result is that such an expression can be
6341 used in contexts (e.g.@: preelaborable packages) which require a
6342 static expression and where the function call could not be used
6343 (since the function call is always non-static, even if its
6344 argument is static).
6347 @unnumberedsec Type_Class
6350 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6351 the value of the type class for the full type of @var{type}. If
6352 @var{type} is a generic formal type, the value is the value for the
6353 corresponding actual subtype. The value of this attribute is of type
6354 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6356 @smallexample @c ada
6358 (Type_Class_Enumeration,
6360 Type_Class_Fixed_Point,
6361 Type_Class_Floating_Point,
6366 Type_Class_Address);
6370 Protected types yield the value @code{Type_Class_Task}, which thus
6371 applies to all concurrent types. This attribute is designed to
6372 be compatible with the DEC Ada 83 attribute of the same name.
6375 @unnumberedsec UET_Address
6378 The @code{UET_Address} attribute can only be used for a prefix which
6379 denotes a library package. It yields the address of the unit exception
6380 table when zero cost exception handling is used. This attribute is
6381 intended only for use within the GNAT implementation. See the unit
6382 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6383 for details on how this attribute is used in the implementation.
6385 @node Unconstrained_Array
6386 @unnumberedsec Unconstrained_Array
6387 @findex Unconstrained_Array
6389 The @code{Unconstrained_Array} attribute can be used with a prefix that
6390 denotes any type or subtype. It is a static attribute that yields
6391 @code{True} if the prefix designates an unconstrained array,
6392 and @code{False} otherwise. In a generic instance, the result is
6393 still static, and yields the result of applying this test to the
6396 @node Universal_Literal_String
6397 @unnumberedsec Universal_Literal_String
6398 @cindex Named numbers, representation of
6399 @findex Universal_Literal_String
6401 The prefix of @code{Universal_Literal_String} must be a named
6402 number. The static result is the string consisting of the characters of
6403 the number as defined in the original source. This allows the user
6404 program to access the actual text of named numbers without intermediate
6405 conversions and without the need to enclose the strings in quotes (which
6406 would preclude their use as numbers).
6408 For example, the following program prints the first 50 digits of pi:
6410 @smallexample @c ada
6411 with Text_IO; use Text_IO;
6415 Put (Ada.Numerics.Pi'Universal_Literal_String);
6419 @node Unrestricted_Access
6420 @unnumberedsec Unrestricted_Access
6421 @cindex @code{Access}, unrestricted
6422 @findex Unrestricted_Access
6424 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6425 except that all accessibility and aliased view checks are omitted. This
6426 is a user-beware attribute. It is similar to
6427 @code{Address}, for which it is a desirable replacement where the value
6428 desired is an access type. In other words, its effect is identical to
6429 first applying the @code{Address} attribute and then doing an unchecked
6430 conversion to a desired access type. In GNAT, but not necessarily in
6431 other implementations, the use of static chains for inner level
6432 subprograms means that @code{Unrestricted_Access} applied to a
6433 subprogram yields a value that can be called as long as the subprogram
6434 is in scope (normal Ada accessibility rules restrict this usage).
6436 It is possible to use @code{Unrestricted_Access} for any type, but care
6437 must be exercised if it is used to create pointers to unconstrained
6438 objects. In this case, the resulting pointer has the same scope as the
6439 context of the attribute, and may not be returned to some enclosing
6440 scope. For instance, a function cannot use @code{Unrestricted_Access}
6441 to create a unconstrained pointer and then return that value to the
6445 @unnumberedsec VADS_Size
6446 @cindex @code{Size}, VADS compatibility
6449 The @code{'VADS_Size} attribute is intended to make it easier to port
6450 legacy code which relies on the semantics of @code{'Size} as implemented
6451 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6452 same semantic interpretation. In particular, @code{'VADS_Size} applied
6453 to a predefined or other primitive type with no Size clause yields the
6454 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6455 typical machines). In addition @code{'VADS_Size} applied to an object
6456 gives the result that would be obtained by applying the attribute to
6457 the corresponding type.
6460 @unnumberedsec Value_Size
6461 @cindex @code{Size}, setting for not-first subtype
6463 @code{@var{type}'Value_Size} is the number of bits required to represent
6464 a value of the given subtype. It is the same as @code{@var{type}'Size},
6465 but, unlike @code{Size}, may be set for non-first subtypes.
6468 @unnumberedsec Wchar_T_Size
6469 @findex Wchar_T_Size
6470 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6471 prefix) provides the size in bits of the C @code{wchar_t} type
6472 primarily for constructing the definition of this type in
6473 package @code{Interfaces.C}.
6476 @unnumberedsec Word_Size
6478 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6479 prefix) provides the value @code{System.Word_Size}.
6481 @c ------------------------
6482 @node Implementation Advice
6483 @chapter Implementation Advice
6485 The main text of the Ada Reference Manual describes the required
6486 behavior of all Ada compilers, and the GNAT compiler conforms to
6489 In addition, there are sections throughout the Ada Reference Manual headed
6490 by the phrase ``Implementation advice''. These sections are not normative,
6491 i.e., they do not specify requirements that all compilers must
6492 follow. Rather they provide advice on generally desirable behavior. You
6493 may wonder why they are not requirements. The most typical answer is
6494 that they describe behavior that seems generally desirable, but cannot
6495 be provided on all systems, or which may be undesirable on some systems.
6497 As far as practical, GNAT follows the implementation advice sections in
6498 the Ada Reference Manual. This chapter contains a table giving the
6499 reference manual section number, paragraph number and several keywords
6500 for each advice. Each entry consists of the text of the advice followed
6501 by the GNAT interpretation of this advice. Most often, this simply says
6502 ``followed'', which means that GNAT follows the advice. However, in a
6503 number of cases, GNAT deliberately deviates from this advice, in which
6504 case the text describes what GNAT does and why.
6506 @cindex Error detection
6507 @unnumberedsec 1.1.3(20): Error Detection
6510 If an implementation detects the use of an unsupported Specialized Needs
6511 Annex feature at run time, it should raise @code{Program_Error} if
6514 Not relevant. All specialized needs annex features are either supported,
6515 or diagnosed at compile time.
6518 @unnumberedsec 1.1.3(31): Child Units
6521 If an implementation wishes to provide implementation-defined
6522 extensions to the functionality of a language-defined library unit, it
6523 should normally do so by adding children to the library unit.
6527 @cindex Bounded errors
6528 @unnumberedsec 1.1.5(12): Bounded Errors
6531 If an implementation detects a bounded error or erroneous
6532 execution, it should raise @code{Program_Error}.
6534 Followed in all cases in which the implementation detects a bounded
6535 error or erroneous execution. Not all such situations are detected at
6539 @unnumberedsec 2.8(16): Pragmas
6542 Normally, implementation-defined pragmas should have no semantic effect
6543 for error-free programs; that is, if the implementation-defined pragmas
6544 are removed from a working program, the program should still be legal,
6545 and should still have the same semantics.
6547 The following implementation defined pragmas are exceptions to this
6559 @item CPP_Constructor
6563 @item Interface_Name
6565 @item Machine_Attribute
6567 @item Unimplemented_Unit
6569 @item Unchecked_Union
6574 In each of the above cases, it is essential to the purpose of the pragma
6575 that this advice not be followed. For details see the separate section
6576 on implementation defined pragmas.
6578 @unnumberedsec 2.8(17-19): Pragmas
6581 Normally, an implementation should not define pragmas that can
6582 make an illegal program legal, except as follows:
6586 A pragma used to complete a declaration, such as a pragma @code{Import};
6590 A pragma used to configure the environment by adding, removing, or
6591 replacing @code{library_items}.
6593 See response to paragraph 16 of this same section.
6595 @cindex Character Sets
6596 @cindex Alternative Character Sets
6597 @unnumberedsec 3.5.2(5): Alternative Character Sets
6600 If an implementation supports a mode with alternative interpretations
6601 for @code{Character} and @code{Wide_Character}, the set of graphic
6602 characters of @code{Character} should nevertheless remain a proper
6603 subset of the set of graphic characters of @code{Wide_Character}. Any
6604 character set ``localizations'' should be reflected in the results of
6605 the subprograms defined in the language-defined package
6606 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6607 an alternative interpretation of @code{Character}, the implementation should
6608 also support a corresponding change in what is a legal
6609 @code{identifier_letter}.
6611 Not all wide character modes follow this advice, in particular the JIS
6612 and IEC modes reflect standard usage in Japan, and in these encoding,
6613 the upper half of the Latin-1 set is not part of the wide-character
6614 subset, since the most significant bit is used for wide character
6615 encoding. However, this only applies to the external forms. Internally
6616 there is no such restriction.
6618 @cindex Integer types
6619 @unnumberedsec 3.5.4(28): Integer Types
6623 An implementation should support @code{Long_Integer} in addition to
6624 @code{Integer} if the target machine supports 32-bit (or longer)
6625 arithmetic. No other named integer subtypes are recommended for package
6626 @code{Standard}. Instead, appropriate named integer subtypes should be
6627 provided in the library package @code{Interfaces} (see B.2).
6629 @code{Long_Integer} is supported. Other standard integer types are supported
6630 so this advice is not fully followed. These types
6631 are supported for convenient interface to C, and so that all hardware
6632 types of the machine are easily available.
6633 @unnumberedsec 3.5.4(29): Integer Types
6637 An implementation for a two's complement machine should support
6638 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6639 implementation should support a non-binary modules up to @code{Integer'Last}.
6643 @cindex Enumeration values
6644 @unnumberedsec 3.5.5(8): Enumeration Values
6647 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6648 subtype, if the value of the operand does not correspond to the internal
6649 code for any enumeration literal of its type (perhaps due to an
6650 un-initialized variable), then the implementation should raise
6651 @code{Program_Error}. This is particularly important for enumeration
6652 types with noncontiguous internal codes specified by an
6653 enumeration_representation_clause.
6658 @unnumberedsec 3.5.7(17): Float Types
6661 An implementation should support @code{Long_Float} in addition to
6662 @code{Float} if the target machine supports 11 or more digits of
6663 precision. No other named floating point subtypes are recommended for
6664 package @code{Standard}. Instead, appropriate named floating point subtypes
6665 should be provided in the library package @code{Interfaces} (see B.2).
6667 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6668 former provides improved compatibility with other implementations
6669 supporting this type. The latter corresponds to the highest precision
6670 floating-point type supported by the hardware. On most machines, this
6671 will be the same as @code{Long_Float}, but on some machines, it will
6672 correspond to the IEEE extended form. The notable case is all ia32
6673 (x86) implementations, where @code{Long_Long_Float} corresponds to
6674 the 80-bit extended precision format supported in hardware on this
6675 processor. Note that the 128-bit format on SPARC is not supported,
6676 since this is a software rather than a hardware format.
6678 @cindex Multidimensional arrays
6679 @cindex Arrays, multidimensional
6680 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6683 An implementation should normally represent multidimensional arrays in
6684 row-major order, consistent with the notation used for multidimensional
6685 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6686 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6687 column-major order should be used instead (see B.5, ``Interfacing with
6692 @findex Duration'Small
6693 @unnumberedsec 9.6(30-31): Duration'Small
6696 Whenever possible in an implementation, the value of @code{Duration'Small}
6697 should be no greater than 100 microseconds.
6699 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6703 The time base for @code{delay_relative_statements} should be monotonic;
6704 it need not be the same time base as used for @code{Calendar.Clock}.
6708 @unnumberedsec 10.2.1(12): Consistent Representation
6711 In an implementation, a type declared in a pre-elaborated package should
6712 have the same representation in every elaboration of a given version of
6713 the package, whether the elaborations occur in distinct executions of
6714 the same program, or in executions of distinct programs or partitions
6715 that include the given version.
6717 Followed, except in the case of tagged types. Tagged types involve
6718 implicit pointers to a local copy of a dispatch table, and these pointers
6719 have representations which thus depend on a particular elaboration of the
6720 package. It is not easy to see how it would be possible to follow this
6721 advice without severely impacting efficiency of execution.
6723 @cindex Exception information
6724 @unnumberedsec 11.4.1(19): Exception Information
6727 @code{Exception_Message} by default and @code{Exception_Information}
6728 should produce information useful for
6729 debugging. @code{Exception_Message} should be short, about one
6730 line. @code{Exception_Information} can be long. @code{Exception_Message}
6731 should not include the
6732 @code{Exception_Name}. @code{Exception_Information} should include both
6733 the @code{Exception_Name} and the @code{Exception_Message}.
6735 Followed. For each exception that doesn't have a specified
6736 @code{Exception_Message}, the compiler generates one containing the location
6737 of the raise statement. This location has the form ``file:line'', where
6738 file is the short file name (without path information) and line is the line
6739 number in the file. Note that in the case of the Zero Cost Exception
6740 mechanism, these messages become redundant with the Exception_Information that
6741 contains a full backtrace of the calling sequence, so they are disabled.
6742 To disable explicitly the generation of the source location message, use the
6743 Pragma @code{Discard_Names}.
6745 @cindex Suppression of checks
6746 @cindex Checks, suppression of
6747 @unnumberedsec 11.5(28): Suppression of Checks
6750 The implementation should minimize the code executed for checks that
6751 have been suppressed.
6755 @cindex Representation clauses
6756 @unnumberedsec 13.1 (21-24): Representation Clauses
6759 The recommended level of support for all representation items is
6760 qualified as follows:
6764 An implementation need not support representation items containing
6765 non-static expressions, except that an implementation should support a
6766 representation item for a given entity if each non-static expression in
6767 the representation item is a name that statically denotes a constant
6768 declared before the entity.
6770 Followed. In fact, GNAT goes beyond the recommended level of support
6771 by allowing nonstatic expressions in some representation clauses even
6772 without the need to declare constants initialized with the values of
6776 @smallexample @c ada
6779 for Y'Address use X'Address;>>
6784 An implementation need not support a specification for the @code{Size}
6785 for a given composite subtype, nor the size or storage place for an
6786 object (including a component) of a given composite subtype, unless the
6787 constraints on the subtype and its composite subcomponents (if any) are
6788 all static constraints.
6790 Followed. Size Clauses are not permitted on non-static components, as
6795 An aliased component, or a component whose type is by-reference, should
6796 always be allocated at an addressable location.
6800 @cindex Packed types
6801 @unnumberedsec 13.2(6-8): Packed Types
6804 If a type is packed, then the implementation should try to minimize
6805 storage allocated to objects of the type, possibly at the expense of
6806 speed of accessing components, subject to reasonable complexity in
6807 addressing calculations.
6811 The recommended level of support pragma @code{Pack} is:
6813 For a packed record type, the components should be packed as tightly as
6814 possible subject to the Sizes of the component subtypes, and subject to
6815 any @code{record_representation_clause} that applies to the type; the
6816 implementation may, but need not, reorder components or cross aligned
6817 word boundaries to improve the packing. A component whose @code{Size} is
6818 greater than the word size may be allocated an integral number of words.
6820 Followed. Tight packing of arrays is supported for all component sizes
6821 up to 64-bits. If the array component size is 1 (that is to say, if
6822 the component is a boolean type or an enumeration type with two values)
6823 then values of the type are implicitly initialized to zero. This
6824 happens both for objects of the packed type, and for objects that have a
6825 subcomponent of the packed type.
6829 An implementation should support Address clauses for imported
6833 @cindex @code{Address} clauses
6834 @unnumberedsec 13.3(14-19): Address Clauses
6838 For an array @var{X}, @code{@var{X}'Address} should point at the first
6839 component of the array, and not at the array bounds.
6845 The recommended level of support for the @code{Address} attribute is:
6847 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6848 object that is aliased or of a by-reference type, or is an entity whose
6849 @code{Address} has been specified.
6851 Followed. A valid address will be produced even if none of those
6852 conditions have been met. If necessary, the object is forced into
6853 memory to ensure the address is valid.
6857 An implementation should support @code{Address} clauses for imported
6864 Objects (including subcomponents) that are aliased or of a by-reference
6865 type should be allocated on storage element boundaries.
6871 If the @code{Address} of an object is specified, or it is imported or exported,
6872 then the implementation should not perform optimizations based on
6873 assumptions of no aliases.
6877 @cindex @code{Alignment} clauses
6878 @unnumberedsec 13.3(29-35): Alignment Clauses
6881 The recommended level of support for the @code{Alignment} attribute for
6884 An implementation should support specified Alignments that are factors
6885 and multiples of the number of storage elements per word, subject to the
6892 An implementation need not support specified @code{Alignment}s for
6893 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6894 loaded and stored by available machine instructions.
6900 An implementation need not support specified @code{Alignment}s that are
6901 greater than the maximum @code{Alignment} the implementation ever returns by
6908 The recommended level of support for the @code{Alignment} attribute for
6911 Same as above, for subtypes, but in addition:
6917 For stand-alone library-level objects of statically constrained
6918 subtypes, the implementation should support all @code{Alignment}s
6919 supported by the target linker. For example, page alignment is likely to
6920 be supported for such objects, but not for subtypes.
6924 @cindex @code{Size} clauses
6925 @unnumberedsec 13.3(42-43): Size Clauses
6928 The recommended level of support for the @code{Size} attribute of
6931 A @code{Size} clause should be supported for an object if the specified
6932 @code{Size} is at least as large as its subtype's @code{Size}, and
6933 corresponds to a size in storage elements that is a multiple of the
6934 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6938 @unnumberedsec 13.3(50-56): Size Clauses
6941 If the @code{Size} of a subtype is specified, and allows for efficient
6942 independent addressability (see 9.10) on the target architecture, then
6943 the @code{Size} of the following objects of the subtype should equal the
6944 @code{Size} of the subtype:
6946 Aliased objects (including components).
6952 @code{Size} clause on a composite subtype should not affect the
6953 internal layout of components.
6955 Followed. But note that this can be overridden by use of the implementation
6956 pragma Implicit_Packing in the case of packed arrays.
6960 The recommended level of support for the @code{Size} attribute of subtypes is:
6964 The @code{Size} (if not specified) of a static discrete or fixed point
6965 subtype should be the number of bits needed to represent each value
6966 belonging to the subtype using an unbiased representation, leaving space
6967 for a sign bit only if the subtype contains negative values. If such a
6968 subtype is a first subtype, then an implementation should support a
6969 specified @code{Size} for it that reflects this representation.
6975 For a subtype implemented with levels of indirection, the @code{Size}
6976 should include the size of the pointers, but not the size of what they
6981 @cindex @code{Component_Size} clauses
6982 @unnumberedsec 13.3(71-73): Component Size Clauses
6985 The recommended level of support for the @code{Component_Size}
6990 An implementation need not support specified @code{Component_Sizes} that are
6991 less than the @code{Size} of the component subtype.
6997 An implementation should support specified @code{Component_Size}s that
6998 are factors and multiples of the word size. For such
6999 @code{Component_Size}s, the array should contain no gaps between
7000 components. For other @code{Component_Size}s (if supported), the array
7001 should contain no gaps between components when packing is also
7002 specified; the implementation should forbid this combination in cases
7003 where it cannot support a no-gaps representation.
7007 @cindex Enumeration representation clauses
7008 @cindex Representation clauses, enumeration
7009 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
7012 The recommended level of support for enumeration representation clauses
7015 An implementation need not support enumeration representation clauses
7016 for boolean types, but should at minimum support the internal codes in
7017 the range @code{System.Min_Int.System.Max_Int}.
7021 @cindex Record representation clauses
7022 @cindex Representation clauses, records
7023 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
7026 The recommended level of support for
7027 @*@code{record_representation_clauses} is:
7029 An implementation should support storage places that can be extracted
7030 with a load, mask, shift sequence of machine code, and set with a load,
7031 shift, mask, store sequence, given the available machine instructions
7038 A storage place should be supported if its size is equal to the
7039 @code{Size} of the component subtype, and it starts and ends on a
7040 boundary that obeys the @code{Alignment} of the component subtype.
7046 If the default bit ordering applies to the declaration of a given type,
7047 then for a component whose subtype's @code{Size} is less than the word
7048 size, any storage place that does not cross an aligned word boundary
7049 should be supported.
7055 An implementation may reserve a storage place for the tag field of a
7056 tagged type, and disallow other components from overlapping that place.
7058 Followed. The storage place for the tag field is the beginning of the tagged
7059 record, and its size is Address'Size. GNAT will reject an explicit component
7060 clause for the tag field.
7064 An implementation need not support a @code{component_clause} for a
7065 component of an extension part if the storage place is not after the
7066 storage places of all components of the parent type, whether or not
7067 those storage places had been specified.
7069 Followed. The above advice on record representation clauses is followed,
7070 and all mentioned features are implemented.
7072 @cindex Storage place attributes
7073 @unnumberedsec 13.5.2(5): Storage Place Attributes
7076 If a component is represented using some form of pointer (such as an
7077 offset) to the actual data of the component, and this data is contiguous
7078 with the rest of the object, then the storage place attributes should
7079 reflect the place of the actual data, not the pointer. If a component is
7080 allocated discontinuously from the rest of the object, then a warning
7081 should be generated upon reference to one of its storage place
7084 Followed. There are no such components in GNAT@.
7086 @cindex Bit ordering
7087 @unnumberedsec 13.5.3(7-8): Bit Ordering
7090 The recommended level of support for the non-default bit ordering is:
7094 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
7095 should support the non-default bit ordering in addition to the default
7098 Followed. Word size does not equal storage size in this implementation.
7099 Thus non-default bit ordering is not supported.
7101 @cindex @code{Address}, as private type
7102 @unnumberedsec 13.7(37): Address as Private
7105 @code{Address} should be of a private type.
7109 @cindex Operations, on @code{Address}
7110 @cindex @code{Address}, operations of
7111 @unnumberedsec 13.7.1(16): Address Operations
7114 Operations in @code{System} and its children should reflect the target
7115 environment semantics as closely as is reasonable. For example, on most
7116 machines, it makes sense for address arithmetic to ``wrap around''.
7117 Operations that do not make sense should raise @code{Program_Error}.
7119 Followed. Address arithmetic is modular arithmetic that wraps around. No
7120 operation raises @code{Program_Error}, since all operations make sense.
7122 @cindex Unchecked conversion
7123 @unnumberedsec 13.9(14-17): Unchecked Conversion
7126 The @code{Size} of an array object should not include its bounds; hence,
7127 the bounds should not be part of the converted data.
7133 The implementation should not generate unnecessary run-time checks to
7134 ensure that the representation of @var{S} is a representation of the
7135 target type. It should take advantage of the permission to return by
7136 reference when possible. Restrictions on unchecked conversions should be
7137 avoided unless required by the target environment.
7139 Followed. There are no restrictions on unchecked conversion. A warning is
7140 generated if the source and target types do not have the same size since
7141 the semantics in this case may be target dependent.
7145 The recommended level of support for unchecked conversions is:
7149 Unchecked conversions should be supported and should be reversible in
7150 the cases where this clause defines the result. To enable meaningful use
7151 of unchecked conversion, a contiguous representation should be used for
7152 elementary subtypes, for statically constrained array subtypes whose
7153 component subtype is one of the subtypes described in this paragraph,
7154 and for record subtypes without discriminants whose component subtypes
7155 are described in this paragraph.
7159 @cindex Heap usage, implicit
7160 @unnumberedsec 13.11(23-25): Implicit Heap Usage
7163 An implementation should document any cases in which it dynamically
7164 allocates heap storage for a purpose other than the evaluation of an
7167 Followed, the only other points at which heap storage is dynamically
7168 allocated are as follows:
7172 At initial elaboration time, to allocate dynamically sized global
7176 To allocate space for a task when a task is created.
7179 To extend the secondary stack dynamically when needed. The secondary
7180 stack is used for returning variable length results.
7185 A default (implementation-provided) storage pool for an
7186 access-to-constant type should not have overhead to support deallocation of
7193 A storage pool for an anonymous access type should be created at the
7194 point of an allocator for the type, and be reclaimed when the designated
7195 object becomes inaccessible.
7199 @cindex Unchecked deallocation
7200 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7203 For a standard storage pool, @code{Free} should actually reclaim the
7208 @cindex Stream oriented attributes
7209 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7212 If a stream element is the same size as a storage element, then the
7213 normal in-memory representation should be used by @code{Read} and
7214 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
7215 should use the smallest number of stream elements needed to represent
7216 all values in the base range of the scalar type.
7219 Followed. By default, GNAT uses the interpretation suggested by AI-195,
7220 which specifies using the size of the first subtype.
7221 However, such an implementation is based on direct binary
7222 representations and is therefore target- and endianness-dependent.
7223 To address this issue, GNAT also supplies an alternate implementation
7224 of the stream attributes @code{Read} and @code{Write},
7225 which uses the target-independent XDR standard representation
7227 @cindex XDR representation
7228 @cindex @code{Read} attribute
7229 @cindex @code{Write} attribute
7230 @cindex Stream oriented attributes
7231 The XDR implementation is provided as an alternative body of the
7232 @code{System.Stream_Attributes} package, in the file
7233 @file{s-stratt-xdr.adb} in the GNAT library.
7234 There is no @file{s-stratt-xdr.ads} file.
7235 In order to install the XDR implementation, do the following:
7237 @item Replace the default implementation of the
7238 @code{System.Stream_Attributes} package with the XDR implementation.
7239 For example on a Unix platform issue the commands:
7241 $ mv s-stratt.adb s-stratt-default.adb
7242 $ mv s-stratt-xdr.adb s-stratt.adb
7246 Rebuild the GNAT run-time library as documented in
7247 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7250 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7253 If an implementation provides additional named predefined integer types,
7254 then the names should end with @samp{Integer} as in
7255 @samp{Long_Integer}. If an implementation provides additional named
7256 predefined floating point types, then the names should end with
7257 @samp{Float} as in @samp{Long_Float}.
7261 @findex Ada.Characters.Handling
7262 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7265 If an implementation provides a localized definition of @code{Character}
7266 or @code{Wide_Character}, then the effects of the subprograms in
7267 @code{Characters.Handling} should reflect the localizations. See also
7270 Followed. GNAT provides no such localized definitions.
7272 @cindex Bounded-length strings
7273 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7276 Bounded string objects should not be implemented by implicit pointers
7277 and dynamic allocation.
7279 Followed. No implicit pointers or dynamic allocation are used.
7281 @cindex Random number generation
7282 @unnumberedsec A.5.2(46-47): Random Number Generation
7285 Any storage associated with an object of type @code{Generator} should be
7286 reclaimed on exit from the scope of the object.
7292 If the generator period is sufficiently long in relation to the number
7293 of distinct initiator values, then each possible value of
7294 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7295 random numbers that does not, in a practical sense, overlap the sequence
7296 initiated by any other value. If this is not possible, then the mapping
7297 between initiator values and generator states should be a rapidly
7298 varying function of the initiator value.
7300 Followed. The generator period is sufficiently long for the first
7301 condition here to hold true.
7303 @findex Get_Immediate
7304 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7307 The @code{Get_Immediate} procedures should be implemented with
7308 unbuffered input. For a device such as a keyboard, input should be
7309 @dfn{available} if a key has already been typed, whereas for a disk
7310 file, input should always be available except at end of file. For a file
7311 associated with a keyboard-like device, any line-editing features of the
7312 underlying operating system should be disabled during the execution of
7313 @code{Get_Immediate}.
7315 Followed on all targets except VxWorks. For VxWorks, there is no way to
7316 provide this functionality that does not result in the input buffer being
7317 flushed before the @code{Get_Immediate} call. A special unit
7318 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7322 @unnumberedsec B.1(39-41): Pragma @code{Export}
7325 If an implementation supports pragma @code{Export} to a given language,
7326 then it should also allow the main subprogram to be written in that
7327 language. It should support some mechanism for invoking the elaboration
7328 of the Ada library units included in the system, and for invoking the
7329 finalization of the environment task. On typical systems, the
7330 recommended mechanism is to provide two subprograms whose link names are
7331 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
7332 elaboration code for library units. @code{adafinal} should contain the
7333 finalization code. These subprograms should have no effect the second
7334 and subsequent time they are called.
7340 Automatic elaboration of pre-elaborated packages should be
7341 provided when pragma @code{Export} is supported.
7343 Followed when the main program is in Ada. If the main program is in a
7344 foreign language, then
7345 @code{adainit} must be called to elaborate pre-elaborated
7350 For each supported convention @var{L} other than @code{Intrinsic}, an
7351 implementation should support @code{Import} and @code{Export} pragmas
7352 for objects of @var{L}-compatible types and for subprograms, and pragma
7353 @code{Convention} for @var{L}-eligible types and for subprograms,
7354 presuming the other language has corresponding features. Pragma
7355 @code{Convention} need not be supported for scalar types.
7359 @cindex Package @code{Interfaces}
7361 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7364 For each implementation-defined convention identifier, there should be a
7365 child package of package Interfaces with the corresponding name. This
7366 package should contain any declarations that would be useful for
7367 interfacing to the language (implementation) represented by the
7368 convention. Any declarations useful for interfacing to any language on
7369 the given hardware architecture should be provided directly in
7372 Followed. An additional package not defined
7373 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7374 for interfacing to C++.
7378 An implementation supporting an interface to C, COBOL, or Fortran should
7379 provide the corresponding package or packages described in the following
7382 Followed. GNAT provides all the packages described in this section.
7384 @cindex C, interfacing with
7385 @unnumberedsec B.3(63-71): Interfacing with C
7388 An implementation should support the following interface correspondences
7395 An Ada procedure corresponds to a void-returning C function.
7401 An Ada function corresponds to a non-void C function.
7407 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7414 An Ada @code{in} parameter of an access-to-object type with designated
7415 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7416 where @var{t} is the C type corresponding to the Ada type @var{T}.
7422 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7423 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7424 argument to a C function, where @var{t} is the C type corresponding to
7425 the Ada type @var{T}. In the case of an elementary @code{out} or
7426 @code{in out} parameter, a pointer to a temporary copy is used to
7427 preserve by-copy semantics.
7433 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7434 @code{@var{t}*} argument to a C function, where @var{t} is the C
7435 structure corresponding to the Ada type @var{T}.
7437 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7438 pragma, or Convention, or by explicitly specifying the mechanism for a given
7439 call using an extended import or export pragma.
7443 An Ada parameter of an array type with component type @var{T}, of any
7444 mode, is passed as a @code{@var{t}*} argument to a C function, where
7445 @var{t} is the C type corresponding to the Ada type @var{T}.
7451 An Ada parameter of an access-to-subprogram type is passed as a pointer
7452 to a C function whose prototype corresponds to the designated
7453 subprogram's specification.
7457 @cindex COBOL, interfacing with
7458 @unnumberedsec B.4(95-98): Interfacing with COBOL
7461 An Ada implementation should support the following interface
7462 correspondences between Ada and COBOL@.
7468 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7469 the COBOL type corresponding to @var{T}.
7475 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7476 the corresponding COBOL type.
7482 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7483 COBOL type corresponding to the Ada parameter type; for scalars, a local
7484 copy is used if necessary to ensure by-copy semantics.
7488 @cindex Fortran, interfacing with
7489 @unnumberedsec B.5(22-26): Interfacing with Fortran
7492 An Ada implementation should support the following interface
7493 correspondences between Ada and Fortran:
7499 An Ada procedure corresponds to a Fortran subroutine.
7505 An Ada function corresponds to a Fortran function.
7511 An Ada parameter of an elementary, array, or record type @var{T} is
7512 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7513 the Fortran type corresponding to the Ada type @var{T}, and where the
7514 INTENT attribute of the corresponding dummy argument matches the Ada
7515 formal parameter mode; the Fortran implementation's parameter passing
7516 conventions are used. For elementary types, a local copy is used if
7517 necessary to ensure by-copy semantics.
7523 An Ada parameter of an access-to-subprogram type is passed as a
7524 reference to a Fortran procedure whose interface corresponds to the
7525 designated subprogram's specification.
7529 @cindex Machine operations
7530 @unnumberedsec C.1(3-5): Access to Machine Operations
7533 The machine code or intrinsic support should allow access to all
7534 operations normally available to assembly language programmers for the
7535 target environment, including privileged instructions, if any.
7541 The interfacing pragmas (see Annex B) should support interface to
7542 assembler; the default assembler should be associated with the
7543 convention identifier @code{Assembler}.
7549 If an entity is exported to assembly language, then the implementation
7550 should allocate it at an addressable location, and should ensure that it
7551 is retained by the linking process, even if not otherwise referenced
7552 from the Ada code. The implementation should assume that any call to a
7553 machine code or assembler subprogram is allowed to read or update every
7554 object that is specified as exported.
7558 @unnumberedsec C.1(10-16): Access to Machine Operations
7561 The implementation should ensure that little or no overhead is
7562 associated with calling intrinsic and machine-code subprograms.
7564 Followed for both intrinsics and machine-code subprograms.
7568 It is recommended that intrinsic subprograms be provided for convenient
7569 access to any machine operations that provide special capabilities or
7570 efficiency and that are not otherwise available through the language
7573 Followed. A full set of machine operation intrinsic subprograms is provided.
7577 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7578 swap, decrement and test, enqueue/dequeue.
7580 Followed on any target supporting such operations.
7584 Standard numeric functions---e.g.@:, sin, log.
7586 Followed on any target supporting such operations.
7590 String manipulation operations---e.g.@:, translate and test.
7592 Followed on any target supporting such operations.
7596 Vector operations---e.g.@:, compare vector against thresholds.
7598 Followed on any target supporting such operations.
7602 Direct operations on I/O ports.
7604 Followed on any target supporting such operations.
7606 @cindex Interrupt support
7607 @unnumberedsec C.3(28): Interrupt Support
7610 If the @code{Ceiling_Locking} policy is not in effect, the
7611 implementation should provide means for the application to specify which
7612 interrupts are to be blocked during protected actions, if the underlying
7613 system allows for a finer-grain control of interrupt blocking.
7615 Followed. The underlying system does not allow for finer-grain control
7616 of interrupt blocking.
7618 @cindex Protected procedure handlers
7619 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7622 Whenever possible, the implementation should allow interrupt handlers to
7623 be called directly by the hardware.
7627 This is never possible under IRIX, so this is followed by default.
7629 Followed on any target where the underlying operating system permits
7634 Whenever practical, violations of any
7635 implementation-defined restrictions should be detected before run time.
7637 Followed. Compile time warnings are given when possible.
7639 @cindex Package @code{Interrupts}
7641 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7645 If implementation-defined forms of interrupt handler procedures are
7646 supported, such as protected procedures with parameters, then for each
7647 such form of a handler, a type analogous to @code{Parameterless_Handler}
7648 should be specified in a child package of @code{Interrupts}, with the
7649 same operations as in the predefined package Interrupts.
7653 @cindex Pre-elaboration requirements
7654 @unnumberedsec C.4(14): Pre-elaboration Requirements
7657 It is recommended that pre-elaborated packages be implemented in such a
7658 way that there should be little or no code executed at run time for the
7659 elaboration of entities not already covered by the Implementation
7662 Followed. Executable code is generated in some cases, e.g.@: loops
7663 to initialize large arrays.
7665 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7669 If the pragma applies to an entity, then the implementation should
7670 reduce the amount of storage used for storing names associated with that
7675 @cindex Package @code{Task_Attributes}
7676 @findex Task_Attributes
7677 @unnumberedsec C.7.2(30): The Package Task_Attributes
7680 Some implementations are targeted to domains in which memory use at run
7681 time must be completely deterministic. For such implementations, it is
7682 recommended that the storage for task attributes will be pre-allocated
7683 statically and not from the heap. This can be accomplished by either
7684 placing restrictions on the number and the size of the task's
7685 attributes, or by using the pre-allocated storage for the first @var{N}
7686 attribute objects, and the heap for the others. In the latter case,
7687 @var{N} should be documented.
7689 Not followed. This implementation is not targeted to such a domain.
7691 @cindex Locking Policies
7692 @unnumberedsec D.3(17): Locking Policies
7696 The implementation should use names that end with @samp{_Locking} for
7697 locking policies defined by the implementation.
7699 Followed. A single implementation-defined locking policy is defined,
7700 whose name (@code{Inheritance_Locking}) follows this suggestion.
7702 @cindex Entry queuing policies
7703 @unnumberedsec D.4(16): Entry Queuing Policies
7706 Names that end with @samp{_Queuing} should be used
7707 for all implementation-defined queuing policies.
7709 Followed. No such implementation-defined queuing policies exist.
7711 @cindex Preemptive abort
7712 @unnumberedsec D.6(9-10): Preemptive Abort
7715 Even though the @code{abort_statement} is included in the list of
7716 potentially blocking operations (see 9.5.1), it is recommended that this
7717 statement be implemented in a way that never requires the task executing
7718 the @code{abort_statement} to block.
7724 On a multi-processor, the delay associated with aborting a task on
7725 another processor should be bounded; the implementation should use
7726 periodic polling, if necessary, to achieve this.
7730 @cindex Tasking restrictions
7731 @unnumberedsec D.7(21): Tasking Restrictions
7734 When feasible, the implementation should take advantage of the specified
7735 restrictions to produce a more efficient implementation.
7737 GNAT currently takes advantage of these restrictions by providing an optimized
7738 run time when the Ravenscar profile and the GNAT restricted run time set
7739 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7740 pragma @code{Profile (Restricted)} for more details.
7742 @cindex Time, monotonic
7743 @unnumberedsec D.8(47-49): Monotonic Time
7746 When appropriate, implementations should provide configuration
7747 mechanisms to change the value of @code{Tick}.
7749 Such configuration mechanisms are not appropriate to this implementation
7750 and are thus not supported.
7754 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7755 be implemented as transformations of the same time base.
7761 It is recommended that the @dfn{best} time base which exists in
7762 the underlying system be available to the application through
7763 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7767 @cindex Partition communication subsystem
7769 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7772 Whenever possible, the PCS on the called partition should allow for
7773 multiple tasks to call the RPC-receiver with different messages and
7774 should allow them to block until the corresponding subprogram body
7777 Followed by GLADE, a separately supplied PCS that can be used with
7782 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7783 should raise @code{Storage_Error} if it runs out of space trying to
7784 write the @code{Item} into the stream.
7786 Followed by GLADE, a separately supplied PCS that can be used with
7789 @cindex COBOL support
7790 @unnumberedsec F(7): COBOL Support
7793 If COBOL (respectively, C) is widely supported in the target
7794 environment, implementations supporting the Information Systems Annex
7795 should provide the child package @code{Interfaces.COBOL} (respectively,
7796 @code{Interfaces.C}) specified in Annex B and should support a
7797 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7798 pragmas (see Annex B), thus allowing Ada programs to interface with
7799 programs written in that language.
7803 @cindex Decimal radix support
7804 @unnumberedsec F.1(2): Decimal Radix Support
7807 Packed decimal should be used as the internal representation for objects
7808 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7810 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
7814 @unnumberedsec G: Numerics
7817 If Fortran (respectively, C) is widely supported in the target
7818 environment, implementations supporting the Numerics Annex
7819 should provide the child package @code{Interfaces.Fortran} (respectively,
7820 @code{Interfaces.C}) specified in Annex B and should support a
7821 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7822 pragmas (see Annex B), thus allowing Ada programs to interface with
7823 programs written in that language.
7827 @cindex Complex types
7828 @unnumberedsec G.1.1(56-58): Complex Types
7831 Because the usual mathematical meaning of multiplication of a complex
7832 operand and a real operand is that of the scaling of both components of
7833 the former by the latter, an implementation should not perform this
7834 operation by first promoting the real operand to complex type and then
7835 performing a full complex multiplication. In systems that, in the
7836 future, support an Ada binding to IEC 559:1989, the latter technique
7837 will not generate the required result when one of the components of the
7838 complex operand is infinite. (Explicit multiplication of the infinite
7839 component by the zero component obtained during promotion yields a NaN
7840 that propagates into the final result.) Analogous advice applies in the
7841 case of multiplication of a complex operand and a pure-imaginary
7842 operand, and in the case of division of a complex operand by a real or
7843 pure-imaginary operand.
7849 Similarly, because the usual mathematical meaning of addition of a
7850 complex operand and a real operand is that the imaginary operand remains
7851 unchanged, an implementation should not perform this operation by first
7852 promoting the real operand to complex type and then performing a full
7853 complex addition. In implementations in which the @code{Signed_Zeros}
7854 attribute of the component type is @code{True} (and which therefore
7855 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7856 predefined arithmetic operations), the latter technique will not
7857 generate the required result when the imaginary component of the complex
7858 operand is a negatively signed zero. (Explicit addition of the negative
7859 zero to the zero obtained during promotion yields a positive zero.)
7860 Analogous advice applies in the case of addition of a complex operand
7861 and a pure-imaginary operand, and in the case of subtraction of a
7862 complex operand and a real or pure-imaginary operand.
7868 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7869 attempt to provide a rational treatment of the signs of zero results and
7870 result components. As one example, the result of the @code{Argument}
7871 function should have the sign of the imaginary component of the
7872 parameter @code{X} when the point represented by that parameter lies on
7873 the positive real axis; as another, the sign of the imaginary component
7874 of the @code{Compose_From_Polar} function should be the same as
7875 (respectively, the opposite of) that of the @code{Argument} parameter when that
7876 parameter has a value of zero and the @code{Modulus} parameter has a
7877 nonnegative (respectively, negative) value.
7881 @cindex Complex elementary functions
7882 @unnumberedsec G.1.2(49): Complex Elementary Functions
7885 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7886 @code{True} should attempt to provide a rational treatment of the signs
7887 of zero results and result components. For example, many of the complex
7888 elementary functions have components that are odd functions of one of
7889 the parameter components; in these cases, the result component should
7890 have the sign of the parameter component at the origin. Other complex
7891 elementary functions have zero components whose sign is opposite that of
7892 a parameter component at the origin, or is always positive or always
7897 @cindex Accuracy requirements
7898 @unnumberedsec G.2.4(19): Accuracy Requirements
7901 The versions of the forward trigonometric functions without a
7902 @code{Cycle} parameter should not be implemented by calling the
7903 corresponding version with a @code{Cycle} parameter of
7904 @code{2.0*Numerics.Pi}, since this will not provide the required
7905 accuracy in some portions of the domain. For the same reason, the
7906 version of @code{Log} without a @code{Base} parameter should not be
7907 implemented by calling the corresponding version with a @code{Base}
7908 parameter of @code{Numerics.e}.
7912 @cindex Complex arithmetic accuracy
7913 @cindex Accuracy, complex arithmetic
7914 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7918 The version of the @code{Compose_From_Polar} function without a
7919 @code{Cycle} parameter should not be implemented by calling the
7920 corresponding version with a @code{Cycle} parameter of
7921 @code{2.0*Numerics.Pi}, since this will not provide the required
7922 accuracy in some portions of the domain.
7926 @c -----------------------------------------
7927 @node Implementation Defined Characteristics
7928 @chapter Implementation Defined Characteristics
7931 In addition to the implementation dependent pragmas and attributes, and the
7932 implementation advice, there are a number of other Ada features that are
7933 potentially implementation dependent and are designated as
7934 implementation-defined. These are mentioned throughout the Ada Reference
7935 Manual, and are summarized in Annex M@.
7937 A requirement for conforming Ada compilers is that they provide
7938 documentation describing how the implementation deals with each of these
7939 issues. In this chapter, you will find each point in Annex M listed
7940 followed by a description in italic font of how GNAT
7944 implementation on IRIX 5.3 operating system or greater
7946 handles the implementation dependence.
7948 You can use this chapter as a guide to minimizing implementation
7949 dependent features in your programs if portability to other compilers
7950 and other operating systems is an important consideration. The numbers
7951 in each section below correspond to the paragraph number in the Ada
7957 @strong{2}. Whether or not each recommendation given in Implementation
7958 Advice is followed. See 1.1.2(37).
7961 @xref{Implementation Advice}.
7966 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
7969 The complexity of programs that can be processed is limited only by the
7970 total amount of available virtual memory, and disk space for the
7971 generated object files.
7976 @strong{4}. Variations from the standard that are impractical to avoid
7977 given the implementation's execution environment. See 1.1.3(6).
7980 There are no variations from the standard.
7985 @strong{5}. Which @code{code_statement}s cause external
7986 interactions. See 1.1.3(10).
7989 Any @code{code_statement} can potentially cause external interactions.
7994 @strong{6}. The coded representation for the text of an Ada
7995 program. See 2.1(4).
7998 See separate section on source representation.
8003 @strong{7}. The control functions allowed in comments. See 2.1(14).
8006 See separate section on source representation.
8011 @strong{8}. The representation for an end of line. See 2.2(2).
8014 See separate section on source representation.
8019 @strong{9}. Maximum supported line length and lexical element
8020 length. See 2.2(15).
8023 The maximum line length is 255 characters and the maximum length of a
8024 lexical element is also 255 characters.
8029 @strong{10}. Implementation defined pragmas. See 2.8(14).
8033 @xref{Implementation Defined Pragmas}.
8038 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
8041 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
8042 parameter, checks that the optimization flag is set, and aborts if it is
8048 @strong{12}. The sequence of characters of the value returned by
8049 @code{@var{S}'Image} when some of the graphic characters of
8050 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
8054 The sequence of characters is as defined by the wide character encoding
8055 method used for the source. See section on source representation for
8061 @strong{13}. The predefined integer types declared in
8062 @code{Standard}. See 3.5.4(25).
8066 @item Short_Short_Integer
8069 (Short) 16 bit signed
8073 64 bit signed (Alpha OpenVMS only)
8074 32 bit signed (all other targets)
8075 @item Long_Long_Integer
8082 @strong{14}. Any nonstandard integer types and the operators defined
8083 for them. See 3.5.4(26).
8086 There are no nonstandard integer types.
8091 @strong{15}. Any nonstandard real types and the operators defined for
8095 There are no nonstandard real types.
8100 @strong{16}. What combinations of requested decimal precision and range
8101 are supported for floating point types. See 3.5.7(7).
8104 The precision and range is as defined by the IEEE standard.
8109 @strong{17}. The predefined floating point types declared in
8110 @code{Standard}. See 3.5.7(16).
8117 (Short) 32 bit IEEE short
8120 @item Long_Long_Float
8121 64 bit IEEE long (80 bit IEEE long on x86 processors)
8127 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
8130 @code{Fine_Delta} is 2**(@minus{}63)
8135 @strong{19}. What combinations of small, range, and digits are
8136 supported for fixed point types. See 3.5.9(10).
8139 Any combinations are permitted that do not result in a small less than
8140 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
8141 If the mantissa is larger than 53 bits on machines where Long_Long_Float
8142 is 64 bits (true of all architectures except ia32), then the output from
8143 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
8144 is because floating-point conversions are used to convert fixed point.
8149 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
8150 within an unnamed @code{block_statement}. See 3.9(10).
8153 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
8154 decimal integer are allocated.
8159 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
8162 @xref{Implementation Defined Attributes}.
8167 @strong{22}. Any implementation-defined time types. See 9.6(6).
8170 There are no implementation-defined time types.
8175 @strong{23}. The time base associated with relative delays.
8178 See 9.6(20). The time base used is that provided by the C library
8179 function @code{gettimeofday}.
8184 @strong{24}. The time base of the type @code{Calendar.Time}. See
8188 The time base used is that provided by the C library function
8189 @code{gettimeofday}.
8194 @strong{25}. The time zone used for package @code{Calendar}
8195 operations. See 9.6(24).
8198 The time zone used by package @code{Calendar} is the current system time zone
8199 setting for local time, as accessed by the C library function
8205 @strong{26}. Any limit on @code{delay_until_statements} of
8206 @code{select_statements}. See 9.6(29).
8209 There are no such limits.
8214 @strong{27}. Whether or not two non-overlapping parts of a composite
8215 object are independently addressable, in the case where packing, record
8216 layout, or @code{Component_Size} is specified for the object. See
8220 Separate components are independently addressable if they do not share
8221 overlapping storage units.
8226 @strong{28}. The representation for a compilation. See 10.1(2).
8229 A compilation is represented by a sequence of files presented to the
8230 compiler in a single invocation of the @command{gcc} command.
8235 @strong{29}. Any restrictions on compilations that contain multiple
8236 compilation_units. See 10.1(4).
8239 No single file can contain more than one compilation unit, but any
8240 sequence of files can be presented to the compiler as a single
8246 @strong{30}. The mechanisms for creating an environment and for adding
8247 and replacing compilation units. See 10.1.4(3).
8250 See separate section on compilation model.
8255 @strong{31}. The manner of explicitly assigning library units to a
8256 partition. See 10.2(2).
8259 If a unit contains an Ada main program, then the Ada units for the partition
8260 are determined by recursive application of the rules in the Ada Reference
8261 Manual section 10.2(2-6). In other words, the Ada units will be those that
8262 are needed by the main program, and then this definition of need is applied
8263 recursively to those units, and the partition contains the transitive
8264 closure determined by this relationship. In short, all the necessary units
8265 are included, with no need to explicitly specify the list. If additional
8266 units are required, e.g.@: by foreign language units, then all units must be
8267 mentioned in the context clause of one of the needed Ada units.
8269 If the partition contains no main program, or if the main program is in
8270 a language other than Ada, then GNAT
8271 provides the binder options @option{-z} and @option{-n} respectively, and in
8272 this case a list of units can be explicitly supplied to the binder for
8273 inclusion in the partition (all units needed by these units will also
8274 be included automatically). For full details on the use of these
8275 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8276 @value{EDITION} User's Guide}.
8281 @strong{32}. The implementation-defined means, if any, of specifying
8282 which compilation units are needed by a given compilation unit. See
8286 The units needed by a given compilation unit are as defined in
8287 the Ada Reference Manual section 10.2(2-6). There are no
8288 implementation-defined pragmas or other implementation-defined
8289 means for specifying needed units.
8294 @strong{33}. The manner of designating the main subprogram of a
8295 partition. See 10.2(7).
8298 The main program is designated by providing the name of the
8299 corresponding @file{ALI} file as the input parameter to the binder.
8304 @strong{34}. The order of elaboration of @code{library_items}. See
8308 The first constraint on ordering is that it meets the requirements of
8309 Chapter 10 of the Ada Reference Manual. This still leaves some
8310 implementation dependent choices, which are resolved by first
8311 elaborating bodies as early as possible (i.e., in preference to specs
8312 where there is a choice), and second by evaluating the immediate with
8313 clauses of a unit to determine the probably best choice, and
8314 third by elaborating in alphabetical order of unit names
8315 where a choice still remains.
8320 @strong{35}. Parameter passing and function return for the main
8321 subprogram. See 10.2(21).
8324 The main program has no parameters. It may be a procedure, or a function
8325 returning an integer type. In the latter case, the returned integer
8326 value is the return code of the program (overriding any value that
8327 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8332 @strong{36}. The mechanisms for building and running partitions. See
8336 GNAT itself supports programs with only a single partition. The GNATDIST
8337 tool provided with the GLADE package (which also includes an implementation
8338 of the PCS) provides a completely flexible method for building and running
8339 programs consisting of multiple partitions. See the separate GLADE manual
8345 @strong{37}. The details of program execution, including program
8346 termination. See 10.2(25).
8349 See separate section on compilation model.
8354 @strong{38}. The semantics of any non-active partitions supported by the
8355 implementation. See 10.2(28).
8358 Passive partitions are supported on targets where shared memory is
8359 provided by the operating system. See the GLADE reference manual for
8365 @strong{39}. The information returned by @code{Exception_Message}. See
8369 Exception message returns the null string unless a specific message has
8370 been passed by the program.
8375 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
8376 declared within an unnamed @code{block_statement}. See 11.4.1(12).
8379 Blocks have implementation defined names of the form @code{B@var{nnn}}
8380 where @var{nnn} is an integer.
8385 @strong{41}. The information returned by
8386 @code{Exception_Information}. See 11.4.1(13).
8389 @code{Exception_Information} returns a string in the following format:
8392 @emph{Exception_Name:} nnnnn
8393 @emph{Message:} mmmmm
8395 @emph{Call stack traceback locations:}
8396 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8404 @code{nnnn} is the fully qualified name of the exception in all upper
8405 case letters. This line is always present.
8408 @code{mmmm} is the message (this line present only if message is non-null)
8411 @code{ppp} is the Process Id value as a decimal integer (this line is
8412 present only if the Process Id is nonzero). Currently we are
8413 not making use of this field.
8416 The Call stack traceback locations line and the following values
8417 are present only if at least one traceback location was recorded.
8418 The values are given in C style format, with lower case letters
8419 for a-f, and only as many digits present as are necessary.
8423 The line terminator sequence at the end of each line, including
8424 the last line is a single @code{LF} character (@code{16#0A#}).
8429 @strong{42}. Implementation-defined check names. See 11.5(27).
8432 The implementation defined check name Alignment_Check controls checking of
8433 address clause values for proper alignment (that is, the address supplied
8434 must be consistent with the alignment of the type).
8436 In addition, a user program can add implementation-defined check names
8437 by means of the pragma Check_Name.
8442 @strong{43}. The interpretation of each aspect of representation. See
8446 See separate section on data representations.
8451 @strong{44}. Any restrictions placed upon representation items. See
8455 See separate section on data representations.
8460 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8464 Size for an indefinite subtype is the maximum possible size, except that
8465 for the case of a subprogram parameter, the size of the parameter object
8471 @strong{46}. The default external representation for a type tag. See
8475 The default external representation for a type tag is the fully expanded
8476 name of the type in upper case letters.
8481 @strong{47}. What determines whether a compilation unit is the same in
8482 two different partitions. See 13.3(76).
8485 A compilation unit is the same in two different partitions if and only
8486 if it derives from the same source file.
8491 @strong{48}. Implementation-defined components. See 13.5.1(15).
8494 The only implementation defined component is the tag for a tagged type,
8495 which contains a pointer to the dispatching table.
8500 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8501 ordering. See 13.5.3(5).
8504 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8505 implementation, so no non-default bit ordering is supported. The default
8506 bit ordering corresponds to the natural endianness of the target architecture.
8511 @strong{50}. The contents of the visible part of package @code{System}
8512 and its language-defined children. See 13.7(2).
8515 See the definition of these packages in files @file{system.ads} and
8516 @file{s-stoele.ads}.
8521 @strong{51}. The contents of the visible part of package
8522 @code{System.Machine_Code}, and the meaning of
8523 @code{code_statements}. See 13.8(7).
8526 See the definition and documentation in file @file{s-maccod.ads}.
8531 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8534 Unchecked conversion between types of the same size
8535 results in an uninterpreted transmission of the bits from one type
8536 to the other. If the types are of unequal sizes, then in the case of
8537 discrete types, a shorter source is first zero or sign extended as
8538 necessary, and a shorter target is simply truncated on the left.
8539 For all non-discrete types, the source is first copied if necessary
8540 to ensure that the alignment requirements of the target are met, then
8541 a pointer is constructed to the source value, and the result is obtained
8542 by dereferencing this pointer after converting it to be a pointer to the
8543 target type. Unchecked conversions where the target subtype is an
8544 unconstrained array are not permitted. If the target alignment is
8545 greater than the source alignment, then a copy of the result is
8546 made with appropriate alignment
8551 @strong{53}. The semantics of operations on invalid representations.
8555 For assignments and other operations where the use of invalid values cannot
8556 result in erroneous behavior, the compiler ignores the possibility of invalid
8557 values. An exception is raised at the point where an invalid value would
8558 result in erroneous behavior. For example executing:
8560 @smallexample @c ada
8561 procedure invalidvals is
8563 Y : Natural range 1 .. 10;
8564 for Y'Address use X'Address;
8565 Z : Natural range 1 .. 10;
8566 A : array (Natural range 1 .. 10) of Integer;
8568 Z := Y; -- no exception
8569 A (Z) := 3; -- exception raised;
8574 As indicated, an exception is raised on the array assignment, but not
8575 on the simple assignment of the invalid negative value from Y to Z.
8580 @strong{53}. The manner of choosing a storage pool for an access type
8581 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8584 There are 3 different standard pools used by the compiler when
8585 @code{Storage_Pool} is not specified depending whether the type is local
8586 to a subprogram or defined at the library level and whether
8587 @code{Storage_Size}is specified or not. See documentation in the runtime
8588 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8589 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8590 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8596 @strong{54}. Whether or not the implementation provides user-accessible
8597 names for the standard pool type(s). See 13.11(17).
8601 See documentation in the sources of the run time mentioned in paragraph
8602 @strong{53} . All these pools are accessible by means of @code{with}'ing
8608 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8611 @code{Storage_Size} is measured in storage units, and refers to the
8612 total space available for an access type collection, or to the primary
8613 stack space for a task.
8618 @strong{56}. Implementation-defined aspects of storage pools. See
8622 See documentation in the sources of the run time mentioned in paragraph
8623 @strong{53} for details on GNAT-defined aspects of storage pools.
8628 @strong{57}. The set of restrictions allowed in a pragma
8629 @code{Restrictions}. See 13.12(7).
8632 All RM defined Restriction identifiers are implemented. The following
8633 additional restriction identifiers are provided. There are two separate
8634 lists of implementation dependent restriction identifiers. The first
8635 set requires consistency throughout a partition (in other words, if the
8636 restriction identifier is used for any compilation unit in the partition,
8637 then all compilation units in the partition must obey the restriction.
8641 @item Simple_Barriers
8642 @findex Simple_Barriers
8643 This restriction ensures at compile time that barriers in entry declarations
8644 for protected types are restricted to either static boolean expressions or
8645 references to simple boolean variables defined in the private part of the
8646 protected type. No other form of entry barriers is permitted. This is one
8647 of the restrictions of the Ravenscar profile for limited tasking (see also
8648 pragma @code{Profile (Ravenscar)}).
8650 @item Max_Entry_Queue_Length => Expr
8651 @findex Max_Entry_Queue_Length
8652 This restriction is a declaration that any protected entry compiled in
8653 the scope of the restriction has at most the specified number of
8654 tasks waiting on the entry
8655 at any one time, and so no queue is required. This restriction is not
8656 checked at compile time. A program execution is erroneous if an attempt
8657 is made to queue more than the specified number of tasks on such an entry.
8661 This restriction ensures at compile time that there is no implicit or
8662 explicit dependence on the package @code{Ada.Calendar}.
8664 @item No_Default_Initialization
8665 @findex No_Default_Initialization
8667 This restriction prohibits any instance of default initialization of variables.
8668 The binder implements a consistency rule which prevents any unit compiled
8669 without the restriction from with'ing a unit with the restriction (this allows
8670 the generation of initialization procedures to be skipped, since you can be
8671 sure that no call is ever generated to an initialization procedure in a unit
8672 with the restriction active). If used in conjunction with Initialize_Scalars or
8673 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8674 without a specific initializer (including the case of OUT scalar parameters).
8676 @item No_Direct_Boolean_Operators
8677 @findex No_Direct_Boolean_Operators
8678 This restriction ensures that no logical (and/or/xor) are used on
8679 operands of type Boolean (or any type derived
8680 from Boolean). This is intended for use in safety critical programs
8681 where the certification protocol requires the use of short-circuit
8682 (and then, or else) forms for all composite boolean operations.
8684 @item No_Dispatching_Calls
8685 @findex No_Dispatching_Calls
8686 This restriction ensures at compile time that the code generated by the
8687 compiler involves no dispatching calls. The use of this restriction allows the
8688 safe use of record extensions, classwide membership tests and other classwide
8689 features not involving implicit dispatching. This restriction ensures that
8690 the code contains no indirect calls through a dispatching mechanism. Note that
8691 this includes internally-generated calls created by the compiler, for example
8692 in the implementation of class-wide objects assignments. The
8693 membership test is allowed in the presence of this restriction, because its
8694 implementation requires no dispatching.
8695 This restriction is comparable to the official Ada restriction
8696 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8697 all classwide constructs that do not imply dispatching.
8698 The following example indicates constructs that violate this restriction.
8702 type T is tagged record
8705 procedure P (X : T);
8707 type DT is new T with record
8708 More_Data : Natural;
8710 procedure Q (X : DT);
8714 procedure Example is
8715 procedure Test (O : T'Class) is
8716 N : Natural := O'Size;-- Error: Dispatching call
8717 C : T'Class := O; -- Error: implicit Dispatching Call
8719 if O in DT'Class then -- OK : Membership test
8720 Q (DT (O)); -- OK : Type conversion plus direct call
8722 P (O); -- Error: Dispatching call
8728 P (Obj); -- OK : Direct call
8729 P (T (Obj)); -- OK : Type conversion plus direct call
8730 P (T'Class (Obj)); -- Error: Dispatching call
8732 Test (Obj); -- OK : Type conversion
8734 if Obj in T'Class then -- OK : Membership test
8740 @item No_Dynamic_Attachment
8741 @findex No_Dynamic_Attachment
8742 This restriction ensures that there is no call to any of the operations
8743 defined in package Ada.Interrupts.
8745 @item No_Enumeration_Maps
8746 @findex No_Enumeration_Maps
8747 This restriction ensures at compile time that no operations requiring
8748 enumeration maps are used (that is Image and Value attributes applied
8749 to enumeration types).
8751 @item No_Entry_Calls_In_Elaboration_Code
8752 @findex No_Entry_Calls_In_Elaboration_Code
8753 This restriction ensures at compile time that no task or protected entry
8754 calls are made during elaboration code. As a result of the use of this
8755 restriction, the compiler can assume that no code past an accept statement
8756 in a task can be executed at elaboration time.
8758 @item No_Exception_Handlers
8759 @findex No_Exception_Handlers
8760 This restriction ensures at compile time that there are no explicit
8761 exception handlers. It also indicates that no exception propagation will
8762 be provided. In this mode, exceptions may be raised but will result in
8763 an immediate call to the last chance handler, a routine that the user
8764 must define with the following profile:
8766 @smallexample @c ada
8767 procedure Last_Chance_Handler
8768 (Source_Location : System.Address; Line : Integer);
8769 pragma Export (C, Last_Chance_Handler,
8770 "__gnat_last_chance_handler");
8773 The parameter is a C null-terminated string representing a message to be
8774 associated with the exception (typically the source location of the raise
8775 statement generated by the compiler). The Line parameter when nonzero
8776 represents the line number in the source program where the raise occurs.
8778 @item No_Exception_Propagation
8779 @findex No_Exception_Propagation
8780 This restriction guarantees that exceptions are never propagated to an outer
8781 subprogram scope). The only case in which an exception may be raised is when
8782 the handler is statically in the same subprogram, so that the effect of a raise
8783 is essentially like a goto statement. Any other raise statement (implicit or
8784 explicit) will be considered unhandled. Exception handlers are allowed, but may
8785 not contain an exception occurrence identifier (exception choice). In addition
8786 use of the package GNAT.Current_Exception is not permitted, and reraise
8787 statements (raise with no operand) are not permitted.
8789 @item No_Exception_Registration
8790 @findex No_Exception_Registration
8791 This restriction ensures at compile time that no stream operations for
8792 types Exception_Id or Exception_Occurrence are used. This also makes it
8793 impossible to pass exceptions to or from a partition with this restriction
8794 in a distributed environment. If this exception is active, then the generated
8795 code is simplified by omitting the otherwise-required global registration
8796 of exceptions when they are declared.
8798 @item No_Implicit_Conditionals
8799 @findex No_Implicit_Conditionals
8800 This restriction ensures that the generated code does not contain any
8801 implicit conditionals, either by modifying the generated code where possible,
8802 or by rejecting any construct that would otherwise generate an implicit
8803 conditional. Note that this check does not include run time constraint
8804 checks, which on some targets may generate implicit conditionals as
8805 well. To control the latter, constraint checks can be suppressed in the
8806 normal manner. Constructs generating implicit conditionals include comparisons
8807 of composite objects and the Max/Min attributes.
8809 @item No_Implicit_Dynamic_Code
8810 @findex No_Implicit_Dynamic_Code
8812 This restriction prevents the compiler from building ``trampolines''.
8813 This is a structure that is built on the stack and contains dynamic
8814 code to be executed at run time. On some targets, a trampoline is
8815 built for the following features: @code{Access},
8816 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8817 nested task bodies; primitive operations of nested tagged types.
8818 Trampolines do not work on machines that prevent execution of stack
8819 data. For example, on windows systems, enabling DEP (data execution
8820 protection) will cause trampolines to raise an exception.
8821 Trampolines are also quite slow at run time.
8823 On many targets, trampolines have been largely eliminated. Look at the
8824 version of system.ads for your target --- if it has
8825 Always_Compatible_Rep equal to False, then trampolines are largely
8826 eliminated. In particular, a trampoline is built for the following
8827 features: @code{Address} of a nested subprogram;
8828 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8829 but only if pragma Favor_Top_Level applies, or the access type has a
8830 foreign-language convention; primitive operations of nested tagged
8833 @item No_Implicit_Loops
8834 @findex No_Implicit_Loops
8835 This restriction ensures that the generated code does not contain any
8836 implicit @code{for} loops, either by modifying
8837 the generated code where possible,
8838 or by rejecting any construct that would otherwise generate an implicit
8839 @code{for} loop. If this restriction is active, it is possible to build
8840 large array aggregates with all static components without generating an
8841 intermediate temporary, and without generating a loop to initialize individual
8842 components. Otherwise, a loop is created for arrays larger than about 5000
8845 @item No_Initialize_Scalars
8846 @findex No_Initialize_Scalars
8847 This restriction ensures that no unit in the partition is compiled with
8848 pragma Initialize_Scalars. This allows the generation of more efficient
8849 code, and in particular eliminates dummy null initialization routines that
8850 are otherwise generated for some record and array types.
8852 @item No_Local_Protected_Objects
8853 @findex No_Local_Protected_Objects
8854 This restriction ensures at compile time that protected objects are
8855 only declared at the library level.
8857 @item No_Protected_Type_Allocators
8858 @findex No_Protected_Type_Allocators
8859 This restriction ensures at compile time that there are no allocator
8860 expressions that attempt to allocate protected objects.
8862 @item No_Secondary_Stack
8863 @findex No_Secondary_Stack
8864 This restriction ensures at compile time that the generated code does not
8865 contain any reference to the secondary stack. The secondary stack is used
8866 to implement functions returning unconstrained objects (arrays or records)
8869 @item No_Select_Statements
8870 @findex No_Select_Statements
8871 This restriction ensures at compile time no select statements of any kind
8872 are permitted, that is the keyword @code{select} may not appear.
8873 This is one of the restrictions of the Ravenscar
8874 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8876 @item No_Standard_Storage_Pools
8877 @findex No_Standard_Storage_Pools
8878 This restriction ensures at compile time that no access types
8879 use the standard default storage pool. Any access type declared must
8880 have an explicit Storage_Pool attribute defined specifying a
8881 user-defined storage pool.
8885 This restriction ensures at compile/bind time that there are no
8886 stream objects created and no use of stream attributes.
8887 This restriction does not forbid dependences on the package
8888 @code{Ada.Streams}. So it is permissible to with
8889 @code{Ada.Streams} (or another package that does so itself)
8890 as long as no actual stream objects are created and no
8891 stream attributes are used.
8893 Note that the use of restriction allows optimization of tagged types,
8894 since they do not need to worry about dispatching stream operations.
8895 To take maximum advantage of this space-saving optimization, any
8896 unit declaring a tagged type should be compiled with the restriction,
8897 though this is not required.
8899 @item No_Task_Attributes_Package
8900 @findex No_Task_Attributes_Package
8901 This restriction ensures at compile time that there are no implicit or
8902 explicit dependencies on the package @code{Ada.Task_Attributes}.
8904 @item No_Task_Termination
8905 @findex No_Task_Termination
8906 This restriction ensures at compile time that no terminate alternatives
8907 appear in any task body.
8911 This restriction prevents the declaration of tasks or task types throughout
8912 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
8913 except that violations are caught at compile time and cause an error message
8914 to be output either by the compiler or binder.
8916 @item Static_Priorities
8917 @findex Static_Priorities
8918 This restriction ensures at compile time that all priority expressions
8919 are static, and that there are no dependencies on the package
8920 @code{Ada.Dynamic_Priorities}.
8922 @item Static_Storage_Size
8923 @findex Static_Storage_Size
8924 This restriction ensures at compile time that any expression appearing
8925 in a Storage_Size pragma or attribute definition clause is static.
8930 The second set of implementation dependent restriction identifiers
8931 does not require partition-wide consistency.
8932 The restriction may be enforced for a single
8933 compilation unit without any effect on any of the
8934 other compilation units in the partition.
8938 @item No_Elaboration_Code
8939 @findex No_Elaboration_Code
8940 This restriction ensures at compile time that no elaboration code is
8941 generated. Note that this is not the same condition as is enforced
8942 by pragma @code{Preelaborate}. There are cases in which pragma
8943 @code{Preelaborate} still permits code to be generated (e.g.@: code
8944 to initialize a large array to all zeroes), and there are cases of units
8945 which do not meet the requirements for pragma @code{Preelaborate},
8946 but for which no elaboration code is generated. Generally, it is
8947 the case that preelaborable units will meet the restrictions, with
8948 the exception of large aggregates initialized with an others_clause,
8949 and exception declarations (which generate calls to a run-time
8950 registry procedure). This restriction is enforced on
8951 a unit by unit basis, it need not be obeyed consistently
8952 throughout a partition.
8954 In the case of aggregates with others, if the aggregate has a dynamic
8955 size, there is no way to eliminate the elaboration code (such dynamic
8956 bounds would be incompatible with @code{Preelaborate} in any case). If
8957 the bounds are static, then use of this restriction actually modifies
8958 the code choice of the compiler to avoid generating a loop, and instead
8959 generate the aggregate statically if possible, no matter how many times
8960 the data for the others clause must be repeatedly generated.
8962 It is not possible to precisely document
8963 the constructs which are compatible with this restriction, since,
8964 unlike most other restrictions, this is not a restriction on the
8965 source code, but a restriction on the generated object code. For
8966 example, if the source contains a declaration:
8969 Val : constant Integer := X;
8973 where X is not a static constant, it may be possible, depending
8974 on complex optimization circuitry, for the compiler to figure
8975 out the value of X at compile time, in which case this initialization
8976 can be done by the loader, and requires no initialization code. It
8977 is not possible to document the precise conditions under which the
8978 optimizer can figure this out.
8980 Note that this the implementation of this restriction requires full
8981 code generation. If it is used in conjunction with "semantics only"
8982 checking, then some cases of violations may be missed.
8984 @item No_Entry_Queue
8985 @findex No_Entry_Queue
8986 This restriction is a declaration that any protected entry compiled in
8987 the scope of the restriction has at most one task waiting on the entry
8988 at any one time, and so no queue is required. This restriction is not
8989 checked at compile time. A program execution is erroneous if an attempt
8990 is made to queue a second task on such an entry.
8992 @item No_Implementation_Attributes
8993 @findex No_Implementation_Attributes
8994 This restriction checks at compile time that no GNAT-defined attributes
8995 are present. With this restriction, the only attributes that can be used
8996 are those defined in the Ada Reference Manual.
8998 @item No_Implementation_Pragmas
8999 @findex No_Implementation_Pragmas
9000 This restriction checks at compile time that no GNAT-defined pragmas
9001 are present. With this restriction, the only pragmas that can be used
9002 are those defined in the Ada Reference Manual.
9004 @item No_Implementation_Restrictions
9005 @findex No_Implementation_Restrictions
9006 This restriction checks at compile time that no GNAT-defined restriction
9007 identifiers (other than @code{No_Implementation_Restrictions} itself)
9008 are present. With this restriction, the only other restriction identifiers
9009 that can be used are those defined in the Ada Reference Manual.
9011 @item No_Wide_Characters
9012 @findex No_Wide_Characters
9013 This restriction ensures at compile time that no uses of the types
9014 @code{Wide_Character} or @code{Wide_String} or corresponding wide
9016 appear, and that no wide or wide wide string or character literals
9017 appear in the program (that is literals representing characters not in
9018 type @code{Character}.
9025 @strong{58}. The consequences of violating limitations on
9026 @code{Restrictions} pragmas. See 13.12(9).
9029 Restrictions that can be checked at compile time result in illegalities
9030 if violated. Currently there are no other consequences of violating
9036 @strong{59}. The representation used by the @code{Read} and
9037 @code{Write} attributes of elementary types in terms of stream
9038 elements. See 13.13.2(9).
9041 The representation is the in-memory representation of the base type of
9042 the type, using the number of bits corresponding to the
9043 @code{@var{type}'Size} value, and the natural ordering of the machine.
9048 @strong{60}. The names and characteristics of the numeric subtypes
9049 declared in the visible part of package @code{Standard}. See A.1(3).
9052 See items describing the integer and floating-point types supported.
9057 @strong{61}. The accuracy actually achieved by the elementary
9058 functions. See A.5.1(1).
9061 The elementary functions correspond to the functions available in the C
9062 library. Only fast math mode is implemented.
9067 @strong{62}. The sign of a zero result from some of the operators or
9068 functions in @code{Numerics.Generic_Elementary_Functions}, when
9069 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
9072 The sign of zeroes follows the requirements of the IEEE 754 standard on
9078 @strong{63}. The value of
9079 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
9082 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9087 @strong{64}. The value of
9088 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
9091 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9096 @strong{65}. The algorithms for random number generation. See
9100 The algorithm is the Mersenne Twister, as documented in the source file
9101 @file{s-rannum.adb}. This version of the algorithm has a period of
9107 @strong{66}. The string representation of a random number generator's
9108 state. See A.5.2(38).
9111 The value returned by the Image function is the concatenation of
9112 the fixed-width decimal representations of the 624 32-bit integers
9113 of the state vector.
9118 @strong{67}. The minimum time interval between calls to the
9119 time-dependent Reset procedure that are guaranteed to initiate different
9120 random number sequences. See A.5.2(45).
9123 The minimum period between reset calls to guarantee distinct series of
9124 random numbers is one microsecond.
9129 @strong{68}. The values of the @code{Model_Mantissa},
9130 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
9131 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
9132 Annex is not supported. See A.5.3(72).
9135 Run the compiler with @option{-gnatS} to produce a listing of package
9136 @code{Standard}, has the values of all numeric attributes.
9141 @strong{69}. Any implementation-defined characteristics of the
9142 input-output packages. See A.7(14).
9145 There are no special implementation defined characteristics for these
9151 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
9155 All type representations are contiguous, and the @code{Buffer_Size} is
9156 the value of @code{@var{type}'Size} rounded up to the next storage unit
9162 @strong{71}. External files for standard input, standard output, and
9163 standard error See A.10(5).
9166 These files are mapped onto the files provided by the C streams
9167 libraries. See source file @file{i-cstrea.ads} for further details.
9172 @strong{72}. The accuracy of the value produced by @code{Put}. See
9176 If more digits are requested in the output than are represented by the
9177 precision of the value, zeroes are output in the corresponding least
9178 significant digit positions.
9183 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
9184 @code{Command_Name}. See A.15(1).
9187 These are mapped onto the @code{argv} and @code{argc} parameters of the
9188 main program in the natural manner.
9193 @strong{74}. The interpretation of the @code{Form} parameter in procedure
9194 @code{Create_Directory}. See A.16(56).
9197 The @code{Form} parameter is not used.
9202 @strong{75}. The interpretation of the @code{Form} parameter in procedure
9203 @code{Create_Path}. See A.16(60).
9206 The @code{Form} parameter is not used.
9211 @strong{76}. The interpretation of the @code{Form} parameter in procedure
9212 @code{Copy_File}. See A.16(68).
9215 The @code{Form} parameter is case-insensitive.
9217 Two fields are recognized in the @code{Form} parameter:
9221 @item preserve=<value>
9228 <value> starts immediately after the character '=' and ends with the
9229 character immediately preceding the next comma (',') or with the last
9230 character of the parameter.
9232 The only possible values for preserve= are:
9237 Do not try to preserve any file attributes. This is the default if no
9238 preserve= is found in Form.
9240 @item all_attributes
9241 Try to preserve all file attributes (timestamps, access rights).
9244 Preserve the timestamp of the copied file, but not the other file attributes.
9249 The only possible values for mode= are:
9254 Only do the copy if the destination file does not already exist. If it already
9255 exists, Copy_File fails.
9258 Copy the file in all cases. Overwite an already existing destination file.
9261 Append the original file to the destination file. If the destination file does
9262 not exist, the destination file is a copy of the source file. When mode=append,
9263 the field preserve=, if it exists, is not taken into account.
9268 If the Form parameter includes one or both of the fields and the value or
9269 values are incorrect, Copy_file fails with Use_Error.
9271 Examples of correct Forms:
9274 Form => "preserve=no_attributes,mode=overwrite" (the default)
9275 Form => "mode=append"
9276 Form => "mode=copy, preserve=all_attributes"
9280 Examples of incorrect Forms
9283 Form => "preserve=junk"
9284 Form => "mode=internal, preserve=timestamps"
9290 @strong{77}. Implementation-defined convention names. See B.1(11).
9293 The following convention names are supported
9301 Synonym for Assembler
9303 Synonym for Assembler
9306 @item C_Pass_By_Copy
9307 Allowed only for record types, like C, but also notes that record
9308 is to be passed by copy rather than reference.
9311 @item C_Plus_Plus (or CPP)
9314 Treated the same as C
9316 Treated the same as C
9320 For support of pragma @code{Import} with convention Intrinsic, see
9321 separate section on Intrinsic Subprograms.
9323 Stdcall (used for Windows implementations only). This convention correspond
9324 to the WINAPI (previously called Pascal convention) C/C++ convention under
9325 Windows. A function with this convention cleans the stack before exit.
9331 Stubbed is a special convention used to indicate that the body of the
9332 subprogram will be entirely ignored. Any call to the subprogram
9333 is converted into a raise of the @code{Program_Error} exception. If a
9334 pragma @code{Import} specifies convention @code{stubbed} then no body need
9335 be present at all. This convention is useful during development for the
9336 inclusion of subprograms whose body has not yet been written.
9340 In addition, all otherwise unrecognized convention names are also
9341 treated as being synonymous with convention C@. In all implementations
9342 except for VMS, use of such other names results in a warning. In VMS
9343 implementations, these names are accepted silently.
9348 @strong{78}. The meaning of link names. See B.1(36).
9351 Link names are the actual names used by the linker.
9356 @strong{79}. The manner of choosing link names when neither the link
9357 name nor the address of an imported or exported entity is specified. See
9361 The default linker name is that which would be assigned by the relevant
9362 external language, interpreting the Ada name as being in all lower case
9368 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
9371 The string passed to @code{Linker_Options} is presented uninterpreted as
9372 an argument to the link command, unless it contains ASCII.NUL characters.
9373 NUL characters if they appear act as argument separators, so for example
9375 @smallexample @c ada
9376 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9380 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9381 linker. The order of linker options is preserved for a given unit. The final
9382 list of options passed to the linker is in reverse order of the elaboration
9383 order. For example, linker options for a body always appear before the options
9384 from the corresponding package spec.
9389 @strong{81}. The contents of the visible part of package
9390 @code{Interfaces} and its language-defined descendants. See B.2(1).
9393 See files with prefix @file{i-} in the distributed library.
9398 @strong{82}. Implementation-defined children of package
9399 @code{Interfaces}. The contents of the visible part of package
9400 @code{Interfaces}. See B.2(11).
9403 See files with prefix @file{i-} in the distributed library.
9408 @strong{83}. The types @code{Floating}, @code{Long_Floating},
9409 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9410 @code{COBOL_Character}; and the initialization of the variables
9411 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9412 @code{Interfaces.COBOL}. See B.4(50).
9419 (Floating) Long_Float
9424 @item Decimal_Element
9426 @item COBOL_Character
9431 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9436 @strong{84}. Support for access to machine instructions. See C.1(1).
9439 See documentation in file @file{s-maccod.ads} in the distributed library.
9444 @strong{85}. Implementation-defined aspects of access to machine
9445 operations. See C.1(9).
9448 See documentation in file @file{s-maccod.ads} in the distributed library.
9453 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
9456 Interrupts are mapped to signals or conditions as appropriate. See
9458 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9459 on the interrupts supported on a particular target.
9464 @strong{87}. Implementation-defined aspects of pre-elaboration. See
9468 GNAT does not permit a partition to be restarted without reloading,
9469 except under control of the debugger.
9474 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
9477 Pragma @code{Discard_Names} causes names of enumeration literals to
9478 be suppressed. In the presence of this pragma, the Image attribute
9479 provides the image of the Pos of the literal, and Value accepts
9485 @strong{89}. The result of the @code{Task_Identification.Image}
9486 attribute. See C.7.1(7).
9489 The result of this attribute is a string that identifies
9490 the object or component that denotes a given task. If a variable @code{Var}
9491 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9493 is the hexadecimal representation of the virtual address of the corresponding
9494 task control block. If the variable is an array of tasks, the image of each
9495 task will have the form of an indexed component indicating the position of a
9496 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9497 component of a record, the image of the task will have the form of a selected
9498 component. These rules are fully recursive, so that the image of a task that
9499 is a subcomponent of a composite object corresponds to the expression that
9500 designates this task.
9502 If a task is created by an allocator, its image depends on the context. If the
9503 allocator is part of an object declaration, the rules described above are used
9504 to construct its image, and this image is not affected by subsequent
9505 assignments. If the allocator appears within an expression, the image
9506 includes only the name of the task type.
9508 If the configuration pragma Discard_Names is present, or if the restriction
9509 No_Implicit_Heap_Allocation is in effect, the image reduces to
9510 the numeric suffix, that is to say the hexadecimal representation of the
9511 virtual address of the control block of the task.
9515 @strong{90}. The value of @code{Current_Task} when in a protected entry
9516 or interrupt handler. See C.7.1(17).
9519 Protected entries or interrupt handlers can be executed by any
9520 convenient thread, so the value of @code{Current_Task} is undefined.
9525 @strong{91}. The effect of calling @code{Current_Task} from an entry
9526 body or interrupt handler. See C.7.1(19).
9529 The effect of calling @code{Current_Task} from an entry body or
9530 interrupt handler is to return the identification of the task currently
9536 @strong{92}. Implementation-defined aspects of
9537 @code{Task_Attributes}. See C.7.2(19).
9540 There are no implementation-defined aspects of @code{Task_Attributes}.
9545 @strong{93}. Values of all @code{Metrics}. See D(2).
9548 The metrics information for GNAT depends on the performance of the
9549 underlying operating system. The sources of the run-time for tasking
9550 implementation, together with the output from @option{-gnatG} can be
9551 used to determine the exact sequence of operating systems calls made
9552 to implement various tasking constructs. Together with appropriate
9553 information on the performance of the underlying operating system,
9554 on the exact target in use, this information can be used to determine
9555 the required metrics.
9560 @strong{94}. The declarations of @code{Any_Priority} and
9561 @code{Priority}. See D.1(11).
9564 See declarations in file @file{system.ads}.
9569 @strong{95}. Implementation-defined execution resources. See D.1(15).
9572 There are no implementation-defined execution resources.
9577 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
9578 access to a protected object keeps its processor busy. See D.2.1(3).
9581 On a multi-processor, a task that is waiting for access to a protected
9582 object does not keep its processor busy.
9587 @strong{97}. The affect of implementation defined execution resources
9588 on task dispatching. See D.2.1(9).
9593 Tasks map to IRIX threads, and the dispatching policy is as defined by
9594 the IRIX implementation of threads.
9596 Tasks map to threads in the threads package used by GNAT@. Where possible
9597 and appropriate, these threads correspond to native threads of the
9598 underlying operating system.
9603 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9604 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9607 There are no implementation-defined policy-identifiers allowed in this
9613 @strong{99}. Implementation-defined aspects of priority inversion. See
9617 Execution of a task cannot be preempted by the implementation processing
9618 of delay expirations for lower priority tasks.
9623 @strong{100}. Implementation defined task dispatching. See D.2.2(18).
9628 Tasks map to IRIX threads, and the dispatching policy is as defined by
9629 the IRIX implementation of threads.
9631 The policy is the same as that of the underlying threads implementation.
9636 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
9637 in a pragma @code{Locking_Policy}. See D.3(4).
9640 The only implementation defined policy permitted in GNAT is
9641 @code{Inheritance_Locking}. On targets that support this policy, locking
9642 is implemented by inheritance, i.e.@: the task owning the lock operates
9643 at a priority equal to the highest priority of any task currently
9644 requesting the lock.
9649 @strong{102}. Default ceiling priorities. See D.3(10).
9652 The ceiling priority of protected objects of the type
9653 @code{System.Interrupt_Priority'Last} as described in the Ada
9654 Reference Manual D.3(10),
9659 @strong{103}. The ceiling of any protected object used internally by
9660 the implementation. See D.3(16).
9663 The ceiling priority of internal protected objects is
9664 @code{System.Priority'Last}.
9669 @strong{104}. Implementation-defined queuing policies. See D.4(1).
9672 There are no implementation-defined queuing policies.
9677 @strong{105}. On a multiprocessor, any conditions that cause the
9678 completion of an aborted construct to be delayed later than what is
9679 specified for a single processor. See D.6(3).
9682 The semantics for abort on a multi-processor is the same as on a single
9683 processor, there are no further delays.
9688 @strong{106}. Any operations that implicitly require heap storage
9689 allocation. See D.7(8).
9692 The only operation that implicitly requires heap storage allocation is
9698 @strong{107}. Implementation-defined aspects of pragma
9699 @code{Restrictions}. See D.7(20).
9702 There are no such implementation-defined aspects.
9707 @strong{108}. Implementation-defined aspects of package
9708 @code{Real_Time}. See D.8(17).
9711 There are no implementation defined aspects of package @code{Real_Time}.
9716 @strong{109}. Implementation-defined aspects of
9717 @code{delay_statements}. See D.9(8).
9720 Any difference greater than one microsecond will cause the task to be
9721 delayed (see D.9(7)).
9726 @strong{110}. The upper bound on the duration of interrupt blocking
9727 caused by the implementation. See D.12(5).
9730 The upper bound is determined by the underlying operating system. In
9731 no cases is it more than 10 milliseconds.
9736 @strong{111}. The means for creating and executing distributed
9740 The GLADE package provides a utility GNATDIST for creating and executing
9741 distributed programs. See the GLADE reference manual for further details.
9746 @strong{112}. Any events that can result in a partition becoming
9747 inaccessible. See E.1(7).
9750 See the GLADE reference manual for full details on such events.
9755 @strong{113}. The scheduling policies, treatment of priorities, and
9756 management of shared resources between partitions in certain cases. See
9760 See the GLADE reference manual for full details on these aspects of
9761 multi-partition execution.
9766 @strong{114}. Events that cause the version of a compilation unit to
9770 Editing the source file of a compilation unit, or the source files of
9771 any units on which it is dependent in a significant way cause the version
9772 to change. No other actions cause the version number to change. All changes
9773 are significant except those which affect only layout, capitalization or
9779 @strong{115}. Whether the execution of the remote subprogram is
9780 immediately aborted as a result of cancellation. See E.4(13).
9783 See the GLADE reference manual for details on the effect of abort in
9784 a distributed application.
9789 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
9792 See the GLADE reference manual for a full description of all implementation
9793 defined aspects of the PCS@.
9798 @strong{117}. Implementation-defined interfaces in the PCS@. See
9802 See the GLADE reference manual for a full description of all
9803 implementation defined interfaces.
9808 @strong{118}. The values of named numbers in the package
9809 @code{Decimal}. See F.2(7).
9821 @item Max_Decimal_Digits
9828 @strong{119}. The value of @code{Max_Picture_Length} in the package
9829 @code{Text_IO.Editing}. See F.3.3(16).
9837 @strong{120}. The value of @code{Max_Picture_Length} in the package
9838 @code{Wide_Text_IO.Editing}. See F.3.4(5).
9846 @strong{121}. The accuracy actually achieved by the complex elementary
9847 functions and by other complex arithmetic operations. See G.1(1).
9850 Standard library functions are used for the complex arithmetic
9851 operations. Only fast math mode is currently supported.
9856 @strong{122}. The sign of a zero result (or a component thereof) from
9857 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9858 @code{Real'Signed_Zeros} is True. See G.1.1(53).
9861 The signs of zero values are as recommended by the relevant
9862 implementation advice.
9867 @strong{123}. The sign of a zero result (or a component thereof) from
9868 any operator or function in
9869 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9870 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
9873 The signs of zero values are as recommended by the relevant
9874 implementation advice.
9879 @strong{124}. Whether the strict mode or the relaxed mode is the
9880 default. See G.2(2).
9883 The strict mode is the default. There is no separate relaxed mode. GNAT
9884 provides a highly efficient implementation of strict mode.
9889 @strong{125}. The result interval in certain cases of fixed-to-float
9890 conversion. See G.2.1(10).
9893 For cases where the result interval is implementation dependent, the
9894 accuracy is that provided by performing all operations in 64-bit IEEE
9895 floating-point format.
9900 @strong{126}. The result of a floating point arithmetic operation in
9901 overflow situations, when the @code{Machine_Overflows} attribute of the
9902 result type is @code{False}. See G.2.1(13).
9905 Infinite and NaN values are produced as dictated by the IEEE
9906 floating-point standard.
9908 Note that on machines that are not fully compliant with the IEEE
9909 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9910 must be used for achieving IEEE confirming behavior (although at the cost
9911 of a significant performance penalty), so infinite and NaN values are
9917 @strong{127}. The result interval for division (or exponentiation by a
9918 negative exponent), when the floating point hardware implements division
9919 as multiplication by a reciprocal. See G.2.1(16).
9922 Not relevant, division is IEEE exact.
9927 @strong{128}. The definition of close result set, which determines the
9928 accuracy of certain fixed point multiplications and divisions. See
9932 Operations in the close result set are performed using IEEE long format
9933 floating-point arithmetic. The input operands are converted to
9934 floating-point, the operation is done in floating-point, and the result
9935 is converted to the target type.
9940 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
9941 point multiplication or division for which the result shall be in the
9942 perfect result set. See G.2.3(22).
9945 The result is only defined to be in the perfect result set if the result
9946 can be computed by a single scaling operation involving a scale factor
9947 representable in 64-bits.
9952 @strong{130}. The result of a fixed point arithmetic operation in
9953 overflow situations, when the @code{Machine_Overflows} attribute of the
9954 result type is @code{False}. See G.2.3(27).
9957 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9963 @strong{131}. The result of an elementary function reference in
9964 overflow situations, when the @code{Machine_Overflows} attribute of the
9965 result type is @code{False}. See G.2.4(4).
9968 IEEE infinite and Nan values are produced as appropriate.
9973 @strong{132}. The value of the angle threshold, within which certain
9974 elementary functions, complex arithmetic operations, and complex
9975 elementary functions yield results conforming to a maximum relative
9976 error bound. See G.2.4(10).
9979 Information on this subject is not yet available.
9984 @strong{133}. The accuracy of certain elementary functions for
9985 parameters beyond the angle threshold. See G.2.4(10).
9988 Information on this subject is not yet available.
9993 @strong{134}. The result of a complex arithmetic operation or complex
9994 elementary function reference in overflow situations, when the
9995 @code{Machine_Overflows} attribute of the corresponding real type is
9996 @code{False}. See G.2.6(5).
9999 IEEE infinite and Nan values are produced as appropriate.
10004 @strong{135}. The accuracy of certain complex arithmetic operations and
10005 certain complex elementary functions for parameters (or components
10006 thereof) beyond the angle threshold. See G.2.6(8).
10009 Information on those subjects is not yet available.
10014 @strong{136}. Information regarding bounded errors and erroneous
10015 execution. See H.2(1).
10018 Information on this subject is not yet available.
10023 @strong{137}. Implementation-defined aspects of pragma
10024 @code{Inspection_Point}. See H.3.2(8).
10027 Pragma @code{Inspection_Point} ensures that the variable is live and can
10028 be examined by the debugger at the inspection point.
10033 @strong{138}. Implementation-defined aspects of pragma
10034 @code{Restrictions}. See H.4(25).
10037 There are no implementation-defined aspects of pragma @code{Restrictions}. The
10038 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
10039 generated code. Checks must suppressed by use of pragma @code{Suppress}.
10044 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
10048 There are no restrictions on pragma @code{Restrictions}.
10050 @node Intrinsic Subprograms
10051 @chapter Intrinsic Subprograms
10052 @cindex Intrinsic Subprograms
10055 * Intrinsic Operators::
10056 * Enclosing_Entity::
10057 * Exception_Information::
10058 * Exception_Message::
10066 * Shift_Right_Arithmetic::
10067 * Source_Location::
10071 GNAT allows a user application program to write the declaration:
10073 @smallexample @c ada
10074 pragma Import (Intrinsic, name);
10078 providing that the name corresponds to one of the implemented intrinsic
10079 subprograms in GNAT, and that the parameter profile of the referenced
10080 subprogram meets the requirements. This chapter describes the set of
10081 implemented intrinsic subprograms, and the requirements on parameter profiles.
10082 Note that no body is supplied; as with other uses of pragma Import, the
10083 body is supplied elsewhere (in this case by the compiler itself). Note
10084 that any use of this feature is potentially non-portable, since the
10085 Ada standard does not require Ada compilers to implement this feature.
10087 @node Intrinsic Operators
10088 @section Intrinsic Operators
10089 @cindex Intrinsic operator
10092 All the predefined numeric operators in package Standard
10093 in @code{pragma Import (Intrinsic,..)}
10094 declarations. In the binary operator case, the operands must have the same
10095 size. The operand or operands must also be appropriate for
10096 the operator. For example, for addition, the operands must
10097 both be floating-point or both be fixed-point, and the
10098 right operand for @code{"**"} must have a root type of
10099 @code{Standard.Integer'Base}.
10100 You can use an intrinsic operator declaration as in the following example:
10102 @smallexample @c ada
10103 type Int1 is new Integer;
10104 type Int2 is new Integer;
10106 function "+" (X1 : Int1; X2 : Int2) return Int1;
10107 function "+" (X1 : Int1; X2 : Int2) return Int2;
10108 pragma Import (Intrinsic, "+");
10112 This declaration would permit ``mixed mode'' arithmetic on items
10113 of the differing types @code{Int1} and @code{Int2}.
10114 It is also possible to specify such operators for private types, if the
10115 full views are appropriate arithmetic types.
10117 @node Enclosing_Entity
10118 @section Enclosing_Entity
10119 @cindex Enclosing_Entity
10121 This intrinsic subprogram is used in the implementation of the
10122 library routine @code{GNAT.Source_Info}. The only useful use of the
10123 intrinsic import in this case is the one in this unit, so an
10124 application program should simply call the function
10125 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
10126 the current subprogram, package, task, entry, or protected subprogram.
10128 @node Exception_Information
10129 @section Exception_Information
10130 @cindex Exception_Information'
10132 This intrinsic subprogram is used in the implementation of the
10133 library routine @code{GNAT.Current_Exception}. The only useful
10134 use of the intrinsic import in this case is the one in this unit,
10135 so an application program should simply call the function
10136 @code{GNAT.Current_Exception.Exception_Information} to obtain
10137 the exception information associated with the current exception.
10139 @node Exception_Message
10140 @section Exception_Message
10141 @cindex Exception_Message
10143 This intrinsic subprogram is used in the implementation of the
10144 library routine @code{GNAT.Current_Exception}. The only useful
10145 use of the intrinsic import in this case is the one in this unit,
10146 so an application program should simply call the function
10147 @code{GNAT.Current_Exception.Exception_Message} to obtain
10148 the message associated with the current exception.
10150 @node Exception_Name
10151 @section Exception_Name
10152 @cindex Exception_Name
10154 This intrinsic subprogram is used in the implementation of the
10155 library routine @code{GNAT.Current_Exception}. The only useful
10156 use of the intrinsic import in this case is the one in this unit,
10157 so an application program should simply call the function
10158 @code{GNAT.Current_Exception.Exception_Name} to obtain
10159 the name of the current exception.
10165 This intrinsic subprogram is used in the implementation of the
10166 library routine @code{GNAT.Source_Info}. The only useful use of the
10167 intrinsic import in this case is the one in this unit, so an
10168 application program should simply call the function
10169 @code{GNAT.Source_Info.File} to obtain the name of the current
10176 This intrinsic subprogram is used in the implementation of the
10177 library routine @code{GNAT.Source_Info}. The only useful use of the
10178 intrinsic import in this case is the one in this unit, so an
10179 application program should simply call the function
10180 @code{GNAT.Source_Info.Line} to obtain the number of the current
10184 @section Rotate_Left
10185 @cindex Rotate_Left
10187 In standard Ada, the @code{Rotate_Left} function is available only
10188 for the predefined modular types in package @code{Interfaces}. However, in
10189 GNAT it is possible to define a Rotate_Left function for a user
10190 defined modular type or any signed integer type as in this example:
10192 @smallexample @c ada
10193 function Shift_Left
10194 (Value : My_Modular_Type;
10196 return My_Modular_Type;
10200 The requirements are that the profile be exactly as in the example
10201 above. The only modifications allowed are in the formal parameter
10202 names, and in the type of @code{Value} and the return type, which
10203 must be the same, and must be either a signed integer type, or
10204 a modular integer type with a binary modulus, and the size must
10205 be 8. 16, 32 or 64 bits.
10208 @section Rotate_Right
10209 @cindex Rotate_Right
10211 A @code{Rotate_Right} function can be defined for any user defined
10212 binary modular integer type, or signed integer type, as described
10213 above for @code{Rotate_Left}.
10216 @section Shift_Left
10219 A @code{Shift_Left} function can be defined for any user defined
10220 binary modular integer type, or signed integer type, as described
10221 above for @code{Rotate_Left}.
10224 @section Shift_Right
10225 @cindex Shift_Right
10227 A @code{Shift_Right} function can be defined for any user defined
10228 binary modular integer type, or signed integer type, as described
10229 above for @code{Rotate_Left}.
10231 @node Shift_Right_Arithmetic
10232 @section Shift_Right_Arithmetic
10233 @cindex Shift_Right_Arithmetic
10235 A @code{Shift_Right_Arithmetic} function can be defined for any user
10236 defined binary modular integer type, or signed integer type, as described
10237 above for @code{Rotate_Left}.
10239 @node Source_Location
10240 @section Source_Location
10241 @cindex Source_Location
10243 This intrinsic subprogram is used in the implementation of the
10244 library routine @code{GNAT.Source_Info}. The only useful use of the
10245 intrinsic import in this case is the one in this unit, so an
10246 application program should simply call the function
10247 @code{GNAT.Source_Info.Source_Location} to obtain the current
10248 source file location.
10250 @node Representation Clauses and Pragmas
10251 @chapter Representation Clauses and Pragmas
10252 @cindex Representation Clauses
10255 * Alignment Clauses::
10257 * Storage_Size Clauses::
10258 * Size of Variant Record Objects::
10259 * Biased Representation ::
10260 * Value_Size and Object_Size Clauses::
10261 * Component_Size Clauses::
10262 * Bit_Order Clauses::
10263 * Effect of Bit_Order on Byte Ordering::
10264 * Pragma Pack for Arrays::
10265 * Pragma Pack for Records::
10266 * Record Representation Clauses::
10267 * Enumeration Clauses::
10268 * Address Clauses::
10269 * Effect of Convention on Representation::
10270 * Determining the Representations chosen by GNAT::
10274 @cindex Representation Clause
10275 @cindex Representation Pragma
10276 @cindex Pragma, representation
10277 This section describes the representation clauses accepted by GNAT, and
10278 their effect on the representation of corresponding data objects.
10280 GNAT fully implements Annex C (Systems Programming). This means that all
10281 the implementation advice sections in chapter 13 are fully implemented.
10282 However, these sections only require a minimal level of support for
10283 representation clauses. GNAT provides much more extensive capabilities,
10284 and this section describes the additional capabilities provided.
10286 @node Alignment Clauses
10287 @section Alignment Clauses
10288 @cindex Alignment Clause
10291 GNAT requires that all alignment clauses specify a power of 2, and all
10292 default alignments are always a power of 2. The default alignment
10293 values are as follows:
10296 @item @emph{Primitive Types}.
10297 For primitive types, the alignment is the minimum of the actual size of
10298 objects of the type divided by @code{Storage_Unit},
10299 and the maximum alignment supported by the target.
10300 (This maximum alignment is given by the GNAT-specific attribute
10301 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
10302 @cindex @code{Maximum_Alignment} attribute
10303 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
10304 default alignment will be 8 on any target that supports alignments
10305 this large, but on some targets, the maximum alignment may be smaller
10306 than 8, in which case objects of type @code{Long_Float} will be maximally
10309 @item @emph{Arrays}.
10310 For arrays, the alignment is equal to the alignment of the component type
10311 for the normal case where no packing or component size is given. If the
10312 array is packed, and the packing is effective (see separate section on
10313 packed arrays), then the alignment will be one for long packed arrays,
10314 or arrays whose length is not known at compile time. For short packed
10315 arrays, which are handled internally as modular types, the alignment
10316 will be as described for primitive types, e.g.@: a packed array of length
10317 31 bits will have an object size of four bytes, and an alignment of 4.
10319 @item @emph{Records}.
10320 For the normal non-packed case, the alignment of a record is equal to
10321 the maximum alignment of any of its components. For tagged records, this
10322 includes the implicit access type used for the tag. If a pragma @code{Pack}
10323 is used and all components are packable (see separate section on pragma
10324 @code{Pack}), then the resulting alignment is 1, unless the layout of the
10325 record makes it profitable to increase it.
10327 A special case is when:
10330 the size of the record is given explicitly, or a
10331 full record representation clause is given, and
10333 the size of the record is 2, 4, or 8 bytes.
10336 In this case, an alignment is chosen to match the
10337 size of the record. For example, if we have:
10339 @smallexample @c ada
10340 type Small is record
10343 for Small'Size use 16;
10347 then the default alignment of the record type @code{Small} is 2, not 1. This
10348 leads to more efficient code when the record is treated as a unit, and also
10349 allows the type to specified as @code{Atomic} on architectures requiring
10355 An alignment clause may specify a larger alignment than the default value
10356 up to some maximum value dependent on the target (obtainable by using the
10357 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10358 a smaller alignment than the default value for enumeration, integer and
10359 fixed point types, as well as for record types, for example
10361 @smallexample @c ada
10366 for V'alignment use 1;
10370 @cindex Alignment, default
10371 The default alignment for the type @code{V} is 4, as a result of the
10372 Integer field in the record, but it is permissible, as shown, to
10373 override the default alignment of the record with a smaller value.
10376 @section Size Clauses
10377 @cindex Size Clause
10380 The default size for a type @code{T} is obtainable through the
10381 language-defined attribute @code{T'Size} and also through the
10382 equivalent GNAT-defined attribute @code{T'Value_Size}.
10383 For objects of type @code{T}, GNAT will generally increase the type size
10384 so that the object size (obtainable through the GNAT-defined attribute
10385 @code{T'Object_Size})
10386 is a multiple of @code{T'Alignment * Storage_Unit}.
10389 @smallexample @c ada
10390 type Smallint is range 1 .. 6;
10399 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10400 as specified by the RM rules,
10401 but objects of this type will have a size of 8
10402 (@code{Smallint'Object_Size} = 8),
10403 since objects by default occupy an integral number
10404 of storage units. On some targets, notably older
10405 versions of the Digital Alpha, the size of stand
10406 alone objects of this type may be 32, reflecting
10407 the inability of the hardware to do byte load/stores.
10409 Similarly, the size of type @code{Rec} is 40 bits
10410 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10411 the alignment is 4, so objects of this type will have
10412 their size increased to 64 bits so that it is a multiple
10413 of the alignment (in bits). This decision is
10414 in accordance with the specific Implementation Advice in RM 13.3(43):
10417 A @code{Size} clause should be supported for an object if the specified
10418 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10419 to a size in storage elements that is a multiple of the object's
10420 @code{Alignment} (if the @code{Alignment} is nonzero).
10424 An explicit size clause may be used to override the default size by
10425 increasing it. For example, if we have:
10427 @smallexample @c ada
10428 type My_Boolean is new Boolean;
10429 for My_Boolean'Size use 32;
10433 then values of this type will always be 32 bits long. In the case of
10434 discrete types, the size can be increased up to 64 bits, with the effect
10435 that the entire specified field is used to hold the value, sign- or
10436 zero-extended as appropriate. If more than 64 bits is specified, then
10437 padding space is allocated after the value, and a warning is issued that
10438 there are unused bits.
10440 Similarly the size of records and arrays may be increased, and the effect
10441 is to add padding bits after the value. This also causes a warning message
10444 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
10445 Size in bits, this corresponds to an object of size 256 megabytes (minus
10446 one). This limitation is true on all targets. The reason for this
10447 limitation is that it improves the quality of the code in many cases
10448 if it is known that a Size value can be accommodated in an object of
10451 @node Storage_Size Clauses
10452 @section Storage_Size Clauses
10453 @cindex Storage_Size Clause
10456 For tasks, the @code{Storage_Size} clause specifies the amount of space
10457 to be allocated for the task stack. This cannot be extended, and if the
10458 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10459 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
10460 or a @code{Storage_Size} pragma in the task definition to set the
10461 appropriate required size. A useful technique is to include in every
10462 task definition a pragma of the form:
10464 @smallexample @c ada
10465 pragma Storage_Size (Default_Stack_Size);
10469 Then @code{Default_Stack_Size} can be defined in a global package, and
10470 modified as required. Any tasks requiring stack sizes different from the
10471 default can have an appropriate alternative reference in the pragma.
10473 You can also use the @option{-d} binder switch to modify the default stack
10476 For access types, the @code{Storage_Size} clause specifies the maximum
10477 space available for allocation of objects of the type. If this space is
10478 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10479 In the case where the access type is declared local to a subprogram, the
10480 use of a @code{Storage_Size} clause triggers automatic use of a special
10481 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10482 space for the pool is automatically reclaimed on exit from the scope in
10483 which the type is declared.
10485 A special case recognized by the compiler is the specification of a
10486 @code{Storage_Size} of zero for an access type. This means that no
10487 items can be allocated from the pool, and this is recognized at compile
10488 time, and all the overhead normally associated with maintaining a fixed
10489 size storage pool is eliminated. Consider the following example:
10491 @smallexample @c ada
10493 type R is array (Natural) of Character;
10494 type P is access all R;
10495 for P'Storage_Size use 0;
10496 -- Above access type intended only for interfacing purposes
10500 procedure g (m : P);
10501 pragma Import (C, g);
10512 As indicated in this example, these dummy storage pools are often useful in
10513 connection with interfacing where no object will ever be allocated. If you
10514 compile the above example, you get the warning:
10517 p.adb:16:09: warning: allocation from empty storage pool
10518 p.adb:16:09: warning: Storage_Error will be raised at run time
10522 Of course in practice, there will not be any explicit allocators in the
10523 case of such an access declaration.
10525 @node Size of Variant Record Objects
10526 @section Size of Variant Record Objects
10527 @cindex Size, variant record objects
10528 @cindex Variant record objects, size
10531 In the case of variant record objects, there is a question whether Size gives
10532 information about a particular variant, or the maximum size required
10533 for any variant. Consider the following program
10535 @smallexample @c ada
10536 with Text_IO; use Text_IO;
10538 type R1 (A : Boolean := False) is record
10540 when True => X : Character;
10541 when False => null;
10549 Put_Line (Integer'Image (V1'Size));
10550 Put_Line (Integer'Image (V2'Size));
10555 Here we are dealing with a variant record, where the True variant
10556 requires 16 bits, and the False variant requires 8 bits.
10557 In the above example, both V1 and V2 contain the False variant,
10558 which is only 8 bits long. However, the result of running the
10567 The reason for the difference here is that the discriminant value of
10568 V1 is fixed, and will always be False. It is not possible to assign
10569 a True variant value to V1, therefore 8 bits is sufficient. On the
10570 other hand, in the case of V2, the initial discriminant value is
10571 False (from the default), but it is possible to assign a True
10572 variant value to V2, therefore 16 bits must be allocated for V2
10573 in the general case, even fewer bits may be needed at any particular
10574 point during the program execution.
10576 As can be seen from the output of this program, the @code{'Size}
10577 attribute applied to such an object in GNAT gives the actual allocated
10578 size of the variable, which is the largest size of any of the variants.
10579 The Ada Reference Manual is not completely clear on what choice should
10580 be made here, but the GNAT behavior seems most consistent with the
10581 language in the RM@.
10583 In some cases, it may be desirable to obtain the size of the current
10584 variant, rather than the size of the largest variant. This can be
10585 achieved in GNAT by making use of the fact that in the case of a
10586 subprogram parameter, GNAT does indeed return the size of the current
10587 variant (because a subprogram has no way of knowing how much space
10588 is actually allocated for the actual).
10590 Consider the following modified version of the above program:
10592 @smallexample @c ada
10593 with Text_IO; use Text_IO;
10595 type R1 (A : Boolean := False) is record
10597 when True => X : Character;
10598 when False => null;
10604 function Size (V : R1) return Integer is
10610 Put_Line (Integer'Image (V2'Size));
10611 Put_Line (Integer'IMage (Size (V2)));
10613 Put_Line (Integer'Image (V2'Size));
10614 Put_Line (Integer'IMage (Size (V2)));
10619 The output from this program is
10629 Here we see that while the @code{'Size} attribute always returns
10630 the maximum size, regardless of the current variant value, the
10631 @code{Size} function does indeed return the size of the current
10634 @node Biased Representation
10635 @section Biased Representation
10636 @cindex Size for biased representation
10637 @cindex Biased representation
10640 In the case of scalars with a range starting at other than zero, it is
10641 possible in some cases to specify a size smaller than the default minimum
10642 value, and in such cases, GNAT uses an unsigned biased representation,
10643 in which zero is used to represent the lower bound, and successive values
10644 represent successive values of the type.
10646 For example, suppose we have the declaration:
10648 @smallexample @c ada
10649 type Small is range -7 .. -4;
10650 for Small'Size use 2;
10654 Although the default size of type @code{Small} is 4, the @code{Size}
10655 clause is accepted by GNAT and results in the following representation
10659 -7 is represented as 2#00#
10660 -6 is represented as 2#01#
10661 -5 is represented as 2#10#
10662 -4 is represented as 2#11#
10666 Biased representation is only used if the specified @code{Size} clause
10667 cannot be accepted in any other manner. These reduced sizes that force
10668 biased representation can be used for all discrete types except for
10669 enumeration types for which a representation clause is given.
10671 @node Value_Size and Object_Size Clauses
10672 @section Value_Size and Object_Size Clauses
10674 @findex Object_Size
10675 @cindex Size, of objects
10678 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10679 number of bits required to hold values of type @code{T}.
10680 Although this interpretation was allowed in Ada 83, it was not required,
10681 and this requirement in practice can cause some significant difficulties.
10682 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10683 However, in Ada 95 and Ada 2005,
10684 @code{Natural'Size} is
10685 typically 31. This means that code may change in behavior when moving
10686 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10688 @smallexample @c ada
10689 type Rec is record;
10695 at 0 range 0 .. Natural'Size - 1;
10696 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10701 In the above code, since the typical size of @code{Natural} objects
10702 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10703 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10704 there are cases where the fact that the object size can exceed the
10705 size of the type causes surprises.
10707 To help get around this problem GNAT provides two implementation
10708 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10709 applied to a type, these attributes yield the size of the type
10710 (corresponding to the RM defined size attribute), and the size of
10711 objects of the type respectively.
10713 The @code{Object_Size} is used for determining the default size of
10714 objects and components. This size value can be referred to using the
10715 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10716 the basis of the determination of the size. The backend is free to
10717 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10718 character might be stored in 32 bits on a machine with no efficient
10719 byte access instructions such as the Alpha.
10721 The default rules for the value of @code{Object_Size} for
10722 discrete types are as follows:
10726 The @code{Object_Size} for base subtypes reflect the natural hardware
10727 size in bits (run the compiler with @option{-gnatS} to find those values
10728 for numeric types). Enumeration types and fixed-point base subtypes have
10729 8, 16, 32 or 64 bits for this size, depending on the range of values
10733 The @code{Object_Size} of a subtype is the same as the
10734 @code{Object_Size} of
10735 the type from which it is obtained.
10738 The @code{Object_Size} of a derived base type is copied from the parent
10739 base type, and the @code{Object_Size} of a derived first subtype is copied
10740 from the parent first subtype.
10744 The @code{Value_Size} attribute
10745 is the (minimum) number of bits required to store a value
10747 This value is used to determine how tightly to pack
10748 records or arrays with components of this type, and also affects
10749 the semantics of unchecked conversion (unchecked conversions where
10750 the @code{Value_Size} values differ generate a warning, and are potentially
10753 The default rules for the value of @code{Value_Size} are as follows:
10757 The @code{Value_Size} for a base subtype is the minimum number of bits
10758 required to store all values of the type (including the sign bit
10759 only if negative values are possible).
10762 If a subtype statically matches the first subtype of a given type, then it has
10763 by default the same @code{Value_Size} as the first subtype. This is a
10764 consequence of RM 13.1(14) (``if two subtypes statically match,
10765 then their subtype-specific aspects are the same''.)
10768 All other subtypes have a @code{Value_Size} corresponding to the minimum
10769 number of bits required to store all values of the subtype. For
10770 dynamic bounds, it is assumed that the value can range down or up
10771 to the corresponding bound of the ancestor
10775 The RM defined attribute @code{Size} corresponds to the
10776 @code{Value_Size} attribute.
10778 The @code{Size} attribute may be defined for a first-named subtype. This sets
10779 the @code{Value_Size} of
10780 the first-named subtype to the given value, and the
10781 @code{Object_Size} of this first-named subtype to the given value padded up
10782 to an appropriate boundary. It is a consequence of the default rules
10783 above that this @code{Object_Size} will apply to all further subtypes. On the
10784 other hand, @code{Value_Size} is affected only for the first subtype, any
10785 dynamic subtypes obtained from it directly, and any statically matching
10786 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
10788 @code{Value_Size} and
10789 @code{Object_Size} may be explicitly set for any subtype using
10790 an attribute definition clause. Note that the use of these attributes
10791 can cause the RM 13.1(14) rule to be violated. If two access types
10792 reference aliased objects whose subtypes have differing @code{Object_Size}
10793 values as a result of explicit attribute definition clauses, then it
10794 is erroneous to convert from one access subtype to the other.
10796 At the implementation level, Esize stores the Object_Size and the
10797 RM_Size field stores the @code{Value_Size} (and hence the value of the
10798 @code{Size} attribute,
10799 which, as noted above, is equivalent to @code{Value_Size}).
10801 To get a feel for the difference, consider the following examples (note
10802 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10805 Object_Size Value_Size
10807 type x1 is range 0 .. 5; 8 3
10809 type x2 is range 0 .. 5;
10810 for x2'size use 12; 16 12
10812 subtype x3 is x2 range 0 .. 3; 16 2
10814 subtype x4 is x2'base range 0 .. 10; 8 4
10816 subtype x5 is x2 range 0 .. dynamic; 16 3*
10818 subtype x6 is x2'base range 0 .. dynamic; 8 3*
10823 Note: the entries marked ``3*'' are not actually specified by the Ada
10824 Reference Manual, but it seems in the spirit of the RM rules to allocate
10825 the minimum number of bits (here 3, given the range for @code{x2})
10826 known to be large enough to hold the given range of values.
10828 So far, so good, but GNAT has to obey the RM rules, so the question is
10829 under what conditions must the RM @code{Size} be used.
10830 The following is a list
10831 of the occasions on which the RM @code{Size} must be used:
10835 Component size for packed arrays or records
10838 Value of the attribute @code{Size} for a type
10841 Warning about sizes not matching for unchecked conversion
10845 For record types, the @code{Object_Size} is always a multiple of the
10846 alignment of the type (this is true for all types). In some cases the
10847 @code{Value_Size} can be smaller. Consider:
10857 On a typical 32-bit architecture, the X component will be four bytes, and
10858 require four-byte alignment, and the Y component will be one byte. In this
10859 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10860 required to store a value of this type, and for example, it is permissible
10861 to have a component of type R in an outer array whose component size is
10862 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10863 since it must be rounded up so that this value is a multiple of the
10864 alignment (4 bytes = 32 bits).
10867 For all other types, the @code{Object_Size}
10868 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10869 Only @code{Size} may be specified for such types.
10871 @node Component_Size Clauses
10872 @section Component_Size Clauses
10873 @cindex Component_Size Clause
10876 Normally, the value specified in a component size clause must be consistent
10877 with the subtype of the array component with regard to size and alignment.
10878 In other words, the value specified must be at least equal to the size
10879 of this subtype, and must be a multiple of the alignment value.
10881 In addition, component size clauses are allowed which cause the array
10882 to be packed, by specifying a smaller value. A first case is for
10883 component size values in the range 1 through 63. The value specified
10884 must not be smaller than the Size of the subtype. GNAT will accurately
10885 honor all packing requests in this range. For example, if we have:
10887 @smallexample @c ada
10888 type r is array (1 .. 8) of Natural;
10889 for r'Component_Size use 31;
10893 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10894 Of course access to the components of such an array is considerably
10895 less efficient than if the natural component size of 32 is used.
10896 A second case is when the subtype of the component is a record type
10897 padded because of its default alignment. For example, if we have:
10899 @smallexample @c ada
10906 type a is array (1 .. 8) of r;
10907 for a'Component_Size use 72;
10911 then the resulting array has a length of 72 bytes, instead of 96 bytes
10912 if the alignment of the record (4) was obeyed.
10914 Note that there is no point in giving both a component size clause
10915 and a pragma Pack for the same array type. if such duplicate
10916 clauses are given, the pragma Pack will be ignored.
10918 @node Bit_Order Clauses
10919 @section Bit_Order Clauses
10920 @cindex Bit_Order Clause
10921 @cindex bit ordering
10922 @cindex ordering, of bits
10925 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10926 attribute. The specification may either correspond to the default bit
10927 order for the target, in which case the specification has no effect and
10928 places no additional restrictions, or it may be for the non-standard
10929 setting (that is the opposite of the default).
10931 In the case where the non-standard value is specified, the effect is
10932 to renumber bits within each byte, but the ordering of bytes is not
10933 affected. There are certain
10934 restrictions placed on component clauses as follows:
10938 @item Components fitting within a single storage unit.
10940 These are unrestricted, and the effect is merely to renumber bits. For
10941 example if we are on a little-endian machine with @code{Low_Order_First}
10942 being the default, then the following two declarations have exactly
10945 @smallexample @c ada
10948 B : Integer range 1 .. 120;
10952 A at 0 range 0 .. 0;
10953 B at 0 range 1 .. 7;
10958 B : Integer range 1 .. 120;
10961 for R2'Bit_Order use High_Order_First;
10964 A at 0 range 7 .. 7;
10965 B at 0 range 0 .. 6;
10970 The useful application here is to write the second declaration with the
10971 @code{Bit_Order} attribute definition clause, and know that it will be treated
10972 the same, regardless of whether the target is little-endian or big-endian.
10974 @item Components occupying an integral number of bytes.
10976 These are components that exactly fit in two or more bytes. Such component
10977 declarations are allowed, but have no effect, since it is important to realize
10978 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10979 In particular, the following attempt at getting an endian-independent integer
10982 @smallexample @c ada
10987 for R2'Bit_Order use High_Order_First;
10990 A at 0 range 0 .. 31;
10995 This declaration will result in a little-endian integer on a
10996 little-endian machine, and a big-endian integer on a big-endian machine.
10997 If byte flipping is required for interoperability between big- and
10998 little-endian machines, this must be explicitly programmed. This capability
10999 is not provided by @code{Bit_Order}.
11001 @item Components that are positioned across byte boundaries
11003 but do not occupy an integral number of bytes. Given that bytes are not
11004 reordered, such fields would occupy a non-contiguous sequence of bits
11005 in memory, requiring non-trivial code to reassemble. They are for this
11006 reason not permitted, and any component clause specifying such a layout
11007 will be flagged as illegal by GNAT@.
11012 Since the misconception that Bit_Order automatically deals with all
11013 endian-related incompatibilities is a common one, the specification of
11014 a component field that is an integral number of bytes will always
11015 generate a warning. This warning may be suppressed using @code{pragma
11016 Warnings (Off)} if desired. The following section contains additional
11017 details regarding the issue of byte ordering.
11019 @node Effect of Bit_Order on Byte Ordering
11020 @section Effect of Bit_Order on Byte Ordering
11021 @cindex byte ordering
11022 @cindex ordering, of bytes
11025 In this section we will review the effect of the @code{Bit_Order} attribute
11026 definition clause on byte ordering. Briefly, it has no effect at all, but
11027 a detailed example will be helpful. Before giving this
11028 example, let us review the precise
11029 definition of the effect of defining @code{Bit_Order}. The effect of a
11030 non-standard bit order is described in section 15.5.3 of the Ada
11034 2 A bit ordering is a method of interpreting the meaning of
11035 the storage place attributes.
11039 To understand the precise definition of storage place attributes in
11040 this context, we visit section 13.5.1 of the manual:
11043 13 A record_representation_clause (without the mod_clause)
11044 specifies the layout. The storage place attributes (see 13.5.2)
11045 are taken from the values of the position, first_bit, and last_bit
11046 expressions after normalizing those values so that first_bit is
11047 less than Storage_Unit.
11051 The critical point here is that storage places are taken from
11052 the values after normalization, not before. So the @code{Bit_Order}
11053 interpretation applies to normalized values. The interpretation
11054 is described in the later part of the 15.5.3 paragraph:
11057 2 A bit ordering is a method of interpreting the meaning of
11058 the storage place attributes. High_Order_First (known in the
11059 vernacular as ``big endian'') means that the first bit of a
11060 storage element (bit 0) is the most significant bit (interpreting
11061 the sequence of bits that represent a component as an unsigned
11062 integer value). Low_Order_First (known in the vernacular as
11063 ``little endian'') means the opposite: the first bit is the
11068 Note that the numbering is with respect to the bits of a storage
11069 unit. In other words, the specification affects only the numbering
11070 of bits within a single storage unit.
11072 We can make the effect clearer by giving an example.
11074 Suppose that we have an external device which presents two bytes, the first
11075 byte presented, which is the first (low addressed byte) of the two byte
11076 record is called Master, and the second byte is called Slave.
11078 The left most (most significant bit is called Control for each byte, and
11079 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
11080 (least significant) bit.
11082 On a big-endian machine, we can write the following representation clause
11084 @smallexample @c ada
11085 type Data is record
11086 Master_Control : Bit;
11094 Slave_Control : Bit;
11104 for Data use record
11105 Master_Control at 0 range 0 .. 0;
11106 Master_V1 at 0 range 1 .. 1;
11107 Master_V2 at 0 range 2 .. 2;
11108 Master_V3 at 0 range 3 .. 3;
11109 Master_V4 at 0 range 4 .. 4;
11110 Master_V5 at 0 range 5 .. 5;
11111 Master_V6 at 0 range 6 .. 6;
11112 Master_V7 at 0 range 7 .. 7;
11113 Slave_Control at 1 range 0 .. 0;
11114 Slave_V1 at 1 range 1 .. 1;
11115 Slave_V2 at 1 range 2 .. 2;
11116 Slave_V3 at 1 range 3 .. 3;
11117 Slave_V4 at 1 range 4 .. 4;
11118 Slave_V5 at 1 range 5 .. 5;
11119 Slave_V6 at 1 range 6 .. 6;
11120 Slave_V7 at 1 range 7 .. 7;
11125 Now if we move this to a little endian machine, then the bit ordering within
11126 the byte is backwards, so we have to rewrite the record rep clause as:
11128 @smallexample @c ada
11129 for Data use record
11130 Master_Control at 0 range 7 .. 7;
11131 Master_V1 at 0 range 6 .. 6;
11132 Master_V2 at 0 range 5 .. 5;
11133 Master_V3 at 0 range 4 .. 4;
11134 Master_V4 at 0 range 3 .. 3;
11135 Master_V5 at 0 range 2 .. 2;
11136 Master_V6 at 0 range 1 .. 1;
11137 Master_V7 at 0 range 0 .. 0;
11138 Slave_Control at 1 range 7 .. 7;
11139 Slave_V1 at 1 range 6 .. 6;
11140 Slave_V2 at 1 range 5 .. 5;
11141 Slave_V3 at 1 range 4 .. 4;
11142 Slave_V4 at 1 range 3 .. 3;
11143 Slave_V5 at 1 range 2 .. 2;
11144 Slave_V6 at 1 range 1 .. 1;
11145 Slave_V7 at 1 range 0 .. 0;
11150 It is a nuisance to have to rewrite the clause, especially if
11151 the code has to be maintained on both machines. However,
11152 this is a case that we can handle with the
11153 @code{Bit_Order} attribute if it is implemented.
11154 Note that the implementation is not required on byte addressed
11155 machines, but it is indeed implemented in GNAT.
11156 This means that we can simply use the
11157 first record clause, together with the declaration
11159 @smallexample @c ada
11160 for Data'Bit_Order use High_Order_First;
11164 and the effect is what is desired, namely the layout is exactly the same,
11165 independent of whether the code is compiled on a big-endian or little-endian
11168 The important point to understand is that byte ordering is not affected.
11169 A @code{Bit_Order} attribute definition never affects which byte a field
11170 ends up in, only where it ends up in that byte.
11171 To make this clear, let us rewrite the record rep clause of the previous
11174 @smallexample @c ada
11175 for Data'Bit_Order use High_Order_First;
11176 for Data use record
11177 Master_Control at 0 range 0 .. 0;
11178 Master_V1 at 0 range 1 .. 1;
11179 Master_V2 at 0 range 2 .. 2;
11180 Master_V3 at 0 range 3 .. 3;
11181 Master_V4 at 0 range 4 .. 4;
11182 Master_V5 at 0 range 5 .. 5;
11183 Master_V6 at 0 range 6 .. 6;
11184 Master_V7 at 0 range 7 .. 7;
11185 Slave_Control at 0 range 8 .. 8;
11186 Slave_V1 at 0 range 9 .. 9;
11187 Slave_V2 at 0 range 10 .. 10;
11188 Slave_V3 at 0 range 11 .. 11;
11189 Slave_V4 at 0 range 12 .. 12;
11190 Slave_V5 at 0 range 13 .. 13;
11191 Slave_V6 at 0 range 14 .. 14;
11192 Slave_V7 at 0 range 15 .. 15;
11197 This is exactly equivalent to saying (a repeat of the first example):
11199 @smallexample @c ada
11200 for Data'Bit_Order use High_Order_First;
11201 for Data use record
11202 Master_Control at 0 range 0 .. 0;
11203 Master_V1 at 0 range 1 .. 1;
11204 Master_V2 at 0 range 2 .. 2;
11205 Master_V3 at 0 range 3 .. 3;
11206 Master_V4 at 0 range 4 .. 4;
11207 Master_V5 at 0 range 5 .. 5;
11208 Master_V6 at 0 range 6 .. 6;
11209 Master_V7 at 0 range 7 .. 7;
11210 Slave_Control at 1 range 0 .. 0;
11211 Slave_V1 at 1 range 1 .. 1;
11212 Slave_V2 at 1 range 2 .. 2;
11213 Slave_V3 at 1 range 3 .. 3;
11214 Slave_V4 at 1 range 4 .. 4;
11215 Slave_V5 at 1 range 5 .. 5;
11216 Slave_V6 at 1 range 6 .. 6;
11217 Slave_V7 at 1 range 7 .. 7;
11222 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
11223 field. The storage place attributes are obtained by normalizing the
11224 values given so that the @code{First_Bit} value is less than 8. After
11225 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
11226 we specified in the other case.
11228 Now one might expect that the @code{Bit_Order} attribute might affect
11229 bit numbering within the entire record component (two bytes in this
11230 case, thus affecting which byte fields end up in), but that is not
11231 the way this feature is defined, it only affects numbering of bits,
11232 not which byte they end up in.
11234 Consequently it never makes sense to specify a starting bit number
11235 greater than 7 (for a byte addressable field) if an attribute
11236 definition for @code{Bit_Order} has been given, and indeed it
11237 may be actively confusing to specify such a value, so the compiler
11238 generates a warning for such usage.
11240 If you do need to control byte ordering then appropriate conditional
11241 values must be used. If in our example, the slave byte came first on
11242 some machines we might write:
11244 @smallexample @c ada
11245 Master_Byte_First constant Boolean := @dots{};
11247 Master_Byte : constant Natural :=
11248 1 - Boolean'Pos (Master_Byte_First);
11249 Slave_Byte : constant Natural :=
11250 Boolean'Pos (Master_Byte_First);
11252 for Data'Bit_Order use High_Order_First;
11253 for Data use record
11254 Master_Control at Master_Byte range 0 .. 0;
11255 Master_V1 at Master_Byte range 1 .. 1;
11256 Master_V2 at Master_Byte range 2 .. 2;
11257 Master_V3 at Master_Byte range 3 .. 3;
11258 Master_V4 at Master_Byte range 4 .. 4;
11259 Master_V5 at Master_Byte range 5 .. 5;
11260 Master_V6 at Master_Byte range 6 .. 6;
11261 Master_V7 at Master_Byte range 7 .. 7;
11262 Slave_Control at Slave_Byte range 0 .. 0;
11263 Slave_V1 at Slave_Byte range 1 .. 1;
11264 Slave_V2 at Slave_Byte range 2 .. 2;
11265 Slave_V3 at Slave_Byte range 3 .. 3;
11266 Slave_V4 at Slave_Byte range 4 .. 4;
11267 Slave_V5 at Slave_Byte range 5 .. 5;
11268 Slave_V6 at Slave_Byte range 6 .. 6;
11269 Slave_V7 at Slave_Byte range 7 .. 7;
11274 Now to switch between machines, all that is necessary is
11275 to set the boolean constant @code{Master_Byte_First} in
11276 an appropriate manner.
11278 @node Pragma Pack for Arrays
11279 @section Pragma Pack for Arrays
11280 @cindex Pragma Pack (for arrays)
11283 Pragma @code{Pack} applied to an array has no effect unless the component type
11284 is packable. For a component type to be packable, it must be one of the
11291 Any type whose size is specified with a size clause
11293 Any packed array type with a static size
11295 Any record type padded because of its default alignment
11299 For all these cases, if the component subtype size is in the range
11300 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
11301 component size were specified giving the component subtype size.
11302 For example if we have:
11304 @smallexample @c ada
11305 type r is range 0 .. 17;
11307 type ar is array (1 .. 8) of r;
11312 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
11313 and the size of the array @code{ar} will be exactly 40 bits.
11315 Note that in some cases this rather fierce approach to packing can produce
11316 unexpected effects. For example, in Ada 95 and Ada 2005,
11317 subtype @code{Natural} typically has a size of 31, meaning that if you
11318 pack an array of @code{Natural}, you get 31-bit
11319 close packing, which saves a few bits, but results in far less efficient
11320 access. Since many other Ada compilers will ignore such a packing request,
11321 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
11322 might not be what is intended. You can easily remove this warning by
11323 using an explicit @code{Component_Size} setting instead, which never generates
11324 a warning, since the intention of the programmer is clear in this case.
11326 GNAT treats packed arrays in one of two ways. If the size of the array is
11327 known at compile time and is less than 64 bits, then internally the array
11328 is represented as a single modular type, of exactly the appropriate number
11329 of bits. If the length is greater than 63 bits, or is not known at compile
11330 time, then the packed array is represented as an array of bytes, and the
11331 length is always a multiple of 8 bits.
11333 Note that to represent a packed array as a modular type, the alignment must
11334 be suitable for the modular type involved. For example, on typical machines
11335 a 32-bit packed array will be represented by a 32-bit modular integer with
11336 an alignment of four bytes. If you explicitly override the default alignment
11337 with an alignment clause that is too small, the modular representation
11338 cannot be used. For example, consider the following set of declarations:
11340 @smallexample @c ada
11341 type R is range 1 .. 3;
11342 type S is array (1 .. 31) of R;
11343 for S'Component_Size use 2;
11345 for S'Alignment use 1;
11349 If the alignment clause were not present, then a 62-bit modular
11350 representation would be chosen (typically with an alignment of 4 or 8
11351 bytes depending on the target). But the default alignment is overridden
11352 with the explicit alignment clause. This means that the modular
11353 representation cannot be used, and instead the array of bytes
11354 representation must be used, meaning that the length must be a multiple
11355 of 8. Thus the above set of declarations will result in a diagnostic
11356 rejecting the size clause and noting that the minimum size allowed is 64.
11358 @cindex Pragma Pack (for type Natural)
11359 @cindex Pragma Pack warning
11361 One special case that is worth noting occurs when the base type of the
11362 component size is 8/16/32 and the subtype is one bit less. Notably this
11363 occurs with subtype @code{Natural}. Consider:
11365 @smallexample @c ada
11366 type Arr is array (1 .. 32) of Natural;
11371 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11372 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11373 Ada 83 compilers did not attempt 31 bit packing.
11375 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11376 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11377 substantial unintended performance penalty when porting legacy Ada 83 code.
11378 To help prevent this, GNAT generates a warning in such cases. If you really
11379 want 31 bit packing in a case like this, you can set the component size
11382 @smallexample @c ada
11383 type Arr is array (1 .. 32) of Natural;
11384 for Arr'Component_Size use 31;
11388 Here 31-bit packing is achieved as required, and no warning is generated,
11389 since in this case the programmer intention is clear.
11391 @node Pragma Pack for Records
11392 @section Pragma Pack for Records
11393 @cindex Pragma Pack (for records)
11396 Pragma @code{Pack} applied to a record will pack the components to reduce
11397 wasted space from alignment gaps and by reducing the amount of space
11398 taken by components. We distinguish between @emph{packable} components and
11399 @emph{non-packable} components.
11400 Components of the following types are considered packable:
11403 All primitive types are packable.
11406 Small packed arrays, whose size does not exceed 64 bits, and where the
11407 size is statically known at compile time, are represented internally
11408 as modular integers, and so they are also packable.
11413 All packable components occupy the exact number of bits corresponding to
11414 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11415 can start on an arbitrary bit boundary.
11417 All other types are non-packable, they occupy an integral number of
11419 are placed at a boundary corresponding to their alignment requirements.
11421 For example, consider the record
11423 @smallexample @c ada
11424 type Rb1 is array (1 .. 13) of Boolean;
11427 type Rb2 is array (1 .. 65) of Boolean;
11442 The representation for the record x2 is as follows:
11444 @smallexample @c ada
11445 for x2'Size use 224;
11447 l1 at 0 range 0 .. 0;
11448 l2 at 0 range 1 .. 64;
11449 l3 at 12 range 0 .. 31;
11450 l4 at 16 range 0 .. 0;
11451 l5 at 16 range 1 .. 13;
11452 l6 at 18 range 0 .. 71;
11457 Studying this example, we see that the packable fields @code{l1}
11459 of length equal to their sizes, and placed at specific bit boundaries (and
11460 not byte boundaries) to
11461 eliminate padding. But @code{l3} is of a non-packable float type, so
11462 it is on the next appropriate alignment boundary.
11464 The next two fields are fully packable, so @code{l4} and @code{l5} are
11465 minimally packed with no gaps. However, type @code{Rb2} is a packed
11466 array that is longer than 64 bits, so it is itself non-packable. Thus
11467 the @code{l6} field is aligned to the next byte boundary, and takes an
11468 integral number of bytes, i.e.@: 72 bits.
11470 @node Record Representation Clauses
11471 @section Record Representation Clauses
11472 @cindex Record Representation Clause
11475 Record representation clauses may be given for all record types, including
11476 types obtained by record extension. Component clauses are allowed for any
11477 static component. The restrictions on component clauses depend on the type
11480 @cindex Component Clause
11481 For all components of an elementary type, the only restriction on component
11482 clauses is that the size must be at least the 'Size value of the type
11483 (actually the Value_Size). There are no restrictions due to alignment,
11484 and such components may freely cross storage boundaries.
11486 Packed arrays with a size up to and including 64 bits are represented
11487 internally using a modular type with the appropriate number of bits, and
11488 thus the same lack of restriction applies. For example, if you declare:
11490 @smallexample @c ada
11491 type R is array (1 .. 49) of Boolean;
11497 then a component clause for a component of type R may start on any
11498 specified bit boundary, and may specify a value of 49 bits or greater.
11500 For packed bit arrays that are longer than 64 bits, there are two
11501 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11502 including the important case of single bits or boolean values, then
11503 there are no limitations on placement of such components, and they
11504 may start and end at arbitrary bit boundaries.
11506 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11507 an array of this type longer than 64 bits must always be placed on
11508 on a storage unit (byte) boundary and occupy an integral number
11509 of storage units (bytes). Any component clause that does not
11510 meet this requirement will be rejected.
11512 Any aliased component, or component of an aliased type, must
11513 have its normal alignment and size. A component clause that
11514 does not meet this requirement will be rejected.
11516 The tag field of a tagged type always occupies an address sized field at
11517 the start of the record. No component clause may attempt to overlay this
11518 tag. When a tagged type appears as a component, the tag field must have
11521 In the case of a record extension T1, of a type T, no component clause applied
11522 to the type T1 can specify a storage location that would overlap the first
11523 T'Size bytes of the record.
11525 For all other component types, including non-bit-packed arrays,
11526 the component can be placed at an arbitrary bit boundary,
11527 so for example, the following is permitted:
11529 @smallexample @c ada
11530 type R is array (1 .. 10) of Boolean;
11539 G at 0 range 0 .. 0;
11540 H at 0 range 1 .. 1;
11541 L at 0 range 2 .. 81;
11542 R at 0 range 82 .. 161;
11547 Note: the above rules apply to recent releases of GNAT 5.
11548 In GNAT 3, there are more severe restrictions on larger components.
11549 For non-primitive types, including packed arrays with a size greater than
11550 64 bits, component clauses must respect the alignment requirement of the
11551 type, in particular, always starting on a byte boundary, and the length
11552 must be a multiple of the storage unit.
11554 @node Enumeration Clauses
11555 @section Enumeration Clauses
11557 The only restriction on enumeration clauses is that the range of values
11558 must be representable. For the signed case, if one or more of the
11559 representation values are negative, all values must be in the range:
11561 @smallexample @c ada
11562 System.Min_Int .. System.Max_Int
11566 For the unsigned case, where all values are nonnegative, the values must
11569 @smallexample @c ada
11570 0 .. System.Max_Binary_Modulus;
11574 A @emph{confirming} representation clause is one in which the values range
11575 from 0 in sequence, i.e.@: a clause that confirms the default representation
11576 for an enumeration type.
11577 Such a confirming representation
11578 is permitted by these rules, and is specially recognized by the compiler so
11579 that no extra overhead results from the use of such a clause.
11581 If an array has an index type which is an enumeration type to which an
11582 enumeration clause has been applied, then the array is stored in a compact
11583 manner. Consider the declarations:
11585 @smallexample @c ada
11586 type r is (A, B, C);
11587 for r use (A => 1, B => 5, C => 10);
11588 type t is array (r) of Character;
11592 The array type t corresponds to a vector with exactly three elements and
11593 has a default size equal to @code{3*Character'Size}. This ensures efficient
11594 use of space, but means that accesses to elements of the array will incur
11595 the overhead of converting representation values to the corresponding
11596 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11598 @node Address Clauses
11599 @section Address Clauses
11600 @cindex Address Clause
11602 The reference manual allows a general restriction on representation clauses,
11603 as found in RM 13.1(22):
11606 An implementation need not support representation
11607 items containing nonstatic expressions, except that
11608 an implementation should support a representation item
11609 for a given entity if each nonstatic expression in the
11610 representation item is a name that statically denotes
11611 a constant declared before the entity.
11615 In practice this is applicable only to address clauses, since this is the
11616 only case in which a non-static expression is permitted by the syntax. As
11617 the AARM notes in sections 13.1 (22.a-22.h):
11620 22.a Reason: This is to avoid the following sort of thing:
11622 22.b X : Integer := F(@dots{});
11623 Y : Address := G(@dots{});
11624 for X'Address use Y;
11626 22.c In the above, we have to evaluate the
11627 initialization expression for X before we
11628 know where to put the result. This seems
11629 like an unreasonable implementation burden.
11631 22.d The above code should instead be written
11634 22.e Y : constant Address := G(@dots{});
11635 X : Integer := F(@dots{});
11636 for X'Address use Y;
11638 22.f This allows the expression ``Y'' to be safely
11639 evaluated before X is created.
11641 22.g The constant could be a formal parameter of mode in.
11643 22.h An implementation can support other nonstatic
11644 expressions if it wants to. Expressions of type
11645 Address are hardly ever static, but their value
11646 might be known at compile time anyway in many
11651 GNAT does indeed permit many additional cases of non-static expressions. In
11652 particular, if the type involved is elementary there are no restrictions
11653 (since in this case, holding a temporary copy of the initialization value,
11654 if one is present, is inexpensive). In addition, if there is no implicit or
11655 explicit initialization, then there are no restrictions. GNAT will reject
11656 only the case where all three of these conditions hold:
11661 The type of the item is non-elementary (e.g.@: a record or array).
11664 There is explicit or implicit initialization required for the object.
11665 Note that access values are always implicitly initialized, and also
11666 in GNAT, certain bit-packed arrays (those having a dynamic length or
11667 a length greater than 64) will also be implicitly initialized to zero.
11670 The address value is non-static. Here GNAT is more permissive than the
11671 RM, and allows the address value to be the address of a previously declared
11672 stand-alone variable, as long as it does not itself have an address clause.
11674 @smallexample @c ada
11675 Anchor : Some_Initialized_Type;
11676 Overlay : Some_Initialized_Type;
11677 for Overlay'Address use Anchor'Address;
11681 However, the prefix of the address clause cannot be an array component, or
11682 a component of a discriminated record.
11687 As noted above in section 22.h, address values are typically non-static. In
11688 particular the To_Address function, even if applied to a literal value, is
11689 a non-static function call. To avoid this minor annoyance, GNAT provides
11690 the implementation defined attribute 'To_Address. The following two
11691 expressions have identical values:
11695 @smallexample @c ada
11696 To_Address (16#1234_0000#)
11697 System'To_Address (16#1234_0000#);
11701 except that the second form is considered to be a static expression, and
11702 thus when used as an address clause value is always permitted.
11705 Additionally, GNAT treats as static an address clause that is an
11706 unchecked_conversion of a static integer value. This simplifies the porting
11707 of legacy code, and provides a portable equivalent to the GNAT attribute
11710 Another issue with address clauses is the interaction with alignment
11711 requirements. When an address clause is given for an object, the address
11712 value must be consistent with the alignment of the object (which is usually
11713 the same as the alignment of the type of the object). If an address clause
11714 is given that specifies an inappropriately aligned address value, then the
11715 program execution is erroneous.
11717 Since this source of erroneous behavior can have unfortunate effects, GNAT
11718 checks (at compile time if possible, generating a warning, or at execution
11719 time with a run-time check) that the alignment is appropriate. If the
11720 run-time check fails, then @code{Program_Error} is raised. This run-time
11721 check is suppressed if range checks are suppressed, or if the special GNAT
11722 check Alignment_Check is suppressed, or if
11723 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11725 Finally, GNAT does not permit overlaying of objects of controlled types or
11726 composite types containing a controlled component. In most cases, the compiler
11727 can detect an attempt at such overlays and will generate a warning at compile
11728 time and a Program_Error exception at run time.
11731 An address clause cannot be given for an exported object. More
11732 understandably the real restriction is that objects with an address
11733 clause cannot be exported. This is because such variables are not
11734 defined by the Ada program, so there is no external object to export.
11737 It is permissible to give an address clause and a pragma Import for the
11738 same object. In this case, the variable is not really defined by the
11739 Ada program, so there is no external symbol to be linked. The link name
11740 and the external name are ignored in this case. The reason that we allow this
11741 combination is that it provides a useful idiom to avoid unwanted
11742 initializations on objects with address clauses.
11744 When an address clause is given for an object that has implicit or
11745 explicit initialization, then by default initialization takes place. This
11746 means that the effect of the object declaration is to overwrite the
11747 memory at the specified address. This is almost always not what the
11748 programmer wants, so GNAT will output a warning:
11758 for Ext'Address use System'To_Address (16#1234_1234#);
11760 >>> warning: implicit initialization of "Ext" may
11761 modify overlaid storage
11762 >>> warning: use pragma Import for "Ext" to suppress
11763 initialization (RM B(24))
11769 As indicated by the warning message, the solution is to use a (dummy) pragma
11770 Import to suppress this initialization. The pragma tell the compiler that the
11771 object is declared and initialized elsewhere. The following package compiles
11772 without warnings (and the initialization is suppressed):
11774 @smallexample @c ada
11782 for Ext'Address use System'To_Address (16#1234_1234#);
11783 pragma Import (Ada, Ext);
11788 A final issue with address clauses involves their use for overlaying
11789 variables, as in the following example:
11790 @cindex Overlaying of objects
11792 @smallexample @c ada
11795 for B'Address use A'Address;
11799 or alternatively, using the form recommended by the RM:
11801 @smallexample @c ada
11803 Addr : constant Address := A'Address;
11805 for B'Address use Addr;
11809 In both of these cases, @code{A}
11810 and @code{B} become aliased to one another via the
11811 address clause. This use of address clauses to overlay
11812 variables, achieving an effect similar to unchecked
11813 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11814 the effect is implementation defined. Furthermore, the
11815 Ada RM specifically recommends that in a situation
11816 like this, @code{B} should be subject to the following
11817 implementation advice (RM 13.3(19)):
11820 19 If the Address of an object is specified, or it is imported
11821 or exported, then the implementation should not perform
11822 optimizations based on assumptions of no aliases.
11826 GNAT follows this recommendation, and goes further by also applying
11827 this recommendation to the overlaid variable (@code{A}
11828 in the above example) in this case. This means that the overlay
11829 works "as expected", in that a modification to one of the variables
11830 will affect the value of the other.
11832 @node Effect of Convention on Representation
11833 @section Effect of Convention on Representation
11834 @cindex Convention, effect on representation
11837 Normally the specification of a foreign language convention for a type or
11838 an object has no effect on the chosen representation. In particular, the
11839 representation chosen for data in GNAT generally meets the standard system
11840 conventions, and for example records are laid out in a manner that is
11841 consistent with C@. This means that specifying convention C (for example)
11844 There are four exceptions to this general rule:
11848 @item Convention Fortran and array subtypes
11849 If pragma Convention Fortran is specified for an array subtype, then in
11850 accordance with the implementation advice in section 3.6.2(11) of the
11851 Ada Reference Manual, the array will be stored in a Fortran-compatible
11852 column-major manner, instead of the normal default row-major order.
11854 @item Convention C and enumeration types
11855 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11856 to accommodate all values of the type. For example, for the enumeration
11859 @smallexample @c ada
11860 type Color is (Red, Green, Blue);
11864 8 bits is sufficient to store all values of the type, so by default, objects
11865 of type @code{Color} will be represented using 8 bits. However, normal C
11866 convention is to use 32 bits for all enum values in C, since enum values
11867 are essentially of type int. If pragma @code{Convention C} is specified for an
11868 Ada enumeration type, then the size is modified as necessary (usually to
11869 32 bits) to be consistent with the C convention for enum values.
11871 Note that this treatment applies only to types. If Convention C is given for
11872 an enumeration object, where the enumeration type is not Convention C, then
11873 Object_Size bits are allocated. For example, for a normal enumeration type,
11874 with less than 256 elements, only 8 bits will be allocated for the object.
11875 Since this may be a surprise in terms of what C expects, GNAT will issue a
11876 warning in this situation. The warning can be suppressed by giving an explicit
11877 size clause specifying the desired size.
11879 @item Convention C/Fortran and Boolean types
11880 In C, the usual convention for boolean values, that is values used for
11881 conditions, is that zero represents false, and nonzero values represent
11882 true. In Ada, the normal convention is that two specific values, typically
11883 0/1, are used to represent false/true respectively.
11885 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11886 value represents true).
11888 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11889 C or Fortran convention for a derived Boolean, as in the following example:
11891 @smallexample @c ada
11892 type C_Switch is new Boolean;
11893 pragma Convention (C, C_Switch);
11897 then the GNAT generated code will treat any nonzero value as true. For truth
11898 values generated by GNAT, the conventional value 1 will be used for True, but
11899 when one of these values is read, any nonzero value is treated as True.
11901 @item Access types on OpenVMS
11902 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11903 arrays) are 64-bits long. An exception to this rule is for the case of
11904 C-convention access types where there is no explicit size clause present (or
11905 inherited for derived types). In this case, GNAT chooses to make these
11906 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11907 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11911 @node Determining the Representations chosen by GNAT
11912 @section Determining the Representations chosen by GNAT
11913 @cindex Representation, determination of
11914 @cindex @option{-gnatR} switch
11917 Although the descriptions in this section are intended to be complete, it is
11918 often easier to simply experiment to see what GNAT accepts and what the
11919 effect is on the layout of types and objects.
11921 As required by the Ada RM, if a representation clause is not accepted, then
11922 it must be rejected as illegal by the compiler. However, when a
11923 representation clause or pragma is accepted, there can still be questions
11924 of what the compiler actually does. For example, if a partial record
11925 representation clause specifies the location of some components and not
11926 others, then where are the non-specified components placed? Or if pragma
11927 @code{Pack} is used on a record, then exactly where are the resulting
11928 fields placed? The section on pragma @code{Pack} in this chapter can be
11929 used to answer the second question, but it is often easier to just see
11930 what the compiler does.
11932 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
11933 with this option, then the compiler will output information on the actual
11934 representations chosen, in a format similar to source representation
11935 clauses. For example, if we compile the package:
11937 @smallexample @c ada
11939 type r (x : boolean) is tagged record
11941 when True => S : String (1 .. 100);
11942 when False => null;
11946 type r2 is new r (false) with record
11951 y2 at 16 range 0 .. 31;
11958 type x1 is array (1 .. 10) of x;
11959 for x1'component_size use 11;
11961 type ia is access integer;
11963 type Rb1 is array (1 .. 13) of Boolean;
11966 type Rb2 is array (1 .. 65) of Boolean;
11982 using the switch @option{-gnatR} we obtain the following output:
11985 Representation information for unit q
11986 -------------------------------------
11989 for r'Alignment use 4;
11991 x at 4 range 0 .. 7;
11992 _tag at 0 range 0 .. 31;
11993 s at 5 range 0 .. 799;
11996 for r2'Size use 160;
11997 for r2'Alignment use 4;
11999 x at 4 range 0 .. 7;
12000 _tag at 0 range 0 .. 31;
12001 _parent at 0 range 0 .. 63;
12002 y2 at 16 range 0 .. 31;
12006 for x'Alignment use 1;
12008 y at 0 range 0 .. 7;
12011 for x1'Size use 112;
12012 for x1'Alignment use 1;
12013 for x1'Component_Size use 11;
12015 for rb1'Size use 13;
12016 for rb1'Alignment use 2;
12017 for rb1'Component_Size use 1;
12019 for rb2'Size use 72;
12020 for rb2'Alignment use 1;
12021 for rb2'Component_Size use 1;
12023 for x2'Size use 224;
12024 for x2'Alignment use 4;
12026 l1 at 0 range 0 .. 0;
12027 l2 at 0 range 1 .. 64;
12028 l3 at 12 range 0 .. 31;
12029 l4 at 16 range 0 .. 0;
12030 l5 at 16 range 1 .. 13;
12031 l6 at 18 range 0 .. 71;
12036 The Size values are actually the Object_Size, i.e.@: the default size that
12037 will be allocated for objects of the type.
12038 The ?? size for type r indicates that we have a variant record, and the
12039 actual size of objects will depend on the discriminant value.
12041 The Alignment values show the actual alignment chosen by the compiler
12042 for each record or array type.
12044 The record representation clause for type r shows where all fields
12045 are placed, including the compiler generated tag field (whose location
12046 cannot be controlled by the programmer).
12048 The record representation clause for the type extension r2 shows all the
12049 fields present, including the parent field, which is a copy of the fields
12050 of the parent type of r2, i.e.@: r1.
12052 The component size and size clauses for types rb1 and rb2 show
12053 the exact effect of pragma @code{Pack} on these arrays, and the record
12054 representation clause for type x2 shows how pragma @code{Pack} affects
12057 In some cases, it may be useful to cut and paste the representation clauses
12058 generated by the compiler into the original source to fix and guarantee
12059 the actual representation to be used.
12061 @node Standard Library Routines
12062 @chapter Standard Library Routines
12065 The Ada Reference Manual contains in Annex A a full description of an
12066 extensive set of standard library routines that can be used in any Ada
12067 program, and which must be provided by all Ada compilers. They are
12068 analogous to the standard C library used by C programs.
12070 GNAT implements all of the facilities described in annex A, and for most
12071 purposes the description in the Ada Reference Manual, or appropriate Ada
12072 text book, will be sufficient for making use of these facilities.
12074 In the case of the input-output facilities,
12075 @xref{The Implementation of Standard I/O},
12076 gives details on exactly how GNAT interfaces to the
12077 file system. For the remaining packages, the Ada Reference Manual
12078 should be sufficient. The following is a list of the packages included,
12079 together with a brief description of the functionality that is provided.
12081 For completeness, references are included to other predefined library
12082 routines defined in other sections of the Ada Reference Manual (these are
12083 cross-indexed from Annex A).
12087 This is a parent package for all the standard library packages. It is
12088 usually included implicitly in your program, and itself contains no
12089 useful data or routines.
12091 @item Ada.Calendar (9.6)
12092 @code{Calendar} provides time of day access, and routines for
12093 manipulating times and durations.
12095 @item Ada.Characters (A.3.1)
12096 This is a dummy parent package that contains no useful entities
12098 @item Ada.Characters.Handling (A.3.2)
12099 This package provides some basic character handling capabilities,
12100 including classification functions for classes of characters (e.g.@: test
12101 for letters, or digits).
12103 @item Ada.Characters.Latin_1 (A.3.3)
12104 This package includes a complete set of definitions of the characters
12105 that appear in type CHARACTER@. It is useful for writing programs that
12106 will run in international environments. For example, if you want an
12107 upper case E with an acute accent in a string, it is often better to use
12108 the definition of @code{UC_E_Acute} in this package. Then your program
12109 will print in an understandable manner even if your environment does not
12110 support these extended characters.
12112 @item Ada.Command_Line (A.15)
12113 This package provides access to the command line parameters and the name
12114 of the current program (analogous to the use of @code{argc} and @code{argv}
12115 in C), and also allows the exit status for the program to be set in a
12116 system-independent manner.
12118 @item Ada.Decimal (F.2)
12119 This package provides constants describing the range of decimal numbers
12120 implemented, and also a decimal divide routine (analogous to the COBOL
12121 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
12123 @item Ada.Direct_IO (A.8.4)
12124 This package provides input-output using a model of a set of records of
12125 fixed-length, containing an arbitrary definite Ada type, indexed by an
12126 integer record number.
12128 @item Ada.Dynamic_Priorities (D.5)
12129 This package allows the priorities of a task to be adjusted dynamically
12130 as the task is running.
12132 @item Ada.Exceptions (11.4.1)
12133 This package provides additional information on exceptions, and also
12134 contains facilities for treating exceptions as data objects, and raising
12135 exceptions with associated messages.
12137 @item Ada.Finalization (7.6)
12138 This package contains the declarations and subprograms to support the
12139 use of controlled types, providing for automatic initialization and
12140 finalization (analogous to the constructors and destructors of C++)
12142 @item Ada.Interrupts (C.3.2)
12143 This package provides facilities for interfacing to interrupts, which
12144 includes the set of signals or conditions that can be raised and
12145 recognized as interrupts.
12147 @item Ada.Interrupts.Names (C.3.2)
12148 This package provides the set of interrupt names (actually signal
12149 or condition names) that can be handled by GNAT@.
12151 @item Ada.IO_Exceptions (A.13)
12152 This package defines the set of exceptions that can be raised by use of
12153 the standard IO packages.
12156 This package contains some standard constants and exceptions used
12157 throughout the numerics packages. Note that the constants pi and e are
12158 defined here, and it is better to use these definitions than rolling
12161 @item Ada.Numerics.Complex_Elementary_Functions
12162 Provides the implementation of standard elementary functions (such as
12163 log and trigonometric functions) operating on complex numbers using the
12164 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
12165 created by the package @code{Numerics.Complex_Types}.
12167 @item Ada.Numerics.Complex_Types
12168 This is a predefined instantiation of
12169 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
12170 build the type @code{Complex} and @code{Imaginary}.
12172 @item Ada.Numerics.Discrete_Random
12173 This generic package provides a random number generator suitable for generating
12174 uniformly distributed values of a specified discrete subtype.
12176 @item Ada.Numerics.Float_Random
12177 This package provides a random number generator suitable for generating
12178 uniformly distributed floating point values in the unit interval.
12180 @item Ada.Numerics.Generic_Complex_Elementary_Functions
12181 This is a generic version of the package that provides the
12182 implementation of standard elementary functions (such as log and
12183 trigonometric functions) for an arbitrary complex type.
12185 The following predefined instantiations of this package are provided:
12189 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
12191 @code{Ada.Numerics.Complex_Elementary_Functions}
12193 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
12196 @item Ada.Numerics.Generic_Complex_Types
12197 This is a generic package that allows the creation of complex types,
12198 with associated complex arithmetic operations.
12200 The following predefined instantiations of this package exist
12203 @code{Ada.Numerics.Short_Complex_Complex_Types}
12205 @code{Ada.Numerics.Complex_Complex_Types}
12207 @code{Ada.Numerics.Long_Complex_Complex_Types}
12210 @item Ada.Numerics.Generic_Elementary_Functions
12211 This is a generic package that provides the implementation of standard
12212 elementary functions (such as log an trigonometric functions) for an
12213 arbitrary float type.
12215 The following predefined instantiations of this package exist
12219 @code{Ada.Numerics.Short_Elementary_Functions}
12221 @code{Ada.Numerics.Elementary_Functions}
12223 @code{Ada.Numerics.Long_Elementary_Functions}
12226 @item Ada.Real_Time (D.8)
12227 This package provides facilities similar to those of @code{Calendar}, but
12228 operating with a finer clock suitable for real time control. Note that
12229 annex D requires that there be no backward clock jumps, and GNAT generally
12230 guarantees this behavior, but of course if the external clock on which
12231 the GNAT runtime depends is deliberately reset by some external event,
12232 then such a backward jump may occur.
12234 @item Ada.Sequential_IO (A.8.1)
12235 This package provides input-output facilities for sequential files,
12236 which can contain a sequence of values of a single type, which can be
12237 any Ada type, including indefinite (unconstrained) types.
12239 @item Ada.Storage_IO (A.9)
12240 This package provides a facility for mapping arbitrary Ada types to and
12241 from a storage buffer. It is primarily intended for the creation of new
12244 @item Ada.Streams (13.13.1)
12245 This is a generic package that provides the basic support for the
12246 concept of streams as used by the stream attributes (@code{Input},
12247 @code{Output}, @code{Read} and @code{Write}).
12249 @item Ada.Streams.Stream_IO (A.12.1)
12250 This package is a specialization of the type @code{Streams} defined in
12251 package @code{Streams} together with a set of operations providing
12252 Stream_IO capability. The Stream_IO model permits both random and
12253 sequential access to a file which can contain an arbitrary set of values
12254 of one or more Ada types.
12256 @item Ada.Strings (A.4.1)
12257 This package provides some basic constants used by the string handling
12260 @item Ada.Strings.Bounded (A.4.4)
12261 This package provides facilities for handling variable length
12262 strings. The bounded model requires a maximum length. It is thus
12263 somewhat more limited than the unbounded model, but avoids the use of
12264 dynamic allocation or finalization.
12266 @item Ada.Strings.Fixed (A.4.3)
12267 This package provides facilities for handling fixed length strings.
12269 @item Ada.Strings.Maps (A.4.2)
12270 This package provides facilities for handling character mappings and
12271 arbitrarily defined subsets of characters. For instance it is useful in
12272 defining specialized translation tables.
12274 @item Ada.Strings.Maps.Constants (A.4.6)
12275 This package provides a standard set of predefined mappings and
12276 predefined character sets. For example, the standard upper to lower case
12277 conversion table is found in this package. Note that upper to lower case
12278 conversion is non-trivial if you want to take the entire set of
12279 characters, including extended characters like E with an acute accent,
12280 into account. You should use the mappings in this package (rather than
12281 adding 32 yourself) to do case mappings.
12283 @item Ada.Strings.Unbounded (A.4.5)
12284 This package provides facilities for handling variable length
12285 strings. The unbounded model allows arbitrary length strings, but
12286 requires the use of dynamic allocation and finalization.
12288 @item Ada.Strings.Wide_Bounded (A.4.7)
12289 @itemx Ada.Strings.Wide_Fixed (A.4.7)
12290 @itemx Ada.Strings.Wide_Maps (A.4.7)
12291 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
12292 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
12293 These packages provide analogous capabilities to the corresponding
12294 packages without @samp{Wide_} in the name, but operate with the types
12295 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
12296 and @code{Character}.
12298 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
12299 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
12300 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
12301 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
12302 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
12303 These packages provide analogous capabilities to the corresponding
12304 packages without @samp{Wide_} in the name, but operate with the types
12305 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
12306 of @code{String} and @code{Character}.
12308 @item Ada.Synchronous_Task_Control (D.10)
12309 This package provides some standard facilities for controlling task
12310 communication in a synchronous manner.
12313 This package contains definitions for manipulation of the tags of tagged
12316 @item Ada.Task_Attributes
12317 This package provides the capability of associating arbitrary
12318 task-specific data with separate tasks.
12321 This package provides basic text input-output capabilities for
12322 character, string and numeric data. The subpackages of this
12323 package are listed next.
12325 @item Ada.Text_IO.Decimal_IO
12326 Provides input-output facilities for decimal fixed-point types
12328 @item Ada.Text_IO.Enumeration_IO
12329 Provides input-output facilities for enumeration types.
12331 @item Ada.Text_IO.Fixed_IO
12332 Provides input-output facilities for ordinary fixed-point types.
12334 @item Ada.Text_IO.Float_IO
12335 Provides input-output facilities for float types. The following
12336 predefined instantiations of this generic package are available:
12340 @code{Short_Float_Text_IO}
12342 @code{Float_Text_IO}
12344 @code{Long_Float_Text_IO}
12347 @item Ada.Text_IO.Integer_IO
12348 Provides input-output facilities for integer types. The following
12349 predefined instantiations of this generic package are available:
12352 @item Short_Short_Integer
12353 @code{Ada.Short_Short_Integer_Text_IO}
12354 @item Short_Integer
12355 @code{Ada.Short_Integer_Text_IO}
12357 @code{Ada.Integer_Text_IO}
12359 @code{Ada.Long_Integer_Text_IO}
12360 @item Long_Long_Integer
12361 @code{Ada.Long_Long_Integer_Text_IO}
12364 @item Ada.Text_IO.Modular_IO
12365 Provides input-output facilities for modular (unsigned) types
12367 @item Ada.Text_IO.Complex_IO (G.1.3)
12368 This package provides basic text input-output capabilities for complex
12371 @item Ada.Text_IO.Editing (F.3.3)
12372 This package contains routines for edited output, analogous to the use
12373 of pictures in COBOL@. The picture formats used by this package are a
12374 close copy of the facility in COBOL@.
12376 @item Ada.Text_IO.Text_Streams (A.12.2)
12377 This package provides a facility that allows Text_IO files to be treated
12378 as streams, so that the stream attributes can be used for writing
12379 arbitrary data, including binary data, to Text_IO files.
12381 @item Ada.Unchecked_Conversion (13.9)
12382 This generic package allows arbitrary conversion from one type to
12383 another of the same size, providing for breaking the type safety in
12384 special circumstances.
12386 If the types have the same Size (more accurately the same Value_Size),
12387 then the effect is simply to transfer the bits from the source to the
12388 target type without any modification. This usage is well defined, and
12389 for simple types whose representation is typically the same across
12390 all implementations, gives a portable method of performing such
12393 If the types do not have the same size, then the result is implementation
12394 defined, and thus may be non-portable. The following describes how GNAT
12395 handles such unchecked conversion cases.
12397 If the types are of different sizes, and are both discrete types, then
12398 the effect is of a normal type conversion without any constraint checking.
12399 In particular if the result type has a larger size, the result will be
12400 zero or sign extended. If the result type has a smaller size, the result
12401 will be truncated by ignoring high order bits.
12403 If the types are of different sizes, and are not both discrete types,
12404 then the conversion works as though pointers were created to the source
12405 and target, and the pointer value is converted. The effect is that bits
12406 are copied from successive low order storage units and bits of the source
12407 up to the length of the target type.
12409 A warning is issued if the lengths differ, since the effect in this
12410 case is implementation dependent, and the above behavior may not match
12411 that of some other compiler.
12413 A pointer to one type may be converted to a pointer to another type using
12414 unchecked conversion. The only case in which the effect is undefined is
12415 when one or both pointers are pointers to unconstrained array types. In
12416 this case, the bounds information may get incorrectly transferred, and in
12417 particular, GNAT uses double size pointers for such types, and it is
12418 meaningless to convert between such pointer types. GNAT will issue a
12419 warning if the alignment of the target designated type is more strict
12420 than the alignment of the source designated type (since the result may
12421 be unaligned in this case).
12423 A pointer other than a pointer to an unconstrained array type may be
12424 converted to and from System.Address. Such usage is common in Ada 83
12425 programs, but note that Ada.Address_To_Access_Conversions is the
12426 preferred method of performing such conversions in Ada 95 and Ada 2005.
12428 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12429 used in conjunction with pointers to unconstrained objects, since
12430 the bounds information cannot be handled correctly in this case.
12432 @item Ada.Unchecked_Deallocation (13.11.2)
12433 This generic package allows explicit freeing of storage previously
12434 allocated by use of an allocator.
12436 @item Ada.Wide_Text_IO (A.11)
12437 This package is similar to @code{Ada.Text_IO}, except that the external
12438 file supports wide character representations, and the internal types are
12439 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12440 and @code{String}. It contains generic subpackages listed next.
12442 @item Ada.Wide_Text_IO.Decimal_IO
12443 Provides input-output facilities for decimal fixed-point types
12445 @item Ada.Wide_Text_IO.Enumeration_IO
12446 Provides input-output facilities for enumeration types.
12448 @item Ada.Wide_Text_IO.Fixed_IO
12449 Provides input-output facilities for ordinary fixed-point types.
12451 @item Ada.Wide_Text_IO.Float_IO
12452 Provides input-output facilities for float types. The following
12453 predefined instantiations of this generic package are available:
12457 @code{Short_Float_Wide_Text_IO}
12459 @code{Float_Wide_Text_IO}
12461 @code{Long_Float_Wide_Text_IO}
12464 @item Ada.Wide_Text_IO.Integer_IO
12465 Provides input-output facilities for integer types. The following
12466 predefined instantiations of this generic package are available:
12469 @item Short_Short_Integer
12470 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12471 @item Short_Integer
12472 @code{Ada.Short_Integer_Wide_Text_IO}
12474 @code{Ada.Integer_Wide_Text_IO}
12476 @code{Ada.Long_Integer_Wide_Text_IO}
12477 @item Long_Long_Integer
12478 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12481 @item Ada.Wide_Text_IO.Modular_IO
12482 Provides input-output facilities for modular (unsigned) types
12484 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12485 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12486 external file supports wide character representations.
12488 @item Ada.Wide_Text_IO.Editing (F.3.4)
12489 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12490 types are @code{Wide_Character} and @code{Wide_String} instead of
12491 @code{Character} and @code{String}.
12493 @item Ada.Wide_Text_IO.Streams (A.12.3)
12494 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12495 types are @code{Wide_Character} and @code{Wide_String} instead of
12496 @code{Character} and @code{String}.
12498 @item Ada.Wide_Wide_Text_IO (A.11)
12499 This package is similar to @code{Ada.Text_IO}, except that the external
12500 file supports wide character representations, and the internal types are
12501 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12502 and @code{String}. It contains generic subpackages listed next.
12504 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12505 Provides input-output facilities for decimal fixed-point types
12507 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12508 Provides input-output facilities for enumeration types.
12510 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12511 Provides input-output facilities for ordinary fixed-point types.
12513 @item Ada.Wide_Wide_Text_IO.Float_IO
12514 Provides input-output facilities for float types. The following
12515 predefined instantiations of this generic package are available:
12519 @code{Short_Float_Wide_Wide_Text_IO}
12521 @code{Float_Wide_Wide_Text_IO}
12523 @code{Long_Float_Wide_Wide_Text_IO}
12526 @item Ada.Wide_Wide_Text_IO.Integer_IO
12527 Provides input-output facilities for integer types. The following
12528 predefined instantiations of this generic package are available:
12531 @item Short_Short_Integer
12532 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12533 @item Short_Integer
12534 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12536 @code{Ada.Integer_Wide_Wide_Text_IO}
12538 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12539 @item Long_Long_Integer
12540 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12543 @item Ada.Wide_Wide_Text_IO.Modular_IO
12544 Provides input-output facilities for modular (unsigned) types
12546 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12547 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12548 external file supports wide character representations.
12550 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12551 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12552 types are @code{Wide_Character} and @code{Wide_String} instead of
12553 @code{Character} and @code{String}.
12555 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12556 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12557 types are @code{Wide_Character} and @code{Wide_String} instead of
12558 @code{Character} and @code{String}.
12561 @node The Implementation of Standard I/O
12562 @chapter The Implementation of Standard I/O
12565 GNAT implements all the required input-output facilities described in
12566 A.6 through A.14. These sections of the Ada Reference Manual describe the
12567 required behavior of these packages from the Ada point of view, and if
12568 you are writing a portable Ada program that does not need to know the
12569 exact manner in which Ada maps to the outside world when it comes to
12570 reading or writing external files, then you do not need to read this
12571 chapter. As long as your files are all regular files (not pipes or
12572 devices), and as long as you write and read the files only from Ada, the
12573 description in the Ada Reference Manual is sufficient.
12575 However, if you want to do input-output to pipes or other devices, such
12576 as the keyboard or screen, or if the files you are dealing with are
12577 either generated by some other language, or to be read by some other
12578 language, then you need to know more about the details of how the GNAT
12579 implementation of these input-output facilities behaves.
12581 In this chapter we give a detailed description of exactly how GNAT
12582 interfaces to the file system. As always, the sources of the system are
12583 available to you for answering questions at an even more detailed level,
12584 but for most purposes the information in this chapter will suffice.
12586 Another reason that you may need to know more about how input-output is
12587 implemented arises when you have a program written in mixed languages
12588 where, for example, files are shared between the C and Ada sections of
12589 the same program. GNAT provides some additional facilities, in the form
12590 of additional child library packages, that facilitate this sharing, and
12591 these additional facilities are also described in this chapter.
12594 * Standard I/O Packages::
12600 * Wide_Wide_Text_IO::
12602 * Text Translation::
12604 * Filenames encoding::
12606 * Operations on C Streams::
12607 * Interfacing to C Streams::
12610 @node Standard I/O Packages
12611 @section Standard I/O Packages
12614 The Standard I/O packages described in Annex A for
12620 Ada.Text_IO.Complex_IO
12622 Ada.Text_IO.Text_Streams
12626 Ada.Wide_Text_IO.Complex_IO
12628 Ada.Wide_Text_IO.Text_Streams
12630 Ada.Wide_Wide_Text_IO
12632 Ada.Wide_Wide_Text_IO.Complex_IO
12634 Ada.Wide_Wide_Text_IO.Text_Streams
12644 are implemented using the C
12645 library streams facility; where
12649 All files are opened using @code{fopen}.
12651 All input/output operations use @code{fread}/@code{fwrite}.
12655 There is no internal buffering of any kind at the Ada library level. The only
12656 buffering is that provided at the system level in the implementation of the
12657 library routines that support streams. This facilitates shared use of these
12658 streams by mixed language programs. Note though that system level buffering is
12659 explicitly enabled at elaboration of the standard I/O packages and that can
12660 have an impact on mixed language programs, in particular those using I/O before
12661 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12662 the Ada elaboration routine before performing any I/O or when impractical,
12663 flush the common I/O streams and in particular Standard_Output before
12664 elaborating the Ada code.
12667 @section FORM Strings
12670 The format of a FORM string in GNAT is:
12673 "keyword=value,keyword=value,@dots{},keyword=value"
12677 where letters may be in upper or lower case, and there are no spaces
12678 between values. The order of the entries is not important. Currently
12679 the following keywords defined.
12682 TEXT_TRANSLATION=[YES|NO]
12684 WCEM=[n|h|u|s|e|8|b]
12685 ENCODING=[UTF8|8BITS]
12689 The use of these parameters is described later in this section.
12695 Direct_IO can only be instantiated for definite types. This is a
12696 restriction of the Ada language, which means that the records are fixed
12697 length (the length being determined by @code{@var{type}'Size}, rounded
12698 up to the next storage unit boundary if necessary).
12700 The records of a Direct_IO file are simply written to the file in index
12701 sequence, with the first record starting at offset zero, and subsequent
12702 records following. There is no control information of any kind. For
12703 example, if 32-bit integers are being written, each record takes
12704 4-bytes, so the record at index @var{K} starts at offset
12705 (@var{K}@minus{}1)*4.
12707 There is no limit on the size of Direct_IO files, they are expanded as
12708 necessary to accommodate whatever records are written to the file.
12710 @node Sequential_IO
12711 @section Sequential_IO
12714 Sequential_IO may be instantiated with either a definite (constrained)
12715 or indefinite (unconstrained) type.
12717 For the definite type case, the elements written to the file are simply
12718 the memory images of the data values with no control information of any
12719 kind. The resulting file should be read using the same type, no validity
12720 checking is performed on input.
12722 For the indefinite type case, the elements written consist of two
12723 parts. First is the size of the data item, written as the memory image
12724 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12725 the data value. The resulting file can only be read using the same
12726 (unconstrained) type. Normal assignment checks are performed on these
12727 read operations, and if these checks fail, @code{Data_Error} is
12728 raised. In particular, in the array case, the lengths must match, and in
12729 the variant record case, if the variable for a particular read operation
12730 is constrained, the discriminants must match.
12732 Note that it is not possible to use Sequential_IO to write variable
12733 length array items, and then read the data back into different length
12734 arrays. For example, the following will raise @code{Data_Error}:
12736 @smallexample @c ada
12737 package IO is new Sequential_IO (String);
12742 IO.Write (F, "hello!")
12743 IO.Reset (F, Mode=>In_File);
12750 On some Ada implementations, this will print @code{hell}, but the program is
12751 clearly incorrect, since there is only one element in the file, and that
12752 element is the string @code{hello!}.
12754 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12755 using Stream_IO, and this is the preferred mechanism. In particular, the
12756 above program fragment rewritten to use Stream_IO will work correctly.
12762 Text_IO files consist of a stream of characters containing the following
12763 special control characters:
12766 LF (line feed, 16#0A#) Line Mark
12767 FF (form feed, 16#0C#) Page Mark
12771 A canonical Text_IO file is defined as one in which the following
12772 conditions are met:
12776 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12780 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12781 end of a page and consequently can appear only immediately following a
12782 @code{LF} (line mark) character.
12785 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12786 (line mark, page mark). In the former case, the page mark is implicitly
12787 assumed to be present.
12791 A file written using Text_IO will be in canonical form provided that no
12792 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12793 or @code{Put_Line}. There will be no @code{FF} character at the end of
12794 the file unless an explicit @code{New_Page} operation was performed
12795 before closing the file.
12797 A canonical Text_IO file that is a regular file (i.e., not a device or a
12798 pipe) can be read using any of the routines in Text_IO@. The
12799 semantics in this case will be exactly as defined in the Ada Reference
12800 Manual, and all the routines in Text_IO are fully implemented.
12802 A text file that does not meet the requirements for a canonical Text_IO
12803 file has one of the following:
12807 The file contains @code{FF} characters not immediately following a
12808 @code{LF} character.
12811 The file contains @code{LF} or @code{FF} characters written by
12812 @code{Put} or @code{Put_Line}, which are not logically considered to be
12813 line marks or page marks.
12816 The file ends in a character other than @code{LF} or @code{FF},
12817 i.e.@: there is no explicit line mark or page mark at the end of the file.
12821 Text_IO can be used to read such non-standard text files but subprograms
12822 to do with line or page numbers do not have defined meanings. In
12823 particular, a @code{FF} character that does not follow a @code{LF}
12824 character may or may not be treated as a page mark from the point of
12825 view of page and line numbering. Every @code{LF} character is considered
12826 to end a line, and there is an implied @code{LF} character at the end of
12830 * Text_IO Stream Pointer Positioning::
12831 * Text_IO Reading and Writing Non-Regular Files::
12833 * Treating Text_IO Files as Streams::
12834 * Text_IO Extensions::
12835 * Text_IO Facilities for Unbounded Strings::
12838 @node Text_IO Stream Pointer Positioning
12839 @subsection Stream Pointer Positioning
12842 @code{Ada.Text_IO} has a definition of current position for a file that
12843 is being read. No internal buffering occurs in Text_IO, and usually the
12844 physical position in the stream used to implement the file corresponds
12845 to this logical position defined by Text_IO@. There are two exceptions:
12849 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12850 is positioned past the @code{LF} (line mark) that precedes the page
12851 mark. Text_IO maintains an internal flag so that subsequent read
12852 operations properly handle the logical position which is unchanged by
12853 the @code{End_Of_Page} call.
12856 After a call to @code{End_Of_File} that returns @code{True}, if the
12857 Text_IO file was positioned before the line mark at the end of file
12858 before the call, then the logical position is unchanged, but the stream
12859 is physically positioned right at the end of file (past the line mark,
12860 and past a possible page mark following the line mark. Again Text_IO
12861 maintains internal flags so that subsequent read operations properly
12862 handle the logical position.
12866 These discrepancies have no effect on the observable behavior of
12867 Text_IO, but if a single Ada stream is shared between a C program and
12868 Ada program, or shared (using @samp{shared=yes} in the form string)
12869 between two Ada files, then the difference may be observable in some
12872 @node Text_IO Reading and Writing Non-Regular Files
12873 @subsection Reading and Writing Non-Regular Files
12876 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
12877 can be used for reading and writing. Writing is not affected and the
12878 sequence of characters output is identical to the normal file case, but
12879 for reading, the behavior of Text_IO is modified to avoid undesirable
12880 look-ahead as follows:
12882 An input file that is not a regular file is considered to have no page
12883 marks. Any @code{Ascii.FF} characters (the character normally used for a
12884 page mark) appearing in the file are considered to be data
12885 characters. In particular:
12889 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12890 following a line mark. If a page mark appears, it will be treated as a
12894 This avoids the need to wait for an extra character to be typed or
12895 entered from the pipe to complete one of these operations.
12898 @code{End_Of_Page} always returns @code{False}
12901 @code{End_Of_File} will return @code{False} if there is a page mark at
12902 the end of the file.
12906 Output to non-regular files is the same as for regular files. Page marks
12907 may be written to non-regular files using @code{New_Page}, but as noted
12908 above they will not be treated as page marks on input if the output is
12909 piped to another Ada program.
12911 Another important discrepancy when reading non-regular files is that the end
12912 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
12913 pressing the @key{EOT} key,
12915 is signaled once (i.e.@: the test @code{End_Of_File}
12916 will yield @code{True}, or a read will
12917 raise @code{End_Error}), but then reading can resume
12918 to read data past that end of
12919 file indication, until another end of file indication is entered.
12921 @node Get_Immediate
12922 @subsection Get_Immediate
12923 @cindex Get_Immediate
12926 Get_Immediate returns the next character (including control characters)
12927 from the input file. In particular, Get_Immediate will return LF or FF
12928 characters used as line marks or page marks. Such operations leave the
12929 file positioned past the control character, and it is thus not treated
12930 as having its normal function. This means that page, line and column
12931 counts after this kind of Get_Immediate call are set as though the mark
12932 did not occur. In the case where a Get_Immediate leaves the file
12933 positioned between the line mark and page mark (which is not normally
12934 possible), it is undefined whether the FF character will be treated as a
12937 @node Treating Text_IO Files as Streams
12938 @subsection Treating Text_IO Files as Streams
12939 @cindex Stream files
12942 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12943 as a stream. Data written to a Text_IO file in this stream mode is
12944 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
12945 16#0C# (@code{FF}), the resulting file may have non-standard
12946 format. Similarly if read operations are used to read from a Text_IO
12947 file treated as a stream, then @code{LF} and @code{FF} characters may be
12948 skipped and the effect is similar to that described above for
12949 @code{Get_Immediate}.
12951 @node Text_IO Extensions
12952 @subsection Text_IO Extensions
12953 @cindex Text_IO extensions
12956 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12957 to the standard @code{Text_IO} package:
12960 @item function File_Exists (Name : String) return Boolean;
12961 Determines if a file of the given name exists.
12963 @item function Get_Line return String;
12964 Reads a string from the standard input file. The value returned is exactly
12965 the length of the line that was read.
12967 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12968 Similar, except that the parameter File specifies the file from which
12969 the string is to be read.
12973 @node Text_IO Facilities for Unbounded Strings
12974 @subsection Text_IO Facilities for Unbounded Strings
12975 @cindex Text_IO for unbounded strings
12976 @cindex Unbounded_String, Text_IO operations
12979 The package @code{Ada.Strings.Unbounded.Text_IO}
12980 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12981 subprograms useful for Text_IO operations on unbounded strings:
12985 @item function Get_Line (File : File_Type) return Unbounded_String;
12986 Reads a line from the specified file
12987 and returns the result as an unbounded string.
12989 @item procedure Put (File : File_Type; U : Unbounded_String);
12990 Writes the value of the given unbounded string to the specified file
12991 Similar to the effect of
12992 @code{Put (To_String (U))} except that an extra copy is avoided.
12994 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12995 Writes the value of the given unbounded string to the specified file,
12996 followed by a @code{New_Line}.
12997 Similar to the effect of @code{Put_Line (To_String (U))} except
12998 that an extra copy is avoided.
13002 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
13003 and is optional. If the parameter is omitted, then the standard input or
13004 output file is referenced as appropriate.
13006 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
13007 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
13008 @code{Wide_Text_IO} functionality for unbounded wide strings.
13010 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
13011 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
13012 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
13015 @section Wide_Text_IO
13018 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
13019 both input and output files may contain special sequences that represent
13020 wide character values. The encoding scheme for a given file may be
13021 specified using a FORM parameter:
13028 as part of the FORM string (WCEM = wide character encoding method),
13029 where @var{x} is one of the following characters
13035 Upper half encoding
13047 The encoding methods match those that
13048 can be used in a source
13049 program, but there is no requirement that the encoding method used for
13050 the source program be the same as the encoding method used for files,
13051 and different files may use different encoding methods.
13053 The default encoding method for the standard files, and for opened files
13054 for which no WCEM parameter is given in the FORM string matches the
13055 wide character encoding specified for the main program (the default
13056 being brackets encoding if no coding method was specified with -gnatW).
13060 In this encoding, a wide character is represented by a five character
13068 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
13069 characters (using upper case letters) of the wide character code. For
13070 example, ESC A345 is used to represent the wide character with code
13071 16#A345#. This scheme is compatible with use of the full
13072 @code{Wide_Character} set.
13074 @item Upper Half Coding
13075 The wide character with encoding 16#abcd#, where the upper bit is on
13076 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
13077 16#cd#. The second byte may never be a format control character, but is
13078 not required to be in the upper half. This method can be also used for
13079 shift-JIS or EUC where the internal coding matches the external coding.
13081 @item Shift JIS Coding
13082 A wide character is represented by a two character sequence 16#ab# and
13083 16#cd#, with the restrictions described for upper half encoding as
13084 described above. The internal character code is the corresponding JIS
13085 character according to the standard algorithm for Shift-JIS
13086 conversion. Only characters defined in the JIS code set table can be
13087 used with this encoding method.
13090 A wide character is represented by a two character sequence 16#ab# and
13091 16#cd#, with both characters being in the upper half. The internal
13092 character code is the corresponding JIS character according to the EUC
13093 encoding algorithm. Only characters defined in the JIS code set table
13094 can be used with this encoding method.
13097 A wide character is represented using
13098 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13099 10646-1/Am.2. Depending on the character value, the representation
13100 is a one, two, or three byte sequence:
13103 16#0000#-16#007f#: 2#0xxxxxxx#
13104 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
13105 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13109 where the @var{xxx} bits correspond to the left-padded bits of the
13110 16-bit character value. Note that all lower half ASCII characters
13111 are represented as ASCII bytes and all upper half characters and
13112 other wide characters are represented as sequences of upper-half
13113 (The full UTF-8 scheme allows for encoding 31-bit characters as
13114 6-byte sequences, but in this implementation, all UTF-8 sequences
13115 of four or more bytes length will raise a Constraint_Error, as
13116 will all invalid UTF-8 sequences.)
13118 @item Brackets Coding
13119 In this encoding, a wide character is represented by the following eight
13120 character sequence:
13127 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
13128 characters (using uppercase letters) of the wide character code. For
13129 example, @code{["A345"]} is used to represent the wide character with code
13131 This scheme is compatible with use of the full Wide_Character set.
13132 On input, brackets coding can also be used for upper half characters,
13133 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
13134 is only used for wide characters with a code greater than @code{16#FF#}.
13136 Note that brackets coding is not normally used in the context of
13137 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
13138 a portable way of encoding source files. In the context of Wide_Text_IO
13139 or Wide_Wide_Text_IO, it can only be used if the file does not contain
13140 any instance of the left bracket character other than to encode wide
13141 character values using the brackets encoding method. In practice it is
13142 expected that some standard wide character encoding method such
13143 as UTF-8 will be used for text input output.
13145 If brackets notation is used, then any occurrence of a left bracket
13146 in the input file which is not the start of a valid wide character
13147 sequence will cause Constraint_Error to be raised. It is possible to
13148 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
13149 input will interpret this as a left bracket.
13151 However, when a left bracket is output, it will be output as a left bracket
13152 and not as ["5B"]. We make this decision because for normal use of
13153 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
13154 brackets. For example, if we write:
13157 Put_Line ("Start of output [first run]");
13161 we really do not want to have the left bracket in this message clobbered so
13162 that the output reads:
13165 Start of output ["5B"]first run]
13169 In practice brackets encoding is reasonably useful for normal Put_Line use
13170 since we won't get confused between left brackets and wide character
13171 sequences in the output. But for input, or when files are written out
13172 and read back in, it really makes better sense to use one of the standard
13173 encoding methods such as UTF-8.
13178 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
13179 not all wide character
13180 values can be represented. An attempt to output a character that cannot
13181 be represented using the encoding scheme for the file causes
13182 Constraint_Error to be raised. An invalid wide character sequence on
13183 input also causes Constraint_Error to be raised.
13186 * Wide_Text_IO Stream Pointer Positioning::
13187 * Wide_Text_IO Reading and Writing Non-Regular Files::
13190 @node Wide_Text_IO Stream Pointer Positioning
13191 @subsection Stream Pointer Positioning
13194 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13195 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13198 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
13199 normal lower ASCII set (i.e.@: a character in the range:
13201 @smallexample @c ada
13202 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
13206 then although the logical position of the file pointer is unchanged by
13207 the @code{Look_Ahead} call, the stream is physically positioned past the
13208 wide character sequence. Again this is to avoid the need for buffering
13209 or backup, and all @code{Wide_Text_IO} routines check the internal
13210 indication that this situation has occurred so that this is not visible
13211 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
13212 can be observed if the wide text file shares a stream with another file.
13214 @node Wide_Text_IO Reading and Writing Non-Regular Files
13215 @subsection Reading and Writing Non-Regular Files
13218 As in the case of Text_IO, when a non-regular file is read, it is
13219 assumed that the file contains no page marks (any form characters are
13220 treated as data characters), and @code{End_Of_Page} always returns
13221 @code{False}. Similarly, the end of file indication is not sticky, so
13222 it is possible to read beyond an end of file.
13224 @node Wide_Wide_Text_IO
13225 @section Wide_Wide_Text_IO
13228 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
13229 both input and output files may contain special sequences that represent
13230 wide wide character values. The encoding scheme for a given file may be
13231 specified using a FORM parameter:
13238 as part of the FORM string (WCEM = wide character encoding method),
13239 where @var{x} is one of the following characters
13245 Upper half encoding
13257 The encoding methods match those that
13258 can be used in a source
13259 program, but there is no requirement that the encoding method used for
13260 the source program be the same as the encoding method used for files,
13261 and different files may use different encoding methods.
13263 The default encoding method for the standard files, and for opened files
13264 for which no WCEM parameter is given in the FORM string matches the
13265 wide character encoding specified for the main program (the default
13266 being brackets encoding if no coding method was specified with -gnatW).
13271 A wide character is represented using
13272 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13273 10646-1/Am.2. Depending on the character value, the representation
13274 is a one, two, three, or four byte sequence:
13277 16#000000#-16#00007f#: 2#0xxxxxxx#
13278 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
13279 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13280 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
13284 where the @var{xxx} bits correspond to the left-padded bits of the
13285 21-bit character value. Note that all lower half ASCII characters
13286 are represented as ASCII bytes and all upper half characters and
13287 other wide characters are represented as sequences of upper-half
13290 @item Brackets Coding
13291 In this encoding, a wide wide character is represented by the following eight
13292 character sequence if is in wide character range
13298 and by the following ten character sequence if not
13301 [ " a b c d e f " ]
13305 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
13306 are the four or six hexadecimal
13307 characters (using uppercase letters) of the wide wide character code. For
13308 example, @code{["01A345"]} is used to represent the wide wide character
13309 with code @code{16#01A345#}.
13311 This scheme is compatible with use of the full Wide_Wide_Character set.
13312 On input, brackets coding can also be used for upper half characters,
13313 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
13314 is only used for wide characters with a code greater than @code{16#FF#}.
13319 If is also possible to use the other Wide_Character encoding methods,
13320 such as Shift-JIS, but the other schemes cannot support the full range
13321 of wide wide characters.
13322 An attempt to output a character that cannot
13323 be represented using the encoding scheme for the file causes
13324 Constraint_Error to be raised. An invalid wide character sequence on
13325 input also causes Constraint_Error to be raised.
13328 * Wide_Wide_Text_IO Stream Pointer Positioning::
13329 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13332 @node Wide_Wide_Text_IO Stream Pointer Positioning
13333 @subsection Stream Pointer Positioning
13336 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13337 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13340 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13341 normal lower ASCII set (i.e.@: a character in the range:
13343 @smallexample @c ada
13344 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13348 then although the logical position of the file pointer is unchanged by
13349 the @code{Look_Ahead} call, the stream is physically positioned past the
13350 wide character sequence. Again this is to avoid the need for buffering
13351 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13352 indication that this situation has occurred so that this is not visible
13353 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
13354 can be observed if the wide text file shares a stream with another file.
13356 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13357 @subsection Reading and Writing Non-Regular Files
13360 As in the case of Text_IO, when a non-regular file is read, it is
13361 assumed that the file contains no page marks (any form characters are
13362 treated as data characters), and @code{End_Of_Page} always returns
13363 @code{False}. Similarly, the end of file indication is not sticky, so
13364 it is possible to read beyond an end of file.
13370 A stream file is a sequence of bytes, where individual elements are
13371 written to the file as described in the Ada Reference Manual. The type
13372 @code{Stream_Element} is simply a byte. There are two ways to read or
13373 write a stream file.
13377 The operations @code{Read} and @code{Write} directly read or write a
13378 sequence of stream elements with no control information.
13381 The stream attributes applied to a stream file transfer data in the
13382 manner described for stream attributes.
13385 @node Text Translation
13386 @section Text Translation
13389 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13390 passed to Text_IO.Create and Text_IO.Open:
13391 @samp{Text_Translation=@var{Yes}} is the default, which means to
13392 translate LF to/from CR/LF on Windows systems.
13393 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13394 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13395 may be used to create Unix-style files on
13396 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13400 @section Shared Files
13403 Section A.14 of the Ada Reference Manual allows implementations to
13404 provide a wide variety of behavior if an attempt is made to access the
13405 same external file with two or more internal files.
13407 To provide a full range of functionality, while at the same time
13408 minimizing the problems of portability caused by this implementation
13409 dependence, GNAT handles file sharing as follows:
13413 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13414 to open two or more files with the same full name is considered an error
13415 and is not supported. The exception @code{Use_Error} will be
13416 raised. Note that a file that is not explicitly closed by the program
13417 remains open until the program terminates.
13420 If the form parameter @samp{shared=no} appears in the form string, the
13421 file can be opened or created with its own separate stream identifier,
13422 regardless of whether other files sharing the same external file are
13423 opened. The exact effect depends on how the C stream routines handle
13424 multiple accesses to the same external files using separate streams.
13427 If the form parameter @samp{shared=yes} appears in the form string for
13428 each of two or more files opened using the same full name, the same
13429 stream is shared between these files, and the semantics are as described
13430 in Ada Reference Manual, Section A.14.
13434 When a program that opens multiple files with the same name is ported
13435 from another Ada compiler to GNAT, the effect will be that
13436 @code{Use_Error} is raised.
13438 The documentation of the original compiler and the documentation of the
13439 program should then be examined to determine if file sharing was
13440 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13441 and @code{Create} calls as required.
13443 When a program is ported from GNAT to some other Ada compiler, no
13444 special attention is required unless the @samp{shared=@var{xxx}} form
13445 parameter is used in the program. In this case, you must examine the
13446 documentation of the new compiler to see if it supports the required
13447 file sharing semantics, and form strings modified appropriately. Of
13448 course it may be the case that the program cannot be ported if the
13449 target compiler does not support the required functionality. The best
13450 approach in writing portable code is to avoid file sharing (and hence
13451 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13454 One common use of file sharing in Ada 83 is the use of instantiations of
13455 Sequential_IO on the same file with different types, to achieve
13456 heterogeneous input-output. Although this approach will work in GNAT if
13457 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13458 for this purpose (using the stream attributes)
13460 @node Filenames encoding
13461 @section Filenames encoding
13464 An encoding form parameter can be used to specify the filename
13465 encoding @samp{encoding=@var{xxx}}.
13469 If the form parameter @samp{encoding=utf8} appears in the form string, the
13470 filename must be encoded in UTF-8.
13473 If the form parameter @samp{encoding=8bits} appears in the form
13474 string, the filename must be a standard 8bits string.
13477 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13478 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13479 variable. And if not set @samp{utf8} is assumed.
13483 The current system Windows ANSI code page.
13488 This encoding form parameter is only supported on the Windows
13489 platform. On the other Operating Systems the run-time is supporting
13493 @section Open Modes
13496 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13497 using the mode shown in the following table:
13500 @center @code{Open} and @code{Create} Call Modes
13502 @b{OPEN } @b{CREATE}
13503 Append_File "r+" "w+"
13505 Out_File (Direct_IO) "r+" "w"
13506 Out_File (all other cases) "w" "w"
13507 Inout_File "r+" "w+"
13511 If text file translation is required, then either @samp{b} or @samp{t}
13512 is added to the mode, depending on the setting of Text. Text file
13513 translation refers to the mapping of CR/LF sequences in an external file
13514 to LF characters internally. This mapping only occurs in DOS and
13515 DOS-like systems, and is not relevant to other systems.
13517 A special case occurs with Stream_IO@. As shown in the above table, the
13518 file is initially opened in @samp{r} or @samp{w} mode for the
13519 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
13520 subsequently requires switching from reading to writing or vice-versa,
13521 then the file is reopened in @samp{r+} mode to permit the required operation.
13523 @node Operations on C Streams
13524 @section Operations on C Streams
13525 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13526 access to the C library functions for operations on C streams:
13528 @smallexample @c adanocomment
13529 package Interfaces.C_Streams is
13530 -- Note: the reason we do not use the types that are in
13531 -- Interfaces.C is that we want to avoid dragging in the
13532 -- code in this unit if possible.
13533 subtype chars is System.Address;
13534 -- Pointer to null-terminated array of characters
13535 subtype FILEs is System.Address;
13536 -- Corresponds to the C type FILE*
13537 subtype voids is System.Address;
13538 -- Corresponds to the C type void*
13539 subtype int is Integer;
13540 subtype long is Long_Integer;
13541 -- Note: the above types are subtypes deliberately, and it
13542 -- is part of this spec that the above correspondences are
13543 -- guaranteed. This means that it is legitimate to, for
13544 -- example, use Integer instead of int. We provide these
13545 -- synonyms for clarity, but in some cases it may be
13546 -- convenient to use the underlying types (for example to
13547 -- avoid an unnecessary dependency of a spec on the spec
13549 type size_t is mod 2 ** Standard'Address_Size;
13550 NULL_Stream : constant FILEs;
13551 -- Value returned (NULL in C) to indicate an
13552 -- fdopen/fopen/tmpfile error
13553 ----------------------------------
13554 -- Constants Defined in stdio.h --
13555 ----------------------------------
13556 EOF : constant int;
13557 -- Used by a number of routines to indicate error or
13559 IOFBF : constant int;
13560 IOLBF : constant int;
13561 IONBF : constant int;
13562 -- Used to indicate buffering mode for setvbuf call
13563 SEEK_CUR : constant int;
13564 SEEK_END : constant int;
13565 SEEK_SET : constant int;
13566 -- Used to indicate origin for fseek call
13567 function stdin return FILEs;
13568 function stdout return FILEs;
13569 function stderr return FILEs;
13570 -- Streams associated with standard files
13571 --------------------------
13572 -- Standard C functions --
13573 --------------------------
13574 -- The functions selected below are ones that are
13575 -- available in UNIX (but not necessarily in ANSI C).
13576 -- These are very thin interfaces
13577 -- which copy exactly the C headers. For more
13578 -- documentation on these functions, see the Microsoft C
13579 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13580 -- ISBN 1-55615-225-6), which includes useful information
13581 -- on system compatibility.
13582 procedure clearerr (stream : FILEs);
13583 function fclose (stream : FILEs) return int;
13584 function fdopen (handle : int; mode : chars) return FILEs;
13585 function feof (stream : FILEs) return int;
13586 function ferror (stream : FILEs) return int;
13587 function fflush (stream : FILEs) return int;
13588 function fgetc (stream : FILEs) return int;
13589 function fgets (strng : chars; n : int; stream : FILEs)
13591 function fileno (stream : FILEs) return int;
13592 function fopen (filename : chars; Mode : chars)
13594 -- Note: to maintain target independence, use
13595 -- text_translation_required, a boolean variable defined in
13596 -- a-sysdep.c to deal with the target dependent text
13597 -- translation requirement. If this variable is set,
13598 -- then b/t should be appended to the standard mode
13599 -- argument to set the text translation mode off or on
13601 function fputc (C : int; stream : FILEs) return int;
13602 function fputs (Strng : chars; Stream : FILEs) return int;
13619 function ftell (stream : FILEs) return long;
13626 function isatty (handle : int) return int;
13627 procedure mktemp (template : chars);
13628 -- The return value (which is just a pointer to template)
13630 procedure rewind (stream : FILEs);
13631 function rmtmp return int;
13639 function tmpfile return FILEs;
13640 function ungetc (c : int; stream : FILEs) return int;
13641 function unlink (filename : chars) return int;
13642 ---------------------
13643 -- Extra functions --
13644 ---------------------
13645 -- These functions supply slightly thicker bindings than
13646 -- those above. They are derived from functions in the
13647 -- C Run-Time Library, but may do a bit more work than
13648 -- just directly calling one of the Library functions.
13649 function is_regular_file (handle : int) return int;
13650 -- Tests if given handle is for a regular file (result 1)
13651 -- or for a non-regular file (pipe or device, result 0).
13652 ---------------------------------
13653 -- Control of Text/Binary Mode --
13654 ---------------------------------
13655 -- If text_translation_required is true, then the following
13656 -- functions may be used to dynamically switch a file from
13657 -- binary to text mode or vice versa. These functions have
13658 -- no effect if text_translation_required is false (i.e.@: in
13659 -- normal UNIX mode). Use fileno to get a stream handle.
13660 procedure set_binary_mode (handle : int);
13661 procedure set_text_mode (handle : int);
13662 ----------------------------
13663 -- Full Path Name support --
13664 ----------------------------
13665 procedure full_name (nam : chars; buffer : chars);
13666 -- Given a NUL terminated string representing a file
13667 -- name, returns in buffer a NUL terminated string
13668 -- representing the full path name for the file name.
13669 -- On systems where it is relevant the drive is also
13670 -- part of the full path name. It is the responsibility
13671 -- of the caller to pass an actual parameter for buffer
13672 -- that is big enough for any full path name. Use
13673 -- max_path_len given below as the size of buffer.
13674 max_path_len : integer;
13675 -- Maximum length of an allowable full path name on the
13676 -- system, including a terminating NUL character.
13677 end Interfaces.C_Streams;
13680 @node Interfacing to C Streams
13681 @section Interfacing to C Streams
13684 The packages in this section permit interfacing Ada files to C Stream
13687 @smallexample @c ada
13688 with Interfaces.C_Streams;
13689 package Ada.Sequential_IO.C_Streams is
13690 function C_Stream (F : File_Type)
13691 return Interfaces.C_Streams.FILEs;
13693 (File : in out File_Type;
13694 Mode : in File_Mode;
13695 C_Stream : in Interfaces.C_Streams.FILEs;
13696 Form : in String := "");
13697 end Ada.Sequential_IO.C_Streams;
13699 with Interfaces.C_Streams;
13700 package Ada.Direct_IO.C_Streams is
13701 function C_Stream (F : File_Type)
13702 return Interfaces.C_Streams.FILEs;
13704 (File : in out File_Type;
13705 Mode : in File_Mode;
13706 C_Stream : in Interfaces.C_Streams.FILEs;
13707 Form : in String := "");
13708 end Ada.Direct_IO.C_Streams;
13710 with Interfaces.C_Streams;
13711 package Ada.Text_IO.C_Streams is
13712 function C_Stream (F : File_Type)
13713 return Interfaces.C_Streams.FILEs;
13715 (File : in out File_Type;
13716 Mode : in File_Mode;
13717 C_Stream : in Interfaces.C_Streams.FILEs;
13718 Form : in String := "");
13719 end Ada.Text_IO.C_Streams;
13721 with Interfaces.C_Streams;
13722 package Ada.Wide_Text_IO.C_Streams is
13723 function C_Stream (F : File_Type)
13724 return Interfaces.C_Streams.FILEs;
13726 (File : in out File_Type;
13727 Mode : in File_Mode;
13728 C_Stream : in Interfaces.C_Streams.FILEs;
13729 Form : in String := "");
13730 end Ada.Wide_Text_IO.C_Streams;
13732 with Interfaces.C_Streams;
13733 package Ada.Wide_Wide_Text_IO.C_Streams is
13734 function C_Stream (F : File_Type)
13735 return Interfaces.C_Streams.FILEs;
13737 (File : in out File_Type;
13738 Mode : in File_Mode;
13739 C_Stream : in Interfaces.C_Streams.FILEs;
13740 Form : in String := "");
13741 end Ada.Wide_Wide_Text_IO.C_Streams;
13743 with Interfaces.C_Streams;
13744 package Ada.Stream_IO.C_Streams is
13745 function C_Stream (F : File_Type)
13746 return Interfaces.C_Streams.FILEs;
13748 (File : in out File_Type;
13749 Mode : in File_Mode;
13750 C_Stream : in Interfaces.C_Streams.FILEs;
13751 Form : in String := "");
13752 end Ada.Stream_IO.C_Streams;
13756 In each of these six packages, the @code{C_Stream} function obtains the
13757 @code{FILE} pointer from a currently opened Ada file. It is then
13758 possible to use the @code{Interfaces.C_Streams} package to operate on
13759 this stream, or the stream can be passed to a C program which can
13760 operate on it directly. Of course the program is responsible for
13761 ensuring that only appropriate sequences of operations are executed.
13763 One particular use of relevance to an Ada program is that the
13764 @code{setvbuf} function can be used to control the buffering of the
13765 stream used by an Ada file. In the absence of such a call the standard
13766 default buffering is used.
13768 The @code{Open} procedures in these packages open a file giving an
13769 existing C Stream instead of a file name. Typically this stream is
13770 imported from a C program, allowing an Ada file to operate on an
13773 @node The GNAT Library
13774 @chapter The GNAT Library
13777 The GNAT library contains a number of general and special purpose packages.
13778 It represents functionality that the GNAT developers have found useful, and
13779 which is made available to GNAT users. The packages described here are fully
13780 supported, and upwards compatibility will be maintained in future releases,
13781 so you can use these facilities with the confidence that the same functionality
13782 will be available in future releases.
13784 The chapter here simply gives a brief summary of the facilities available.
13785 The full documentation is found in the spec file for the package. The full
13786 sources of these library packages, including both spec and body, are provided
13787 with all GNAT releases. For example, to find out the full specifications of
13788 the SPITBOL pattern matching capability, including a full tutorial and
13789 extensive examples, look in the @file{g-spipat.ads} file in the library.
13791 For each entry here, the package name (as it would appear in a @code{with}
13792 clause) is given, followed by the name of the corresponding spec file in
13793 parentheses. The packages are children in four hierarchies, @code{Ada},
13794 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13795 GNAT-specific hierarchy.
13797 Note that an application program should only use packages in one of these
13798 four hierarchies if the package is defined in the Ada Reference Manual,
13799 or is listed in this section of the GNAT Programmers Reference Manual.
13800 All other units should be considered internal implementation units and
13801 should not be directly @code{with}'ed by application code. The use of
13802 a @code{with} statement that references one of these internal implementation
13803 units makes an application potentially dependent on changes in versions
13804 of GNAT, and will generate a warning message.
13807 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13808 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13809 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13810 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13811 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13812 * Ada.Command_Line.Environment (a-colien.ads)::
13813 * Ada.Command_Line.Remove (a-colire.ads)::
13814 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13815 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13816 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13817 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13818 * Ada.Exceptions.Traceback (a-exctra.ads)::
13819 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13820 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13821 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13822 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13823 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13824 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13825 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
13826 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13827 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13828 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
13829 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13830 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13831 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
13832 * GNAT.Altivec (g-altive.ads)::
13833 * GNAT.Altivec.Conversions (g-altcon.ads)::
13834 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13835 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13836 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13837 * GNAT.Array_Split (g-arrspl.ads)::
13838 * GNAT.AWK (g-awk.ads)::
13839 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13840 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13841 * GNAT.Bubble_Sort (g-bubsor.ads)::
13842 * GNAT.Bubble_Sort_A (g-busora.ads)::
13843 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13844 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13845 * GNAT.Byte_Swapping (g-bytswa.ads)::
13846 * GNAT.Calendar (g-calend.ads)::
13847 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13848 * GNAT.Case_Util (g-casuti.ads)::
13849 * GNAT.CGI (g-cgi.ads)::
13850 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13851 * GNAT.CGI.Debug (g-cgideb.ads)::
13852 * GNAT.Command_Line (g-comlin.ads)::
13853 * GNAT.Compiler_Version (g-comver.ads)::
13854 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13855 * GNAT.CRC32 (g-crc32.ads)::
13856 * GNAT.Current_Exception (g-curexc.ads)::
13857 * GNAT.Debug_Pools (g-debpoo.ads)::
13858 * GNAT.Debug_Utilities (g-debuti.ads)::
13859 * GNAT.Decode_String (g-decstr.ads)::
13860 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13861 * GNAT.Directory_Operations (g-dirope.ads)::
13862 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13863 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13864 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13865 * GNAT.Encode_String (g-encstr.ads)::
13866 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13867 * GNAT.Exception_Actions (g-excact.ads)::
13868 * GNAT.Exception_Traces (g-exctra.ads)::
13869 * GNAT.Exceptions (g-except.ads)::
13870 * GNAT.Expect (g-expect.ads)::
13871 * GNAT.Float_Control (g-flocon.ads)::
13872 * GNAT.Heap_Sort (g-heasor.ads)::
13873 * GNAT.Heap_Sort_A (g-hesora.ads)::
13874 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13875 * GNAT.HTable (g-htable.ads)::
13876 * GNAT.IO (g-io.ads)::
13877 * GNAT.IO_Aux (g-io_aux.ads)::
13878 * GNAT.Lock_Files (g-locfil.ads)::
13879 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
13880 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
13881 * GNAT.MD5 (g-md5.ads)::
13882 * GNAT.Memory_Dump (g-memdum.ads)::
13883 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13884 * GNAT.OS_Lib (g-os_lib.ads)::
13885 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13886 * GNAT.Random_Numbers (g-rannum.ads)::
13887 * GNAT.Regexp (g-regexp.ads)::
13888 * GNAT.Registry (g-regist.ads)::
13889 * GNAT.Regpat (g-regpat.ads)::
13890 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13891 * GNAT.Semaphores (g-semaph.ads)::
13892 * GNAT.Serial_Communications (g-sercom.ads)::
13893 * GNAT.SHA1 (g-sha1.ads)::
13894 * GNAT.SHA224 (g-sha224.ads)::
13895 * GNAT.SHA256 (g-sha256.ads)::
13896 * GNAT.SHA384 (g-sha384.ads)::
13897 * GNAT.SHA512 (g-sha512.ads)::
13898 * GNAT.Signals (g-signal.ads)::
13899 * GNAT.Sockets (g-socket.ads)::
13900 * GNAT.Source_Info (g-souinf.ads)::
13901 * GNAT.Spelling_Checker (g-speche.ads)::
13902 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13903 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13904 * GNAT.Spitbol (g-spitbo.ads)::
13905 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13906 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13907 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13908 * GNAT.SSE (g-sse.ads)::
13909 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
13910 * GNAT.Strings (g-string.ads)::
13911 * GNAT.String_Split (g-strspl.ads)::
13912 * GNAT.Table (g-table.ads)::
13913 * GNAT.Task_Lock (g-tasloc.ads)::
13914 * GNAT.Threads (g-thread.ads)::
13915 * GNAT.Time_Stamp (g-timsta.ads)::
13916 * GNAT.Traceback (g-traceb.ads)::
13917 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13918 * GNAT.UTF_32 (g-utf_32.ads)::
13919 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13920 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13921 * GNAT.Wide_String_Split (g-wistsp.ads)::
13922 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13923 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13924 * Interfaces.C.Extensions (i-cexten.ads)::
13925 * Interfaces.C.Streams (i-cstrea.ads)::
13926 * Interfaces.CPP (i-cpp.ads)::
13927 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13928 * Interfaces.VxWorks (i-vxwork.ads)::
13929 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13930 * System.Address_Image (s-addima.ads)::
13931 * System.Assertions (s-assert.ads)::
13932 * System.Memory (s-memory.ads)::
13933 * System.Partition_Interface (s-parint.ads)::
13934 * System.Pool_Global (s-pooglo.ads)::
13935 * System.Pool_Local (s-pooloc.ads)::
13936 * System.Restrictions (s-restri.ads)::
13937 * System.Rident (s-rident.ads)::
13938 * System.Strings.Stream_Ops (s-ststop.ads)::
13939 * System.Task_Info (s-tasinf.ads)::
13940 * System.Wch_Cnv (s-wchcnv.ads)::
13941 * System.Wch_Con (s-wchcon.ads)::
13944 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13945 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13946 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13947 @cindex Latin_9 constants for Character
13950 This child of @code{Ada.Characters}
13951 provides a set of definitions corresponding to those in the
13952 RM-defined package @code{Ada.Characters.Latin_1} but with the
13953 few modifications required for @code{Latin-9}
13954 The provision of such a package
13955 is specifically authorized by the Ada Reference Manual
13958 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13959 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13960 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13961 @cindex Latin_1 constants for Wide_Character
13964 This child of @code{Ada.Characters}
13965 provides a set of definitions corresponding to those in the
13966 RM-defined package @code{Ada.Characters.Latin_1} but with the
13967 types of the constants being @code{Wide_Character}
13968 instead of @code{Character}. The provision of such a package
13969 is specifically authorized by the Ada Reference Manual
13972 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13973 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13974 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13975 @cindex Latin_9 constants for Wide_Character
13978 This child of @code{Ada.Characters}
13979 provides a set of definitions corresponding to those in the
13980 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13981 types of the constants being @code{Wide_Character}
13982 instead of @code{Character}. The provision of such a package
13983 is specifically authorized by the Ada Reference Manual
13986 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13987 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13988 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13989 @cindex Latin_1 constants for Wide_Wide_Character
13992 This child of @code{Ada.Characters}
13993 provides a set of definitions corresponding to those in the
13994 RM-defined package @code{Ada.Characters.Latin_1} but with the
13995 types of the constants being @code{Wide_Wide_Character}
13996 instead of @code{Character}. The provision of such a package
13997 is specifically authorized by the Ada Reference Manual
14000 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
14001 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14002 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14003 @cindex Latin_9 constants for Wide_Wide_Character
14006 This child of @code{Ada.Characters}
14007 provides a set of definitions corresponding to those in the
14008 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14009 types of the constants being @code{Wide_Wide_Character}
14010 instead of @code{Character}. The provision of such a package
14011 is specifically authorized by the Ada Reference Manual
14014 @node Ada.Command_Line.Environment (a-colien.ads)
14015 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14016 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14017 @cindex Environment entries
14020 This child of @code{Ada.Command_Line}
14021 provides a mechanism for obtaining environment values on systems
14022 where this concept makes sense.
14024 @node Ada.Command_Line.Remove (a-colire.ads)
14025 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14026 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14027 @cindex Removing command line arguments
14028 @cindex Command line, argument removal
14031 This child of @code{Ada.Command_Line}
14032 provides a mechanism for logically removing
14033 arguments from the argument list. Once removed, an argument is not visible
14034 to further calls on the subprograms in @code{Ada.Command_Line} will not
14035 see the removed argument.
14037 @node Ada.Command_Line.Response_File (a-clrefi.ads)
14038 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14039 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14040 @cindex Response file for command line
14041 @cindex Command line, response file
14042 @cindex Command line, handling long command lines
14045 This child of @code{Ada.Command_Line} provides a mechanism facilities for
14046 getting command line arguments from a text file, called a "response file".
14047 Using a response file allow passing a set of arguments to an executable longer
14048 than the maximum allowed by the system on the command line.
14050 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
14051 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14052 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14053 @cindex C Streams, Interfacing with Direct_IO
14056 This package provides subprograms that allow interfacing between
14057 C streams and @code{Direct_IO}. The stream identifier can be
14058 extracted from a file opened on the Ada side, and an Ada file
14059 can be constructed from a stream opened on the C side.
14061 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
14062 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14063 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14064 @cindex Null_Occurrence, testing for
14067 This child subprogram provides a way of testing for the null
14068 exception occurrence (@code{Null_Occurrence}) without raising
14071 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
14072 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14073 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14074 @cindex Null_Occurrence, testing for
14077 This child subprogram is used for handling otherwise unhandled
14078 exceptions (hence the name last chance), and perform clean ups before
14079 terminating the program. Note that this subprogram never returns.
14081 @node Ada.Exceptions.Traceback (a-exctra.ads)
14082 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14083 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14084 @cindex Traceback for Exception Occurrence
14087 This child package provides the subprogram (@code{Tracebacks}) to
14088 give a traceback array of addresses based on an exception
14091 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
14092 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14093 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14094 @cindex C Streams, Interfacing with Sequential_IO
14097 This package provides subprograms that allow interfacing between
14098 C streams and @code{Sequential_IO}. The stream identifier can be
14099 extracted from a file opened on the Ada side, and an Ada file
14100 can be constructed from a stream opened on the C side.
14102 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
14103 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14104 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14105 @cindex C Streams, Interfacing with Stream_IO
14108 This package provides subprograms that allow interfacing between
14109 C streams and @code{Stream_IO}. The stream identifier can be
14110 extracted from a file opened on the Ada side, and an Ada file
14111 can be constructed from a stream opened on the C side.
14113 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
14114 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14115 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14116 @cindex @code{Unbounded_String}, IO support
14117 @cindex @code{Text_IO}, extensions for unbounded strings
14120 This package provides subprograms for Text_IO for unbounded
14121 strings, avoiding the necessity for an intermediate operation
14122 with ordinary strings.
14124 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
14125 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14126 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14127 @cindex @code{Unbounded_Wide_String}, IO support
14128 @cindex @code{Text_IO}, extensions for unbounded wide strings
14131 This package provides subprograms for Text_IO for unbounded
14132 wide strings, avoiding the necessity for an intermediate operation
14133 with ordinary wide strings.
14135 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
14136 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14137 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14138 @cindex @code{Unbounded_Wide_Wide_String}, IO support
14139 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
14142 This package provides subprograms for Text_IO for unbounded
14143 wide wide strings, avoiding the necessity for an intermediate operation
14144 with ordinary wide wide strings.
14146 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
14147 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14148 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14149 @cindex C Streams, Interfacing with @code{Text_IO}
14152 This package provides subprograms that allow interfacing between
14153 C streams and @code{Text_IO}. The stream identifier can be
14154 extracted from a file opened on the Ada side, and an Ada file
14155 can be constructed from a stream opened on the C side.
14157 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
14158 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14159 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14160 @cindex @code{Text_IO} resetting standard files
14163 This procedure is used to reset the status of the standard files used
14164 by Ada.Text_IO. This is useful in a situation (such as a restart in an
14165 embedded application) where the status of the files may change during
14166 execution (for example a standard input file may be redefined to be
14169 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
14170 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14171 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14172 @cindex Unicode categorization, Wide_Character
14175 This package provides subprograms that allow categorization of
14176 Wide_Character values according to Unicode categories.
14178 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
14179 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14180 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14181 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
14184 This package provides subprograms that allow interfacing between
14185 C streams and @code{Wide_Text_IO}. The stream identifier can be
14186 extracted from a file opened on the Ada side, and an Ada file
14187 can be constructed from a stream opened on the C side.
14189 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
14190 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14191 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14192 @cindex @code{Wide_Text_IO} resetting standard files
14195 This procedure is used to reset the status of the standard files used
14196 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
14197 embedded application) where the status of the files may change during
14198 execution (for example a standard input file may be redefined to be
14201 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
14202 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14203 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14204 @cindex Unicode categorization, Wide_Wide_Character
14207 This package provides subprograms that allow categorization of
14208 Wide_Wide_Character values according to Unicode categories.
14210 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
14211 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14212 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14213 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
14216 This package provides subprograms that allow interfacing between
14217 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
14218 extracted from a file opened on the Ada side, and an Ada file
14219 can be constructed from a stream opened on the C side.
14221 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
14222 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14223 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14224 @cindex @code{Wide_Wide_Text_IO} resetting standard files
14227 This procedure is used to reset the status of the standard files used
14228 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
14229 restart in an embedded application) where the status of the files may
14230 change during execution (for example a standard input file may be
14231 redefined to be interactive).
14233 @node GNAT.Altivec (g-altive.ads)
14234 @section @code{GNAT.Altivec} (@file{g-altive.ads})
14235 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
14239 This is the root package of the GNAT AltiVec binding. It provides
14240 definitions of constants and types common to all the versions of the
14243 @node GNAT.Altivec.Conversions (g-altcon.ads)
14244 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14245 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14249 This package provides the Vector/View conversion routines.
14251 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
14252 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14253 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14257 This package exposes the Ada interface to the AltiVec operations on
14258 vector objects. A soft emulation is included by default in the GNAT
14259 library. The hard binding is provided as a separate package. This unit
14260 is common to both bindings.
14262 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
14263 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14264 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14268 This package exposes the various vector types part of the Ada binding
14269 to AltiVec facilities.
14271 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
14272 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14273 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14277 This package provides public 'View' data types from/to which private
14278 vector representations can be converted via
14279 GNAT.Altivec.Conversions. This allows convenient access to individual
14280 vector elements and provides a simple way to initialize vector
14283 @node GNAT.Array_Split (g-arrspl.ads)
14284 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14285 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14286 @cindex Array splitter
14289 Useful array-manipulation routines: given a set of separators, split
14290 an array wherever the separators appear, and provide direct access
14291 to the resulting slices.
14293 @node GNAT.AWK (g-awk.ads)
14294 @section @code{GNAT.AWK} (@file{g-awk.ads})
14295 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
14300 Provides AWK-like parsing functions, with an easy interface for parsing one
14301 or more files containing formatted data. The file is viewed as a database
14302 where each record is a line and a field is a data element in this line.
14304 @node GNAT.Bounded_Buffers (g-boubuf.ads)
14305 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14306 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14308 @cindex Bounded Buffers
14311 Provides a concurrent generic bounded buffer abstraction. Instances are
14312 useful directly or as parts of the implementations of other abstractions,
14315 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
14316 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14317 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14322 Provides a thread-safe asynchronous intertask mailbox communication facility.
14324 @node GNAT.Bubble_Sort (g-bubsor.ads)
14325 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14326 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14328 @cindex Bubble sort
14331 Provides a general implementation of bubble sort usable for sorting arbitrary
14332 data items. Exchange and comparison procedures are provided by passing
14333 access-to-procedure values.
14335 @node GNAT.Bubble_Sort_A (g-busora.ads)
14336 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14337 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14339 @cindex Bubble sort
14342 Provides a general implementation of bubble sort usable for sorting arbitrary
14343 data items. Move and comparison procedures are provided by passing
14344 access-to-procedure values. This is an older version, retained for
14345 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14347 @node GNAT.Bubble_Sort_G (g-busorg.ads)
14348 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14349 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14351 @cindex Bubble sort
14354 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14355 are provided as generic parameters, this improves efficiency, especially
14356 if the procedures can be inlined, at the expense of duplicating code for
14357 multiple instantiations.
14359 @node GNAT.Byte_Order_Mark (g-byorma.ads)
14360 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14361 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14362 @cindex UTF-8 representation
14363 @cindex Wide characte representations
14366 Provides a routine which given a string, reads the start of the string to
14367 see whether it is one of the standard byte order marks (BOM's) which signal
14368 the encoding of the string. The routine includes detection of special XML
14369 sequences for various UCS input formats.
14371 @node GNAT.Byte_Swapping (g-bytswa.ads)
14372 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14373 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14374 @cindex Byte swapping
14378 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14379 Machine-specific implementations are available in some cases.
14381 @node GNAT.Calendar (g-calend.ads)
14382 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14383 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14384 @cindex @code{Calendar}
14387 Extends the facilities provided by @code{Ada.Calendar} to include handling
14388 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14389 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14390 C @code{timeval} format.
14392 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14393 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14394 @cindex @code{Calendar}
14396 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14398 @node GNAT.CRC32 (g-crc32.ads)
14399 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14400 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14402 @cindex Cyclic Redundancy Check
14405 This package implements the CRC-32 algorithm. For a full description
14406 of this algorithm see
14407 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14408 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14409 Aug.@: 1988. Sarwate, D.V@.
14411 @node GNAT.Case_Util (g-casuti.ads)
14412 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14413 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14414 @cindex Casing utilities
14415 @cindex Character handling (@code{GNAT.Case_Util})
14418 A set of simple routines for handling upper and lower casing of strings
14419 without the overhead of the full casing tables
14420 in @code{Ada.Characters.Handling}.
14422 @node GNAT.CGI (g-cgi.ads)
14423 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14424 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14425 @cindex CGI (Common Gateway Interface)
14428 This is a package for interfacing a GNAT program with a Web server via the
14429 Common Gateway Interface (CGI)@. Basically this package parses the CGI
14430 parameters, which are a set of key/value pairs sent by the Web server. It
14431 builds a table whose index is the key and provides some services to deal
14434 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14435 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14436 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14437 @cindex CGI (Common Gateway Interface) cookie support
14438 @cindex Cookie support in CGI
14441 This is a package to interface a GNAT program with a Web server via the
14442 Common Gateway Interface (CGI). It exports services to deal with Web
14443 cookies (piece of information kept in the Web client software).
14445 @node GNAT.CGI.Debug (g-cgideb.ads)
14446 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14447 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14448 @cindex CGI (Common Gateway Interface) debugging
14451 This is a package to help debugging CGI (Common Gateway Interface)
14452 programs written in Ada.
14454 @node GNAT.Command_Line (g-comlin.ads)
14455 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14456 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14457 @cindex Command line
14460 Provides a high level interface to @code{Ada.Command_Line} facilities,
14461 including the ability to scan for named switches with optional parameters
14462 and expand file names using wild card notations.
14464 @node GNAT.Compiler_Version (g-comver.ads)
14465 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14466 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14467 @cindex Compiler Version
14468 @cindex Version, of compiler
14471 Provides a routine for obtaining the version of the compiler used to
14472 compile the program. More accurately this is the version of the binder
14473 used to bind the program (this will normally be the same as the version
14474 of the compiler if a consistent tool set is used to compile all units
14477 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14478 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14479 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14483 Provides a simple interface to handle Ctrl-C keyboard events.
14485 @node GNAT.Current_Exception (g-curexc.ads)
14486 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14487 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14488 @cindex Current exception
14489 @cindex Exception retrieval
14492 Provides access to information on the current exception that has been raised
14493 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14494 specification syntax.
14495 This is particularly useful in simulating typical facilities for
14496 obtaining information about exceptions provided by Ada 83 compilers.
14498 @node GNAT.Debug_Pools (g-debpoo.ads)
14499 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14500 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14502 @cindex Debug pools
14503 @cindex Memory corruption debugging
14506 Provide a debugging storage pools that helps tracking memory corruption
14507 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14508 @value{EDITION} User's Guide}.
14510 @node GNAT.Debug_Utilities (g-debuti.ads)
14511 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14512 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14516 Provides a few useful utilities for debugging purposes, including conversion
14517 to and from string images of address values. Supports both C and Ada formats
14518 for hexadecimal literals.
14520 @node GNAT.Decode_String (g-decstr.ads)
14521 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14522 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14523 @cindex Decoding strings
14524 @cindex String decoding
14525 @cindex Wide character encoding
14530 A generic package providing routines for decoding wide character and wide wide
14531 character strings encoded as sequences of 8-bit characters using a specified
14532 encoding method. Includes validation routines, and also routines for stepping
14533 to next or previous encoded character in an encoded string.
14534 Useful in conjunction with Unicode character coding. Note there is a
14535 preinstantiation for UTF-8. See next entry.
14537 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14538 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14539 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14540 @cindex Decoding strings
14541 @cindex Decoding UTF-8 strings
14542 @cindex UTF-8 string decoding
14543 @cindex Wide character decoding
14548 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14550 @node GNAT.Directory_Operations (g-dirope.ads)
14551 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14552 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14553 @cindex Directory operations
14556 Provides a set of routines for manipulating directories, including changing
14557 the current directory, making new directories, and scanning the files in a
14560 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14561 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14562 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14563 @cindex Directory operations iteration
14566 A child unit of GNAT.Directory_Operations providing additional operations
14567 for iterating through directories.
14569 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14570 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14571 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14572 @cindex Hash tables
14575 A generic implementation of hash tables that can be used to hash arbitrary
14576 data. Provided in two forms, a simple form with built in hash functions,
14577 and a more complex form in which the hash function is supplied.
14580 This package provides a facility similar to that of @code{GNAT.HTable},
14581 except that this package declares a type that can be used to define
14582 dynamic instances of the hash table, while an instantiation of
14583 @code{GNAT.HTable} creates a single instance of the hash table.
14585 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14586 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14587 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14588 @cindex Table implementation
14589 @cindex Arrays, extendable
14592 A generic package providing a single dimension array abstraction where the
14593 length of the array can be dynamically modified.
14596 This package provides a facility similar to that of @code{GNAT.Table},
14597 except that this package declares a type that can be used to define
14598 dynamic instances of the table, while an instantiation of
14599 @code{GNAT.Table} creates a single instance of the table type.
14601 @node GNAT.Encode_String (g-encstr.ads)
14602 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14603 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14604 @cindex Encoding strings
14605 @cindex String encoding
14606 @cindex Wide character encoding
14611 A generic package providing routines for encoding wide character and wide
14612 wide character strings as sequences of 8-bit characters using a specified
14613 encoding method. Useful in conjunction with Unicode character coding.
14614 Note there is a preinstantiation for UTF-8. See next entry.
14616 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14617 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14618 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14619 @cindex Encoding strings
14620 @cindex Encoding UTF-8 strings
14621 @cindex UTF-8 string encoding
14622 @cindex Wide character encoding
14627 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14629 @node GNAT.Exception_Actions (g-excact.ads)
14630 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14631 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14632 @cindex Exception actions
14635 Provides callbacks when an exception is raised. Callbacks can be registered
14636 for specific exceptions, or when any exception is raised. This
14637 can be used for instance to force a core dump to ease debugging.
14639 @node GNAT.Exception_Traces (g-exctra.ads)
14640 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14641 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14642 @cindex Exception traces
14646 Provides an interface allowing to control automatic output upon exception
14649 @node GNAT.Exceptions (g-except.ads)
14650 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14651 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14652 @cindex Exceptions, Pure
14653 @cindex Pure packages, exceptions
14656 Normally it is not possible to raise an exception with
14657 a message from a subprogram in a pure package, since the
14658 necessary types and subprograms are in @code{Ada.Exceptions}
14659 which is not a pure unit. @code{GNAT.Exceptions} provides a
14660 facility for getting around this limitation for a few
14661 predefined exceptions, and for example allow raising
14662 @code{Constraint_Error} with a message from a pure subprogram.
14664 @node GNAT.Expect (g-expect.ads)
14665 @section @code{GNAT.Expect} (@file{g-expect.ads})
14666 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14669 Provides a set of subprograms similar to what is available
14670 with the standard Tcl Expect tool.
14671 It allows you to easily spawn and communicate with an external process.
14672 You can send commands or inputs to the process, and compare the output
14673 with some expected regular expression. Currently @code{GNAT.Expect}
14674 is implemented on all native GNAT ports except for OpenVMS@.
14675 It is not implemented for cross ports, and in particular is not
14676 implemented for VxWorks or LynxOS@.
14678 @node GNAT.Float_Control (g-flocon.ads)
14679 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14680 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14681 @cindex Floating-Point Processor
14684 Provides an interface for resetting the floating-point processor into the
14685 mode required for correct semantic operation in Ada. Some third party
14686 library calls may cause this mode to be modified, and the Reset procedure
14687 in this package can be used to reestablish the required mode.
14689 @node GNAT.Heap_Sort (g-heasor.ads)
14690 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14691 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14695 Provides a general implementation of heap sort usable for sorting arbitrary
14696 data items. Exchange and comparison procedures are provided by passing
14697 access-to-procedure values. The algorithm used is a modified heap sort
14698 that performs approximately N*log(N) comparisons in the worst case.
14700 @node GNAT.Heap_Sort_A (g-hesora.ads)
14701 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14702 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14706 Provides a general implementation of heap sort usable for sorting arbitrary
14707 data items. Move and comparison procedures are provided by passing
14708 access-to-procedure values. The algorithm used is a modified heap sort
14709 that performs approximately N*log(N) comparisons in the worst case.
14710 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14711 interface, but may be slightly more efficient.
14713 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14714 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14715 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14719 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14720 are provided as generic parameters, this improves efficiency, especially
14721 if the procedures can be inlined, at the expense of duplicating code for
14722 multiple instantiations.
14724 @node GNAT.HTable (g-htable.ads)
14725 @section @code{GNAT.HTable} (@file{g-htable.ads})
14726 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14727 @cindex Hash tables
14730 A generic implementation of hash tables that can be used to hash arbitrary
14731 data. Provides two approaches, one a simple static approach, and the other
14732 allowing arbitrary dynamic hash tables.
14734 @node GNAT.IO (g-io.ads)
14735 @section @code{GNAT.IO} (@file{g-io.ads})
14736 @cindex @code{GNAT.IO} (@file{g-io.ads})
14738 @cindex Input/Output facilities
14741 A simple preelaborable input-output package that provides a subset of
14742 simple Text_IO functions for reading characters and strings from
14743 Standard_Input, and writing characters, strings and integers to either
14744 Standard_Output or Standard_Error.
14746 @node GNAT.IO_Aux (g-io_aux.ads)
14747 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14748 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14750 @cindex Input/Output facilities
14752 Provides some auxiliary functions for use with Text_IO, including a test
14753 for whether a file exists, and functions for reading a line of text.
14755 @node GNAT.Lock_Files (g-locfil.ads)
14756 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14757 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14758 @cindex File locking
14759 @cindex Locking using files
14762 Provides a general interface for using files as locks. Can be used for
14763 providing program level synchronization.
14765 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
14766 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
14767 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
14768 @cindex Random number generation
14771 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
14772 a modified version of the Blum-Blum-Shub generator.
14774 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
14775 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
14776 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
14777 @cindex Random number generation
14780 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
14781 a modified version of the Blum-Blum-Shub generator.
14783 @node GNAT.MD5 (g-md5.ads)
14784 @section @code{GNAT.MD5} (@file{g-md5.ads})
14785 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14786 @cindex Message Digest MD5
14789 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14791 @node GNAT.Memory_Dump (g-memdum.ads)
14792 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14793 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14794 @cindex Dump Memory
14797 Provides a convenient routine for dumping raw memory to either the
14798 standard output or standard error files. Uses GNAT.IO for actual
14801 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14802 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14803 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14804 @cindex Exception, obtaining most recent
14807 Provides access to the most recently raised exception. Can be used for
14808 various logging purposes, including duplicating functionality of some
14809 Ada 83 implementation dependent extensions.
14811 @node GNAT.OS_Lib (g-os_lib.ads)
14812 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14813 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14814 @cindex Operating System interface
14815 @cindex Spawn capability
14818 Provides a range of target independent operating system interface functions,
14819 including time/date management, file operations, subprocess management,
14820 including a portable spawn procedure, and access to environment variables
14821 and error return codes.
14823 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14824 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14825 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14826 @cindex Hash functions
14829 Provides a generator of static minimal perfect hash functions. No
14830 collisions occur and each item can be retrieved from the table in one
14831 probe (perfect property). The hash table size corresponds to the exact
14832 size of the key set and no larger (minimal property). The key set has to
14833 be know in advance (static property). The hash functions are also order
14834 preserving. If w2 is inserted after w1 in the generator, their
14835 hashcode are in the same order. These hashing functions are very
14836 convenient for use with realtime applications.
14838 @node GNAT.Random_Numbers (g-rannum.ads)
14839 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14840 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14841 @cindex Random number generation
14844 Provides random number capabilities which extend those available in the
14845 standard Ada library and are more convenient to use.
14847 @node GNAT.Regexp (g-regexp.ads)
14848 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14849 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14850 @cindex Regular expressions
14851 @cindex Pattern matching
14854 A simple implementation of regular expressions, using a subset of regular
14855 expression syntax copied from familiar Unix style utilities. This is the
14856 simples of the three pattern matching packages provided, and is particularly
14857 suitable for ``file globbing'' applications.
14859 @node GNAT.Registry (g-regist.ads)
14860 @section @code{GNAT.Registry} (@file{g-regist.ads})
14861 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14862 @cindex Windows Registry
14865 This is a high level binding to the Windows registry. It is possible to
14866 do simple things like reading a key value, creating a new key. For full
14867 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14868 package provided with the Win32Ada binding
14870 @node GNAT.Regpat (g-regpat.ads)
14871 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14872 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14873 @cindex Regular expressions
14874 @cindex Pattern matching
14877 A complete implementation of Unix-style regular expression matching, copied
14878 from the original V7 style regular expression library written in C by
14879 Henry Spencer (and binary compatible with this C library).
14881 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14882 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14883 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14884 @cindex Secondary Stack Info
14887 Provide the capability to query the high water mark of the current task's
14890 @node GNAT.Semaphores (g-semaph.ads)
14891 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14892 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14896 Provides classic counting and binary semaphores using protected types.
14898 @node GNAT.Serial_Communications (g-sercom.ads)
14899 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14900 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14901 @cindex Serial_Communications
14904 Provides a simple interface to send and receive data over a serial
14905 port. This is only supported on GNU/Linux and Windows.
14907 @node GNAT.SHA1 (g-sha1.ads)
14908 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14909 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14910 @cindex Secure Hash Algorithm SHA-1
14913 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
14916 @node GNAT.SHA224 (g-sha224.ads)
14917 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
14918 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
14919 @cindex Secure Hash Algorithm SHA-224
14922 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
14924 @node GNAT.SHA256 (g-sha256.ads)
14925 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
14926 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
14927 @cindex Secure Hash Algorithm SHA-256
14930 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
14932 @node GNAT.SHA384 (g-sha384.ads)
14933 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
14934 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
14935 @cindex Secure Hash Algorithm SHA-384
14938 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
14940 @node GNAT.SHA512 (g-sha512.ads)
14941 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
14942 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
14943 @cindex Secure Hash Algorithm SHA-512
14946 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
14948 @node GNAT.Signals (g-signal.ads)
14949 @section @code{GNAT.Signals} (@file{g-signal.ads})
14950 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14954 Provides the ability to manipulate the blocked status of signals on supported
14957 @node GNAT.Sockets (g-socket.ads)
14958 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14959 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14963 A high level and portable interface to develop sockets based applications.
14964 This package is based on the sockets thin binding found in
14965 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14966 on all native GNAT ports except for OpenVMS@. It is not implemented
14967 for the LynxOS@ cross port.
14969 @node GNAT.Source_Info (g-souinf.ads)
14970 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14971 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14972 @cindex Source Information
14975 Provides subprograms that give access to source code information known at
14976 compile time, such as the current file name and line number.
14978 @node GNAT.Spelling_Checker (g-speche.ads)
14979 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14980 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14981 @cindex Spell checking
14984 Provides a function for determining whether one string is a plausible
14985 near misspelling of another string.
14987 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14988 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14989 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14990 @cindex Spell checking
14993 Provides a generic function that can be instantiated with a string type for
14994 determining whether one string is a plausible near misspelling of another
14997 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14998 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14999 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15000 @cindex SPITBOL pattern matching
15001 @cindex Pattern matching
15004 A complete implementation of SNOBOL4 style pattern matching. This is the
15005 most elaborate of the pattern matching packages provided. It fully duplicates
15006 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
15007 efficient algorithm developed by Robert Dewar for the SPITBOL system.
15009 @node GNAT.Spitbol (g-spitbo.ads)
15010 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15011 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15012 @cindex SPITBOL interface
15015 The top level package of the collection of SPITBOL-style functionality, this
15016 package provides basic SNOBOL4 string manipulation functions, such as
15017 Pad, Reverse, Trim, Substr capability, as well as a generic table function
15018 useful for constructing arbitrary mappings from strings in the style of
15019 the SNOBOL4 TABLE function.
15021 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
15022 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15023 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15024 @cindex Sets of strings
15025 @cindex SPITBOL Tables
15028 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15029 for type @code{Standard.Boolean}, giving an implementation of sets of
15032 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
15033 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15034 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15035 @cindex Integer maps
15037 @cindex SPITBOL Tables
15040 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15041 for type @code{Standard.Integer}, giving an implementation of maps
15042 from string to integer values.
15044 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
15045 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15046 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15047 @cindex String maps
15049 @cindex SPITBOL Tables
15052 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
15053 a variable length string type, giving an implementation of general
15054 maps from strings to strings.
15056 @node GNAT.SSE (g-sse.ads)
15057 @section @code{GNAT.SSE} (@file{g-sse.ads})
15058 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
15061 Root of a set of units aimed at offering Ada bindings to a subset of
15062 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
15063 targets. It exposes vector component types together with a general
15064 introduction to the binding contents and use.
15066 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
15067 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15068 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15071 SSE vector types for use with SSE related intrinsics.
15073 @node GNAT.Strings (g-string.ads)
15074 @section @code{GNAT.Strings} (@file{g-string.ads})
15075 @cindex @code{GNAT.Strings} (@file{g-string.ads})
15078 Common String access types and related subprograms. Basically it
15079 defines a string access and an array of string access types.
15081 @node GNAT.String_Split (g-strspl.ads)
15082 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
15083 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
15084 @cindex String splitter
15087 Useful string manipulation routines: given a set of separators, split
15088 a string wherever the separators appear, and provide direct access
15089 to the resulting slices. This package is instantiated from
15090 @code{GNAT.Array_Split}.
15092 @node GNAT.Table (g-table.ads)
15093 @section @code{GNAT.Table} (@file{g-table.ads})
15094 @cindex @code{GNAT.Table} (@file{g-table.ads})
15095 @cindex Table implementation
15096 @cindex Arrays, extendable
15099 A generic package providing a single dimension array abstraction where the
15100 length of the array can be dynamically modified.
15103 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
15104 except that this package declares a single instance of the table type,
15105 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
15106 used to define dynamic instances of the table.
15108 @node GNAT.Task_Lock (g-tasloc.ads)
15109 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15110 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15111 @cindex Task synchronization
15112 @cindex Task locking
15116 A very simple facility for locking and unlocking sections of code using a
15117 single global task lock. Appropriate for use in situations where contention
15118 between tasks is very rarely expected.
15120 @node GNAT.Time_Stamp (g-timsta.ads)
15121 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15122 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15124 @cindex Current time
15127 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
15128 represents the current date and time in ISO 8601 format. This is a very simple
15129 routine with minimal code and there are no dependencies on any other unit.
15131 @node GNAT.Threads (g-thread.ads)
15132 @section @code{GNAT.Threads} (@file{g-thread.ads})
15133 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
15134 @cindex Foreign threads
15135 @cindex Threads, foreign
15138 Provides facilities for dealing with foreign threads which need to be known
15139 by the GNAT run-time system. Consult the documentation of this package for
15140 further details if your program has threads that are created by a non-Ada
15141 environment which then accesses Ada code.
15143 @node GNAT.Traceback (g-traceb.ads)
15144 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
15145 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
15146 @cindex Trace back facilities
15149 Provides a facility for obtaining non-symbolic traceback information, useful
15150 in various debugging situations.
15152 @node GNAT.Traceback.Symbolic (g-trasym.ads)
15153 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15154 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15155 @cindex Trace back facilities
15157 @node GNAT.UTF_32 (g-utf_32.ads)
15158 @section @code{GNAT.UTF_32} (@file{g-table.ads})
15159 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
15160 @cindex Wide character codes
15163 This is a package intended to be used in conjunction with the
15164 @code{Wide_Character} type in Ada 95 and the
15165 @code{Wide_Wide_Character} type in Ada 2005 (available
15166 in @code{GNAT} in Ada 2005 mode). This package contains
15167 Unicode categorization routines, as well as lexical
15168 categorization routines corresponding to the Ada 2005
15169 lexical rules for identifiers and strings, and also a
15170 lower case to upper case fold routine corresponding to
15171 the Ada 2005 rules for identifier equivalence.
15173 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
15174 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15175 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15176 @cindex Spell checking
15179 Provides a function for determining whether one wide wide string is a plausible
15180 near misspelling of another wide wide string, where the strings are represented
15181 using the UTF_32_String type defined in System.Wch_Cnv.
15183 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
15184 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15185 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15186 @cindex Spell checking
15189 Provides a function for determining whether one wide string is a plausible
15190 near misspelling of another wide string.
15192 @node GNAT.Wide_String_Split (g-wistsp.ads)
15193 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15194 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15195 @cindex Wide_String splitter
15198 Useful wide string manipulation routines: given a set of separators, split
15199 a wide string wherever the separators appear, and provide direct access
15200 to the resulting slices. This package is instantiated from
15201 @code{GNAT.Array_Split}.
15203 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
15204 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15205 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15206 @cindex Spell checking
15209 Provides a function for determining whether one wide wide string is a plausible
15210 near misspelling of another wide wide string.
15212 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
15213 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15214 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15215 @cindex Wide_Wide_String splitter
15218 Useful wide wide string manipulation routines: given a set of separators, split
15219 a wide wide string wherever the separators appear, and provide direct access
15220 to the resulting slices. This package is instantiated from
15221 @code{GNAT.Array_Split}.
15223 @node Interfaces.C.Extensions (i-cexten.ads)
15224 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15225 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15228 This package contains additional C-related definitions, intended
15229 for use with either manually or automatically generated bindings
15232 @node Interfaces.C.Streams (i-cstrea.ads)
15233 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15234 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15235 @cindex C streams, interfacing
15238 This package is a binding for the most commonly used operations
15241 @node Interfaces.CPP (i-cpp.ads)
15242 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
15243 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
15244 @cindex C++ interfacing
15245 @cindex Interfacing, to C++
15248 This package provides facilities for use in interfacing to C++. It
15249 is primarily intended to be used in connection with automated tools
15250 for the generation of C++ interfaces.
15252 @node Interfaces.Packed_Decimal (i-pacdec.ads)
15253 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15254 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15255 @cindex IBM Packed Format
15256 @cindex Packed Decimal
15259 This package provides a set of routines for conversions to and
15260 from a packed decimal format compatible with that used on IBM
15263 @node Interfaces.VxWorks (i-vxwork.ads)
15264 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15265 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15266 @cindex Interfacing to VxWorks
15267 @cindex VxWorks, interfacing
15270 This package provides a limited binding to the VxWorks API.
15271 In particular, it interfaces with the
15272 VxWorks hardware interrupt facilities.
15274 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
15275 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15276 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15277 @cindex Interfacing to VxWorks' I/O
15278 @cindex VxWorks, I/O interfacing
15279 @cindex VxWorks, Get_Immediate
15280 @cindex Get_Immediate, VxWorks
15283 This package provides a binding to the ioctl (IO/Control)
15284 function of VxWorks, defining a set of option values and
15285 function codes. A particular use of this package is
15286 to enable the use of Get_Immediate under VxWorks.
15288 @node System.Address_Image (s-addima.ads)
15289 @section @code{System.Address_Image} (@file{s-addima.ads})
15290 @cindex @code{System.Address_Image} (@file{s-addima.ads})
15291 @cindex Address image
15292 @cindex Image, of an address
15295 This function provides a useful debugging
15296 function that gives an (implementation dependent)
15297 string which identifies an address.
15299 @node System.Assertions (s-assert.ads)
15300 @section @code{System.Assertions} (@file{s-assert.ads})
15301 @cindex @code{System.Assertions} (@file{s-assert.ads})
15303 @cindex Assert_Failure, exception
15306 This package provides the declaration of the exception raised
15307 by an run-time assertion failure, as well as the routine that
15308 is used internally to raise this assertion.
15310 @node System.Memory (s-memory.ads)
15311 @section @code{System.Memory} (@file{s-memory.ads})
15312 @cindex @code{System.Memory} (@file{s-memory.ads})
15313 @cindex Memory allocation
15316 This package provides the interface to the low level routines used
15317 by the generated code for allocation and freeing storage for the
15318 default storage pool (analogous to the C routines malloc and free.
15319 It also provides a reallocation interface analogous to the C routine
15320 realloc. The body of this unit may be modified to provide alternative
15321 allocation mechanisms for the default pool, and in addition, direct
15322 calls to this unit may be made for low level allocation uses (for
15323 example see the body of @code{GNAT.Tables}).
15325 @node System.Partition_Interface (s-parint.ads)
15326 @section @code{System.Partition_Interface} (@file{s-parint.ads})
15327 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
15328 @cindex Partition interfacing functions
15331 This package provides facilities for partition interfacing. It
15332 is used primarily in a distribution context when using Annex E
15335 @node System.Pool_Global (s-pooglo.ads)
15336 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
15337 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
15338 @cindex Storage pool, global
15339 @cindex Global storage pool
15342 This package provides a storage pool that is equivalent to the default
15343 storage pool used for access types for which no pool is specifically
15344 declared. It uses malloc/free to allocate/free and does not attempt to
15345 do any automatic reclamation.
15347 @node System.Pool_Local (s-pooloc.ads)
15348 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
15349 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
15350 @cindex Storage pool, local
15351 @cindex Local storage pool
15354 This package provides a storage pool that is intended for use with locally
15355 defined access types. It uses malloc/free for allocate/free, and maintains
15356 a list of allocated blocks, so that all storage allocated for the pool can
15357 be freed automatically when the pool is finalized.
15359 @node System.Restrictions (s-restri.ads)
15360 @section @code{System.Restrictions} (@file{s-restri.ads})
15361 @cindex @code{System.Restrictions} (@file{s-restri.ads})
15362 @cindex Run-time restrictions access
15365 This package provides facilities for accessing at run time
15366 the status of restrictions specified at compile time for
15367 the partition. Information is available both with regard
15368 to actual restrictions specified, and with regard to
15369 compiler determined information on which restrictions
15370 are violated by one or more packages in the partition.
15372 @node System.Rident (s-rident.ads)
15373 @section @code{System.Rident} (@file{s-rident.ads})
15374 @cindex @code{System.Rident} (@file{s-rident.ads})
15375 @cindex Restrictions definitions
15378 This package provides definitions of the restrictions
15379 identifiers supported by GNAT, and also the format of
15380 the restrictions provided in package System.Restrictions.
15381 It is not normally necessary to @code{with} this generic package
15382 since the necessary instantiation is included in
15383 package System.Restrictions.
15385 @node System.Strings.Stream_Ops (s-ststop.ads)
15386 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15387 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15388 @cindex Stream operations
15389 @cindex String stream operations
15392 This package provides a set of stream subprograms for standard string types.
15393 It is intended primarily to support implicit use of such subprograms when
15394 stream attributes are applied to string types, but the subprograms in this
15395 package can be used directly by application programs.
15397 @node System.Task_Info (s-tasinf.ads)
15398 @section @code{System.Task_Info} (@file{s-tasinf.ads})
15399 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15400 @cindex Task_Info pragma
15403 This package provides target dependent functionality that is used
15404 to support the @code{Task_Info} pragma
15406 @node System.Wch_Cnv (s-wchcnv.ads)
15407 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15408 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15409 @cindex Wide Character, Representation
15410 @cindex Wide String, Conversion
15411 @cindex Representation of wide characters
15414 This package provides routines for converting between
15415 wide and wide wide characters and a representation as a value of type
15416 @code{Standard.String}, using a specified wide character
15417 encoding method. It uses definitions in
15418 package @code{System.Wch_Con}.
15420 @node System.Wch_Con (s-wchcon.ads)
15421 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15422 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15425 This package provides definitions and descriptions of
15426 the various methods used for encoding wide characters
15427 in ordinary strings. These definitions are used by
15428 the package @code{System.Wch_Cnv}.
15430 @node Interfacing to Other Languages
15431 @chapter Interfacing to Other Languages
15433 The facilities in annex B of the Ada Reference Manual are fully
15434 implemented in GNAT, and in addition, a full interface to C++ is
15438 * Interfacing to C::
15439 * Interfacing to C++::
15440 * Interfacing to COBOL::
15441 * Interfacing to Fortran::
15442 * Interfacing to non-GNAT Ada code::
15445 @node Interfacing to C
15446 @section Interfacing to C
15449 Interfacing to C with GNAT can use one of two approaches:
15453 The types in the package @code{Interfaces.C} may be used.
15455 Standard Ada types may be used directly. This may be less portable to
15456 other compilers, but will work on all GNAT compilers, which guarantee
15457 correspondence between the C and Ada types.
15461 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15462 effect, since this is the default. The following table shows the
15463 correspondence between Ada scalar types and the corresponding C types.
15468 @item Short_Integer
15470 @item Short_Short_Integer
15474 @item Long_Long_Integer
15482 @item Long_Long_Float
15483 This is the longest floating-point type supported by the hardware.
15487 Additionally, there are the following general correspondences between Ada
15491 Ada enumeration types map to C enumeration types directly if pragma
15492 @code{Convention C} is specified, which causes them to have int
15493 length. Without pragma @code{Convention C}, Ada enumeration types map to
15494 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15495 @code{int}, respectively) depending on the number of values passed.
15496 This is the only case in which pragma @code{Convention C} affects the
15497 representation of an Ada type.
15500 Ada access types map to C pointers, except for the case of pointers to
15501 unconstrained types in Ada, which have no direct C equivalent.
15504 Ada arrays map directly to C arrays.
15507 Ada records map directly to C structures.
15510 Packed Ada records map to C structures where all members are bit fields
15511 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15514 @node Interfacing to C++
15515 @section Interfacing to C++
15518 The interface to C++ makes use of the following pragmas, which are
15519 primarily intended to be constructed automatically using a binding generator
15520 tool, although it is possible to construct them by hand. No suitable binding
15521 generator tool is supplied with GNAT though.
15523 Using these pragmas it is possible to achieve complete
15524 inter-operability between Ada tagged types and C++ class definitions.
15525 See @ref{Implementation Defined Pragmas}, for more details.
15528 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15529 The argument denotes an entity in the current declarative region that is
15530 declared as a tagged or untagged record type. It indicates that the type
15531 corresponds to an externally declared C++ class type, and is to be laid
15532 out the same way that C++ would lay out the type.
15534 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15535 for backward compatibility but its functionality is available
15536 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15538 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15539 This pragma identifies an imported function (imported in the usual way
15540 with pragma @code{Import}) as corresponding to a C++ constructor.
15543 @node Interfacing to COBOL
15544 @section Interfacing to COBOL
15547 Interfacing to COBOL is achieved as described in section B.4 of
15548 the Ada Reference Manual.
15550 @node Interfacing to Fortran
15551 @section Interfacing to Fortran
15554 Interfacing to Fortran is achieved as described in section B.5 of the
15555 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
15556 multi-dimensional array causes the array to be stored in column-major
15557 order as required for convenient interface to Fortran.
15559 @node Interfacing to non-GNAT Ada code
15560 @section Interfacing to non-GNAT Ada code
15562 It is possible to specify the convention @code{Ada} in a pragma
15563 @code{Import} or pragma @code{Export}. However this refers to
15564 the calling conventions used by GNAT, which may or may not be
15565 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15566 compiler to allow interoperation.
15568 If arguments types are kept simple, and if the foreign compiler generally
15569 follows system calling conventions, then it may be possible to integrate
15570 files compiled by other Ada compilers, provided that the elaboration
15571 issues are adequately addressed (for example by eliminating the
15572 need for any load time elaboration).
15574 In particular, GNAT running on VMS is designed to
15575 be highly compatible with the DEC Ada 83 compiler, so this is one
15576 case in which it is possible to import foreign units of this type,
15577 provided that the data items passed are restricted to simple scalar
15578 values or simple record types without variants, or simple array
15579 types with fixed bounds.
15581 @node Specialized Needs Annexes
15582 @chapter Specialized Needs Annexes
15585 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15586 required in all implementations. However, as described in this chapter,
15587 GNAT implements all of these annexes:
15590 @item Systems Programming (Annex C)
15591 The Systems Programming Annex is fully implemented.
15593 @item Real-Time Systems (Annex D)
15594 The Real-Time Systems Annex is fully implemented.
15596 @item Distributed Systems (Annex E)
15597 Stub generation is fully implemented in the GNAT compiler. In addition,
15598 a complete compatible PCS is available as part of the GLADE system,
15599 a separate product. When the two
15600 products are used in conjunction, this annex is fully implemented.
15602 @item Information Systems (Annex F)
15603 The Information Systems annex is fully implemented.
15605 @item Numerics (Annex G)
15606 The Numerics Annex is fully implemented.
15608 @item Safety and Security / High-Integrity Systems (Annex H)
15609 The Safety and Security Annex (termed the High-Integrity Systems Annex
15610 in Ada 2005) is fully implemented.
15613 @node Implementation of Specific Ada Features
15614 @chapter Implementation of Specific Ada Features
15617 This chapter describes the GNAT implementation of several Ada language
15621 * Machine Code Insertions::
15622 * GNAT Implementation of Tasking::
15623 * GNAT Implementation of Shared Passive Packages::
15624 * Code Generation for Array Aggregates::
15625 * The Size of Discriminated Records with Default Discriminants::
15626 * Strict Conformance to the Ada Reference Manual::
15629 @node Machine Code Insertions
15630 @section Machine Code Insertions
15631 @cindex Machine Code insertions
15634 Package @code{Machine_Code} provides machine code support as described
15635 in the Ada Reference Manual in two separate forms:
15638 Machine code statements, consisting of qualified expressions that
15639 fit the requirements of RM section 13.8.
15641 An intrinsic callable procedure, providing an alternative mechanism of
15642 including machine instructions in a subprogram.
15646 The two features are similar, and both are closely related to the mechanism
15647 provided by the asm instruction in the GNU C compiler. Full understanding
15648 and use of the facilities in this package requires understanding the asm
15649 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15650 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15652 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15653 semantic restrictions and effects as described below. Both are provided so
15654 that the procedure call can be used as a statement, and the function call
15655 can be used to form a code_statement.
15657 The first example given in the GCC documentation is the C @code{asm}
15660 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15664 The equivalent can be written for GNAT as:
15666 @smallexample @c ada
15667 Asm ("fsinx %1 %0",
15668 My_Float'Asm_Output ("=f", result),
15669 My_Float'Asm_Input ("f", angle));
15673 The first argument to @code{Asm} is the assembler template, and is
15674 identical to what is used in GNU C@. This string must be a static
15675 expression. The second argument is the output operand list. It is
15676 either a single @code{Asm_Output} attribute reference, or a list of such
15677 references enclosed in parentheses (technically an array aggregate of
15680 The @code{Asm_Output} attribute denotes a function that takes two
15681 parameters. The first is a string, the second is the name of a variable
15682 of the type designated by the attribute prefix. The first (string)
15683 argument is required to be a static expression and designates the
15684 constraint for the parameter (e.g.@: what kind of register is
15685 required). The second argument is the variable to be updated with the
15686 result. The possible values for constraint are the same as those used in
15687 the RTL, and are dependent on the configuration file used to build the
15688 GCC back end. If there are no output operands, then this argument may
15689 either be omitted, or explicitly given as @code{No_Output_Operands}.
15691 The second argument of @code{@var{my_float}'Asm_Output} functions as
15692 though it were an @code{out} parameter, which is a little curious, but
15693 all names have the form of expressions, so there is no syntactic
15694 irregularity, even though normally functions would not be permitted
15695 @code{out} parameters. The third argument is the list of input
15696 operands. It is either a single @code{Asm_Input} attribute reference, or
15697 a list of such references enclosed in parentheses (technically an array
15698 aggregate of such references).
15700 The @code{Asm_Input} attribute denotes a function that takes two
15701 parameters. The first is a string, the second is an expression of the
15702 type designated by the prefix. The first (string) argument is required
15703 to be a static expression, and is the constraint for the parameter,
15704 (e.g.@: what kind of register is required). The second argument is the
15705 value to be used as the input argument. The possible values for the
15706 constant are the same as those used in the RTL, and are dependent on
15707 the configuration file used to built the GCC back end.
15709 If there are no input operands, this argument may either be omitted, or
15710 explicitly given as @code{No_Input_Operands}. The fourth argument, not
15711 present in the above example, is a list of register names, called the
15712 @dfn{clobber} argument. This argument, if given, must be a static string
15713 expression, and is a space or comma separated list of names of registers
15714 that must be considered destroyed as a result of the @code{Asm} call. If
15715 this argument is the null string (the default value), then the code
15716 generator assumes that no additional registers are destroyed.
15718 The fifth argument, not present in the above example, called the
15719 @dfn{volatile} argument, is by default @code{False}. It can be set to
15720 the literal value @code{True} to indicate to the code generator that all
15721 optimizations with respect to the instruction specified should be
15722 suppressed, and that in particular, for an instruction that has outputs,
15723 the instruction will still be generated, even if none of the outputs are
15724 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15725 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15726 Generally it is strongly advisable to use Volatile for any ASM statement
15727 that is missing either input or output operands, or when two or more ASM
15728 statements appear in sequence, to avoid unwanted optimizations. A warning
15729 is generated if this advice is not followed.
15731 The @code{Asm} subprograms may be used in two ways. First the procedure
15732 forms can be used anywhere a procedure call would be valid, and
15733 correspond to what the RM calls ``intrinsic'' routines. Such calls can
15734 be used to intersperse machine instructions with other Ada statements.
15735 Second, the function forms, which return a dummy value of the limited
15736 private type @code{Asm_Insn}, can be used in code statements, and indeed
15737 this is the only context where such calls are allowed. Code statements
15738 appear as aggregates of the form:
15740 @smallexample @c ada
15741 Asm_Insn'(Asm (@dots{}));
15742 Asm_Insn'(Asm_Volatile (@dots{}));
15746 In accordance with RM rules, such code statements are allowed only
15747 within subprograms whose entire body consists of such statements. It is
15748 not permissible to intermix such statements with other Ada statements.
15750 Typically the form using intrinsic procedure calls is more convenient
15751 and more flexible. The code statement form is provided to meet the RM
15752 suggestion that such a facility should be made available. The following
15753 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15754 is used, the arguments may be given in arbitrary order, following the
15755 normal rules for use of positional and named arguments)
15759 [Template =>] static_string_EXPRESSION
15760 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
15761 [,[Inputs =>] INPUT_OPERAND_LIST ]
15762 [,[Clobber =>] static_string_EXPRESSION ]
15763 [,[Volatile =>] static_boolean_EXPRESSION] )
15765 OUTPUT_OPERAND_LIST ::=
15766 [PREFIX.]No_Output_Operands
15767 | OUTPUT_OPERAND_ATTRIBUTE
15768 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15770 OUTPUT_OPERAND_ATTRIBUTE ::=
15771 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15773 INPUT_OPERAND_LIST ::=
15774 [PREFIX.]No_Input_Operands
15775 | INPUT_OPERAND_ATTRIBUTE
15776 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15778 INPUT_OPERAND_ATTRIBUTE ::=
15779 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15783 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15784 are declared in the package @code{Machine_Code} and must be referenced
15785 according to normal visibility rules. In particular if there is no
15786 @code{use} clause for this package, then appropriate package name
15787 qualification is required.
15789 @node GNAT Implementation of Tasking
15790 @section GNAT Implementation of Tasking
15793 This chapter outlines the basic GNAT approach to tasking (in particular,
15794 a multi-layered library for portability) and discusses issues related
15795 to compliance with the Real-Time Systems Annex.
15798 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15799 * Ensuring Compliance with the Real-Time Annex::
15802 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15803 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15806 GNAT's run-time support comprises two layers:
15809 @item GNARL (GNAT Run-time Layer)
15810 @item GNULL (GNAT Low-level Library)
15814 In GNAT, Ada's tasking services rely on a platform and OS independent
15815 layer known as GNARL@. This code is responsible for implementing the
15816 correct semantics of Ada's task creation, rendezvous, protected
15819 GNARL decomposes Ada's tasking semantics into simpler lower level
15820 operations such as create a thread, set the priority of a thread,
15821 yield, create a lock, lock/unlock, etc. The spec for these low-level
15822 operations constitutes GNULLI, the GNULL Interface. This interface is
15823 directly inspired from the POSIX real-time API@.
15825 If the underlying executive or OS implements the POSIX standard
15826 faithfully, the GNULL Interface maps as is to the services offered by
15827 the underlying kernel. Otherwise, some target dependent glue code maps
15828 the services offered by the underlying kernel to the semantics expected
15831 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
15832 key point is that each Ada task is mapped on a thread in the underlying
15833 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
15835 In addition Ada task priorities map onto the underlying thread priorities.
15836 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15840 The underlying scheduler is used to schedule the Ada tasks. This
15841 makes Ada tasks as efficient as kernel threads from a scheduling
15845 Interaction with code written in C containing threads is eased
15846 since at the lowest level Ada tasks and C threads map onto the same
15847 underlying kernel concept.
15850 When an Ada task is blocked during I/O the remaining Ada tasks are
15854 On multiprocessor systems Ada tasks can execute in parallel.
15858 Some threads libraries offer a mechanism to fork a new process, with the
15859 child process duplicating the threads from the parent.
15861 support this functionality when the parent contains more than one task.
15862 @cindex Forking a new process
15864 @node Ensuring Compliance with the Real-Time Annex
15865 @subsection Ensuring Compliance with the Real-Time Annex
15866 @cindex Real-Time Systems Annex compliance
15869 Although mapping Ada tasks onto
15870 the underlying threads has significant advantages, it does create some
15871 complications when it comes to respecting the scheduling semantics
15872 specified in the real-time annex (Annex D).
15874 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15875 scheduling policy states:
15878 @emph{When the active priority of a ready task that is not running
15879 changes, or the setting of its base priority takes effect, the
15880 task is removed from the ready queue for its old active priority
15881 and is added at the tail of the ready queue for its new active
15882 priority, except in the case where the active priority is lowered
15883 due to the loss of inherited priority, in which case the task is
15884 added at the head of the ready queue for its new active priority.}
15888 While most kernels do put tasks at the end of the priority queue when
15889 a task changes its priority, (which respects the main
15890 FIFO_Within_Priorities requirement), almost none keep a thread at the
15891 beginning of its priority queue when its priority drops from the loss
15892 of inherited priority.
15894 As a result most vendors have provided incomplete Annex D implementations.
15896 The GNAT run-time, has a nice cooperative solution to this problem
15897 which ensures that accurate FIFO_Within_Priorities semantics are
15900 The principle is as follows. When an Ada task T is about to start
15901 running, it checks whether some other Ada task R with the same
15902 priority as T has been suspended due to the loss of priority
15903 inheritance. If this is the case, T yields and is placed at the end of
15904 its priority queue. When R arrives at the front of the queue it
15907 Note that this simple scheme preserves the relative order of the tasks
15908 that were ready to execute in the priority queue where R has been
15911 @node GNAT Implementation of Shared Passive Packages
15912 @section GNAT Implementation of Shared Passive Packages
15913 @cindex Shared passive packages
15916 GNAT fully implements the pragma @code{Shared_Passive} for
15917 @cindex pragma @code{Shared_Passive}
15918 the purpose of designating shared passive packages.
15919 This allows the use of passive partitions in the
15920 context described in the Ada Reference Manual; i.e., for communication
15921 between separate partitions of a distributed application using the
15922 features in Annex E.
15924 @cindex Distribution Systems Annex
15926 However, the implementation approach used by GNAT provides for more
15927 extensive usage as follows:
15930 @item Communication between separate programs
15932 This allows separate programs to access the data in passive
15933 partitions, using protected objects for synchronization where
15934 needed. The only requirement is that the two programs have a
15935 common shared file system. It is even possible for programs
15936 running on different machines with different architectures
15937 (e.g.@: different endianness) to communicate via the data in
15938 a passive partition.
15940 @item Persistence between program runs
15942 The data in a passive package can persist from one run of a
15943 program to another, so that a later program sees the final
15944 values stored by a previous run of the same program.
15949 The implementation approach used is to store the data in files. A
15950 separate stream file is created for each object in the package, and
15951 an access to an object causes the corresponding file to be read or
15954 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15955 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15956 set to the directory to be used for these files.
15957 The files in this directory
15958 have names that correspond to their fully qualified names. For
15959 example, if we have the package
15961 @smallexample @c ada
15963 pragma Shared_Passive (X);
15970 and the environment variable is set to @code{/stemp/}, then the files created
15971 will have the names:
15979 These files are created when a value is initially written to the object, and
15980 the files are retained until manually deleted. This provides the persistence
15981 semantics. If no file exists, it means that no partition has assigned a value
15982 to the variable; in this case the initial value declared in the package
15983 will be used. This model ensures that there are no issues in synchronizing
15984 the elaboration process, since elaboration of passive packages elaborates the
15985 initial values, but does not create the files.
15987 The files are written using normal @code{Stream_IO} access.
15988 If you want to be able
15989 to communicate between programs or partitions running on different
15990 architectures, then you should use the XDR versions of the stream attribute
15991 routines, since these are architecture independent.
15993 If active synchronization is required for access to the variables in the
15994 shared passive package, then as described in the Ada Reference Manual, the
15995 package may contain protected objects used for this purpose. In this case
15996 a lock file (whose name is @file{___lock} (three underscores)
15997 is created in the shared memory directory.
15998 @cindex @file{___lock} file (for shared passive packages)
15999 This is used to provide the required locking
16000 semantics for proper protected object synchronization.
16002 As of January 2003, GNAT supports shared passive packages on all platforms
16003 except for OpenVMS.
16005 @node Code Generation for Array Aggregates
16006 @section Code Generation for Array Aggregates
16009 * Static constant aggregates with static bounds::
16010 * Constant aggregates with unconstrained nominal types::
16011 * Aggregates with static bounds::
16012 * Aggregates with non-static bounds::
16013 * Aggregates in assignment statements::
16017 Aggregates have a rich syntax and allow the user to specify the values of
16018 complex data structures by means of a single construct. As a result, the
16019 code generated for aggregates can be quite complex and involve loops, case
16020 statements and multiple assignments. In the simplest cases, however, the
16021 compiler will recognize aggregates whose components and constraints are
16022 fully static, and in those cases the compiler will generate little or no
16023 executable code. The following is an outline of the code that GNAT generates
16024 for various aggregate constructs. For further details, you will find it
16025 useful to examine the output produced by the -gnatG flag to see the expanded
16026 source that is input to the code generator. You may also want to examine
16027 the assembly code generated at various levels of optimization.
16029 The code generated for aggregates depends on the context, the component values,
16030 and the type. In the context of an object declaration the code generated is
16031 generally simpler than in the case of an assignment. As a general rule, static
16032 component values and static subtypes also lead to simpler code.
16034 @node Static constant aggregates with static bounds
16035 @subsection Static constant aggregates with static bounds
16038 For the declarations:
16039 @smallexample @c ada
16040 type One_Dim is array (1..10) of integer;
16041 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
16045 GNAT generates no executable code: the constant ar0 is placed in static memory.
16046 The same is true for constant aggregates with named associations:
16048 @smallexample @c ada
16049 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
16050 Cr3 : constant One_Dim := (others => 7777);
16054 The same is true for multidimensional constant arrays such as:
16056 @smallexample @c ada
16057 type two_dim is array (1..3, 1..3) of integer;
16058 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
16062 The same is true for arrays of one-dimensional arrays: the following are
16065 @smallexample @c ada
16066 type ar1b is array (1..3) of boolean;
16067 type ar_ar is array (1..3) of ar1b;
16068 None : constant ar1b := (others => false); -- fully static
16069 None2 : constant ar_ar := (1..3 => None); -- fully static
16073 However, for multidimensional aggregates with named associations, GNAT will
16074 generate assignments and loops, even if all associations are static. The
16075 following two declarations generate a loop for the first dimension, and
16076 individual component assignments for the second dimension:
16078 @smallexample @c ada
16079 Zero1: constant two_dim := (1..3 => (1..3 => 0));
16080 Zero2: constant two_dim := (others => (others => 0));
16083 @node Constant aggregates with unconstrained nominal types
16084 @subsection Constant aggregates with unconstrained nominal types
16087 In such cases the aggregate itself establishes the subtype, so that
16088 associations with @code{others} cannot be used. GNAT determines the
16089 bounds for the actual subtype of the aggregate, and allocates the
16090 aggregate statically as well. No code is generated for the following:
16092 @smallexample @c ada
16093 type One_Unc is array (natural range <>) of integer;
16094 Cr_Unc : constant One_Unc := (12,24,36);
16097 @node Aggregates with static bounds
16098 @subsection Aggregates with static bounds
16101 In all previous examples the aggregate was the initial (and immutable) value
16102 of a constant. If the aggregate initializes a variable, then code is generated
16103 for it as a combination of individual assignments and loops over the target
16104 object. The declarations
16106 @smallexample @c ada
16107 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
16108 Cr_Var2 : One_Dim := (others > -1);
16112 generate the equivalent of
16114 @smallexample @c ada
16120 for I in Cr_Var2'range loop
16125 @node Aggregates with non-static bounds
16126 @subsection Aggregates with non-static bounds
16129 If the bounds of the aggregate are not statically compatible with the bounds
16130 of the nominal subtype of the target, then constraint checks have to be
16131 generated on the bounds. For a multidimensional array, constraint checks may
16132 have to be applied to sub-arrays individually, if they do not have statically
16133 compatible subtypes.
16135 @node Aggregates in assignment statements
16136 @subsection Aggregates in assignment statements
16139 In general, aggregate assignment requires the construction of a temporary,
16140 and a copy from the temporary to the target of the assignment. This is because
16141 it is not always possible to convert the assignment into a series of individual
16142 component assignments. For example, consider the simple case:
16144 @smallexample @c ada
16149 This cannot be converted into:
16151 @smallexample @c ada
16157 So the aggregate has to be built first in a separate location, and then
16158 copied into the target. GNAT recognizes simple cases where this intermediate
16159 step is not required, and the assignments can be performed in place, directly
16160 into the target. The following sufficient criteria are applied:
16164 The bounds of the aggregate are static, and the associations are static.
16166 The components of the aggregate are static constants, names of
16167 simple variables that are not renamings, or expressions not involving
16168 indexed components whose operands obey these rules.
16172 If any of these conditions are violated, the aggregate will be built in
16173 a temporary (created either by the front-end or the code generator) and then
16174 that temporary will be copied onto the target.
16176 @node The Size of Discriminated Records with Default Discriminants
16177 @section The Size of Discriminated Records with Default Discriminants
16180 If a discriminated type @code{T} has discriminants with default values, it is
16181 possible to declare an object of this type without providing an explicit
16184 @smallexample @c ada
16186 type Size is range 1..100;
16188 type Rec (D : Size := 15) is record
16189 Name : String (1..D);
16197 Such an object is said to be @emph{unconstrained}.
16198 The discriminant of the object
16199 can be modified by a full assignment to the object, as long as it preserves the
16200 relation between the value of the discriminant, and the value of the components
16203 @smallexample @c ada
16205 Word := (3, "yes");
16207 Word := (5, "maybe");
16209 Word := (5, "no"); -- raises Constraint_Error
16214 In order to support this behavior efficiently, an unconstrained object is
16215 given the maximum size that any value of the type requires. In the case
16216 above, @code{Word} has storage for the discriminant and for
16217 a @code{String} of length 100.
16218 It is important to note that unconstrained objects do not require dynamic
16219 allocation. It would be an improper implementation to place on the heap those
16220 components whose size depends on discriminants. (This improper implementation
16221 was used by some Ada83 compilers, where the @code{Name} component above
16223 been stored as a pointer to a dynamic string). Following the principle that
16224 dynamic storage management should never be introduced implicitly,
16225 an Ada compiler should reserve the full size for an unconstrained declared
16226 object, and place it on the stack.
16228 This maximum size approach
16229 has been a source of surprise to some users, who expect the default
16230 values of the discriminants to determine the size reserved for an
16231 unconstrained object: ``If the default is 15, why should the object occupy
16233 The answer, of course, is that the discriminant may be later modified,
16234 and its full range of values must be taken into account. This is why the
16239 type Rec (D : Positive := 15) is record
16240 Name : String (1..D);
16248 is flagged by the compiler with a warning:
16249 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
16250 because the required size includes @code{Positive'Last}
16251 bytes. As the first example indicates, the proper approach is to declare an
16252 index type of ``reasonable'' range so that unconstrained objects are not too
16255 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
16256 created in the heap by means of an allocator, then it is @emph{not}
16258 it is constrained by the default values of the discriminants, and those values
16259 cannot be modified by full assignment. This is because in the presence of
16260 aliasing all views of the object (which may be manipulated by different tasks,
16261 say) must be consistent, so it is imperative that the object, once created,
16264 @node Strict Conformance to the Ada Reference Manual
16265 @section Strict Conformance to the Ada Reference Manual
16268 The dynamic semantics defined by the Ada Reference Manual impose a set of
16269 run-time checks to be generated. By default, the GNAT compiler will insert many
16270 run-time checks into the compiled code, including most of those required by the
16271 Ada Reference Manual. However, there are three checks that are not enabled
16272 in the default mode for efficiency reasons: arithmetic overflow checking for
16273 integer operations (including division by zero), checks for access before
16274 elaboration on subprogram calls, and stack overflow checking (most operating
16275 systems do not perform this check by default).
16277 Strict conformance to the Ada Reference Manual can be achieved by adding
16278 three compiler options for overflow checking for integer operations
16279 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
16280 calls and generic instantiations (@option{-gnatE}), and stack overflow
16281 checking (@option{-fstack-check}).
16283 Note that the result of a floating point arithmetic operation in overflow and
16284 invalid situations, when the @code{Machine_Overflows} attribute of the result
16285 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
16286 case for machines compliant with the IEEE floating-point standard, but on
16287 machines that are not fully compliant with this standard, such as Alpha, the
16288 @option{-mieee} compiler flag must be used for achieving IEEE confirming
16289 behavior (although at the cost of a significant performance penalty), so
16290 infinite and and NaN values are properly generated.
16293 @node Implementation of Ada 2012 Features
16294 @chapter Implementation of Ada 2012 Features
16295 @cindex Ada 2012 implementation status
16297 This chapter contains a complete list of Ada 2012 features that have been
16298 implemented as of GNAT version 6.4. Generally, these features are only
16299 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
16300 @cindex @option{-gnat12} option
16301 or if the configuration pragma @code{Ada_2012} is used.
16302 @cindex pragma @code{Ada_2012}
16303 @cindex configuration pragma @code{Ada_2012}
16304 @cindex @code{Ada_2012} configuration pragma
16305 However, new pragmas, attributes, and restrictions are
16306 unconditionally available, since the Ada 95 standard allows the addition of
16307 new pragmas, attributes, and restrictions (there are exceptions, which are
16308 documented in the individual descriptions), and also certain packages
16309 were made available in earlier versions of Ada.
16311 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
16312 This date shows the implementation date of the feature. Any wavefront
16313 subsequent to this date will contain the indicated feature, as will any
16314 subsequent releases. A date of 0000-00-00 means that GNAT has always
16315 implemented the feature, or implemented it as soon as it appeared as a
16316 binding interpretation.
16318 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
16319 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
16320 The features are ordered based on the relevant sections of the Ada
16321 Reference Manual (``RM''). When a given AI relates to multiple points
16322 in the RM, the earliest is used.
16324 A complete description of the AIs may be found in
16325 @url{www.ada-auth.org/ai05-summary.html}.
16330 @emph{AI-0176 Quantified expressions (2010-09-29)}
16331 @cindex AI-0176 (Ada 2012 feature)
16334 Both universally and existentially quantified expressions are implemented.
16335 They use the new syntax for iterators proposed in AI05-139-2, as well as
16336 the standard Ada loop syntax.
16339 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
16342 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
16343 @cindex AI-0079 (Ada 2012 feature)
16346 Wide characters in the unicode category @i{other_format} are now allowed in
16347 source programs between tokens, but not within a token such as an identifier.
16350 RM References: 2.01 (4/2) 2.02 (7)
16353 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
16354 @cindex AI-0091 (Ada 2012 feature)
16357 Wide characters in the unicode category @i{other_format} are not permitted
16358 within an identifier, since this can be a security problem. The error
16359 message for this case has been improved to be more specific, but GNAT has
16360 never allowed such characters to appear in identifiers.
16363 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)
16366 @emph{AI-0100 Placement of pragmas (2010-07-01)}
16367 @cindex AI-0100 (Ada 2012 feature)
16370 This AI is an earlier version of AI-163. It simplifies the rules
16371 for legal placement of pragmas. In the case of lists that allow pragmas, if
16372 the list may have no elements, then the list may consist solely of pragmas.
16375 RM References: 2.08 (7)
16378 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
16379 @cindex AI-0163 (Ada 2012 feature)
16382 A statement sequence may be composed entirely of pragmas. It is no longer
16383 necessary to add a dummy @code{null} statement to make the sequence legal.
16386 RM References: 2.08 (7) 2.08 (16)
16390 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
16391 @cindex AI-0080 (Ada 2012 feature)
16394 This is an editorial change only, described as non-testable in the AI.
16397 RM References: 3.01 (7)
16401 @emph{AI-0183 Aspect specifications (2010-08-16)}
16402 @cindex AI-0183 (Ada 2012 feature)
16405 Aspect specifications have been fully implemented except for pre and post-
16406 conditions, and type invariants, which have their own separate AI's. All
16407 forms of declarations listed in the AI are supported. The following is a
16408 list of the aspects supported (with GNAT implementation aspects marked)
16410 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
16411 @item @code{Ada_2005} @tab -- GNAT
16412 @item @code{Ada_2012} @tab -- GNAT
16413 @item @code{Address} @tab
16414 @item @code{Alignment} @tab
16415 @item @code{Atomic} @tab
16416 @item @code{Atomic_Components} @tab
16417 @item @code{Bit_Order} @tab
16418 @item @code{Component_Size} @tab
16419 @item @code{Discard_Names} @tab
16420 @item @code{External_Tag} @tab
16421 @item @code{Favor_Top_Level} @tab -- GNAT
16422 @item @code{Inline} @tab
16423 @item @code{Inline_Always} @tab -- GNAT
16424 @item @code{Invariant} @tab
16425 @item @code{Machine_Radix} @tab
16426 @item @code{No_Return} @tab
16427 @item @code{Object_Size} @tab -- GNAT
16428 @item @code{Pack} @tab
16429 @item @code{Persistent_BSS} @tab -- GNAT
16430 @item @code{Post} @tab
16431 @item @code{Pre} @tab
16432 @item @code{Predicate} @tab
16433 @item @code{Preelaborable_Initialization} @tab
16434 @item @code{Pure_Function} @tab -- GNAT
16435 @item @code{Shared} @tab -- GNAT
16436 @item @code{Size} @tab
16437 @item @code{Storage_Pool} @tab
16438 @item @code{Storage_Size} @tab
16439 @item @code{Stream_Size} @tab
16440 @item @code{Suppress} @tab
16441 @item @code{Suppress_Debug_Info} @tab -- GNAT
16442 @item @code{Unchecked_Union} @tab
16443 @item @code{Universal_Aliasing} @tab -- GNAT
16444 @item @code{Unmodified} @tab -- GNAT
16445 @item @code{Unreferenced} @tab -- GNAT
16446 @item @code{Unreferenced_Objects} @tab -- GNAT
16447 @item @code{Unsuppress} @tab
16448 @item @code{Value_Size} @tab -- GNAT
16449 @item @code{Volatile} @tab
16450 @item @code{Volatile_Components}
16451 @item @code{Warnings} @tab -- GNAT
16455 Note that for aspects with an expression, e.g. @code{Size}, the expression is
16456 treated like a default expression (visibility is analyzed at the point of
16457 occurrence of the aspect, but evaluation of the expression occurs at the
16458 freeze point of the entity involved.
16461 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
16462 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
16463 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
16464 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
16465 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
16470 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
16471 @cindex AI-0128 (Ada 2012 feature)
16474 If an equality operator ("=") is declared for a type, then the implicitly
16475 declared inequality operator ("/=") is a primitive operation of the type.
16476 This is the only reasonable interpretation, and is the one always implemented
16477 by GNAT, but the RM was not entirely clear in making this point.
16480 RM References: 3.02.03 (6) 6.06 (6)
16483 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
16484 @cindex AI-0003 (Ada 2012 feature)
16487 In Ada 2012, a qualified expression is considered to be syntatically a name,
16488 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
16489 useful in disambiguating some cases of overloading.
16492 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
16496 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
16497 @cindex AI-0120 (Ada 2012 feature)
16500 This is an RM editorial change only. The section that lists objects that are
16501 constant failed to include the current instance of a protected object
16502 within a protected function. This has always been treated as a constant
16506 RM References: 3.03 (21)
16509 @emph{AI-0008 General access to constrained objects (0000-00-00)}
16510 @cindex AI-0008 (Ada 2012 feature)
16513 The wording in the RM implied that if you have a general access to a
16514 constrained object, it could be used to modify the discriminants. This was
16515 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
16516 has always done so in this situation.
16519 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
16523 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
16524 @cindex AI-0093 (Ada 2012 feature)
16527 This is an editorial change only, to make more widespread use of the Ada 2012
16528 ``immutably limited''.
16531 RM References: 3.03 (23.4/3)
16536 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
16537 @cindex AI-0096 (Ada 2012 feature)
16540 In general it is illegal for a type derived from a formal limited type to be
16541 nonlimited. This AI makes an exception to this rule: derivation is legal
16542 if it appears in the private part of the generic, and the formal type is not
16543 tagged. If the type is tagged, the legality check must be applied to the
16544 private part of the package.
16547 RM References: 3.04 (5.1/2) 6.02 (7)
16551 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
16552 @cindex AI-0181 (Ada 2012 feature)
16555 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
16556 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
16557 @code{Image} and @code{Value} attributes for the character types. Strictly
16558 speaking this is an inconsistency with Ada 95, but in practice the use of
16559 these attributes is so obscure that it will not cause problems.
16562 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
16566 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
16567 @cindex AI-0182 (Ada 2012 feature)
16570 This AI allows @code{Character'Value} to accept the string @code{'?'} where
16571 @code{?} is any character including non-graphic control characters. GNAT has
16572 always accepted such strings. It also allows strings such as
16573 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
16574 permission and raises @code{Constraint_Error}, as is certainly still
16578 RM References: 3.05 (56/2)
16582 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
16583 @cindex AI-0214 (Ada 2012 feature)
16586 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
16587 to have default expressions by allowing them when the type is limited. It
16588 is often useful to define a default value for a discriminant even though
16589 it can't be changed by assignment.
16592 RM References: 3.07 (9.1/2) 3.07.02 (3)
16596 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
16597 @cindex AI-0102 (Ada 2012 feature)
16600 It is illegal to assign an anonymous access constant to an anonymous access
16601 variable. The RM did not have a clear rule to prevent this, but GNAT has
16602 always generated an error for this usage.
16605 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
16609 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
16610 @cindex AI-0158 (Ada 2012 feature)
16613 This AI extends the syntax of membership tests to simplify complex conditions
16614 that can be expressed as membership in a subset of values of any type. It
16615 introduces syntax for a list of expressions that may be used in loop contexts
16619 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
16623 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
16624 @cindex AI-0173 (Ada 2012 feature)
16627 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
16628 with the tag of an abstract type, and @code{False} otherwise.
16631 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
16636 @emph{AI-0076 function with controlling result (0000-00-00)}
16637 @cindex AI-0076 (Ada 2012 feature)
16640 This is an editorial change only. The RM defines calls with controlling
16641 results, but uses the term ``function with controlling result'' without an
16642 explicit definition.
16645 RM References: 3.09.02 (2/2)
16649 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
16650 @cindex AI-0126 (Ada 2012 feature)
16653 This AI clarifies dispatching rules, and simply confirms that dispatching
16654 executes the operation of the parent type when there is no explicitly or
16655 implicitly declared operation for the descendant type. This has always been
16656 the case in all versions of GNAT.
16659 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
16663 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
16664 @cindex AI-0097 (Ada 2012 feature)
16667 The RM as written implied that in some cases it was possible to create an
16668 object of an abstract type, by having an abstract extension inherit a non-
16669 abstract constructor from its parent type. This mistake has been corrected
16670 in GNAT and in the RM, and this construct is now illegal.
16673 RM References: 3.09.03 (4/2)
16677 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
16678 @cindex AI-0203 (Ada 2012 feature)
16681 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
16682 permitted such usage.
16685 RM References: 3.09.03 (8/3)
16689 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
16690 @cindex AI-0198 (Ada 2012 feature)
16693 This AI resolves a conflict between two rules involving inherited abstract
16694 operations and predefined operators. If a derived numeric type inherits
16695 an abstract operator, it overrides the predefined one. This interpretation
16696 was always the one implemented in GNAT.
16699 RM References: 3.09.03 (4/3)
16702 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
16703 @cindex AI-0073 (Ada 2012 feature)
16706 This AI covers a number of issues regarding returning abstract types. In
16707 particular generic fucntions cannot have abstract result types or access
16708 result types designated an abstract type. There are some other cases which
16709 are detailed in the AI. Note that this binding interpretation has not been
16710 retrofitted to operate before Ada 2012 mode, since it caused a significant
16711 number of regressions.
16714 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
16718 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
16719 @cindex AI-0070 (Ada 2012 feature)
16722 This is an editorial change only, there are no testable consequences short of
16723 checking for the absence of generated code for an interface declaration.
16726 RM References: 3.09.04 (18/2)
16730 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
16731 @cindex AI-0208 (Ada 2012 feature)
16734 The wording in the Ada 2005 RM concerning characteristics of incomplete views
16735 was incorrect and implied that some programs intended to be legal were now
16736 illegal. GNAT had never considered such programs illegal, so it has always
16737 implemented the intent of this AI.
16740 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
16744 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
16745 @cindex AI-0162 (Ada 2012 feature)
16748 Incomplete types are made more useful by allowing them to be completed by
16749 private types and private extensions.
16752 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
16757 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
16758 @cindex AI-0098 (Ada 2012 feature)
16761 An unintentional omission in the RM implied some inconsistent restrictions on
16762 the use of anonymous access to subprogram values. These restrictions were not
16763 intentional, and have never been enforced by GNAT.
16766 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
16770 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
16771 @cindex AI-0199 (Ada 2012 feature)
16774 A choice list in a record aggregate can include several components of
16775 (distinct) anonymous access types as long as they have matching designated
16779 RM References: 4.03.01 (16)
16783 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
16784 @cindex AI-0220 (Ada 2012 feature)
16787 This AI addresses a wording problem in the RM that appears to permit some
16788 complex cases of aggregates with non-static discriminants. GNAT has always
16789 implemented the intended semantics.
16792 RM References: 4.03.01 (17)
16795 @emph{AI-0147 Conditional expressions (2009-03-29)}
16796 @cindex AI-0147 (Ada 2012 feature)
16799 Conditional expressions are permitted. The form of such an expression is:
16802 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
16805 The parentheses can be omitted in contexts where parentheses are present
16806 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
16807 clause is omitted, @b{else True} is assumed;
16808 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
16809 @emph{(A implies B)} in standard logic.
16812 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
16813 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
16817 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
16818 @cindex AI-0037 (Ada 2012 feature)
16821 This AI confirms that an association of the form @code{Indx => <>} in an
16822 array aggregate must raise @code{Constraint_Error} if @code{Indx}
16823 is out of range. The RM specified a range check on other associations, but
16824 not when the value of the association was defaulted. GNAT has always inserted
16825 a constraint check on the index value.
16828 RM References: 4.03.03 (29)
16832 @emph{AI-0123 Composability of equality (2010-04-13)}
16833 @cindex AI-0123 (Ada 2012 feature)
16836 Equality of untagged record composes, so that the predefined equality for a
16837 composite type that includes a component of some untagged record type
16838 @code{R} uses the equality operation of @code{R} (which may be user-defined
16839 or predefined). This makes the behavior of untagged records identical to that
16840 of tagged types in this respect.
16842 This change is an incompatibility with previous versions of Ada, but it
16843 corrects a non-uniformity that was often a source of confusion. Analysis of
16844 a large number of industrial programs indicates that in those rare cases
16845 where a composite type had an untagged record component with a user-defined
16846 equality, either there was no use of the composite equality, or else the code
16847 expected the same composability as for tagged types, and thus had a bug that
16848 would be fixed by this change.
16851 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
16856 @emph{AI-0088 The value of exponentiation (0000-00-00)}
16857 @cindex AI-0088 (Ada 2012 feature)
16860 This AI clarifies the equivalence rule given for the dynamic semantics of
16861 exponentiation: the value of the operation can be obtained by repeated
16862 multiplication, but the operation can be implemented otherwise (for example
16863 using the familiar divide-by-two-and-square algorithm, even if this is less
16864 accurate), and does not imply repeated reads of a volatile base.
16867 RM References: 4.05.06 (11)
16870 @emph{AI-0188 Case expressions (2010-01-09)}
16871 @cindex AI-0188 (Ada 2012 feature)
16874 Case expressions are permitted. This allows use of constructs such as:
16876 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
16880 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
16883 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
16884 @cindex AI-0104 (Ada 2012 feature)
16887 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
16888 @code{Constraint_Error} because the default value of the allocated object is
16889 @b{null}. This useless construct is illegal in Ada 2012.
16892 RM References: 4.08 (2)
16895 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
16896 @cindex AI-0157 (Ada 2012 feature)
16899 Allocation and Deallocation from an empty storage pool (i.e. allocation or
16900 deallocation of a pointer for which a static storage size clause of zero
16901 has been given) is now illegal and is detected as such. GNAT
16902 previously gave a warning but not an error.
16905 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
16908 @emph{AI-0179 Statement not required after label (2010-04-10)}
16909 @cindex AI-0179 (Ada 2012 feature)
16912 It is not necessary to have a statement following a label, so a label
16913 can appear at the end of a statement sequence without the need for putting a
16914 null statement afterwards, but it is not allowable to have only labels and
16915 no real statements in a statement sequence.
16918 RM References: 5.01 (2)
16922 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
16923 @cindex AI-139-2 (Ada 2012 feature)
16926 The new syntax for iterating over arrays and containers is now implemented.
16927 Iteration over containers is for now limited to read-only iterators. Only
16928 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
16931 RM References: 5.05
16934 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
16935 @cindex AI-0134 (Ada 2012 feature)
16938 For full conformance, the profiles of anonymous-access-to-subprogram
16939 parameters must match. GNAT has always enforced this rule.
16942 RM References: 6.03.01 (18)
16945 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
16946 @cindex AI-0207 (Ada 2012 feature)
16949 This AI confirms that access_to_constant indication must match for mode
16950 conformance. This was implemented in GNAT when the qualifier was originally
16951 introduced in Ada 2005.
16954 RM References: 6.03.01 (16/2)
16958 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
16959 @cindex AI-0046 (Ada 2012 feature)
16962 For full conformance, in the case of access parameters, the null exclusion
16963 must match (either both or neither must have @code{@b{not null}}).
16966 RM References: 6.03.02 (18)
16970 @emph{AI-0118 The association of parameter associations (0000-00-00)}
16971 @cindex AI-0118 (Ada 2012 feature)
16974 This AI clarifies the rules for named associations in subprogram calls and
16975 generic instantiations. The rules have been in place since Ada 83.
16978 RM References: 6.04.01 (2) 12.03 (9)
16982 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
16983 @cindex AI-0196 (Ada 2012 feature)
16986 Null exclusion checks are not made for @code{@b{out}} parameters when
16987 evaluating the actual parameters. GNAT has never generated these checks.
16990 RM References: 6.04.01 (13)
16993 @emph{AI-0015 Constant return objects (0000-00-00)}
16994 @cindex AI-0015 (Ada 2012 feature)
16997 The return object declared in an @i{extended_return_statement} may be
16998 declared constant. This was always intended, and GNAT has always allowed it.
17001 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
17006 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
17007 @cindex AI-0032 (Ada 2012 feature)
17010 If a function returns a class-wide type, the object of an extended return
17011 statement can be declared with a specific type that is covered by the class-
17012 wide type. This has been implemented in GNAT since the introduction of
17013 extended returns. Note AI-0103 complements this AI by imposing matching
17014 rules for constrained return types.
17017 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
17021 @emph{AI-0103 Static matching for extended return (2010-07-23)}
17022 @cindex AI-0103 (Ada 2012 feature)
17025 If the return subtype of a function is an elementary type or a constrained
17026 type, the subtype indication in an extended return statement must match
17027 statically this return subtype.
17030 RM References: 6.05 (5.2/2)
17034 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
17035 @cindex AI-0058 (Ada 2012 feature)
17038 The RM had some incorrect wording implying wrong treatment of abnormal
17039 completion in an extended return. GNAT has always implemented the intended
17040 correct semantics as described by this AI.
17043 RM References: 6.05 (22/2)
17047 @emph{AI-0050 Raising Constraingt_Errpr early for function call (0000-00-00)}
17048 @cindex AI-0050 (Ada 2012 feature)
17051 The implementation permissions for raising @code{Constraing_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
17052 not take advantage of these incorrect permissions in any case.
17055 RM References: 6.05 (24/2)
17059 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
17060 @cindex AI-0125 (Ada 2012 feature)
17063 In Ada 2012, the declaration of a primitive operation of a type extension
17064 or private extension can also override an inherited primitive that is not
17065 visible at the point of this declaration.
17068 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
17071 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
17072 @cindex AI-0062 (Ada 2012 feature)
17075 A full constant may have a null exclusion even if its associated deferred
17076 constant does not. GNAT has always allowed this.
17079 RM References: 7.04 (6/2) 7.04 (7.1/2)
17083 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
17084 @cindex AI-0178 (Ada 2012 feature)
17087 This AI clarifies the role of incomplete views and plugs an omission in the
17088 RM. GNAT always correctly restricted the use of incomplete views and types.
17091 RM References: 7.05 (3/2) 7.05 (6/2)
17094 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
17095 @cindex AI-0087 (Ada 2012 feature)
17098 The actual for a formal nonlimited derived type cannot be limited. In
17099 particular, a formal derived type that extends a limited interface but which
17100 is not explicitly limited cannot be instantiated with a limited type.
17103 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
17106 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
17107 @cindex AI-0099 (Ada 2012 feature)
17110 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
17111 and therefore depends on the run-time charateristics of an object (i.e. its
17112 tag) and not on its nominal type. As the AI indicates: ``we do not expect
17113 this to affect any implementation''.
17116 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
17121 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
17122 @cindex AI-0064 (Ada 2012 feature)
17125 This is an editorial change only. The intended behavior is already checked
17126 by an existing ACATS test, which GNAT has always executed correctly.
17129 RM References: 7.06.01 (17.1/1)
17132 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
17133 @cindex AI-0026 (Ada 2012 feature)
17136 Record representation clauses concerning Unchecked_Union types cannot mention
17137 the discriminant of the type. The type of a component declared in the variant
17138 part of an Unchecked_Union cannot be controlled, have controlled components,
17139 nor have protected or task parts. If an Unchecked_Union type is declared
17140 within the body of a generic unit or its descendants, then the type of a
17141 component declared in the variant part cannot be a formal private type or a
17142 formal private extension declared within the same generic unit.
17145 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
17149 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
17150 @cindex AI-0205 (Ada 2012 feature)
17153 This AI corrects a simple omission in the RM. Return objects have always
17154 been visible within an extended return statement.
17157 RM References: 8.03 (17)
17161 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
17162 @cindex AI-0042 (Ada 2012 feature)
17165 This AI fixes a wording gap in the RM. An operation of a synchronized
17166 interface can be implemented by a protected or task entry, but the abstract
17167 operation is not being overridden in the usual sense, and it must be stated
17168 separately that this implementation is legal. This has always been the case
17172 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
17175 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
17176 @cindex AI-0030 (Ada 2012 feature)
17179 Requeue is permitted to a protected, synchronized or task interface primitive
17180 providing it is known that the overriding operation is an entry. Otherwise
17181 the requeue statement has the same effect as a procedure call. Use of pragma
17182 @code{Implemented} provides a way to impose a static requirement on the
17183 overriding operation by adhering to one of the implementation kinds: entry,
17184 protected procedure or any of the above.
17187 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
17188 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
17192 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
17193 @cindex AI-0201 (Ada 2012 feature)
17196 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
17197 attribute, then individual components may not be addressable by independent
17198 tasks. However, if the representation clause has no effect (is confirming),
17199 then independence is not compromised. Furthermore, in GNAT, specification of
17200 other appropriately addressable component sizes (e.g. 16 for 8-bit
17201 characters) also preserves independence. GNAT now gives very clear warnings
17202 both for the declaration of such a type, and for any assignment to its components.
17205 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
17208 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
17209 @cindex AI-0009 (Ada 2012 feature)
17212 This AI introduces the new pragmas @code{Independent} and
17213 @code{Independent_Components},
17214 which control guaranteeing independence of access to objects and components.
17215 The AI also requires independence not unaffected by confirming rep clauses.
17218 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
17219 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
17223 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
17224 @cindex AI-0072 (Ada 2012 feature)
17227 This AI clarifies that task signalling for reading @code{'Terminated} only
17228 occurs if the result is True. GNAT semantics has always been consistent with
17229 this notion of task signalling.
17232 RM References: 9.10 (6.1/1)
17235 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
17236 @cindex AI-0108 (Ada 2012 feature)
17239 This AI confirms that an incomplete type from a limited view does not have
17240 discriminants. This has always been the case in GNAT.
17243 RM References: 10.01.01 (12.3/2)
17246 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
17247 @cindex AI-0129 (Ada 2012 feature)
17250 This AI clarifies the description of limited views: a limited view of a
17251 package includes only one view of a type that has an incomplete declaration
17252 and a full declaration (there is no possible ambiguity in a client package).
17253 This AI also fixes an omission: a nested package in the private part has no
17254 limited view. GNAT always implemented this correctly.
17257 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
17262 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
17263 @cindex AI-0077 (Ada 2012 feature)
17266 This AI clarifies that a declaration does not include a context clause,
17267 and confirms that it is illegal to have a context in which both a limited
17268 and a nonlimited view of a package are accessible. Such double visibility
17269 was always rejected by GNAT.
17272 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
17275 @emph{AI-0122 Private with and children of generics (0000-00-00)}
17276 @cindex AI-0122 (Ada 2012 feature)
17279 This AI clarifies the visibility of private children of generic units within
17280 instantiations of a parent. GNAT has always handled this correctly.
17283 RM References: 10.01.02 (12/2)
17288 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
17289 @cindex AI-0040 (Ada 2012 feature)
17292 This AI confirms that a limited with clause in a child unit cannot name
17293 an ancestor of the unit. This has always been checked in GNAT.
17296 RM References: 10.01.02 (20/2)
17299 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
17300 @cindex AI-0132 (Ada 2012 feature)
17303 This AI fills a gap in the description of library unit pragmas. The pragma
17304 clearly must apply to a library unit, even if it does not carry the name
17305 of the enclosing unit. GNAT has always enforced the required check.
17308 RM References: 10.01.05 (7)
17312 @emph{AI-0034 Categorization of limited views (0000-00-00)}
17313 @cindex AI-0034 (Ada 2012 feature)
17316 The RM makes certain limited with clauses illegal because of categorization
17317 considerations, when the corresponding normal with would be legal. This is
17318 not intended, and GNAT has always implemented the recommended behavior.
17321 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
17325 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
17326 @cindex AI-0035 (Ada 2012 feature)
17329 This AI remedies some inconsistencies in the legality rules for Pure units.
17330 Derived access types are legal in a pure unit (on the assumption that the
17331 rule for a zero storage pool size has been enforced on the ancestor type).
17332 The rules are enforced in generic instances and in subunits. GNAT has always
17333 implemented the recommended behavior.
17336 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)
17340 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
17341 @cindex AI-0219 (Ada 2012 feature)
17344 This AI refines the rules for the cases with limited parameters which do not
17345 allow the implementations to omit ``redundant''. GNAT now properly conforms
17346 to the requirements of this binding interpretation.
17349 RM References: 10.02.01 (18/2)
17352 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
17353 @cindex AI-0043 (Ada 2012 feature)
17356 This AI covers various omissions in the RM regarding the raising of
17357 exceptions. GNAT has always implemented the intended semantics.
17360 RM References: 11.04.01 (10.1/2) 11 (2)
17364 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
17365 @cindex AI-0200 (Ada 2012 feature)
17368 This AI plugs a gap in the RM which appeared to allow some obviously intended
17369 illegal instantiations. GNAT has never allowed these instantiations.
17372 RM References: 12.07 (16)
17376 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
17377 @cindex AI-0112 (Ada 2012 feature)
17380 This AI concerns giving names to various representation aspects, but the
17381 practical effect is simply to make the use of duplicate
17382 @code{Atomic}[@code{_Components}],
17383 @code{Volatile}[@code{_Components}] and
17384 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
17385 now performs this required check.
17388 RM References: 13.01 (8)
17391 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
17392 @cindex AI-0106 (Ada 2012 feature)
17395 The RM appeared to allow representation pragmas on generic formal parameters,
17396 but this was not intended, and GNAT has never permitted this usage.
17399 RM References: 13.01 (9.1/1)
17403 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
17404 @cindex AI-0012 (Ada 2012 feature)
17407 It is now illegal to give an inappropriate component size or a pragma
17408 @code{Pack} that attempts to change the component size in the case of atomic
17409 or aliased components. Previously GNAT ignored such an attempt with a
17413 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
17417 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
17418 @cindex AI-0039 (Ada 2012 feature)
17421 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
17422 for stream attributes, but these were never useful and are now illegal. GNAT
17423 has always regarded such expressions as illegal.
17426 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
17430 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
17431 @cindex AI-0095 (Ada 2012 feature)
17434 The prefix of @code{'Address} cannot statically denote a subprogram with
17435 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
17436 @code{Program_Error} if the prefix denotes a subprogram with convention
17440 RM References: 13.03 (11/1)
17444 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
17445 @cindex AI-0116 (Ada 2012 feature)
17448 This AI requires that the alignment of a class-wide object be no greater
17449 than the alignment of any type in the class. GNAT has always followed this
17453 RM References: 13.03 (29) 13.11 (16)
17457 @emph{AI-0146 Type invariants (2009-09-21)}
17458 @cindex AI-0146 (Ada 2012 feature)
17461 Type invariants may be specified for private types using the aspect notation.
17462 Aspect @code{Invariant} may be specified for any private type,
17463 @code{Invariant'Class} can
17464 only be specified for tagged types, and is inherited by any descendent of the
17465 tagged types. The invariant is a boolean expression that is tested for being
17466 true in the following situations: conversions to the private type, object
17467 declarations for the private type that are default initialized, and
17469 parameters and returned result on return from any primitive operation for
17470 the type that is visible to a client.
17473 RM References: 13.03.03 (00)
17476 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
17477 @cindex AI-0078 (Ada 2012 feature)
17480 In Ada 2012, compilers are required to support unchecked conversion where the
17481 target alignment is a multiple of the source alignment. GNAT always supported
17482 this case (and indeed all cases of differing alignments, doing copies where
17483 required if the alignment was reduced).
17486 RM References: 13.09 (7)
17490 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
17491 @cindex AI-0195 (Ada 2012 feature)
17494 The handling of invalid values is now designated to be implementation
17495 defined. This is a documentation change only, requiring Annex M in the GNAT
17496 Reference Manual to document this handling.
17497 In GNAT, checks for invalid values are made
17498 only when necessary to avoid erroneous behavior. Operations like assignments
17499 which cannot cause erroneous behavior ignore the possibility of invalid
17500 values and do not do a check. The date given above applies only to the
17501 documentation change, this behavior has always been implemented by GNAT.
17504 RM References: 13.09.01 (10)
17507 @emph{AI-0193 Alignment of allocators (2010-09-16)}
17508 @cindex AI-0193 (Ada 2012 feature)
17511 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
17512 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
17516 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
17517 13.11.01 (2) 13.11.01 (3)
17521 @emph{AI-0177 Parameterized expressions (2010-07-10)}
17522 @cindex AI-0177 (Ada 2012 feature)
17525 The new Ada 2012 notion of parameterized expressions is implemented. The form
17528 @i{function specification} @b{is} (@i{expression})
17532 This is exactly equivalent to the
17533 corresponding function body that returns the expression, but it can appear
17534 in a package spec. Note that the expression must be parenthesized.
17537 RM References: 13.11.01 (3/2)
17540 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
17541 @cindex AI-0033 (Ada 2012 feature)
17544 Neither of these two pragmas may appear within a generic template, because
17545 the generic might be instantiated at other than the library level.
17548 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
17552 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
17553 @cindex AI-0161 (Ada 2012 feature)
17556 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
17557 of the default stream attributes for elementary types. If this restriction is
17558 in force, then it is necessary to provide explicit subprograms for any
17559 stream attributes used.
17562 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
17565 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
17566 @cindex AI-0194 (Ada 2012 feature)
17569 The @code{Stream_Size} attribute returns the default number of bits in the
17570 stream representation of the given type.
17571 This value is not affected by the presence
17572 of stream subprogram attributes for the type. GNAT has always implemented
17573 this interpretation.
17576 RM References: 13.13.02 (1.2/2)
17579 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
17580 @cindex AI-0109 (Ada 2012 feature)
17583 This AI is an editorial change only. It removes the need for a tag check
17584 that can never fail.
17587 RM References: 13.13.02 (34/2)
17590 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
17591 @cindex AI-0007 (Ada 2012 feature)
17594 The RM as written appeared to limit the possibilities of declaring read
17595 attribute procedures for private scalar types. This limitation was not
17596 intended, and has never been enforced by GNAT.
17599 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
17603 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
17604 @cindex AI-0065 (Ada 2012 feature)
17607 This AI clarifies the fact that all remote access types support external
17608 streaming. This fixes an obvious oversight in the definition of the
17609 language, and GNAT always implemented the intended correct rules.
17612 RM References: 13.13.02 (52/2)
17615 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
17616 @cindex AI-0019 (Ada 2012 feature)
17619 The RM suggests that primitive subprograms of a specific tagged type are
17620 frozen when the tagged type is frozen. This would be an incompatible change
17621 and is not intended. GNAT has never attempted this kind of freezing and its
17622 behavior is consistent with the recommendation of this AI.
17625 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)
17628 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
17629 @cindex AI-0017 (Ada 2012 feature)
17632 So-called ``Taft-amendment types'' (i.e., types that are completed in package
17633 bodies) are not frozen by the occurrence of bodies in the
17634 enclosing declarative part. GNAT always implemented this properly.
17637 RM References: 13.14 (3/1)
17641 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
17642 @cindex AI-0060 (Ada 2012 feature)
17645 This AI extends the definition of remote access types to include access
17646 to limited, synchronized, protected or task class-wide interface types.
17647 GNAT already implemented this extension.
17650 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
17653 @emph{AI-0114 Classification of letters (0000-00-00)}
17654 @cindex AI-0114 (Ada 2012 feature)
17657 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
17658 181 (@code{MICRO SIGN}), and
17659 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
17660 lower case letters by Unicode.
17661 However, they are not allowed in identifiers, and they
17662 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
17663 This behavior is consistent with that defined in Ada 95.
17666 RM References: A.03.02 (59) A.04.06 (7)
17670 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
17671 @cindex AI-0185 (Ada 2012 feature)
17674 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
17675 classification functions for @code{Wide_Character} and
17676 @code{Wide_Wide_Character}, as well as providing
17677 case folding routines for @code{Wide_[Wide_]Character} and
17678 @code{Wide_[Wide_]String}.
17681 RM References: A.03.05 (0) A.03.06 (0)
17685 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
17686 @cindex AI-0031 (Ada 2012 feature)
17689 A new version of @code{Find_Token} is added to all relevant string packages,
17690 with an extra parameter @code{From}. Instead of starting at the first
17691 character of the string, the search for a matching Token starts at the
17692 character indexed by the value of @code{From}.
17693 These procedures are available in all versions of Ada
17694 but if used in versions earlier than Ada 2012 they will generate a warning
17695 that an Ada 2012 subprogram is being used.
17698 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
17703 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
17704 @cindex AI-0056 (Ada 2012 feature)
17707 The wording in the Ada 2005 RM implied an incompatible handling of the
17708 @code{Index} functions, resulting in raising an exception instead of
17709 returning zero in some situations.
17710 This was not intended and has been corrected.
17711 GNAT always returned zero, and is thus consistent with this AI.
17714 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
17718 @emph{AI-0137 String encoding package (2010-03-25)}
17719 @cindex AI-0137 (Ada 2012 feature)
17722 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
17723 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
17724 and @code{Wide_Wide_Strings} have been
17725 implemented. These packages (whose documentation can be found in the spec
17726 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
17727 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
17728 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
17729 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
17730 UTF-16), as well as conversions between the different UTF encodings. With
17731 the exception of @code{Wide_Wide_Strings}, these packages are available in
17732 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
17733 The @code{Wide_Wide_Strings package}
17734 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
17735 mode since it uses @code{Wide_Wide_Character}).
17738 RM References: A.04.11
17741 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
17742 @cindex AI-0038 (Ada 2012 feature)
17745 These are minor errors in the description on three points. The intent on
17746 all these points has always been clear, and GNAT has always implemented the
17747 correct intended semantics.
17750 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)
17753 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
17754 @cindex AI-0044 (Ada 2012 feature)
17757 This AI places restrictions on allowed instantiations of generic containers.
17758 These restrictions are not checked by the compiler, so there is nothing to
17759 change in the implementation. This affects only the RM documentation.
17762 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)
17765 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
17766 @cindex AI-0127 (Ada 2012 feature)
17769 This package provides an interface for identifying the current locale.
17772 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
17773 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
17778 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
17779 @cindex AI-0002 (Ada 2012 feature)
17782 The compiler is not required to support exporting an Ada subprogram with
17783 convention C if there are parameters or a return type of an unconstrained
17784 array type (such as @code{String}). GNAT allows such declarations but
17785 generates warnings. It is possible, but complicated, to write the
17786 corresponding C code and certainly such code would be specific to GNAT and
17790 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
17794 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
17795 @cindex AI-0216 (Ada 2012 feature)
17798 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
17799 forbid tasks declared locally within subprograms, or functions returning task
17800 objects, and that is the implementation that GNAT has always provided.
17801 However the language in the RM was not sufficiently clear on this point.
17802 Thus this is a docmentation change in the RM only.
17805 RM References: D.07 (3/3)
17808 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
17809 @cindex AI-0211 (Ada 2012 feature)
17812 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
17813 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
17816 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
17819 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
17820 @cindex AI-0190 (Ada 2012 feature)
17823 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
17824 used to control storage pools globally.
17825 In particular, you can force every access
17826 type that is used for allocation (@b{new}) to have an explicit storage pool,
17827 or you can declare a pool globally to be used for all access types that lack
17831 RM References: D.07 (8)
17834 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
17835 @cindex AI-0189 (Ada 2012 feature)
17838 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
17839 which says that no dynamic allocation will occur once elaboration is
17841 In general this requires a run-time check, which is not required, and which
17842 GNAT does not attempt. But the static cases of allocators in a task body or
17843 in the body of the main program are detected and flagged at compile or bind
17847 RM References: D.07 (19.1/2) H.04 (23.3/2)
17850 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
17851 @cindex AI-0171 (Ada 2012 feature)
17854 A new package @code{System.Multiprocessors} is added, together with the
17855 definition of pragma @code{CPU} for controlling task affinity. A new no
17856 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
17857 is added to the Ravenscar profile.
17860 RM References: D.13.01 (4/2) D.16
17864 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
17865 @cindex AI-0210 (Ada 2012 feature)
17868 This is a documentation only issue regarding wording of metric requirements,
17869 that does not affect the implementation of the compiler.
17872 RM References: D.15 (24/2)
17876 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
17877 @cindex AI-0206 (Ada 2012 feature)
17880 Remote types packages are now allowed to depend on preelaborated packages.
17881 This was formerly considered illegal.
17884 RM References: E.02.02 (6)
17889 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
17890 @cindex AI-0152 (Ada 2012 feature)
17893 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
17894 where the type of the returned value is an anonymous access type.
17897 RM References: H.04 (8/1)
17901 @node Obsolescent Features
17902 @chapter Obsolescent Features
17905 This chapter describes features that are provided by GNAT, but are
17906 considered obsolescent since there are preferred ways of achieving
17907 the same effect. These features are provided solely for historical
17908 compatibility purposes.
17911 * pragma No_Run_Time::
17912 * pragma Ravenscar::
17913 * pragma Restricted_Run_Time::
17916 @node pragma No_Run_Time
17917 @section pragma No_Run_Time
17919 The pragma @code{No_Run_Time} is used to achieve an affect similar
17920 to the use of the "Zero Foot Print" configurable run time, but without
17921 requiring a specially configured run time. The result of using this
17922 pragma, which must be used for all units in a partition, is to restrict
17923 the use of any language features requiring run-time support code. The
17924 preferred usage is to use an appropriately configured run-time that
17925 includes just those features that are to be made accessible.
17927 @node pragma Ravenscar
17928 @section pragma Ravenscar
17930 The pragma @code{Ravenscar} has exactly the same effect as pragma
17931 @code{Profile (Ravenscar)}. The latter usage is preferred since it
17932 is part of the new Ada 2005 standard.
17934 @node pragma Restricted_Run_Time
17935 @section pragma Restricted_Run_Time
17937 The pragma @code{Restricted_Run_Time} has exactly the same effect as
17938 pragma @code{Profile (Restricted)}. The latter usage is
17939 preferred since the Ada 2005 pragma @code{Profile} is intended for
17940 this kind of implementation dependent addition.
17943 @c GNU Free Documentation License
17945 @node Index,,GNU Free Documentation License, Top